mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-24 00:29:57 +00:00
Merge pull request #6811 from unknownbrackets/d3d9
d3d: Add basic stencil mask handling
This commit is contained in:
commit
afb31ef79a
@ -92,8 +92,11 @@ namespace DX9 {
|
||||
}
|
||||
|
||||
static void ClearBuffer() {
|
||||
dxstate.depthWrite.set(true);
|
||||
dxstate.scissorTest.disable();
|
||||
dxstate.depthWrite.set(TRUE);
|
||||
dxstate.colorMask.set(true, true, true, true);
|
||||
dxstate.stencilFunc.set(D3DCMP_ALWAYS, 0, 0);
|
||||
dxstate.stencilMask.set(0xFF);
|
||||
pD3Ddevice->Clear(0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_TARGET |D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 0, 0);
|
||||
}
|
||||
|
||||
@ -103,6 +106,8 @@ namespace DX9 {
|
||||
dxstate.depthTest.disable();
|
||||
dxstate.scissorTest.disable();
|
||||
dxstate.stencilTest.disable();
|
||||
dxstate.colorMask.set(true, true, true, true);
|
||||
dxstate.stencilMask.set(0xFF);
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,6 +230,7 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
|
||||
dxstate.stencilTest.enable();
|
||||
dxstate.stencilOp.set(D3DSTENCILOP_REPLACE, D3DSTENCILOP_REPLACE, D3DSTENCILOP_REPLACE);
|
||||
dxstate.stencilFunc.set(D3DCMP_ALWAYS, 0, 0xFF);
|
||||
dxstate.stencilMask.set(0xFF);
|
||||
} else {
|
||||
dxstate.stencilTest.disable();
|
||||
}
|
||||
@ -254,6 +255,21 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
|
||||
bool gmask = ((gstate.pmskc >> 8) & 0xFF) < 128;
|
||||
bool bmask = ((gstate.pmskc >> 16) & 0xFF) < 128;
|
||||
bool amask = (gstate.pmska & 0xFF) < 128;
|
||||
|
||||
u8 abits = (gstate.pmska >> 0) & 0xFF;
|
||||
#ifndef MOBILE_DEVICE
|
||||
u8 rbits = (gstate.pmskc >> 0) & 0xFF;
|
||||
u8 gbits = (gstate.pmskc >> 8) & 0xFF;
|
||||
u8 bbits = (gstate.pmskc >> 16) & 0xFF;
|
||||
if ((rbits != 0 && rbits != 0xFF) || (gbits != 0 && gbits != 0xFF) || (bbits != 0 && bbits != 0xFF)) {
|
||||
WARN_LOG_REPORT_ONCE(rgbmask, G3D, "Unsupported RGB mask: r=%02x g=%02x b=%02x", rbits, gbits, bbits);
|
||||
}
|
||||
if (abits != 0 && abits != 0xFF) {
|
||||
// The stencil part of the mask is supported.
|
||||
WARN_LOG_REPORT_ONCE(amask, G3D, "Unsupported alpha/stencil mask: %02x", abits);
|
||||
}
|
||||
#endif
|
||||
|
||||
dxstate.colorMask.set(rmask, gmask, bmask, amask);
|
||||
|
||||
// Stencil Test
|
||||
@ -265,6 +281,7 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
|
||||
dxstate.stencilOp.set(stencilOps[gstate.getStencilOpSFail()], // stencil fail
|
||||
stencilOps[gstate.getStencilOpZFail()], // depth fail
|
||||
stencilOps[gstate.getStencilOpZPass()]); // depth pass
|
||||
dxstate.stencilMask.set(~abits);
|
||||
} else {
|
||||
dxstate.stencilTest.disable();
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ void DirectxState::Restore() {
|
||||
stencilTest.restore(); count++;
|
||||
stencilOp.restore(); count++;
|
||||
stencilFunc.restore(); count++;
|
||||
stencilMask.restore(); count++;
|
||||
|
||||
dither.restore(); count++;
|
||||
|
||||
|
@ -380,6 +380,7 @@ public:
|
||||
|
||||
DxState3<D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP> stencilOp;
|
||||
DxState3<D3DRS_STENCILFUNC, D3DCMP_ALWAYS, D3DRS_STENCILREF, 0, D3DRS_STENCILMASK, 0xFFFFFFFF> stencilFunc;
|
||||
DxState1<D3DRS_STENCILWRITEMASK, 0xFFFFFFFF> stencilMask;
|
||||
|
||||
DxSampler0State1<D3DSAMP_MINFILTER, D3DTEXF_POINT> texMinFilter;
|
||||
DxSampler0State1<D3DSAMP_MAGFILTER, D3DTEXF_POINT> texMagFilter;
|
||||
|
Loading…
Reference in New Issue
Block a user