summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-03-01 12:07:34 +0000
committerhrydgard <hrydgard@gmail.com>2009-03-01 12:07:34 +0000
commit7607d6dc6ab91daebdeac6471ee658ac63655dbc (patch)
tree3487a2850721f022ec5e02118e4e9871186b4dd5 /Source/Core/VideoCommon
parentfca8d04a113e4a3c516b7715dce62857af3a08dc (diff)
revert the mess i made in the d3d plugin. Add way to use HLSL directly without going through Cg. Not that the results look much better... i do see shadows of spinning cars in Burnout 2 after clicking around in the dark. Then it crashes.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2504 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp18
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index c13d580106..287e5a6300 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -133,7 +133,7 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 zbufrender, u3
static void WriteStage(char *&p, int n, u32 texture_mask);
static void WrapNonPow2Tex(char* &p, const char* var, int texmap, u32 texture_mask);
static void WriteAlphaCompare(char *&p, int num, int comp);
-static bool WriteAlphaTest(char *&p);
+static bool WriteAlphaTest(char *&p, bool HLSL);
static void WriteFog(char *&p, bool bOutputZ);
const float epsilon8bit = 1.0f / 255.0f;
@@ -369,7 +369,7 @@ static void BuildSwapModeTable()
}
}
-const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool bRenderZToCol0)
+const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool bRenderZToCol0, bool HLSL)
{
text[sizeof(text) - 1] = 0x7C; // canary
DVSTARTPROFILE();
@@ -516,7 +516,7 @@ const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool
//if (bpmem.genMode.numindstages ) WRITE(p, "prev.rg = indtex0.xy;\nprev.b = 0;\n");
- if (!WriteAlphaTest(p)) {
+ if (!WriteAlphaTest(p, HLSL)) {
// alpha test will always fail, so restart the shader and just make it an empty function
p = pmainstart;
WRITE(p, "discard;\n");
@@ -535,7 +535,9 @@ const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool
*/
WriteFog(p, bOutputZ);
WRITE(p, " ocol0 = prev;\n");
- }
+ } else {
+ WRITE(p, " ocol0 = prev;\n");
+ }
}
if (bRenderZ) {
@@ -889,7 +891,7 @@ static void WriteAlphaCompare(char *&p, int num, int comp)
}
}
-static bool WriteAlphaTest(char *&p)
+static bool WriteAlphaTest(char *&p, bool HLSL)
{
u32 op = bpmem.alphaFunc.logic;
u32 comp[2] = {bpmem.alphaFunc.comp0,bpmem.alphaFunc.comp1};
@@ -928,7 +930,11 @@ static bool WriteAlphaTest(char *&p)
}
// Seems we need discard for Cg and clip for d3d. sigh.
- WRITE(p, "discard( ");
+ if (HLSL)
+ WRITE(p, "clip( ");
+ else {
+ WRITE(p, "discard( ");
+ }
WriteAlphaCompare(p, 0, bpmem.alphaFunc.comp0);
// negated because testing the inverse condition
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h
index d69fd805c6..d6228f352b 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.h
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h
@@ -91,7 +91,7 @@ public:
}
};
-const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool bRenderZToCol0);
+const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool bRenderZToCol0, bool HLSL = false);
void GetPixelShaderId(PIXELSHADERUID &, u32 s_texturemask, u32 zbufrender, u32 zBufRenderToCol0);
#endif