From c2719feda2acabdb4df241590f15e2733c6aad69 Mon Sep 17 00:00:00 2001 From: wwylele Date: Tue, 3 Apr 2018 09:00:06 +0300 Subject: [PATCH 1/2] gl_rasterizer: move shader uniform sync from SetShader() to ctor --- .../renderer_opengl/gl_rasterizer.cpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 6965f244c6..ecae102d20 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -176,7 +176,6 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { // Sync fixed function OpenGL state SyncClipEnabled(); - SyncClipCoef(); SyncCullMode(); SyncBlendEnabled(); SyncBlendFuncs(); @@ -187,6 +186,30 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { SyncColorWriteMask(); SyncStencilWriteMask(); SyncDepthWriteMask(); + + // Sync uniforms + SyncClipCoef(); + SyncDepthScale(); + SyncDepthOffset(); + SyncAlphaTest(); + SyncCombinerColor(); + auto& tev_stages = Pica::g_state.regs.texturing.GetTevStages(); + for (std::size_t index = 0; index < tev_stages.size(); ++index) + SyncTevConstColor(index, tev_stages[index]); + + SyncGlobalAmbient(); + for (unsigned light_index = 0; light_index < 8; light_index++) { + SyncLightSpecular0(light_index); + SyncLightSpecular1(light_index); + SyncLightDiffuse(light_index); + SyncLightAmbient(light_index); + SyncLightPosition(light_index); + SyncLightDistanceAttenuationBias(light_index); + SyncLightDistanceAttenuationScale(light_index); + } + + SyncFogColor(); + SyncProcTexNoise(); } RasterizerOpenGL::~RasterizerOpenGL() {} @@ -1284,29 +1307,6 @@ void RasterizerOpenGL::SetShader() { "Uniform block size did not match! Got %d, expected %zu", static_cast(block_size), sizeof(UniformData)); glUniformBlockBinding(current_shader->shader.handle, block_index, 0); - - // Update uniforms - SyncDepthScale(); - SyncDepthOffset(); - SyncAlphaTest(); - SyncCombinerColor(); - auto& tev_stages = Pica::g_state.regs.texturing.GetTevStages(); - for (int index = 0; index < tev_stages.size(); ++index) - SyncTevConstColor(index, tev_stages[index]); - - SyncGlobalAmbient(); - for (int light_index = 0; light_index < 8; light_index++) { - SyncLightSpecular0(light_index); - SyncLightSpecular1(light_index); - SyncLightDiffuse(light_index); - SyncLightAmbient(light_index); - SyncLightPosition(light_index); - SyncLightDistanceAttenuationBias(light_index); - SyncLightDistanceAttenuationScale(light_index); - } - - SyncFogColor(); - SyncProcTexNoise(); } } } From 0d84c5a0b69a42bbfc76fa5835edeff33820fdf6 Mon Sep 17 00:00:00 2001 From: wwylele Date: Wed, 4 Apr 2018 17:23:55 +0300 Subject: [PATCH 2/2] gl_rasterizer: move state syncing from ctor to its own function --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 ++++++-- src/video_core/renderer_opengl/gl_rasterizer.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index ecae102d20..898e32bc01 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -174,6 +174,12 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { glEnable(GL_BLEND); + SyncEntireState(); +} + +RasterizerOpenGL::~RasterizerOpenGL() {} + +void RasterizerOpenGL::SyncEntireState() { // Sync fixed function OpenGL state SyncClipEnabled(); SyncCullMode(); @@ -212,8 +218,6 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { SyncProcTexNoise(); } -RasterizerOpenGL::~RasterizerOpenGL() {} - /** * This is a helper function to resolve an issue when interpolating opposite quaternions. See below * for a detailed description of this issue (yuriks): diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 5db9b6b7ad..b347c90b84 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -162,6 +162,9 @@ private: static_assert(sizeof(UniformData) < 16384, "UniformData structure must be less than 16kb as per the OpenGL spec"); + /// Syncs entire status to match PICA registers + void SyncEntireState(); + /// Syncs the clip enabled status to match the PICA register void SyncClipEnabled();