ShaderGen: Use interface blocks when geometry shaders are supported

We don't use explicit locations in OpenGL currently, so this breaks
when we use alternative names in the geometry shaders.
This commit is contained in:
Stenzek
2019-04-20 23:44:33 +10:00
parent 4b1adab785
commit eddde3e6c8
3 changed files with 92 additions and 24 deletions

View File

@ -67,8 +67,17 @@ ShaderCode GenerateVertexShader(APIType api_type)
}
else if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
out.Write("VARYING_LOCATION(0) out float3 v_tex0;\n"
"#define id gl_VertexID\n"
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
{
out.Write("VARYING_LOCATION(0) out VertexData {\n");
out.Write(" float3 v_tex0;\n");
out.Write("};\n");
}
else
{
out.Write("VARYING_LOCATION(0) out float3 v_tex0;\n");
}
out.Write("#define id gl_VertexID\n"
"#define opos gl_Position\n"
"void main() {\n");
}
@ -112,8 +121,17 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data)
"clamp_tb.x, clamp_tb.y), %s));\n"
"}\n",
mono_depth ? "0.0" : "uv.z");
out.Write("VARYING_LOCATION(0) in vec3 v_tex0;\n"
"FRAGMENT_OUTPUT_LOCATION(0) out vec4 ocol0;"
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
{
out.Write("VARYING_LOCATION(0) in VertexData {\n");
out.Write(" float3 v_tex0;\n");
out.Write("};\n");
}
else
{
out.Write("VARYING_LOCATION(0) in vec3 v_tex0;\n");
}
out.Write("FRAGMENT_OUTPUT_LOCATION(0) out vec4 ocol0;"
"void main()\n{\n");
}