diff options
| author | Stenzek <stenzek@gmail.com> | 2016-03-29 13:35:16 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2016-03-30 00:42:50 +1000 |
| commit | e6b2212ec0240c8d00ec2f72b84c037db94bfccb (patch) | |
| tree | 61518f1f88daa9b4c09e7c4d21e5311af63e0f40 /Source/Core/VideoCommon/ShaderGenCommon.h | |
| parent | 6d420542741ae9046ce6040001204b49fb88db68 (diff) | |
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.
Diffstat (limited to 'Source/Core/VideoCommon/ShaderGenCommon.h')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderGenCommon.h | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h index 9283cdc8cc..18c40af41e 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/ShaderGenCommon.h @@ -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 |
