From 0914c70b7f9d68e71779fa32c474ed896b225704 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 26 Dec 2019 01:19:15 -0300 Subject: gl_state: Remove color mask tracking --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 25 ++++++++++------------ src/video_core/renderer_opengl/gl_state.cpp | 16 -------------- src/video_core/renderer_opengl/gl_state.h | 10 --------- src/video_core/renderer_opengl/renderer_opengl.cpp | 1 + 4 files changed, 12 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d7971f86f..d0c811929 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -411,12 +411,10 @@ void RasterizerOpenGL::Clear() { use_color = true; } if (use_color) { - clear_state.color_mask[0].red_enabled = regs.clear_buffers.R ? GL_TRUE : GL_FALSE; - clear_state.color_mask[0].green_enabled = regs.clear_buffers.G ? GL_TRUE : GL_FALSE; - clear_state.color_mask[0].blue_enabled = regs.clear_buffers.B ? GL_TRUE : GL_FALSE; - clear_state.color_mask[0].alpha_enabled = regs.clear_buffers.A ? GL_TRUE : GL_FALSE; - // TODO: Signal state tracker about these changes + glColorMaski(0, regs.clear_buffers.R, regs.clear_buffers.G, regs.clear_buffers.B, + regs.clear_buffers.A); + SyncFramebufferSRGB(); // TODO(Rodrigo): Determine if clamping is used on clears SyncFragmentColorClampState(); @@ -1071,15 +1069,14 @@ void RasterizerOpenGL::SyncColorMask() { auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; - const std::size_t count = - regs.independent_blend_enable ? Tegra::Engines::Maxwell3D::Regs::NumRenderTargets : 1; - for (std::size_t i = 0; i < count; i++) { - const auto& source = regs.color_mask[regs.color_mask_common ? 0 : i]; - auto& dest = state.color_mask[i]; - dest.red_enabled = (source.R == 0) ? GL_FALSE : GL_TRUE; - dest.green_enabled = (source.G == 0) ? GL_FALSE : GL_TRUE; - dest.blue_enabled = (source.B == 0) ? GL_FALSE : GL_TRUE; - dest.alpha_enabled = (source.A == 0) ? GL_FALSE : GL_TRUE; + if (regs.color_mask_common) { + auto& mask = regs.color_mask[0]; + glColorMask(mask.R, mask.B, mask.G, mask.A); + } else { + for (std::size_t i = 0; i < Maxwell::NumRenderTargets; ++i) { + const auto& mask = regs.color_mask[regs.color_mask_common ? 0 : i]; + glColorMaski(static_cast(i), mask.R, mask.G, mask.B, mask.A); + } } } diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index f8325d6e7..bcacc5590 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -121,21 +121,6 @@ void OpenGLState::ApplyRasterizerDiscard() { Enable(GL_RASTERIZER_DISCARD, cur_state.rasterizer_discard, rasterizer_discard); } -void OpenGLState::ApplyColorMask() { - for (std::size_t i = 0; i < Maxwell::NumRenderTargets; ++i) { - const auto& updated = color_mask[i]; - auto& current = cur_state.color_mask[i]; - if (updated.red_enabled != current.red_enabled || - updated.green_enabled != current.green_enabled || - updated.blue_enabled != current.blue_enabled || - updated.alpha_enabled != current.alpha_enabled) { - current = updated; - glColorMaski(static_cast(i), updated.red_enabled, updated.green_enabled, - updated.blue_enabled, updated.alpha_enabled); - } - } -} - void OpenGLState::ApplyStencilTest() { Enable(GL_STENCIL_TEST, cur_state.stencil.test_enabled, stencil.test_enabled); @@ -311,7 +296,6 @@ void OpenGLState::Apply() { ApplyProgramPipeline(); ApplyClipDistances(); ApplyRasterizerDiscard(); - ApplyColorMask(); ApplyViewport(); ApplyStencilTest(); ApplyBlending(); diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 89eb30dfc..ccc302014 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h @@ -15,15 +15,6 @@ class OpenGLState { public: bool rasterizer_discard = false; // GL_RASTERIZER_DISCARD - struct ColorMask { - GLboolean red_enabled = GL_TRUE; - GLboolean green_enabled = GL_TRUE; - GLboolean blue_enabled = GL_TRUE; - GLboolean alpha_enabled = GL_TRUE; - }; - std::array - color_mask; // GL_COLOR_WRITEMASK - struct { bool test_enabled = false; // GL_STENCIL_TEST struct { @@ -107,7 +98,6 @@ public: void ApplyProgramPipeline(); void ApplyClipDistances(); void ApplyRasterizerDiscard(); - void ApplyColorMask(); void ApplyStencilTest(); void ApplyViewport(); void ApplyTargetBlending(std::size_t target, bool force); diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 4d41ac7b4..6dbf727ee 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -570,6 +570,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, glDisable(GL_POLYGON_OFFSET_FILL); glCullFace(GL_BACK); glFrontFace(GL_CW); + glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glVertexAttribFormat(PositionLocation, 2, GL_FLOAT, GL_FALSE, offsetof(ScreenRectVertex, position)); -- cgit v1.2.3