summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/Render.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-02-26 21:01:21 +1000
committerStenzek <stenzek@gmail.com>2018-03-10 15:56:37 +1000
commitfc1fe0672bd4179a9af3ebc55b180e19cefcd65a (patch)
treeedd1d036d398d156c1ce9defa2e7825f50671f49 /Source/Core/VideoBackends/OGL/Render.cpp
parentf9c829c7f711efadea1db7aabb51c703380fa03a (diff)
OGL: Add some basic state tracking
We would want to improve the granularity here in the future, but for now, this should avoid any performance loss from switching to the VideoCommon shader cache.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index 5319e41cbd..945dbadcf1 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -1290,8 +1290,11 @@ void Renderer::SetAndClearFramebuffer(const AbstractFramebuffer* framebuffer,
glClear(clear_mask);
}
-void Renderer::ApplyBlendingState(const BlendingState& state)
+void Renderer::ApplyBlendingState(const BlendingState state, bool force)
{
+ if (!force && m_current_blend_state == state)
+ return;
+
bool useDualSource =
state.usedualsrc && g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) || state.dstalpha);
@@ -1364,6 +1367,7 @@ void Renderer::ApplyBlendingState(const BlendingState& state)
}
glColorMask(state.colorupdate, state.colorupdate, state.colorupdate, state.alphaupdate);
+ m_current_blend_state = state;
}
// This function has the final picture. We adjust the aspect ratio here.
@@ -1561,15 +1565,19 @@ void Renderer::RestoreAPIState()
glEnable(GL_CLIP_DISTANCE0);
glEnable(GL_CLIP_DISTANCE1);
}
- BPFunctions::SetGenerationMode();
BPFunctions::SetScissor();
BPFunctions::SetViewport();
- BPFunctions::SetDepthMode();
- BPFunctions::SetBlendMode();
+
+ ApplyRasterizationState(m_current_rasterization_state, true);
+ ApplyDepthState(m_current_depth_state, true);
+ ApplyBlendingState(m_current_blend_state, true);
}
-void Renderer::ApplyRasterizationState(const RasterizationState& state)
+void Renderer::ApplyRasterizationState(const RasterizationState state, bool force)
{
+ if (!force && m_current_rasterization_state == state)
+ return;
+
// none, ccw, cw, ccw
if (state.cullmode != GenMode::CULL_NONE)
{
@@ -1581,10 +1589,15 @@ void Renderer::ApplyRasterizationState(const RasterizationState& state)
{
glDisable(GL_CULL_FACE);
}
+
+ m_current_rasterization_state = state;
}
-void Renderer::ApplyDepthState(const DepthState& state)
+void Renderer::ApplyDepthState(const DepthState state, bool force)
{
+ if (!force && m_current_depth_state == state)
+ return;
+
const GLenum glCmpFuncs[8] = {GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,
GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS};
@@ -1602,6 +1615,8 @@ void Renderer::ApplyDepthState(const DepthState& state)
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
}
+
+ m_current_depth_state = state;
}
void Renderer::SetPipeline(const AbstractPipeline* pipeline)