diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2012-01-11 01:18:54 -0600 |
|---|---|---|
| committer | Sonicadvance1 <sonicadvance1@RH-Live.(none)> | 2012-10-09 23:56:00 -0500 |
| commit | 71f6b1eec63a2e744481dc325f24f1ddd578d77e (patch) | |
| tree | f2b0e50fc70d59e6450058853678af621f871b64 /Source/Core/VideoCommon | |
| parent | 210ecad15f71efe0e09e4cf54744715483df5df1 (diff) | |
Change 'stuff'
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 40 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexShaderGen.cpp | 34 |
2 files changed, 59 insertions, 15 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 6b0b61902a..640712e673 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -571,9 +571,15 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n"); if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n"); - } - else - WRITE(p, "#version 120\n"); + WRITE(p, "#define ATTRIN in\n"); + WRITE(p, "#define ATTROUT out\n"); + } + else + { + WRITE(p, "#version 120\n"); + WRITE(p, "#define ATTRIN attribute\n"); + WRITE(p, "#define ATTROUT attribute\n"); + } if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind) 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"); // 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) - WRITE(p, " float3 uv%d = gl_TexCoord[%d].xyz;\n", i, i); - WRITE(p, " float4 clipPos = gl_TexCoord[%d];\n", numTexgen); + for (int i = 0; i < 8; ++i) + { + 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) - 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 { @@ -743,12 +757,18 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) { 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 { 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"); diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index b8ddf29fbb..69837f973d 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -270,6 +270,30 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType) 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); } + + // 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, "void main()\n{\n"); @@ -581,21 +605,21 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType) if (xfregs.numTexGen.numTexGens < 7) { for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i) - WRITE(p, " gl_TexCoord[%d].xyz = o.tex%d;\n", i, i); - WRITE(p, " gl_TexCoord[%d] = o.clipPos;\n", xfregs.numTexGen.numTexGens); + WRITE(p, " uv%d_2.xyz = o.tex%d;\n", i, i); + WRITE(p, " clipPos_2 = o.clipPos;\n"); 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 { // clip position 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, " gl_TexCoord[%d] = o.tex%d;\n", i, i); + WRITE(p, " uv%d_2 = o.tex%d;\n", i, i); } else { 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"); |
