From 7979dec5b089ef7435f344c7d3eead521efe1f3c Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 17 May 2015 13:00:28 +0200 Subject: [PATCH] gsdx-ogl: optimize colclip 0 Currently colclip uses 2 passes to wrap the output of blending unit However some blending mode are only a plain copy (of 0 or Cs or Cd). So no overflow of [0:255], no need to wrap it Note: I saw those cases in GoW. --- plugins/GSdx/GSRendererOGL.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index d3eddb7840..ecef2e203c 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -428,9 +428,21 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour om_dssel.date = 1; } - if(env.COLCLAMP.CLAMP == 0 && /* hack */ !tex && PRIM->PRIM != GS_POINTLIST) + bool colclip_wrap = env.COLCLAMP.CLAMP == 0 && !tex && PRIM->PRIM != GS_POINTLIST; + if(colclip_wrap) { - ps_sel.colclip = 1; +#ifdef ENABLE_OGL_DEBUG + const char *col[3] = {"Cs", "Cd", "0"}; +#endif + if (context->ALPHA.A == context->ALPHA.B) { + // No addition neither substraction so no risk of overflow the [0:255] range. + GL_INS("Disable COLCLIP wrap: blending is a plain copy of %s", col[context->ALPHA.D]); + colclip_wrap = false; + } else { + GL_INS("Enable COLCLIP wrap (blending is %d/%d/%d/%d)", + context->ALPHA.A, context->ALPHA.B, context->ALPHA.C, context->ALPHA.D); + ps_sel.colclip = 1; + } } ps_sel.clr1 = om_bsel.IsCLR1(); @@ -626,7 +638,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour { SendDraw(require_barrier); - if (env.COLCLAMP.CLAMP == 0 && !tex && PRIM->PRIM != GS_POINTLIST) + if (colclip_wrap) { ASSERT(bogus_blend <= 2); GL_PUSH("COLCLIP"); @@ -686,7 +698,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour SendDraw(require_barrier); - if (env.COLCLAMP.CLAMP == 0 && !tex && PRIM->PRIM != GS_POINTLIST) + if (colclip_wrap) { ASSERT(bogus_blend <= 2); GL_PUSH("COLCLIP");