mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Fix compilation with g++ 4.7 and some warnings. Fixes issue 5347.
This commit is contained in:
@ -556,22 +556,22 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
|
||||
WRITE(p, "\n");
|
||||
|
||||
WRITE(p, "uniform float4 "I_COLORS"[4] : register(c%d);\n", C_COLORS);
|
||||
WRITE(p, "uniform float4 "I_KCOLORS"[4] : register(c%d);\n", C_KCOLORS);
|
||||
WRITE(p, "uniform float4 "I_ALPHA"[1] : register(c%d);\n", C_ALPHA);
|
||||
WRITE(p, "uniform float4 "I_TEXDIMS"[8] : register(c%d);\n", C_TEXDIMS);
|
||||
WRITE(p, "uniform float4 "I_ZBIAS"[2] : register(c%d);\n", C_ZBIAS);
|
||||
WRITE(p, "uniform float4 "I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE);
|
||||
WRITE(p, "uniform float4 "I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX);
|
||||
WRITE(p, "uniform float4 "I_FOG"[3] : register(c%d);\n", C_FOG);
|
||||
WRITE(p, "uniform float4 " I_COLORS"[4] : register(c%d);\n", C_COLORS);
|
||||
WRITE(p, "uniform float4 " I_KCOLORS"[4] : register(c%d);\n", C_KCOLORS);
|
||||
WRITE(p, "uniform float4 " I_ALPHA"[1] : register(c%d);\n", C_ALPHA);
|
||||
WRITE(p, "uniform float4 " I_TEXDIMS"[8] : register(c%d);\n", C_TEXDIMS);
|
||||
WRITE(p, "uniform float4 " I_ZBIAS"[2] : register(c%d);\n", C_ZBIAS);
|
||||
WRITE(p, "uniform float4 " I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE);
|
||||
WRITE(p, "uniform float4 " I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX);
|
||||
WRITE(p, "uniform float4 " I_FOG"[3] : register(c%d);\n", C_FOG);
|
||||
|
||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
{
|
||||
WRITE(p,"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n");
|
||||
WRITE(p,"typedef struct { Light lights[8]; } s_"I_PLIGHTS";\n");
|
||||
WRITE(p, "uniform s_"I_PLIGHTS" "I_PLIGHTS" : register(c%d);\n", C_PLIGHTS);
|
||||
WRITE(p, "typedef struct { float4 C0, C1, C2, C3; } s_"I_PMATERIALS";\n");
|
||||
WRITE(p, "uniform s_"I_PMATERIALS" "I_PMATERIALS" : register(c%d);\n", C_PMATERIALS);
|
||||
WRITE(p,"typedef struct { Light lights[8]; } s_" I_PLIGHTS";\n");
|
||||
WRITE(p, "uniform s_" I_PLIGHTS" " I_PLIGHTS" : register(c%d);\n", C_PLIGHTS);
|
||||
WRITE(p, "typedef struct { float4 C0, C1, C2, C3; } s_" I_PMATERIALS";\n");
|
||||
WRITE(p, "uniform s_" I_PMATERIALS" " I_PMATERIALS" : register(c%d);\n", C_PMATERIALS);
|
||||
}
|
||||
|
||||
WRITE(p, "void main(\n");
|
||||
@ -635,7 +635,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
else if (dstAlphaMode == DSTALPHA_ALPHA_PASS)
|
||||
{
|
||||
WRITE(p, " ocol0 = "I_ALPHA"[0].aaaa;\n");
|
||||
WRITE(p, " ocol0 = " I_ALPHA"[0].aaaa;\n");
|
||||
}
|
||||
if(!Pretest || dstAlphaMode == DSTALPHA_ALPHA_PASS)
|
||||
{
|
||||
@ -644,7 +644,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
}
|
||||
|
||||
WRITE(p, " float4 c0 = "I_COLORS"[1], c1 = "I_COLORS"[2], c2 = "I_COLORS"[3], prev = float4(0.0f, 0.0f, 0.0f, 0.0f), textemp = float4(0.0f, 0.0f, 0.0f, 0.0f), rastemp = float4(0.0f, 0.0f, 0.0f, 0.0f), konsttemp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n"
|
||||
WRITE(p, " float4 c0 = " I_COLORS"[1], c1 = " I_COLORS"[2], c2 = " I_COLORS"[3], prev = float4(0.0f, 0.0f, 0.0f, 0.0f), textemp = float4(0.0f, 0.0f, 0.0f, 0.0f), rastemp = float4(0.0f, 0.0f, 0.0f, 0.0f), konsttemp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n"
|
||||
" float3 comp16 = float3(1.0f, 255.0f, 0.0f), comp24 = float3(1.0f, 255.0f, 255.0f*255.0f);\n"
|
||||
" float4 alphabump=float4(0.0f,0.0f,0.0f,0.0f);\n"
|
||||
" float3 tevcoord=float3(0.0f, 0.0f, 0.0f);\n"
|
||||
@ -695,7 +695,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
WRITE(p, " uv%d.xy = uv%d.xy / uv%d.z;\n", i, i, i);
|
||||
}
|
||||
|
||||
WRITE(p, "uv%d.xy = uv%d.xy * "I_TEXDIMS"[%d].zw;\n", i, i, i);
|
||||
WRITE(p, "uv%d.xy = uv%d.xy * " I_TEXDIMS"[%d].zw;\n", i, i, i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,7 +707,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
int texcoord = bpmem.tevindref.getTexCoord(i);
|
||||
|
||||
if (texcoord < numTexgen)
|
||||
WRITE(p, "tempcoord = uv%d.xy * "I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
|
||||
WRITE(p, "tempcoord = uv%d.xy * " I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
|
||||
else
|
||||
WRITE(p, "tempcoord = float2(0.0f, 0.0f);\n");
|
||||
|
||||
@ -738,7 +738,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
if((bpmem.fog.c_proj_fsel.fsel != 0) || DepthTextureEnable)
|
||||
{
|
||||
// the screen space depth value = far z + (clip z / clip w) * z range
|
||||
WRITE(p, "float zCoord = "I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * "I_ZBIAS"[1].y;\n");
|
||||
WRITE(p, "float zCoord = " I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * " I_ZBIAS"[1].y;\n");
|
||||
}
|
||||
|
||||
if (DepthTextureEnable)
|
||||
@ -747,9 +747,9 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
if (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable)
|
||||
{
|
||||
if (bpmem.ztex2.op == ZTEXTURE_ADD)
|
||||
WRITE(p, "zCoord = dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w + zCoord;\n");
|
||||
WRITE(p, "zCoord = dot(" I_ZBIAS"[0].xyzw, textemp.xyzw) + " I_ZBIAS"[1].w + zCoord;\n");
|
||||
else
|
||||
WRITE(p, "zCoord = dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w;\n");
|
||||
WRITE(p, "zCoord = dot(" I_ZBIAS"[0].xyzw, textemp.xyzw) + " I_ZBIAS"[1].w;\n");
|
||||
|
||||
// scale to make result from frac correct
|
||||
WRITE(p, "zCoord = zCoord * (16777215.0f/16777216.0f);\n");
|
||||
@ -760,7 +760,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
}
|
||||
|
||||
if (dstAlphaMode == DSTALPHA_ALPHA_PASS)
|
||||
WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n");
|
||||
WRITE(p, " ocol0 = float4(prev.rgb, " I_ALPHA"[0].a);\n");
|
||||
else
|
||||
{
|
||||
WriteFog(p);
|
||||
@ -774,7 +774,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
||||
// Colors will be blended against the alpha from ocol1...
|
||||
WRITE(p, " ocol1 = ocol0;\n");
|
||||
// ...and the alpha from ocol0 will be written to the framebuffer.
|
||||
WRITE(p, " ocol0.a = "I_ALPHA"[0].a;\n");
|
||||
WRITE(p, " ocol0.a = " I_ALPHA"[0].a;\n");
|
||||
}
|
||||
|
||||
WRITE(p, "}\n");
|
||||
@ -867,20 +867,20 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
if (bpmem.tevind[n].mid <= 3)
|
||||
{
|
||||
int mtxidx = 2*(bpmem.tevind[n].mid-1);
|
||||
WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n",
|
||||
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 <= 7 && bHasTexCoord)
|
||||
{ // s matrix
|
||||
_assert_(bpmem.tevind[n].mid >= 5);
|
||||
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);
|
||||
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 <= 11 && bHasTexCoord)
|
||||
{ // t matrix
|
||||
_assert_(bpmem.tevind[n].mid >= 9);
|
||||
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);
|
||||
WRITE(p, "float2 indtevtrans%d = " I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
|
||||
}
|
||||
else
|
||||
WRITE(p, "float2 indtevtrans%d = 0;\n", n);
|
||||
@ -1094,9 +1094,9 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
||||
void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType)
|
||||
{
|
||||
if (ApiType == API_D3D11)
|
||||
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap);
|
||||
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap);
|
||||
else
|
||||
WRITE(p, "%s=tex2D(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap);
|
||||
WRITE(p, "%s=tex2D(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap);
|
||||
}
|
||||
|
||||
static const char *tevAlphaFuncsTable[] =
|
||||
@ -1221,13 +1221,13 @@ static void WriteFog(char *&p)
|
||||
{
|
||||
// perspective
|
||||
// ze = A/(B - (Zs >> B_SHF)
|
||||
WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - (zCoord / "I_FOG"[1].w));\n");
|
||||
WRITE (p, " float ze = " I_FOG"[1].x / (" I_FOG"[1].y - (zCoord / " I_FOG"[1].w));\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// orthographic
|
||||
// ze = a*Zs (here, no B_SHF)
|
||||
WRITE (p, " float ze = "I_FOG"[1].x * zCoord;\n");
|
||||
WRITE (p, " float ze = " I_FOG"[1].x * zCoord;\n");
|
||||
}
|
||||
|
||||
// x_adjust = sqrt((x-center)^2 + k^2)/k
|
||||
@ -1235,12 +1235,12 @@ static void WriteFog(char *&p)
|
||||
//this is complitly teorical as the real hard seems to use a table intead of calculate the values.
|
||||
if(bpmem.fogRange.Base.Enabled)
|
||||
{
|
||||
WRITE (p, " float x_adjust = (2.0f * (clipPos.x / "I_FOG"[2].y)) - 1.0f - "I_FOG"[2].x;\n");
|
||||
WRITE (p, " x_adjust = sqrt(x_adjust * x_adjust + "I_FOG"[2].z * "I_FOG"[2].z) / "I_FOG"[2].z;\n");
|
||||
WRITE (p, " float x_adjust = (2.0f * (clipPos.x / " I_FOG"[2].y)) - 1.0f - " I_FOG"[2].x;\n");
|
||||
WRITE (p, " x_adjust = sqrt(x_adjust * x_adjust + " I_FOG"[2].z * " I_FOG"[2].z) / " I_FOG"[2].z;\n");
|
||||
WRITE (p, " ze *= x_adjust;\n");
|
||||
}
|
||||
|
||||
WRITE (p, " float fog = saturate(ze - "I_FOG"[1].z);\n");
|
||||
WRITE (p, " float fog = saturate(ze - " I_FOG"[1].z);\n");
|
||||
|
||||
if(bpmem.fog.c_proj_fsel.fsel > 3)
|
||||
{
|
||||
@ -1252,7 +1252,7 @@ static void WriteFog(char *&p)
|
||||
WARN_LOG(VIDEO, "Unknown Fog Type! %08x", bpmem.fog.c_proj_fsel.fsel);
|
||||
}
|
||||
|
||||
WRITE(p, " prev.rgb = lerp(prev.rgb,"I_FOG"[0].rgb,fog);\n");
|
||||
WRITE(p, " prev.rgb = lerp(prev.rgb," I_FOG"[0].rgb,fog);\n");
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user