From c68802a3343cd3df78818a303512a8d6b6949ce7 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Wed, 1 Jul 2009 22:29:24 +0000 Subject: [PATCH] GSdx: dq8 fix git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1448 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSRendererDX.h | 37 ++++++++++++++++++++----------- plugins/GSdx/GSTextureCache.cpp | 7 +++--- plugins/GSdx/GSTextureCacheSW.cpp | 21 +++++++++++++++++- plugins/GSdx/GSTextureCacheSW.h | 1 + plugins/GSdx/res/tfx.fx | 10 +++++---- 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/plugins/GSdx/GSRendererDX.h b/plugins/GSdx/GSRendererDX.h index 21d416ab56..96bfe7fe40 100644 --- a/plugins/GSdx/GSRendererDX.h +++ b/plugins/GSdx/GSRendererDX.h @@ -193,21 +193,19 @@ public: GSTextureFX::PSConstantBuffer ps_cb; - ps_cb.FogColor_AREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, (int)context->TEST.AREF) / 255; + ps_cb.FogColor_AREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, 0) / 255; - if(ps_sel.atst == ATST_LESS || ps_sel.atst == ATST_GEQUAL) + switch(ps_sel.atst) { - ps_cb.FogColor_AREF.a -= 1.0f / 255; - } - else if(ps_sel.atst == ATST_LEQUAL || ps_sel.atst == ATST_GREATER) - { - // example: - // ATST = ATST_GREATER, AREF = 127 - // alpha = (int)127.0 => fail - // alpha = (int)127.5 => fail (!) - // alpha = (int)128.0 => pass - - ps_cb.FogColor_AREF.a += 1.0f / 255; + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; } if(tex) @@ -307,6 +305,19 @@ public: ps_sel.atst = iatst[ps_sel.atst]; + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } + m_tfx->UpdatePS(ps_sel, &ps_cb, ps_ssel); bool z = om_dssel.zwe; diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index deb9b85161..8786ef38b5 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -802,10 +802,11 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0) for(int i = 0; i < countof(m_pages); i++) { - if(m_pages[i]) + if(uint32 p = m_pages[i]) { + m_pages[i] = 0; + hash_map* m = &m_map[i << 5]; - uint32 p = m_pages[i]; for(int j = 0; j < 32; j++) { @@ -814,8 +815,6 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0) m[j][s] = true; } } - - m_pages[i] = 0; } } } diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 43ebaf825d..0e2aa894a6 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -25,6 +25,7 @@ GSTextureCacheSW::GSTextureCacheSW(GSState* state) : m_state(state) { + memset(m_pages, 0, sizeof(m_pages)); } GSTextureCacheSW::~GSTextureCacheSW() @@ -85,7 +86,25 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE if(page < MAX_PAGES) { - m_map[page][t] = true; + m_pages[page >> 5] |= 1 << (page & 31); + } + } + } + + for(int i = 0; i < countof(m_pages); i++) + { + if(uint32 p = m_pages[i]) + { + m_pages[i] = 0; + + hash_map* m = &m_map[i << 5]; + + for(int j = 0; j < 32; j++) + { + if(p & (1 << j)) + { + m[j][t] = true; + } } } } diff --git a/plugins/GSdx/GSTextureCacheSW.h b/plugins/GSdx/GSTextureCacheSW.h index ccb57495e4..454637770f 100644 --- a/plugins/GSdx/GSTextureCacheSW.h +++ b/plugins/GSdx/GSTextureCacheSW.h @@ -48,6 +48,7 @@ protected: GSState* m_state; hash_map m_textures; hash_map m_map[MAX_PAGES]; + uint32 m_pages[16]; public: GSTextureCacheSW(GSState* state); diff --git a/plugins/GSdx/res/tfx.fx b/plugins/GSdx/res/tfx.fx index 3550300f21..1ae604a790 100644 --- a/plugins/GSdx/res/tfx.fx +++ b/plugins/GSdx/res/tfx.fx @@ -299,25 +299,27 @@ void atst(float4 c) { if(PS_ATE == 1) { + float a = trunc(c.a * 255); + if(PS_ATST == 0) { discard; } else if(PS_ATST == 2 || PS_ATST == 3) // l, le { - clip(AREF - c.a); + clip(AREF - a); } else if(PS_ATST == 4) // e { - clip(0.6f / 255 - abs(c.a - AREF)); // FIXME: 0.5f is too small + clip(0.5f - abs(a - AREF)); } else if(PS_ATST == 5 || PS_ATST == 6) // ge, g { - clip(c.a - AREF); + clip(a - AREF); } else if(PS_ATST == 7) // ne { - clip(abs(c.a - AREF) - 0.4f / 255); // FIXME: 0.5f is too much + clip(abs(a - AREF) - 0.5f); } } }