summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-12-26 01:28:17 -0300
committerGravatar ReinUsesLisp2020-02-28 17:00:23 -0300
commit7c16b3551b5294d86a7dc8e0721c081bd88547ed (patch)
tree481af352889cd5c22166c215d755f93a297869ef /src
parentgl_state: Remove color mask tracking (diff)
downloadyuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.gz
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.xz
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.zip
gl_state: Remove scissor test tracking
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp32
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h2
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp35
-rw-r--r--src/video_core/renderer_opengl/gl_state.h10
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp1
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp1
6 files changed, 12 insertions, 69 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index d0c811929..3ccedcf55 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -467,12 +467,10 @@ void RasterizerOpenGL::Clear() {
467 SyncViewport(clear_state); 467 SyncViewport(clear_state);
468 SyncRasterizeEnable(clear_state); 468 SyncRasterizeEnable(clear_state);
469 if (regs.clear_flags.scissor) { 469 if (regs.clear_flags.scissor) {
470 SyncScissorTest(clear_state); 470 SyncScissorTest();
471 } 471 }
472 472
473 if (regs.clear_flags.viewport) { 473 UNIMPLEMENTED_IF(regs.clear_flags.viewport);
474 clear_state.EmulateViewportWithScissor();
475 }
476 474
477 clear_state.Apply(); 475 clear_state.Apply();
478 476
@@ -508,7 +506,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
508 SyncLogicOpState(); 506 SyncLogicOpState();
509 SyncCullMode(); 507 SyncCullMode();
510 SyncPrimitiveRestart(); 508 SyncPrimitiveRestart();
511 SyncScissorTest(state); 509 SyncScissorTest();
512 SyncTransformFeedback(); 510 SyncTransformFeedback();
513 SyncPointState(); 511 SyncPointState();
514 SyncPolygonOffset(); 512 SyncPolygonOffset();
@@ -1140,25 +1138,13 @@ void RasterizerOpenGL::SyncLogicOpState() {
1140 } 1138 }
1141} 1139}
1142 1140
1143void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) { 1141void RasterizerOpenGL::SyncScissorTest() {
1144 const auto& regs = system.GPU().Maxwell3D().regs; 1142 const auto& regs = system.GPU().Maxwell3D().regs;
1145 const bool geometry_shaders_enabled = 1143 for (std::size_t index = 0; index < Maxwell::NumViewports; ++index) {
1146 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry)); 1144 const auto& src = regs.scissor_test[index];
1147 const std::size_t viewport_count = 1145 oglEnablei(GL_SCISSOR_TEST, src.enable, static_cast<GLuint>(index));
1148 geometry_shaders_enabled ? Tegra::Engines::Maxwell3D::Regs::NumViewports : 1; 1146 glScissorIndexed(static_cast<GLuint>(index), src.min_x, src.min_y, src.max_x - src.min_x,
1149 for (std::size_t i = 0; i < viewport_count; i++) { 1147 src.max_y - src.min_y);
1150 const auto& src = regs.scissor_test[i];
1151 auto& dst = current_state.viewports[i].scissor;
1152 dst.enabled = (src.enable != 0);
1153 if (dst.enabled == 0) {
1154 return;
1155 }
1156 const u32 width = src.max_x - src.min_x;
1157 const u32 height = src.max_y - src.min_y;
1158 dst.x = src.min_x;
1159 dst.y = src.min_y;
1160 dst.width = width;
1161 dst.height = height;
1162 } 1148 }
1163} 1149}
1164 1150
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 91179323d..0450657a7 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -167,7 +167,7 @@ private:
167 void SyncMultiSampleState(); 167 void SyncMultiSampleState();
168 168
169 /// Syncs the scissor test state to match the guest state 169 /// Syncs the scissor test state to match the guest state
170 void SyncScissorTest(OpenGLState& current_state); 170 void SyncScissorTest();
171 171
172 /// Syncs the transform feedback state to match the guest state 172 /// Syncs the transform feedback state to match the guest state
173 void SyncTransformFeedback(); 173 void SyncTransformFeedback();
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index bcacc5590..dcea16fd3 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -171,19 +171,6 @@ void OpenGLState::ApplyViewport() {
171 current.depth_range_far = updated.depth_range_far; 171 current.depth_range_far = updated.depth_range_far;
172 glDepthRangeIndexed(i, updated.depth_range_near, updated.depth_range_far); 172 glDepthRangeIndexed(i, updated.depth_range_near, updated.depth_range_far);
173 } 173 }
174
175 Enable(GL_SCISSOR_TEST, i, current.scissor.enabled, updated.scissor.enabled);
176
177 if (current.scissor.x != updated.scissor.x || current.scissor.y != updated.scissor.y ||
178 current.scissor.width != updated.scissor.width ||
179 current.scissor.height != updated.scissor.height) {
180 current.scissor.x = updated.scissor.x;
181 current.scissor.y = updated.scissor.y;
182 current.scissor.width = updated.scissor.width;
183 current.scissor.height = updated.scissor.height;
184 glScissorIndexed(i, updated.scissor.x, updated.scissor.y, updated.scissor.width,
185 updated.scissor.height);
186 }
187 } 174 }
188} 175}
189 176
@@ -306,28 +293,6 @@ void OpenGLState::Apply() {
306 ApplyRenderBuffer(); 293 ApplyRenderBuffer();
307} 294}
308 295
309void OpenGLState::EmulateViewportWithScissor() {
310 auto& current = viewports[0];
311 if (current.scissor.enabled) {
312 const GLint left = std::max(current.x, current.scissor.x);
313 const GLint right =
314 std::max(current.x + current.width, current.scissor.x + current.scissor.width);
315 const GLint bottom = std::max(current.y, current.scissor.y);
316 const GLint top =
317 std::max(current.y + current.height, current.scissor.y + current.scissor.height);
318 current.scissor.x = std::max(left, 0);
319 current.scissor.y = std::max(bottom, 0);
320 current.scissor.width = std::max(right - left, 0);
321 current.scissor.height = std::max(top - bottom, 0);
322 } else {
323 current.scissor.enabled = true;
324 current.scissor.x = current.x;
325 current.scissor.y = current.y;
326 current.scissor.width = current.width;
327 current.scissor.height = current.height;
328 }
329}
330
331OpenGLState& OpenGLState::UnbindTexture(GLuint handle) { 296OpenGLState& OpenGLState::UnbindTexture(GLuint handle) {
332 for (auto& texture : textures) { 297 for (auto& texture : textures) {
333 if (texture == handle) { 298 if (texture == handle) {
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index ccc302014..44eb35dd5 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -63,13 +63,6 @@ public:
63 GLint height = 0; 63 GLint height = 0;
64 GLfloat depth_range_near = 0.0f; // GL_DEPTH_RANGE 64 GLfloat depth_range_near = 0.0f; // GL_DEPTH_RANGE
65 GLfloat depth_range_far = 1.0f; // GL_DEPTH_RANGE 65 GLfloat depth_range_far = 1.0f; // GL_DEPTH_RANGE
66 struct {
67 bool enabled = false; // GL_SCISSOR_TEST
68 GLint x = 0;
69 GLint y = 0;
70 GLsizei width = 0;
71 GLsizei height = 0;
72 } scissor;
73 }; 66 };
74 std::array<Viewport, Tegra::Engines::Maxwell3D::Regs::NumViewports> viewports; 67 std::array<Viewport, Tegra::Engines::Maxwell3D::Regs::NumViewports> viewports;
75 68
@@ -117,9 +110,6 @@ public:
117 OpenGLState& ResetFramebuffer(GLuint handle); 110 OpenGLState& ResetFramebuffer(GLuint handle);
118 OpenGLState& ResetRenderbuffer(GLuint handle); 111 OpenGLState& ResetRenderbuffer(GLuint handle);
119 112
120 /// Viewport does not affects glClearBuffer so emulate viewport using scissor test
121 void EmulateViewportWithScissor();
122
123private: 113private:
124 static OpenGLState cur_state; 114 static OpenGLState cur_state;
125}; 115};
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 0bdbb70a4..f6cb02c53 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -536,6 +536,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
536 } else { 536 } else {
537 glDisable(GL_FRAMEBUFFER_SRGB); 537 glDisable(GL_FRAMEBUFFER_SRGB);
538 } 538 }
539 glDisablei(GL_SCISSOR_TEST, 0);
539 540
540 u32 buffers{}; 541 u32 buffers{};
541 542
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 6dbf727ee..0d5ef9ef6 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -568,6 +568,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
568 glDisable(GL_ALPHA_TEST); 568 glDisable(GL_ALPHA_TEST);
569 glDisable(GL_DEPTH_TEST); 569 glDisable(GL_DEPTH_TEST);
570 glDisable(GL_POLYGON_OFFSET_FILL); 570 glDisable(GL_POLYGON_OFFSET_FILL);
571 glDisablei(GL_SCISSOR_TEST, 0);
571 glCullFace(GL_BACK); 572 glCullFace(GL_BACK);
572 glFrontFace(GL_CW); 573 glFrontFace(GL_CW);
573 glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 574 glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);