mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-29 02:22:37 -06:00
OpenGL: Only update depth uniforms if the depth changed
This commit is contained in:
parent
f8a11a664f
commit
5389dedfa1
2 changed files with 22 additions and 9 deletions
|
@ -104,7 +104,6 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
|
||||||
|
|
||||||
// Sync fixed function OpenGL state
|
// Sync fixed function OpenGL state
|
||||||
SyncCullMode();
|
SyncCullMode();
|
||||||
SyncDepthModifiers();
|
|
||||||
SyncBlendEnabled();
|
SyncBlendEnabled();
|
||||||
SyncBlendFuncs();
|
SyncBlendFuncs();
|
||||||
SyncBlendColor();
|
SyncBlendColor();
|
||||||
|
@ -259,8 +258,10 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) {
|
||||||
|
|
||||||
// Depth modifiers
|
// Depth modifiers
|
||||||
case PICA_REG_INDEX(viewport_depth_range):
|
case PICA_REG_INDEX(viewport_depth_range):
|
||||||
|
SyncDepthScale();
|
||||||
|
break;
|
||||||
case PICA_REG_INDEX(viewport_depth_near_plane):
|
case PICA_REG_INDEX(viewport_depth_near_plane):
|
||||||
SyncDepthModifiers();
|
SyncDepthOffset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Depth buffering
|
// Depth buffering
|
||||||
|
@ -880,6 +881,8 @@ void RasterizerOpenGL::SetShader() {
|
||||||
glUniformBlockBinding(current_shader->shader.handle, block_index, 0);
|
glUniformBlockBinding(current_shader->shader.handle, block_index, 0);
|
||||||
|
|
||||||
// Update uniforms
|
// Update uniforms
|
||||||
|
SyncDepthScale();
|
||||||
|
SyncDepthOffset();
|
||||||
SyncAlphaTest();
|
SyncAlphaTest();
|
||||||
SyncCombinerColor();
|
SyncCombinerColor();
|
||||||
auto& tev_stages = Pica::g_state.regs.GetTevStages();
|
auto& tev_stages = Pica::g_state.regs.GetTevStages();
|
||||||
|
@ -922,13 +925,20 @@ void RasterizerOpenGL::SyncCullMode() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncDepthModifiers() {
|
void RasterizerOpenGL::SyncDepthScale() {
|
||||||
float depth_scale = Pica::float24::FromRaw(Pica::g_state.regs.viewport_depth_range).ToFloat32();
|
float depth_scale = Pica::float24::FromRaw(Pica::g_state.regs.viewport_depth_range).ToFloat32();
|
||||||
float depth_offset = Pica::float24::FromRaw(Pica::g_state.regs.viewport_depth_near_plane).ToFloat32();
|
if (depth_scale != uniform_block_data.data.depth_scale) {
|
||||||
|
uniform_block_data.data.depth_scale = depth_scale;
|
||||||
|
uniform_block_data.dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uniform_block_data.data.depth_scale = depth_scale;
|
void RasterizerOpenGL::SyncDepthOffset() {
|
||||||
uniform_block_data.data.depth_offset = depth_offset;
|
float depth_offset = Pica::float24::FromRaw(Pica::g_state.regs.viewport_depth_near_plane).ToFloat32();
|
||||||
uniform_block_data.dirty = true;
|
if (depth_offset != uniform_block_data.data.depth_offset) {
|
||||||
|
uniform_block_data.data.depth_offset = depth_offset;
|
||||||
|
uniform_block_data.dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncBlendEnabled() {
|
void RasterizerOpenGL::SyncBlendEnabled() {
|
||||||
|
|
|
@ -339,8 +339,11 @@ private:
|
||||||
/// Syncs the cull mode to match the PICA register
|
/// Syncs the cull mode to match the PICA register
|
||||||
void SyncCullMode();
|
void SyncCullMode();
|
||||||
|
|
||||||
/// Syncs the depth scale and offset to match the PICA registers
|
/// Syncs the depth scale to match the PICA register
|
||||||
void SyncDepthModifiers();
|
void SyncDepthScale();
|
||||||
|
|
||||||
|
/// Syncs the depth offset to match the PICA register
|
||||||
|
void SyncDepthOffset();
|
||||||
|
|
||||||
/// Syncs the blend enabled status to match the PICA register
|
/// Syncs the blend enabled status to match the PICA register
|
||||||
void SyncBlendEnabled();
|
void SyncBlendEnabled();
|
||||||
|
|
Loading…
Reference in a new issue