gsdx ogl: move ATST emulation in a dedicated function

Future commit will try to reduce the number of Alpha Test possibilities
This commit is contained in:
Gregory Hainaut 2016-06-10 21:16:39 +02:00
parent fb2182dd9b
commit 9a188a87c2
2 changed files with 37 additions and 17 deletions

View File

@ -41,6 +41,7 @@ GSRendererOGL::GSRendererOGL()
UserHacks_merge_sprite = theApp.GetConfigB("UserHacks_merge_pp_sprite"); UserHacks_merge_sprite = theApp.GetConfigB("UserHacks_merge_pp_sprite");
m_prim_overlap = PRIM_OVERLAP_UNKNOW; m_prim_overlap = PRIM_OVERLAP_UNKNOW;
m_pass1_atst = 0;
ResetStates(); ResetStates();
if (!theApp.GetConfigB("UserHacks")) { if (!theApp.GetConfigB("UserHacks")) {
@ -168,6 +169,34 @@ void GSRendererOGL::SetupIA()
dev->IASetPrimitiveTopology(t); dev->IASetPrimitiveTopology(t);
} }
void GSRendererOGL::EmulateAtst(const int pass, const GSTextureCache::Source* tex)
{
if (pass == 1) {
if (m_context->TEST.ATE)
m_pass1_atst = m_context->TEST.ATST;
else
m_pass1_atst = ATST_ALWAYS;
if (m_context->TEST.ATE && m_context->TEST.ATST > 1)
ps_cb.FogColor_AREF.a = (float)m_context->TEST.AREF;
if (tex && tex->m_spritehack_t && (m_pass1_atst == 2)) {
m_ps_sel.atst = 1;
} else {
m_ps_sel.atst = m_pass1_atst;
}
} else if (pass == 2) {
static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4};
m_ps_sel.atst = iatst[m_pass1_atst];
if (tex && tex->m_spritehack_t && (m_ps_sel.atst == 2)) {
m_ps_sel.atst = 1;
}
}
}
void GSRendererOGL::EmulateTextureShuffleAndFbmask() void GSRendererOGL::EmulateTextureShuffleAndFbmask()
{ {
if (m_texture_shuffle) { if (m_texture_shuffle) {
@ -1242,21 +1271,14 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
#endif #endif
} }
if (m_context->TEST.ATE) EmulateAtst(1, tex);
m_ps_sel.atst = m_context->TEST.ATST;
else
m_ps_sel.atst = ATST_ALWAYS;
if (m_context->TEST.ATE && m_context->TEST.ATST > 1)
ps_cb.FogColor_AREF.a = (float)m_context->TEST.AREF;
// By default don't use texture
m_ps_sel.tfx = 4;
int atst = m_ps_sel.atst;
if (tex) { if (tex) {
EmulateTextureSampler(tex); EmulateTextureSampler(tex);
} else {
m_ps_sel.tfx = 4;
} }
// Always bind the RT. This way special effect can use it. // Always bind the RT. This way special effect can use it.
dev->PSSetShaderResource(3, rt); dev->PSSetShaderResource(3, rt);
@ -1337,12 +1359,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
{ {
ASSERT(!m_env.PABE.PABE); ASSERT(!m_env.PABE.PABE);
static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4}; EmulateAtst(2, tex);
m_ps_sel.atst = iatst[atst];
if (tex && tex->m_spritehack_t && (m_ps_sel.atst == 2)) {
m_ps_sel.atst = 1;
}
dev->SetupPipeline(m_vs_sel, m_gs_sel, m_ps_sel); dev->SetupPipeline(m_vs_sel, m_gs_sel, m_ps_sel);

View File

@ -71,6 +71,8 @@ class GSRendererOGL final : public GSRendererHW
GSDeviceOGL::OMColorMaskSelector m_om_csel; GSDeviceOGL::OMColorMaskSelector m_om_csel;
GSDeviceOGL::OMDepthStencilSelector m_om_dssel; GSDeviceOGL::OMDepthStencilSelector m_om_dssel;
int m_pass1_atst;
private: private:
inline void ResetStates(); inline void ResetStates();
inline void Lines2Sprites(); inline void Lines2Sprites();
@ -79,6 +81,7 @@ class GSRendererOGL final : public GSRendererHW
inline void EmulateChannelShuffle(GSTexture** rt, const GSTextureCache::Source* tex); inline void EmulateChannelShuffle(GSTexture** rt, const GSTextureCache::Source* tex);
inline void EmulateBlending(bool DATE_GL42); inline void EmulateBlending(bool DATE_GL42);
inline void EmulateTextureSampler(const GSTextureCache::Source* tex); inline void EmulateTextureSampler(const GSTextureCache::Source* tex);
inline void EmulateAtst(const int pass, const GSTextureCache::Source* tex);
public: public:
GSRendererOGL(); GSRendererOGL();