diff options
| author | Jules Blok <jules.blok@gmail.com> | 2014-11-04 11:53:19 +0100 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2014-11-23 14:27:40 +0100 |
| commit | 27f3f804a0fd002a19143b2373a6c622fcb56589 (patch) | |
| tree | 55198522c3acc4efe14aafddbb153d233809915f /Source/Core/VideoCommon/VertexShaderGen.cpp | |
| parent | 51a4d6a4bef09e7b270ee26e5b2889379819da45 (diff) | |
ShaderGen: Only pass VS_OUTPUT between shaders if stereo 3D is enabled.
GLSL130 doesn't support passing structs between shaders.
This is not a problem for stereo 3D which has a GLSL150 requirement.
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderGen.cpp | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 700bd0d2a6..24c6f39f46 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -123,11 +123,31 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ } uid_data->stereo = g_ActiveConfig.iStereoMode > 0; - out.Write("centroid out VS_OUTPUT %s;\n", (g_ActiveConfig.iStereoMode > 0) ? "v" : "o"); + if (g_ActiveConfig.iStereoMode > 0) + { + out.Write("centroid out VS_OUTPUT o;\n"); + } + else + { + // Let's set up attributes + for (size_t i = 0; i < 8; ++i) + { + if (i < xfmem.numTexGen.numTexGens) + { + out.Write("centroid out float3 uv%d;\n", i); + } + } + + out.Write("centroid out float4 clipPos;\n"); + if (g_ActiveConfig.bEnablePixelLighting) + out.Write("centroid out float4 Normal;\n"); + out.Write("centroid out float4 colors_02;\n"); + out.Write("centroid out float4 colors_12;\n"); + } out.Write("void main()\n{\n"); - if (g_ActiveConfig.iStereoMode > 0) + if (g_ActiveConfig.iStereoMode <= 0) out.Write("VS_OUTPUT o;\n"); } else // D3D @@ -414,8 +434,24 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ if (api_type == API_OPENGL) { - if (g_ActiveConfig.iStereoMode > 0) - out.Write("v = o;\n"); + if (g_ActiveConfig.iStereoMode <= 0) + { + // Bit ugly here + // TODO: Make pretty + // Will look better when we bind uniforms in GLSL 1.3 + // clipPos/w needs to be done in pixel shader, not here + + for (unsigned int i = 0; i < xfmem.numTexGen.numTexGens; ++i) + out.Write("uv%d.xyz = o.tex%d;\n", i, i); + + out.Write("clipPos = o.clipPos;\n"); + + if (g_ActiveConfig.bEnablePixelLighting) + out.Write("Normal = o.Normal;\n"); + + out.Write("colors_02 = o.colors_0;\n"); + out.Write("colors_12 = o.colors_1;\n"); + } out.Write("gl_Position = o.pos;\n"); } |
