[GL] Add stencil enable to state tracker

This commit is contained in:
wheremyfoodat 2023-07-27 15:34:21 +03:00
parent 03733569e0
commit b4cc743608
3 changed files with 25 additions and 3 deletions

View file

@ -21,6 +21,7 @@ struct GLStateManager {
bool blendEnabled;
bool depthEnabled;
bool scissorEnabled;
bool stencilEnabled;
// Colour/depth masks
bool redMask, greenMask, blueMask, alphaMask;
@ -40,6 +41,7 @@ struct GLStateManager {
void resetVBO();
void resetProgram();
void resetScissor();
void resetStencil();
void enableDepth() {
if (!depthEnabled) {
@ -83,6 +85,20 @@ struct GLStateManager {
}
}
void enableStencil() {
if (!stencilEnabled) {
stencilEnabled = true;
OpenGL::enableStencil();
}
}
void disableStencil() {
if (stencilEnabled) {
stencilEnabled = false;
OpenGL::disableStencil();
}
}
void bindVAO(GLuint handle) {
if (boundVAO != handle) {
boundVAO = handle;

View file

@ -26,6 +26,11 @@ void GLStateManager::resetScissor() {
OpenGL::setScissor(0, 0, 0, 0);
}
void GLStateManager::resetStencil() {
stencilEnabled = false;
OpenGL::disableStencil();
}
void GLStateManager::resetVAO() {
boundVAO = 0;
glBindVertexArray(0);
@ -50,4 +55,5 @@ void GLStateManager::reset() {
resetVBO();
resetProgram();
resetScissor();
resetStencil();
}

View file

@ -207,7 +207,7 @@ void RendererGL::setupBlending() {
void RendererGL::setupStencilTest(bool stencilEnable) {
if (!stencilEnable) {
OpenGL::disableStencil();
gl.disableStencil();
return;
}
@ -221,7 +221,7 @@ void RendererGL::setupStencilTest(bool stencilEnable) {
GL_GREATER,
GL_GEQUAL
};
OpenGL::enableStencil();
gl.enableStencil();
const u32 stencilConfig = regs[PICA::InternalRegs::StencilTest];
const u32 stencilFunc = getBits<4, 3>(stencilConfig);
@ -583,7 +583,7 @@ void RendererGL::displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u
gl.disableBlend();
gl.disableDepth();
gl.disableScissor();
OpenGL::disableStencil();
gl.disableStencil();
gl.setColourMask(true, true, true, true);
gl.useProgram(displayProgram);
gl.bindVAO(dummyVAO);