spirv-reader: test texture builtins over arrayed textures
Tested:
- textureSample
- textureSampleBias
- textureSampleLevel
- textureSampleGrad
- textureSampleCompare
Fixed: tint:349
Change-Id: Ibb45883b88c8eeec6ba40170f47d78613e150db7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34102
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc
index 2ac81ba..baa1d10 100644
--- a/src/reader/spirv/parser_impl_handle_test.cc
+++ b/src/reader/spirv/parser_impl_handle_test.cc
@@ -1333,6 +1333,49 @@
)
})"},
+ // OpImageSampleImplicitLod arrayed
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleImplicitLod "
+ "%v4float %sampled_image %coords123",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSample}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ )
+ })"},
+
// OpImageSampleImplicitLod with ConstOffset
SampledImageCase{
"%float 2D 0 0 0 1 Unknown",
@@ -1368,6 +1411,51 @@
)
})"},
+ // OpImageSampleImplicitLod arrayed with ConstOffset
+ SampledImageCase{
+ "%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleImplicitLod "
+ "%v4float %sampled_image %coords123 ConstOffset %offsets2d",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSample}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ Identifier[not set]{offsets2d}
+ )
+ })"},
+
// OpImageSampleImplicitLod with Bias
SampledImageCase{"%float 2D 0 0 0 1 Unknown",
"%result = OpImageSampleImplicitLod "
@@ -1402,6 +1490,50 @@
)
})"},
+ // OpImageSampleImplicitLod arrayed with Bias
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleImplicitLod "
+ "%v4float %sampled_image %coords123 Bias %float_7",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleBias}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{7.000000}
+ )
+ })"},
+
// OpImageSampleImplicitLod with Bias and ConstOffset
// TODO(dneto): OpImageSampleImplicitLod with Bias and unsigned
// ConstOffset
@@ -1438,6 +1570,51 @@
ScalarConstructor[not set]{7.000000}
Identifier[not set]{offsets2d}
)
+ })"},
+ // OpImageSampleImplicitLod arrayed with Bias
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleImplicitLod "
+ "%v4float %sampled_image %coords123 Bias|ConstOffset "
+ "%float_7 %offsets2d",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleBias}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{7.000000}
+ Identifier[not set]{offsets2d}
+ )
})"}));
INSTANTIATE_TEST_SUITE_P(
@@ -1558,7 +1735,49 @@
ScalarConstructor[not set]{0.200000}
)
})"},
-
+ // ImageSampleDrefImplicitLod - arrayed
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleDrefImplicitLod "
+ "%v4float %sampled_image %coords123 %depth",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_comparison
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __depth_texture_2d_array
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleCompare}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{0.200000}
+ )
+ })"},
// ImageSampleDrefImplicitLod with ConstOffset
SampledImageCase{
"%float 2D 0 0 0 1 Unknown",
@@ -1593,9 +1812,52 @@
ScalarConstructor[not set]{0.200000}
Identifier[not set]{offsets2d}
)
- })"}
-
- ));
+ })"},
+ // ImageSampleDrefImplicitLod arrayed with ConstOffset
+ SampledImageCase{
+ "%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleDrefImplicitLod %v4float "
+ "%sampled_image %coords123 %depth ConstOffset %offsets2d",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_comparison
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __depth_texture_2d_array
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleCompare}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{0.200000}
+ Identifier[not set]{offsets2d}
+ )
+ })"}));
INSTANTIATE_TEST_SUITE_P(
ImageSampleExplicitLod,
@@ -1636,6 +1898,50 @@
)
})"},
+ // OpImageSampleExplicitLod arrayed - using Lod
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleExplicitLod "
+ "%v4float %sampled_image %coords123 Lod %float_null",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleLevel}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{0.000000}
+ )
+ })"},
+
// OpImageSampleExplicitLod - using Lod and ConstOffset
// TODO(dneto) OpImageSampleExplicitLod - using Lod and unsigned
// ConstOffset
@@ -1674,6 +1980,52 @@
)
})"},
+ // OpImageSampleExplicitLod arrayed - using Lod and ConstOffset
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleExplicitLod "
+ "%v4float %sampled_image %coords123 Lod|ConstOffset "
+ "%float_null %offsets2d",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleLevel}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{0.000000}
+ Identifier[not set]{offsets2d}
+ )
+ })"},
+
// OpImageSampleExplicitLod - using Grad
SampledImageCase{
"%float 2D 0 0 0 1 Unknown",
@@ -1710,6 +2062,52 @@
)
})"},
+ // OpImageSampleExplicitLod arrayed - using Grad
+ SampledImageCase{
+ "%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleExplicitLod "
+ "%v4float %sampled_image %coords123 Grad %float_7 %float_null",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleGrad}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{7.000000}
+ ScalarConstructor[not set]{0.000000}
+ )
+ })"},
+
// OpImageSampleExplicitLod - using Grad and ConstOffset
// TODO(dneto): OpImageSampleExplicitLod - using Grad and unsigned
// ConstOffset
@@ -1747,6 +2145,54 @@
ScalarConstructor[not set]{0.000000}
Identifier[not set]{offsets2d}
)
+ })"},
+ // OpImageSampleExplicitLod arrayed - using Grad and ConstOffset
+ // TODO(dneto): OpImageSampleExplicitLod - using Grad and unsigned
+ // ConstOffset
+ SampledImageCase{"%float 2D 0 1 0 1 Unknown",
+ "%result = OpImageSampleExplicitLod "
+ "%v4float %sampled_image %coords123 Grad|ConstOffset "
+ "%float_7 %float_null %offsets2d",
+ R"(
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{0}
+ BindingDecoration{0}
+ }
+ x_10
+ uniform_constant
+ __sampler_sampler
+ }
+ DecoratedVariable{
+ Decorations{
+ SetDecoration{2}
+ BindingDecoration{1}
+ }
+ x_20
+ uniform_constant
+ __sampled_texture_2d_array__f32
+ })",
+ R"(
+ Call[not set]{
+ Identifier[not set]{textureSampleGrad}
+ (
+ Identifier[not set]{x_20}
+ Identifier[not set]{x_10}
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{xy}
+ }
+ TypeConstructor[not set]{
+ __u32
+ MemberAccessor[not set]{
+ Identifier[not set]{coords123}
+ Identifier[not set]{z}
+ }
+ }
+ ScalarConstructor[not set]{7.000000}
+ ScalarConstructor[not set]{0.000000}
+ Identifier[not set]{offsets2d}
+ )
})"}));
struct ImageCoordsCase {