summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp65
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp30
-rw-r--r--src/video_core/renderer_opengl/gl_state.h14
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp1
4 files changed, 18 insertions, 92 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 8f9bb4c93..573f14cab 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -427,32 +427,6 @@ void RasterizerOpenGL::Clear() {
427 if (regs.clear_buffers.S) { 427 if (regs.clear_buffers.S) {
428 ASSERT_MSG(regs.zeta_enable != 0, "Tried to clear stencil but buffer is not enabled!"); 428 ASSERT_MSG(regs.zeta_enable != 0, "Tried to clear stencil but buffer is not enabled!");
429 use_stencil = true; 429 use_stencil = true;
430 clear_state.stencil.test_enabled = true;
431
432 if (regs.clear_flags.stencil) {
433 // Stencil affects the clear so fill it with the used masks
434 clear_state.stencil.front.test_func = GL_ALWAYS;
435 clear_state.stencil.front.test_mask = regs.stencil_front_func_mask;
436 clear_state.stencil.front.action_stencil_fail = GL_KEEP;
437 clear_state.stencil.front.action_depth_fail = GL_KEEP;
438 clear_state.stencil.front.action_depth_pass = GL_KEEP;
439 clear_state.stencil.front.write_mask = regs.stencil_front_mask;
440 if (regs.stencil_two_side_enable) {
441 clear_state.stencil.back.test_func = GL_ALWAYS;
442 clear_state.stencil.back.test_mask = regs.stencil_back_func_mask;
443 clear_state.stencil.back.action_stencil_fail = GL_KEEP;
444 clear_state.stencil.back.action_depth_fail = GL_KEEP;
445 clear_state.stencil.back.action_depth_pass = GL_KEEP;
446 clear_state.stencil.back.write_mask = regs.stencil_back_mask;
447 } else {
448 clear_state.stencil.back.test_func = GL_ALWAYS;
449 clear_state.stencil.back.test_mask = 0xFFFFFFFF;
450 clear_state.stencil.back.write_mask = 0xFFFFFFFF;
451 clear_state.stencil.back.action_stencil_fail = GL_KEEP;
452 clear_state.stencil.back.action_depth_fail = GL_KEEP;
453 clear_state.stencil.back.action_depth_pass = GL_KEEP;
454 }
455 }
456 } 430 }
457 431
458 if (!use_color && !use_depth && !use_stencil) { 432 if (!use_color && !use_depth && !use_stencil) {
@@ -1011,35 +985,30 @@ void RasterizerOpenGL::SyncDepthTestState() {
1011void RasterizerOpenGL::SyncStencilTestState() { 985void RasterizerOpenGL::SyncStencilTestState() {
1012 auto& maxwell3d = system.GPU().Maxwell3D(); 986 auto& maxwell3d = system.GPU().Maxwell3D();
1013 const auto& regs = maxwell3d.regs; 987 const auto& regs = maxwell3d.regs;
1014 state.stencil.test_enabled = regs.stencil_enable != 0;
1015 988
989 oglEnable(GL_STENCIL_TEST, regs.stencil_enable);
1016 if (!regs.stencil_enable) { 990 if (!regs.stencil_enable) {
1017 return; 991 return;
1018 } 992 }
1019 993
1020 state.stencil.front.test_func = MaxwellToGL::ComparisonOp(regs.stencil_front_func_func); 994 glStencilFuncSeparate(GL_FRONT, MaxwellToGL::ComparisonOp(regs.stencil_front_func_func),
1021 state.stencil.front.test_ref = regs.stencil_front_func_ref; 995 regs.stencil_front_func_ref, regs.stencil_front_func_mask);
1022 state.stencil.front.test_mask = regs.stencil_front_func_mask; 996 glStencilOpSeparate(GL_FRONT, MaxwellToGL::StencilOp(regs.stencil_front_op_fail),
1023 state.stencil.front.action_stencil_fail = MaxwellToGL::StencilOp(regs.stencil_front_op_fail); 997 MaxwellToGL::StencilOp(regs.stencil_front_op_zfail),
1024 state.stencil.front.action_depth_fail = MaxwellToGL::StencilOp(regs.stencil_front_op_zfail); 998 MaxwellToGL::StencilOp(regs.stencil_front_op_zpass));
1025 state.stencil.front.action_depth_pass = MaxwellToGL::StencilOp(regs.stencil_front_op_zpass); 999 glStencilMaskSeparate(GL_FRONT, regs.stencil_front_mask);
1026 state.stencil.front.write_mask = regs.stencil_front_mask; 1000
1027 if (regs.stencil_two_side_enable) { 1001 if (regs.stencil_two_side_enable) {
1028 state.stencil.back.test_func = MaxwellToGL::ComparisonOp(regs.stencil_back_func_func); 1002 glStencilFuncSeparate(GL_BACK, MaxwellToGL::ComparisonOp(regs.stencil_back_func_func),
1029 state.stencil.back.test_ref = regs.stencil_back_func_ref; 1003 regs.stencil_back_func_ref, regs.stencil_back_func_mask);
1030 state.stencil.back.test_mask = regs.stencil_back_func_mask; 1004 glStencilOpSeparate(GL_BACK, MaxwellToGL::StencilOp(regs.stencil_back_op_fail),
1031 state.stencil.back.action_stencil_fail = MaxwellToGL::StencilOp(regs.stencil_back_op_fail); 1005 MaxwellToGL::StencilOp(regs.stencil_back_op_zfail),
1032 state.stencil.back.action_depth_fail = MaxwellToGL::StencilOp(regs.stencil_back_op_zfail); 1006 MaxwellToGL::StencilOp(regs.stencil_back_op_zpass));
1033 state.stencil.back.action_depth_pass = MaxwellToGL::StencilOp(regs.stencil_back_op_zpass); 1007 glStencilMaskSeparate(GL_BACK, regs.stencil_back_mask);
1034 state.stencil.back.write_mask = regs.stencil_back_mask;
1035 } else { 1008 } else {
1036 state.stencil.back.test_func = GL_ALWAYS; 1009 glStencilFuncSeparate(GL_BACK, GL_ALWAYS, 0, 0xFFFFFFFF);
1037 state.stencil.back.test_ref = 0; 1010 glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP);
1038 state.stencil.back.test_mask = 0xFFFFFFFF; 1011 glStencilMaskSeparate(GL_BACK, 0xFFFFFFFF);
1039 state.stencil.back.write_mask = 0xFFFFFFFF;
1040 state.stencil.back.action_stencil_fail = GL_KEEP;
1041 state.stencil.back.action_depth_fail = GL_KEEP;
1042 state.stencil.back.action_depth_pass = GL_KEEP;
1043 } 1012 }
1044} 1013}
1045 1014
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index 69a8a4eb1..d62a55b2f 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -106,35 +106,6 @@ void OpenGLState::ApplyProgramPipeline() {
106 } 106 }
107} 107}
108 108
109void OpenGLState::ApplyStencilTest() {
110 Enable(GL_STENCIL_TEST, cur_state.stencil.test_enabled, stencil.test_enabled);
111
112 const auto ConfigStencil = [](GLenum face, const auto& config, auto& current) {
113 if (current.test_func != config.test_func || current.test_ref != config.test_ref ||
114 current.test_mask != config.test_mask) {
115 current.test_func = config.test_func;
116 current.test_ref = config.test_ref;
117 current.test_mask = config.test_mask;
118 glStencilFuncSeparate(face, config.test_func, config.test_ref, config.test_mask);
119 }
120 if (current.action_depth_fail != config.action_depth_fail ||
121 current.action_depth_pass != config.action_depth_pass ||
122 current.action_stencil_fail != config.action_stencil_fail) {
123 current.action_depth_fail = config.action_depth_fail;
124 current.action_depth_pass = config.action_depth_pass;
125 current.action_stencil_fail = config.action_stencil_fail;
126 glStencilOpSeparate(face, config.action_stencil_fail, config.action_depth_fail,
127 config.action_depth_pass);
128 }
129 if (current.write_mask != config.write_mask) {
130 current.write_mask = config.write_mask;
131 glStencilMaskSeparate(face, config.write_mask);
132 }
133 };
134 ConfigStencil(GL_FRONT, stencil.front, cur_state.stencil.front);
135 ConfigStencil(GL_BACK, stencil.back, cur_state.stencil.back);
136}
137
138void OpenGLState::ApplyGlobalBlending() { 109void OpenGLState::ApplyGlobalBlending() {
139 const Blend& updated = blend[0]; 110 const Blend& updated = blend[0];
140 Blend& current = cur_state.blend[0]; 111 Blend& current = cur_state.blend[0];
@@ -235,7 +206,6 @@ void OpenGLState::Apply() {
235 ApplyFramebufferState(); 206 ApplyFramebufferState();
236 ApplyShaderProgram(); 207 ApplyShaderProgram();
237 ApplyProgramPipeline(); 208 ApplyProgramPipeline();
238 ApplyStencilTest();
239 ApplyBlending(); 209 ApplyBlending();
240 ApplyTextures(); 210 ApplyTextures();
241 ApplySamplers(); 211 ApplySamplers();
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 6ea625c56..18f36da08 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -13,19 +13,6 @@ namespace OpenGL {
13 13
14class OpenGLState { 14class OpenGLState {
15public: 15public:
16 struct {
17 bool test_enabled = false; // GL_STENCIL_TEST
18 struct {
19 GLenum test_func = GL_ALWAYS; // GL_STENCIL_FUNC
20 GLint test_ref = 0; // GL_STENCIL_REF
21 GLuint test_mask = 0xFFFFFFFF; // GL_STENCIL_VALUE_MASK
22 GLuint write_mask = 0xFFFFFFFF; // GL_STENCIL_WRITEMASK
23 GLenum action_stencil_fail = GL_KEEP; // GL_STENCIL_FAIL
24 GLenum action_depth_fail = GL_KEEP; // GL_STENCIL_PASS_DEPTH_FAIL
25 GLenum action_depth_pass = GL_KEEP; // GL_STENCIL_PASS_DEPTH_PASS
26 } front, back;
27 } stencil;
28
29 struct Blend { 16 struct Blend {
30 bool enabled = false; // GL_BLEND 17 bool enabled = false; // GL_BLEND
31 GLenum rgb_equation = GL_FUNC_ADD; // GL_BLEND_EQUATION_RGB 18 GLenum rgb_equation = GL_FUNC_ADD; // GL_BLEND_EQUATION_RGB
@@ -69,7 +56,6 @@ public:
69 void ApplyFramebufferState(); 56 void ApplyFramebufferState();
70 void ApplyShaderProgram(); 57 void ApplyShaderProgram();
71 void ApplyProgramPipeline(); 58 void ApplyProgramPipeline();
72 void ApplyStencilTest();
73 void ApplyTargetBlending(std::size_t target, bool force); 59 void ApplyTargetBlending(std::size_t target, bool force);
74 void ApplyGlobalBlending(); 60 void ApplyGlobalBlending();
75 void ApplyBlending(); 61 void ApplyBlending();
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index a4cf6a489..fcadc09d9 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -579,6 +579,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
579 glDisable(GL_COLOR_LOGIC_OP); 579 glDisable(GL_COLOR_LOGIC_OP);
580 glDisable(GL_ALPHA_TEST); 580 glDisable(GL_ALPHA_TEST);
581 glDisable(GL_DEPTH_TEST); 581 glDisable(GL_DEPTH_TEST);
582 glDisable(GL_STENCIL_TEST);
582 glDisable(GL_POLYGON_OFFSET_FILL); 583 glDisable(GL_POLYGON_OFFSET_FILL);
583 glDisable(GL_RASTERIZER_DISCARD); 584 glDisable(GL_RASTERIZER_DISCARD);
584 glDisablei(GL_SCISSOR_TEST, 0); 585 glDisablei(GL_SCISSOR_TEST, 0);