Change 'stuff'

This commit is contained in:
Ryan Houdek 2012-01-11 01:18:54 -06:00 committed by Sonicadvance1
parent 210ecad15f
commit 71f6b1eec6
2 changed files with 59 additions and 15 deletions

View File

@ -571,9 +571,15 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n"); WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n"); WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n");
WRITE(p, "#define ATTRIN in\n");
WRITE(p, "#define ATTROUT out\n");
} }
else else
{
WRITE(p, "#version 120\n"); WRITE(p, "#version 120\n");
WRITE(p, "#define ATTRIN attribute\n");
WRITE(p, "#define ATTROUT attribute\n");
}
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind) if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n"); WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
@ -729,13 +735,21 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, " float4 colors_1 = gl_SecondaryColor;\n"); WRITE(p, " float4 colors_1 = gl_SecondaryColor;\n");
// compute window position if needed because binding semantic WPOS is not widely supported // compute window position if needed because binding semantic WPOS is not widely supported
if (numTexgen < 7) // Let's set up attributes
if (xfregs.numTexGen.numTexGens < 7)
{ {
for (int i = 0; i < numTexgen; ++i) for (int i = 0; i < 8; ++i)
WRITE(p, " float3 uv%d = gl_TexCoord[%d].xyz;\n", i, i); {
WRITE(p, " float4 clipPos = gl_TexCoord[%d];\n", numTexgen); WRITE(p, "ATTRIN float3 uv%d_2;\n", i);
WRITE(p, " float3 uv%d = uv%d_2;\n", i, i);
}
WRITE(p, "ATTRIN float4 clipPos_2;\n");
WRITE(p, " float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, " float4 Normal = gl_TexCoord[%d];\n", numTexgen + 1); {
WRITE(p, "ATTRIN float4 Normal_2;\n");
WRITE(p, " float4 Normal = Normal_2;\n");
}
} }
else else
{ {
@ -743,12 +757,18 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
WRITE(p, " float4 uv%d = gl_TexCoord[%d];\n", i, i); {
WRITE(p, "ATTRIN float4 uv%d_2;\n", i);
WRITE(p, " float4 uv%d = uv%d_2;\n", i, i);
}
} }
else else
{ {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " float%d uv%d = gl_TexCoord[%d]%s;\n", i < 4 ? 4 : 3 , i, i, i < 4 ? "" : ".xyz"); {
WRITE(p, "ATTRIN float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
WRITE(p, " float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i);
}
} }
} }
WRITE(p, "void main()\n{\n"); WRITE(p, "void main()\n{\n");

View File

@ -270,6 +270,30 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if ((components & (VB_HAS_UV0<<i)) || hastexmtx) if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
WRITE(p, " float%d tex%d = gl_MultiTexCoord%d.xy%s; // TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i, hastexmtx ? "z" : "", i); WRITE(p, " float%d tex%d = gl_MultiTexCoord%d.xy%s; // TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i, hastexmtx ? "z" : "", i);
} }
// Let's set up attributes
if (xfregs.numTexGen.numTexGens < 7)
{
for (int i = 0; i < 8; ++i)
WRITE(p, "ATTROUT float3 uv%d_2;\n", i);
WRITE(p, "ATTROUT float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, "ATTROUT float4 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)
WRITE(p, "ATTROUT float4 uv%d_2;\n", i);
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, "ATTROUT float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
}
}
WRITE(p, " float4 rawpos = gl_Vertex;\n") ; WRITE(p, " float4 rawpos = gl_Vertex;\n") ;
WRITE(p, "void main()\n{\n"); WRITE(p, "void main()\n{\n");
@ -581,21 +605,21 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if (xfregs.numTexGen.numTexGens < 7) { if (xfregs.numTexGen.numTexGens < 7) {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " gl_TexCoord[%d].xyz = o.tex%d;\n", i, i); WRITE(p, " uv%d_2.xyz = o.tex%d;\n", i, i);
WRITE(p, " gl_TexCoord[%d] = o.clipPos;\n", xfregs.numTexGen.numTexGens); WRITE(p, " clipPos_2 = o.clipPos;\n");
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, " gl_TexCoord[%d] = o.Normal;\n", xfregs.numTexGen.numTexGens + 1); WRITE(p, " Normal_2 = o.Normal;\n");
} else { } else {
// clip position is in w of first 4 texcoords // clip position is in w of first 4 texcoords
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
WRITE(p, " gl_TexCoord[%d] = o.tex%d;\n", i, i); WRITE(p, " uv%d_2 = o.tex%d;\n", i, i);
} }
else else
{ {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " gl_TexCoord[%d]%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i); WRITE(p, " uv%d_2%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i);
} }
} }
WRITE(p, "gl_FrontColor = o.colors_0;\n"); WRITE(p, "gl_FrontColor = o.colors_0;\n");