From 0bf64fdffd47517c5a1d09c65b4944828a4f882e Mon Sep 17 00:00:00 2001 From: "sudonim1@gmail.com" Date: Wed, 13 Jun 2012 15:36:10 +0000 Subject: [PATCH] GSDX: fixed an oversight in my shader change gregory caught which removed alpha expansion for the direct sampling case, should probably fix the remaining bugs. Also set the texture sampler to point sampling when the shader will be performing its own bilinear filtering (effect on games unknown but should be an improvement). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5291 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSRendererDX.cpp | 5 +-- plugins/GSdx/res/tfx.fx | 61 ++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/plugins/GSdx/GSRendererDX.cpp b/plugins/GSdx/GSRendererDX.cpp index 9bbe1bbb86..0b0129ebbe 100644 --- a/plugins/GSdx/GSRendererDX.cpp +++ b/plugins/GSdx/GSRendererDX.cpp @@ -276,6 +276,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc if(tex) { const GSLocalMemory::psm_t &psm = GSLocalMemory::m_psm[context->TEX0.PSM]; + bool bilinear = m_filter == 2 ? m_vt.IsLinear() : m_filter; ps_sel.wms = context->CLAMP.WMS; ps_sel.wmt = context->CLAMP.WMT; @@ -289,7 +290,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc ps_sel.aem = env.TEXA.AEM; ps_sel.tfx = context->TEX0.TFX; ps_sel.tcc = context->TEX0.TCC; - ps_sel.ltf = m_filter == 2 ? m_vt.IsLinear() : m_filter; + ps_sel.ltf = bilinear && !(ps_sel.fmt <= 2 && ps_sel.wms < 3 && ps_sel.wmt < 3); ps_sel.rt = tex->m_target; ps_sel.spritehack = tex->m_spritehack_t; @@ -321,7 +322,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; - ps_ssel.ltf = ps_sel.ltf; + ps_ssel.ltf = bilinear && ps_sel.fmt <= 2 && ps_sel.wms < 3 && ps_sel.wmt < 3; } else { diff --git a/plugins/GSdx/res/tfx.fx b/plugins/GSdx/res/tfx.fx index f02b457f82..ac7c7bbc95 100644 --- a/plugins/GSdx/res/tfx.fx +++ b/plugins/GSdx/res/tfx.fx @@ -356,23 +356,25 @@ float4 sample(float2 st, float q) { st /= q; } - + float4 t; + float4x4 c; + float2 dd; + /* if(PS_FMT <= FMT_16 && PS_WMS < 2 && PS_WMT < 2) { - t = sample_c(st); + c[0] = sample_c(st); } */ if(PS_FMT <= FMT_16 && PS_WMS < 3 && PS_WMT < 3) { - t = sample_c(clampuv(st)); + c[0] = sample_c(clampuv(st)); } else { float4 uv; - float2 dd; - + if(PS_LTF) { uv = st.xyxy + HalfTexel; @@ -382,10 +384,8 @@ float4 sample(float2 st, float q) { uv = st.xyxy; } - - uv = wrapuv(uv); - float4x4 c; + uv = wrapuv(uv); if(PS_FMT & FMT_PAL) { @@ -395,33 +395,34 @@ float4 sample(float2 st, float q) { c = sample_4c(uv); } + } - for (uint i = 0; i < 4; i++) + [unroll] + for (uint i = 0; i < 4; i++) + { + if((PS_FMT & ~FMT_PAL) == FMT_32) { - if((PS_FMT & ~FMT_PAL) == FMT_32) - { - #if SHADER_MODEL <= 0x300 - if(PS_RT) c[i].a *= 128.0f / 255; - #endif - } - else if((PS_FMT & ~FMT_PAL) == FMT_24) - { - c[i].a = !PS_AEM || any(c[i].rgb) ? TA.x : 0; - } - else if((PS_FMT & ~FMT_PAL) == FMT_16) - { - c[i].a = c[i].a >= 0.5 ? TA.y : !PS_AEM || any(c[i].rgb) ? TA.x : 0; - } + #if SHADER_MODEL <= 0x300 + if(PS_RT) c[i].a *= 128.0f / 255; + #endif } - - if(PS_LTF) - { - t = lerp(lerp(c[0], c[1], dd.x), lerp(c[2], c[3], dd.x), dd.y); - } - else + else if((PS_FMT & ~FMT_PAL) == FMT_24) { - t = c[0]; + c[i].a = !PS_AEM || any(c[i].rgb) ? TA.x : 0; } + else if((PS_FMT & ~FMT_PAL) == FMT_16) + { + c[i].a = c[i].a >= 0.5 ? TA.y : !PS_AEM || any(c[i].rgb) ? TA.x : 0; + } + } + + if(PS_LTF) + { + t = lerp(lerp(c[0], c[1], dd.x), lerp(c[2], c[3], dd.x), dd.y); + } + else + { + t = c[0]; } return t;