diff options
| author | 2019-12-30 01:40:27 -0300 | |
|---|---|---|
| committer | 2020-02-28 17:56:42 -0300 | |
| commit | a42a6e1a2c41b59a779d92a94123f38d88c3fec3 (patch) | |
| tree | 47b53ff043d88de50ae4a2c40d2adb5e976a751b /src | |
| parent | gl_state_tracker: Implement dirty flags for point sizes (diff) | |
| download | yuzu-a42a6e1a2c41b59a779d92a94123f38d88c3fec3.tar.gz yuzu-a42a6e1a2c41b59a779d92a94123f38d88c3fec3.tar.xz yuzu-a42a6e1a2c41b59a779d92a94123f38d88c3fec3.zip | |
gl_state_tracker: Implement dirty flags for clip control
Diffstat (limited to 'src')
5 files changed, 31 insertions, 15 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index ec1936927..133ac6c0f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -460,7 +460,6 @@ void RasterizerOpenGL::Clear() { | |||
| 460 | // TODO: Signal state tracker about these changes | 460 | // TODO: Signal state tracker about these changes |
| 461 | state_tracker.NotifyBlend0(); | 461 | state_tracker.NotifyBlend0(); |
| 462 | // TODO(Rodrigo): Find out if these changes affect clearing | 462 | // TODO(Rodrigo): Find out if these changes affect clearing |
| 463 | glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); | ||
| 464 | glDisablei(GL_BLEND, 0); | 463 | glDisablei(GL_BLEND, 0); |
| 465 | 464 | ||
| 466 | UNIMPLEMENTED_IF(regs.clear_flags.viewport); | 465 | UNIMPLEMENTED_IF(regs.clear_flags.viewport); |
| @@ -927,7 +926,23 @@ void RasterizerOpenGL::SyncViewport() { | |||
| 927 | auto& flags = gpu.dirty.flags; | 926 | auto& flags = gpu.dirty.flags; |
| 928 | const auto& regs = gpu.regs; | 927 | const auto& regs = gpu.regs; |
| 929 | 928 | ||
| 930 | if (flags[Dirty::Viewports]) { | 929 | const bool dirty_viewport = flags[Dirty::Viewports]; |
| 930 | if (dirty_viewport || flags[Dirty::ClipControl]) { | ||
| 931 | flags[Dirty::ClipControl] = false; | ||
| 932 | |||
| 933 | bool flip_y = false; | ||
| 934 | if (regs.viewport_transform[0].scale_y < 0.0) { | ||
| 935 | flip_y = !flip_y; | ||
| 936 | } | ||
| 937 | if (regs.screen_y_control.y_negate != 0) { | ||
| 938 | flip_y = !flip_y; | ||
| 939 | } | ||
| 940 | glClipControl(flip_y ? GL_UPPER_LEFT : GL_LOWER_LEFT, | ||
| 941 | regs.depth_mode == Maxwell::DepthMode::ZeroToOne ? GL_ZERO_TO_ONE | ||
| 942 | : GL_NEGATIVE_ONE_TO_ONE); | ||
| 943 | } | ||
| 944 | |||
| 945 | if (dirty_viewport) { | ||
| 931 | flags[Dirty::Viewports] = false; | 946 | flags[Dirty::Viewports] = false; |
| 932 | 947 | ||
| 933 | const bool force = flags[Dirty::ViewportTransform]; | 948 | const bool force = flags[Dirty::ViewportTransform]; |
| @@ -948,17 +963,6 @@ void RasterizerOpenGL::SyncViewport() { | |||
| 948 | static_cast<GLdouble>(src.depth_range_far)); | 963 | static_cast<GLdouble>(src.depth_range_far)); |
| 949 | } | 964 | } |
| 950 | } | 965 | } |
| 951 | |||
| 952 | bool flip_y = false; | ||
| 953 | if (regs.viewport_transform[0].scale_y < 0.0) { | ||
| 954 | flip_y = !flip_y; | ||
| 955 | } | ||
| 956 | if (regs.screen_y_control.y_negate != 0) { | ||
| 957 | flip_y = !flip_y; | ||
| 958 | } | ||
| 959 | glClipControl(flip_y ? GL_UPPER_LEFT : GL_LOWER_LEFT, | ||
| 960 | regs.depth_mode == Maxwell::DepthMode::ZeroToOne ? GL_ZERO_TO_ONE | ||
| 961 | : GL_NEGATIVE_ONE_TO_ONE); | ||
| 962 | } | 966 | } |
| 963 | 967 | ||
| 964 | void RasterizerOpenGL::SyncDepthClamp() { | 968 | void RasterizerOpenGL::SyncDepthClamp() { |
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp index 8bb827ac5..3d64b1ea4 100644 --- a/src/video_core/renderer_opengl/gl_state_tracker.cpp +++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp | |||
| @@ -211,6 +211,12 @@ void SetupDirtyPointSize(Tables& tables) { | |||
| 211 | tables[0][OFF(point_sprite_enable)] = PointSize; | 211 | tables[0][OFF(point_sprite_enable)] = PointSize; |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | void SetupDirtyClipControl(Tables& tables) { | ||
| 215 | auto& table = tables[0]; | ||
| 216 | table[OFF(screen_y_control)] = ClipControl; | ||
| 217 | table[OFF(depth_mode)] = ClipControl; | ||
| 218 | } | ||
| 219 | |||
| 214 | void SetupDirtyMisc(Tables& tables) { | 220 | void SetupDirtyMisc(Tables& tables) { |
| 215 | auto& table = tables[0]; | 221 | auto& table = tables[0]; |
| 216 | 222 | ||
| @@ -248,6 +254,7 @@ void StateTracker::Initialize() { | |||
| 248 | SetupDirtyLogicOp(tables); | 254 | SetupDirtyLogicOp(tables); |
| 249 | SetupDirtyFragmentClampColor(tables); | 255 | SetupDirtyFragmentClampColor(tables); |
| 250 | SetupDirtyPointSize(tables); | 256 | SetupDirtyPointSize(tables); |
| 257 | SetupDirtyClipControl(tables); | ||
| 251 | SetupDirtyMisc(tables); | 258 | SetupDirtyMisc(tables); |
| 252 | 259 | ||
| 253 | auto& store = dirty.on_write_stores; | 260 | auto& store = dirty.on_write_stores; |
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.h b/src/video_core/renderer_opengl/gl_state_tracker.h index 90b17a7d6..5269dadff 100644 --- a/src/video_core/renderer_opengl/gl_state_tracker.h +++ b/src/video_core/renderer_opengl/gl_state_tracker.h | |||
| @@ -71,6 +71,7 @@ enum : u8 { | |||
| 71 | LogicOp, | 71 | LogicOp, |
| 72 | FragmentClampColor, | 72 | FragmentClampColor, |
| 73 | PointSize, | 73 | PointSize, |
| 74 | ClipControl, | ||
| 74 | 75 | ||
| 75 | Last | 76 | Last |
| 76 | }; | 77 | }; |
| @@ -167,6 +168,11 @@ public: | |||
| 167 | flags[OpenGL::Dirty::LogicOp] = true; | 168 | flags[OpenGL::Dirty::LogicOp] = true; |
| 168 | } | 169 | } |
| 169 | 170 | ||
| 171 | void NotifyClipControl() { | ||
| 172 | auto& flags = system.GPU().Maxwell3D().dirty.flags; | ||
| 173 | flags[OpenGL::Dirty::ClipControl] = true; | ||
| 174 | } | ||
| 175 | |||
| 170 | private: | 176 | private: |
| 171 | Core::System& system; | 177 | Core::System& system; |
| 172 | }; | 178 | }; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index d8a2bf9eb..4b86018d5 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -532,11 +532,9 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view, | |||
| 532 | } | 532 | } |
| 533 | // TODO(Rodrigo): Find out if rasterizer discard affects blits | 533 | // TODO(Rodrigo): Find out if rasterizer discard affects blits |
| 534 | // TODO(Rodrigo): Find out if blending affects blits | 534 | // TODO(Rodrigo): Find out if blending affects blits |
| 535 | // TODO(Rodrigo): Find out if clip control affects blits | ||
| 536 | glDisable(GL_RASTERIZER_DISCARD); | 535 | glDisable(GL_RASTERIZER_DISCARD); |
| 537 | glDisablei(GL_SCISSOR_TEST, 0); | 536 | glDisablei(GL_SCISSOR_TEST, 0); |
| 538 | glDisablei(GL_BLEND, 0); | 537 | glDisablei(GL_BLEND, 0); |
| 539 | glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); | ||
| 540 | 538 | ||
| 541 | glBindFramebuffer(GL_READ_FRAMEBUFFER, src_framebuffer.handle); | 539 | glBindFramebuffer(GL_READ_FRAMEBUFFER, src_framebuffer.handle); |
| 542 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_framebuffer.handle); | 540 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_framebuffer.handle); |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 7391412c2..7b4c2b80c 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -590,6 +590,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { | |||
| 590 | state_tracker.NotifyRasterizeEnable(); | 590 | state_tracker.NotifyRasterizeEnable(); |
| 591 | state_tracker.NotifyFramebufferSRGB(); | 591 | state_tracker.NotifyFramebufferSRGB(); |
| 592 | state_tracker.NotifyLogicOp(); | 592 | state_tracker.NotifyLogicOp(); |
| 593 | state_tracker.NotifyClipControl(); | ||
| 593 | 594 | ||
| 594 | program_manager.UseVertexShader(vertex_program.handle); | 595 | program_manager.UseVertexShader(vertex_program.handle); |
| 595 | program_manager.UseGeometryShader(0); | 596 | program_manager.UseGeometryShader(0); |