From 1addae1993c47818df46720eaabf36d8d596ddc9 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 8 May 2015 10:57:21 +0200 Subject: [PATCH] gsdx-ogl: don't use extra shader for sprite hack Atst == 2 && sprite_hack is equivalent to Atst == 1 It frees a bit in the shader selector, and reduces shader combinations. --- plugins/GSdx/GSDeviceOGL.cpp | 1 - plugins/GSdx/GSDeviceOGL.h | 5 ++--- plugins/GSdx/GSRendererOGL.cpp | 13 +++++++++++-- plugins/GSdx/res/glsl/tfx_fs.glsl | 2 +- plugins/GSdx/res/glsl_source.h | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index d0dffb4231..f19df34409 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -626,7 +626,6 @@ GLuint GSDeviceOGL::CompilePS(PSSelector sel) + format("#define PS_LTF %d\n", sel.ltf) + format("#define PS_COLCLIP %d\n", sel.colclip) + format("#define PS_DATE %d\n", sel.date) - + format("#define PS_SPRITEHACK %d\n", sel.spritehack) + format("#define PS_TCOFFSETHACK %d\n", sel.tcoffsethack) //+ format("#define PS_POINT_SAMPLER %d\n", sel.point_sampler) + format("#define PS_IIP %d\n", sel.iip) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 8f41c22589..69f634c2ac 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -305,7 +305,6 @@ class GSDeviceOGL : public GSDevice uint32 fba:1; uint32 aout:1; uint32 date:3; - uint32 spritehack:1; uint32 tcoffsethack:1; //uint32 point_sampler:1; Not tested, so keep the bit for blend uint32 iip:1; @@ -319,14 +318,14 @@ class GSDeviceOGL : public GSDevice uint32 wmt:2; uint32 ltf:1; - uint32 _free:3; + uint32 _free:4; }; uint32 key; }; // FIXME is the & useful ? - operator uint32() {return key & 0x1fffffff;} + operator uint32() {return key & 0x0fffffff;} PSSelector() : key(0) {} }; diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 69b297fd8a..b57ceca219 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -447,6 +447,8 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour // By default don't use texture ps_sel.tfx = 4; + bool spritehack = false; + int atst = ps_sel.atst; if(tex) { @@ -464,7 +466,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour ps_sel.tfx = context->TEX0.TFX; ps_sel.tcc = context->TEX0.TCC; ps_sel.ltf = bilinear && !simple_sample; - ps_sel.spritehack = tex->m_spritehack_t; + spritehack = tex->m_spritehack_t; // FIXME the ati is currently disabled on the shader. I need to find a .gs to test that we got same // bug on opengl // FIXME for the moment disable it on subroutine (it will kill my perf for nothings) @@ -518,6 +520,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour dev->PSSetShaderResource(0, tex->m_texture); } } + + if (spritehack && (ps_sel.atst == 2)) { + ps_sel.atst = 1; + } } // WARNING: setup of the program must be done first. So you can setup @@ -603,7 +609,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; - ps_sel.atst = iatst[ps_sel.atst]; + ps_sel.atst = iatst[atst]; + if (spritehack && (ps_sel.atst == 2)) { + ps_sel.atst = 1; + } dev->SetupPS(ps_sel); diff --git a/plugins/GSdx/res/glsl/tfx_fs.glsl b/plugins/GSdx/res/glsl/tfx_fs.glsl index cb51f40165..5fe38025a6 100644 --- a/plugins/GSdx/res/glsl/tfx_fs.glsl +++ b/plugins/GSdx/res/glsl/tfx_fs.glsl @@ -325,7 +325,7 @@ void atst(vec4 c) discard; #elif (PS_ATST == 1) // always // nothing to do -#elif (PS_ATST == 2) && (PS_SPRITEHACK == 0) // l +#elif (PS_ATST == 2) // l if ((AREF - a - 0.5f) < 0.0f) discard; #elif (PS_ATST == 3 ) // le diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index f490f25342..4e4ec35a3b 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -1046,7 +1046,7 @@ static const char* tfx_fs_all_glsl = " discard;\n" "#elif (PS_ATST == 1) // always\n" " // nothing to do\n" - "#elif (PS_ATST == 2) && (PS_SPRITEHACK == 0) // l\n" + "#elif (PS_ATST == 2) // l\n" " if ((AREF - a - 0.5f) < 0.0f)\n" " discard;\n" "#elif (PS_ATST == 3 ) // le\n"