diff options
author | Rodolfo Bogado <rodolfoosvaldobogado@gmail.com> | 2018-11-05 03:46:06 +0100 |
---|---|---|
committer | Rodolfo Bogado <rodolfoosvaldobogado@gmail.com> | 2018-11-05 04:24:19 +0100 |
commit | 19038db4898bc059fe78d21ba9a400b5277dd2dd (patch) | |
tree | 78ff28c93f700da54a7d452ae82dfa4714cab3c7 /src/video_core/renderer_opengl/gl_state.cpp | |
parent | Implement multi-target viewports and blending (diff) | |
download | yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.tar yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.tar.gz yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.tar.bz2 yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.tar.lz yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.tar.xz yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.tar.zst yuzu-19038db4898bc059fe78d21ba9a400b5277dd2dd.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 2e1f81e26..9517285e5 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -25,12 +25,12 @@ OpenGLState::OpenGLState() { primitive_restart.enabled = false; primitive_restart.index = 0; - - color_mask.red_enabled = GL_TRUE; - color_mask.green_enabled = GL_TRUE; - color_mask.blue_enabled = GL_TRUE; - color_mask.alpha_enabled = GL_TRUE; - + for (auto& item : color_mask) { + item.red_enabled = GL_TRUE; + item.green_enabled = GL_TRUE; + item.blue_enabled = GL_TRUE; + item.alpha_enabled = GL_TRUE; + } stencil.test_enabled = false; auto reset_stencil = [](auto& config) { config.test_func = GL_ALWAYS; @@ -135,6 +135,32 @@ void OpenGLState::ApplyCulling() const { } } +void OpenGLState::ApplyColorMask() const { + if (GLAD_GL_ARB_viewport_array) { + for (size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) { + const auto& updated = color_mask[i]; + const 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) { + glColorMaski(static_cast<GLuint>(i), updated.red_enabled, updated.green_enabled, + updated.blue_enabled, updated.alpha_enabled); + } + } + } else { + const auto& updated = color_mask[0]; + const auto& current = cur_state.color_mask[0]; + 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) { + glColorMask(updated.red_enabled, updated.green_enabled, updated.blue_enabled, + updated.alpha_enabled); + } + } +} + void OpenGLState::ApplyDepth() const { // Depth test const bool depth_test_changed = depth.test_enabled != cur_state.depth.test_enabled; @@ -444,18 +470,11 @@ void OpenGLState::Apply() const { } } } - // Color mask - if (color_mask.red_enabled != cur_state.color_mask.red_enabled || - color_mask.green_enabled != cur_state.color_mask.green_enabled || - color_mask.blue_enabled != cur_state.color_mask.blue_enabled || - color_mask.alpha_enabled != cur_state.color_mask.alpha_enabled) { - glColorMask(color_mask.red_enabled, color_mask.green_enabled, color_mask.blue_enabled, - color_mask.alpha_enabled); - } // Point if (point.size != cur_state.point.size) { glPointSize(point.size); } + ApplyColorMask(); ApplyViewport(); ApplyScissor(); ApplyStencilTest(); |