Merge pull request #3624 from wwylele/sync-uniform

gl_rasterizer: move shader uniform sync from SetShader() to ctor
This commit is contained in:
James Rowe 2018-04-05 00:30:38 -06:00 committed by GitHub
commit 1fecead2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 26 deletions

View File

@ -174,9 +174,14 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
glEnable(GL_BLEND);
SyncEntireState();
}
RasterizerOpenGL::~RasterizerOpenGL() {}
void RasterizerOpenGL::SyncEntireState() {
// Sync fixed function OpenGL state
SyncClipEnabled();
SyncClipCoef();
SyncCullMode();
SyncBlendEnabled();
SyncBlendFuncs();
@ -187,9 +192,31 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
SyncColorWriteMask();
SyncStencilWriteMask();
SyncDepthWriteMask();
}
RasterizerOpenGL::~RasterizerOpenGL() {}
// 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();
}
/**
* This is a helper function to resolve an issue when interpolating opposite quaternions. See below
@ -1284,29 +1311,6 @@ void RasterizerOpenGL::SetShader() {
"Uniform block size did not match! Got %d, expected %zu",
static_cast<int>(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();
}
}
}

View File

@ -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();