Commit 75d577fb by Natasha Lee Committed by Commit Bot

Fixed Bug where array initialized with same name of

previously declared variable fails on DirectX. Combined user defined variables with their unique ids to avoid overwriting same name variables of different scope. Bug: angleproject:2126 Change-Id: If9ad9e48f629d83b105d43ee28a50b8176d0e0a1 Reviewed-on: https://chromium-review.googlesource.com/c/1456484Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
parent 238c19e1
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/StructureHLSL.h" #include "compiler/translator/StructureHLSL.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/util.h"
namespace sh namespace sh
{ {
...@@ -857,6 +858,13 @@ TString DecorateVariableIfNeeded(const TVariable &variable) ...@@ -857,6 +858,13 @@ TString DecorateVariableIfNeeded(const TVariable &variable)
ASSERT(!name.beginsWith("_")); ASSERT(!name.beginsWith("_"));
return TString(name.data()); return TString(name.data());
} }
// For user defined variables, combine variable name with unique id
// so variables of the same name in different scopes do not get overwritten.
else if (variable.symbolType() == SymbolType::UserDefined &&
variable.getType().getQualifier() == EvqTemporary)
{
return Decorate(variable.name()) + str(variable.uniqueId().get());
}
else else
{ {
return Decorate(variable.name()); return Decorate(variable.name());
......
...@@ -297,7 +297,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundAddFunction) ...@@ -297,7 +297,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundAddFunction)
foundInHLSLCode("float4 angle_compound_add_frm(inout float4 x, in float4 y) {\n" foundInHLSLCode("float4 angle_compound_add_frm(inout float4 x, in float4 y) {\n"
" x = angle_frm(angle_frm(x) + y);")); " x = angle_frm(angle_frm(x) + y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_add_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_add_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_add_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_add_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("+=")); ASSERT_TRUE(notFoundInCode("+="));
} }
...@@ -323,7 +323,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundSubFunction) ...@@ -323,7 +323,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundSubFunction)
foundInHLSLCode("float4 angle_compound_sub_frm(inout float4 x, in float4 y) {\n" foundInHLSLCode("float4 angle_compound_sub_frm(inout float4 x, in float4 y) {\n"
" x = angle_frm(angle_frm(x) - y);")); " x = angle_frm(angle_frm(x) - y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_sub_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_sub_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_sub_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_sub_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("-=")); ASSERT_TRUE(notFoundInCode("-="));
} }
...@@ -349,7 +349,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundDivFunction) ...@@ -349,7 +349,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundDivFunction)
foundInHLSLCode("float4 angle_compound_div_frm(inout float4 x, in float4 y) {\n" foundInHLSLCode("float4 angle_compound_div_frm(inout float4 x, in float4 y) {\n"
" x = angle_frm(angle_frm(x) / y);")); " x = angle_frm(angle_frm(x) / y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_div_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_div_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_div_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_div_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("/=")); ASSERT_TRUE(notFoundInCode("/="));
} }
...@@ -375,7 +375,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundMulFunction) ...@@ -375,7 +375,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundMulFunction)
foundInHLSLCode("float4 angle_compound_mul_frm(inout float4 x, in float4 y) {\n" foundInHLSLCode("float4 angle_compound_mul_frm(inout float4 x, in float4 y) {\n"
" x = angle_frm(angle_frm(x) * y);")); " x = angle_frm(angle_frm(x) * y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("*=")); ASSERT_TRUE(notFoundInCode("*="));
} }
...@@ -401,7 +401,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundAddVectorPlusScalarFunction) ...@@ -401,7 +401,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundAddVectorPlusScalarFunction)
foundInHLSLCode("float4 angle_compound_add_frm(inout float4 x, in float y) {\n" foundInHLSLCode("float4 angle_compound_add_frm(inout float4 x, in float y) {\n"
" x = angle_frm(angle_frm(x) + y);")); " x = angle_frm(angle_frm(x) + y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_add_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_add_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_add_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_add_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("+=")); ASSERT_TRUE(notFoundInCode("+="));
} }
...@@ -427,7 +427,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundMatrixTimesMatrixFunction) ...@@ -427,7 +427,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundMatrixTimesMatrixFunction)
foundInHLSLCode("float4x4 angle_compound_mul_frm(inout float4x4 x, in float4x4 y) {\n" foundInHLSLCode("float4x4 angle_compound_mul_frm(inout float4x4 x, in float4x4 y) {\n"
" x = angle_frm(angle_frm(x) * y);")); " x = angle_frm(angle_frm(x) * y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_um, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_um, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_m, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_m1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("*=")); ASSERT_TRUE(notFoundInCode("*="));
} }
...@@ -457,7 +457,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundNonSquareMatrixTimesMatrixFunction) ...@@ -457,7 +457,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundNonSquareMatrixTimesMatrixFunction)
foundInHLSLCode("float2x4 angle_compound_mul_frm(inout float2x4 x, in float2x2 y) {\n" foundInHLSLCode("float2x4 angle_compound_mul_frm(inout float2x4 x, in float2x2 y) {\n"
" x = angle_frm(angle_frm(x) * y);")); " x = angle_frm(angle_frm(x) * y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_um, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_um, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_m, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_m1031, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("*=")); ASSERT_TRUE(notFoundInCode("*="));
} }
...@@ -483,7 +483,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundMatrixTimesScalarFunction) ...@@ -483,7 +483,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundMatrixTimesScalarFunction)
foundInHLSLCode("float4x4 angle_compound_mul_frm(inout float4x4 x, in float y) {\n" foundInHLSLCode("float4x4 angle_compound_mul_frm(inout float4x4 x, in float y) {\n"
" x = angle_frm(angle_frm(x) * y);")); " x = angle_frm(angle_frm(x) * y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_um, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_um, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_m, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_m1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("*=")); ASSERT_TRUE(notFoundInCode("*="));
} }
...@@ -509,7 +509,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundVectorTimesMatrixFunction) ...@@ -509,7 +509,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundVectorTimesMatrixFunction)
foundInHLSLCode("float4 angle_compound_mul_frm(inout float4 x, in float4x4 y) {\n" foundInHLSLCode("float4 angle_compound_mul_frm(inout float4 x, in float4x4 y) {\n"
" x = angle_frm(angle_frm(x) * y);")); " x = angle_frm(angle_frm(x) * y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("*=")); ASSERT_TRUE(notFoundInCode("*="));
} }
...@@ -535,7 +535,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundVectorTimesScalarFunction) ...@@ -535,7 +535,7 @@ TEST_F(DebugShaderPrecisionTest, CompoundVectorTimesScalarFunction)
foundInHLSLCode("float4 angle_compound_mul_frm(inout float4 x, in float y) {\n" foundInHLSLCode("float4 angle_compound_mul_frm(inout float4 x, in float y) {\n"
" x = angle_frm(angle_frm(x) * y);")); " x = angle_frm(angle_frm(x) * y);"));
ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_uv, angle_frm(_uu2));")); ASSERT_TRUE(foundInAllGLSLCode("angle_compound_mul_frm(_uv, angle_frm(_uu2));"));
ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_v, angle_frm(_u2));")); ASSERT_TRUE(foundInHLSLCode("angle_compound_mul_frm(_v1030, angle_frm(_u2));"));
ASSERT_TRUE(notFoundInCode("*=")); ASSERT_TRUE(notFoundInCode("*="));
} }
...@@ -564,11 +564,11 @@ TEST_F(DebugShaderPrecisionTest, BinaryMathRounding) ...@@ -564,11 +564,11 @@ TEST_F(DebugShaderPrecisionTest, BinaryMathRounding)
ASSERT_TRUE(foundInAllGLSLCode("v4 = angle_frm((angle_frm(_uu4) / angle_frm(_uu5)))")); ASSERT_TRUE(foundInAllGLSLCode("v4 = angle_frm((angle_frm(_uu4) / angle_frm(_uu5)))"));
ASSERT_TRUE(foundInAllGLSLCode("v6 = angle_frm((_uv5 = angle_frm(_uu5)))")); ASSERT_TRUE(foundInAllGLSLCode("v6 = angle_frm((_uv5 = angle_frm(_uu5)))"));
ASSERT_TRUE(foundInHLSLCode("v1 = angle_frm((angle_frm(_u1) + angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v11033 = angle_frm((angle_frm(_u1) + angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v2 = angle_frm((angle_frm(_u2) - angle_frm(_u3)))")); ASSERT_TRUE(foundInHLSLCode("v21034 = angle_frm((angle_frm(_u2) - angle_frm(_u3)))"));
ASSERT_TRUE(foundInHLSLCode("v3 = angle_frm((angle_frm(_u3) * angle_frm(_u4)))")); ASSERT_TRUE(foundInHLSLCode("v31035 = angle_frm((angle_frm(_u3) * angle_frm(_u4)))"));
ASSERT_TRUE(foundInHLSLCode("v4 = angle_frm((angle_frm(_u4) / angle_frm(_u5)))")); ASSERT_TRUE(foundInHLSLCode("v41036 = angle_frm((angle_frm(_u4) / angle_frm(_u5)))"));
ASSERT_TRUE(foundInHLSLCode("v6 = angle_frm((_v5 = angle_frm(_u5)))")); ASSERT_TRUE(foundInHLSLCode("v61038 = angle_frm((_v51037 = angle_frm(_u5)))"));
} }
TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding) TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding)
...@@ -694,59 +694,59 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding) ...@@ -694,59 +694,59 @@ TEST_F(DebugShaderPrecisionTest, BuiltInMathFunctionRounding)
ASSERT_TRUE( ASSERT_TRUE(
foundInAllGLSLCode("m1 = angle_frm(matrixCompMult(angle_frm(_uum1), angle_frm(_uum2)))")); foundInAllGLSLCode("m1 = angle_frm(matrixCompMult(angle_frm(_uum1), angle_frm(_uum2)))"));
ASSERT_TRUE(foundInHLSLCode("v1 = angle_frm(radians(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v11037 = angle_frm(radians(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v2 = angle_frm(degrees(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v21038 = angle_frm(degrees(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v3 = angle_frm(sin(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v31039 = angle_frm(sin(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v4 = angle_frm(cos(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v41040 = angle_frm(cos(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v5 = angle_frm(tan(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v51041 = angle_frm(tan(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v6 = angle_frm(asin(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v61042 = angle_frm(asin(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v7 = angle_frm(acos(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v71043 = angle_frm(acos(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v8 = angle_frm(atan(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v81044 = angle_frm(atan(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v9 = angle_frm(atan_emu(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v91045 = angle_frm(atan_emu(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v10 = angle_frm(pow(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v101046 = angle_frm(pow(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v11 = angle_frm(exp(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v111047 = angle_frm(exp(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v12 = angle_frm(log(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v121048 = angle_frm(log(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v13 = angle_frm(exp2(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v131049 = angle_frm(exp2(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v14 = angle_frm(log2(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v141050 = angle_frm(log2(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v15 = angle_frm(sqrt(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v151051 = angle_frm(sqrt(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v16 = angle_frm(rsqrt(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v161052 = angle_frm(rsqrt(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v17 = angle_frm(abs(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v171053 = angle_frm(abs(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v18 = angle_frm(sign(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v181054 = angle_frm(sign(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v19 = angle_frm(floor(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v191055 = angle_frm(floor(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v20 = angle_frm(ceil(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v201056 = angle_frm(ceil(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v21 = angle_frm(frac(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v211057 = angle_frm(frac(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v22 = angle_frm(mod_emu(angle_frm(_u1), angle_frm(_uf)))")); ASSERT_TRUE(foundInHLSLCode("v221058 = angle_frm(mod_emu(angle_frm(_u1), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v23 = angle_frm(mod_emu(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v231059 = angle_frm(mod_emu(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v24 = angle_frm(min(angle_frm(_u1), angle_frm(_uf)))")); ASSERT_TRUE(foundInHLSLCode("v241060 = angle_frm(min(angle_frm(_u1), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v25 = angle_frm(min(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v251061 = angle_frm(min(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v26 = angle_frm(max(angle_frm(_u1), angle_frm(_uf)))")); ASSERT_TRUE(foundInHLSLCode("v261062 = angle_frm(max(angle_frm(_u1), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v27 = angle_frm(max(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("v271063 = angle_frm(max(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE( ASSERT_TRUE(foundInHLSLCode(
foundInHLSLCode("v28 = angle_frm(clamp(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))")); "v281064 = angle_frm(clamp(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))"));
ASSERT_TRUE( ASSERT_TRUE(foundInHLSLCode(
foundInHLSLCode("v29 = angle_frm(clamp(angle_frm(_u1), angle_frm(_uf), angle_frm(_uf2)))")); "v291065 = angle_frm(clamp(angle_frm(_u1), angle_frm(_uf), angle_frm(_uf2)))"));
ASSERT_TRUE(
foundInHLSLCode("v30 = angle_frm(lerp(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))"));
ASSERT_TRUE(
foundInHLSLCode("v31 = angle_frm(lerp(angle_frm(_u1), angle_frm(_u2), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v32 = angle_frm(step(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v33 = angle_frm(step(angle_frm(_uf), angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v34 = angle_frm(smoothstep(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))")); "v301066 = angle_frm(lerp(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v35 = angle_frm(smoothstep(angle_frm(_uf), angle_frm(_uf2), angle_frm(_u1)))")); "v311067 = angle_frm(lerp(angle_frm(_u1), angle_frm(_u2), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("v36 = angle_frm(normalize(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("v321068 = angle_frm(step(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("v331069 = angle_frm(step(angle_frm(_uf), angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v37 = angle_frm(faceforward_emu(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))")); "v341070 = angle_frm(smoothstep(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))"));
ASSERT_TRUE(foundInHLSLCode("v38 = angle_frm(reflect(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v39 = angle_frm(refract(angle_frm(_u1), angle_frm(_u2), angle_frm(_uf)))")); "v351071 = angle_frm(smoothstep(angle_frm(_uf), angle_frm(_uf2), angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("v361072 = angle_frm(normalize(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode(
"v371073 = angle_frm(faceforward_emu(angle_frm(_u1), angle_frm(_u2), angle_frm(_u3)))"));
ASSERT_TRUE(foundInHLSLCode("v381074 = angle_frm(reflect(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode(
"v391075 = angle_frm(refract(angle_frm(_u1), angle_frm(_u2), angle_frm(_uf)))"));
ASSERT_TRUE(foundInHLSLCode("f1 = angle_frm(length(angle_frm(_u1)))")); ASSERT_TRUE(foundInHLSLCode("f11076 = angle_frm(length(angle_frm(_u1)))"));
ASSERT_TRUE(foundInHLSLCode("f2 = angle_frm(distance(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("f21077 = angle_frm(distance(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("f3 = angle_frm(dot(angle_frm(_u1), angle_frm(_u2)))")); ASSERT_TRUE(foundInHLSLCode("f31078 = angle_frm(dot(angle_frm(_u1), angle_frm(_u2)))"));
ASSERT_TRUE(foundInHLSLCode("vf31 = angle_frm(cross(angle_frm(_uf31), angle_frm(_uf32)))")); ASSERT_TRUE(foundInHLSLCode("vf311079 = angle_frm(cross(angle_frm(_uf31), angle_frm(_uf32)))"));
ASSERT_TRUE(foundInHLSLCode("m1 = angle_frm((angle_frm(_um1) * angle_frm(_um2)))")); ASSERT_TRUE(foundInHLSLCode("m11080 = angle_frm((angle_frm(_um1) * angle_frm(_um2)))"));
} }
TEST_F(DebugShaderPrecisionTest, BuiltInRelationalFunctionRounding) TEST_F(DebugShaderPrecisionTest, BuiltInRelationalFunctionRounding)
...@@ -772,12 +772,12 @@ TEST_F(DebugShaderPrecisionTest, BuiltInRelationalFunctionRounding) ...@@ -772,12 +772,12 @@ TEST_F(DebugShaderPrecisionTest, BuiltInRelationalFunctionRounding)
ASSERT_TRUE(foundInAllGLSLCode("bv5 = equal(angle_frm(_uu1), angle_frm(_uu2))")); ASSERT_TRUE(foundInAllGLSLCode("bv5 = equal(angle_frm(_uu1), angle_frm(_uu2))"));
ASSERT_TRUE(foundInAllGLSLCode("bv6 = notEqual(angle_frm(_uu1), angle_frm(_uu2))")); ASSERT_TRUE(foundInAllGLSLCode("bv6 = notEqual(angle_frm(_uu1), angle_frm(_uu2))"));
ASSERT_TRUE(foundInHLSLCode("bv1 = (angle_frm(_u1) < angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("bv11030 = (angle_frm(_u1) < angle_frm(_u2))"));
ASSERT_TRUE(foundInHLSLCode("bv2 = (angle_frm(_u1) <= angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("bv21031 = (angle_frm(_u1) <= angle_frm(_u2))"));
ASSERT_TRUE(foundInHLSLCode("bv3 = (angle_frm(_u1) > angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("bv31032 = (angle_frm(_u1) > angle_frm(_u2))"));
ASSERT_TRUE(foundInHLSLCode("bv4 = (angle_frm(_u1) >= angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("bv41033 = (angle_frm(_u1) >= angle_frm(_u2))"));
ASSERT_TRUE(foundInHLSLCode("bv5 = (angle_frm(_u1) == angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("bv51034 = (angle_frm(_u1) == angle_frm(_u2))"));
ASSERT_TRUE(foundInHLSLCode("bv6 = (angle_frm(_u1) != angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("bv61035 = (angle_frm(_u1) != angle_frm(_u2))"));
} }
TEST_F(DebugShaderPrecisionTest, ConstructorRounding) TEST_F(DebugShaderPrecisionTest, ConstructorRounding)
...@@ -799,8 +799,8 @@ TEST_F(DebugShaderPrecisionTest, ConstructorRounding) ...@@ -799,8 +799,8 @@ TEST_F(DebugShaderPrecisionTest, ConstructorRounding)
ASSERT_TRUE(foundInAllGLSLCode("v1 = angle_frm(vec4(_uu1, _uu2, angle_frl(_uu3), _uu4))")); ASSERT_TRUE(foundInAllGLSLCode("v1 = angle_frm(vec4(_uu1, _uu2, angle_frl(_uu3), _uu4))"));
ASSERT_TRUE(foundInAllGLSLCode("v2 = angle_frm(vec4(_uuiv))")); ASSERT_TRUE(foundInAllGLSLCode("v2 = angle_frm(vec4(_uuiv))"));
ASSERT_TRUE(foundInHLSLCode("v1 = angle_frm(vec4_ctor(_u1, _u2, angle_frl(_u3), _u4))")); ASSERT_TRUE(foundInHLSLCode("v11033 = angle_frm(vec4_ctor(_u1, _u2, angle_frl(_u3), _u4))"));
ASSERT_TRUE(foundInHLSLCode("v2 = angle_frm(vec4_ctor(_uiv))")); ASSERT_TRUE(foundInHLSLCode("v21034 = angle_frm(vec4_ctor(_uiv))"));
} }
TEST_F(DebugShaderPrecisionTest, StructConstructorNoRounding) TEST_F(DebugShaderPrecisionTest, StructConstructorNoRounding)
...@@ -815,7 +815,7 @@ TEST_F(DebugShaderPrecisionTest, StructConstructorNoRounding) ...@@ -815,7 +815,7 @@ TEST_F(DebugShaderPrecisionTest, StructConstructorNoRounding)
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInAllGLSLCode("s = _uS(angle_frm(_uu))")); ASSERT_TRUE(foundInAllGLSLCode("s = _uS(angle_frm(_uu))"));
ASSERT_TRUE(foundInHLSLCode("s = _S_ctor(angle_frm(_u))")); ASSERT_TRUE(foundInHLSLCode("s1031 = _S_ctor(angle_frm(_u))"));
ASSERT_TRUE(notFoundInCode("angle_frm(_uS")); // GLSL ASSERT_TRUE(notFoundInCode("angle_frm(_uS")); // GLSL
ASSERT_TRUE(notFoundInCode("angle_frm(_S")); // HLSL ASSERT_TRUE(notFoundInCode("angle_frm(_S")); // HLSL
} }
...@@ -831,7 +831,7 @@ TEST_F(DebugShaderPrecisionTest, SwizzleRounding) ...@@ -831,7 +831,7 @@ TEST_F(DebugShaderPrecisionTest, SwizzleRounding)
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInAllGLSLCode("v = angle_frm(_uu).xyxy")); ASSERT_TRUE(foundInAllGLSLCode("v = angle_frm(_uu).xyxy"));
ASSERT_TRUE(foundInHLSLCode("v = angle_frm(_u).xyxy")); ASSERT_TRUE(foundInHLSLCode("v1029 = angle_frm(_u).xyxy"));
} }
TEST_F(DebugShaderPrecisionTest, BuiltInTexFunctionRounding) TEST_F(DebugShaderPrecisionTest, BuiltInTexFunctionRounding)
...@@ -847,7 +847,7 @@ TEST_F(DebugShaderPrecisionTest, BuiltInTexFunctionRounding) ...@@ -847,7 +847,7 @@ TEST_F(DebugShaderPrecisionTest, BuiltInTexFunctionRounding)
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInAllGLSLCode("v = angle_frl(texture2D(_us, angle_frm(_uu)))")); ASSERT_TRUE(foundInAllGLSLCode("v = angle_frl(texture2D(_us, angle_frm(_uu)))"));
ASSERT_TRUE(foundInHLSLCode("v = angle_frl(gl_texture2D(_s, angle_frm(_u)))")); ASSERT_TRUE(foundInHLSLCode("v1030 = angle_frl(gl_texture2D(_s, angle_frm(_u)))"));
} }
TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromDefinition) TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromDefinition)
...@@ -882,14 +882,14 @@ TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromDefinition) ...@@ -882,14 +882,14 @@ TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromDefinition)
// otherwise. // otherwise.
// Test in parameters // Test in parameters
ASSERT_TRUE(foundInAllGLSLCode("v = _uadd(angle_frm(_uu1), angle_frm(_uu2))")); ASSERT_TRUE(foundInAllGLSLCode("v = _uadd(angle_frm(_uu1), angle_frm(_uu2))"));
ASSERT_TRUE(foundInHLSLCode("v = f_add_float4_float4(angle_frm(_u1), angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("v1043 = f_add_float4_float4(angle_frm(_u1), angle_frm(_u2))"));
// Test inout parameter // Test inout parameter
ASSERT_TRUE(foundInAllGLSLCode("_ucompound_add(_uv, angle_frm(_uu3))")); ASSERT_TRUE(foundInAllGLSLCode("_ucompound_add(_uv, angle_frm(_uu3))"));
ASSERT_TRUE(foundInHLSLCode("compound_add_float4_float4(_v, angle_frm(_u3))")); ASSERT_TRUE(foundInHLSLCode("compound_add_float4_float4(_v1043, angle_frm(_u3))"));
// Test out parameter // Test out parameter
ASSERT_TRUE(foundInAllGLSLCode("_uadd_to_last(angle_frm(_uu4), angle_frm(_uu5), _uv2)")); ASSERT_TRUE(foundInAllGLSLCode("_uadd_to_last(angle_frm(_uu4), angle_frm(_uu5), _uv2)"));
ASSERT_TRUE( ASSERT_TRUE(foundInHLSLCode(
foundInHLSLCode("add_to_last_float4_float4_float4(angle_frm(_u4), angle_frm(_u5), _v2)")); "add_to_last_float4_float4_float4(angle_frm(_u4), angle_frm(_u5), _v21044)"));
} }
TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromPrototype) TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromPrototype)
...@@ -923,14 +923,14 @@ TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromPrototype) ...@@ -923,14 +923,14 @@ TEST_F(DebugShaderPrecisionTest, FunctionCallParameterQualifiersFromPrototype)
compile(shaderString); compile(shaderString);
// Test in parameters // Test in parameters
ASSERT_TRUE(foundInAllGLSLCode("v = _uadd(angle_frm(_uu1), angle_frm(_uu2))")); ASSERT_TRUE(foundInAllGLSLCode("v = _uadd(angle_frm(_uu1), angle_frm(_uu2))"));
ASSERT_TRUE(foundInHLSLCode("v = f_add_float4_float4(angle_frm(_u1), angle_frm(_u2))")); ASSERT_TRUE(foundInHLSLCode("v1043 = f_add_float4_float4(angle_frm(_u1), angle_frm(_u2))"));
// Test inout parameter // Test inout parameter
ASSERT_TRUE(foundInAllGLSLCode("_ucompound_add(_uv, angle_frm(_uu3))")); ASSERT_TRUE(foundInAllGLSLCode("_ucompound_add(_uv, angle_frm(_uu3))"));
ASSERT_TRUE(foundInHLSLCode("compound_add_float4_float4(_v, angle_frm(_u3))")); ASSERT_TRUE(foundInHLSLCode("compound_add_float4_float4(_v1043, angle_frm(_u3))"));
// Test out parameter // Test out parameter
ASSERT_TRUE(foundInAllGLSLCode("add_to_last(angle_frm(_uu4), angle_frm(_uu5), _uv2)")); ASSERT_TRUE(foundInAllGLSLCode("add_to_last(angle_frm(_uu4), angle_frm(_uu5), _uv2)"));
ASSERT_TRUE( ASSERT_TRUE(foundInHLSLCode(
foundInHLSLCode("add_to_last_float4_float4_float4(angle_frm(_u4), angle_frm(_u5), _v2)")); "add_to_last_float4_float4_float4(angle_frm(_u4), angle_frm(_u5), _v21044)"));
} }
TEST_F(DebugShaderPrecisionTest, NestedFunctionCalls) TEST_F(DebugShaderPrecisionTest, NestedFunctionCalls)
...@@ -957,7 +957,7 @@ TEST_F(DebugShaderPrecisionTest, NestedFunctionCalls) ...@@ -957,7 +957,7 @@ TEST_F(DebugShaderPrecisionTest, NestedFunctionCalls)
ASSERT_TRUE(foundInAllGLSLCode( ASSERT_TRUE(foundInAllGLSLCode(
"v2 = _uadd(_ucompound_add(_uv, angle_frm(_uu2)), angle_frm(fract(angle_frm(_uu3))))")); "v2 = _uadd(_ucompound_add(_uv, angle_frm(_uu2)), angle_frm(fract(angle_frm(_uu3))))"));
ASSERT_TRUE(foundInHLSLCode( ASSERT_TRUE(foundInHLSLCode(
"v2 = f_add_float4_float4(f_compound_add_float4_float4(_v, angle_frm(_u2)), " "v21038 = f_add_float4_float4(f_compound_add_float4_float4(_v1037, angle_frm(_u2)), "
"angle_frm(frac(angle_frm(_u3))))")); "angle_frm(frac(angle_frm(_u3))))"));
} }
...@@ -1010,7 +1010,7 @@ TEST_F(DebugShaderPrecisionTest, ModfOutParameter) ...@@ -1010,7 +1010,7 @@ TEST_F(DebugShaderPrecisionTest, ModfOutParameter)
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInAllGLSLCode("modf(angle_frm(_uu), _uo)")); ASSERT_TRUE(foundInAllGLSLCode("modf(angle_frm(_uu), _uo)"));
ASSERT_TRUE(foundInHLSLCode("modf(angle_frm(_u), _o)")); ASSERT_TRUE(foundInHLSLCode("modf(angle_frm(_u), _o1030)"));
} }
#if defined(ANGLE_ENABLE_HLSL) #if defined(ANGLE_ENABLE_HLSL)
......
...@@ -197,5 +197,30 @@ TEST_F(HLSLOutputTest, Array) ...@@ -197,5 +197,30 @@ TEST_F(HLSLOutputTest, Array)
} }
})"; })";
compile(shaderString); compile(shaderString);
EXPECT_TRUE(foundInCode("_arr[2]")); // The unique id of arr is 1030, which is given to the symbol when parsed and inserted to the
// symbol table
EXPECT_TRUE(foundInCode("_arr1030[2]"));
} }
// Test that initializing array with previously declared array will not be overwritten
TEST_F(HLSLOutputTest, SameNameArray)
{
const std::string &shaderString =
R"(#version 300 es
precision highp float;
out vec4 my_FragColor;
void main()
{
float arr[2] = float[2](1.0, 1.0);
{
float arr[2] = arr;
my_FragColor = vec4(0.0, arr[0], 0.0, arr[1]);
}
})";
compile(shaderString);
// The unique id of the original array, arr, is 1029
EXPECT_TRUE(foundInCode("_arr1029[2]"));
// The unique id of the new array, arr, is 1030
EXPECT_TRUE(foundInCode("_arr1030[2]"));
}
\ No newline at end of file
...@@ -5095,6 +5095,27 @@ void main() ...@@ -5095,6 +5095,27 @@ void main()
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
} }
// Test initializing an array with the same name of previously declared array
TEST_P(GLSLTest_ES3, InitSameNameArray)
{
constexpr char kFS[] = R"(#version 300 es
precision highp float;
out vec4 my_FragColor;
void main()
{
float arr[2] = float[2](1.0, 1.0);
{
float arr[2] = arr;
my_FragColor = vec4(0.0, arr[0], 0.0, arr[1]);
}
})";
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFS);
drawQuad(program, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST(GLSLTest, ANGLE_INSTANTIATE_TEST(GLSLTest,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment