renderer_gl: Respect depth-stencil write flag
This commit is contained in:
@@ -59,6 +59,7 @@ namespace PICA {
|
|||||||
StencilTest = 0x105,
|
StencilTest = 0x105,
|
||||||
StencilOp = 0x106,
|
StencilOp = 0x106,
|
||||||
DepthAndColorMask = 0x107,
|
DepthAndColorMask = 0x107,
|
||||||
|
DepthBufferWrite = 0x115,
|
||||||
DepthBufferFormat = 0x116,
|
DepthBufferFormat = 0x116,
|
||||||
ColourBufferFormat = 0x117,
|
ColourBufferFormat = 0x117,
|
||||||
DepthBufferLoc = 0x11C,
|
DepthBufferLoc = 0x11C,
|
||||||
|
|||||||
@@ -225,10 +225,12 @@ void RendererGL::setupStencilTest(bool stencilEnable) {
|
|||||||
|
|
||||||
const u32 stencilConfig = regs[PICA::InternalRegs::StencilTest];
|
const u32 stencilConfig = regs[PICA::InternalRegs::StencilTest];
|
||||||
const u32 stencilFunc = getBits<4, 3>(stencilConfig);
|
const u32 stencilFunc = getBits<4, 3>(stencilConfig);
|
||||||
const u32 stencilBufferMask = getBits<8, 8>(stencilConfig);
|
|
||||||
const s32 reference = s8(getBits<16, 8>(stencilConfig)); // Signed reference value
|
const s32 reference = s8(getBits<16, 8>(stencilConfig)); // Signed reference value
|
||||||
const u32 stencilRefMask = getBits<24, 8>(stencilConfig);
|
const u32 stencilRefMask = getBits<24, 8>(stencilConfig);
|
||||||
|
|
||||||
|
const bool stencilWrite = regs[PICA::InternalRegs::DepthBufferWrite];
|
||||||
|
const u32 stencilBufferMask = stencilWrite ? getBits<8, 8>(stencilConfig) : 0;
|
||||||
|
|
||||||
glStencilFunc(stencilFuncs[stencilFunc], reference, stencilRefMask);
|
glStencilFunc(stencilFuncs[stencilFunc], reference, stencilRefMask);
|
||||||
glStencilMask(stencilBufferMask);
|
glStencilMask(stencilBufferMask);
|
||||||
|
|
||||||
@@ -381,6 +383,7 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
|||||||
poop.bind(OpenGL::DrawAndReadFramebuffer);
|
poop.bind(OpenGL::DrawAndReadFramebuffer);
|
||||||
|
|
||||||
const u32 depthControl = regs[PICA::InternalRegs::DepthAndColorMask];
|
const u32 depthControl = regs[PICA::InternalRegs::DepthAndColorMask];
|
||||||
|
const bool depthWrite = regs[PICA::InternalRegs::DepthBufferWrite];
|
||||||
const bool depthEnable = depthControl & 1;
|
const bool depthEnable = depthControl & 1;
|
||||||
const bool depthWriteEnable = getBit<12>(depthControl);
|
const bool depthWriteEnable = getBit<12>(depthControl);
|
||||||
const int depthFunc = getBits<4, 3>(depthControl);
|
const int depthFunc = getBits<4, 3>(depthControl);
|
||||||
@@ -432,7 +435,7 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
|||||||
// Because it attaches a depth texture to the aforementioned colour buffer
|
// Because it attaches a depth texture to the aforementioned colour buffer
|
||||||
if (depthEnable) {
|
if (depthEnable) {
|
||||||
gl.enableDepth();
|
gl.enableDepth();
|
||||||
gl.setDepthMask(depthWriteEnable ? GL_TRUE : GL_FALSE);
|
gl.setDepthMask(depthWriteEnable && depthWrite ? GL_TRUE : GL_FALSE);
|
||||||
gl.setDepthFunc(depthModes[depthFunc]);
|
gl.setDepthFunc(depthModes[depthFunc]);
|
||||||
bindDepthBuffer();
|
bindDepthBuffer();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user