From 275af9c5e44129db8d039a0a0a7c1a721d6ab05a Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Mon, 15 Dec 2014 21:09:25 +0100 Subject: VideoCommon: Assume we always use a geometry shader, not just for stereoscopy. --- Source/Core/VideoCommon/VertexShaderGen.cpp | 45 +---------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 00db2b0f02..80e025386f 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -72,33 +72,9 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ out.Write("in float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i); } - uid_data->stereo = g_ActiveConfig.iStereoMode > 0; - 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("centroid out VS_OUTPUT o;\n"); out.Write("void main()\n{\n"); - - if (g_ActiveConfig.iStereoMode <= 0) - out.Write("VS_OUTPUT o;\n"); } else // D3D { @@ -384,25 +360,6 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ if (api_type == API_OPENGL) { - 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"); } else // D3D -- cgit v1.2.3 From 782a5adb947ef5e4c961580047ff17aea70f3d0f Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Tue, 16 Dec 2014 23:52:42 +0100 Subject: VideoCommon: Pass interface blocks between shader stages to resolve naming conflicts. --- Source/Core/VideoCommon/VertexShaderGen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 80e025386f..83fbddf2d9 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -72,7 +72,9 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ out.Write("in float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i); } - out.Write("centroid out VS_OUTPUT o;\n"); + out.Write("out VertexData {\n" + "\tcentroid VS_OUTPUT o;\n" + "};\n"); out.Write("void main()\n{\n"); } -- cgit v1.2.3 From 69df23f725205a4bcd10c6315f2421d3041e614e Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Wed, 17 Dec 2014 09:18:40 +0100 Subject: VideoCommon: Only use interface blocks when geometry shaders are supported. --- Source/Core/VideoCommon/VertexShaderGen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 83fbddf2d9..bd033967ee 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -72,9 +72,16 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ out.Write("in float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i); } - out.Write("out VertexData {\n" - "\tcentroid VS_OUTPUT o;\n" - "};\n"); + if (g_ActiveConfig.backend_info.bSupportsGeometryShaders) + { + out.Write("out VertexData {\n" + "\tcentroid VS_OUTPUT o;\n" + "};\n"); + } + else + { + out.Write("centroid out VS_OUTPUT o; \n"); + } out.Write("void main()\n{\n"); } -- cgit v1.2.3 From 8dc3653ac9ec07040c8bcd0748c8040cf831d632 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Wed, 17 Dec 2014 23:44:05 +0100 Subject: VideoCommon: Don't pass structs between shader stages when geometry shaders are unsupported. --- Source/Core/VideoCommon/VertexShaderGen.cpp | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index bd033967ee..123f137ff2 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -80,10 +80,25 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ } else { - out.Write("centroid out VS_OUTPUT o; \n"); + // 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.backend_info.bSupportsGeometryShaders) + out.Write("VS_OUTPUT o;\n"); } else // D3D { @@ -369,6 +384,19 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ if (api_type == API_OPENGL) { + if (!g_ActiveConfig.backend_info.bSupportsGeometryShaders) + { + // TODO: Pass structs between shader stages even if geometry shaders + // are not supported, however that will break GL 3.0 and 3.1 support. + 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"); } else // D3D -- cgit v1.2.3