Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Mali-T604 shader compilation
  • Loading branch information
Sonicadvance1 committed Jul 25, 2013
1 parent 672871b commit e0a5f78
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions Source/Core/VideoCommon/Src/PixelShaderGen.cpp
Expand Up @@ -328,28 +328,22 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api

if (per_pixel_depth)
out.Write("#define depth gl_FragDepth\n");
out.Write("float4 rawpos = gl_FragCoord;\n");

out.Write("VARYIN float4 colors_02;\n");
out.Write("VARYIN float4 colors_12;\n");
out.Write("float4 colors_0 = colors_02;\n");
out.Write("float4 colors_1 = colors_12;\n");


// compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes
if (xfregs.numTexGen.numTexGens < 7)
{
for (int i = 0; i < 8; ++i)
{
out.Write("VARYIN float3 uv%d_2;\n", i);
out.Write("float3 uv%d = uv%d_2;\n", i, i);
}
out.Write("VARYIN float4 clipPos_2;\n");
out.Write("float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
out.Write("VARYIN float4 Normal_2;\n");
out.Write("float4 Normal = Normal_2;\n");
}
}
else
Expand All @@ -360,15 +354,13 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api
for (int i = 0; i < 8; ++i)
{
out.Write("VARYIN float4 uv%d_2;\n", i);
out.Write("float4 uv%d = uv%d_2;\n", i, i);
}
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{
out.Write("VARYIN float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
out.Write("float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i);
}
}
out.Write("float4 clipPos;\n");
Expand Down Expand Up @@ -443,6 +435,50 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api
" float4 cc2=float4(0.0f,0.0f,0.0f,0.0f), cprev=float4(0.0f,0.0f,0.0f,0.0f);\n"
" float4 crastemp=float4(0.0f,0.0f,0.0f,0.0f),ckonsttemp=float4(0.0f,0.0f,0.0f,0.0f);\n\n");

if (ApiType == API_OPENGL)
{
// On Mali, global variables must be initialized as constants.
// This is why we initialize these variables locally instead.
out.Write("float4 rawpos = gl_FragCoord;\n");
out.Write("float4 colors_0 = colors_02;\n");
out.Write("float4 colors_1 = colors_12;\n");
// compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes
if (xfregs.numTexGen.numTexGens < 7)
{
if(numTexgen)
{
for (int i = 0; i < 8; ++i)
{
out.Write("float3 uv%d = uv%d_2;\n", i, i);
}
}
out.Write("float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
out.Write("float4 Normal = Normal_2;\n");
}
}
else
{
// wpos is in w of first 4 texcoords
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
for (int i = 0; i < 8; ++i)
{
out.Write("float4 uv%d = uv%d_2;\n", i, i);
}
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{
out.Write("float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i);
}
}
}
}

if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
uid_data.xfregs_numTexGen_numTexGens = xfregs.numTexGen.numTexGens;
Expand Down

0 comments on commit e0a5f78

Please sign in to comment.