summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordonkopunchstania <donkopunchstania@gmail.com>2009-03-05 05:10:25 +0000
committerdonkopunchstania <donkopunchstania@gmail.com>2009-03-05 05:10:25 +0000
commitcb121dab6696bf31a85d80dc824c0a390bb8ef79 (patch)
tree64dce3a84259f3d8e5fd84ef820e668c8909ac13 /Source/Core/VideoCommon
parent0b6bf51c9a3620e207ce6482736dd9a58442c38a (diff)
Fix more cases where shader compilation can fail if there are no tex gens.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2556 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index 287e5a6300..23a1d57aca 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -476,21 +476,32 @@ const char *GeneratePixelShader(u32 texture_mask, bool has_zbuffer_target, bool
// note that we have to scale by the regular texture map's coordinates since this is a texRECT call
// (and we have to match with the game's texscale calls)
int texcoord = bpmem.tevindref.getTexCoord(i);
- if (texture_mask & (1<<bpmem.tevindref.getTexMap(i))) {
- // TODO: I removed a superfluous argument, please check that the resulting expression is correct. (mthuurne 2008-08-27)
- WRITE(p, "float2 induv%d=uv%d.xy * "I_INDTEXSCALE"[%d].%s;\n", i, texcoord, i/2, (i&1)?"zw":"xy"); //, bpmem.tevindref.getTexMap(i)
- char str[16];
- sprintf(str, "induv%d", i);
- WrapNonPow2Tex(p, str, bpmem.tevindref.getTexMap(i), texture_mask);
- WRITE(p, "float3 indtex%d=texRECT(samp%d,induv%d.xy).abg;\n", i, bpmem.tevindref.getTexMap(i), i);
+ if (texcoord < numTexgen) {
+ if (texture_mask & (1<<bpmem.tevindref.getTexMap(i))) {
+ // TODO: I removed a superfluous argument, please check that the resulting expression is correct. (mthuurne 2008-08-27)
+ WRITE(p, "float2 induv%d=uv%d.xy * "I_INDTEXSCALE"[%d].%s;\n", i, texcoord, i/2, (i&1)?"zw":"xy"); //, bpmem.tevindref.getTexMap(i)
+
+ char str[16];
+ sprintf(str, "induv%d", i);
+ WrapNonPow2Tex(p, str, bpmem.tevindref.getTexMap(i), texture_mask);
+ WRITE(p, "float3 indtex%d=texRECT(samp%d,induv%d.xy).abg;\n", i, bpmem.tevindref.getTexMap(i), i);
+ }
+ else {
+ WRITE(p, "float3 indtex%d=tex2D(samp%d,uv%d.xy*"I_INDTEXSCALE"[%d].%s).abg;\n", i, bpmem.tevindref.getTexMap(i), texcoord, i/2, (i&1)?"zw":"xy");
+ }
}
else {
- WRITE(p, "float3 indtex%d=tex2D(samp%d,uv%d.xy*"I_INDTEXSCALE"[%d].%s).abg;\n", i, bpmem.tevindref.getTexMap(i), texcoord, i/2, (i&1)?"zw":"xy");
+ WRITE(p, "float3 indtex%d=tex2D(samp%d,float2(0.0f,0.0f));\n", i, bpmem.tevindref.getTexMap(i));
}
}
}
+ // HACK to handle cases where the tex gen is not enabled
+ if (numTexgen == 0) {
+ WRITE(p, "float3 uv0 = float3(0.0f,0.0f,0.0f);\n");
+ }
+
for (int i = 0; i < numStages; i++)
WriteStage(p, i, texture_mask); //build the equation for this stage
@@ -570,8 +581,14 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
int texcoord = bpmem.tevorders[n/2].getTexCoord(n&1);
int texfun = xfregs.texcoords[texcoord].texmtxinfo.projection;
+ bool bHasTexCoord = texcoord < bpmem.genMode.numtexgens;
bool bHasIndStage = bpmem.tevind[n].IsActive() && bpmem.tevind[n].bt < bpmem.genMode.numindstages;
+ // HACK to handle cases where the tex gen is not enabled
+ if (!bHasTexCoord) {
+ texcoord = 0;
+ }
+
if (bHasIndStage) {
// perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords
bHasIndStage = true;
@@ -610,11 +627,11 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n",
n, mtxidx, n, mtxidx+1, n);
}
- else if (bpmem.tevind[n].mid <= 5) { // s matrix
+ else if (bpmem.tevind[n].mid <= 5 && bHasTexCoord) { // s matrix
int mtxidx = 2*(bpmem.tevind[n].mid-5);
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n);
}
- else if (bpmem.tevind[n].mid <= 9) { // t matrix
+ else if (bpmem.tevind[n].mid <= 9 && bHasTexCoord) { // t matrix
int mtxidx = 2*(bpmem.tevind[n].mid-9);
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
}
@@ -714,7 +731,7 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
if(!bHasIndStage) {
// calc tevcord
//tevcoord.xy = texdim[1].xy * uv1.xy / uv1.z;
- if(bpmem.genMode.numtexgens) {
+ if(bHasTexCoord) {
if (texture_mask & (1<<texmap)) {
// nonpow2
if (texfun == XF_TEXPROJ_STQ )