GPU: Added code to manipulate the combiner buffer.

You can set an initial color value with GPUREG_TEXENV_BUFFER_COLOR, then use GPU_SetCombinerBufferWrite with GPU_TEV_BUFFER_WRITE_CONFIG to allow/disallow the TEV stages to write their color outputs to the buffer.

You can retrieve the previous buffer color using GPU_PREVIOUS_BUFFER as color source in the TEV config.
This commit is contained in:
Subv 2015-08-22 10:53:52 -05:00
parent c49d5f49c2
commit 1738893d05
3 changed files with 14 additions and 3 deletions

View File

@ -33,6 +33,9 @@ void GPUCMD_Finalize();
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<12) //takes a GPU_TEXTURE_WRAP_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 #define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<8) //takes a GPU_TEXTURE_WRAP_PARAM
// Combiner buffer write config
#define GPU_TEV_BUFFER_WRITE_CONFIG(stage0, stage1, stage2, stage3) (stage0 | (stage1 << 1) | (stage2 << 2) | (stage3 << 3))
typedef enum typedef enum
{ {
GPU_NEAREST = 0x0, GPU_NEAREST = 0x0,
@ -184,6 +187,7 @@ typedef enum{
GPU_TEXTURE1 = 0x04, GPU_TEXTURE1 = 0x04,
GPU_TEXTURE2 = 0x05, GPU_TEXTURE2 = 0x05,
GPU_TEXTURE3 = 0x06, GPU_TEXTURE3 = 0x06,
GPU_PREVIOUS_BUFFER = 0x0D,
GPU_CONSTANT = 0x0E, GPU_CONSTANT = 0x0E,
GPU_PREVIOUS = 0x0F, GPU_PREVIOUS = 0x0F,
}GPU_TEVSRC; }GPU_TEVSRC;
@ -262,6 +266,8 @@ void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEM
void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 mask, u8 replace); void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 mask, u8 replace);
void GPU_SetStencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass); void GPU_SetStencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass);
void GPU_SetFaceCulling(GPU_CULLMODE mode); void GPU_SetFaceCulling(GPU_CULLMODE mode);
// Only the first four tev stages can write to the combiner buffer, use GPU_TEV_BUFFER_WRITE_CONFIG to build the parameters
void GPU_SetCombinerBufferWrite(u8 rgb_config, u8 alpha_config);
// these two can't be used together // these two can't be used together
void GPU_SetAlphaBlending(GPU_BLENDEQUATION colorEquation, GPU_BLENDEQUATION alphaEquation, void GPU_SetAlphaBlending(GPU_BLENDEQUATION colorEquation, GPU_BLENDEQUATION alphaEquation,
@ -281,7 +287,7 @@ void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 para
/** /**
* @param borderColor The color used for the border when using the @ref GPU_CLAMP_TO_BORDER wrap mode * @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); void GPU_SetTextureBorderColor(GPU_TEXUNIT unit,u32 borderColor);
void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor); void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor);
void GPU_DrawArray(GPU_Primitive_t primitive, u32 n); void GPU_DrawArray(GPU_Primitive_t primitive, u32 n);

View File

@ -224,7 +224,7 @@
#define GPUREG_00DD 0x00DD #define GPUREG_00DD 0x00DD
#define GPUREG_00DE 0x00DE #define GPUREG_00DE 0x00DE
#define GPUREG_00DF 0x00DF #define GPUREG_00DF 0x00DF
#define GPUREG_00E0 0x00E0 #define GPUREG_TEXENV_BUFFER_CONFIG 0x00E0
#define GPUREG_00E1 0x00E1 #define GPUREG_00E1 0x00E1
#define GPUREG_00E2 0x00E2 #define GPUREG_00E2 0x00E2
#define GPUREG_00E3 0x00E3 #define GPUREG_00E3 0x00E3
@ -253,7 +253,7 @@
#define GPUREG_TEXENV5_CONFIG2 0x00FA #define GPUREG_TEXENV5_CONFIG2 0x00FA
#define GPUREG_TEXENV5_CONFIG3 0x00FB #define GPUREG_TEXENV5_CONFIG3 0x00FB
#define GPUREG_TEXENV5_CONFIG4 0x00FC #define GPUREG_TEXENV5_CONFIG4 0x00FC
#define GPUREG_00FD 0x00FD #define GPUREG_TEXENV_BUFFER_COLOR 0x00FD
#define GPUREG_00FE 0x00FE #define GPUREG_00FE 0x00FE
#define GPUREG_00FF 0x00FF #define GPUREG_00FF 0x00FF
#define GPUREG_COLOROUTPUT_CONFIG 0x0100 #define GPUREG_COLOROUTPUT_CONFIG 0x0100

View File

@ -463,6 +463,11 @@ void GPU_SetFaceCulling(GPU_CULLMODE mode)
GPUCMD_AddWrite(GPUREG_FACECULLING_CONFIG, mode&0x3); GPUCMD_AddWrite(GPUREG_FACECULLING_CONFIG, mode&0x3);
} }
void GPU_SetCombinerBufferWrite(u8 rgb_config, u8 alpha_config)
{
GPUCMD_AddMaskedWrite(GPUREG_TEXENV_BUFFER_CONFIG, 0x2, (rgb_config << 8) | (alpha_config << 12));
}
const u8 GPU_TEVID[]={0xC0,0xC8,0xD0,0xD8,0xF0,0xF8}; const u8 GPU_TEVID[]={0xC0,0xC8,0xD0,0xD8,0xF0,0xF8};
void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor) void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor)