summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2012-08-06 09:29:01 +1000
committerskidau <skidau@gmail.com>2012-08-06 09:29:01 +1000
commit0efd4e5c29766ba5f5d22204339637ade9ccec83 (patch)
tree92afd1cae763dd6029db0360dbb017bd55211ded /Source/Core/VideoCommon/Src/PixelShaderManager.cpp
parent86a1899b9e9f196e23cb87f654fbc8e6efc9e862 (diff)
Skipped the ZCompLoc pass if the result can be determined at compile time. Brings back the speed lost by r146b02615c07.
Diffstat (limited to 'Source/Core/VideoCommon/Src/PixelShaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderManager.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
index 1533f9348e..52468d0262 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
@@ -466,6 +466,39 @@ void PixelShaderManager::SetMaterialColorChanged(int index)
nMaterialsChanged |= (1 << index);
}
+ALPHA_PRETEST_RESULT PixelShaderManager::AlphaPreTest()
+{
+ u32 op = bpmem.alphaFunc.logic;
+ u32 comp[2] = {bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1};
+
+ // First kill all the simple cases
+ switch(op)
+ {
+ case 0: // AND
+ if (comp[0] == ALPHACMP_ALWAYS && comp[1] == ALPHACMP_ALWAYS) return ALPHAPT_ALWAYSPASS;
+ if (comp[0] == ALPHACMP_NEVER || comp[1] == ALPHACMP_NEVER) return ALPHAPT_ALWAYSFAIL;
+ break;
+ case 1: // OR
+ if (comp[0] == ALPHACMP_ALWAYS || comp[1] == ALPHACMP_ALWAYS) return ALPHAPT_ALWAYSPASS;
+ if (comp[0] == ALPHACMP_NEVER && comp[1] == ALPHACMP_NEVER)return ALPHAPT_ALWAYSFAIL;
+ break;
+ case 2: // XOR
+ if ((comp[0] == ALPHACMP_ALWAYS && comp[1] == ALPHACMP_NEVER) || (comp[0] == ALPHACMP_NEVER && comp[1] == ALPHACMP_ALWAYS))
+ return ALPHAPT_ALWAYSPASS;
+ if ((comp[0] == ALPHACMP_ALWAYS && comp[1] == ALPHACMP_ALWAYS) || (comp[0] == ALPHACMP_NEVER && comp[1] == ALPHACMP_NEVER))
+ return ALPHAPT_ALWAYSFAIL;
+ break;
+ case 3: // XNOR
+ if ((comp[0] == ALPHACMP_ALWAYS && comp[1] == ALPHACMP_NEVER) || (comp[0] == ALPHACMP_NEVER && comp[1] == ALPHACMP_ALWAYS))
+ return ALPHAPT_ALWAYSFAIL;
+ if ((comp[0] == ALPHACMP_ALWAYS && comp[1] == ALPHACMP_ALWAYS) || (comp[0] == ALPHACMP_NEVER && comp[1] == ALPHACMP_NEVER))
+ return ALPHAPT_ALWAYSPASS;
+ break;
+ default: PanicAlert("bad logic for alpha test? %08x", op);
+ }
+ return ALPHAPT_UNDEFINED;
+}
+
void PixelShaderManager::DoState(PointerWrap &p)
{
p.Do(lastRGBAfull);