ShaderGen: Only specify storage qualifier in interface block when needed
Drivers that don't support GL_ARB_shading_language_420pack require that the storage qualifier be specified even when inside an interface block. AMD's driver throws a compile error when "centroid in/out" is used within an interface block. Our previous behavior was to include the storage qualifier regardless, but this wasn't working on AMD, therefore we should check for the presence of the extension and include based on this, instead.
This commit is contained in:
parent
6d42054274
commit
e6b2212ec0
|
@ -90,16 +90,15 @@ static T GenerateGeometryShader(u32 primitive_type, API_TYPE ApiType)
|
|||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||
out.Write("#define InstanceID gl_InvocationID\n");
|
||||
|
||||
out.Write("// The interface block qualifier is duplicated to its member due to Apple OS X bug 24983074\n");
|
||||
out.Write("in VertexData {\n");
|
||||
GenerateVSOutputMembers<T>(out, ApiType, "in", GetInterpolationQualifier());
|
||||
GenerateVSOutputMembers<T>(out, ApiType, GetInterpolationQualifier(true, true));
|
||||
out.Write("} vs[%d];\n", vertex_in);
|
||||
|
||||
out.Write("out VertexData {\n");
|
||||
GenerateVSOutputMembers<T>(out, ApiType, "out", GetInterpolationQualifier());
|
||||
GenerateVSOutputMembers<T>(out, ApiType, GetInterpolationQualifier(true, false));
|
||||
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
out.Write("\tflat out int layer;\n");
|
||||
out.Write("\tflat int layer;\n");
|
||||
|
||||
out.Write("} ps;\n");
|
||||
|
||||
|
|
|
@ -354,12 +354,11 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
|
|||
uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
|
||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
|
||||
{
|
||||
out.Write("// The interface block qualifier is duplicated to its member due to Apple OS X bug 24983074\n");
|
||||
out.Write("in VertexData {\n");
|
||||
GenerateVSOutputMembers<T>(out, ApiType, "in", GetInterpolationQualifier());
|
||||
GenerateVSOutputMembers<T>(out, ApiType, GetInterpolationQualifier(true, true));
|
||||
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
out.Write("\tflat in int layer;\n");
|
||||
out.Write("\tflat int layer;\n");
|
||||
|
||||
out.Write("};\n");
|
||||
}
|
||||
|
|
|
@ -214,12 +214,9 @@ private:
|
|||
};
|
||||
|
||||
template<class T>
|
||||
inline void DefineOutputMember(T& object, API_TYPE api_type, const char* qualifier, const char* in_out, const char* type, const char* name, int var_index, const char* semantic = "", int semantic_index = -1)
|
||||
inline void DefineOutputMember(T& object, API_TYPE api_type, const char* qualifier, const char* type, const char* name, int var_index, const char* semantic = "", int semantic_index = -1)
|
||||
{
|
||||
if (qualifier != nullptr)
|
||||
object.Write("\t%s %s %s %s", qualifier, in_out, type, name);
|
||||
else
|
||||
object.Write("\t%s %s %s", in_out, type, name);
|
||||
object.Write("\t%s %s %s", qualifier, type, name);
|
||||
|
||||
if (var_index != -1)
|
||||
object.Write("%d", var_index);
|
||||
|
@ -236,21 +233,21 @@ inline void DefineOutputMember(T& object, API_TYPE api_type, const char* qualifi
|
|||
}
|
||||
|
||||
template<class T>
|
||||
inline void GenerateVSOutputMembers(T& object, API_TYPE api_type, const char* in_out, const char* qualifier = nullptr)
|
||||
inline void GenerateVSOutputMembers(T& object, API_TYPE api_type, const char* qualifier)
|
||||
{
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float4", "pos", -1, "POSITION");
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float4", "colors_", 0, "COLOR", 0);
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float4", "colors_", 1, "COLOR", 1);
|
||||
DefineOutputMember(object, api_type, qualifier, "float4", "pos", -1, "POSITION");
|
||||
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 0, "COLOR", 0);
|
||||
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 1, "COLOR", 1);
|
||||
|
||||
for (unsigned int i = 0; i < xfmem.numTexGen.numTexGens; ++i)
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float3", "tex", i, "TEXCOORD", i);
|
||||
DefineOutputMember(object, api_type, qualifier, "float3", "tex", i, "TEXCOORD", i);
|
||||
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float4", "clipPos", -1, "TEXCOORD", xfmem.numTexGen.numTexGens);
|
||||
DefineOutputMember(object, api_type, qualifier, "float4", "clipPos", -1, "TEXCOORD", xfmem.numTexGen.numTexGens);
|
||||
|
||||
if (g_ActiveConfig.bEnablePixelLighting)
|
||||
{
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float3", "Normal", -1, "TEXCOORD", xfmem.numTexGen.numTexGens + 1);
|
||||
DefineOutputMember(object, api_type, qualifier, in_out, "float3", "WorldPos", -1, "TEXCOORD", xfmem.numTexGen.numTexGens + 2);
|
||||
DefineOutputMember(object, api_type, qualifier, "float3", "Normal", -1, "TEXCOORD", xfmem.numTexGen.numTexGens + 1);
|
||||
DefineOutputMember(object, api_type, qualifier, "float3", "WorldPos", -1, "TEXCOORD", xfmem.numTexGen.numTexGens + 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,15 +278,27 @@ inline void AssignVSOutputMembers(T& object, const char* a, const char* b)
|
|||
// As a workaround, we interpolate at the centroid of the coveraged pixel, which
|
||||
// is always inside the primitive.
|
||||
// Without MSAA, this flag is defined to have no effect.
|
||||
inline const char* GetInterpolationQualifier()
|
||||
inline const char* GetInterpolationQualifier(bool in_glsl_interface_block = false, bool in = false)
|
||||
{
|
||||
if (g_ActiveConfig.iMultisamples <= 1)
|
||||
return "";
|
||||
|
||||
if (!g_ActiveConfig.bSSAA)
|
||||
return "centroid";
|
||||
|
||||
return "sample";
|
||||
// Without GL_ARB_shading_language_420pack support, the interpolation qualifier must be
|
||||
// "centroid in" and not "centroid", even within an interface block.
|
||||
if (in_glsl_interface_block && !g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
||||
{
|
||||
if (!g_ActiveConfig.bSSAA)
|
||||
return in ? "centroid in" : "centroid out";
|
||||
else
|
||||
return in ? "sample in" : "sample out";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_ActiveConfig.bSSAA)
|
||||
return "centroid";
|
||||
else
|
||||
return "sample";
|
||||
}
|
||||
}
|
||||
|
||||
// Constant variable names
|
||||
|
|
|
@ -74,9 +74,8 @@ static T GenerateVertexShader(API_TYPE api_type)
|
|||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
|
||||
{
|
||||
out.Write("// The interface block qualifier is duplicated to its member due to Apple OS X bug 24983074\n");
|
||||
out.Write("out VertexData {\n");
|
||||
GenerateVSOutputMembers<T>(out, api_type, "out", GetInterpolationQualifier());
|
||||
GenerateVSOutputMembers<T>(out, api_type, GetInterpolationQualifier(true, false));
|
||||
out.Write("} vs;\n");
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue