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.
This commit is contained in:
Gregory Hainaut 2015-05-08 10:57:21 +02:00
parent b490085214
commit 1addae1993
5 changed files with 15 additions and 8 deletions

View File

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

View File

@ -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) {}
};

View File

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

View File

@ -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

View File

@ -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"