From a7690e7cdde7f35cfce69a056ea246136c2e93d4 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Mon, 21 Nov 2022 21:56:50 -0500 Subject: [PATCH 1/4] Only generate citro3d-specific types/funcs, etc. --- citro3d-sys/Cargo.toml | 1 + citro3d-sys/bindgen.sh | 19 +- citro3d-sys/src/bindings.rs | 1295 ++++++++++++++--------------------- citro3d-sys/src/gx.rs | 2 +- citro3d-sys/src/texenv.rs | 1 + citro3d-sys/src/uniforms.rs | 4 +- 6 files changed, 521 insertions(+), 801 deletions(-) diff --git a/citro3d-sys/Cargo.toml b/citro3d-sys/Cargo.toml index 29379ee..4c5a246 100644 --- a/citro3d-sys/Cargo.toml +++ b/citro3d-sys/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" [dependencies] libc = "0.2.116" +ctru-sys = { git = "https://github.com/rust3ds/ctru-rs.git" } diff --git a/citro3d-sys/bindgen.sh b/citro3d-sys/bindgen.sh index ac378f0..ebede4c 100755 --- a/citro3d-sys/bindgen.sh +++ b/citro3d-sys/bindgen.sh @@ -2,7 +2,7 @@ set -euxo pipefail -bindgen "$DEVKITPRO/libctru/include/citro3d.h" \ +bindgen "$DEVKITPRO/libctru/include/tex3ds.h" \ --rust-target nightly \ --use-core \ --distrust-clang-mangling \ @@ -10,26 +10,15 @@ bindgen "$DEVKITPRO/libctru/include/citro3d.h" \ --ctypes-prefix "::libc" \ --no-prepend-enum-name \ --fit-macro-constant-types \ + --raw-line "use ctru_sys::*;" \ --must-use-type "Result" \ --generate "functions,types,vars" \ --blocklist-type "u(8|16|32|64)" \ --opaque-type "GPU_.*" \ --opaque-type "GFX_.*" \ --opaque-type "float24Uniform_s" \ - --allowlist-type "C3D_.*" \ - --allowlist-type "DVLB_.*" \ - --allowlist-type "shader.*" \ - --allowlist-type "float24Uniform_s" \ - --allowlist-function "C3D_.*" \ - --allowlist-function "shader.*" \ - --allowlist-function "DVLB_.*" \ - --allowlist-function "linear.*" \ - --allowlist-var "C3D_.*" \ - --allowlist-type "GPU_.*" \ - --allowlist-type "GX_.*" \ - --allowlist-function 'AttrInfo_(Init|AddLoader|AddFixed)' \ - --allowlist-function 'BufInfo_(Init|Add)' \ - --allowlist-function 'Mtx_.*' \ + --allowlist-file ".*/c3d/.*[.]h" \ + --allowlist-file ".*/tex3ds[.]h" \ -- \ --target=arm-none-eabi \ --sysroot=$DEVKITARM/arm-none-eabi \ diff --git a/citro3d-sys/src/bindings.rs b/citro3d-sys/src/bindings.rs index 862e4d8..0f750e1 100644 --- a/citro3d-sys/src/bindings.rs +++ b/citro3d-sys/src/bindings.rs @@ -1,4 +1,6 @@ -/* automatically generated by rust-bindgen 0.60.1 */ +/* automatically generated by rust-bindgen 0.62.0 */ + +use ctru_sys::*; #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -80,26 +82,29 @@ where } } } +pub const M_TAU: f64 = 6.283185307179586; pub const C3D_AspectRatioTop: f64 = 1.6666666666666667; pub const C3D_AspectRatioBot: f64 = 1.3333333333333333; pub const C3D_MTXSTACK_SIZE: u8 = 8; pub const C3D_FVUNIF_COUNT: u8 = 96; pub const C3D_IVUNIF_COUNT: u8 = 4; pub const C3D_DEFAULT_CMDBUF_SIZE: u32 = 262144; -pub type __int8_t = ::libc::c_schar; -pub type __uint8_t = ::libc::c_uchar; -pub type __uint16_t = ::libc::c_ushort; -pub type __int32_t = ::libc::c_int; -pub type __uint32_t = ::libc::c_uint; -pub type __uint64_t = ::libc::c_ulonglong; -pub type size_t = ::libc::c_uint; +pub const C3DF_LightEnv_IsCP_Any: u32 = 66846720; +pub const C3DF_LightEnv_LutDirtyAll: u32 = 4227858432; +pub type __int64_t = ::libc::c_longlong; pub type u8_ = u8; pub type u16_ = u16; pub type u32_ = u32; pub type u64_ = u64; -pub type s8 = i8; -pub type s32 = i32; -pub type Result = s32; +pub type _LOCK_T = i32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __lock_t { + pub lock: _LOCK_T, + pub thread_tag: u32, + pub counter: u32, +} +pub type _LOCK_RECURSIVE_T = __lock_t; #[doc = "< Top screen"] pub const GFX_TOP: gfxScreen_t = 0; #[doc = "< Bottom screen"] @@ -115,644 +120,209 @@ pub const GFX_RIGHT: gfx3dSide_t = 1; #[doc = " This is only meaningful when stereoscopic 3D is enabled on the top screen."] #[doc = " In any other case, use \\ref GFX_LEFT."] pub type gfx3dSide_t = ::libc::c_uint; -extern "C" { - #[doc = " @brief Allocates a 0x80-byte aligned buffer."] - #[doc = " @param size Size of the buffer to allocate."] - #[doc = " @return The allocated buffer."] - pub fn linearAlloc(size: size_t) -> *mut ::libc::c_void; -} -extern "C" { - #[doc = " @brief Allocates a buffer aligned to the given size."] - #[doc = " @param size Size of the buffer to allocate."] - #[doc = " @param alignment Alignment to use."] - #[doc = " @return The allocated buffer."] - pub fn linearMemAlign(size: size_t, alignment: size_t) -> *mut ::libc::c_void; -} -extern "C" { - #[doc = " @brief Reallocates a buffer."] - #[doc = " Note: Not implemented yet."] - #[doc = " @param mem Buffer to reallocate."] - #[doc = " @param size Size of the buffer to allocate."] - #[doc = " @return The reallocated buffer."] - pub fn linearRealloc(mem: *mut ::libc::c_void, size: size_t) -> *mut ::libc::c_void; -} -extern "C" { - #[doc = " @brief Retrieves the allocated size of a buffer."] - #[doc = " @return The size of the buffer."] - pub fn linearGetSize(mem: *mut ::libc::c_void) -> size_t; -} -extern "C" { - #[doc = " @brief Frees a buffer."] - #[doc = " @param mem Buffer to free."] - pub fn linearFree(mem: *mut ::libc::c_void); -} -extern "C" { - #[doc = " @brief Gets the current linear free space."] - #[doc = " @return The current linear free space."] - pub fn linearSpaceFree() -> u32_; -} -#[doc = "< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha"] -pub const GX_TRANSFER_FMT_RGBA8: GX_TRANSFER_FORMAT = 0; -#[doc = "< 8-bit Red + 8-bit Green + 8-bit Blue"] -pub const GX_TRANSFER_FMT_RGB8: GX_TRANSFER_FORMAT = 1; -#[doc = "< 5-bit Red + 6-bit Green + 5-bit Blue"] -pub const GX_TRANSFER_FMT_RGB565: GX_TRANSFER_FORMAT = 2; -#[doc = "< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha"] -pub const GX_TRANSFER_FMT_RGB5A1: GX_TRANSFER_FORMAT = 3; -#[doc = "< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha"] -pub const GX_TRANSFER_FMT_RGBA4: GX_TRANSFER_FORMAT = 4; -#[doc = " @brief Supported transfer pixel formats."] -#[doc = " @sa GSPGPU_FramebufferFormat"] -pub type GX_TRANSFER_FORMAT = ::libc::c_uint; -#[doc = "< No anti-aliasing"] -pub const GX_TRANSFER_SCALE_NO: GX_TRANSFER_SCALE = 0; -#[doc = "< 2x1 anti-aliasing"] -pub const GX_TRANSFER_SCALE_X: GX_TRANSFER_SCALE = 1; -#[doc = "< 2x2 anti-aliasing"] -pub const GX_TRANSFER_SCALE_XY: GX_TRANSFER_SCALE = 2; -#[doc = " @brief Anti-aliasing modes"] -#[doc = ""] -#[doc = " Please remember that the framebuffer is sideways."] -#[doc = " Hence if you activate 2x1 anti-aliasing the destination dimensions are w = 240*2 and h = 400"] -pub type GX_TRANSFER_SCALE = ::libc::c_uint; -#[doc = "< Trigger the PPF event"] -pub const GX_FILL_TRIGGER: GX_FILL_CONTROL = 1; -#[doc = "< Indicates if the memory fill is complete. You should not use it when requesting a transfer."] -pub const GX_FILL_FINISHED: GX_FILL_CONTROL = 2; -#[doc = "< The buffer has a 16 bit per pixel depth"] -pub const GX_FILL_16BIT_DEPTH: GX_FILL_CONTROL = 0; -#[doc = "< The buffer has a 24 bit per pixel depth"] -pub const GX_FILL_24BIT_DEPTH: GX_FILL_CONTROL = 256; -#[doc = "< The buffer has a 32 bit per pixel depth"] -pub const GX_FILL_32BIT_DEPTH: GX_FILL_CONTROL = 512; -#[doc = " GX transfer control flags"] -pub type GX_FILL_CONTROL = ::libc::c_uint; -#[doc = "< Nearest-neighbor interpolation."] -pub const GPU_NEAREST: GPU_TEXTURE_FILTER_PARAM = 0; -#[doc = "< Linear interpolation."] -pub const GPU_LINEAR: GPU_TEXTURE_FILTER_PARAM = 1; -#[doc = " Texture filters."] -pub type GPU_TEXTURE_FILTER_PARAM = ::libc::c_uint; -#[doc = "< Clamps to edge."] -pub const GPU_CLAMP_TO_EDGE: GPU_TEXTURE_WRAP_PARAM = 0; -#[doc = "< Clamps to border."] -pub const GPU_CLAMP_TO_BORDER: GPU_TEXTURE_WRAP_PARAM = 1; -#[doc = "< Repeats texture."] -pub const GPU_REPEAT: GPU_TEXTURE_WRAP_PARAM = 2; -#[doc = "< Repeats with mirrored texture."] -pub const GPU_MIRRORED_REPEAT: GPU_TEXTURE_WRAP_PARAM = 3; -#[doc = " Texture wrap modes."] -pub type GPU_TEXTURE_WRAP_PARAM = ::libc::c_uint; -#[doc = "< 2D texture"] -pub const GPU_TEX_2D: GPU_TEXTURE_MODE_PARAM = 0; -#[doc = "< Cube map"] -pub const GPU_TEX_CUBE_MAP: GPU_TEXTURE_MODE_PARAM = 1; -#[doc = "< 2D Shadow texture"] -pub const GPU_TEX_SHADOW_2D: GPU_TEXTURE_MODE_PARAM = 2; -#[doc = "< Projection texture"] -pub const GPU_TEX_PROJECTION: GPU_TEXTURE_MODE_PARAM = 3; -#[doc = "< Shadow cube map"] -pub const GPU_TEX_SHADOW_CUBE: GPU_TEXTURE_MODE_PARAM = 4; -#[doc = "< Disabled"] -pub const GPU_TEX_DISABLED: GPU_TEXTURE_MODE_PARAM = 5; -#[doc = " Texture modes."] -pub type GPU_TEXTURE_MODE_PARAM = ::libc::c_uint; -#[doc = "< Texture unit 0."] -pub const GPU_TEXUNIT0: GPU_TEXUNIT = 1; -#[doc = "< Texture unit 1."] -pub const GPU_TEXUNIT1: GPU_TEXUNIT = 2; -#[doc = "< Texture unit 2."] -pub const GPU_TEXUNIT2: GPU_TEXUNIT = 4; -#[doc = " Supported texture units."] -pub type GPU_TEXUNIT = ::libc::c_uint; -#[doc = "< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha"] -pub const GPU_RGBA8: GPU_TEXCOLOR = 0; -#[doc = "< 8-bit Red + 8-bit Green + 8-bit Blue"] -pub const GPU_RGB8: GPU_TEXCOLOR = 1; -#[doc = "< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha"] -pub const GPU_RGBA5551: GPU_TEXCOLOR = 2; -#[doc = "< 5-bit Red + 6-bit Green + 5-bit Blue"] -pub const GPU_RGB565: GPU_TEXCOLOR = 3; -#[doc = "< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha"] -pub const GPU_RGBA4: GPU_TEXCOLOR = 4; -#[doc = "< 8-bit Luminance + 8-bit Alpha"] -pub const GPU_LA8: GPU_TEXCOLOR = 5; -#[doc = "< 8-bit Hi + 8-bit Lo"] -pub const GPU_HILO8: GPU_TEXCOLOR = 6; -#[doc = "< 8-bit Luminance"] -pub const GPU_L8: GPU_TEXCOLOR = 7; -#[doc = "< 8-bit Alpha"] -pub const GPU_A8: GPU_TEXCOLOR = 8; -#[doc = "< 4-bit Luminance + 4-bit Alpha"] -pub const GPU_LA4: GPU_TEXCOLOR = 9; -#[doc = "< 4-bit Luminance"] -pub const GPU_L4: GPU_TEXCOLOR = 10; -#[doc = "< 4-bit Alpha"] -pub const GPU_A4: GPU_TEXCOLOR = 11; -#[doc = "< ETC1 texture compression"] -pub const GPU_ETC1: GPU_TEXCOLOR = 12; -#[doc = "< ETC1 texture compression + 4-bit Alpha"] -pub const GPU_ETC1A4: GPU_TEXCOLOR = 13; -#[doc = " Supported texture formats."] -pub type GPU_TEXCOLOR = ::libc::c_uint; -#[doc = "< 2D face"] -pub const GPU_TEXFACE_2D: GPU_TEXFACE = 0; -#[doc = "< +X face"] -pub const GPU_POSITIVE_X: GPU_TEXFACE = 0; -#[doc = "< -X face"] -pub const GPU_NEGATIVE_X: GPU_TEXFACE = 1; -#[doc = "< +Y face"] -pub const GPU_POSITIVE_Y: GPU_TEXFACE = 2; -#[doc = "< -Y face"] -pub const GPU_NEGATIVE_Y: GPU_TEXFACE = 3; -#[doc = "< +Z face"] -pub const GPU_POSITIVE_Z: GPU_TEXFACE = 4; -#[doc = "< -Z face"] -pub const GPU_NEGATIVE_Z: GPU_TEXFACE = 5; -#[doc = " Texture faces."] -pub type GPU_TEXFACE = ::libc::c_uint; -#[doc = "< Clamp to zero."] -pub const GPU_PT_CLAMP_TO_ZERO: GPU_PROCTEX_CLAMP = 0; -#[doc = "< Clamp to edge."] -pub const GPU_PT_CLAMP_TO_EDGE: GPU_PROCTEX_CLAMP = 1; -#[doc = "< Symmetrical repeat."] -pub const GPU_PT_REPEAT: GPU_PROCTEX_CLAMP = 2; -#[doc = "< Mirrored repeat."] -pub const GPU_PT_MIRRORED_REPEAT: GPU_PROCTEX_CLAMP = 3; -#[doc = "< Pulse."] -pub const GPU_PT_PULSE: GPU_PROCTEX_CLAMP = 4; -#[doc = " Procedural texture clamp modes."] -pub type GPU_PROCTEX_CLAMP = ::libc::c_uint; -#[doc = "< U"] -pub const GPU_PT_U: GPU_PROCTEX_MAPFUNC = 0; -#[doc = "< U2"] -pub const GPU_PT_U2: GPU_PROCTEX_MAPFUNC = 1; -#[doc = "< V"] -pub const GPU_PT_V: GPU_PROCTEX_MAPFUNC = 2; -#[doc = "< V2"] -pub const GPU_PT_V2: GPU_PROCTEX_MAPFUNC = 3; -#[doc = "< U+V"] -pub const GPU_PT_ADD: GPU_PROCTEX_MAPFUNC = 4; -#[doc = "< U2+V2"] -pub const GPU_PT_ADD2: GPU_PROCTEX_MAPFUNC = 5; -#[doc = "< sqrt(U2+V2)"] -pub const GPU_PT_SQRT2: GPU_PROCTEX_MAPFUNC = 6; -#[doc = "< min"] -pub const GPU_PT_MIN: GPU_PROCTEX_MAPFUNC = 7; -#[doc = "< max"] -pub const GPU_PT_MAX: GPU_PROCTEX_MAPFUNC = 8; -#[doc = "< rmax"] -pub const GPU_PT_RMAX: GPU_PROCTEX_MAPFUNC = 9; -#[doc = " Procedural texture mapping functions."] -pub type GPU_PROCTEX_MAPFUNC = ::libc::c_uint; -#[doc = "< No shift."] -pub const GPU_PT_NONE: GPU_PROCTEX_SHIFT = 0; -#[doc = "< Odd shift."] -pub const GPU_PT_ODD: GPU_PROCTEX_SHIFT = 1; -#[doc = "< Even shift."] -pub const GPU_PT_EVEN: GPU_PROCTEX_SHIFT = 2; -#[doc = " Procedural texture shift values."] -pub type GPU_PROCTEX_SHIFT = ::libc::c_uint; -#[doc = "< Nearest-neighbor"] -pub const GPU_PT_NEAREST: GPU_PROCTEX_FILTER = 0; -#[doc = "< Linear interpolation"] -pub const GPU_PT_LINEAR: GPU_PROCTEX_FILTER = 1; -#[doc = "< Nearest-neighbor with mipmap using nearest-neighbor"] -pub const GPU_PT_NEAREST_MIP_NEAREST: GPU_PROCTEX_FILTER = 2; -#[doc = "< Linear interpolation with mipmap using nearest-neighbor"] -pub const GPU_PT_LINEAR_MIP_NEAREST: GPU_PROCTEX_FILTER = 3; -#[doc = "< Nearest-neighbor with mipmap using linear interpolation"] -pub const GPU_PT_NEAREST_MIP_LINEAR: GPU_PROCTEX_FILTER = 4; -#[doc = "< Linear interpolation with mipmap using linear interpolation"] -pub const GPU_PT_LINEAR_MIP_LINEAR: GPU_PROCTEX_FILTER = 5; -#[doc = " Procedural texture filter values."] -pub type GPU_PROCTEX_FILTER = ::libc::c_uint; -#[doc = "< Noise table"] -pub const GPU_LUT_NOISE: GPU_PROCTEX_LUTID = 0; -#[doc = "< RGB mapping function table"] -pub const GPU_LUT_RGBMAP: GPU_PROCTEX_LUTID = 2; -#[doc = "< Alpha mapping function table"] -pub const GPU_LUT_ALPHAMAP: GPU_PROCTEX_LUTID = 3; -#[doc = "< Color table"] -pub const GPU_LUT_COLOR: GPU_PROCTEX_LUTID = 4; -#[doc = "< Color difference table"] -pub const GPU_LUT_COLORDIF: GPU_PROCTEX_LUTID = 5; -#[doc = " Procedural texture LUT IDs."] -pub type GPU_PROCTEX_LUTID = ::libc::c_uint; -#[doc = "< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha"] -pub const GPU_RB_RGBA8: GPU_COLORBUF = 0; -#[doc = "< 8-bit Red + 8-bit Green + 8-bit Blue"] -pub const GPU_RB_RGB8: GPU_COLORBUF = 1; -#[doc = "< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha"] -pub const GPU_RB_RGBA5551: GPU_COLORBUF = 2; -#[doc = "< 5-bit Red + 6-bit Green + 5-bit Blue"] -pub const GPU_RB_RGB565: GPU_COLORBUF = 3; -#[doc = "< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha"] -pub const GPU_RB_RGBA4: GPU_COLORBUF = 4; -#[doc = " Supported color buffer formats."] -pub type GPU_COLORBUF = ::libc::c_uint; -#[doc = "< 16-bit Depth"] -pub const GPU_RB_DEPTH16: GPU_DEPTHBUF = 0; -#[doc = "< 24-bit Depth"] -pub const GPU_RB_DEPTH24: GPU_DEPTHBUF = 2; -#[doc = "< 24-bit Depth + 8-bit Stencil"] -pub const GPU_RB_DEPTH24_STENCIL8: GPU_DEPTHBUF = 3; -#[doc = " Supported depth buffer formats."] -pub type GPU_DEPTHBUF = ::libc::c_uint; -#[doc = "< Never pass."] -pub const GPU_NEVER: GPU_TESTFUNC = 0; -#[doc = "< Always pass."] -pub const GPU_ALWAYS: GPU_TESTFUNC = 1; -#[doc = "< Pass if equal."] -pub const GPU_EQUAL: GPU_TESTFUNC = 2; -#[doc = "< Pass if not equal."] -pub const GPU_NOTEQUAL: GPU_TESTFUNC = 3; -#[doc = "< Pass if less than."] -pub const GPU_LESS: GPU_TESTFUNC = 4; -#[doc = "< Pass if less than or equal."] -pub const GPU_LEQUAL: GPU_TESTFUNC = 5; -#[doc = "< Pass if greater than."] -pub const GPU_GREATER: GPU_TESTFUNC = 6; -#[doc = "< Pass if greater than or equal."] -pub const GPU_GEQUAL: GPU_TESTFUNC = 7; -#[doc = " Test functions."] -pub type GPU_TESTFUNC = ::libc::c_uint; -#[doc = "< Pass if greater than or equal."] -pub const GPU_EARLYDEPTH_GEQUAL: GPU_EARLYDEPTHFUNC = 0; -#[doc = "< Pass if greater than."] -pub const GPU_EARLYDEPTH_GREATER: GPU_EARLYDEPTHFUNC = 1; -#[doc = "< Pass if less than or equal."] -pub const GPU_EARLYDEPTH_LEQUAL: GPU_EARLYDEPTHFUNC = 2; -#[doc = "< Pass if less than."] -pub const GPU_EARLYDEPTH_LESS: GPU_EARLYDEPTHFUNC = 3; -#[doc = " Early depth test functions."] -pub type GPU_EARLYDEPTHFUNC = ::libc::c_uint; -#[doc = "< Never pass (0)."] -pub const GPU_GAS_NEVER: GPU_GASDEPTHFUNC = 0; -#[doc = "< Always pass (1)."] -pub const GPU_GAS_ALWAYS: GPU_GASDEPTHFUNC = 1; -#[doc = "< Pass if greater than (1-X)."] -pub const GPU_GAS_GREATER: GPU_GASDEPTHFUNC = 2; -#[doc = "< Pass if less than (X)."] -pub const GPU_GAS_LESS: GPU_GASDEPTHFUNC = 3; -#[doc = " Gas depth functions."] -pub type GPU_GASDEPTHFUNC = ::libc::c_uint; -#[doc = "< Disable."] -pub const GPU_SCISSOR_DISABLE: GPU_SCISSORMODE = 0; -#[doc = "< Exclude pixels inside the scissor box."] -pub const GPU_SCISSOR_INVERT: GPU_SCISSORMODE = 1; -#[doc = "< Exclude pixels outside of the scissor box."] -pub const GPU_SCISSOR_NORMAL: GPU_SCISSORMODE = 3; -#[doc = " Scissor test modes."] -pub type GPU_SCISSORMODE = ::libc::c_uint; -#[doc = "< Keep old value. (old_stencil)"] -pub const GPU_STENCIL_KEEP: GPU_STENCILOP = 0; -#[doc = "< Zero. (0)"] -pub const GPU_STENCIL_ZERO: GPU_STENCILOP = 1; -#[doc = "< Replace value. (ref)"] -pub const GPU_STENCIL_REPLACE: GPU_STENCILOP = 2; -#[doc = "< Increment value. (old_stencil + 1 saturated to [0, 255])"] -pub const GPU_STENCIL_INCR: GPU_STENCILOP = 3; -#[doc = "< Decrement value. (old_stencil - 1 saturated to [0, 255])"] -pub const GPU_STENCIL_DECR: GPU_STENCILOP = 4; -#[doc = "< Invert value. (~old_stencil)"] -pub const GPU_STENCIL_INVERT: GPU_STENCILOP = 5; -#[doc = "< Increment value. (old_stencil + 1)"] -pub const GPU_STENCIL_INCR_WRAP: GPU_STENCILOP = 6; -#[doc = "< Decrement value. (old_stencil - 1)"] -pub const GPU_STENCIL_DECR_WRAP: GPU_STENCILOP = 7; -#[doc = " Stencil operations."] -pub type GPU_STENCILOP = ::libc::c_uint; -#[doc = "< Write red."] -pub const GPU_WRITE_RED: GPU_WRITEMASK = 1; -#[doc = "< Write green."] -pub const GPU_WRITE_GREEN: GPU_WRITEMASK = 2; -#[doc = "< Write blue."] -pub const GPU_WRITE_BLUE: GPU_WRITEMASK = 4; -#[doc = "< Write alpha."] -pub const GPU_WRITE_ALPHA: GPU_WRITEMASK = 8; -#[doc = "< Write depth."] -pub const GPU_WRITE_DEPTH: GPU_WRITEMASK = 16; -#[doc = "< Write all color components."] -pub const GPU_WRITE_COLOR: GPU_WRITEMASK = 15; -#[doc = "< Write all components."] -pub const GPU_WRITE_ALL: GPU_WRITEMASK = 31; -#[doc = " Pixel write mask."] -pub type GPU_WRITEMASK = ::libc::c_uint; -#[doc = "< Add colors."] -pub const GPU_BLEND_ADD: GPU_BLENDEQUATION = 0; -#[doc = "< Subtract colors."] -pub const GPU_BLEND_SUBTRACT: GPU_BLENDEQUATION = 1; -#[doc = "< Reverse-subtract colors."] -pub const GPU_BLEND_REVERSE_SUBTRACT: GPU_BLENDEQUATION = 2; -#[doc = "< Use the minimum color."] -pub const GPU_BLEND_MIN: GPU_BLENDEQUATION = 3; -#[doc = "< Use the maximum color."] -pub const GPU_BLEND_MAX: GPU_BLENDEQUATION = 4; -#[doc = " Blend modes."] -pub type GPU_BLENDEQUATION = ::libc::c_uint; -#[doc = "< Zero."] -pub const GPU_ZERO: GPU_BLENDFACTOR = 0; -#[doc = "< One."] -pub const GPU_ONE: GPU_BLENDFACTOR = 1; -#[doc = "< Source color."] -pub const GPU_SRC_COLOR: GPU_BLENDFACTOR = 2; -#[doc = "< Source color - 1."] -pub const GPU_ONE_MINUS_SRC_COLOR: GPU_BLENDFACTOR = 3; -#[doc = "< Destination color."] -pub const GPU_DST_COLOR: GPU_BLENDFACTOR = 4; -#[doc = "< Destination color - 1."] -pub const GPU_ONE_MINUS_DST_COLOR: GPU_BLENDFACTOR = 5; -#[doc = "< Source alpha."] -pub const GPU_SRC_ALPHA: GPU_BLENDFACTOR = 6; -#[doc = "< Source alpha - 1."] -pub const GPU_ONE_MINUS_SRC_ALPHA: GPU_BLENDFACTOR = 7; -#[doc = "< Destination alpha."] -pub const GPU_DST_ALPHA: GPU_BLENDFACTOR = 8; -#[doc = "< Destination alpha - 1."] -pub const GPU_ONE_MINUS_DST_ALPHA: GPU_BLENDFACTOR = 9; -#[doc = "< Constant color."] -pub const GPU_CONSTANT_COLOR: GPU_BLENDFACTOR = 10; -#[doc = "< Constant color - 1."] -pub const GPU_ONE_MINUS_CONSTANT_COLOR: GPU_BLENDFACTOR = 11; -#[doc = "< Constant alpha."] -pub const GPU_CONSTANT_ALPHA: GPU_BLENDFACTOR = 12; -#[doc = "< Constant alpha - 1."] -pub const GPU_ONE_MINUS_CONSTANT_ALPHA: GPU_BLENDFACTOR = 13; -#[doc = "< Saturated alpha."] -pub const GPU_SRC_ALPHA_SATURATE: GPU_BLENDFACTOR = 14; -#[doc = " Blend factors."] -pub type GPU_BLENDFACTOR = ::libc::c_uint; -#[doc = "< Clear."] -pub const GPU_LOGICOP_CLEAR: GPU_LOGICOP = 0; -#[doc = "< Bitwise AND."] -pub const GPU_LOGICOP_AND: GPU_LOGICOP = 1; -#[doc = "< Reverse bitwise AND."] -pub const GPU_LOGICOP_AND_REVERSE: GPU_LOGICOP = 2; -#[doc = "< Copy."] -pub const GPU_LOGICOP_COPY: GPU_LOGICOP = 3; -#[doc = "< Set."] -pub const GPU_LOGICOP_SET: GPU_LOGICOP = 4; -#[doc = "< Inverted copy."] -pub const GPU_LOGICOP_COPY_INVERTED: GPU_LOGICOP = 5; -#[doc = "< No operation."] -pub const GPU_LOGICOP_NOOP: GPU_LOGICOP = 6; -#[doc = "< Invert."] -pub const GPU_LOGICOP_INVERT: GPU_LOGICOP = 7; -#[doc = "< Bitwise NAND."] -pub const GPU_LOGICOP_NAND: GPU_LOGICOP = 8; -#[doc = "< Bitwise OR."] -pub const GPU_LOGICOP_OR: GPU_LOGICOP = 9; -#[doc = "< Bitwise NOR."] -pub const GPU_LOGICOP_NOR: GPU_LOGICOP = 10; -#[doc = "< Bitwise XOR."] -pub const GPU_LOGICOP_XOR: GPU_LOGICOP = 11; -#[doc = "< Equivalent."] -pub const GPU_LOGICOP_EQUIV: GPU_LOGICOP = 12; -#[doc = "< Inverted bitwise AND."] -pub const GPU_LOGICOP_AND_INVERTED: GPU_LOGICOP = 13; -#[doc = "< Reverse bitwise OR."] -pub const GPU_LOGICOP_OR_REVERSE: GPU_LOGICOP = 14; -#[doc = "< Inverted bitwize OR."] -pub const GPU_LOGICOP_OR_INVERTED: GPU_LOGICOP = 15; -#[doc = " Logical operations."] -pub type GPU_LOGICOP = ::libc::c_uint; -#[doc = "< OpenGL mode."] -pub const GPU_FRAGOPMODE_GL: GPU_FRAGOPMODE = 0; -#[doc = "< Gas mode (?)."] -pub const GPU_FRAGOPMODE_GAS_ACC: GPU_FRAGOPMODE = 1; -#[doc = "< Shadow mode (?)."] -pub const GPU_FRAGOPMODE_SHADOW: GPU_FRAGOPMODE = 3; -#[doc = " Fragment operation modes."] -pub type GPU_FRAGOPMODE = ::libc::c_uint; -#[doc = "< 8-bit byte."] -pub const GPU_BYTE: GPU_FORMATS = 0; -#[doc = "< 8-bit unsigned byte."] -pub const GPU_UNSIGNED_BYTE: GPU_FORMATS = 1; -#[doc = "< 16-bit short."] -pub const GPU_SHORT: GPU_FORMATS = 2; -#[doc = "< 32-bit float."] -pub const GPU_FLOAT: GPU_FORMATS = 3; -#[doc = " Supported component formats."] -pub type GPU_FORMATS = ::libc::c_uint; -#[doc = "< Disabled."] -pub const GPU_CULL_NONE: GPU_CULLMODE = 0; -#[doc = "< Front, counter-clockwise."] -pub const GPU_CULL_FRONT_CCW: GPU_CULLMODE = 1; -#[doc = "< Back, counter-clockwise."] -pub const GPU_CULL_BACK_CCW: GPU_CULLMODE = 2; -#[doc = " Cull modes."] -pub type GPU_CULLMODE = ::libc::c_uint; -#[doc = "< Primary color."] -pub const GPU_PRIMARY_COLOR: GPU_TEVSRC = 0; -#[doc = "< Primary fragment color."] -pub const GPU_FRAGMENT_PRIMARY_COLOR: GPU_TEVSRC = 1; -#[doc = "< Secondary fragment color."] -pub const GPU_FRAGMENT_SECONDARY_COLOR: GPU_TEVSRC = 2; -#[doc = "< Texture unit 0."] -pub const GPU_TEXTURE0: GPU_TEVSRC = 3; -#[doc = "< Texture unit 1."] -pub const GPU_TEXTURE1: GPU_TEVSRC = 4; -#[doc = "< Texture unit 2."] -pub const GPU_TEXTURE2: GPU_TEVSRC = 5; -#[doc = "< Texture unit 3."] -pub const GPU_TEXTURE3: GPU_TEVSRC = 6; -#[doc = "< Previous buffer."] -pub const GPU_PREVIOUS_BUFFER: GPU_TEVSRC = 13; -#[doc = "< Constant value."] -pub const GPU_CONSTANT: GPU_TEVSRC = 14; -#[doc = "< Previous value."] -pub const GPU_PREVIOUS: GPU_TEVSRC = 15; -#[doc = " Texture combiner sources."] -pub type GPU_TEVSRC = ::libc::c_uint; -#[doc = "< Source color."] -pub const GPU_TEVOP_RGB_SRC_COLOR: GPU_TEVOP_RGB = 0; -#[doc = "< Source color - 1."] -pub const GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR: GPU_TEVOP_RGB = 1; -#[doc = "< Source alpha."] -pub const GPU_TEVOP_RGB_SRC_ALPHA: GPU_TEVOP_RGB = 2; -#[doc = "< Source alpha - 1."] -pub const GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA: GPU_TEVOP_RGB = 3; -#[doc = "< Source red."] -pub const GPU_TEVOP_RGB_SRC_R: GPU_TEVOP_RGB = 4; -#[doc = "< Source red - 1."] -pub const GPU_TEVOP_RGB_ONE_MINUS_SRC_R: GPU_TEVOP_RGB = 5; -#[doc = "< Unknown."] -pub const GPU_TEVOP_RGB_0x06: GPU_TEVOP_RGB = 6; -#[doc = "< Unknown."] -pub const GPU_TEVOP_RGB_0x07: GPU_TEVOP_RGB = 7; -#[doc = "< Source green."] -pub const GPU_TEVOP_RGB_SRC_G: GPU_TEVOP_RGB = 8; -#[doc = "< Source green - 1."] -pub const GPU_TEVOP_RGB_ONE_MINUS_SRC_G: GPU_TEVOP_RGB = 9; -#[doc = "< Unknown."] -pub const GPU_TEVOP_RGB_0x0A: GPU_TEVOP_RGB = 10; -#[doc = "< Unknown."] -pub const GPU_TEVOP_RGB_0x0B: GPU_TEVOP_RGB = 11; -#[doc = "< Source blue."] -pub const GPU_TEVOP_RGB_SRC_B: GPU_TEVOP_RGB = 12; -#[doc = "< Source blue - 1."] -pub const GPU_TEVOP_RGB_ONE_MINUS_SRC_B: GPU_TEVOP_RGB = 13; -#[doc = "< Unknown."] -pub const GPU_TEVOP_RGB_0x0E: GPU_TEVOP_RGB = 14; -#[doc = "< Unknown."] -pub const GPU_TEVOP_RGB_0x0F: GPU_TEVOP_RGB = 15; -#[doc = " Texture RGB combiner operands."] -pub type GPU_TEVOP_RGB = ::libc::c_uint; -#[doc = "< Source alpha."] -pub const GPU_TEVOP_A_SRC_ALPHA: GPU_TEVOP_A = 0; -#[doc = "< Source alpha - 1."] -pub const GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA: GPU_TEVOP_A = 1; -#[doc = "< Source red."] -pub const GPU_TEVOP_A_SRC_R: GPU_TEVOP_A = 2; -#[doc = "< Source red - 1."] -pub const GPU_TEVOP_A_ONE_MINUS_SRC_R: GPU_TEVOP_A = 3; -#[doc = "< Source green."] -pub const GPU_TEVOP_A_SRC_G: GPU_TEVOP_A = 4; -#[doc = "< Source green - 1."] -pub const GPU_TEVOP_A_ONE_MINUS_SRC_G: GPU_TEVOP_A = 5; -#[doc = "< Source blue."] -pub const GPU_TEVOP_A_SRC_B: GPU_TEVOP_A = 6; -#[doc = "< Source blue - 1."] -pub const GPU_TEVOP_A_ONE_MINUS_SRC_B: GPU_TEVOP_A = 7; -#[doc = " Texture Alpha combiner operands."] -pub type GPU_TEVOP_A = ::libc::c_uint; -#[doc = "< Replace."] -pub const GPU_REPLACE: GPU_COMBINEFUNC = 0; -#[doc = "< Modulate."] -pub const GPU_MODULATE: GPU_COMBINEFUNC = 1; -#[doc = "< Add."] -pub const GPU_ADD: GPU_COMBINEFUNC = 2; -#[doc = "< Signed add."] -pub const GPU_ADD_SIGNED: GPU_COMBINEFUNC = 3; -#[doc = "< Interpolate."] -pub const GPU_INTERPOLATE: GPU_COMBINEFUNC = 4; -#[doc = "< Subtract."] -pub const GPU_SUBTRACT: GPU_COMBINEFUNC = 5; -#[doc = "< Dot3. RGB only."] -pub const GPU_DOT3_RGB: GPU_COMBINEFUNC = 6; -#[doc = "< Multiply then add."] -pub const GPU_MULTIPLY_ADD: GPU_COMBINEFUNC = 8; -#[doc = "< Add then multiply."] -pub const GPU_ADD_MULTIPLY: GPU_COMBINEFUNC = 9; -#[doc = " Texture combiner functions."] -pub type GPU_COMBINEFUNC = ::libc::c_uint; -#[doc = "< 1x"] -pub const GPU_TEVSCALE_1: GPU_TEVSCALE = 0; -#[doc = "< 2x"] -pub const GPU_TEVSCALE_2: GPU_TEVSCALE = 1; -#[doc = "< 4x"] -pub const GPU_TEVSCALE_4: GPU_TEVSCALE = 2; -#[doc = " Texture scale factors."] -pub type GPU_TEVSCALE = ::libc::c_uint; -#[doc = "< None."] -pub const GPU_NO_FRESNEL: GPU_FRESNELSEL = 0; -#[doc = "< Primary alpha."] -pub const GPU_PRI_ALPHA_FRESNEL: GPU_FRESNELSEL = 1; -#[doc = "< Secondary alpha."] -pub const GPU_SEC_ALPHA_FRESNEL: GPU_FRESNELSEL = 2; -#[doc = "< Primary and secondary alpha."] -pub const GPU_PRI_SEC_ALPHA_FRESNEL: GPU_FRESNELSEL = 3; -#[doc = " Fresnel options."] -pub type GPU_FRESNELSEL = ::libc::c_uint; -#[doc = "< Disabled."] -pub const GPU_BUMP_NOT_USED: GPU_BUMPMODE = 0; -#[doc = "< Bump as bump mapping."] -pub const GPU_BUMP_AS_BUMP: GPU_BUMPMODE = 1; -#[doc = "< Bump as tangent/normal mapping."] -pub const GPU_BUMP_AS_TANG: GPU_BUMPMODE = 2; -#[doc = " Bump map modes."] -pub type GPU_BUMPMODE = ::libc::c_uint; -#[doc = "< D0 LUT."] -pub const GPU_LUT_D0: GPU_LIGHTLUTID = 0; -#[doc = "< D1 LUT."] -pub const GPU_LUT_D1: GPU_LIGHTLUTID = 1; -#[doc = "< Spotlight LUT."] -pub const GPU_LUT_SP: GPU_LIGHTLUTID = 2; -#[doc = "< Fresnel LUT."] -pub const GPU_LUT_FR: GPU_LIGHTLUTID = 3; -#[doc = "< Reflection-Blue LUT."] -pub const GPU_LUT_RB: GPU_LIGHTLUTID = 4; -#[doc = "< Reflection-Green LUT."] -pub const GPU_LUT_RG: GPU_LIGHTLUTID = 5; -#[doc = "< Reflection-Red LUT."] -pub const GPU_LUT_RR: GPU_LIGHTLUTID = 6; -#[doc = "< Distance attenuation LUT."] -pub const GPU_LUT_DA: GPU_LIGHTLUTID = 7; -#[doc = " LUT IDs."] -pub type GPU_LIGHTLUTID = ::libc::c_uint; -#[doc = "< Normal*HalfVector"] -pub const GPU_LUTINPUT_NH: GPU_LIGHTLUTINPUT = 0; -#[doc = "< View*HalfVector"] -pub const GPU_LUTINPUT_VH: GPU_LIGHTLUTINPUT = 1; -#[doc = "< Normal*View"] -pub const GPU_LUTINPUT_NV: GPU_LIGHTLUTINPUT = 2; -#[doc = "< LightVector*Normal"] -pub const GPU_LUTINPUT_LN: GPU_LIGHTLUTINPUT = 3; -#[doc = "< -LightVector*SpotlightVector"] -pub const GPU_LUTINPUT_SP: GPU_LIGHTLUTINPUT = 4; -#[doc = "< cosine of phi"] -pub const GPU_LUTINPUT_CP: GPU_LIGHTLUTINPUT = 5; -#[doc = " LUT inputs."] -pub type GPU_LIGHTLUTINPUT = ::libc::c_uint; -#[doc = "< 1x scale."] -pub const GPU_LUTSCALER_1x: GPU_LIGHTLUTSCALER = 0; -#[doc = "< 2x scale."] -pub const GPU_LUTSCALER_2x: GPU_LIGHTLUTSCALER = 1; -#[doc = "< 4x scale."] -pub const GPU_LUTSCALER_4x: GPU_LIGHTLUTSCALER = 2; -#[doc = "< 8x scale."] -pub const GPU_LUTSCALER_8x: GPU_LIGHTLUTSCALER = 3; -#[doc = "< 0.25x scale."] -pub const GPU_LUTSCALER_0_25x: GPU_LIGHTLUTSCALER = 6; -#[doc = "< 0.5x scale."] -pub const GPU_LUTSCALER_0_5x: GPU_LIGHTLUTSCALER = 7; -#[doc = " LUT scalers."] -pub type GPU_LIGHTLUTSCALER = ::libc::c_uint; -#[doc = "< LUTs that are common to all lights."] -pub const GPU_LUTSELECT_COMMON: GPU_LIGHTLUTSELECT = 0; -#[doc = "< Spotlight LUT."] -pub const GPU_LUTSELECT_SP: GPU_LIGHTLUTSELECT = 1; -#[doc = "< Distance attenuation LUT."] -pub const GPU_LUTSELECT_DA: GPU_LIGHTLUTSELECT = 2; -#[doc = " LUT selection."] -pub type GPU_LIGHTLUTSELECT = ::libc::c_uint; -#[doc = "< Fog/Gas unit disabled."] -pub const GPU_NO_FOG: GPU_FOGMODE = 0; -#[doc = "< Fog/Gas unit configured in Fog mode."] -pub const GPU_FOG: GPU_FOGMODE = 5; -#[doc = "< Fog/Gas unit configured in Gas mode."] -pub const GPU_GAS: GPU_FOGMODE = 7; -#[doc = " Fog modes."] -pub type GPU_FOGMODE = ::libc::c_uint; -#[doc = "< Plain density."] -pub const GPU_PLAIN_DENSITY: GPU_GASMODE = 0; -#[doc = "< Depth density."] -pub const GPU_DEPTH_DENSITY: GPU_GASMODE = 1; -#[doc = " Gas shading density source values."] -pub type GPU_GASMODE = ::libc::c_uint; -#[doc = "< Gas density used as input."] -pub const GPU_GAS_DENSITY: GPU_GASLUTINPUT = 0; -#[doc = "< Light factor used as input."] -pub const GPU_GAS_LIGHT_FACTOR: GPU_GASLUTINPUT = 1; -#[doc = " Gas color LUT inputs."] -pub type GPU_GASLUTINPUT = ::libc::c_uint; -#[doc = "< Triangles."] -pub const GPU_TRIANGLES: GPU_Primitive_t = 0; -#[doc = "< Triangle strip."] -pub const GPU_TRIANGLE_STRIP: GPU_Primitive_t = 256; -#[doc = "< Triangle fan."] -pub const GPU_TRIANGLE_FAN: GPU_Primitive_t = 512; -#[doc = "< Geometry shader primitive."] -pub const GPU_GEOMETRY_PRIM: GPU_Primitive_t = 768; -#[doc = " Supported primitives."] -pub type GPU_Primitive_t = ::libc::c_uint; -#[doc = "< Vertex shader."] -pub const GPU_VERTEX_SHADER: GPU_SHADER_TYPE = 0; -#[doc = "< Geometry shader."] -pub const GPU_GEOMETRY_SHADER: GPU_SHADER_TYPE = 1; -#[doc = " Shader types."] -pub type GPU_SHADER_TYPE = ::libc::c_uint; +pub type _off_t = __int64_t; +pub type _fpos_t = __int64_t; +pub type wint_t = ::libc::c_int; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _mbstate_t { + pub __count: ::libc::c_int, + pub __value: _mbstate_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _mbstate_t__bindgen_ty_1 { + pub __wch: wint_t, + pub __wchb: [::libc::c_uchar; 4usize], +} +#[doc = " @brief Data callback"] +pub type decompressCallback = ::core::option::Option< + unsafe extern "C" fn( + userdata: *mut ::libc::c_void, + buffer: *mut ::libc::c_void, + size: usize, + ) -> isize, +>; +pub type __ULong = ::libc::c_ulong; +pub type _flock_t = _LOCK_RECURSIVE_T; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_t { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Bigint { + pub _next: *mut _Bigint, + pub _k: ::libc::c_int, + pub _maxwds: ::libc::c_int, + pub _sign: ::libc::c_int, + pub _wds: ::libc::c_int, + pub _x: [__ULong; 1usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __tm { + pub __tm_sec: ::libc::c_int, + pub __tm_min: ::libc::c_int, + pub __tm_hour: ::libc::c_int, + pub __tm_mday: ::libc::c_int, + pub __tm_mon: ::libc::c_int, + pub __tm_year: ::libc::c_int, + pub __tm_wday: ::libc::c_int, + pub __tm_yday: ::libc::c_int, + pub __tm_isdst: ::libc::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _on_exit_args { + pub _fnargs: [*mut ::libc::c_void; 32usize], + pub _dso_handle: [*mut ::libc::c_void; 32usize], + pub _fntypes: __ULong, + pub _is_cxa: __ULong, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _atexit { + pub _next: *mut _atexit, + pub _ind: ::libc::c_int, + pub _fns: [::core::option::Option; 32usize], + pub _on_exit_args: _on_exit_args, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __sbuf { + pub _base: *mut ::libc::c_uchar, + pub _size: ::libc::c_int, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __sFILE { + pub _p: *mut ::libc::c_uchar, + pub _r: ::libc::c_int, + pub _w: ::libc::c_int, + pub _flags: ::libc::c_short, + pub _file: ::libc::c_short, + pub _bf: __sbuf, + pub _lbfsize: ::libc::c_int, + pub _cookie: *mut ::libc::c_void, + pub _read: ::core::option::Option< + unsafe extern "C" fn( + arg1: *mut _reent, + arg2: *mut ::libc::c_void, + arg3: *mut ::libc::c_char, + arg4: ::libc::c_int, + ) -> ::libc::c_int, + >, + pub _write: ::core::option::Option< + unsafe extern "C" fn( + arg1: *mut _reent, + arg2: *mut ::libc::c_void, + arg3: *const ::libc::c_char, + arg4: ::libc::c_int, + ) -> ::libc::c_int, + >, + pub _seek: ::core::option::Option< + unsafe extern "C" fn( + arg1: *mut _reent, + arg2: *mut ::libc::c_void, + arg3: _fpos_t, + arg4: ::libc::c_int, + ) -> _fpos_t, + >, + pub _close: ::core::option::Option< + unsafe extern "C" fn(arg1: *mut _reent, arg2: *mut ::libc::c_void) -> ::libc::c_int, + >, + pub _ub: __sbuf, + pub _up: *mut ::libc::c_uchar, + pub _ur: ::libc::c_int, + pub _ubuf: [::libc::c_uchar; 3usize], + pub _nbuf: [::libc::c_uchar; 1usize], + pub _lb: __sbuf, + pub _blksize: ::libc::c_int, + pub _offset: _off_t, + pub _data: *mut _reent, + pub _lock: _flock_t, + pub _mbstate: _mbstate_t, + pub _flags2: ::libc::c_int, +} +pub type __FILE = __sFILE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _glue { + pub _next: *mut _glue, + pub _niobs: ::libc::c_int, + pub _iobs: *mut __FILE, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _rand48 { + pub _seed: [::libc::c_ushort; 3usize], + pub _mult: [::libc::c_ushort; 3usize], + pub _add: ::libc::c_ushort, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _reent { + pub _errno: ::libc::c_int, + pub _stdin: *mut __FILE, + pub _stdout: *mut __FILE, + pub _stderr: *mut __FILE, + pub _inc: ::libc::c_int, + pub _emergency: [::libc::c_char; 25usize], + pub _unspecified_locale_info: ::libc::c_int, + pub _locale: *mut __locale_t, + pub __sdidinit: ::libc::c_int, + pub __cleanup: ::core::option::Option, + pub _result: *mut _Bigint, + pub _result_k: ::libc::c_int, + pub _p5s: *mut _Bigint, + pub _freelist: *mut *mut _Bigint, + pub _cvtlen: ::libc::c_int, + pub _cvtbuf: *mut ::libc::c_char, + pub _new: _reent__bindgen_ty_1, + pub _atexit: *mut _atexit, + pub _atexit0: _atexit, + pub _sig_func: *mut ::core::option::Option, + pub __sglue: _glue, + pub __sf: [__FILE; 3usize], + pub deviceData: *mut ::libc::c_void, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _reent__bindgen_ty_1 { + pub _reent: _reent__bindgen_ty_1__bindgen_ty_1, + pub _unused: _reent__bindgen_ty_1__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _reent__bindgen_ty_1__bindgen_ty_1 { + pub _unused_rand: ::libc::c_uint, + pub _strtok_last: *mut ::libc::c_char, + pub _asctime_buf: [::libc::c_char; 26usize], + pub _localtime_buf: __tm, + pub _gamma_signgam: ::libc::c_int, + pub _rand_next: ::libc::c_ulonglong, + pub _r48: _rand48, + pub _mblen_state: _mbstate_t, + pub _mbtowc_state: _mbstate_t, + pub _wctomb_state: _mbstate_t, + pub _l64a_buf: [::libc::c_char; 8usize], + pub _signal_buf: [::libc::c_char; 24usize], + pub _getdate_err: ::libc::c_int, + pub _mbrlen_state: _mbstate_t, + pub _mbrtowc_state: _mbstate_t, + pub _mbsrtowcs_state: _mbstate_t, + pub _wcrtomb_state: _mbstate_t, + pub _wcsrtombs_state: _mbstate_t, + pub _h_errno: ::libc::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _reent__bindgen_ty_1__bindgen_ty_2 { + pub _nextf: [*mut ::libc::c_uchar; 30usize], + pub _nmalloc: [::libc::c_uint; 30usize], +} #[doc = "< Vertex shader."] pub const VERTEX_SHDR: DVLE_type = 0; #[doc = "< Geometry shader."] @@ -860,36 +430,6 @@ pub struct DVLE_s { #[doc = "< Output map attribute clock."] pub outmapClock: u32_, } -#[doc = " DVLB data."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DVLB_s { - #[doc = "< DVLE count."] - pub numDVLE: u32_, - #[doc = "< Primary DVLP."] - pub DVLP: DVLP_s, - #[doc = "< Contained DVLE."] - pub DVLE: *mut DVLE_s, -} -extern "C" { - #[doc = " @brief Parses a shader binary."] - #[doc = " @param shbinData Shader binary data."] - #[doc = " @param shbinSize Shader binary size."] - #[doc = " @return The parsed shader binary."] - pub fn DVLB_ParseFile(shbinData: *mut u32_, shbinSize: u32_) -> *mut DVLB_s; -} -extern "C" { - #[doc = " @brief Frees shader binary data."] - #[doc = " @param dvlb DVLB to free."] - pub fn DVLB_Free(dvlb: *mut DVLB_s); -} -#[doc = " 24-bit float uniforms."] -#[repr(C)] -#[repr(align(4))] -#[derive(Debug, Copy, Clone)] -pub struct float24Uniform_s { - pub _bindgen_opaque_blob: [u32; 4usize], -} #[doc = " Describes an instance of either a vertex or geometry shader."] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -922,107 +462,6 @@ pub struct shaderProgram_s { #[doc = "< Geometry shader input stride."] pub geoShaderInputStride: u8_, } -extern "C" { - #[must_use] - #[doc = " @brief Initializes a shader instance."] - #[doc = " @param si Shader instance to initialize."] - #[doc = " @param dvle DVLE to initialize the shader instance with."] - pub fn shaderInstanceInit(si: *mut shaderInstance_s, dvle: *mut DVLE_s) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Frees a shader instance."] - #[doc = " @param si Shader instance to free."] - pub fn shaderInstanceFree(si: *mut shaderInstance_s) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Sets a bool uniform of a shader."] - #[doc = " @param si Shader instance to use."] - #[doc = " @param id ID of the bool uniform."] - #[doc = " @param value Value to set."] - pub fn shaderInstanceSetBool( - si: *mut shaderInstance_s, - id: ::libc::c_int, - value: bool, - ) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Gets a bool uniform of a shader."] - #[doc = " @param si Shader instance to use."] - #[doc = " @param id ID of the bool uniform."] - #[doc = " @param value Pointer to output the value to."] - pub fn shaderInstanceGetBool( - si: *mut shaderInstance_s, - id: ::libc::c_int, - value: *mut bool, - ) -> Result; -} -extern "C" { - #[doc = " @brief Gets the location of a shader's uniform."] - #[doc = " @param si Shader instance to use."] - #[doc = " @param name Name of the uniform."] - pub fn shaderInstanceGetUniformLocation( - si: *mut shaderInstance_s, - name: *const ::libc::c_char, - ) -> s8; -} -extern "C" { - #[must_use] - #[doc = " @brief Initializes a shader program."] - #[doc = " @param sp Shader program to initialize."] - pub fn shaderProgramInit(sp: *mut shaderProgram_s) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Frees a shader program."] - #[doc = " @param sp Shader program to free."] - pub fn shaderProgramFree(sp: *mut shaderProgram_s) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Sets the vertex shader of a shader program."] - #[doc = " @param sp Shader program to use."] - #[doc = " @param dvle Vertex shader to set."] - pub fn shaderProgramSetVsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Sets the geometry shader of a shader program."] - #[doc = " @param sp Shader program to use."] - #[doc = " @param dvle Geometry shader to set."] - #[doc = " @param stride Input stride of the shader (pass 0 to match the number of outputs of the vertex shader)."] - pub fn shaderProgramSetGsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s, stride: u8_) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Configures the permutation of the input attributes of the geometry shader of a shader program."] - #[doc = " @param sp Shader program to use."] - #[doc = " @param permutation Attribute permutation to use."] - pub fn shaderProgramSetGshInputPermutation( - sp: *mut shaderProgram_s, - permutation: u64_, - ) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Configures the shader units to use the specified shader program."] - #[doc = " @param sp Shader program to use."] - #[doc = " @param sendVshCode When true, the vertex shader's code and operand descriptors are uploaded."] - #[doc = " @param sendGshCode When true, the geometry shader's code and operand descriptors are uploaded."] - pub fn shaderProgramConfigure( - sp: *mut shaderProgram_s, - sendVshCode: bool, - sendGshCode: bool, - ) -> Result; -} -extern "C" { - #[must_use] - #[doc = " @brief Same as shaderProgramConfigure, but always loading code/operand descriptors and uploading DVLE constants afterwards."] - #[doc = " @param sp Shader program to use."] - pub fn shaderProgramUse(sp: *mut shaderProgram_s) -> Result; -} pub type C3D_IVec = u32_; #[doc = " @struct C3D_FVec"] #[doc = " @brief Float vector"] @@ -1317,6 +756,99 @@ extern "C" { isLeftHanded: bool, ); } +extern "C" { + #[doc = " @brief Multiply two Quaternions"] + #[doc = " @param[in] lhs Multiplicand"] + #[doc = " @param[in] rhs Multiplier"] + #[doc = " @return lhs*rhs"] + pub fn Quat_Multiply(lhs: C3D_FQuat, rhs: C3D_FQuat) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief Raise Quaternion to a power"] + #[doc = " @note If p is 0, this returns the identity Quaternion."] + #[doc = " If p is 1, this returns q."] + #[doc = " @param[in] q Base Quaternion"] + #[doc = " @param[in] p Power"] + #[doc = " @return qp"] + pub fn Quat_Pow(q: C3D_FQuat, p: f32) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief Cross product of Quaternion and FVec3"] + #[doc = " @param[in] q Base Quaternion"] + #[doc = " @param[in] v Vector to cross"] + #[doc = " @return q×v"] + pub fn Quat_CrossFVec3(q: C3D_FQuat, v: C3D_FVec) -> C3D_FVec; +} +extern "C" { + #[doc = " @brief 3D Rotation"] + #[doc = " @param[in] q Quaternion to rotate"] + #[doc = " @param[in] axis Axis about which to rotate"] + #[doc = " @param[in] r Radians to rotate"] + #[doc = " @param[in] bRightSide Whether to transform from the right side"] + #[doc = " @return Rotated Quaternion"] + pub fn Quat_Rotate(q: C3D_FQuat, axis: C3D_FVec, r: f32, bRightSide: bool) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief 3D Rotation about the X axis"] + #[doc = " @param[in] q Quaternion to rotate"] + #[doc = " @param[in] r Radians to rotate"] + #[doc = " @param[in] bRightSide Whether to transform from the right side"] + #[doc = " @return Rotated Quaternion"] + pub fn Quat_RotateX(q: C3D_FQuat, r: f32, bRightSide: bool) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief 3D Rotation about the Y axis"] + #[doc = " @param[in] q Quaternion to rotate"] + #[doc = " @param[in] r Radians to rotate"] + #[doc = " @param[in] bRightSide Whether to transform from the right side"] + #[doc = " @return Rotated Quaternion"] + pub fn Quat_RotateY(q: C3D_FQuat, r: f32, bRightSide: bool) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief 3D Rotation about the Z axis"] + #[doc = " @param[in] q Quaternion to rotate"] + #[doc = " @param[in] r Radians to rotate"] + #[doc = " @param[in] bRightSide Whether to transform from the right side"] + #[doc = " @return Rotated Quaternion"] + pub fn Quat_RotateZ(q: C3D_FQuat, r: f32, bRightSide: bool) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief Get Quaternion equivalent to 4x4 matrix"] + #[doc = " @note If the matrix is orthogonal or special orthogonal, where determinant(matrix) = +1.0f, then the matrix can be converted."] + #[doc = " @param[in] m Input Matrix"] + #[doc = " @return Generated Quaternion"] + pub fn Quat_FromMtx(m: *const C3D_Mtx) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief Converting Pitch, Yaw, and Roll to Quaternion equivalent"] + #[doc = " @param[in] pitch The pitch angle in radians."] + #[doc = " @param[in] yaw The yaw angle in radians."] + #[doc = " @param[in] roll The roll angle in radians."] + #[doc = " @param[in] bRightSide Whether to transform from the right side"] + #[doc = " @return C3D_FQuat The Quaternion equivalent with the pitch, yaw, and roll (in that order) orientations applied."] + pub fn Quat_FromPitchYawRoll(pitch: f32, yaw: f32, roll: f32, bRightSide: bool) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief Quaternion Look-At"] + #[doc = " @param[in] source C3D_FVec Starting position. Origin of rotation."] + #[doc = " @param[in] target C3D_FVec Target position to orient towards."] + #[doc = " @param[in] forwardVector C3D_FVec The Up vector."] + #[doc = " @param[in] upVector C3D_FVec The Up vector."] + #[doc = " @return Quaternion rotation."] + pub fn Quat_LookAt( + source: C3D_FVec, + target: C3D_FVec, + forwardVector: C3D_FVec, + upVector: C3D_FVec, + ) -> C3D_FQuat; +} +extern "C" { + #[doc = " @brief Quaternion, created from a given axis and angle in radians."] + #[doc = " @param[in] axis C3D_FVec The axis to rotate around at."] + #[doc = " @param[in] angle float The angle to rotate. Unit: Radians"] + #[doc = " @return Quaternion rotation based on the axis and angle. Axis doesn't have to be orthogonal."] + pub fn Quat_FromAxisAngle(axis: C3D_FVec, angle: f32) -> C3D_FQuat; +} #[repr(C)] #[derive(Copy, Clone)] pub struct C3D_MtxStack { @@ -1327,6 +859,26 @@ pub struct C3D_MtxStack { pub unifLen: u8_, pub isDirty: bool, } +extern "C" { + pub fn MtxStack_Init(stk: *mut C3D_MtxStack); +} +extern "C" { + pub fn MtxStack_Bind( + stk: *mut C3D_MtxStack, + unifType: GPU_SHADER_TYPE, + unifPos: ::libc::c_int, + unifLen: ::libc::c_int, + ); +} +extern "C" { + pub fn MtxStack_Push(stk: *mut C3D_MtxStack) -> *mut C3D_Mtx; +} +extern "C" { + pub fn MtxStack_Pop(stk: *mut C3D_MtxStack) -> *mut C3D_Mtx; +} +extern "C" { + pub fn MtxStack_Update(stk: *mut C3D_MtxStack); +} extern "C" { pub static mut C3D_FVUnif: [[C3D_FVec; 96usize]; 2usize]; } @@ -1410,7 +962,7 @@ pub const C3D_UNSIGNED_BYTE: _bindgen_ty_38 = 0; pub const C3D_UNSIGNED_SHORT: _bindgen_ty_38 = 1; pub type _bindgen_ty_38 = ::libc::c_uint; extern "C" { - pub fn C3D_Init(cmdBufSize: size_t) -> bool; + pub fn C3D_Init(cmdBufSize: usize) -> bool; } extern "C" { pub fn C3D_Fini(); @@ -1640,18 +1192,18 @@ impl C3D_Tex { } } #[inline] - pub fn size(&self) -> size_t { + pub fn size(&self) -> usize { unsafe { ::core::mem::transmute(self._bitfield_1.get(4usize, 28u8) as u32) } } #[inline] - pub fn set_size(&mut self, val: size_t) { + pub fn set_size(&mut self, val: usize) { unsafe { let val: u32 = ::core::mem::transmute(val); self._bitfield_1.set(4usize, 28u8, val as u64) } } #[inline] - pub fn new_bitfield_1(fmt: GPU_TEXCOLOR, size: size_t) -> __BindgenBitfieldUnit<[u8; 4usize]> { + pub fn new_bitfield_1(fmt: GPU_TEXCOLOR, size: usize) -> __BindgenBitfieldUnit<[u8; 4usize]> { let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); __bindgen_bitfield_unit.set(0usize, 4u8, { let fmt: u32 = unsafe { ::core::mem::transmute(fmt) }; @@ -2154,9 +1706,20 @@ pub type C3D_ProcTexLut = [u32_; 128usize]; extern "C" { pub fn C3D_ProcTexLutBind(id: GPU_PROCTEX_LUTID, lut: *mut C3D_ProcTexLut); } +extern "C" { + pub fn ProcTexLut_FromArray(lut: *mut C3D_ProcTexLut, in_: *const f32); +} extern "C" { pub fn C3D_ProcTexColorLutBind(lut: *mut C3D_ProcTexColorLut); } +extern "C" { + pub fn ProcTexColorLut_Write( + out: *mut C3D_ProcTexColorLut, + in_: *const u32_, + offset: ::libc::c_int, + length: ::libc::c_int, + ); +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct C3D_LightLut { @@ -2172,6 +1735,27 @@ pub struct C3D_LightLutDA { pub type C3D_LightLutFunc = ::core::option::Option f32>; pub type C3D_LightLutFuncDA = ::core::option::Option f32>; +extern "C" { + pub fn LightLut_FromArray(lut: *mut C3D_LightLut, data: *mut f32); +} +extern "C" { + pub fn LightLut_FromFunc( + lut: *mut C3D_LightLut, + func: C3D_LightLutFunc, + param: f32, + negative: bool, + ); +} +extern "C" { + pub fn LightLutDA_Create( + lut: *mut C3D_LightLutDA, + func: C3D_LightLutFuncDA, + from: f32, + to: f32, + arg0: f32, + arg1: f32, + ); +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct C3D_Material { @@ -2199,6 +1783,10 @@ pub struct C3D_LightEnvConf { pub lutInput: C3D_LightLutInputConf, pub permutation: u32_, } +pub const C3DF_LightEnv_Dirty: _bindgen_ty_40 = 1; +pub const C3DF_LightEnv_MtlDirty: _bindgen_ty_40 = 2; +pub const C3DF_LightEnv_LCDirty: _bindgen_ty_40 = 4; +pub type _bindgen_ty_40 = ::libc::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct C3D_LightEnv_t { @@ -2230,6 +1818,11 @@ extern "C" { lut: *mut C3D_LightLut, ); } +pub const GPU_SHADOW_PRIMARY: _bindgen_ty_41 = 65536; +pub const GPU_SHADOW_SECONDARY: _bindgen_ty_41 = 131072; +pub const GPU_INVERT_SHADOW: _bindgen_ty_41 = 262144; +pub const GPU_SHADOW_ALPHA: _bindgen_ty_41 = 524288; +pub type _bindgen_ty_41 = ::libc::c_uint; extern "C" { pub fn C3D_LightEnvFresnel(env: *mut C3D_LightEnv, selector: GPU_FRESNELSEL); } @@ -2269,6 +1862,12 @@ pub struct C3D_LightConf { pub distAttnBias: u32_, pub distAttnScale: u32_, } +pub const C3DF_Light_Enabled: _bindgen_ty_42 = 1; +pub const C3DF_Light_Dirty: _bindgen_ty_42 = 2; +pub const C3DF_Light_MatDirty: _bindgen_ty_42 = 4; +pub const C3DF_Light_SPDirty: _bindgen_ty_42 = 16384; +pub const C3DF_Light_DADirty: _bindgen_ty_42 = 32768; +pub type _bindgen_ty_42 = ::libc::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct C3D_Light_t { @@ -2339,6 +1938,12 @@ pub struct C3D_GasLut { pub diff: [u32_; 8usize], pub color: [u32_; 8usize], } +extern "C" { + pub fn FogLut_FromArray(lut: *mut C3D_FogLut, data: *const f32); +} +extern "C" { + pub fn FogLut_Exp(lut: *mut C3D_FogLut, density: f32, gradient: f32, near: f32, far: f32); +} extern "C" { pub fn C3D_FogGasMode(fogMode: GPU_FOGMODE, gasMode: GPU_GASMODE, zFlip: bool); } @@ -2348,6 +1953,9 @@ extern "C" { extern "C" { pub fn C3D_FogLutBind(lut: *mut C3D_FogLut); } +extern "C" { + pub fn GasLut_FromArray(lut: *mut C3D_GasLut, data: *const u32_); +} extern "C" { pub fn C3D_GasBeginAcc(); } @@ -2581,3 +2189,122 @@ extern "C" { control1: u16_, ); } +pub type FILE = __FILE; +#[doc = " @brief Subtexture"] +#[doc = " @note If top > bottom, the subtexture is rotated 1/4 revolution counter-clockwise"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Tex3DS_SubTexture { + #[doc = "< Sub-texture width (pixels)"] + pub width: u16_, + #[doc = "< Sub-texture height (pixels)"] + pub height: u16_, + #[doc = "< Left u-coordinate"] + pub left: f32, + #[doc = "< Top v-coordinate"] + pub top: f32, + #[doc = "< Right u-coordinate"] + pub right: f32, + #[doc = "< Bottom v-coordinate"] + pub bottom: f32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Tex3DS_Texture_s { + _unused: [u8; 0], +} +#[doc = " @brief Texture"] +pub type Tex3DS_Texture = *mut Tex3DS_Texture_s; +extern "C" { + #[doc = " @brief Import Tex3DS texture"] + #[doc = " @param[in] input Input data"] + #[doc = " @param[in] insize Size of the input data"] + #[doc = " @param[out] tex citro3d texture"] + #[doc = " @param[out] texcube citro3d texcube"] + #[doc = " @param[in] vram Whether to store textures in VRAM"] + #[doc = " @returns Tex3DS texture"] + pub fn Tex3DS_TextureImport( + input: *const ::libc::c_void, + insize: usize, + tex: *mut C3D_Tex, + texcube: *mut C3D_TexCube, + vram: bool, + ) -> Tex3DS_Texture; +} +extern "C" { + #[doc = " @brief Import Tex3DS texture"] + #[doc = ""] + #[doc = " @description"] + #[doc = " For example, use this if you want to import from a large file without"] + #[doc = " pulling the entire file into memory."] + #[doc = ""] + #[doc = " @param[out] tex citro3d texture"] + #[doc = " @param[out] texcube citro3d texcube"] + #[doc = " @param[in] vram Whether to store textures in VRAM"] + #[doc = " @param[in] callback Data callback"] + #[doc = " @param[in] userdata User data passed to callback"] + #[doc = " @returns Tex3DS texture"] + pub fn Tex3DS_TextureImportCallback( + tex: *mut C3D_Tex, + texcube: *mut C3D_TexCube, + vram: bool, + callback: decompressCallback, + userdata: *mut ::libc::c_void, + ) -> Tex3DS_Texture; +} +extern "C" { + #[doc = " @brief Import Tex3DS texture"] + #[doc = ""] + #[doc = " Starts reading at the current file descriptor's offset. The file"] + #[doc = " descriptor's position is left at the end of the decoded data. On error, the"] + #[doc = " file descriptor's position is indeterminate."] + #[doc = ""] + #[doc = " @param[in] fd Open file descriptor"] + #[doc = " @param[out] tex citro3d texture"] + #[doc = " @param[out] texcube citro3d texcube"] + #[doc = " @param[in] vram Whether to store textures in VRAM"] + #[doc = " @returns Tex3DS texture"] + pub fn Tex3DS_TextureImportFD( + fd: ::libc::c_int, + tex: *mut C3D_Tex, + texcube: *mut C3D_TexCube, + vram: bool, + ) -> Tex3DS_Texture; +} +extern "C" { + #[doc = " @brief Import Tex3DS texture"] + #[doc = ""] + #[doc = " Starts reading at the current file stream's offset. The file stream's"] + #[doc = " position is left at the end of the decoded data. On error, the file"] + #[doc = " stream's position is indeterminate."] + #[doc = ""] + #[doc = " @param[in] fp Open file stream"] + #[doc = " @param[out] tex citro3d texture"] + #[doc = " @param[out] texcube citro3d texcube"] + #[doc = " @param[in] vram Whether to store textures in VRAM"] + #[doc = " @returns Tex3DS texture"] + pub fn Tex3DS_TextureImportStdio( + fp: *mut FILE, + tex: *mut C3D_Tex, + texcube: *mut C3D_TexCube, + vram: bool, + ) -> Tex3DS_Texture; +} +extern "C" { + #[doc = " @brief Get number of subtextures"] + #[doc = " @param[in] texture Tex3DS texture"] + #[doc = " @returns Number of subtextures"] + pub fn Tex3DS_GetNumSubTextures(texture: Tex3DS_Texture) -> usize; +} +extern "C" { + #[doc = " @brief Get subtexture"] + #[doc = " @param[in] texture Tex3DS texture"] + #[doc = " @param[in] index Subtexture index"] + #[doc = " @returns Subtexture info"] + pub fn Tex3DS_GetSubTexture(texture: Tex3DS_Texture, index: usize) -> *const Tex3DS_SubTexture; +} +extern "C" { + #[doc = " @brief Free Tex3DS texture"] + #[doc = " @param[in] texture Tex3DS texture to free"] + pub fn Tex3DS_TextureFree(texture: Tex3DS_Texture); +} diff --git a/citro3d-sys/src/gx.rs b/citro3d-sys/src/gx.rs index 9be28ed..2630208 100644 --- a/citro3d-sys/src/gx.rs +++ b/citro3d-sys/src/gx.rs @@ -1,6 +1,6 @@ //! Helper functions based on `<3ds/gpu/gx.h>`. -use crate::{GX_TRANSFER_FORMAT, GX_TRANSFER_SCALE}; +use ctru_sys::{GX_TRANSFER_FORMAT, GX_TRANSFER_SCALE}; #[inline] pub fn GX_TRANSFER_FLIP_VERT(flip: bool) -> u32 { diff --git a/citro3d-sys/src/texenv.rs b/citro3d-sys/src/texenv.rs index f52ffac..bcc599c 100644 --- a/citro3d-sys/src/texenv.rs +++ b/citro3d-sys/src/texenv.rs @@ -5,6 +5,7 @@ use core::ops::{BitOr, Shl}; +use ctru_sys::{GPU_COMBINEFUNC, GPU_PREVIOUS, GPU_REPLACE, GPU_TEVSCALE_1, GPU_TEVSRC}; use libc::c_int; use super::*; diff --git a/citro3d-sys/src/uniforms.rs b/citro3d-sys/src/uniforms.rs index b2df616..bfd6d83 100644 --- a/citro3d-sys/src/uniforms.rs +++ b/citro3d-sys/src/uniforms.rs @@ -1,6 +1,8 @@ //! Definitions from`` -use super::{C3D_FVUnif, C3D_FVUnifDirty, C3D_FVec, C3D_Mtx, GPU_SHADER_TYPE}; +use ctru_sys::GPU_SHADER_TYPE; + +use super::{C3D_FVUnif, C3D_FVUnifDirty, C3D_FVec, C3D_Mtx}; #[inline] pub unsafe fn C3D_FVUnifWritePtr( From 340a38489c9a7c15fef0580b37e7a6c6bf81b2f2 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Mon, 21 Nov 2022 21:57:26 -0500 Subject: [PATCH 2/4] Update citro3d to use upstream ctru_sys types --- citro3d/Cargo.toml | 5 ++--- citro3d/src/lib.rs | 4 ++-- citro3d/src/render.rs | 20 ++++++++++---------- citro3d/src/render/transfer.rs | 13 +++++++------ citro3d/src/shader.rs | 26 +++++++++++++------------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/citro3d/Cargo.toml b/citro3d/Cargo.toml index 8bdaf3f..70eca7f 100644 --- a/citro3d/Cargo.toml +++ b/citro3d/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" bitflags = "1.3.2" bytemuck = { version = "1.10.0", features = ["extern_crate_std"] } citro3d-sys = { git = "https://github.com/ian-h-chamberlain/citro3d-rs.git" } -ctru-rs = { git = "https://github.com/Meziu/ctru-rs.git" } +ctru-rs = { git = "https://github.com/rust3ds/ctru-rs.git" } +ctru-sys = { git = "https://github.com/rust3ds/ctru-rs.git" } libc = "0.2.125" - -[dev-dependencies] diff --git a/citro3d/src/lib.rs b/citro3d/src/lib.rs index 7d27f4f..0f9501f 100644 --- a/citro3d/src/lib.rs +++ b/citro3d/src/lib.rs @@ -25,7 +25,7 @@ impl Instance { /// /// Fails if `citro3d` cannot be initialized. pub fn new() -> Result { - Self::with_cmdbuf_size(citro3d_sys::C3D_DEFAULT_CMDBUF_SIZE) + Self::with_cmdbuf_size(citro3d_sys::C3D_DEFAULT_CMDBUF_SIZE.try_into().unwrap()) } /// Initialize the instance with a specified command buffer size. @@ -33,7 +33,7 @@ impl Instance { /// # Errors /// /// Fails if `citro3d` cannot be initialized. - pub fn with_cmdbuf_size(size: u32) -> Result { + pub fn with_cmdbuf_size(size: usize) -> Result { if unsafe { citro3d_sys::C3D_Init(size) } { Ok(Self) } else { diff --git a/citro3d/src/render.rs b/citro3d/src/render.rs index dcd7fa3..56d83f5 100644 --- a/citro3d/src/render.rs +++ b/citro3d/src/render.rs @@ -2,11 +2,11 @@ //! of data to the GPU, including the format of color and depth data to be rendered. use citro3d_sys::{ - C3D_RenderTarget, C3D_RenderTargetCreate, C3D_RenderTargetDelete, C3D_DEPTHTYPE, GPU_COLORBUF, - GPU_DEPTHBUF, + C3D_RenderTarget, C3D_RenderTargetCreate, C3D_RenderTargetDelete, C3D_DEPTHTYPE, }; use ctru::gfx; use ctru::services::gspgpu::FramebufferFormat; +use ctru_sys::{GPU_COLORBUF, GPU_DEPTHBUF}; use crate::{Error, Result}; @@ -103,15 +103,15 @@ bitflags::bitflags! { #[derive(Clone, Copy, Debug)] pub enum ColorFormat { /// 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha. - RGBA8 = citro3d_sys::GPU_RB_RGBA8, + RGBA8 = ctru_sys::GPU_RB_RGBA8, /// 8-bit Red + 8-bit Green + 8-bit Blue. - RGB8 = citro3d_sys::GPU_RB_RGB8, + RGB8 = ctru_sys::GPU_RB_RGB8, /// 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha. - RGBA5551 = citro3d_sys::GPU_RB_RGBA5551, + RGBA5551 = ctru_sys::GPU_RB_RGBA5551, /// 5-bit Red + 6-bit Green + 5-bit Blue. - RGB565 = citro3d_sys::GPU_RB_RGB565, + RGB565 = ctru_sys::GPU_RB_RGB565, /// 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha. - RGBA4 = citro3d_sys::GPU_RB_RGBA4, + RGBA4 = ctru_sys::GPU_RB_RGBA4, } impl From for ColorFormat { @@ -132,11 +132,11 @@ impl From for ColorFormat { #[derive(Clone, Copy, Debug)] pub enum DepthFormat { /// 16-bit depth. - Depth16 = citro3d_sys::GPU_RB_DEPTH16, + Depth16 = ctru_sys::GPU_RB_DEPTH16, /// 24-bit depth. - Depth24 = citro3d_sys::GPU_RB_DEPTH24, + Depth24 = ctru_sys::GPU_RB_DEPTH24, /// 24-bit depth + 8-bit Stencil. - Depth24Stencil8 = citro3d_sys::GPU_RB_DEPTH24_STENCIL8, + Depth24Stencil8 = ctru_sys::GPU_RB_DEPTH24_STENCIL8, } impl DepthFormat { diff --git a/citro3d/src/render/transfer.rs b/citro3d/src/render/transfer.rs index 60a5e58..4192547 100644 --- a/citro3d/src/render/transfer.rs +++ b/citro3d/src/render/transfer.rs @@ -1,4 +1,5 @@ -use citro3d_sys::{GX_TRANSFER_FORMAT, GX_TRANSFER_IN_FORMAT, GX_TRANSFER_OUT_FORMAT}; +use citro3d_sys::{GX_TRANSFER_IN_FORMAT, GX_TRANSFER_OUT_FORMAT}; +use ctru_sys::GX_TRANSFER_FORMAT; use super::ColorFormat; @@ -33,15 +34,15 @@ impl Flags { #[repr(u32)] pub enum Format { /// 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha. - RGBA8 = citro3d_sys::GX_TRANSFER_FMT_RGBA8, + RGBA8 = ctru_sys::GX_TRANSFER_FMT_RGBA8, /// 8-bit Red + 8-bit Green + 8-bit Blue. - RGB8 = citro3d_sys::GX_TRANSFER_FMT_RGB8, + RGB8 = ctru_sys::GX_TRANSFER_FMT_RGB8, /// 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha. - RGB565 = citro3d_sys::GX_TRANSFER_FMT_RGB565, + RGB565 = ctru_sys::GX_TRANSFER_FMT_RGB565, /// 5-bit Red + 6-bit Green + 5-bit Blue. - RGB5A1 = citro3d_sys::GX_TRANSFER_FMT_RGB5A1, + RGB5A1 = ctru_sys::GX_TRANSFER_FMT_RGB5A1, /// 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha. - RGBA4 = citro3d_sys::GX_TRANSFER_FMT_RGBA4, + RGBA4 = ctru_sys::GX_TRANSFER_FMT_RGBA4, } impl From for Format { diff --git a/citro3d/src/shader.rs b/citro3d/src/shader.rs index d66a924..91142ee 100644 --- a/citro3d/src/shader.rs +++ b/citro3d/src/shader.rs @@ -16,7 +16,7 @@ pub mod macros; /// /// The PICA200 does not support user-programmable fragment shaders. pub struct Program { - program: citro3d_sys::shaderProgram_s, + program: ctru_sys::shaderProgram_s, } impl Program { @@ -30,14 +30,14 @@ impl Program { pub fn new(vertex_shader: Entrypoint) -> Result { let mut program = unsafe { let mut program = MaybeUninit::uninit(); - let result = citro3d_sys::shaderProgramInit(program.as_mut_ptr()); + let result = ctru_sys::shaderProgramInit(program.as_mut_ptr()); if result != 0 { return Err(ctru::Error::from(result)); } program.assume_init() }; - let ret = unsafe { citro3d_sys::shaderProgramSetVsh(&mut program, vertex_shader.as_raw()) }; + let ret = unsafe { ctru_sys::shaderProgramSetVsh(&mut program, vertex_shader.as_raw()) }; if ret == 0 { Ok(Self { program }) @@ -58,7 +58,7 @@ impl Program { stride: u8, ) -> Result<(), ctru::Error> { let ret = unsafe { - citro3d_sys::shaderProgramSetGsh(&mut self.program, geometry_shader.as_raw(), stride) + ctru_sys::shaderProgramSetGsh(&mut self.program, geometry_shader.as_raw(), stride) }; if ret == 0 { @@ -69,15 +69,15 @@ impl Program { } // TODO: pub(crate) - pub fn as_raw(&mut self) -> *mut citro3d_sys::shaderProgram_s { + pub fn as_raw(&mut self) -> *mut ctru_sys::shaderProgram_s { &mut self.program } } -impl<'vert, 'geom> Drop for Program { +impl Drop for Program { fn drop(&mut self) { unsafe { - let _ = citro3d_sys::shaderProgramFree(self.as_raw()); + let _ = ctru_sys::shaderProgramFree(self.as_raw()); } } } @@ -88,7 +88,7 @@ impl<'vert, 'geom> Drop for Program { /// /// This is the result of parsing a shader binary (shbin), and the resulting /// [`Entrypoint`]s can be used as part of a [`Program`]. -pub struct Library(*mut citro3d_sys::DVLB_s); +pub struct Library(*mut ctru_sys::DVLB_s); impl Library { /// Parse a new shader library from input bytes. @@ -100,7 +100,7 @@ impl Library { pub fn from_bytes(bytes: &[u8]) -> Result> { let aligned: &[u32] = bytemuck::try_cast_slice(bytes)?; Ok(Self(unsafe { - citro3d_sys::DVLB_ParseFile( + ctru_sys::DVLB_ParseFile( // SAFETY: we're trusting the parse implementation doesn't mutate // the contents of the data. From a quick read it looks like that's // correct and it should just take a const arg in the API. @@ -132,7 +132,7 @@ impl Library { self.len() == 0 } - fn as_raw(&mut self) -> *mut citro3d_sys::DVLB_s { + fn as_raw(&mut self) -> *mut ctru_sys::DVLB_s { self.0 } } @@ -140,7 +140,7 @@ impl Library { impl Drop for Library { fn drop(&mut self) { unsafe { - citro3d_sys::DVLB_Free(self.as_raw()); + ctru_sys::DVLB_Free(self.as_raw()); } } } @@ -149,12 +149,12 @@ impl Drop for Library { /// vertex or a geometry shader. #[derive(Clone, Copy)] pub struct Entrypoint<'lib> { - ptr: *mut citro3d_sys::DVLE_s, + ptr: *mut ctru_sys::DVLE_s, _library: &'lib Library, } impl<'lib> Entrypoint<'lib> { - fn as_raw(self) -> *mut citro3d_sys::DVLE_s { + fn as_raw(self) -> *mut ctru_sys::DVLE_s { self.ptr } } From 02a9d40fdbc55de4969c3bcb5131bf36471a4f16 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Tue, 22 Nov 2022 19:14:36 -0500 Subject: [PATCH 3/4] Use bindgen library to generate bindings This allows us to use a custom callback for marking some types as Copy, which bindgen otherwise pessimistically assumes cannot. --- Cargo.toml | 2 +- bindgen-citro3d/Cargo.toml | 7 ++ bindgen-citro3d/src/main.rs | 80 +++++++++++++++++ citro3d-sys/bindgen.sh | 31 +------ citro3d-sys/src/bindings.rs | 166 ----------------------------------- citro3d/examples/triangle.rs | 18 ++-- 6 files changed, 98 insertions(+), 206 deletions(-) create mode 100644 bindgen-citro3d/Cargo.toml create mode 100644 bindgen-citro3d/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index e2d84ae..e22ce63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["citro3d-sys", "citro3d"] +members = ["citro3d-sys", "citro3d", "bindgen-citro3d"] [patch."https://github.com/ian-h-chamberlain/citro3d-rs.git"] citro3d-sys = { path = "citro3d-sys" } diff --git a/bindgen-citro3d/Cargo.toml b/bindgen-citro3d/Cargo.toml new file mode 100644 index 0000000..3231842 --- /dev/null +++ b/bindgen-citro3d/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bindgen-citro3d" +version = "0.1.0" +edition = "2021" + +[dependencies] +bindgen = "0.62.0" diff --git a/bindgen-citro3d/src/main.rs b/bindgen-citro3d/src/main.rs new file mode 100644 index 0000000..6d1282b --- /dev/null +++ b/bindgen-citro3d/src/main.rs @@ -0,0 +1,80 @@ +use std::iter::FromIterator; +use std::path::PathBuf; + +use bindgen::callbacks::{DeriveTrait, ImplementsTrait, ParseCallbacks}; +use bindgen::{Builder, RustTarget}; + +fn main() { + let devkitpro = std::env::var("DEVKITPRO").expect("DEVKITPRO not set in environment"); + let devkitarm = std::env::var("DEVKITARM").expect("DEVKITARM not set in environment"); + + let include_path = PathBuf::from(devkitpro).join(PathBuf::from_iter(["libctru", "include"])); + let header = include_path.join("tex3ds.h"); + + let sysroot = PathBuf::from(devkitarm).join("arm-none-eabi"); + let system_include = sysroot.join("include"); + + let bindings = Builder::default() + .header(header.to_str().unwrap()) + .rust_target(RustTarget::Nightly) + .use_core() + .trust_clang_mangling(false) + .layout_tests(false) + .ctypes_prefix("::libc") + .prepend_enum_name(false) + .fit_macro_constants(true) + .raw_line("use ctru_sys::*;") + .must_use_type("Result") + // TODO functions,types,vars + .blocklist_type("u(8|16|32|64)") + .opaque_type("(GPU|GFX)_.*") + .opaque_type("float24Uniform_s") + .blocklist_file(".*/3ds/.*[.]h") + .allowlist_file(".*/c3d/.*[.]h") + .allowlist_file(".*/tex3ds[.]h") + .clang_args([ + "--target=arm-none-eabi", + "--sysroot", + sysroot.to_str().unwrap(), + "-isystem", + system_include.to_str().unwrap(), + "-I", + include_path.to_str().unwrap(), + "-mfloat-abi=hard", + "-march=armv6k", + "-mtune=mpcore", + "-mfpu=vfp", + "-DARM11 ", + "-D_3DS ", + "-D__3DS__ ", + ]) + .parse_callbacks(Box::new(CustomCallbacks)) + .generate() + .expect("Unable to generate bindings"); + + bindings + .write(Box::new(std::io::stdout())) + .expect("failed to write bindings"); +} + +#[derive(Debug)] +struct CustomCallbacks; + +impl ParseCallbacks for CustomCallbacks { + fn blocklisted_type_implements_trait( + &self, + name: &str, + derive_trait: DeriveTrait, + ) -> Option { + if let DeriveTrait::Copy | DeriveTrait::Debug = derive_trait { + match name { + "u64_" | "u32_" | "u16_" | "u8_" | "u64" | "u32" | "u16" | "u8" | "gfxScreen_t" + | "gfx3dSide_t" => Some(ImplementsTrait::Yes), + _ if name.starts_with("GPU_") => Some(ImplementsTrait::Yes), + _ => None, + } + } else { + None + } + } +} diff --git a/citro3d-sys/bindgen.sh b/citro3d-sys/bindgen.sh index ebede4c..ebb4ff9 100755 --- a/citro3d-sys/bindgen.sh +++ b/citro3d-sys/bindgen.sh @@ -2,33 +2,4 @@ set -euxo pipefail -bindgen "$DEVKITPRO/libctru/include/tex3ds.h" \ - --rust-target nightly \ - --use-core \ - --distrust-clang-mangling \ - --no-layout-tests \ - --ctypes-prefix "::libc" \ - --no-prepend-enum-name \ - --fit-macro-constant-types \ - --raw-line "use ctru_sys::*;" \ - --must-use-type "Result" \ - --generate "functions,types,vars" \ - --blocklist-type "u(8|16|32|64)" \ - --opaque-type "GPU_.*" \ - --opaque-type "GFX_.*" \ - --opaque-type "float24Uniform_s" \ - --allowlist-file ".*/c3d/.*[.]h" \ - --allowlist-file ".*/tex3ds[.]h" \ - -- \ - --target=arm-none-eabi \ - --sysroot=$DEVKITARM/arm-none-eabi \ - -isystem$DEVKITARM/arm-none-eabi/include \ - -I$DEVKITPRO/libctru/include \ - -mfloat-abi=hard \ - -march=armv6k \ - -mtune=mpcore \ - -mfpu=vfp \ - -DARM11 \ - -D_3DS \ - -D__3DS__ \ -> src/bindings.rs +cargo run --package bindgen-citro3d > src/bindings.rs diff --git a/citro3d-sys/src/bindings.rs b/citro3d-sys/src/bindings.rs index 0f750e1..c6fc58e 100644 --- a/citro3d-sys/src/bindings.rs +++ b/citro3d-sys/src/bindings.rs @@ -92,10 +92,6 @@ pub const C3D_DEFAULT_CMDBUF_SIZE: u32 = 262144; pub const C3DF_LightEnv_IsCP_Any: u32 = 66846720; pub const C3DF_LightEnv_LutDirtyAll: u32 = 4227858432; pub type __int64_t = ::libc::c_longlong; -pub type u8_ = u8; -pub type u16_ = u16; -pub type u32_ = u32; -pub type u64_ = u64; pub type _LOCK_T = i32; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -105,21 +101,6 @@ pub struct __lock_t { pub counter: u32, } pub type _LOCK_RECURSIVE_T = __lock_t; -#[doc = "< Top screen"] -pub const GFX_TOP: gfxScreen_t = 0; -#[doc = "< Bottom screen"] -pub const GFX_BOTTOM: gfxScreen_t = 1; -#[doc = " Screen IDs."] -pub type gfxScreen_t = ::libc::c_uint; -#[doc = "< Left eye framebuffer"] -pub const GFX_LEFT: gfx3dSide_t = 0; -#[doc = "< Right eye framebuffer"] -pub const GFX_RIGHT: gfx3dSide_t = 1; -#[doc = " @brief Top screen framebuffer side."] -#[doc = ""] -#[doc = " This is only meaningful when stereoscopic 3D is enabled on the top screen."] -#[doc = " In any other case, use \\ref GFX_LEFT."] -pub type gfx3dSide_t = ::libc::c_uint; pub type _off_t = __int64_t; pub type _fpos_t = __int64_t; pub type wint_t = ::libc::c_int; @@ -135,14 +116,6 @@ pub union _mbstate_t__bindgen_ty_1 { pub __wch: wint_t, pub __wchb: [::libc::c_uchar; 4usize], } -#[doc = " @brief Data callback"] -pub type decompressCallback = ::core::option::Option< - unsafe extern "C" fn( - userdata: *mut ::libc::c_void, - buffer: *mut ::libc::c_void, - size: usize, - ) -> isize, ->; pub type __ULong = ::libc::c_ulong; pub type _flock_t = _LOCK_RECURSIVE_T; #[repr(C)] @@ -323,145 +296,6 @@ pub struct _reent__bindgen_ty_1__bindgen_ty_2 { pub _nextf: [*mut ::libc::c_uchar; 30usize], pub _nmalloc: [::libc::c_uint; 30usize], } -#[doc = "< Vertex shader."] -pub const VERTEX_SHDR: DVLE_type = 0; -#[doc = "< Geometry shader."] -pub const GEOMETRY_SHDR: DVLE_type = 1; -#[doc = " DVLE type."] -pub type DVLE_type = ::libc::c_uint; -#[doc = "< Point processing mode."] -pub const GSH_POINT: DVLE_geoShaderMode = 0; -#[doc = "< Variable-size primitive processing mode."] -pub const GSH_VARIABLE_PRIM: DVLE_geoShaderMode = 1; -#[doc = "< Fixed-size primitive processing mode."] -pub const GSH_FIXED_PRIM: DVLE_geoShaderMode = 2; -#[doc = " Geometry shader operation modes."] -pub type DVLE_geoShaderMode = ::libc::c_uint; -#[doc = " DVLP data."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DVLP_s { - #[doc = "< Code size."] - pub codeSize: u32_, - #[doc = "< Code data."] - pub codeData: *mut u32_, - #[doc = "< Operand description size."] - pub opdescSize: u32_, - #[doc = "< Operand description data."] - pub opcdescData: *mut u32_, -} -#[doc = " DVLE constant entry data."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DVLE_constEntry_s { - #[doc = "< Constant type. See @ref DVLE_constantType"] - pub type_: u16_, - #[doc = "< Constant ID."] - pub id: u16_, - #[doc = "< Constant data."] - pub data: [u32_; 4usize], -} -#[doc = " DVLE output entry data."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DVLE_outEntry_s { - #[doc = "< Output type. See @ref DVLE_outputAttribute_t"] - pub type_: u16_, - #[doc = "< Output register ID."] - pub regID: u16_, - #[doc = "< Output mask."] - pub mask: u8_, - #[doc = "< Unknown."] - pub unk: [u8_; 3usize], -} -#[doc = " DVLE uniform entry data."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DVLE_uniformEntry_s { - #[doc = "< Symbol offset."] - pub symbolOffset: u32_, - #[doc = "< Start register."] - pub startReg: u16_, - #[doc = "< End register."] - pub endReg: u16_, -} -#[doc = " DVLE data."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DVLE_s { - #[doc = "< DVLE type."] - pub type_: DVLE_type, - #[doc = "< true = merge vertex/geometry shader outmaps ('dummy' output attribute is present)."] - pub mergeOutmaps: bool, - #[doc = "< Geometry shader operation mode."] - pub gshMode: DVLE_geoShaderMode, - #[doc = "< Starting float uniform register number for storing the fixed-size primitive vertex array."] - pub gshFixedVtxStart: u8_, - #[doc = "< Number of fully-defined vertices in the variable-size primitive vertex array."] - pub gshVariableVtxNum: u8_, - #[doc = "< Number of vertices in the fixed-size primitive vertex array."] - pub gshFixedVtxNum: u8_, - #[doc = "< Contained DVLPs."] - pub dvlp: *mut DVLP_s, - #[doc = "< Offset of the start of the main function."] - pub mainOffset: u32_, - #[doc = "< Offset of the end of the main function."] - pub endmainOffset: u32_, - #[doc = "< Constant table size."] - pub constTableSize: u32_, - #[doc = "< Constant table data."] - pub constTableData: *mut DVLE_constEntry_s, - #[doc = "< Output table size."] - pub outTableSize: u32_, - #[doc = "< Output table data."] - pub outTableData: *mut DVLE_outEntry_s, - #[doc = "< Uniform table size."] - pub uniformTableSize: u32_, - #[doc = "< Uniform table data."] - pub uniformTableData: *mut DVLE_uniformEntry_s, - #[doc = "< Symbol table data."] - pub symbolTableData: *mut ::libc::c_char, - #[doc = "< Output map mask."] - pub outmapMask: u8_, - #[doc = "< Output map data."] - pub outmapData: [u32_; 8usize], - #[doc = "< Output map mode."] - pub outmapMode: u32_, - #[doc = "< Output map attribute clock."] - pub outmapClock: u32_, -} -#[doc = " Describes an instance of either a vertex or geometry shader."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct shaderInstance_s { - #[doc = "< Shader DVLE."] - pub dvle: *mut DVLE_s, - #[doc = "< Boolean uniforms."] - pub boolUniforms: u16_, - #[doc = "< Used boolean uniform mask."] - pub boolUniformMask: u16_, - #[doc = "< Integer uniforms."] - pub intUniforms: [u32_; 4usize], - #[doc = "< 24-bit float uniforms."] - pub float24Uniforms: *mut float24Uniform_s, - #[doc = "< Used integer uniform mask."] - pub intUniformMask: u8_, - #[doc = "< Float uniform count."] - pub numFloat24Uniforms: u8_, -} -#[doc = " Describes an instance of a full shader program."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct shaderProgram_s { - #[doc = "< Vertex shader."] - pub vertexShader: *mut shaderInstance_s, - #[doc = "< Geometry shader."] - pub geometryShader: *mut shaderInstance_s, - #[doc = "< Geometry shader input permutation."] - pub geoShaderInputPermutation: [u32_; 2usize], - #[doc = "< Geometry shader input stride."] - pub geoShaderInputStride: u8_, -} pub type C3D_IVec = u32_; #[doc = " @struct C3D_FVec"] #[doc = " @brief Float vector"] diff --git a/citro3d/examples/triangle.rs b/citro3d/examples/triangle.rs index e46171c..099ccd7 100644 --- a/citro3d/examples/triangle.rs +++ b/citro3d/examples/triangle.rs @@ -108,7 +108,7 @@ fn scene_init(program: &mut shader::Program) -> (i8, C3D_Mtx, *mut libc::c_void) // Get the location of the uniforms let projection_name = CStr::from_bytes_with_nul(b"projection\0").unwrap(); - let uloc_projection = citro3d_sys::shaderInstanceGetUniformLocation( + let uloc_projection = ctru_sys::shaderInstanceGetUniformLocation( (*program.as_raw()).vertexShader, projection_name.as_ptr(), ); @@ -116,8 +116,8 @@ fn scene_init(program: &mut shader::Program) -> (i8, C3D_Mtx, *mut libc::c_void) // Configure attributes for use with the vertex shader let attr_info = citro3d_sys::C3D_GetAttrInfo(); citro3d_sys::AttrInfo_Init(attr_info); - citro3d_sys::AttrInfo_AddLoader(attr_info, 0, citro3d_sys::GPU_FLOAT, 3); // v0=position - citro3d_sys::AttrInfo_AddLoader(attr_info, 1, citro3d_sys::GPU_FLOAT, 3); // v1=color + citro3d_sys::AttrInfo_AddLoader(attr_info, 0, ctru_sys::GPU_FLOAT, 3); // v0=position + citro3d_sys::AttrInfo_AddLoader(attr_info, 1, ctru_sys::GPU_FLOAT, 3); // v1=color // Compute the projection matrix let projection = { @@ -137,7 +137,7 @@ fn scene_init(program: &mut shader::Program) -> (i8, C3D_Mtx, *mut libc::c_void) }; // Create the vertex buffer object - let vbo_data: *mut Vertex = citro3d_sys::linearAlloc( + let vbo_data: *mut Vertex = ctru_sys::linearAlloc( std::mem::size_of_val(&VERTICES) .try_into() .expect("size fits in u32"), @@ -166,11 +166,11 @@ fn scene_init(program: &mut shader::Program) -> (i8, C3D_Mtx, *mut libc::c_void) citro3d_sys::C3D_TexEnvSrc( env, citro3d_sys::C3D_Both, - citro3d_sys::GPU_PRIMARY_COLOR, + ctru_sys::GPU_PRIMARY_COLOR, 0, 0, ); - citro3d_sys::C3D_TexEnvFunc(env, citro3d_sys::C3D_Both, citro3d_sys::GPU_REPLACE); + citro3d_sys::C3D_TexEnvFunc(env, citro3d_sys::C3D_Both, ctru_sys::GPU_REPLACE); (uloc_projection, projection, vbo_data.cast()) } @@ -179,11 +179,11 @@ fn scene_init(program: &mut shader::Program) -> (i8, C3D_Mtx, *mut libc::c_void) fn scene_render(uloc_projection: i32, projection: &C3D_Mtx) { unsafe { // Update the uniforms - citro3d_sys::C3D_FVUnifMtx4x4(citro3d_sys::GPU_VERTEX_SHADER, uloc_projection, projection); + citro3d_sys::C3D_FVUnifMtx4x4(ctru_sys::GPU_VERTEX_SHADER, uloc_projection, projection); // Draw the VBO citro3d_sys::C3D_DrawArrays( - citro3d_sys::GPU_TRIANGLES, + ctru_sys::GPU_TRIANGLES, 0, VERTICES .len() @@ -195,6 +195,6 @@ fn scene_render(uloc_projection: i32, projection: &C3D_Mtx) { fn scene_exit(vbo_data: *mut libc::c_void) { unsafe { - citro3d_sys::linearFree(vbo_data); + ctru_sys::linearFree(vbo_data); } } From e26d01f78269b025ed016bdc7df08726054eb064 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Sun, 27 Nov 2022 19:36:58 -0700 Subject: [PATCH 4/4] Don't generate bindings Also fix some minor clippy lints + document the helper script a bit more. --- bindgen-citro3d/Cargo.toml | 1 + bindgen-citro3d/src/main.rs | 18 +++- citro3d-sys/build.rs | 2 +- citro3d-sys/src/bindings.rs | 201 ------------------------------------ 4 files changed, 17 insertions(+), 205 deletions(-) diff --git a/bindgen-citro3d/Cargo.toml b/bindgen-citro3d/Cargo.toml index 3231842..86ac6e5 100644 --- a/bindgen-citro3d/Cargo.toml +++ b/bindgen-citro3d/Cargo.toml @@ -2,6 +2,7 @@ name = "bindgen-citro3d" version = "0.1.0" edition = "2021" +description = "Helper tool to generate citro3d-sys bindings." [dependencies] bindgen = "0.62.0" diff --git a/bindgen-citro3d/src/main.rs b/bindgen-citro3d/src/main.rs index 6d1282b..ea12c12 100644 --- a/bindgen-citro3d/src/main.rs +++ b/bindgen-citro3d/src/main.rs @@ -1,3 +1,7 @@ +//! This is meant to be run as a "script" to generate bindings to `citro3d`. +//! We use this instead of `bindgen-cli` to enable the use of [`CustomCallbacks`] +//! with [`bindgen`] as a library for finer grained control of the bindings. + use std::iter::FromIterator; use std::path::PathBuf; @@ -8,7 +12,7 @@ fn main() { let devkitpro = std::env::var("DEVKITPRO").expect("DEVKITPRO not set in environment"); let devkitarm = std::env::var("DEVKITARM").expect("DEVKITARM not set in environment"); - let include_path = PathBuf::from(devkitpro).join(PathBuf::from_iter(["libctru", "include"])); + let include_path = PathBuf::from_iter([devkitpro.as_str(), "libctru", "include"]); let header = include_path.join("tex3ds.h"); let sysroot = PathBuf::from(devkitarm).join("arm-none-eabi"); @@ -25,13 +29,13 @@ fn main() { .fit_macro_constants(true) .raw_line("use ctru_sys::*;") .must_use_type("Result") - // TODO functions,types,vars .blocklist_type("u(8|16|32|64)") .opaque_type("(GPU|GFX)_.*") .opaque_type("float24Uniform_s") - .blocklist_file(".*/3ds/.*[.]h") .allowlist_file(".*/c3d/.*[.]h") .allowlist_file(".*/tex3ds[.]h") + .blocklist_file(".*/3ds/.*[.]h") + .blocklist_file(".*/sys/.*[.]h") .clang_args([ "--target=arm-none-eabi", "--sysroot", @@ -57,6 +61,14 @@ fn main() { .expect("failed to write bindings"); } +/// Custom callback struct to allow us to mark some "known good types" as +/// [`Copy`], which in turn allows using Rust `union` instead of bindgen union +/// types. See +/// +/// for more info. +/// +/// We do the same for [`Debug`] just for the convenience of derived Debug impls +/// on some `citro3d` types. #[derive(Debug)] struct CustomCallbacks; diff --git a/citro3d-sys/build.rs b/citro3d-sys/build.rs index ff80359..e865214 100644 --- a/citro3d-sys/build.rs +++ b/citro3d-sys/build.rs @@ -6,7 +6,7 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=DEVKITPRO"); - println!("cargo:rustc-link-search=native={}/libctru/lib", dkp_path); + println!("cargo:rustc-link-search=native={dkp_path}/libctru/lib"); println!( "cargo:rustc-link-lib=static={}", match debug_symbols.as_str() { diff --git a/citro3d-sys/src/bindings.rs b/citro3d-sys/src/bindings.rs index c6fc58e..76ca7ad 100644 --- a/citro3d-sys/src/bindings.rs +++ b/citro3d-sys/src/bindings.rs @@ -92,210 +92,9 @@ pub const C3D_DEFAULT_CMDBUF_SIZE: u32 = 262144; pub const C3DF_LightEnv_IsCP_Any: u32 = 66846720; pub const C3DF_LightEnv_LutDirtyAll: u32 = 4227858432; pub type __int64_t = ::libc::c_longlong; -pub type _LOCK_T = i32; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __lock_t { - pub lock: _LOCK_T, - pub thread_tag: u32, - pub counter: u32, -} -pub type _LOCK_RECURSIVE_T = __lock_t; pub type _off_t = __int64_t; pub type _fpos_t = __int64_t; pub type wint_t = ::libc::c_int; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _mbstate_t { - pub __count: ::libc::c_int, - pub __value: _mbstate_t__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _mbstate_t__bindgen_ty_1 { - pub __wch: wint_t, - pub __wchb: [::libc::c_uchar; 4usize], -} -pub type __ULong = ::libc::c_ulong; -pub type _flock_t = _LOCK_RECURSIVE_T; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __locale_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _Bigint { - pub _next: *mut _Bigint, - pub _k: ::libc::c_int, - pub _maxwds: ::libc::c_int, - pub _sign: ::libc::c_int, - pub _wds: ::libc::c_int, - pub _x: [__ULong; 1usize], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __tm { - pub __tm_sec: ::libc::c_int, - pub __tm_min: ::libc::c_int, - pub __tm_hour: ::libc::c_int, - pub __tm_mday: ::libc::c_int, - pub __tm_mon: ::libc::c_int, - pub __tm_year: ::libc::c_int, - pub __tm_wday: ::libc::c_int, - pub __tm_yday: ::libc::c_int, - pub __tm_isdst: ::libc::c_int, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _on_exit_args { - pub _fnargs: [*mut ::libc::c_void; 32usize], - pub _dso_handle: [*mut ::libc::c_void; 32usize], - pub _fntypes: __ULong, - pub _is_cxa: __ULong, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _atexit { - pub _next: *mut _atexit, - pub _ind: ::libc::c_int, - pub _fns: [::core::option::Option; 32usize], - pub _on_exit_args: _on_exit_args, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __sbuf { - pub _base: *mut ::libc::c_uchar, - pub _size: ::libc::c_int, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __sFILE { - pub _p: *mut ::libc::c_uchar, - pub _r: ::libc::c_int, - pub _w: ::libc::c_int, - pub _flags: ::libc::c_short, - pub _file: ::libc::c_short, - pub _bf: __sbuf, - pub _lbfsize: ::libc::c_int, - pub _cookie: *mut ::libc::c_void, - pub _read: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::libc::c_void, - arg3: *mut ::libc::c_char, - arg4: ::libc::c_int, - ) -> ::libc::c_int, - >, - pub _write: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::libc::c_void, - arg3: *const ::libc::c_char, - arg4: ::libc::c_int, - ) -> ::libc::c_int, - >, - pub _seek: ::core::option::Option< - unsafe extern "C" fn( - arg1: *mut _reent, - arg2: *mut ::libc::c_void, - arg3: _fpos_t, - arg4: ::libc::c_int, - ) -> _fpos_t, - >, - pub _close: ::core::option::Option< - unsafe extern "C" fn(arg1: *mut _reent, arg2: *mut ::libc::c_void) -> ::libc::c_int, - >, - pub _ub: __sbuf, - pub _up: *mut ::libc::c_uchar, - pub _ur: ::libc::c_int, - pub _ubuf: [::libc::c_uchar; 3usize], - pub _nbuf: [::libc::c_uchar; 1usize], - pub _lb: __sbuf, - pub _blksize: ::libc::c_int, - pub _offset: _off_t, - pub _data: *mut _reent, - pub _lock: _flock_t, - pub _mbstate: _mbstate_t, - pub _flags2: ::libc::c_int, -} -pub type __FILE = __sFILE; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _glue { - pub _next: *mut _glue, - pub _niobs: ::libc::c_int, - pub _iobs: *mut __FILE, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _rand48 { - pub _seed: [::libc::c_ushort; 3usize], - pub _mult: [::libc::c_ushort; 3usize], - pub _add: ::libc::c_ushort, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent { - pub _errno: ::libc::c_int, - pub _stdin: *mut __FILE, - pub _stdout: *mut __FILE, - pub _stderr: *mut __FILE, - pub _inc: ::libc::c_int, - pub _emergency: [::libc::c_char; 25usize], - pub _unspecified_locale_info: ::libc::c_int, - pub _locale: *mut __locale_t, - pub __sdidinit: ::libc::c_int, - pub __cleanup: ::core::option::Option, - pub _result: *mut _Bigint, - pub _result_k: ::libc::c_int, - pub _p5s: *mut _Bigint, - pub _freelist: *mut *mut _Bigint, - pub _cvtlen: ::libc::c_int, - pub _cvtbuf: *mut ::libc::c_char, - pub _new: _reent__bindgen_ty_1, - pub _atexit: *mut _atexit, - pub _atexit0: _atexit, - pub _sig_func: *mut ::core::option::Option, - pub __sglue: _glue, - pub __sf: [__FILE; 3usize], - pub deviceData: *mut ::libc::c_void, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union _reent__bindgen_ty_1 { - pub _reent: _reent__bindgen_ty_1__bindgen_ty_1, - pub _unused: _reent__bindgen_ty_1__bindgen_ty_2, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _reent__bindgen_ty_1__bindgen_ty_1 { - pub _unused_rand: ::libc::c_uint, - pub _strtok_last: *mut ::libc::c_char, - pub _asctime_buf: [::libc::c_char; 26usize], - pub _localtime_buf: __tm, - pub _gamma_signgam: ::libc::c_int, - pub _rand_next: ::libc::c_ulonglong, - pub _r48: _rand48, - pub _mblen_state: _mbstate_t, - pub _mbtowc_state: _mbstate_t, - pub _wctomb_state: _mbstate_t, - pub _l64a_buf: [::libc::c_char; 8usize], - pub _signal_buf: [::libc::c_char; 24usize], - pub _getdate_err: ::libc::c_int, - pub _mbrlen_state: _mbstate_t, - pub _mbrtowc_state: _mbstate_t, - pub _mbsrtowcs_state: _mbstate_t, - pub _wcrtomb_state: _mbstate_t, - pub _wcsrtombs_state: _mbstate_t, - pub _h_errno: ::libc::c_int, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _reent__bindgen_ty_1__bindgen_ty_2 { - pub _nextf: [*mut ::libc::c_uchar; 30usize], - pub _nmalloc: [::libc::c_uint; 30usize], -} pub type C3D_IVec = u32_; #[doc = " @struct C3D_FVec"] #[doc = " @brief Float vector"]