|
|
@@ -271,7 +271,7 @@ TEST_F(GraphicsRobustAccessTest, ACVectorExcessConstantClamped) {
|
|
|
%uint_4 = OpConstant %uint 4
|
|
|
)"
|
|
|
<< MainPrefix() << R"(
|
|
|
- %var = OpVariable %var_ty Function)" << ACCheck(ac, "%uint_4", "%uint_3")
|
|
|
+ %var = OpVariable %var_ty Function)" << ACCheck(ac, "%uint_4", "%int_3")
|
|
|
<< MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
}
|
|
|
@@ -329,7 +329,7 @@ TEST_F(GraphicsRobustAccessTest, ACVectorGeneralClamped) {
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_3 = OpConstant %int 3
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %int_3
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %int_3
|
|
|
%var = OpVariable %var_ty Function)" << ACCheck(ac, "%i", "%[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -354,7 +354,7 @@ TEST_F(GraphicsRobustAccessTest, ACVectorGeneralShortClamped) {
|
|
|
; CHECK-DAG: %short_3 = OpConstant %short 3
|
|
|
; CHECK-NOT: = OpTypeInt 32
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %short %[[GLSLSTD450]] UClamp %i %short_0 %short_3
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %short %[[GLSLSTD450]] SClamp %i %short_0 %short_3
|
|
|
%var = OpVariable %var_ty Function)" << ACCheck(ac, "%i", "%[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -375,11 +375,11 @@ TEST_F(GraphicsRobustAccessTest, ACVectorGeneralUShortClamped) {
|
|
|
<< MainPrefix() << R"(
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-NOT: = OpTypeInt 32
|
|
|
- ; CHECK-DAG: %ushort_0 = OpConstant %ushort 0
|
|
|
- ; CHECK-DAG: %ushort_3 = OpConstant %ushort 3
|
|
|
+ ; CHECK-DAG: %short_0 = OpConstant %short 0
|
|
|
+ ; CHECK-DAG: %short_3 = OpConstant %short 3
|
|
|
; CHECK-NOT: = OpTypeInt 32
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %ushort %[[GLSLSTD450]] UClamp %i %ushort_0 %ushort_3
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %ushort %[[GLSLSTD450]] SClamp %i %short_0 %short_3
|
|
|
%var = OpVariable %var_ty Function)" << ACCheck(ac, "%i", "%[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -404,7 +404,7 @@ TEST_F(GraphicsRobustAccessTest, ACVectorGeneralLongClamped) {
|
|
|
; CHECK-DAG: %long_3 = OpConstant %long 3
|
|
|
; CHECK-NOT: = OpTypeInt 32
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %long %[[GLSLSTD450]] UClamp %i %long_0 %long_3
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %long %[[GLSLSTD450]] SClamp %i %long_0 %long_3
|
|
|
%var = OpVariable %var_ty Function)" << ACCheck(ac, "%i", "%[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -425,11 +425,11 @@ TEST_F(GraphicsRobustAccessTest, ACVectorGeneralULongClamped) {
|
|
|
<< MainPrefix() << R"(
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-NOT: = OpTypeInt 32
|
|
|
- ; CHECK-DAG: %ulong_0 = OpConstant %ulong 0
|
|
|
- ; CHECK-DAG: %ulong_3 = OpConstant %ulong 3
|
|
|
+ ; CHECK-DAG: %long_0 = OpConstant %long 0
|
|
|
+ ; CHECK-DAG: %long_3 = OpConstant %long 3
|
|
|
; CHECK-NOT: = OpTypeInt 32
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] UClamp %i %ulong_0 %ulong_3
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] SClamp %i %long_0 %long_3
|
|
|
%var = OpVariable %var_ty Function)" << ACCheck(ac, "%i", "%[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -486,10 +486,9 @@ TEST_F(GraphicsRobustAccessTest, ACMatrixExcessConstantClamped) {
|
|
|
%uint_1 = OpConstant %uint 1
|
|
|
%uint_4 = OpConstant %uint 4
|
|
|
)" << MainPrefix() << R"(
|
|
|
- ; CHECK: %uint_3 = OpConstant %uint 3
|
|
|
+ ; CHECK: %int_3 = OpConstant %int 3
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
- << ACCheck(ac, "%uint_4 %uint_1", "%uint_3 %uint_1")
|
|
|
- << MainSuffix();
|
|
|
+ << ACCheck(ac, "%uint_4 %uint_1", "%int_3 %uint_1") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
}
|
|
|
}
|
|
|
@@ -529,7 +528,7 @@ TEST_F(GraphicsRobustAccessTest, ACMatrixGeneralClamped) {
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_3 = OpConstant %int 3
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %int_3
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %int_3
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i %uint_1", "%[[clamp]] %uint_1") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -585,7 +584,7 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralClamped) {
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_199 = OpConstant %int 199
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %int_199
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %int_199
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -606,11 +605,11 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralShortIndexUIntBoundsClamped) {
|
|
|
%i = OpUndef %short
|
|
|
)" << MainPrefix() << R"(
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
- ; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
- ; CHECK-DAG: %uint_69999 = OpConstant %uint 69999
|
|
|
+ ; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
+ ; CHECK-DAG: %int_69999 = OpConstant %int 69999
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[i_ext:\w+]] = OpSConvert %uint %i
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %[[i_ext]] %uint_0 %uint_69999
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %[[i_ext]] %int_0 %int_69999
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -631,11 +630,11 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralUShortIndexIntBoundsClamped) {
|
|
|
%i = OpUndef %ushort
|
|
|
)" << MainPrefix() << R"(
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
- ; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
- ; CHECK-DAG: %uint_69999 = OpConstant %uint 69999
|
|
|
+ ; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
+ ; CHECK-DAG: %int_69999 = OpConstant %int 69999
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[i_ext:\w+]] = OpUConvert %uint %i
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %[[i_ext]] %uint_0 %uint_69999
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %[[i_ext]] %int_0 %int_69999
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -656,10 +655,10 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralUIntIndexShortBoundsClamped) {
|
|
|
%i = OpUndef %uint
|
|
|
)" << MainPrefix() << R"(
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
- ; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
- ; CHECK-DAG: %uint_199 = OpConstant %uint 199
|
|
|
+ ; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
+ ; CHECK-DAG: %int_199 = OpConstant %int 199
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %i %uint_0 %uint_199
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %i %int_0 %int_199
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -683,7 +682,7 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralIntIndexUShortBoundsClamped) {
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_199 = OpConstant %int 199
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %int_199
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %int_199
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -707,7 +706,7 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralLongIndexUIntBoundsClamped) {
|
|
|
; CHECK-DAG: %long_0 = OpConstant %long 0
|
|
|
; CHECK-DAG: %long_199 = OpConstant %long 199
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %long %[[GLSLSTD450]] UClamp %i %long_0 %long_199
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %long %[[GLSLSTD450]] SClamp %i %long_0 %long_199
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -728,16 +727,91 @@ TEST_F(GraphicsRobustAccessTest, ACArrayGeneralULongIndexIntBoundsClamped) {
|
|
|
%i = OpUndef %ulong
|
|
|
)" << MainPrefix() << R"(
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
- ; CHECK-DAG: %ulong_0 = OpConstant %ulong 0
|
|
|
- ; CHECK-DAG: %ulong_199 = OpConstant %ulong 199
|
|
|
+ ; CHECK-DAG: %long_0 = OpConstant %long 0
|
|
|
+ ; CHECK-DAG: %long_199 = OpConstant %long 199
|
|
|
+ ; CHECK: OpLabel
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] SClamp %i %long_0 %long_199
|
|
|
+ %var = OpVariable %var_ty Function)"
|
|
|
+ << ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
+ SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(GraphicsRobustAccessTest,
|
|
|
+ ACArrayGeneralShortIndeArrayBiggerThanShortMaxClipsToShortIntMax) {
|
|
|
+ for (auto* ac : AccessChains()) {
|
|
|
+ std::ostringstream shaders;
|
|
|
+ shaders << "OpCapability Int16\n"
|
|
|
+ << ShaderPreambleAC({"i"}) << TypesVoid() << TypesShort()
|
|
|
+ << TypesInt() << TypesFloat() << R"(
|
|
|
+ %uint_50000 = OpConstant %uint 50000
|
|
|
+ %arr = OpTypeArray %float %uint_50000
|
|
|
+ %var_ty = OpTypePointer Function %arr
|
|
|
+ %ptr_ty = OpTypePointer Function %float
|
|
|
+ %i = OpUndef %ushort
|
|
|
+ )" << MainPrefix() << R"(
|
|
|
+ ; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
+ ; CHECK-DAG: %short_0 = OpConstant %short 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %short 32767
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] UClamp %i %ulong_0 %ulong_199
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %ushort %[[GLSLSTD450]] SClamp %i %short_0 %[[intmax]]
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+TEST_F(GraphicsRobustAccessTest,
|
|
|
+ ACArrayGeneralIntIndexArrayBiggerThanIntMaxClipsToSignedIntMax) {
|
|
|
+ for (auto* ac : AccessChains()) {
|
|
|
+ std::ostringstream shaders;
|
|
|
+ shaders << ShaderPreambleAC({"i"}) << TypesVoid() << TypesInt()
|
|
|
+ << TypesFloat() << R"(
|
|
|
+ %uint_3000000000 = OpConstant %uint 3000000000
|
|
|
+ %arr = OpTypeArray %float %uint_3000000000
|
|
|
+ %var_ty = OpTypePointer Function %arr
|
|
|
+ %ptr_ty = OpTypePointer Function %float
|
|
|
+ %i = OpUndef %uint
|
|
|
+ )" << MainPrefix() << R"(
|
|
|
+ ; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
+ ; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
+ ; CHECK: OpLabel
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %i %int_0 %[[intmax]]
|
|
|
+ %var = OpVariable %var_ty Function)"
|
|
|
+ << ACCheck(ac, "%i", "%[[clamp]]") << MainSuffix();
|
|
|
+ SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(GraphicsRobustAccessTest,
|
|
|
+ ACArrayGeneralLongIndexArrayBiggerThanLongMaxClipsToSignedLongMax) {
|
|
|
+ for (auto* ac : AccessChains()) {
|
|
|
+ std::ostringstream shaders;
|
|
|
+ shaders << "OpCapability Int64\n"
|
|
|
+ << ShaderPreambleAC({"i"}) << TypesVoid() << TypesInt()
|
|
|
+ << TypesLong()
|
|
|
+ << TypesFloat()
|
|
|
+ // 2^63 == 9,223,372,036,854,775,807
|
|
|
+ << R"(
|
|
|
+ %ulong_9223372036854775999 = OpConstant %ulong 9223372036854775999
|
|
|
+ %arr = OpTypeArray %float %ulong_9223372036854775999
|
|
|
+ %var_ty = OpTypePointer Function %arr
|
|
|
+ %ptr_ty = OpTypePointer Function %float
|
|
|
+ %i = OpUndef %ulong
|
|
|
+ )"
|
|
|
+ << MainPrefix() << R"(
|
|
|
+ ; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
+ ; CHECK-DAG: %long_0 = OpConstant %long 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %long 9223372036854775807
|
|
|
+ ; CHECK: OpLabel
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] SClamp %i %long_0 %[[intmax]]
|
|
|
+ %var = OpVariable %var_ty Function)" << ACCheck(ac, "%i", "%[[clamp]]")
|
|
|
+ << MainSuffix();
|
|
|
+ SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
TEST_F(GraphicsRobustAccessTest, ACArraySpecIdSizedAlwaysClamped) {
|
|
|
for (auto* ac : AccessChains()) {
|
|
|
std::ostringstream shaders;
|
|
|
@@ -753,9 +827,11 @@ TEST_F(GraphicsRobustAccessTest, ACArraySpecIdSizedAlwaysClamped) {
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
; CHECK-DAG: %uint_1 = OpConstant %uint 1
|
|
|
+ ; CHECK-DAG: %[[uint_intmax:\w+]] = OpConstant %uint 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[max:\w+]] = OpISub %uint %spec200 %uint_1
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %uint_5 %uint_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UMin %[[max]] %[[uint_intmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %uint_5 %uint_0 %[[smin]]
|
|
|
%var = OpVariable %var_ty Function)"
|
|
|
<< ACCheck(ac, "%uint_5", "%[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -908,11 +984,13 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayLeastInboundClamped) {
|
|
|
%int_0 = OpConstant %int 0
|
|
|
%int_2 = OpConstant %int 2
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
- ; CHECK: %int_1 = OpConstant %int 1
|
|
|
+ ; CHECK-DAG: %int_1 = OpConstant %int 1
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %int %[[arrlen]] %int_1
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %int_0 %int_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %int %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %int_0 %int_0 %[[smin]]
|
|
|
)"
|
|
|
<< MainPrefix() << ACCheck(ac, "%int_2 %int_0", "%int_2 %[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
@@ -937,11 +1015,13 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayGeneralShortIndexClamped) {
|
|
|
; CHECK: %uint = OpTypeInt 32 0
|
|
|
; CHECK-DAG: %uint_1 = OpConstant %uint 1
|
|
|
; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %uint 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK-DAG: %[[max:\w+]] = OpISub %uint %[[arrlen]] %uint_1
|
|
|
; CHECK-DAG: %[[i_ext:\w+]] = OpSConvert %uint %i
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %[[i_ext]] %uint_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %[[i_ext]] %uint_0 %[[smin]]
|
|
|
)"
|
|
|
<< MainPrefix() << ACCheck(ac, "%short_2 %i", "%short_2 %[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
@@ -966,11 +1046,13 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayGeneralUShortIndexClamped) {
|
|
|
; CHECK: %uint = OpTypeInt 32 0
|
|
|
; CHECK-DAG: %uint_1 = OpConstant %uint 1
|
|
|
; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %uint 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK-DAG: %[[max:\w+]] = OpISub %uint %[[arrlen]] %uint_1
|
|
|
; CHECK-DAG: %[[i_ext:\w+]] = OpSConvert %uint %i
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %[[i_ext]] %uint_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %[[i_ext]] %uint_0 %[[smin]]
|
|
|
)"
|
|
|
<< MainPrefix() << ACCheck(ac, "%short_2 %i", "%short_2 %[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
@@ -993,10 +1075,12 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayGeneralIntIndexClamped) {
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-DAG: %int_1 = OpConstant %int 1
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %int %[[arrlen]] %int_1
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %int %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %[[smin]]
|
|
|
)"
|
|
|
<< MainPrefix() << ACCheck(ac, "%int_2 %i", "%int_2 %[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
@@ -1019,10 +1103,12 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayGeneralUIntIndexClamped) {
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-DAG: %uint_1 = OpConstant %uint 1
|
|
|
; CHECK-DAG: %uint_0 = OpConstant %uint 0
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %uint 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %uint %[[arrlen]] %uint_1
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UClamp %i %uint_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %uint %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %uint %[[GLSLSTD450]] SClamp %i %uint_0 %[[smin]]
|
|
|
)"
|
|
|
<< MainPrefix() << ACCheck(ac, "%int_2 %i", "%int_2 %[[clamp]]")
|
|
|
<< MainSuffix();
|
|
|
@@ -1046,11 +1132,13 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayGeneralLongIndexClamped) {
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-DAG: %long_0 = OpConstant %long 0
|
|
|
; CHECK-DAG: %long_1 = OpConstant %long 1
|
|
|
+ ; CHECK-DAG: %[[longmax:\w+]] = OpConstant %long 9223372036854775807
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK: %[[arrlen_ext:\w+]] = OpUConvert %ulong %[[arrlen]]
|
|
|
; CHECK: %[[max:\w+]] = OpISub %long %[[arrlen_ext]] %long_1
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %long %[[GLSLSTD450]] UClamp %i %long_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %long %[[GLSLSTD450]] UMin %[[max]] %[[longmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %long %[[GLSLSTD450]] SClamp %i %long_0 %[[smin]]
|
|
|
)" << MainPrefix()
|
|
|
<< ACCheck(ac, "%int_2 %i", "%int_2 %[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -1073,11 +1161,13 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayGeneralULongIndexClamped) {
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-DAG: %ulong_0 = OpConstant %ulong 0
|
|
|
; CHECK-DAG: %ulong_1 = OpConstant %ulong 1
|
|
|
+ ; CHECK-DAG: %[[longmax:\w+]] = OpConstant %ulong 9223372036854775807
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK: %[[arrlen_ext:\w+]] = OpUConvert %ulong %[[arrlen]]
|
|
|
; CHECK: %[[max:\w+]] = OpISub %ulong %[[arrlen_ext]] %ulong_1
|
|
|
- ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] UClamp %i %ulong_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] UMin %[[max]] %[[longmax]]
|
|
|
+ ; CHECK: %[[clamp:\w+]] = OpExtInst %ulong %[[GLSLSTD450]] SClamp %i %ulong_0 %[[smin]]
|
|
|
)" << MainPrefix()
|
|
|
<< ACCheck(ac, "%int_2 %i", "%int_2 %[[clamp]]") << MainSuffix();
|
|
|
SinglePassRunAndMatch<GraphicsRobustAccessPass>(shaders.str(), true);
|
|
|
@@ -1109,11 +1199,13 @@ TEST_F(GraphicsRobustAccessTest, ACRTArrayStructVectorElem) {
|
|
|
; CHECK: %[[GLSLSTD450:\w+]] = OpExtInstImport "GLSL.std.450"
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_3 = OpConstant %int 3
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %var 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %int %[[arrlen]] %int_1
|
|
|
- ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %[[max]]
|
|
|
- ; CHECK: %[[clamp_j:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %j %int_0 %int_3
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %int %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %[[smin]]
|
|
|
+ ; CHECK: %[[clamp_j:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %j %int_0 %int_3
|
|
|
)" << MainPrefix()
|
|
|
<< ACCheck(ac, "%int_2 %i %int_1 %j",
|
|
|
"%int_2 %[[clamp_i]] %int_1 %[[clamp_j]]")
|
|
|
@@ -1148,6 +1240,7 @@ TEST_F(GraphicsRobustAccessTest, ACArrayRTArrayStructVectorElem) {
|
|
|
; CHECK-DAG: %[[ssbo_p:\w+]] = OpTypePointer Uniform %ssbo_s
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_9 = OpConstant %int 9
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
; This access chain is manufatured only so we can compute the array length.
|
|
|
; Note that the %int_9 is already clamped
|
|
|
@@ -1155,7 +1248,8 @@ TEST_F(GraphicsRobustAccessTest, ACArrayRTArrayStructVectorElem) {
|
|
|
<< R"( %[[ssbo_p]] %var %int_9
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %[[ssbo_base]] 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %int %[[arrlen]] %int_1
|
|
|
- ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %[[max]]
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %int %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %[[smin]]
|
|
|
)" << MainPrefix()
|
|
|
<< ACCheck(ac, "%int_17 %int_2 %i %int_1 %int_2",
|
|
|
"%int_9 %int_2 %[[clamp_i]] %int_1 %int_2")
|
|
|
@@ -1195,8 +1289,9 @@ TEST_F(GraphicsRobustAccessTest, ACSplitACArrayRTArrayStructVectorElem) {
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_9 = OpConstant %int 9
|
|
|
; CHECK-DAG: %int_3 = OpConstant %int 3
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %int_9
|
|
|
+ ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %int_9
|
|
|
; CHECK: %ac_ssbo = )" << ac
|
|
|
<< R"( %ssbo_pty %var %[[clamp_i]]
|
|
|
; CHECK: %ac_rtarr = )"
|
|
|
@@ -1207,8 +1302,9 @@ TEST_F(GraphicsRobustAccessTest, ACSplitACArrayRTArrayStructVectorElem) {
|
|
|
; definition to find the base pointer %ac_ssbo.
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %ac_ssbo 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %int %[[arrlen]] %int_1
|
|
|
- ; CHECK: %[[clamp_j:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %j %int_0 %[[max]]
|
|
|
- ; CHECK: %[[clamp_k:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %k %int_0 %int_3
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %int %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp_j:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %j %int_0 %[[smin]]
|
|
|
+ ; CHECK: %[[clamp_k:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %k %int_0 %int_3
|
|
|
; CHECK: %ac = )" << ac
|
|
|
<< R"( %ptr_ty %ac_rtarr %[[clamp_j]] %int_1 %[[clamp_k]]
|
|
|
; CHECK-NOT: AccessChain
|
|
|
@@ -1258,8 +1354,9 @@ TEST_F(GraphicsRobustAccessTest,
|
|
|
; CHECK-DAG: %int_0 = OpConstant %int 0
|
|
|
; CHECK-DAG: %int_9 = OpConstant %int 9
|
|
|
; CHECK-DAG: %int_3 = OpConstant %int 3
|
|
|
+ ; CHECK-DAG: %[[intmax:\w+]] = OpConstant %int 2147483647
|
|
|
; CHECK: OpLabel
|
|
|
- ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %i %int_0 %int_9
|
|
|
+ ; CHECK: %[[clamp_i:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %i %int_0 %int_9
|
|
|
; CHECK: %ac_ssbo = )" << ac
|
|
|
<< R"( %ssbo_pty %var %[[clamp_i]]
|
|
|
; CHECK: %bb1 = OpLabel
|
|
|
@@ -1272,8 +1369,9 @@ TEST_F(GraphicsRobustAccessTest,
|
|
|
; definition to find the base pointer %ac_ssbo.
|
|
|
; CHECK: %[[arrlen:\w+]] = OpArrayLength %uint %ac_ssbo 2
|
|
|
; CHECK: %[[max:\w+]] = OpISub %int %[[arrlen]] %int_1
|
|
|
- ; CHECK: %[[clamp_j:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %j %int_0 %[[max]]
|
|
|
- ; CHECK: %[[clamp_k:\w+]] = OpExtInst %int %[[GLSLSTD450]] UClamp %k %int_0 %int_3
|
|
|
+ ; CHECK: %[[smin:\w+]] = OpExtInst %int %[[GLSLSTD450]] UMin %[[max]] %[[intmax]]
|
|
|
+ ; CHECK: %[[clamp_j:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %j %int_0 %[[smin]]
|
|
|
+ ; CHECK: %[[clamp_k:\w+]] = OpExtInst %int %[[GLSLSTD450]] SClamp %k %int_0 %int_3
|
|
|
; CHECK: %ac = )" << ac
|
|
|
<< R"( %ptr_ty %ac_rtarr %[[clamp_j]] %int_1 %[[clamp_k]]
|
|
|
; CHECK-NOT: AccessChain
|