Merge pull request #3757 from stenzek/amd-glsl-storage-qualifier
ShaderGen: Handle AMD bug with storage qualifiers in interface blocks
This commit is contained in:
commit
77c05737e9
|
@ -90,16 +90,15 @@ static T GenerateGeometryShader(u32 primitive_type, API_TYPE ApiType)
|
||||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||||
out.Write("#define InstanceID gl_InvocationID\n");
|
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");
|
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("} vs[%d];\n", vertex_in);
|
||||||
|
|
||||||
out.Write("out VertexData {\n");
|
out.Write("out VertexData {\n");
|
||||||
GenerateVSOutputMembers<T>(out, ApiType, "out", GetInterpolationQualifier());
|
GenerateVSOutputMembers<T>(out, ApiType, GetInterpolationQualifier(true, false));
|
||||||
|
|
||||||
if (g_ActiveConfig.iStereoMode > 0)
|
if (g_ActiveConfig.iStereoMode > 0)
|
||||||
out.Write("\tflat out int layer;\n");
|
out.Write("\tflat int layer;\n");
|
||||||
|
|
||||||
out.Write("} ps;\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;
|
uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
|
||||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
|
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");
|
out.Write("in VertexData {\n");
|
||||||
GenerateVSOutputMembers<T>(out, ApiType, "in", GetInterpolationQualifier());
|
GenerateVSOutputMembers<T>(out, ApiType, GetInterpolationQualifier(true, true));
|
||||||
|
|
||||||
if (g_ActiveConfig.iStereoMode > 0)
|
if (g_ActiveConfig.iStereoMode > 0)
|
||||||
out.Write("\tflat in int layer;\n");
|
out.Write("\tflat int layer;\n");
|
||||||
|
|
||||||
out.Write("};\n");
|
out.Write("};\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,12 +214,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
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", qualifier, type, name);
|
||||||
object.Write("\t%s %s %s %s", qualifier, in_out, type, name);
|
|
||||||
else
|
|
||||||
object.Write("\t%s %s %s", in_out, type, name);
|
|
||||||
|
|
||||||
if (var_index != -1)
|
if (var_index != -1)
|
||||||
object.Write("%d", var_index);
|
object.Write("%d", var_index);
|
||||||
|
@ -236,21 +233,21 @@ inline void DefineOutputMember(T& object, API_TYPE api_type, const char* qualifi
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
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, "float4", "pos", -1, "POSITION");
|
||||||
DefineOutputMember(object, api_type, qualifier, in_out, "float4", "colors_", 0, "COLOR", 0);
|
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 0, "COLOR", 0);
|
||||||
DefineOutputMember(object, api_type, qualifier, in_out, "float4", "colors_", 1, "COLOR", 1);
|
DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 1, "COLOR", 1);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < xfmem.numTexGen.numTexGens; ++i)
|
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)
|
if (g_ActiveConfig.bEnablePixelLighting)
|
||||||
{
|
{
|
||||||
DefineOutputMember(object, api_type, qualifier, in_out, "float3", "Normal", -1, "TEXCOORD", xfmem.numTexGen.numTexGens + 1);
|
DefineOutputMember(object, api_type, qualifier, "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", "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
|
// As a workaround, we interpolate at the centroid of the coveraged pixel, which
|
||||||
// is always inside the primitive.
|
// is always inside the primitive.
|
||||||
// Without MSAA, this flag is defined to have no effect.
|
// 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)
|
if (g_ActiveConfig.iMultisamples <= 1)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (!g_ActiveConfig.bSSAA)
|
// Without GL_ARB_shading_language_420pack support, the interpolation qualifier must be
|
||||||
return "centroid";
|
// "centroid in" and not "centroid", even within an interface block.
|
||||||
|
if (in_glsl_interface_block && !g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
||||||
return "sample";
|
{
|
||||||
|
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
|
// Constant variable names
|
||||||
|
|
|
@ -74,9 +74,8 @@ static T GenerateVertexShader(API_TYPE api_type)
|
||||||
|
|
||||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
|
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");
|
out.Write("out VertexData {\n");
|
||||||
GenerateVSOutputMembers<T>(out, api_type, "out", GetInterpolationQualifier());
|
GenerateVSOutputMembers<T>(out, api_type, GetInterpolationQualifier(true, false));
|
||||||
out.Write("} vs;\n");
|
out.Write("} vs;\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue