Fix ambiguous function call issues in HLSL output
D3D compiler can't resolve between these overloaded functions:
float4 vec4(float2x2 x0);
float4 vec4(float4 x0);
Include the parameter types in the function name to disambiguate
between overloaded user-defined functions and constructors, like this:
float4 vec4_float2x2(float2x2 x0);
float4 vec4_float4(float4 x0);
This is only done for float2x2 and float4 parameters, other parameter
types like float2x3 vs. float3x2 don't need this.
BUG=angleproject:1099
BUG=angleproject:1030
TEST=angle_end2end_tests,
dEQP-GLES3.functional.attribute_location.* (10 more tests pass),
dEQP-GLES2.functional.attribute_location.*
Change-Id: Ief047d41b0adbc238393c3c13cb29771cbb83d58
Reviewed-on: https://chromium-review.googlesource.com/329882
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/UtilsHLSL.cpp b/src/compiler/translator/UtilsHLSL.cpp
index 404ccee..53ea73c 100644
--- a/src/compiler/translator/UtilsHLSL.cpp
+++ b/src/compiler/translator/UtilsHLSL.cpp
@@ -435,4 +435,23 @@
}
return 0;
}
+
+TString DisambiguateFunctionName(const TIntermSequence *parameters)
+{
+ TString disambiguatingString;
+ for (auto parameter : *parameters)
+ {
+ const TType ¶mType = parameter->getAsTyped()->getType();
+ // Disambiguation is needed for float2x2 and float4 parameters. These are the only parameter
+ // types that HLSL thinks are identical. float2x3 and float3x2 are different types, for
+ // example. Other parameter types are not added to function names to avoid making function
+ // names longer.
+ if (paramType.getObjectSize() == 4 && paramType.getBasicType() == EbtFloat)
+ {
+ disambiguatingString += "_" + TypeString(paramType);
+ }
+ }
+ return disambiguatingString;
}
+
+} // namespace sh