summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_rasterizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f0ccc2397..d29049508 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -269,7 +269,8 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) {
break;
// Stencil test
- case PICA_REG_INDEX(output_merger.stencil_test):
+ case PICA_REG_INDEX(output_merger.stencil_test.raw_func):
+ case PICA_REG_INDEX(output_merger.stencil_test.raw_op):
SyncStencilTest();
break;
@@ -676,7 +677,15 @@ void RasterizerOpenGL::SyncLogicOp() {
}
void RasterizerOpenGL::SyncStencilTest() {
- // TODO: Implement stencil test, mask, and op
+ const auto& regs = Pica::g_state.regs;
+ state.stencil.test_enabled = regs.output_merger.stencil_test.enable && regs.framebuffer.depth_format == Pica::Regs::DepthFormat::D24S8;
+ state.stencil.test_func = PicaToGL::CompareFunc(regs.output_merger.stencil_test.func);
+ state.stencil.test_ref = regs.output_merger.stencil_test.reference_value;
+ state.stencil.test_mask = regs.output_merger.stencil_test.input_mask;
+ state.stencil.write_mask = regs.output_merger.stencil_test.write_mask;
+ state.stencil.action_stencil_fail = PicaToGL::StencilOp(regs.output_merger.stencil_test.action_stencil_fail);
+ state.stencil.action_depth_fail = PicaToGL::StencilOp(regs.output_merger.stencil_test.action_depth_fail);
+ state.stencil.action_depth_pass = PicaToGL::StencilOp(regs.output_merger.stencil_test.action_depth_pass);
}
void RasterizerOpenGL::SyncDepthTest() {
@@ -867,8 +876,15 @@ void RasterizerOpenGL::ReloadDepthBuffer() {
state.Apply();
glActiveTexture(GL_TEXTURE0);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fb_depth_texture.width, fb_depth_texture.height,
- fb_depth_texture.gl_format, fb_depth_texture.gl_type, temp_fb_depth_buffer.get());
+ if (fb_depth_texture.format == Pica::Regs::DepthFormat::D24S8) {
+ // TODO(Subv): There is a bug with Intel Windows drivers that makes glTexSubImage2D not change the stencil buffer.
+ // The bug has been reported to Intel (https://communities.intel.com/message/324464)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, fb_depth_texture.width, fb_depth_texture.height, 0,
+ GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, temp_fb_depth_buffer.get());
+ } else {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fb_depth_texture.width, fb_depth_texture.height,
+ fb_depth_texture.gl_format, fb_depth_texture.gl_type, temp_fb_depth_buffer.get());
+ }
state.texture_units[0].texture_2d = 0;
state.Apply();