[ir][spirv-writer] Handle texture sample builtins
Use the BuiltinPolyfillSpirv transform to replace texture sample
builtins with calls to SPIR-V intrinsic functions that will create the
`OpSampledImage` and then execute an `OpImageSample*` instruction.
A `LiteralOperand` subclass of `ir::Constant` is used to represent the
literal 'image operands' operand, and a `SampledImage` subclass of
`type::Type` is used to represent the `OpSampledImage` type.
Bug: tint:1906
Change-Id: Id3fd166f1cf5772fd75aed5cbeb8c3c02ea65197
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/141230
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/writer/spirv/ir/test_helper_ir.h b/src/tint/writer/spirv/ir/test_helper_ir.h
index 3d86819..54af5ad 100644
--- a/src/tint/writer/spirv/ir/test_helper_ir.h
+++ b/src/tint/writer/spirv/ir/test_helper_ir.h
@@ -176,19 +176,20 @@
/// Helper to make a scalar value with the scalar type `type`.
/// @param type the element type
+ /// @param value the optional value to use
/// @returns the scalar value
- ir::Value* MakeScalarValue(TestElementType type) {
+ ir::Constant* MakeScalarValue(TestElementType type, uint32_t value = 1) {
switch (type) {
case kBool:
return b.Constant(true);
case kI32:
- return b.Constant(i32(1));
+ return b.Constant(i32(value));
case kU32:
- return b.Constant(u32(1));
+ return b.Constant(u32(value));
case kF32:
- return b.Constant(f32(1));
+ return b.Constant(f32(value));
case kF16:
- return b.Constant(f16(1));
+ return b.Constant(f16(value));
}
return nullptr;
}
@@ -196,7 +197,7 @@
/// Helper to make a vector value with an element type of `type`.
/// @param type the element type
/// @returns the vector value
- ir::Value* MakeVectorValue(TestElementType type) {
+ ir::Constant* MakeVectorValue(TestElementType type) {
switch (type) {
case kBool:
return b.Constant(mod.constant_values.Composite(