aboutsummaryrefslogtreecommitdiff
path: root/ctru-sys/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'ctru-sys/src/gpu')
-rw-r--r--ctru-sys/src/gpu/gpu.rs308
-rw-r--r--ctru-sys/src/gpu/gx.rs55
-rw-r--r--ctru-sys/src/gpu/mod.rs8
-rw-r--r--ctru-sys/src/gpu/registers.rs19
-rw-r--r--ctru-sys/src/gpu/shaderProgram.rs89
-rw-r--r--ctru-sys/src/gpu/shader_program.rs42
-rw-r--r--ctru-sys/src/gpu/shbin.rs193
7 files changed, 278 insertions, 436 deletions
diff --git a/ctru-sys/src/gpu/gpu.rs b/ctru-sys/src/gpu/gpu.rs
index 24f2f90..30e7a03 100644
--- a/ctru-sys/src/gpu/gpu.rs
+++ b/ctru-sys/src/gpu/gpu.rs
@@ -1,294 +1,26 @@
-use ctru::Handle;
+/* automatically generated by rust-bindgen */
#[inline]
-pub fn GPUCMD_HEADER(incremental: i32, mask: i32, reg: i32) {
- (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF));
+pub fn GPUCMD_HEADER(incremental: u32, mask: u32, reg: u32) -> u32{
+ (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF))
}
-#[inline]
-pub fn GPU_TEXTURE_MAG_FILTER(v: i32) {
- (((v)&0x1)<<1); //takes a GPU_TEXTURE_FILTER_PARAM
-}
-
-#[inline]
-pub fn GPU_TEXTURE_MIN_FILTER(v: i32) {
- (((v)&0x1)<<2); //takes a GPU_TEXTURE_FILTER_PARAM
-}
-
-#[inline]
-pub fn GPU_TEXTURE_WRAP_S(v: i32) {
- (((v)&0x3)<<8); //takes a GPU_TEXTURE_WRAP_PARAM
-}
-
-#[inline]
-pub fn GPU_TEXTURE_WRAP_T(v: i32) {
- (((v)&0x3)<<12); //takes a GPU_TEXTURE_WRAP_PARAM
-}
-
-#[repr(C)]
-pub enum GPU_TEXTURE_FILTER_PARAM {
- GPU_NEAREST = 0x0,
- GPU_LINEAR = 0x1
-}
-
-#[repr(C)]
-pub enum GPU_TEXTURE_WRAP_PARAM {
- GPU_CLAMP_TO_EDGE = 0x0,
- GPU_REPEAT = 0x1
-}
-
-#[repr(C)]
-pub enum GPU_TEXUNIT {
- GPU_TEXUNIT0 = 0x1,
- GPU_TEXUNIT1 = 0x2,
- GPU_TEXUNIT2 = 0x4
-}
-
-#[repr(C)]
-pub enum GPU_TEXCOLOR {
- GPU_RGBA8=0x0,
- GPU_RGB8=0x1,
- GPU_RGBA5551=0x2,
- GPU_RGB565=0x3,
- GPU_RGBA4=0x4,
- GPU_LA8=0x5,
- GPU_HILO8=0x6,
- GPU_L8=0x7,
- GPU_A8=0x8,
- GPU_LA4=0x9,
- GPU_L4=0xA,
- GPU_ETC1=0xB,
- GPU_ETC1A4=0xC
-}
-
-#[repr(C)]
-pub enum GPU_TESTFUNC {
- GPU_NEVER = 0,
- GPU_ALWAYS = 1,
- GPU_EQUAL = 2,
- GPU_NOTEQUAL = 3,
- GPU_LESS = 4,
- GPU_LEQUAL = 5,
- GPU_GREATER = 6,
- GPU_GEQUAL = 7
-}
-
-#[repr(C)]
-pub enum GPU_SCISSORMODE {
- GPU_SCISSOR_DISABLE = 0, // disable scissor test
- GPU_SCISSOR_INVERT = 1, // exclude pixels inside the scissor box
- // 2 is the same as 0
- GPU_SCISSOR_NORMAL = 3, // exclude pixels outside of the scissor box
-}
-
-#[repr(C)]
-pub enum GPU_STENCILOP {
- GPU_KEEP = 0, // keep destination value
- GPU_AND_NOT = 1, // destination & ~source
- GPU_XOR = 5, // destination ^ source
- // 2 is the same as 1. Other values are too weird to even be usable.
-}
-
-#[repr(C)]
-pub enum GPU_WRITEMASK {
- GPU_WRITE_RED = 0x01,
- GPU_WRITE_GREEN = 0x02,
- GPU_WRITE_BLUE = 0x04,
- GPU_WRITE_ALPHA = 0x08,
- GPU_WRITE_DEPTH = 0x10,
-
- GPU_WRITE_COLOR = 0x0F,
- GPU_WRITE_ALL = 0x1F
-}
-
-#[repr(C)]
-pub enum GPU_BLENDEQUATION {
- GPU_BLEND_ADD = 0,
- GPU_BLEND_SUBTRACT = 1,
- GPU_BLEND_REVERSE_SUBTRACT = 2,
- GPU_BLEND_MIN = 3,
- GPU_BLEND_MAX = 4
-}
-
-#[repr(C)]
-pub enum GPU_BLENDFACTOR {
- GPU_ZERO = 0,
- GPU_ONE = 1,
- GPU_SRC_COLOR = 2,
- GPU_ONE_MINUS_SRC_COLOR = 3,
- GPU_DST_COLOR = 4,
- GPU_ONE_MINUS_DST_COLOR = 5,
- GPU_SRC_ALPHA = 6,
- GPU_ONE_MINUS_SRC_ALPHA = 7,
- GPU_DST_ALPHA = 8,
- GPU_ONE_MINUS_DST_ALPHA = 9,
- GPU_CONSTANT_COLOR = 10,
- GPU_ONE_MINUS_CONSTANT_COLOR = 11,
- GPU_CONSTANT_ALPHA = 12,
- GPU_ONE_MINUS_CONSTANT_ALPHA = 13,
- GPU_SRC_ALPHA_SATURATE = 14
-}
-
-#[repr(C)]
-pub enum GPU_LOGICOP {
- GPU_LOGICOP_CLEAR = 0,
- GPU_LOGICOP_AND = 1,
- GPU_LOGICOP_AND_REVERSE = 2,
- GPU_LOGICOP_COPY = 3,
- GPU_LOGICOP_SET = 4,
- GPU_LOGICOP_COPY_INVERTED = 5,
- GPU_LOGICOP_NOOP = 6,
- GPU_LOGICOP_INVERT = 7,
- GPU_LOGICOP_NAND = 8,
- GPU_LOGICOP_OR = 9,
- GPU_LOGICOP_NOR = 10,
- GPU_LOGICOP_XOR = 11,
- GPU_LOGICOP_EQUIV = 12,
- GPU_LOGICOP_AND_INVERTED = 13,
- GPU_LOGICOP_OR_REVERSE = 14,
- GPU_LOGICOP_OR_INVERTED = 15
-}
-
-#[repr(C)]
-pub enum GPU_FORMATS {
- GPU_BYTE = 0,
- GPU_UNSIGNED_BYTE = 1,
- GPU_SHORT = 2,
- GPU_FLOAT = 3
-}
-
-//defines for CW ?
-#[repr(C)]
-pub enum GPU_CULLMODE {
- GPU_CULL_NONE = 0,
- GPU_CULL_FRONT_CCW = 1,
- GPU_CULL_BACK_CCW = 2
-}
-
-#[inline]
-pub fn GU_ATTRIBFMT(i: i32, n: i32, f: i32) {
- (((((n)-1)<<2)|((f)&3))<<((i)*4));
-}
-
-/**
-* Texture combiners sources
-*/
-#[repr(C)]
-pub enum GPU_TEVSRC{
- GPU_PRIMARY_COLOR = 0x00,
- GPU_TEXTURE0 = 0x03,
- GPU_TEXTURE1 = 0x04,
- GPU_TEXTURE2 = 0x05,
- GPU_TEXTURE3 = 0x06,
- GPU_CONSTANT = 0x0E,
- GPU_PREVIOUS = 0x0F,
-}
-
-/**
-* Texture RGB combiners operands
-*/
-#[repr(C)]
-pub enum GPU_TEVOP_RGB{
- GPU_TEVOP_RGB_SRC_COLOR = 0x00,
- GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR = 0x01,
- GPU_TEVOP_RGB_SRC_ALPHA = 0x02,
- GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA = 0x03,
- GPU_TEVOP_RGB_SRC0_RGB = 0x04,
- GPU_TEVOP_RGB_0x05 = 0x05,
- GPU_TEVOP_RGB_0x06 = 0x06,
- GPU_TEVOP_RGB_0x07 = 0x07,
- GPU_TEVOP_RGB_SRC1_RGB = 0x08,
- GPU_TEVOP_RGB_0x09 = 0x09,
- GPU_TEVOP_RGB_0x0A = 0x0A,
- GPU_TEVOP_RGB_0x0B = 0x0B,
- GPU_TEVOP_RGB_SRC2_RGB = 0x0C,
- GPU_TEVOP_RGB_0x0D = 0x0D,
- GPU_TEVOP_RGB_0x0E = 0x0E,
- GPU_TEVOP_RGB_0x0F = 0x0F,
-};
-
-/**
-* Texture ALPHA combiners operands
-*/
-#[repr(C)]
-pub enum GPU_TEVOP_A {
- GPU_TEVOP_A_SRC_ALPHA = 0x00,
- GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA = 0x01,
- GPU_TEVOP_A_SRC0_RGB = 0x02,
- GPU_TEVOP_A_SRC1_RGB = 0x04,
- GPU_TEVOP_A_SRC2_RGB = 0x06,
-}
-
-/**
-* Texture combiner functions
-*/
-pub enum GPU_COMBINEFUNC {
- GPU_REPLACE = 0x00,
- GPU_MODULATE = 0x01,
- GPU_ADD = 0x02,
- GPU_ADD_SIGNED = 0x03,
- GPU_INTERPOLATE = 0x04,
- GPU_SUBTRACT = 0x05,
- GPU_DOT3_RGB = 0x06 //RGB only
-}
-
-#[inline]
-pub fn GPU_TEVSOURCES(a, b, c) {
- (((a))|((b)<<4)|((c)<<8));
-}
-
-#[inline]
-pub fn GPU_TEVOPERANDS(a, b, c) {
- (((a))|((b)<<4)|((c)<<8));
-}
-
-#[repr(C)]
-pub enum GPU_Primitive_t {
- GPU_TRIANGLES = 0x0000,
- GPU_TRIANGLE_STRIP = 0x0100,
- GPU_TRIANGLE_FAN = 0x0200,
- GPU_UNKPRIM = 0x0300 // ?
-}
-
-#[repr(C)]
-pub enum GPU_SHADER_TYPE {
- GPU_VERTEX_SHADER=0x0,
- GPU_GEOMETRY_SHADER=0x1
-}
-
-
extern "C" {
- pub fn GPU_Init(gsphandle: *mut Handle) -> ();
- pub fn GPU_Reset(gxbuf: *mut u32, gpuBuf: *mut u32, gpuBufSize: u32) -> ();
-
- pub fn GPUCMD_SetBuffer(adr: *mut u32, size: u32, offset: u32) -> ();
- pub fn GPUCMD_SetBufferOffset(offset: u32) -> ();
- pub fn GPUCMD_GetBuffer(adr: *mut *mut u32, size: *mut u32, offset: *mut u32) -> ();
- pub fn GPUCMD_AddRawCommands(cmd: *mut u32, size: u32) -> ();
- pub fn GPUCMD_Run(gxbuf: *mut u32) -> ();
- pub fn GPUCMD_FlushAndRun(gxbuf: *mut u32) -> ();
- pub fn GPUCMD_Add(header: u32, param: *mut u32, paramlength: u32) -> ();
- pub fn GPUCMD_Finalize() -> ();
- pub fn GPU_SetFloatUniform(_type: GPU_SHADER_TYPE, startreg: u32, data: *mut u32, numreg: u32) -> ();
- pub fn GPU_SetViewport(depthBuffer: *mut u32, colorBuffer: *mut u32, x: u32, y: u32, w: u32, h: u32) -> ();
- pub fn GPU_SetScissorTest(mode: GPU_SCISSORMODE, x: u32, y: u32, w: u32, h: u32) -> ();
- pub fn GPU_DepthMap(zScale: f32, zOffset: f32) -> ();
- pub fn GPU_SetAlphaTest(enable: u8, function: GPU_TESTFUNC, _ref: u8) -> ();
- pub fn GPU_SetDepthTestAndWriteMask(enable: u8, function: GPU_TESTFUNC, writemask: GPU_WRITEMASK) -> ();
- pub fn GPU_SetStencilTest(enable: u8, function: GPU_TESTFUNC, _ref: _u8, mask: _u8, replace: _u8) -> ();
- pub fn GPU_SetStencilOp(sfail: GPU_STENCILOP, dfail: GPU_STENCILOP, pass: GPU_STENCILOP) -> ();
- pub fn GPU_SetFaceCulling(mode: GPU_CULLMODE) -> ();
- pub fn GPU_SetAlphaBlending(colorEquation: GPU_BLENDEQUATION, alphaEquation: GPU_BLENDEQUATION, colorSrc: GPU_BLENDFACTOR, colorDst: GPU_BLENDFACTOR, alphaSrc: GPU_BLENDFACTOR, alphaDst: GPU_BLENDFACTOR) -> ();
- pub fn GPU_SetColorLogicOp(op: GPU_LOGICOP) -> ();
- pub fn GPU_SetBlendingColor(r: u8, g: u8, b: u8, a: u8) -> ();
- pub fn GPU_SetAttributeBuffers(totalAttributes: u8, baseAddress: *mut u32, attributeFormats: u64, attributeMask: u16, attributePermutation: u64, numBuffers: u8, bufferOffsets: *mut u32, bufferPermutations: *mut u64, bufferNumAttributes: *mut u8) -> ();
- pub fn GPU_SetTextureEnable(units: GPU_TEXUNIT) -> ();
- pub fn GPU_SetTexture(unit: GPU_TEXUNIT, data: *mut u32, width: u16, height: u16, param: u32, colorType: GPU_TEXCOLOR) -> ();
- pub fn GPU_SetTexEnv(id: u8, rgbSources: u16, alphaSources: u16, rgbOperands: u16, alphaOperands: u16, rgbCombine: GPU_COMBINEFUNC, alphaCombine: GPU_COMBINEFUNC, constantColor: u32) -> ();
- pub fn GPU_DrawArray(primitive: GPU_Primitive_t, n: u32) -> ();
- pub fn GPU_DrawElements(primitive: GPU_Primitive_t, indexArray: *mut u32, n: u32) -> ();
- pub fn GPU_FinishDrawing() -> ();
- pub fn GPU_SetShaderOutmap(outmapData: *mut u32) -> ();
- pub fn GPU_SendShaderCode(_type: GPU_SHADER_TYPE, data: *mut u32, offset: u16, length: u16) -> ();
- pub fn GPU_SendOperandDescriptors(_type: GPU_SHADER_TYPE, data: *mut u32, offset: u16, length: u16) -> ();
+ pub static mut gpuCmdBuf: *mut u32;
+ pub static mut gpuCmdBufSize: u32;
+ pub static mut gpuCmdBufOffset: u32;
+
+ pub fn GPUCMD_SetBuffer(adr: *mut u32, size: u32, offset: u32);
+ pub fn GPUCMD_SetBufferOffset(offset: u32);
+ pub fn GPUCMD_GetBuffer(adr: *mut *mut u32, size: *mut u32,
+ offset: *mut u32);
+ pub fn GPUCMD_AddRawCommands(cmd: *mut u32, size: u32);
+ pub fn GPUCMD_Run();
+ pub fn GPUCMD_FlushAndRun();
+ pub fn GPUCMD_Add(header: u32, param: *mut u32, paramlength: u32);
+ pub fn GPUCMD_Finalize();
+ pub fn f32tof16(f: f32) -> u32;
+ pub fn f32tof20(f: f32) -> u32;
+ pub fn f32tof24(f: f32) -> u32;
+ pub fn f32tof31(f: f32) -> u32;
}
diff --git a/ctru-sys/src/gpu/gx.rs b/ctru-sys/src/gpu/gx.rs
index d26c9ab..69eeddf 100644
--- a/ctru-sys/src/gpu/gx.rs
+++ b/ctru-sys/src/gpu/gx.rs
@@ -1,3 +1,5 @@
+use ::Result;
+
#[inline]
pub fn GX_BUFFER_DIM(w: u32, h: u32) {
(((h)<<16)|((w)&0xFFFF));
@@ -10,7 +12,7 @@ pub enum GX_TRANSFER_FORMAT
GX_TRANSFER_FMT_RGB8 = 1,
GX_TRANSFER_FMT_RGB565 = 2,
GX_TRANSFER_FMT_RGB5A1 = 3,
- GX_TRANSFER_FMT_RGBA4 = 4
+ GX_TRANSFER_FMT_RGBA4 = 4,
}
#[repr(C)]
@@ -18,7 +20,7 @@ pub enum GX_TRANSFER_SCALE
{
GX_TRANSFER_SCALE_NO = 0,
GX_TRANSFER_SCALE_X = 1,
- GX_TRANSFER_SCALE_Y = 2
+ GX_TRANSFER_SCALE_Y = 2,
}
#[repr(C)]
@@ -31,43 +33,62 @@ pub enum GX_FILL_CONTROL {
}
#[inline]
-pub fn GX_TRANSFER_FLIP_VERT(x) {
+pub fn GX_TRANSFER_FLIP_VERT(x: i32) {
((x)<<0);
}
#[inline]
-pub fn GX_TRANSFER_OUT_TILED(x) {
+pub fn GX_TRANSFER_OUT_TILED(x: i32) {
((x)<<1);
}
#[inline]
-pub fn GX_TRANSFER_RAW_COPY(x) {
- ((x)<<3)
+pub fn GX_TRANSFER_RAW_COPY(x: i32) {
+ ((x)<<3);
}
#[inline]
-pub fn GX_TRANSFER_IN_FORMAT(x) {
+pub fn GX_TRANSFER_IN_FORMAT(x: i32) {
((x)<<8);
}
#[inline]
-pub fn GX_TRANSFER_OUT_FORMAT(x) {
- ((x)<<12)
+pub fn GX_TRANSFER_OUT_FORMAT(x: i32) {
+ ((x)<<12);
}
#[inline]
-pub fn GX_TRANSFER_SCALING(x) {
+pub fn GX_TRANSFER_SCALING(x: i32) {
((x)<<24);
}
-use ctru::Result;
+#[inline]
+pub fn GX_CMDLIST_BIT0() {
+ (1u32<<(0));
+}
+#[inline]
+pub fn GX_CMNDLIST_FLUSH() {
+ (1u32<<(1));
+}
extern "C" {
- pub fn GX_RequestDma(gxbuf: *mut u32, src: *mut u32, dst: *mut u32, length: u32) -> Result;
- pub fn GX_SetCommandList_Last(gxbuf: *mut u32, buf0a: *mut u32, buf0s: u32, flags: u8) -> Result;
- pub fn GX_SetMemoryFill(gxbuf: *mut u32, buf0a: *mut u32, buf0v: u32, buf0e: *mut u32, width0: u16, buf1a: *mut u32, buf1v: u32, buf1e: *mut u32, width1: u16) -> Result;
- pub fn GX_SetDisplayTransfer(gxbuf: *mut u32, inadr: *mut u32, indim: u32, outadr: *mut u32, outdim: u32, flags: u32) -> Result;
- pub fn GX_SetTextureCopy(gxbuf: *mut u32, inadr: *mut u32, indim: u32, outadr: *mut u32, outdim: u32, size: u32, flags: u32) -> Result;
- pub fn GX_SetCommandList_First(gxbuf: *mut u32, buf0a: *mut u32, buf0s: u32, buf1a: *mut u32, buf1s: u32, buf2a: *mut u32, buf2s: u32) -> Result;
+ pub static mut gxCmdBuf: *mut u32;
+
+ pub fn GX_RequestDma(src: *mut u32, dst: *mut u32, length: u32)
+ -> Result;
+ pub fn GX_ProcessCommandList(buf0a: *mut u32, buf0s: u32, flags: u8)
+ -> Result;
+ pub fn GX_MemoryFill(buf0a: *mut u32, buf0v: u32, buf0e: *mut u32,
+ control0: u16, buf1a: *mut u32, buf1v: u32,
+ buf1e: *mut u32, control1: u16) -> Result;
+ pub fn GX_DisplayTransfer(inadr: *mut u32, indim: u32,
+ outadr: *mut u32, outdim: u32, flags: u32)
+ -> Result;
+ pub fn GX_TextureCopy(inadr: *mut u32, indim: u32, outadr: *mut u32,
+ outdim: u32, size: u32, flags: u32) -> Result;
+ pub fn GX_FlushCacheRegions(buf0a: *mut u32, buf0s: u32,
+ buf1a: *mut u32, buf1s: u32,
+ buf2a: *mut u32, buf2s: u32) -> Result;
}
+
diff --git a/ctru-sys/src/gpu/mod.rs b/ctru-sys/src/gpu/mod.rs
index 8d71046..2b9cb99 100644
--- a/ctru-sys/src/gpu/mod.rs
+++ b/ctru-sys/src/gpu/mod.rs
@@ -1,11 +1,5 @@
pub mod gpu;
pub mod gx;
pub mod registers;
-pub mod shader_program;
+pub mod shaderProgram;
pub mod shbin;
-
-use self::gpu::*;
-use self::gx::*;
-use self::registers::*;
-use self::shader_program::*;
-use self::shbin::*;
diff --git a/ctru-sys/src/gpu/registers.rs b/ctru-sys/src/gpu/registers.rs
index 739a50a..98b2a3b 100644
--- a/ctru-sys/src/gpu/registers.rs
+++ b/ctru-sys/src/gpu/registers.rs
@@ -1,3 +1,4 @@
+//Miscellaneous registers (0x000-0x03F)
pub const GPUREG_0000: i32 = 0x0000;
pub const GPUREG_0001: i32 = 0x0001;
pub const GPUREG_0002: i32 = 0x0002;
@@ -62,6 +63,8 @@ pub const GPUREG_003C: i32 = 0x003C;
pub const GPUREG_003D: i32 = 0x003D;
pub const GPUREG_003E: i32 = 0x003E;
pub const GPUREG_003F: i32 = 0x003F;
+
+//Rasterizer registers (0x040-0x07F)
pub const GPUREG_FACECULLING_CONFIG: i32 = 0x0040;
pub const GPUREG_0041: i32 = 0x0041;
pub const GPUREG_0042: i32 = 0x0042;
@@ -126,6 +129,8 @@ pub const GPUREG_007C: i32 = 0x007C;
pub const GPUREG_007D: i32 = 0x007D;
pub const GPUREG_007E: i32 = 0x007E;
pub const GPUREG_007F: i32 = 0x007F;
+
+//Texturing registers (0x080-0x0FF)
pub const GPUREG_TEXUNITS_CONFIG: i32 = 0x0080;
pub const GPUREG_0081: i32 = 0x0081;
pub const GPUREG_TEXUNIT0_DIM: i32 = 0x0082;
@@ -254,6 +259,8 @@ pub const GPUREG_TEXENV5_CONFIG4: i32 = 0x00FC;
pub const GPUREG_00FD: i32 = 0x00FD;
pub const GPUREG_00FE: i32 = 0x00FE;
pub const GPUREG_00FF: i32 = 0x00FF;
+
+//Framebuffer registers (0x100-0x13F)
pub const GPUREG_COLOROUTPUT_CONFIG: i32 = 0x0100;
pub const GPUREG_BLEND_CONFIG: i32 = 0x0101;
pub const GPUREG_COLORLOGICOP_CONFIG: i32 = 0x0102;
@@ -318,6 +325,8 @@ pub const GPUREG_013C: i32 = 0x013C;
pub const GPUREG_013D: i32 = 0x013D;
pub const GPUREG_013E: i32 = 0x013E;
pub const GPUREG_013F: i32 = 0x013F;
+
+//Fragment lighting registers (0x140-0x1FF)
pub const GPUREG_0140: i32 = 0x0140;
pub const GPUREG_0141: i32 = 0x0141;
pub const GPUREG_0142: i32 = 0x0142;
@@ -510,6 +519,8 @@ pub const GPUREG_01FC: i32 = 0x01FC;
pub const GPUREG_01FD: i32 = 0x01FD;
pub const GPUREG_01FE: i32 = 0x01FE;
pub const GPUREG_01FF: i32 = 0x01FF;
+
+//Geometry pipeline registers (0x200-0x27F)
pub const GPUREG_ATTRIBBUFFERS_LOC: i32 = 0x0200;
pub const GPUREG_ATTRIBBUFFERS_FORMAT_LOW: i32 = 0x0201;
pub const GPUREG_ATTRIBBUFFERS_FORMAT_HIGH: i32 = 0x0202;
@@ -638,6 +649,8 @@ pub const GPUREG_027C: i32 = 0x027C;
pub const GPUREG_027D: i32 = 0x027D;
pub const GPUREG_027E: i32 = 0x027E;
pub const GPUREG_027F: i32 = 0x027F;
+
+//Geometry shader registers (0x280-0x2AF)
pub const GPUREG_GSH_BOOLUNIFORM: i32 = 0x0280;
pub const GPUREG_GSH_INTUNIFORM_I0: i32 = 0x0281;
pub const GPUREG_GSH_INTUNIFORM_I1: i32 = 0x0282;
@@ -665,6 +678,8 @@ pub const GPUREG_GSH_OPDESCS_CONFIG: i32 = 0x02A5;
pub const GPUREG_GSH_OPDESCS_DATA: i32 = 0x02A6;
pub const GPUREG_02AE: i32 = 0x02AE;
pub const GPUREG_02AF: i32 = 0x02AF;
+
+//Vertex shader registers (0x2B0-0x2DF)
pub const GPUREG_VSH_BOOLUNIFORM: i32 = 0x02B0;
pub const GPUREG_VSH_INTUNIFORM_I0: i32 = 0x02B1;
pub const GPUREG_VSH_INTUNIFORM_I1: i32 = 0x02B2;
@@ -692,6 +707,8 @@ pub const GPUREG_VSH_OPDESCS_CONFIG: i32 = 0x02D5;
pub const GPUREG_VSH_OPDESCS_DATA: i32 = 0x02D6;
pub const GPUREG_02DE: i32 = 0x02DE;
pub const GPUREG_02DF: i32 = 0x02DF;
+
+//Unknown registers (0x2E0-0x2FF)
pub const GPUREG_02E0: i32 = 0x02E0;
pub const GPUREG_02E1: i32 = 0x02E1;
pub const GPUREG_02E2: i32 = 0x02E2;
@@ -723,4 +740,4 @@ pub const GPUREG_02FB: i32 = 0x02FB;
pub const GPUREG_02FC: i32 = 0x02FC;
pub const GPUREG_02FD: i32 = 0x02FD;
pub const GPUREG_02FE: i32 = 0x02FE;
-pub const GPUREG_02FF: i32 = 0x02FF
+pub const GPUREG_02FF: i32 = 0x02FF;
diff --git a/ctru-sys/src/gpu/shaderProgram.rs b/ctru-sys/src/gpu/shaderProgram.rs
new file mode 100644
index 0000000..f81f772
--- /dev/null
+++ b/ctru-sys/src/gpu/shaderProgram.rs
@@ -0,0 +1,89 @@
+use ::Result;
+use ::types::*;
+use gpu::shbin::*;
+
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed1 {
+ pub id: u32,
+ pub data: [u32; 3usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed1 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed1 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type float24Uniform_s = Struct_Unnamed1;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed2 {
+ pub dvle: *mut DVLE_s,
+ pub boolUniforms: u16,
+ pub boolUniformMask: u16,
+ pub intUniforms: [u32; 4usize],
+ pub float24Uniforms: *mut float24Uniform_s,
+ pub intUniformMask: u8,
+ pub numFloat24Uniforms: u8,
+}
+impl ::core::clone::Clone for Struct_Unnamed2 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed2 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type shaderInstance_s = Struct_Unnamed2;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed3 {
+ pub vertexShader: *mut shaderInstance_s,
+ pub geometryShader: *mut shaderInstance_s,
+ pub geoShaderInputPermutation: [u32; 2usize],
+ pub geoShaderInputStride: u8,
+ pub geoShaderMode: u8,
+}
+impl ::core::clone::Clone for Struct_Unnamed3 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed3 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type shaderProgram_s = Struct_Unnamed3;
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed4 {
+ GSH_NORMAL = 0,
+ GSH_PARTICLE = 1,
+ GSH_SUBDIVISION_LOOP = 2,
+ GSH_SUBDIVISION_CATMULL_CLARK = 3,
+}
+pub type geoShaderMode = Enum_Unnamed4;
+extern "C" {
+ pub fn shaderInstanceInit(si: *mut shaderInstance_s, dvle: *mut DVLE_s)
+ -> Result;
+ pub fn shaderInstanceFree(si: *mut shaderInstance_s) -> Result;
+ pub fn shaderInstanceSetBool(si: *mut shaderInstance_s,
+ id: i32, value: u8)
+ -> Result;
+ pub fn shaderInstanceGetBool(si: *mut shaderInstance_s,
+ id: i32, value: *mut u8)
+ -> Result;
+ pub fn shaderInstanceGetUniformLocation(si: *mut shaderInstance_s,
+ name:
+ *const u8)
+ -> s8;
+ pub fn shaderProgramInit(sp: *mut shaderProgram_s) -> Result;
+ pub fn shaderProgramFree(sp: *mut shaderProgram_s) -> Result;
+ pub fn shaderProgramSetVsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s)
+ -> Result;
+ pub fn shaderProgramSetGsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s,
+ stride: u8) -> Result;
+ pub fn shaderProgramSetGshInputPermutation(sp: *mut shaderProgram_s,
+ permutation: u64) -> Result;
+ pub fn shaderProgramSetGshMode(sp: *mut shaderProgram_s,
+ mode: geoShaderMode) -> Result;
+ pub fn shaderProgramConfigure(sp: *mut shaderProgram_s, sendVshCode: u8,
+ sendGshCode: u8) -> Result;
+ pub fn shaderProgramUse(sp: *mut shaderProgram_s) -> Result;
+}
diff --git a/ctru-sys/src/gpu/shader_program.rs b/ctru-sys/src/gpu/shader_program.rs
deleted file mode 100644
index bf373e1..0000000
--- a/ctru-sys/src/gpu/shader_program.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use super::shbin::*;
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct float24Uniform_s {
- id: u32,
- data: [u32; 3usize]
-}
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct shaderInstance_s {
- pub dvle: *mut DVLE_s;
- pub boolUniforms: u16,
- pub intUniforms: [u32; 4usize],
- pub float24Uniforms: *mut float24Uniform_s,
- pub numFloat24Uniforms: u8,
-}
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct shaderProgram_s {
- pub vertexShader: *mut shaderInstance_s,
- pub geometryShader: *mut shaderInstance_s,
- pub geometryShaderInputStride: u8,
-}
-
-use ctru::Result;
-
-
-extern "C" {
- pub fn shaderInstanceInit(si: *mut shaderInstance_s, dvle: *mut DVLE_s) -> Result;
- pub fn shaderInstanceFree(si: *mut shaderInstance_s) -> Result;
- pub fn shaderInstanceSetBool(si: *mut shaderInstance_s, id: ::libc::c_int, value: u8) -> Result;
- pub fn shaderInstanceGetBool(si: *mut shaderInstance_s, id: ::libc::c_int, value: *mut u8) -> Result;
- pub fn shaderInstanceGetUniformLocation(si: *mut shaderInstance_s, name: *const ::libc::c_char) -> Result;
- pub fn shaderProgramInit(sp: *mut shaderProgram_s) -> Result;
- pub fn shaderProgramFree(sp: *mut shaderProgram_s) -> Result;
- pub fn shaderProgramSetVsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s) -> Result;
- pub fn shaderProgramSetGsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s, stride: _u8) -> Result;
- pub fn shaderProgramUse(sp: *mut shaderProgram_s) -> Result;
-}
diff --git a/ctru-sys/src/gpu/shbin.rs b/ctru-sys/src/gpu/shbin.rs
index db400d9..1c5a453 100644
--- a/ctru-sys/src/gpu/shbin.rs
+++ b/ctru-sys/src/gpu/shbin.rs
@@ -1,105 +1,136 @@
-typedef enum{
- VERTEX_SHDR=GPU_VERTEX_SHADER,
- GEOMETRY_SHDR=GPU_GEOMETRY_SHADER
-}DVLE_type;
+use ::types::*;
-#[repr(C)]
-pub enum DVLE_type {
- VERTEX_SHDR=GPU_VERTEX_SHADER,
- GEOMETRY_SHDR=GPU_GEOMETRY_SHADER,
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed1 {
+ VERTEX_SHDR = 0,
+ GEOMETRY_SHDR = 1,
}
-
-typedef enum{
- DVLE_CONST_BOOL=0x0,
- DVLE_CONST_u8=0x1,
- DVLE_CONST_FLOAT24=0x2,
-}DVLE_constantType;
-
-#[repr(C)]
-pub enum DVLE_constantType {
- DVLE_CONST_BOOL = 0x0,
- DVLE_CONST_u8 = 0x1,
- DVLE_CONST_FLOAT24 = 0x2,
+pub type DVLE_type = Enum_Unnamed1;
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed2 {
+ DVLE_CONST_BOOL = 0,
+ DVLE_CONST_u8 = 1,
+ DVLE_CONST_FLOAT24 = 2,
}
-
-#[repr(C)]
-pub enum DVLE_outputAttribute_t {
- RESULT_POSITION = 0x0,
- RESULT_NORMALQUAT = 0x1,
- RESULT_COLOR = 0x2,
- RESULT_TEXCOORD0 = 0x3,
- RESULT_TEXCOORD0W = 0x4,
- RESULT_TEXCOORD1 = 0x5,
- RESULT_TEXCOORD2 = 0x6,
- RESULT_VIEW = 0x8
+pub type DVLE_constantType = Enum_Unnamed2;
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed3 {
+ RESULT_POSITION = 0,
+ RESULT_NORMALQUAT = 1,
+ RESULT_COLOR = 2,
+ RESULT_TEXCOORD0 = 3,
+ RESULT_TEXCOORD0W = 4,
+ RESULT_TEXCOORD1 = 5,
+ RESULT_TEXCOORD2 = 6,
+ RESULT_VIEW = 8,
}
-
+pub type DVLE_outputAttribute_t = Enum_Unnamed3;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLP_s {
- codeSize: u32,
- codeData: *mut u32,
- opdescSize: u32,
- opcdescData: *mut u32
+pub struct Struct_Unnamed4 {
+ pub codeSize: u32,
+ pub codeData: *mut u32,
+ pub opdescSize: u32,
+ pub opcdescData: *mut u32,
}
-
+impl ::core::clone::Clone for Struct_Unnamed4 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed4 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLP_s = Struct_Unnamed4;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_constEntry_s {
- type: u16,
- id: u16,
- data: [u32; 4usize]
+pub struct Struct_Unnamed5 {
+ pub _type: u16,
+ pub id: u16,
+ pub data: [u32; 4usize],
}
-
+impl ::core::clone::Clone for Struct_Unnamed5 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed5 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_constEntry_s = Struct_Unnamed5;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_outEntry_s {
- type: u16,
- regID: u16,
- mask: u8,
- unk: [u8; 3usize]
+pub struct Struct_Unnamed6 {
+ pub _type: u16,
+ pub regID: u16,
+ pub mask: u8,
+ pub unk: [u8; 3usize],
}
-
+impl ::core::clone::Clone for Struct_Unnamed6 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed6 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_outEntry_s = Struct_Unnamed6;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_uniformEntry_s{
- symbolOffset: u32,
- startReg: u16,
- endReg: u16,
+pub struct Struct_Unnamed7 {
+ pub symbolOffset: u32,
+ pub startReg: u16,
+ pub endReg: u16,
}
-
+impl ::core::clone::Clone for Struct_Unnamed7 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed7 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_uniformEntry_s = Struct_Unnamed7;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_s {
- DVLE_type type: DVLE_type,
- DVLP_s* dvlp: *mut DVLP_s,
- mainOffset: u32,
- endmainOffset: u32,
- constTableSize: u32,
- constTableData: *mut DVLE_constEntry_s,
- outTableSize: u32,
- outTableData: *mut DVLE_outEntry_s,
- uniformTableSize: u32,
- uniformTableData: *mut DVLE_uniformEntry_s,
- symbolTableData: *mut u8,
- outmapMask: u8,
- outmapData: [u32; 8usize]
+pub struct Struct_Unnamed8 {
+ pub _type: DVLE_type,
+ pub dvlp: *mut DVLP_s,
+ pub mainOffset: u32,
+ pub endmainOffset: u32,
+ pub constTableSize: u32,
+ pub constTableData: *mut DVLE_constEntry_s,
+ pub outTableSize: u32,
+ pub outTableData: *mut DVLE_outEntry_s,
+ pub uniformTableSize: u32,
+ pub uniformTableData: *mut DVLE_uniformEntry_s,
+ pub symbolTableData: *mut u8,
+ pub outmapMask: u8,
+ pub outmapData: [u32; 8usize],
+ pub outmapMode: u32,
+ pub outmapClock: u32,
}
-
+impl ::core::clone::Clone for Struct_Unnamed8 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed8 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_s = Struct_Unnamed8;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLB_s {
- numDVLE: u32,
- DVLP: DVLP_s,
- DVLE: *mut DVLE_s
+pub struct Struct_Unnamed9 {
+ pub numDVLE: u32,
+ pub DVLP: DVLP_s,
+ pub DVLE: *mut DVLE_s,
}
-
-use ctru::raw::types::*;
-
-
+impl ::core::clone::Clone for Struct_Unnamed9 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed9 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLB_s = Struct_Unnamed9;
extern "C" {
- pub fn DVLB_ParseFile(shbinData: *mut u32, shbinSize: u32) -> *mut DVLB_s;
- pub fn DVLB_Free(dvlb: *mut DVLB_s) -> ();
- pub fn DVLE_GetUniformRegister(dvle: *mut DVLE_s, name: *const u8) -> s8;
- pub fn DVLE_GenerateOutmap(dvle: *mut DVLE_s) -> ();
+ pub fn DVLB_ParseFile(shbinData: *mut u32, shbinSize: u32)
+ -> *mut DVLB_s;
+ pub fn DVLB_Free(dvlb: *mut DVLB_s);
+ pub fn DVLE_GetUniformRegister(dvle: *mut DVLE_s,
+ name: *const u8) -> s8;
+ pub fn DVLE_GenerateOutmap(dvle: *mut DVLE_s);
}