summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
diff options
context:
space:
mode:
authordonkopunchstania <donkopunchstania@gmail.com>2009-03-16 02:47:48 +0000
committerdonkopunchstania <donkopunchstania@gmail.com>2009-03-16 02:47:48 +0000
commit90254bd924949bd68db28ce3aa7186b626e27b30 (patch)
tree771184326606a6d4e74d6fb21dfa362e0aa0e897 /Source/Core/VideoCommon/Src/PixelShaderGen.cpp
parentb1b2868c8b22553eb6583dc80fa14906fb3e8466 (diff)
Change destination alpha handling. The blending method introduced in rev 1921 was not the correct way to do it. This way was suggested by hrydgard in October and I should have listened. A simple pixel shader as hrydgard suggested cannot be used because the alpha is not set if the pixel is discarded due to failing depth (after z texture) or alpha (result of tev stages) tests. There is a bit of a performance hit so there should be an option to disable the second render pass which sets the alpha because it is probably not needed most of the time.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2662 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index d57b4fabb5..60fef26895 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -26,7 +26,7 @@
// Mash together all the inputs that contribute to the code of a generated pixel shader into
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
-void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 zbufrender, u32 zBufRenderToCol0)
+void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 zbufrender, u32 zBufRenderToCol0, u32 dstAlphaEnable)
{
u32 projtexcoords = 0;
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) {
@@ -39,7 +39,7 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 zbufrender, u3
uid.values[0] = (u32)bpmem.genMode.numtevstages |
((u32)bpmem.genMode.numindstages << 4) |
((u32)bpmem.genMode.numtexgens << 7) |
- ((u32)bpmem.dstalpha.enable << 11) |
+ ((u32)dstAlphaEnable << 11) |
((u32)((bpmem.alphaFunc.hex >> 16) & 0xff) << 12) |
(projtexcoords << 20) |
((u32)bpmem.ztex2.op << 28) |
@@ -369,7 +369,7 @@ static void BuildSwapModeTable()
}
}
-const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool bRenderZToCol0, bool HLSL)
+const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool bRenderZToCol0, bool dstAlphaEnable, bool HLSL)
{
text[sizeof(text) - 1] = 0x7C; // canary
DVSTARTPROFILE();
@@ -535,17 +535,12 @@ const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool
}
else {
if (!bRenderZToCol0) {
- /* donkopunchstania: NEEDS FIX - dstalpha does not change how fragments are blended with the EFB
- once the blending is done, the dstalpha is written to the EFB in place of the
- fragment alpha if dstalpha is enabled. this only matters if the EFB supports alpha.
- Commenting this out fixed Metroids but causes glitches in Super Mario Sunshine.
-
- if (bpmem.dstalpha.enable)
+ if (dstAlphaEnable) {
WRITE(p, " ocol0 = float4(prev.rgb,"I_ALPHA"[0].w);\n");
- else
- */
- WriteFog(p, bOutputZ);
- WRITE(p, " ocol0 = prev;\n");
+ } else {
+ WriteFog(p, bOutputZ);
+ WRITE(p, " ocol0 = prev;\n");
+ }
} else {
WRITE(p, " ocol0 = prev;\n");
}