Add C3D_EarlyDepthTest() {currently unusable due to glitchy rendering}

This commit is contained in:
fincs 2017-04-02 17:14:49 +02:00
parent ce1aa48a12
commit a41dac3e3a
4 changed files with 17 additions and 5 deletions

View File

@ -6,6 +6,7 @@ void C3D_CullFace(GPU_CULLMODE mode);
void C3D_StencilTest(bool enable, GPU_TESTFUNC function, int ref, int inputMask, int writeMask);
void C3D_StencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass);
void C3D_BlendingColor(u32 color);
void C3D_EarlyDepthTest(bool enable, GPU_EARLYDEPTHFUNC function, u32 ref);
void C3D_DepthTest(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask);
void C3D_AlphaTest(bool enable, GPU_TESTFUNC function, int ref);
void C3D_AlphaBlend(GPU_BLENDEQUATION colorEq, GPU_BLENDEQUATION alphaEq, GPU_BLENDFACTOR srcClr, GPU_BLENDFACTOR dstClr, GPU_BLENDFACTOR srcAlpha, GPU_BLENDFACTOR dstAlpha);

View File

@ -104,6 +104,7 @@ bool C3D_Init(size_t cmdBufSize)
C3D_StencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
C3D_StencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP);
C3D_BlendingColor(0);
C3D_EarlyDepthTest(false, GPU_EARLYDEPTH_GREATER, 0);
C3D_DepthTest(true, GPU_GREATER, GPU_WRITE_ALL);
C3D_AlphaTest(false, GPU_ALWAYS, 0x00);
C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);

View File

@ -39,6 +39,14 @@ void C3D_BlendingColor(u32 color)
e->blendClr = color;
}
void C3D_EarlyDepthTest(bool enable, GPU_EARLYDEPTHFUNC function, u32 ref)
{
C3D_Effect* e = getEffect();
e->earlyDepth = enable;
e->earlyDepthFunc = function;
e->earlyDepthRef = ref;
}
void C3D_DepthTest(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask)
{
C3D_Effect* e = getEffect();
@ -90,8 +98,8 @@ void C3Di_EffectBind(C3D_Effect* e)
GPUCMD_AddWrite(GPUREG_LOGIC_OP, e->clrLogicOp);
GPUCMD_AddMaskedWrite(GPUREG_COLOR_OPERATION, 7, e->fragOpMode);
GPUCMD_AddWrite(GPUREG_FRAGOP_SHADOW, e->fragOpShadow);
// Disable early depth test?
GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 1, 0);
GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0);
GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 1, e->earlyDepth ? 1 : 0);
GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, e->earlyDepth ? 1 : 0);
GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_FUNC, 1, e->earlyDepthFunc);
GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_DATA, 0x7, e->earlyDepthRef);
}

View File

@ -14,7 +14,9 @@ typedef struct
u32 fragOpShadow;
u32 zScale, zOffset;
GPU_CULLMODE cullMode;
bool zBuffer;
bool zBuffer, earlyDepth;
GPU_EARLYDEPTHFUNC earlyDepthFunc;
u32 earlyDepthRef;
u32 alphaTest;
u32 stencilMode, stencilOp;