writer/spirv: Use ConstOffset instead of Offsets
Offset requires the ImageGatherExtended capability, where as ConstOffset does not. WGSL enforces the offset range required by SPIRV.
Bug: tint:143
Change-Id: Ia098010ecdb8a4a01999b4e9a6faabf3f4d1251f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37447
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 68ca025..aca2eb4 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -2263,7 +2263,7 @@
if (pidx.offset != kNotUsed) {
image_operands.emplace_back(
- ImageOperand{SpvImageOperandsOffsetMask, gen_param(pidx.offset)});
+ ImageOperand{SpvImageOperandsConstOffsetMask, gen_param(pidx.offset)});
}
if (!image_operands.empty()) {
diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc
index a86ccb2..ae0725f 100644
--- a/src/writer/spirv/builder_intrinsic_texture_test.cc
+++ b/src/writer/spirv/builder_intrinsic_texture_test.cc
@@ -838,7 +838,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleImplicitLod %9 %13 %17 Offset %22
+%8 = OpImageSampleImplicitLod %9 %13 %17 ConstOffset %22
)",
R"(
)"};
@@ -898,7 +898,7 @@
%13 = OpSampledImage %12 %11 %10
%17 = OpConvertSToF %4 %19
%20 = OpCompositeConstruct %14 %15 %16 %17
-%8 = OpImageSampleImplicitLod %9 %13 %20 Offset %24
+%8 = OpImageSampleImplicitLod %9 %13 %20 ConstOffset %24
)",
R"(
)"};
@@ -956,7 +956,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleImplicitLod %9 %13 %18 Offset %24
+%8 = OpImageSampleImplicitLod %9 %13 %18 ConstOffset %24
)",
R"(
)"};
@@ -1064,7 +1064,7 @@
%9 = OpLoad %7 %5
%10 = OpLoad %3 %1
%12 = OpSampledImage %11 %10 %9
-%8 = OpImageSampleImplicitLod %4 %12 %16 Offset %21
+%8 = OpImageSampleImplicitLod %4 %12 %16 ConstOffset %21
)",
R"(
)"};
@@ -1122,7 +1122,7 @@
%12 = OpSampledImage %11 %10 %9
%16 = OpConvertSToF %4 %18
%19 = OpCompositeConstruct %13 %14 %15 %16
-%8 = OpImageSampleImplicitLod %4 %12 %19 Offset %23
+%8 = OpImageSampleImplicitLod %4 %12 %19 ConstOffset %23
)",
R"(
)"};
@@ -1233,7 +1233,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleImplicitLod %9 %13 %17 Bias|Offset %18 %23
+%8 = OpImageSampleImplicitLod %9 %13 %17 Bias|ConstOffset %18 %23
)",
R"(
)"};
@@ -1295,7 +1295,7 @@
%13 = OpSampledImage %12 %11 %10
%17 = OpConvertSToF %4 %19
%20 = OpCompositeConstruct %14 %15 %16 %17
-%8 = OpImageSampleImplicitLod %9 %13 %20 Bias|Offset %21 %25
+%8 = OpImageSampleImplicitLod %9 %13 %20 Bias|ConstOffset %21 %25
)",
R"(
)"};
@@ -1355,7 +1355,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleImplicitLod %9 %13 %18 Bias|Offset %19 %25
+%8 = OpImageSampleImplicitLod %9 %13 %18 Bias|ConstOffset %19 %25
)",
R"(
)"};
@@ -1469,7 +1469,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleExplicitLod %9 %13 %17 Lod|Offset %18 %23
+%8 = OpImageSampleExplicitLod %9 %13 %17 Lod|ConstOffset %18 %23
)",
R"(
)"};
@@ -1531,7 +1531,7 @@
%13 = OpSampledImage %12 %11 %10
%17 = OpConvertSToF %4 %19
%20 = OpCompositeConstruct %14 %15 %16 %17
-%8 = OpImageSampleExplicitLod %9 %13 %20 Lod|Offset %21 %25
+%8 = OpImageSampleExplicitLod %9 %13 %20 Lod|ConstOffset %21 %25
)",
R"(
)"};
@@ -1591,7 +1591,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleExplicitLod %9 %13 %18 Lod|Offset %19 %25
+%8 = OpImageSampleExplicitLod %9 %13 %18 Lod|ConstOffset %19 %25
)",
R"(
)"};
@@ -1704,7 +1704,7 @@
%9 = OpLoad %7 %5
%10 = OpLoad %3 %1
%12 = OpSampledImage %11 %10 %9
-%8 = OpImageSampleExplicitLod %4 %12 %16 Lod|Offset %18 %22
+%8 = OpImageSampleExplicitLod %4 %12 %16 Lod|ConstOffset %18 %22
)",
R"(
)"};
@@ -1764,7 +1764,7 @@
%12 = OpSampledImage %11 %10 %9
%16 = OpConvertSToF %4 %18
%19 = OpCompositeConstruct %13 %14 %15 %16
-%8 = OpImageSampleExplicitLod %4 %12 %19 Lod|Offset %20 %24
+%8 = OpImageSampleExplicitLod %4 %12 %19 Lod|ConstOffset %20 %24
)",
R"(
)"};
@@ -1888,7 +1888,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleExplicitLod %9 %13 %17 Grad|Offset %20 %23 %28
+%8 = OpImageSampleExplicitLod %9 %13 %17 Grad|ConstOffset %20 %23 %28
)",
R"(
)"};
@@ -1962,7 +1962,7 @@
%13 = OpSampledImage %12 %11 %10
%17 = OpConvertSToF %4 %19
%20 = OpCompositeConstruct %14 %15 %16 %17
-%8 = OpImageSampleExplicitLod %9 %13 %20 Grad|Offset %24 %27 %31
+%8 = OpImageSampleExplicitLod %9 %13 %20 Grad|ConstOffset %24 %27 %31
)",
R"(
)"};
@@ -2036,7 +2036,7 @@
%10 = OpLoad %7 %5
%11 = OpLoad %3 %1
%13 = OpSampledImage %12 %11 %10
-%8 = OpImageSampleExplicitLod %9 %13 %18 Grad|Offset %22 %26 %32
+%8 = OpImageSampleExplicitLod %9 %13 %18 Grad|ConstOffset %22 %26 %32
)",
R"(
)"};
@@ -2165,7 +2165,7 @@
%9 = OpLoad %7 %5
%10 = OpLoad %3 %1
%12 = OpSampledImage %11 %10 %9
-%8 = OpImageSampleDrefExplicitLod %4 %12 %16 %17 Lod|Offset %18 %23
+%8 = OpImageSampleDrefExplicitLod %4 %12 %16 %17 Lod|ConstOffset %18 %23
)",
R"(
)"};
@@ -2227,7 +2227,7 @@
%12 = OpSampledImage %11 %10 %9
%16 = OpConvertSToF %4 %18
%19 = OpCompositeConstruct %13 %14 %15 %16
-%8 = OpImageSampleDrefExplicitLod %4 %12 %19 %20 Lod|Offset %21 %25
+%8 = OpImageSampleDrefExplicitLod %4 %12 %19 %20 Lod|ConstOffset %21 %25
)",
R"(
)"};