Finish up basic documentation.
This commit is contained in:
parent
f4cef43033
commit
fa5f3783ce
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @file 3ds.h
|
||||
* @brief Central 3DS header. Includes all others.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,321 +1,349 @@
|
||||
/**
|
||||
* @file enums.h
|
||||
* @brief GPU enumeration values.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
//tex param
|
||||
#define GPU_TEXTURE_MAG_FILTER(v) (((v)&0x1)<<1) //takes a GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MIN_FILTER(v) (((v)&0x1)<<2) //takes a GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<12) //takes a GPU_TEXTURE_WRAP_PARAM
|
||||
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<8) //takes a GPU_TEXTURE_WRAP_PARAM
|
||||
/// Creates a texture magnification filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MAG_FILTER(v) (((v)&0x1)<<1)
|
||||
/// Creates a texture minification filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MIN_FILTER(v) (((v)&0x1)<<2)
|
||||
/// Creates a texture wrap S parameter from a @ref GPU_TEXTURE_WRAP_PARAM
|
||||
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<12)
|
||||
/// Creates a texture wrap T parameter from a @ref GPU_TEXTURE_WRAP_PARAM
|
||||
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<8)
|
||||
|
||||
// Combiner buffer write config
|
||||
/// Creates a combiner buffer write configuration.
|
||||
#define GPU_TEV_BUFFER_WRITE_CONFIG(stage0, stage1, stage2, stage3) ((stage0) | ((stage1) << 1) | ((stage2) << 2) | ((stage3) << 3))
|
||||
|
||||
/// Texture filters.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NEAREST = 0x0,
|
||||
GPU_LINEAR = 0x1,
|
||||
GPU_NEAREST = 0x0, ///< Nearest.
|
||||
GPU_LINEAR = 0x1, ///< Linear.
|
||||
} GPU_TEXTURE_FILTER_PARAM;
|
||||
|
||||
/// Texture wrap modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_CLAMP_TO_EDGE = 0x0,
|
||||
GPU_CLAMP_TO_BORDER = 0x1,
|
||||
GPU_REPEAT = 0x2,
|
||||
GPU_MIRRORED_REPEAT = 0x3,
|
||||
GPU_CLAMP_TO_EDGE = 0x0, ///< Clamps to edge.
|
||||
GPU_CLAMP_TO_BORDER = 0x1, ///< Clamps to border.
|
||||
GPU_REPEAT = 0x2, ///< Repeats texture.
|
||||
GPU_MIRRORED_REPEAT = 0x3, ///< Repeats with mirrored texture.
|
||||
} GPU_TEXTURE_WRAP_PARAM;
|
||||
|
||||
/// Supported texture units.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEXUNIT0 = 0x1,
|
||||
GPU_TEXUNIT1 = 0x2,
|
||||
GPU_TEXUNIT2 = 0x4,
|
||||
GPU_TEXUNIT0 = 0x1, ///< Texture unit 0.
|
||||
GPU_TEXUNIT1 = 0x2, ///< Texture unit 1.
|
||||
GPU_TEXUNIT2 = 0x4, ///< Texture unit 2.
|
||||
} GPU_TEXUNIT;
|
||||
|
||||
/// Supported pixel formats.
|
||||
typedef enum
|
||||
{
|
||||
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,
|
||||
GPU_RGBA8 = 0x0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
|
||||
GPU_RGB8 = 0x1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
|
||||
GPU_RGBA5551 = 0x2, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
|
||||
GPU_RGB565 = 0x3, ///< 5-bit Red + 6-bit Green + 5-bit Blue
|
||||
GPU_RGBA4 = 0x4, ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
|
||||
GPU_LA8 = 0x5, ///< 8-bit Luminance + 8-bit Alpha
|
||||
GPU_HILO8 = 0x6, ///< 8-bit Hi + 8-bit Lo
|
||||
GPU_L8 = 0x7, ///< 8-bit Luminance
|
||||
GPU_A8 = 0x8, ///< 8-bit Alpha
|
||||
GPU_LA4 = 0x9, ///< 4-bit Luminance + 4-bit Alpha
|
||||
GPU_L4 = 0xA, ///< 4-bit Luminance
|
||||
GPU_ETC1 = 0xB, ///< ETC1 texture compression
|
||||
GPU_ETC1A4 = 0xC, ///< ETC1 texture compression + 4-bit Alpha
|
||||
} GPU_TEXCOLOR;
|
||||
|
||||
/// Test functions.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NEVER = 0,
|
||||
GPU_ALWAYS = 1,
|
||||
GPU_EQUAL = 2,
|
||||
GPU_NOTEQUAL = 3,
|
||||
GPU_LESS = 4,
|
||||
GPU_LEQUAL = 5,
|
||||
GPU_GREATER = 6,
|
||||
GPU_GEQUAL = 7,
|
||||
GPU_NEVER = 0, ///< Never pass.
|
||||
GPU_ALWAYS = 1, ///< Always pass.
|
||||
GPU_EQUAL = 2, ///< Pass if equal.
|
||||
GPU_NOTEQUAL = 3, ///< Pass if not equal.
|
||||
GPU_LESS = 4, ///< Pass if less than.
|
||||
GPU_LEQUAL = 5, ///< Pass if less than or equal.
|
||||
GPU_GREATER = 6, ///< Pass if greater than.
|
||||
GPU_GEQUAL = 7, ///< Pass if greater than or equal.
|
||||
}GPU_TESTFUNC;
|
||||
|
||||
/// Scissor test modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_SCISSOR_DISABLE = 0, // disable scissor test
|
||||
GPU_SCISSOR_INVERT = 1, // exclude pixels inside the scissor box
|
||||
GPU_SCISSOR_DISABLE = 0, ///< Disable.
|
||||
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
|
||||
|
||||
GPU_SCISSOR_NORMAL = 3, ///< Exclude pixels outside of the scissor box.
|
||||
} GPU_SCISSORMODE;
|
||||
|
||||
/// Stencil operations.
|
||||
typedef enum
|
||||
{
|
||||
GPU_STENCIL_KEEP = 0, // old_stencil
|
||||
GPU_STENCIL_ZERO = 1, // 0
|
||||
GPU_STENCIL_REPLACE = 2, // ref
|
||||
GPU_STENCIL_INCR = 3, // old_stencil + 1 saturated to [0, 255]
|
||||
GPU_STENCIL_DECR = 4, // old_stencil - 1 saturated to [0, 255]
|
||||
GPU_STENCIL_INVERT = 5, // ~old_stencil
|
||||
GPU_STENCIL_INCR_WRAP = 6, // old_stencil + 1
|
||||
GPU_STENCIL_DECR_WRAP = 7, // old_stencil - 1
|
||||
GPU_STENCIL_KEEP = 0, ///< Keep old value. (old_stencil)
|
||||
GPU_STENCIL_ZERO = 1, ///< Zero. (0)
|
||||
GPU_STENCIL_REPLACE = 2, ///< Replace value. (ref)
|
||||
GPU_STENCIL_INCR = 3, ///< Increment value. (old_stencil + 1 saturated to [0, 255])
|
||||
GPU_STENCIL_DECR = 4, ///< Decrement value. (old_stencil - 1 saturated to [0, 255])
|
||||
GPU_STENCIL_INVERT = 5, ///< Invert value. (~old_stencil)
|
||||
GPU_STENCIL_INCR_WRAP = 6, ///< Increment value. (old_stencil + 1)
|
||||
GPU_STENCIL_DECR_WRAP = 7, ///< Decrement value. (old_stencil - 1)
|
||||
} GPU_STENCILOP;
|
||||
|
||||
/// Pixel write mask.
|
||||
typedef enum
|
||||
{
|
||||
GPU_WRITE_RED = 0x01,
|
||||
GPU_WRITE_GREEN = 0x02,
|
||||
GPU_WRITE_BLUE = 0x04,
|
||||
GPU_WRITE_ALPHA = 0x08,
|
||||
GPU_WRITE_DEPTH = 0x10,
|
||||
GPU_WRITE_RED = 0x01, ///< Write red.
|
||||
GPU_WRITE_GREEN = 0x02, ///< Write green.
|
||||
GPU_WRITE_BLUE = 0x04, ///< Write blue.
|
||||
GPU_WRITE_ALPHA = 0x08, ///< Write alpha.
|
||||
GPU_WRITE_DEPTH = 0x10, ///< Write depth.
|
||||
|
||||
GPU_WRITE_COLOR = 0x0F,
|
||||
GPU_WRITE_ALL = 0x1F,
|
||||
GPU_WRITE_COLOR = 0x0F, ///< Write all color components.
|
||||
GPU_WRITE_ALL = 0x1F, ///< Write all components.
|
||||
} GPU_WRITEMASK;
|
||||
|
||||
/// Blend modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_BLEND_ADD = 0,
|
||||
GPU_BLEND_SUBTRACT = 1,
|
||||
GPU_BLEND_REVERSE_SUBTRACT = 2,
|
||||
GPU_BLEND_MIN = 3,
|
||||
GPU_BLEND_MAX = 4,
|
||||
GPU_BLEND_ADD = 0, ///< Add colors.
|
||||
GPU_BLEND_SUBTRACT = 1, ///< Subtract colors.
|
||||
GPU_BLEND_REVERSE_SUBTRACT = 2, ///< Reverse-subtract colors.
|
||||
GPU_BLEND_MIN = 3, ///< Use the minimum color.
|
||||
GPU_BLEND_MAX = 4, ///< Use the maximum color.
|
||||
} GPU_BLENDEQUATION;
|
||||
|
||||
/// Blend factors.
|
||||
typedef enum
|
||||
{
|
||||
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,
|
||||
GPU_ZERO = 0, ///< Zero.
|
||||
GPU_ONE = 1, ///< One.
|
||||
GPU_SRC_COLOR = 2, ///< Source color.
|
||||
GPU_ONE_MINUS_SRC_COLOR = 3, ///< Source color - 1.
|
||||
GPU_DST_COLOR = 4, ///< Destination color.
|
||||
GPU_ONE_MINUS_DST_COLOR = 5, ///< Destination color - 1.
|
||||
GPU_SRC_ALPHA = 6, ///< Source alpha.
|
||||
GPU_ONE_MINUS_SRC_ALPHA = 7, ///< Source alpha - 1.
|
||||
GPU_DST_ALPHA = 8, ///< Destination alpha.
|
||||
GPU_ONE_MINUS_DST_ALPHA = 9, ///< Destination alpha - 1.
|
||||
GPU_CONSTANT_COLOR = 10, ///< Constant color.
|
||||
GPU_ONE_MINUS_CONSTANT_COLOR = 11, ///< Constant color - 1.
|
||||
GPU_CONSTANT_ALPHA = 12, ///< Constant alpha.
|
||||
GPU_ONE_MINUS_CONSTANT_ALPHA = 13, ///< Constant alpha - 1.
|
||||
GPU_SRC_ALPHA_SATURATE = 14, ///< Saturated alpha.
|
||||
} GPU_BLENDFACTOR;
|
||||
|
||||
/// Logical operations.
|
||||
typedef enum
|
||||
{
|
||||
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,
|
||||
GPU_LOGICOP_CLEAR = 0, ///< Clear.
|
||||
GPU_LOGICOP_AND = 1, ///< Bitwise AND.
|
||||
GPU_LOGICOP_AND_REVERSE = 2, ///< Reverse bitwise AND.
|
||||
GPU_LOGICOP_COPY = 3, ///< Copy.
|
||||
GPU_LOGICOP_SET = 4, ///< Set.
|
||||
GPU_LOGICOP_COPY_INVERTED = 5, ///< Inverted copy.
|
||||
GPU_LOGICOP_NOOP = 6, ///< No operation.
|
||||
GPU_LOGICOP_INVERT = 7, ///< Invert.
|
||||
GPU_LOGICOP_NAND = 8, ///< Bitwise NAND.
|
||||
GPU_LOGICOP_OR = 9, ///< Bitwise OR.
|
||||
GPU_LOGICOP_NOR = 10, ///< Bitwise NOR.
|
||||
GPU_LOGICOP_XOR = 11, ///< Bitwise XOR.
|
||||
GPU_LOGICOP_EQUIV = 12, ///< Equivalent.
|
||||
GPU_LOGICOP_AND_INVERTED = 13, ///< Inverted bitwise AND.
|
||||
GPU_LOGICOP_OR_REVERSE = 14, ///< Reverse bitwise OR.
|
||||
GPU_LOGICOP_OR_INVERTED = 15, ///< Inverted bitwize OR.
|
||||
} GPU_LOGICOP;
|
||||
|
||||
/// Supported component formats.
|
||||
typedef enum
|
||||
{
|
||||
GPU_BYTE = 0,
|
||||
GPU_UNSIGNED_BYTE = 1,
|
||||
GPU_SHORT = 2,
|
||||
GPU_FLOAT = 3,
|
||||
GPU_BYTE = 0, ///< 8-bit byte.
|
||||
GPU_UNSIGNED_BYTE = 1, ///< 8-bit unsigned byte.
|
||||
GPU_SHORT = 2, ///< 16-bit short.
|
||||
GPU_FLOAT = 3, ///< 32-bit float.
|
||||
} GPU_FORMATS;
|
||||
|
||||
/// Cull modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_CULL_NONE = 0,
|
||||
GPU_CULL_FRONT_CCW = 1,
|
||||
GPU_CULL_BACK_CCW = 2,
|
||||
GPU_CULL_NONE = 0, ///< Disabled.
|
||||
GPU_CULL_FRONT_CCW = 1, ///< Front, counter-clockwise.
|
||||
GPU_CULL_BACK_CCW = 2, ///< Back, counter-clockwise.
|
||||
} GPU_CULLMODE;
|
||||
|
||||
/// Creates a VBO attribute parameter from its index, size, and format.
|
||||
#define GPU_ATTRIBFMT(i, n, f) (((((n)-1)<<2)|((f)&3))<<((i)*4))
|
||||
|
||||
/**
|
||||
* Texture combiners sources
|
||||
*/
|
||||
/// Texture combiner sources.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PRIMARY_COLOR = 0x00,
|
||||
GPU_FRAGMENT_PRIMARY_COLOR = 0x01,
|
||||
GPU_FRAGMENT_SECONDARY_COLOR = 0x02,
|
||||
GPU_TEXTURE0 = 0x03,
|
||||
GPU_TEXTURE1 = 0x04,
|
||||
GPU_TEXTURE2 = 0x05,
|
||||
GPU_TEXTURE3 = 0x06,
|
||||
GPU_PREVIOUS_BUFFER = 0x0D,
|
||||
GPU_CONSTANT = 0x0E,
|
||||
GPU_PREVIOUS = 0x0F,
|
||||
GPU_PRIMARY_COLOR = 0x00, ///< Primary color.
|
||||
GPU_FRAGMENT_PRIMARY_COLOR = 0x01, ///< Primary fragment color.
|
||||
GPU_FRAGMENT_SECONDARY_COLOR = 0x02, ///< Secondary fragment color.
|
||||
GPU_TEXTURE0 = 0x03, ///< Texture unit 0.
|
||||
GPU_TEXTURE1 = 0x04, ///< Texture unit 1.
|
||||
GPU_TEXTURE2 = 0x05, ///< Texture unit 2.
|
||||
GPU_TEXTURE3 = 0x06, ///< Texture unit 3.
|
||||
GPU_PREVIOUS_BUFFER = 0x0D, ///< Previous buffer.
|
||||
GPU_CONSTANT = 0x0E, ///< Constant value.
|
||||
GPU_PREVIOUS = 0x0F, ///< Previous value.
|
||||
} GPU_TEVSRC;
|
||||
|
||||
/**
|
||||
* Texture RGB combiners operands
|
||||
*/
|
||||
/// Texture RGB combiner operands.
|
||||
typedef enum
|
||||
{
|
||||
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_SRC_R = 0x04,
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_R = 0x05,
|
||||
GPU_TEVOP_RGB_0x06 = 0x06,
|
||||
GPU_TEVOP_RGB_0x07 = 0x07,
|
||||
GPU_TEVOP_RGB_SRC_G = 0x08,
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_G = 0x09,
|
||||
GPU_TEVOP_RGB_0x0A = 0x0A,
|
||||
GPU_TEVOP_RGB_0x0B = 0x0B,
|
||||
GPU_TEVOP_RGB_SRC_B = 0x0C,
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_B = 0x0D,
|
||||
GPU_TEVOP_RGB_0x0E = 0x0E,
|
||||
GPU_TEVOP_RGB_0x0F = 0x0F,
|
||||
GPU_TEVOP_RGB_SRC_COLOR = 0x00, ///< Source color.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR = 0x01, ///< Source color - 1.
|
||||
GPU_TEVOP_RGB_SRC_ALPHA = 0x02, ///< Source alpha.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA = 0x03, ///< Source alpha - 1.
|
||||
GPU_TEVOP_RGB_SRC_R = 0x04, ///< Source red.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_R = 0x05, ///< Source red - 1.
|
||||
GPU_TEVOP_RGB_0x06 = 0x06, ///< Unknown.
|
||||
GPU_TEVOP_RGB_0x07 = 0x07, ///< Unknown.
|
||||
GPU_TEVOP_RGB_SRC_G = 0x08, ///< Source green.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_G = 0x09, ///< Source green - 1.
|
||||
GPU_TEVOP_RGB_0x0A = 0x0A, ///< Unknown.
|
||||
GPU_TEVOP_RGB_0x0B = 0x0B, ///< Unknown.
|
||||
GPU_TEVOP_RGB_SRC_B = 0x0C, ///< Source blue.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_B = 0x0D, ///< Source blue - 1.
|
||||
GPU_TEVOP_RGB_0x0E = 0x0E, ///< Unknown.
|
||||
GPU_TEVOP_RGB_0x0F = 0x0F, ///< Unknown.
|
||||
} GPU_TEVOP_RGB;
|
||||
|
||||
|
||||
/**
|
||||
* Texture ALPHA combiners operands
|
||||
*/
|
||||
/// Texture Alpha combiner operands.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEVOP_A_SRC_ALPHA = 0x00,
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA = 0x01,
|
||||
GPU_TEVOP_A_SRC_R = 0x02,
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_R = 0x03,
|
||||
GPU_TEVOP_A_SRC_G = 0x04,
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_G = 0x05,
|
||||
GPU_TEVOP_A_SRC_B = 0x06,
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_B = 0x07,
|
||||
GPU_TEVOP_A_SRC_ALPHA = 0x00, ///< Source alpha.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA = 0x01, ///< Source alpha - 1.
|
||||
GPU_TEVOP_A_SRC_R = 0x02, ///< Source red.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_R = 0x03, ///< Source red - 1.
|
||||
GPU_TEVOP_A_SRC_G = 0x04, ///< Source green.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_G = 0x05, ///< Source green - 1.
|
||||
GPU_TEVOP_A_SRC_B = 0x06, ///< Source blue.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_B = 0x07, ///< Source blue - 1.
|
||||
} GPU_TEVOP_A;
|
||||
|
||||
/**
|
||||
* Texture combiner functions
|
||||
*/
|
||||
/// Texture combiner functions.
|
||||
typedef enum
|
||||
{
|
||||
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
|
||||
GPU_MULTIPLY_ADD = 0x08,
|
||||
GPU_ADD_MULTIPLY = 0x09,
|
||||
GPU_REPLACE = 0x00, ///< Replace.
|
||||
GPU_MODULATE = 0x01, ///< Modulate.
|
||||
GPU_ADD = 0x02, ///< Add.
|
||||
GPU_ADD_SIGNED = 0x03, ///< Signed add.
|
||||
GPU_INTERPOLATE = 0x04, ///< Interpolate.
|
||||
GPU_SUBTRACT = 0x05, ///< Subtract.
|
||||
GPU_DOT3_RGB = 0x06, ///< Dot3. RGB only.
|
||||
GPU_MULTIPLY_ADD = 0x08, ///< Multiply then add.
|
||||
GPU_ADD_MULTIPLY = 0x09, ///< Add then multiply.
|
||||
} GPU_COMBINEFUNC;
|
||||
|
||||
/**
|
||||
* Texture scale factors
|
||||
*/
|
||||
/// Texture scale factors.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEVSCALE_1 = 0x0,
|
||||
GPU_TEVSCALE_2 = 0x1,
|
||||
GPU_TEVSCALE_4 = 0x2,
|
||||
GPU_TEVSCALE_1 = 0x0, ///< 1x
|
||||
GPU_TEVSCALE_2 = 0x1, ///< 2x
|
||||
GPU_TEVSCALE_4 = 0x2, ///< 4x
|
||||
} GPU_TEVSCALE;
|
||||
|
||||
/// Creates a texture combiner source parameter from three sources.
|
||||
#define GPU_TEVSOURCES(a,b,c) (((a))|((b)<<4)|((c)<<8))
|
||||
/// Creates a texture combiner operand parameter from three operands.
|
||||
#define GPU_TEVOPERANDS(a,b,c) (((a))|((b)<<4)|((c)<<8))
|
||||
|
||||
/// Creates a light environment layer configuration parameter.
|
||||
#define GPU_LIGHT_ENV_LAYER_CONFIG(n) ((n)+((n)==7))
|
||||
/// Creates a LC1 shadow bit parameter.
|
||||
#define GPU_LC1_SHADOWBIT(n) BIT(n)
|
||||
/// Creates a LC1 spot bit parameter.
|
||||
#define GPU_LC1_SPOTBIT(n) BIT((n)+8)
|
||||
/// Creates a LC1 LUT bit parameter.
|
||||
#define GPU_LC1_LUTBIT(n) BIT((n)+16)
|
||||
/// Creates a LC1 attenuation bit parameter.
|
||||
#define GPU_LC1_ATTNBIT(n) BIT((n)+24)
|
||||
/// Creates a light permutation parameter.
|
||||
#define GPU_LIGHTPERM(i,n) ((n) << (i))
|
||||
/// Creates a light LUT input parameter.
|
||||
#define GPU_LIGHTLUTINPUT(i,n) ((n) << ((i)*4))
|
||||
/// Creates a light LUT index parameter.
|
||||
#define GPU_LIGHTLUTIDX(c,i,o) ((o) | ((i) << 8) | ((c) << 11))
|
||||
/// Creates a light color parameter from red, green, and blue components.
|
||||
#define GPU_LIGHTCOLOR(r,g,b) (((b) & 0xFF) | (((g) << 10) & 0xFF) | (((r) << 20) & 0xFF))
|
||||
|
||||
/// FRESNEL options.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NO_FRESNEL = 0,
|
||||
GPU_PRI_ALPHA_FRESNEL = 1,
|
||||
GPU_SEC_ALPHA_FRESNEL = 2,
|
||||
GPU_PRI_SEC_ALPHA_FRESNEL = 3,
|
||||
GPU_NO_FRESNEL = 0, ///< None.
|
||||
GPU_PRI_ALPHA_FRESNEL = 1, ///< Primary alpha.
|
||||
GPU_SEC_ALPHA_FRESNEL = 2, ///< Secondary alpha.
|
||||
GPU_PRI_SEC_ALPHA_FRESNEL = 3, ///< Primary and secondary alpha.
|
||||
} GPU_FRESNELSEL;
|
||||
|
||||
/// Bump map modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_BUMP_NOT_USED = 0,
|
||||
GPU_BUMP_AS_BUMP = 1,
|
||||
GPU_BUMP_AS_TANG = 2,
|
||||
GPU_BUMP_NOT_USED = 0, ///< Disabled.
|
||||
GPU_BUMP_AS_BUMP = 1, ///< Bump as bump.
|
||||
GPU_BUMP_AS_TANG = 2, ///< Bump as tang.
|
||||
} GPU_BUMPMODE;
|
||||
|
||||
/// LUT IDs.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUT_D0 = 0,
|
||||
GPU_LUT_D1 = 1,
|
||||
GPU_LUT_SP = 2,
|
||||
GPU_LUT_FR = 3,
|
||||
GPU_LUT_RB = 4,
|
||||
GPU_LUT_RG = 5,
|
||||
GPU_LUT_RR = 6,
|
||||
GPU_LUT_DA = 7,
|
||||
GPU_LUT_D0 = 0, ///< LUT D0.
|
||||
GPU_LUT_D1 = 1, ///< LUT D1.
|
||||
GPU_LUT_SP = 2, ///< LUT SP.
|
||||
GPU_LUT_FR = 3, ///< LUT FR.
|
||||
GPU_LUT_RB = 4, ///< LUT RB.
|
||||
GPU_LUT_RG = 5, ///< LUT RG.
|
||||
GPU_LUT_RR = 6, ///< LUT RR.
|
||||
GPU_LUT_DA = 7, ///< LUT DA.
|
||||
} GPU_LIGHTLUTID;
|
||||
|
||||
/// LUT inputs.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUTINPUT_NH = 0,
|
||||
GPU_LUTINPUT_VH = 1,
|
||||
GPU_LUTINPUT_NV = 2,
|
||||
GPU_LUTINPUT_LN = 3,
|
||||
GPU_LUTINPUT_SP = 4,
|
||||
GPU_LUTINPUT_CP = 5,
|
||||
GPU_LUTINPUT_NH = 0, ///< Input NH.
|
||||
GPU_LUTINPUT_VH = 1, ///< Input VH.
|
||||
GPU_LUTINPUT_NV = 2, ///< Input NV.
|
||||
GPU_LUTINPUT_LN = 3, ///< Input LN.
|
||||
GPU_LUTINPUT_SP = 4, ///< Input SP.
|
||||
GPU_LUTINPUT_CP = 5, ///< Input CP.
|
||||
} GPU_LIGHTLUTINPUT;
|
||||
|
||||
/// LUT scalers.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUTSCALER_1x = 0,
|
||||
GPU_LUTSCALER_2x = 1,
|
||||
GPU_LUTSCALER_4x = 2,
|
||||
GPU_LUTSCALER_8x = 3,
|
||||
GPU_LUTSCALER_0_25x = 6,
|
||||
GPU_LUTSCALER_0_5x = 7,
|
||||
GPU_LUTSCALER_1x = 0, ///< 1x scale.
|
||||
GPU_LUTSCALER_2x = 1, ///< 2x scale.
|
||||
GPU_LUTSCALER_4x = 2, ///< 4x scale.
|
||||
GPU_LUTSCALER_8x = 3, ///< 8x scale.
|
||||
GPU_LUTSCALER_0_25x = 6, ///< 0.25x scale.
|
||||
GPU_LUTSCALER_0_5x = 7, ///< 0.5x scale.
|
||||
} GPU_LIGHTLUTSCALER;
|
||||
|
||||
/// LUT selection.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUTSELECT_COMMON = 0,
|
||||
GPU_LUTSELECT_SP = 1,
|
||||
GPU_LUTSELECT_DA = 2,
|
||||
GPU_LUTSELECT_COMMON = 0, ///< Common.
|
||||
GPU_LUTSELECT_SP = 1, ///< SP.
|
||||
GPU_LUTSELECT_DA = 2, ///< DA.
|
||||
} GPU_LIGHTLUTSELECT;
|
||||
|
||||
/// Supported primitives.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TRIANGLES = 0x0000,
|
||||
GPU_TRIANGLE_STRIP = 0x0100,
|
||||
GPU_TRIANGLE_FAN = 0x0200,
|
||||
GPU_GEOMETRY_PRIM = 0x0300,
|
||||
GPU_TRIANGLES = 0x0000, ///< Triangles.
|
||||
GPU_TRIANGLE_STRIP = 0x0100, ///< Triangle strip.
|
||||
GPU_TRIANGLE_FAN = 0x0200, ///< Triangle fan.
|
||||
GPU_GEOMETRY_PRIM = 0x0300, ///< Geometry shader primitive.
|
||||
} GPU_Primitive_t;
|
||||
|
||||
/// Shader types.
|
||||
typedef enum
|
||||
{
|
||||
GPU_VERTEX_SHADER = 0x0,
|
||||
GPU_GEOMETRY_SHADER = 0x1,
|
||||
GPU_VERTEX_SHADER = 0x0, ///< Vertex shader.
|
||||
GPU_GEOMETRY_SHADER = 0x1, ///< Geometry shader.
|
||||
} GPU_SHADER_TYPE;
|
||||
|
@ -1,47 +1,209 @@
|
||||
/**
|
||||
* @file gpu-old.h
|
||||
* @brief Deprecated GPU functions.
|
||||
* @deprecated
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "gpu.h"
|
||||
|
||||
//GPU
|
||||
/**
|
||||
* @brief Initializes the GPU.
|
||||
* @param gsphandle GSP handle to use.
|
||||
*/
|
||||
void GPU_Init(Handle *gsphandle) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Resets the GPU.
|
||||
* @param gxbuf GX command buffer to use.
|
||||
* @param gpuBuf GPU command buffer to use.
|
||||
* @param gpuBufSize GPU command buffer size.
|
||||
*/
|
||||
void GPU_Reset(u32* gxbuf, u32* gpuBuf, u32 gpuBufSize) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets a shader float uniform.
|
||||
* @param type Type of shader to set the uniform of.
|
||||
* @param startreg Start of the uniform register to set.
|
||||
* @param data Data to set.
|
||||
* @param numreg Number of registers to set.
|
||||
*/
|
||||
void GPU_SetFloatUniform(GPU_SHADER_TYPE type, u32 startreg, u32* data, u32 numreg) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the viewport.
|
||||
* @param depthBuffer Buffer to output depth data to.
|
||||
* @param colorBuffer Buffer to output color data to.
|
||||
* @param x X of the viewport.
|
||||
* @param y Y of the viewport.
|
||||
* @param w Width of the viewport.
|
||||
* @param h Height of the viewport.
|
||||
*/
|
||||
void GPU_SetViewport(u32* depthBuffer, u32* colorBuffer, u32 x, u32 y, u32 w, u32 h) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the current scissor test mode.
|
||||
* @param mode Scissor test mode to use.
|
||||
* @param x X of the scissor region.
|
||||
* @param y Y of the scissor region.
|
||||
* @param w Width of the scissor region.
|
||||
* @param h Height of the scissor region.
|
||||
*/
|
||||
void GPU_SetScissorTest(GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the depth map.
|
||||
* @param zScale Z scale to use.
|
||||
* @param zOffset Z offset to use.
|
||||
*/
|
||||
void GPU_DepthMap(float zScale, float zOffset) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the alpha test parameters.
|
||||
* @param enable Whether to enable alpha testing.
|
||||
* @param function Test function to use.
|
||||
* @param ref Reference value to use.
|
||||
*/
|
||||
void GPU_SetAlphaTest(bool enable, GPU_TESTFUNC function, u8 ref) DEPRECATED;
|
||||
void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask) DEPRECATED; // GPU_WRITEMASK values can be ORed together
|
||||
|
||||
/**
|
||||
* @brief Sets the depth test parameters and pixel write mask.
|
||||
* @note GPU_WRITEMASK values can be ORed together.
|
||||
* @param enable Whether to enable depth testing.
|
||||
* @param function Test function to use.
|
||||
* @param writemask Pixel write mask to use.
|
||||
*/
|
||||
void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the stencil test parameters.
|
||||
* @param enable Whether to enable stencil testing.
|
||||
* @param function Test function to use.
|
||||
* @param ref Reference value to use.
|
||||
* @param input_mask Input mask to use.
|
||||
* @param write_mask Write mask to use.
|
||||
*/
|
||||
void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 input_mask, u8 write_mask) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the stencil test operators.
|
||||
* @param sfail Operator to use on source test failure.
|
||||
* @param dfail Operator to use on destination test failure.
|
||||
* @param pass Operator to use on test passing.
|
||||
*/
|
||||
void GPU_SetStencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the face culling mode.
|
||||
* @param mode Face culling mode to use.
|
||||
*/
|
||||
void GPU_SetFaceCulling(GPU_CULLMODE mode) DEPRECATED;
|
||||
// Only the first four tev stages can write to the combiner buffer, use GPU_TEV_BUFFER_WRITE_CONFIG to build the parameters
|
||||
|
||||
/**
|
||||
* @brief Sets the combiner buffer write parameters.
|
||||
* @note Use GPU_TEV_BUFFER_WRITE_CONFIG to build the parameters.
|
||||
* @note Only the first four TEV stages can write to the combiner buffer.
|
||||
* @param rgb_config RGB configuration to use.
|
||||
* @param alpha_config Alpha configuration to use.
|
||||
*/
|
||||
void GPU_SetCombinerBufferWrite(u8 rgb_config, u8 alpha_config) DEPRECATED;
|
||||
|
||||
// these two can't be used together
|
||||
/**
|
||||
* @brief Sets the alpha blending parameters.
|
||||
* @note Cannot be used with GPU_SetColorLogicOp.
|
||||
* @param colorEquation Blend equation to use for color components.
|
||||
* @param alphaEquation Blend equation to use for the alpha component.
|
||||
* @param colorSrc Source factor of color components.
|
||||
* @param colorDst Destination factor of color components.
|
||||
* @param alphaSrc Source factor of the alpha component.
|
||||
* @param alphaDst Destination factor of the alpha component.
|
||||
*/
|
||||
void GPU_SetAlphaBlending(GPU_BLENDEQUATION colorEquation, GPU_BLENDEQUATION alphaEquation,
|
||||
GPU_BLENDFACTOR colorSrc, GPU_BLENDFACTOR colorDst,
|
||||
GPU_BLENDFACTOR alphaSrc, GPU_BLENDFACTOR alphaDst) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the color logic operator.
|
||||
* @note Cannot be used with GPU_SetAlphaBlending.
|
||||
* @param op Operator to set.
|
||||
*/
|
||||
void GPU_SetColorLogicOp(GPU_LOGICOP op) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the blending color.
|
||||
* @param r Red component.
|
||||
* @param g Green component.
|
||||
* @param b Blue component.
|
||||
* @param a Alpha component.
|
||||
*/
|
||||
void GPU_SetBlendingColor(u8 r, u8 g, u8 b, u8 a) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the VBO attribute buffers.
|
||||
* @param totalAttributes Total number of attributes.
|
||||
* @param baseAddress Base address of the VBO.
|
||||
* @param attributeFormats Attribute format data.
|
||||
* @param attributeMask Attribute mask.
|
||||
* @param attributePermutation Attribute permutations.
|
||||
* @param numBuffers Number of buffers.
|
||||
* @param bufferOffsets Offsets of the buffers.
|
||||
* @param bufferPermutations Buffer permutations.
|
||||
* @param bufferNumAttributes Numbers of attributes of the buffers.
|
||||
*/
|
||||
void GPU_SetAttributeBuffers(u8 totalAttributes, u32* baseAddress, u64 attributeFormats, u16 attributeMask, u64 attributePermutation, u8 numBuffers, u32 bufferOffsets[], u64 bufferPermutations[], u8 bufferNumAttributes[]) DEPRECATED;
|
||||
|
||||
void GPU_SetTextureEnable(GPU_TEXUNIT units) DEPRECATED; // GPU_TEXUNITx values can be ORed together to enable multiple texture units
|
||||
|
||||
/**
|
||||
* @brief Sets the enabled texture units.
|
||||
* @param units Units to enable. OR texture unit values together to create this value.
|
||||
*/
|
||||
void GPU_SetTextureEnable(GPU_TEXUNIT units) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the texture data of a texture unit.
|
||||
* @param unit Texture unit to use.
|
||||
* @param data Data to load. Must be in linear memory or VRAM.
|
||||
* @param width Width of the texture.
|
||||
* @param height Height of the texture.
|
||||
* @param Parameters of the texture, such as filters and wrap modes.
|
||||
* @param colorType Color type of the texture.
|
||||
*/
|
||||
void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @param borderColor The color used for the border when using the @ref GPU_CLAMP_TO_BORDER wrap mode
|
||||
* @brief Sets the border color of a texture unit.
|
||||
* @param unit Texture unit to use.
|
||||
* @param borderColor The color used for the border when using the @ref GPU_CLAMP_TO_BORDER wrap mode.
|
||||
*/
|
||||
void GPU_SetTextureBorderColor(GPU_TEXUNIT unit,u32 borderColor) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Sets the parameters of a texture combiner.
|
||||
* @param id ID of the combiner.
|
||||
* @param rgbSources RGB source configuration.
|
||||
* @param alphaSources Alpha source configuration.
|
||||
* @param rgbOperands RGB operand configuration.
|
||||
* @param alphaOperands Alpha operand configuration.
|
||||
* @param rgbCombine RGB combiner function.
|
||||
* @param alphaCombine Alpha combiner function.
|
||||
* @param constantColor Constant color to provide.
|
||||
*/
|
||||
void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Draws an array of vertex data.
|
||||
* @param primitive Primitive to draw.
|
||||
* @param first First vertex to draw.
|
||||
* @param count Number of vertices to draw.
|
||||
*/
|
||||
void GPU_DrawArray(GPU_Primitive_t primitive, u32 first, u32 count) DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief Draws vertex elements.
|
||||
* @param primitive Primitive to draw.
|
||||
* @param indexArray Array of vertex indices to use.
|
||||
* @param n Number of vertices to draw.
|
||||
*/
|
||||
void GPU_DrawElements(GPU_Primitive_t primitive, u32* indexArray, u32 n) DEPRECATED;
|
||||
|
||||
/// Finishes drawing.
|
||||
void GPU_FinishDrawing() DEPRECATED;
|
||||
|
@ -1,34 +1,105 @@
|
||||
/**
|
||||
* @file gpu.h
|
||||
* @brief Barebones GPU communications driver.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "registers.h"
|
||||
#include "enums.h"
|
||||
|
||||
//GPUCMD
|
||||
/// Creates a GPU command header from its write increments, mask, and register.
|
||||
#define GPUCMD_HEADER(incremental, mask, reg) (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF))
|
||||
|
||||
extern u32* gpuCmdBuf;
|
||||
extern u32 gpuCmdBufSize;
|
||||
extern u32 gpuCmdBufOffset;
|
||||
extern u32* gpuCmdBuf; ///< GPU command buffer.
|
||||
extern u32 gpuCmdBufSize; ///< GPU command buffer size.
|
||||
extern u32 gpuCmdBufOffset; ///< GPU command buffer offset.
|
||||
|
||||
/**
|
||||
* @brief Sets the GPU command buffer to use.
|
||||
* @param adr Pointer to the command buffer.
|
||||
* @param size Size of the command buffer.
|
||||
* @param offset Offset of the command buffer.
|
||||
*/
|
||||
void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset);
|
||||
|
||||
/**
|
||||
* @brief Sets the offset of the GPU command buffer.
|
||||
* @param offset Offset of the command buffer.
|
||||
*/
|
||||
void GPUCMD_SetBufferOffset(u32 offset);
|
||||
|
||||
/**
|
||||
* @brief Gets the current GPU command buffer.
|
||||
* @param adr Pointer to output the command buffer to.
|
||||
* @param size Pointer to output the size of the command buffer to.
|
||||
* @param offset Pointer to output the offset of the command buffer to.
|
||||
*/
|
||||
void GPUCMD_GetBuffer(u32** adr, u32* size, u32* offset);
|
||||
|
||||
/**
|
||||
* @brief Adds raw GPU commands to the current command buffer.
|
||||
* @param cmd Buffer containing commands to add.
|
||||
* @param size Size of the buffer.
|
||||
*/
|
||||
void GPUCMD_AddRawCommands(u32* cmd, u32 size);
|
||||
|
||||
/// Executes the GPU command buffer.
|
||||
void GPUCMD_Run(void);
|
||||
|
||||
/// Flushes linear memory and executes the GPU command buffer.
|
||||
void GPUCMD_FlushAndRun(void);
|
||||
|
||||
/**
|
||||
* @brief Adds a GPU command to the current command buffer.
|
||||
* @param header Header of the command.
|
||||
* @param param Parameters of the command.
|
||||
* @param paramlength Size of the parameter buffer.
|
||||
*/
|
||||
void GPUCMD_Add(u32 header, u32* param, u32 paramlength);
|
||||
|
||||
/// Finalizes the GPU command buffer.
|
||||
void GPUCMD_Finalize(void);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 16-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof16(float f);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 20-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof20(float f);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 24-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof24(float f);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 31-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof31(float f);
|
||||
|
||||
/// Adds a command with a single parameter to the current command buffer.
|
||||
#define GPUCMD_AddSingleParam(header, param) GPUCMD_Add((header), (u32[]){(u32)(param)}, 1)
|
||||
|
||||
/// Adds a masked register write to the current command buffer.
|
||||
#define GPUCMD_AddMaskedWrite(reg, mask, val) GPUCMD_AddSingleParam(GPUCMD_HEADER(0, (mask), (reg)), (val))
|
||||
/// Adds a register write to the current command buffer.
|
||||
#define GPUCMD_AddWrite(reg, val) GPUCMD_AddMaskedWrite((reg), 0xF, (val))
|
||||
/// Adds multiple masked register writes to the current command buffer.
|
||||
#define GPUCMD_AddMaskedWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(0, (mask), (reg)), (vals), (num))
|
||||
/// Adds multiple register writes to the current command buffer.
|
||||
#define GPUCMD_AddWrites(reg, vals, num) GPUCMD_AddMaskedWrites((reg), 0xF, (vals), (num))
|
||||
/// Adds multiple masked incremental register writes to the current command buffer.
|
||||
#define GPUCMD_AddMaskedIncrementalWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(1, (mask), (reg)), (vals), (num))
|
||||
/// Adds multiple incremental register writes to the current command buffer.
|
||||
#define GPUCMD_AddIncrementalWrites(reg, vals, num) GPUCMD_AddMaskedIncrementalWrites((reg), 0xF, (vals), (num))
|
||||
|
@ -1,22 +1,23 @@
|
||||
/**
|
||||
* @file gx.h
|
||||
* @brief GX commands.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Creates a buffer dimension parameter from width and height values.
|
||||
#define GX_BUFFER_DIM(w, h) (((h)<<16)|((w)&0xFFFF))
|
||||
|
||||
/**
|
||||
* @brief Pixel formats
|
||||
* @brief Supported transfer pixel formats.
|
||||
* @sa GSP_FramebufferFormats
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GX_TRANSFER_FMT_RGBA8 = 0,
|
||||
GX_TRANSFER_FMT_RGB8 = 1,
|
||||
GX_TRANSFER_FMT_RGB565 = 2,
|
||||
GX_TRANSFER_FMT_RGB5A1 = 3,
|
||||
GX_TRANSFER_FMT_RGBA4 = 4
|
||||
GX_TRANSFER_FMT_RGBA8 = 0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
|
||||
GX_TRANSFER_FMT_RGB8 = 1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
|
||||
GX_TRANSFER_FMT_RGB565 = 2, ///< 5-bit Red + 6-bit Green + 5-bit Blue
|
||||
GX_TRANSFER_FMT_RGB5A1 = 3, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
|
||||
GX_TRANSFER_FMT_RGBA4 = 4 ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
|
||||
} GX_TRANSFER_FORMAT;
|
||||
|
||||
/**
|
||||
@ -42,21 +43,85 @@ typedef enum
|
||||
GX_FILL_32BIT_DEPTH = 0x200, ///< The buffer has a 32 bit per pixel depth
|
||||
} GX_FILL_CONTROL;
|
||||
|
||||
/// Creates a transfer vertical flip flag.
|
||||
#define GX_TRANSFER_FLIP_VERT(x) ((x)<<0)
|
||||
/// Creates a transfer tiled output flag.
|
||||
#define GX_TRANSFER_OUT_TILED(x) ((x)<<1)
|
||||
/// Creates a transfer raw copy flag.
|
||||
#define GX_TRANSFER_RAW_COPY(x) ((x)<<3)
|
||||
/// Creates a transfer input format flag.
|
||||
#define GX_TRANSFER_IN_FORMAT(x) ((x)<<8)
|
||||
/// Creates a transfer output format flag.
|
||||
#define GX_TRANSFER_OUT_FORMAT(x) ((x)<<12)
|
||||
/// Creates a transfer scaling flag.
|
||||
#define GX_TRANSFER_SCALING(x) ((x)<<24)
|
||||
|
||||
/// Command list flag bit 0.
|
||||
#define GX_CMDLIST_BIT0 BIT(0)
|
||||
/// Flushes the command list.
|
||||
#define GX_CMDLIST_FLUSH BIT(1)
|
||||
|
||||
Result GX_RequestDma(u32* src, u32* dst, u32 length);
|
||||
Result GX_ProcessCommandList(u32* buf0a, u32 buf0s, u8 flags);
|
||||
Result GX_MemoryFill(u32* buf0a, u32 buf0v, u32* buf0e, u16 control0, u32* buf1a, u32 buf1v, u32* buf1e, u16 control1);
|
||||
Result GX_DisplayTransfer(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags);
|
||||
Result GX_TextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
|
||||
Result GX_FlushCacheRegions(u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s);
|
||||
extern u32* gxCmdBuf; ///< GX command buffer.
|
||||
|
||||
extern u32* gxCmdBuf;
|
||||
/**
|
||||
* @brief Requests a DMA.
|
||||
* @param src Source to DMA from.
|
||||
* @param dst Destination to DMA to.
|
||||
* @param length Length of data to transfer.
|
||||
*/
|
||||
Result GX_RequestDma(u32* src, u32* dst, u32 length);
|
||||
|
||||
/**
|
||||
* @brief Processes a GPU command list.
|
||||
* @param buf0a Command list address.
|
||||
* @param buf0s Command list size.
|
||||
* @param flags Flags to process with.
|
||||
*/
|
||||
Result GX_ProcessCommandList(u32* buf0a, u32 buf0s, u8 flags);
|
||||
|
||||
/**
|
||||
* @brief Fills the memory of two buffers with the given values.
|
||||
* @param buf0a Start address of the first buffer.
|
||||
* @param buf0v Dimensions of the first buffer.
|
||||
* @param buf0e End address of the first buffer.
|
||||
* @param control0 Value to fill the first buffer with.
|
||||
* @param buf1a Start address of the second buffer.
|
||||
* @param buf1v Dimensions of the second buffer.
|
||||
* @param buf1e End address of the second buffer.
|
||||
* @param control1 Value to fill the second buffer with.
|
||||
*/
|
||||
Result GX_MemoryFill(u32* buf0a, u32 buf0v, u32* buf0e, u16 control0, u32* buf1a, u32 buf1v, u32* buf1e, u16 control1);
|
||||
|
||||
/**
|
||||
* @brief Initiates a display transfer.
|
||||
* @note The PPF event will be signaled on completion.
|
||||
* @param inadr Address of the input.
|
||||
* @param indim Dimensions of the input.
|
||||
* @param outadr Address of the output.
|
||||
* @param outdim Dimensions of the output.
|
||||
* @param flags Flags to transfer with.
|
||||
*/
|
||||
Result GX_DisplayTransfer(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags);
|
||||
|
||||
/**
|
||||
* @brief Initiates a texture copy.
|
||||
* @note The PPF event will be signaled on completion.
|
||||
* @param inadr Address of the input.
|
||||
* @param indim Dimensions of the input.
|
||||
* @param outadr Address of the output.
|
||||
* @param outdim Dimensions of the output.
|
||||
* @param size Size of the data to transfer.
|
||||
* @param flags Flags to transfer with.
|
||||
*/
|
||||
Result GX_TextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
|
||||
|
||||
/**
|
||||
* @brief Flushes the cache regions of three buffers.
|
||||
* @param buf0a Address of the first buffer.
|
||||
* @param buf0s Size of the first buffer.
|
||||
* @param buf1a Address of the second buffer.
|
||||
* @param buf1s Size of the second buffer.
|
||||
* @param buf2a Address of the third buffer.
|
||||
* @param buf2s Size of the third buffer.
|
||||
*/
|
||||
Result GX_FlushCacheRegions(u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,42 +7,96 @@
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/gpu/shbin.h>
|
||||
|
||||
/// 24-bit float uniforms.
|
||||
typedef struct
|
||||
{
|
||||
u32 id;
|
||||
u32 data[3];
|
||||
u32 id; ///< Uniform ID.
|
||||
u32 data[3]; ///< Uniform data.
|
||||
}float24Uniform_s;
|
||||
|
||||
/**
|
||||
* @brief Describes an instance of either a vertex or geometry shader.
|
||||
*/
|
||||
/// Describes an instance of either a vertex or geometry shader.
|
||||
typedef struct
|
||||
{
|
||||
DVLE_s* dvle;
|
||||
u16 boolUniforms;
|
||||
u32 intUniforms[4];
|
||||
float24Uniform_s* float24Uniforms;
|
||||
u8 numFloat24Uniforms;
|
||||
DVLE_s* dvle; ///< Shader DVLE.
|
||||
u16 boolUniforms; ///< Boolean uniforms.
|
||||
u32 intUniforms[4]; ///< Integer uniforms.
|
||||
float24Uniform_s* float24Uniforms; ///< 24-bit float uniforms.
|
||||
u8 numFloat24Uniforms; ///< Float uniform count.
|
||||
}shaderInstance_s;
|
||||
|
||||
/**
|
||||
* @brief Describes an instance of a full shader program.
|
||||
*/
|
||||
/// Describes an instance of a full shader program.
|
||||
typedef struct
|
||||
{
|
||||
shaderInstance_s* vertexShader;
|
||||
shaderInstance_s* geometryShader;
|
||||
u8 geometryShaderInputStride;
|
||||
shaderInstance_s* vertexShader; ///< Vertex shader.
|
||||
shaderInstance_s* geometryShader; ///< Geometry shader.
|
||||
u8 geometryShaderInputStride; ///< Geometry shader input stride.
|
||||
}shaderProgram_s;
|
||||
|
||||
/**
|
||||
* @brief Initializes a shader instance.
|
||||
* @param si Shader instance to initialize.
|
||||
* @param dvle DVLE to initialize the shader instance with.
|
||||
*/
|
||||
Result shaderInstanceInit(shaderInstance_s* si, DVLE_s* dvle);
|
||||
|
||||
/**
|
||||
* @brief Frees a shader instance.
|
||||
* @param si Shader instance to free.
|
||||
*/
|
||||
Result shaderInstanceFree(shaderInstance_s* si);
|
||||
|
||||
/**
|
||||
* @brief Sets a bool uniform of a shader.
|
||||
* @param si Shader instance to use.
|
||||
* @param id ID of the bool uniform.
|
||||
* @param value Value to set.
|
||||
*/
|
||||
Result shaderInstanceSetBool(shaderInstance_s* si, int id, bool value);
|
||||
|
||||
/**
|
||||
* @brief Gets a bool uniform of a shader.
|
||||
* @param si Shader instance to use.
|
||||
* @param id ID of the bool uniform.
|
||||
* @param value Pointer to output the value to.
|
||||
*/
|
||||
Result shaderInstanceGetBool(shaderInstance_s* si, int id, bool* value);
|
||||
|
||||
/**
|
||||
* @brief Gets the location of a shader's uniform.
|
||||
* @param si Shader instance to use.
|
||||
* @param name Name of the uniform.
|
||||
*/
|
||||
Result shaderInstanceGetUniformLocation(shaderInstance_s* si, const char* name);
|
||||
|
||||
/**
|
||||
* @brief Initializes a shader program.
|
||||
* @param sp Shader program to initialize.
|
||||
*/
|
||||
Result shaderProgramInit(shaderProgram_s* sp);
|
||||
|
||||
/**
|
||||
* @brief Frees a shader program.
|
||||
* @param sp Shader program to free.
|
||||
*/
|
||||
Result shaderProgramFree(shaderProgram_s* sp);
|
||||
|
||||
/**
|
||||
* @brief Sets the vertex shader of a shader program.
|
||||
* @param sp Shader program to use.
|
||||
* @param dvle Vertex shader to set.
|
||||
*/
|
||||
Result shaderProgramSetVsh(shaderProgram_s* sp, DVLE_s* dvle);
|
||||
|
||||
/**
|
||||
* @brief Sets the geometry shader of a shader program.
|
||||
* @param sp Shader program to use.
|
||||
* @param dvle Geometry shader to set.
|
||||
* @param stride Stride of the geometry shader.
|
||||
*/
|
||||
Result shaderProgramSetGsh(shaderProgram_s* sp, DVLE_s* dvle, u8 stride);
|
||||
|
||||
/**
|
||||
* @brief Sets the active shader program.
|
||||
* @param sp Shader program to use.
|
||||
*/
|
||||
Result shaderProgramUse(shaderProgram_s* sp);
|
||||
|
@ -1,78 +1,114 @@
|
||||
/**
|
||||
* @file shbin.h
|
||||
* @brief Shader binary support.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/gpu/gpu.h>
|
||||
|
||||
/// DVLE type.
|
||||
typedef enum{
|
||||
VERTEX_SHDR=GPU_VERTEX_SHADER,
|
||||
GEOMETRY_SHDR=GPU_GEOMETRY_SHADER
|
||||
VERTEX_SHDR=GPU_VERTEX_SHADER, ///< Vertex shader.
|
||||
GEOMETRY_SHDR=GPU_GEOMETRY_SHADER ///< Geometry shader.
|
||||
}DVLE_type;
|
||||
|
||||
/// Constant type.
|
||||
typedef enum{
|
||||
DVLE_CONST_BOOL=0x0,
|
||||
DVLE_CONST_u8=0x1,
|
||||
DVLE_CONST_FLOAT24=0x2,
|
||||
DVLE_CONST_BOOL=0x0, ///< Bool.
|
||||
DVLE_CONST_u8=0x1, ///< Unsigned 8-bit integer.
|
||||
DVLE_CONST_FLOAT24=0x2, ///< 24-bit float.
|
||||
}DVLE_constantType;
|
||||
|
||||
/// Output attribute.
|
||||
typedef enum{
|
||||
RESULT_POSITION = 0x0,
|
||||
RESULT_NORMALQUAT = 0x1,
|
||||
RESULT_COLOR = 0x2,
|
||||
RESULT_TEXCOORD0 = 0x3,
|
||||
RESULT_TEXCOORD0W = 0x4,
|
||||
RESULT_TEXCOORD1 = 0x5,
|
||||
RESULT_TEXCOORD2 = 0x6,
|
||||
RESULT_VIEW = 0x8
|
||||
RESULT_POSITION = 0x0, ///< Position.
|
||||
RESULT_NORMALQUAT = 0x1, ///< Normal Quaternion.
|
||||
RESULT_COLOR = 0x2, ///< Color.
|
||||
RESULT_TEXCOORD0 = 0x3, ///< Texture coordinate 0.
|
||||
RESULT_TEXCOORD0W = 0x4, ///< Texture coordinate 0 W.
|
||||
RESULT_TEXCOORD1 = 0x5, ///< Texture coordinate 1.
|
||||
RESULT_TEXCOORD2 = 0x6, ///< Texture coordinate 2.
|
||||
RESULT_VIEW = 0x8 ///< View.
|
||||
}DVLE_outputAttribute_t;
|
||||
|
||||
/// DVLP data.
|
||||
typedef struct{
|
||||
u32 codeSize;
|
||||
u32* codeData;
|
||||
u32 opdescSize;
|
||||
u32* opcdescData;
|
||||
u32 codeSize; ///< Code size.
|
||||
u32* codeData; ///< Code data.
|
||||
u32 opdescSize; ///< Operand description size.
|
||||
u32* opcdescData; ///< Operand description data.
|
||||
}DVLP_s;
|
||||
|
||||
/// DVLE constant entry data.
|
||||
typedef struct{
|
||||
u16 type;
|
||||
u16 id;
|
||||
u32 data[4];
|
||||
u16 type; ///< Constant type. See @ref DVLE_constantType
|
||||
u16 id; ///< Constant ID.
|
||||
u32 data[4]; ///< Constant data.
|
||||
}DVLE_constEntry_s;
|
||||
|
||||
/// DVLE output entry data.
|
||||
typedef struct{
|
||||
u16 type;
|
||||
u16 regID;
|
||||
u8 mask;
|
||||
u8 unk[3];
|
||||
u16 type; ///< Output type. See @ref DVLE_outputAttribute_t
|
||||
u16 regID; ///< Output register ID.
|
||||
u8 mask; ///< Output mask.
|
||||
u8 unk[3]; ///< Unknown.
|
||||
}DVLE_outEntry_s;
|
||||
|
||||
/// DVLE uniform entry data.
|
||||
typedef struct{
|
||||
u32 symbolOffset;
|
||||
u16 startReg;
|
||||
u16 endReg;
|
||||
u32 symbolOffset; ///< Symbol offset.
|
||||
u16 startReg; ///< Start register.
|
||||
u16 endReg; ///< End register.
|
||||
}DVLE_uniformEntry_s;
|
||||
|
||||
/// DVLE data.
|
||||
typedef struct{
|
||||
DVLE_type type;
|
||||
DVLP_s* dvlp;
|
||||
u32 mainOffset, endmainOffset;
|
||||
u32 constTableSize;
|
||||
DVLE_constEntry_s* constTableData;
|
||||
u32 outTableSize;
|
||||
DVLE_outEntry_s* outTableData;
|
||||
u32 uniformTableSize;
|
||||
DVLE_uniformEntry_s* uniformTableData;
|
||||
char* symbolTableData;
|
||||
u8 outmapMask;
|
||||
u32 outmapData[8];
|
||||
DVLE_type type; ///< DVLE type.
|
||||
DVLP_s* dvlp; ///< Contained DVLPs.
|
||||
u32 mainOffset; ///< Offset of the start of the main function.
|
||||
u32 endmainOffset; ///< Offset of the end of the main function.
|
||||
u32 constTableSize; ///< Constant table size.
|
||||
DVLE_constEntry_s* constTableData; ///< Constant table data.
|
||||
u32 outTableSize; ///< Output table size.
|
||||
DVLE_outEntry_s* outTableData; ///< Output table data.
|
||||
u32 uniformTableSize; ///< Uniform table size.
|
||||
DVLE_uniformEntry_s* uniformTableData; ///< Uniform table data.
|
||||
char* symbolTableData; ///< Symbol table data.
|
||||
u8 outmapMask; ///< Output map mask.
|
||||
u32 outmapData[8]; ///< Output map data.
|
||||
}DVLE_s;
|
||||
|
||||
/// DVLB data.
|
||||
typedef struct{
|
||||
u32 numDVLE;
|
||||
DVLP_s DVLP;
|
||||
DVLE_s* DVLE;
|
||||
u32 numDVLE; ///< DVLE count.
|
||||
DVLP_s DVLP; ///< Primary DVLP.
|
||||
DVLE_s* DVLE; ///< Contained DVLE.
|
||||
}DVLB_s;
|
||||
|
||||
/**
|
||||
* @brief Parses a shader binary.
|
||||
* @param shbinData Shader binary data.
|
||||
* @param shbinSize Shader binary size.
|
||||
* @return The parsed shader binary.
|
||||
*/
|
||||
DVLB_s* DVLB_ParseFile(u32* shbinData, u32 shbinSize);
|
||||
|
||||
/**
|
||||
* @brief Frees shader binary data.
|
||||
* @param dvlb DVLB to free.
|
||||
*/
|
||||
void DVLB_Free(DVLB_s* dvlb);
|
||||
|
||||
/**
|
||||
* @brief Gets a uniform register index from a shader.
|
||||
* @param dvle Shader to get the register from.
|
||||
* @param name Name of the register.
|
||||
* @return The uniform register index.
|
||||
*/
|
||||
s8 DVLE_GetUniformRegister(DVLE_s* dvle, const char* name);
|
||||
|
||||
/**
|
||||
* @brief Generates a shader output map.
|
||||
* @param dvle Shader to generate an output map for.
|
||||
*/
|
||||
void DVLE_GenerateOutmap(DVLE_s* dvle);
|
||||
|
@ -1,52 +1,148 @@
|
||||
/**
|
||||
* @file channel.h
|
||||
* @brief NDSP channels.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
///@name Data types
|
||||
///@{
|
||||
/// Supported NDSP encodings.
|
||||
enum
|
||||
{
|
||||
NDSP_ENCODING_PCM8 = 0,
|
||||
NDSP_ENCODING_PCM16,
|
||||
NDSP_ENCODING_ADPCM, // DSPADPCM (GameCube format)
|
||||
};
|
||||
NDSP_ENCODING_PCM8 = 0, ///< PCM8
|
||||
NDSP_ENCODING_PCM16, ///< PCM16
|
||||
NDSP_ENCODING_ADPCM, ///< DSPADPCM (GameCube format)
|
||||
} NDSP_Encoding;
|
||||
|
||||
/// Creates a hardware channel value from a channel number.
|
||||
#define NDSP_CHANNELS(n) ((u32)(n) & 3)
|
||||
/// Creates a hardware encoding value from an encoding type.
|
||||
#define NDSP_ENCODING(n) (((u32)(n) & 3) << 2)
|
||||
|
||||
/// NDSP playback flags.
|
||||
enum
|
||||
{
|
||||
NDSP_FORMAT_MONO_PCM8 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM8),
|
||||
NDSP_FORMAT_MONO_PCM16 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM16),
|
||||
NDSP_FORMAT_MONO_ADPCM = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_ADPCM),
|
||||
NDSP_FORMAT_STEREO_PCM8 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM8),
|
||||
NDSP_FORMAT_STEREO_PCM16 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM16),
|
||||
NDSP_FORMAT_MONO_PCM8 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM8), ///< Buffer contains Mono PCM8.
|
||||
NDSP_FORMAT_MONO_PCM16 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM16), ///< Buffer contains Mono PCM16.
|
||||
NDSP_FORMAT_MONO_ADPCM = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_ADPCM), ///< Buffer contains Mono ADPCM.
|
||||
NDSP_FORMAT_STEREO_PCM8 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM8), ///< Buffer contains Stereo PCM8.
|
||||
NDSP_FORMAT_STEREO_PCM16 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM16), ///< Buffer contains Stereo PCM16.
|
||||
|
||||
NDSP_FORMAT_PCM8 = NDSP_FORMAT_MONO_PCM8,
|
||||
NDSP_FORMAT_PCM16 = NDSP_FORMAT_MONO_PCM16,
|
||||
NDSP_FORMAT_ADPCM = NDSP_FORMAT_MONO_ADPCM,
|
||||
NDSP_FORMAT_PCM8 = NDSP_FORMAT_MONO_PCM8, ///< (Alias) Buffer contains Mono PCM8.
|
||||
NDSP_FORMAT_PCM16 = NDSP_FORMAT_MONO_PCM16, ///< (Alias) Buffer contains Mono PCM16.
|
||||
NDSP_FORMAT_ADPCM = NDSP_FORMAT_MONO_ADPCM, ///< (Alias) Buffer contains Mono ADPCM.
|
||||
|
||||
// Flags
|
||||
NDSP_FRONT_BYPASS = BIT(4),
|
||||
NDSP_3D_SURROUND_PREPROCESSED = BIT(6), //?
|
||||
};
|
||||
NDSP_FRONT_BYPASS = BIT(4), ///< Front bypass.
|
||||
NDSP_3D_SURROUND_PREPROCESSED = BIT(6), ///< Preprocessed 3D surround sound.
|
||||
} NDSP_Flags;
|
||||
///@}
|
||||
|
||||
// Basic channel operation
|
||||
///@name Basic channel operation
|
||||
///@{
|
||||
/**
|
||||
* @brief Resets a channel.
|
||||
* @param id ID of the channel.
|
||||
*/
|
||||
void ndspChnReset(int id);
|
||||
|
||||
/**
|
||||
* @brief Initializes the parameters of a channel.
|
||||
* @param id ID of the channel.
|
||||
*/
|
||||
void ndspChnInitParams(int id);
|
||||
|
||||
/**
|
||||
* @brief Checks whether a channel is currently playing.
|
||||
* @param id ID of the channel.
|
||||
* @return Whether the channel is currently playing.
|
||||
*/
|
||||
bool ndspChnIsPlaying(int id);
|
||||
|
||||
/**
|
||||
* @brief Gets the current sample position of a channel.
|
||||
* @param id ID of the channel.
|
||||
* @return The channel's sample position.
|
||||
*/
|
||||
u32 ndspChnGetSamplePos(int id);
|
||||
|
||||
/**
|
||||
* @brief Gets the current wave buffer sequence position of a channel.
|
||||
* @param id ID of the channel.
|
||||
* @return The channel's wave buffer sequence position.
|
||||
*/
|
||||
u16 ndspChnGetWaveBufSeq(int id);
|
||||
///@}
|
||||
|
||||
// Configuration
|
||||
///@name Configuration
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets the format of a channel.
|
||||
* @sa NDSP_Encoding
|
||||
* @param id ID of the channel.
|
||||
* @param format Format to use.
|
||||
*/
|
||||
void ndspChnSetFormat(int id, u16 format);
|
||||
|
||||
/**
|
||||
* @brief Sets the linear interpolation type of a channel.
|
||||
* @param id ID of the channel.
|
||||
* @param type Linear interpolation type to use.
|
||||
*/
|
||||
void ndspChnSetInterp(int id, int type);
|
||||
|
||||
/**
|
||||
* @brief Sets the sample rate of a channel.
|
||||
* @param id ID of the channel.
|
||||
* @param rate Sample rate to use.
|
||||
*/
|
||||
void ndspChnSetRate(int id, float rate);
|
||||
|
||||
/**
|
||||
* @brief Sets the mix parameters of a channel.
|
||||
* @param id ID of the channel.
|
||||
* @param mix Mix parameters to use.
|
||||
*/
|
||||
void ndspChnSetMix(int id, float mix[12]);
|
||||
|
||||
/**
|
||||
* @brief Sets the ADPCM coefficients of a channel.
|
||||
* @param id ID of the channel.
|
||||
* @param coefs ADPCM coefficients to use.
|
||||
*/
|
||||
void ndspChnSetAdpcmCoefs(int id, u16 coefs[16]);
|
||||
///@}
|
||||
|
||||
// Wave buffers
|
||||
///@name Wave buffers
|
||||
///@{
|
||||
/**
|
||||
* @brief Clears the wave buffers of a channel.
|
||||
* @param id ID of the channel.
|
||||
*/
|
||||
void ndspChnWaveBufClear(int id);
|
||||
void ndspChnWaveBufAdd(int id, ndspWaveBuf* buf);
|
||||
|
||||
// IIR filters
|
||||
/**
|
||||
* @brief Adds a wave buffer to a channel.
|
||||
* @param id ID of the channel.
|
||||
* @param buf Wave buffer to add.
|
||||
*/
|
||||
void ndspChnWaveBufAdd(int id, ndspWaveBuf* buf);
|
||||
///@}
|
||||
|
||||
///@name IIR filters
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets whether the mono filter of a channel is enabled.
|
||||
* @param id ID of the channel.
|
||||
* @param enable Whether to enable the mono filter.
|
||||
*/
|
||||
void ndspChnIirMonoSetEnable(int id, bool enable);
|
||||
// ndspChnIirMonoSetParams
|
||||
/**
|
||||
* @brief Sets whether the biquad filter of a channel is enabled.
|
||||
* @param id ID of the channel.
|
||||
* @param enable Whether to enable the biquad filter.
|
||||
*/
|
||||
void ndspChnIirBiquadSetEnable(int id, bool enable);
|
||||
// ndspChnIirBiquadSetParams
|
||||
///@}
|
||||
|
@ -1,59 +1,168 @@
|
||||
/**
|
||||
* @file ndsp.h
|
||||
* @brief Nintendo default DSP interface.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
///@name Data types
|
||||
///@{
|
||||
/// ADPCM data.
|
||||
typedef struct
|
||||
{
|
||||
u16 index;
|
||||
s16 history0, history1;
|
||||
u16 index; ///< Current sample index(?)
|
||||
s16 history0; ///< First previous sample index(?)
|
||||
s16 history1; ///< Second previous sample index(?)
|
||||
} ndspAdpcmData;
|
||||
|
||||
/// Wave buffer type.
|
||||
typedef struct tag_ndspWaveBuf ndspWaveBuf;
|
||||
|
||||
/// Wave buffer struct.
|
||||
struct tag_ndspWaveBuf
|
||||
{
|
||||
union
|
||||
{
|
||||
s8* data_pcm8;
|
||||
s16* data_pcm16;
|
||||
u8* data_adpcm;
|
||||
u32 data_vaddr;
|
||||
s8* data_pcm8; ///< PCM8 data.
|
||||
s16* data_pcm16; ///< PCM16 data.
|
||||
u8* data_adpcm; ///< ADPCM data.
|
||||
u32 data_vaddr; ///< Data virtual address.
|
||||
};
|
||||
u32 nsamples;
|
||||
ndspAdpcmData* adpcm_data;
|
||||
u32 nsamples; ///< Total samples.
|
||||
ndspAdpcmData* adpcm_data; ///< ADPCM data.
|
||||
|
||||
u32 offset; // only used for capture
|
||||
bool looping;
|
||||
u8 padding;
|
||||
u32 offset; ///< Buffer offset. Only used for capture.
|
||||
bool looping; ///< Whether to loop the buffer.
|
||||
u8 padding; ///< Padding.
|
||||
|
||||
// The following fields are used internally
|
||||
u16 sequence_id;
|
||||
ndspWaveBuf* next;
|
||||
u16 sequence_id; ///< Sequence ID. Used internally.
|
||||
ndspWaveBuf* next; ///< Next buffer. Used internally.
|
||||
};
|
||||
|
||||
/// NDSP callback function. (data = User provided data)
|
||||
typedef void (*ndspCallback)(void* data);
|
||||
/// NDSP auxiliary callback function. (data = User provided data, nsamples = Number of samples, samples = Sample data)
|
||||
typedef void (*ndspAuxCallback)(void* data, int nsamples, void* samples[4]);
|
||||
///@}
|
||||
|
||||
// Initialization and basic operations
|
||||
///@name Initialization and basic operations
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets up the DSP component.
|
||||
* @param binary DSP binary to load.
|
||||
* @param size Size of the DSP binary.
|
||||
* @param progMask Program RAM block mask to load the binary to.
|
||||
* @param dataMask Data RAM block mask to load the binary to.
|
||||
*/
|
||||
void ndspUseComponent(const void* binary, u32 size, u16 progMask, u16 dataMask);
|
||||
|
||||
/// Initializes NDSP.
|
||||
Result ndspInit(void);
|
||||
|
||||
/// Exits NDSP.
|
||||
void ndspExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the number of dropped NDSP frames.
|
||||
* @return The number of dropped frames.
|
||||
*/
|
||||
u32 ndspGetDroppedFrames(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the total NDSP frame count.
|
||||
* @return The total frame count.
|
||||
*/
|
||||
u32 ndspGetFrameCount(void);
|
||||
///@}
|
||||
|
||||
// General parameters
|
||||
///@name General parameters
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets the master volume.
|
||||
* @param volume Volume to set. Defaults to 1.0f.
|
||||
*/
|
||||
void ndspSetMasterVol(float volume);
|
||||
|
||||
/**
|
||||
* @brief Sets the output mode.
|
||||
* @param mode Output mode to set. Defaults to 0.
|
||||
*/
|
||||
void ndspSetOutputMode(int mode);
|
||||
|
||||
/**
|
||||
* @brief Sets the clipping mode.
|
||||
* @param mode Clipping mode to set. Defaults to 1.
|
||||
*/
|
||||
void ndspSetClippingMode(int mode);
|
||||
|
||||
/**
|
||||
* @brief Sets the output count.
|
||||
* @param count Output count to set. Defaults to 2.
|
||||
*/
|
||||
void ndspSetOutputCount(int count);
|
||||
|
||||
/**
|
||||
* @brief Sets the wave buffer to capture audio to.
|
||||
* @param capture Wave buffer to capture to.
|
||||
*/
|
||||
void ndspSetCapture(ndspWaveBuf* capture);
|
||||
|
||||
/**
|
||||
* @brief Sets the NDSP frame callback.
|
||||
* @param callback Callback to set.
|
||||
* @param data User-defined data to pass to the callback.
|
||||
*/
|
||||
void ndspSetCallback(ndspCallback callback, void* data);
|
||||
///@}
|
||||
|
||||
// Surround
|
||||
///@name Surround
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets the surround sound depth.
|
||||
* @param depth Depth to set. Defaults to 0x7FFF.
|
||||
*/
|
||||
void ndspSurroundSetDepth(u16 depth);
|
||||
void ndspSurroundSetPos(u16 pos);
|
||||
void ndspSurroundSetRearRatio(u16 ratio);
|
||||
|
||||
// Auxiliary output
|
||||
/**
|
||||
* @brief Sets the surround sound position.
|
||||
* @param pos Position to set. Defaults to 0.
|
||||
*/
|
||||
void ndspSurroundSetPos(u16 pos);
|
||||
|
||||
/**
|
||||
* @brief Sets the surround sound rear ratio.
|
||||
* @param ratio Rear ratio to set. Defaults to 0x8000.
|
||||
*/
|
||||
void ndspSurroundSetRearRatio(u16 ratio);
|
||||
///@}
|
||||
|
||||
///@name Auxiliary output
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets whether an auxiliary output is enabled.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param enable Whether to enable the auxiliary output.
|
||||
*/
|
||||
void ndspAuxSetEnable(int id, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Sets whether an auxiliary output should use front bypass.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param bypass Whether to use front bypass.
|
||||
*/
|
||||
void ndspAuxSetFrontBypass(int id, bool bypass);
|
||||
|
||||
/**
|
||||
* @brief Sets the volume of an auxiliary output.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param volume Volume to set.
|
||||
*/
|
||||
void ndspAuxSetVolume(int id, float volume);
|
||||
|
||||
/**
|
||||
* @brief Sets the NDSP frame callback of an auxiliary output.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param callback Callback to set.
|
||||
* @param data User-defined data to pass to the callback.
|
||||
*/
|
||||
void ndspAuxSetCallback(int id, ndspAuxCallback callback, void* data);
|
||||
///@}
|
||||
|
@ -1,11 +1,13 @@
|
||||
/**
|
||||
* @file apt.h
|
||||
* @brief APT service.
|
||||
* @brief APT (Applet) service.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// TODO : find a better place to put this
|
||||
// TODO: find a better place to put this
|
||||
/// APT workaround flag.
|
||||
#define RUNFLAG_APTWORKAROUND (BIT(0))
|
||||
/// APT reinititalize flag.
|
||||
#define RUNFLAG_APTREINIT (BIT(1))
|
||||
|
||||
/**
|
||||
@ -165,28 +167,185 @@ void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param);
|
||||
*/
|
||||
void aptUnhook(aptHookCookie* cookie);
|
||||
|
||||
/**
|
||||
* @brief Gets an APT lock handle.
|
||||
* @param flags Flags to use.
|
||||
* @param lockHandle Pointer to output the lock handle to.
|
||||
*/
|
||||
Result APT_GetLockHandle(u16 flags, Handle* lockHandle);
|
||||
|
||||
/**
|
||||
* @brief Initializes an application's registration with APT.
|
||||
* @param appId ID of the application.
|
||||
* @param eventHandle1 Pointer to output the signal event handle to.
|
||||
* @param eventHandle2 Pointer to output the launch and exit event handle to.
|
||||
*/
|
||||
Result APT_Initialize(NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
|
||||
|
||||
/**
|
||||
* @brief Terminates an application's registration with APT.
|
||||
* @param appID ID of the application.
|
||||
*/
|
||||
Result APT_Finalize(NS_APPID appId);
|
||||
|
||||
/// Asynchronously resets the hardware.
|
||||
Result APT_HardwareResetAsync(void);
|
||||
|
||||
/**
|
||||
* @brief Enables APT.
|
||||
* @param a Parameter to enable with.
|
||||
*/
|
||||
Result APT_Enable(u32 a);
|
||||
|
||||
/**
|
||||
* @brief Gets applet management info.
|
||||
* @param inval Requested applet type.
|
||||
* @param outval8 Pointer to output the current applet type to.
|
||||
* @param outval32 Pointer to output the requested app ID to.
|
||||
* @param menu_appid Pointer to output the home menu app ID to.
|
||||
* @param active_appid Pointer to output the currently active app ID to.
|
||||
* @param pAttributes Pointer to output the atrributes to.
|
||||
*/
|
||||
Result APT_GetAppletManInfo(u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid);
|
||||
|
||||
/**
|
||||
* @brief Gets an applet's information.
|
||||
* @param appID ID of the applet.
|
||||
* @param pProgramID Pointer to output the program ID to.
|
||||
* @param pMediaType Pointer to output the media type to.
|
||||
* @param pRegistered Pointer to output the registration status to.
|
||||
* @param pLoadState Pointer to output the load state to.
|
||||
* @param pAttributes Pointer to output the atrributes to.
|
||||
*/
|
||||
Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes);
|
||||
|
||||
/**
|
||||
* @brief Gets an applet's program information.
|
||||
* @param id ID of the applet.
|
||||
* @param flags Flags to use when retreiving the information.
|
||||
* @param titleversion Pointer to output the applet's title version to.
|
||||
*
|
||||
* Flags:
|
||||
* - 0x01: Use AM_ListTitles with NAND media type.
|
||||
* - 0x02: Use AM_ListTitles with SDMC media type.
|
||||
* - 0x04: Use AM_ListTitles with GAMECARD media type.
|
||||
* - 0x10: Input ID is an app ID. Must be set if 0x20 is not.
|
||||
* - 0x20: Input ID is a program ID. Must be set if 0x10 is not.
|
||||
* - 0x100: Sets program ID high to 0x00040000, else it is 0x00040010. Only used when 0x20 is set.
|
||||
*/
|
||||
Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion);
|
||||
|
||||
/**
|
||||
* @brief Gets the current application's program ID.
|
||||
* @param pProgramID Pointer to output the program ID to.
|
||||
*/
|
||||
Result APT_GetProgramID(u64* pProgramID);
|
||||
|
||||
/// Prepares to jump to the home menu.
|
||||
Result APT_PrepareToJumpToHomeMenu(void);
|
||||
|
||||
/**
|
||||
* @brief Jumps to the home menu.
|
||||
* @param param Parameters to jump with.
|
||||
* @param Size of the parameter buffer.
|
||||
* @param handle Handle to pass.
|
||||
*/
|
||||
Result APT_JumpToHomeMenu(const u8 *param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Prepares to jump to an application.
|
||||
* @param a Application to jump to.
|
||||
*/
|
||||
Result APT_PrepareToJumpToApplication(u32 a);
|
||||
|
||||
/**
|
||||
* @brief Jumps to an application.
|
||||
* @param param Parameters to jump with.
|
||||
* @param Size of the parameter buffer.
|
||||
* @param handle Handle to pass.
|
||||
*/
|
||||
Result APT_JumpToApplication(const u8 *param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Gets whether an application is registered.
|
||||
* @param appID ID of the application.
|
||||
* @param out Pointer to output the registration state to.
|
||||
*/
|
||||
Result APT_IsRegistered(NS_APPID appID, u8* out);
|
||||
|
||||
/**
|
||||
* @brief Inquires as to whether a signal has been received.
|
||||
* @param appID ID of the application.
|
||||
* @param signalType Pointer to output the signal type to.
|
||||
*/
|
||||
Result APT_InquireNotification(u32 appID, u8* signalType);
|
||||
|
||||
/**
|
||||
* @brief Notifies an application to wait.
|
||||
* @param appID ID of the application.
|
||||
*/
|
||||
Result APT_NotifyToWait(NS_APPID appID);
|
||||
|
||||
/**
|
||||
* @brief Calls an applet utility function.
|
||||
* @param out Pointer to write output data to.
|
||||
* @param a Utility function to call.
|
||||
* @param size1 Size of the first buffer.
|
||||
* @param buf1 First buffer.
|
||||
* @param size2 Size of the second buffer.
|
||||
* @param buf2 Second buffer.
|
||||
*/
|
||||
Result APT_AppletUtility(u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2);
|
||||
|
||||
/**
|
||||
* @brief Glances at a receieved parameter without removing it from the queue.
|
||||
* @param appID ID of the application.
|
||||
* @param bufferSize Size of the buffer.
|
||||
* @param buffer Buffer to receive to.
|
||||
* @param actualSize Pointer to output the actual received data size to.
|
||||
* @param signalType Pointer to output the signal type to.
|
||||
*/
|
||||
Result APT_GlanceParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
|
||||
|
||||
/**
|
||||
* @brief Receives a parameter.
|
||||
* @param appID ID of the application.
|
||||
* @param bufferSize Size of the buffer.
|
||||
* @param buffer Buffer to receive to.
|
||||
* @param actualSize Pointer to output the actual received data size to.
|
||||
* @param signalType Pointer to output the signal type to.
|
||||
*/
|
||||
Result APT_ReceiveParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
|
||||
|
||||
/**
|
||||
* @brief Sends a parameter.
|
||||
* @param src_appID ID of the source application.
|
||||
* @param dst_appID ID of the destination application.
|
||||
* @param bufferSize Size of the buffer.
|
||||
* @param buffer Buffer to send.
|
||||
* @param paramhandle Handle to pass.
|
||||
* @param signalType Signal type to send.
|
||||
*/
|
||||
Result APT_SendParameter(NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType);
|
||||
|
||||
/**
|
||||
* @brief Sends capture buffer information.
|
||||
* @param bufferSize Size of the buffer to send.
|
||||
* @param buffer Buffer to send.
|
||||
*/
|
||||
Result APT_SendCaptureBufferInfo(u32 bufferSize, u32* buffer);
|
||||
|
||||
/**
|
||||
* @brief Replies to a sleep query.
|
||||
* @param appID ID of the application.
|
||||
* @param a Parameter to reply with.
|
||||
*/
|
||||
Result APT_ReplySleepQuery(NS_APPID appID, u32 a);
|
||||
|
||||
/**
|
||||
* @brief Replies that a sleep notification has been completed.
|
||||
* @param appID ID of the application.
|
||||
*/
|
||||
Result APT_ReplySleepNotificationComplete(NS_APPID appID);
|
||||
|
||||
/**
|
||||
@ -197,9 +356,9 @@ Result APT_PrepareToCloseApplication(u8 a);
|
||||
|
||||
/**
|
||||
* @brief Closes the application.
|
||||
* @param param Parameter to use.
|
||||
* @param param Parameters to close with.
|
||||
* @param paramSize Size of param.
|
||||
* @param handle Handle to use.
|
||||
* @param handle Handle to pass.
|
||||
*/
|
||||
Result APT_CloseApplication(const u8 *param, size_t paramSize, Handle handle);
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* @brief Initializes MIC.
|
||||
* @param sharedmem Shared memory block to use. Must be 0x1000-bytes aligned.
|
||||
* @param sharedmem_size Size of the shared memory block to use. (audiodata size + 4, aligned to 0x1000-bytes)
|
||||
* @param control Control. TODO: Document parameter.
|
||||
* @param control Control value. Bits 0-6 = Amplification.
|
||||
* @param unk0 Unknown. Typically 3.
|
||||
* @param unk1 Unknown. Typically 1.
|
||||
* @param unk2 Unknown. Typically 1.
|
||||
@ -72,12 +72,14 @@ Result MIC_GetEventHandle(Handle *handle);
|
||||
|
||||
/**
|
||||
* Sets the control value.
|
||||
* @note Bits 0-6 = Amplification.
|
||||
* @param value Control value to set.
|
||||
*/
|
||||
Result MIC_SetControl(u8 value);
|
||||
|
||||
/**
|
||||
* Gets the control value.
|
||||
* @note Bits 0-6 = Amplification.
|
||||
* @param value Pointer to output the control value to.
|
||||
*/
|
||||
Result MIC_GetControl(u8 *value);
|
||||
|
Loading…
Reference in New Issue
Block a user