diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-12-29 06:03:05 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-02-28 21:56:42 +0100 |
commit | f7ec078592468fa22ff377b996a720c8be82c2dc (patch) | |
tree | 9326105d022b9e939f036c46d028f7f7ef8f9e5e /src/video_core/renderer_opengl/gl_rasterizer.cpp | |
parent | gl_state_tracker: Add dirty flags for buffers and divisors (diff) | |
download | yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.tar yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.tar.gz yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.tar.bz2 yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.tar.lz yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.tar.xz yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.tar.zst yuzu-f7ec078592468fa22ff377b996a720c8be82c2dc.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index bb89985cc..717f127e9 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -232,8 +232,7 @@ GLintptr RasterizerOpenGL::SetupIndexBuffer() { void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { MICROPROFILE_SCOPE(OpenGL_Shader); auto& gpu = system.GPU().Maxwell3D(); - - std::array<bool, Maxwell::NumClipDistances> clip_distances{}; + u32 clip_distances = 0; for (std::size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) { const auto& shader_config = gpu.regs.shader_config[index]; @@ -294,9 +293,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { // When a clip distance is enabled but not set in the shader it crops parts of the screen // (sometimes it's half the screen, sometimes three quarters). To avoid this, enable the // clip distances only when it's written by a shader stage. - for (std::size_t i = 0; i < Maxwell::NumClipDistances; ++i) { - clip_distances[i] = clip_distances[i] || shader->GetShaderEntries().clip_distances[i]; - } + clip_distances |= shader->GetShaderEntries().clip_distances; // When VertexA is enabled, we have dual vertex shaders if (program == Maxwell::ShaderProgram::VertexA) { @@ -306,6 +303,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { } SyncClipEnabled(clip_distances); + gpu.dirty.flags[Dirty::Shaders] = false; } std::size_t RasterizerOpenGL::CalculateVertexArraysSize() const { @@ -972,12 +970,22 @@ void RasterizerOpenGL::SyncDepthClamp() { oglEnable(GL_DEPTH_CLAMP, state.depth_clamp_far || state.depth_clamp_near); } -void RasterizerOpenGL::SyncClipEnabled( - const std::array<bool, Maxwell::Regs::NumClipDistances>& clip_mask) { - const auto& regs = system.GPU().Maxwell3D().regs; +void RasterizerOpenGL::SyncClipEnabled(u32 clip_mask) { + auto& gpu = system.GPU().Maxwell3D(); + auto& flags = gpu.dirty.flags; + if (!flags[Dirty::ClipDistances] && !flags[Dirty::Shaders]) { + return; + } + flags[Dirty::ClipDistances] = false; + + clip_mask &= gpu.regs.clip_distance_enabled; + if (clip_mask == last_clip_distance_mask) { + return; + } + last_clip_distance_mask = clip_mask; + for (std::size_t i = 0; i < Maxwell::Regs::NumClipDistances; ++i) { - oglEnable(static_cast<GLenum>(GL_CLIP_DISTANCE0 + i), - clip_mask[i] && ((regs.clip_distance_enabled >> i) & 1)); + oglEnable(static_cast<GLenum>(GL_CLIP_DISTANCE0 + i), (clip_mask >> i) & 1); } } |