[Mlir-commits] [mlir] [mlir][spirv] Add definition for ImageWriteOp (PR #124124)

Igor Wodiany llvmlistbot at llvm.org
Thu Feb 6 02:23:14 PST 2025


================
@@ -135,6 +135,58 @@ def SPIRV_ImageQuerySizeOp : SPIRV_Op<"ImageQuerySize", [Pure]> {
 
 // -----
 
+def SPIRV_ImageWriteOp : SPIRV_Op<"ImageWrite", []> {
+  let summary = "Write a texel to an image without a sampler.";
+
+  let description = [{
+    Image must be an object whose type is OpTypeImage with a Sampled operand
+    of 0 or 2. If the Arrayed operand is 1, then additional capabilities may
+    be required; e.g., ImageCubeArray, or ImageMSArray. Its Dim operand
+    must not be SubpassData.
+
+    Coordinate must be a scalar or vector of floating-point type or integer
+    type. It contains non-normalized texel coordinates (u[, v] ... [, array
+    layer]) as needed by the definition of Image. See the client API
+    specification for handling of coordinates outside the image.
+
+    Texel is the data to write. It must be a scalar or vector with component
+    type the same as Sampled Type of the OpTypeImage (unless that Sampled
+    Type is OpTypeVoid).
+
+    The Image Format must not be Unknown, unless the
+    StorageImageWriteWithoutFormat Capability was declared.
+
+    Image Operands encodes what operands follow, as per Image Operands.
+
+    <!-- End of AutoGen section -->
+
+    #### Example:
+
+    ```mlir
+    spirv.ImageWrite %0 : !spirv.image<f32, Dim2D, NoDepth, NonArrayed, SingleSampled, NoSampler, Rgba16>, %1 : vector<2xsi32>, %2 : vector<4xf32>
----------------
IgWod-IMG wrote:

I agree, I noticed the inconsistency, but I decided to match existing image ops. There are few more image ops that are on my todo list and I actually started cleaning things up. For example, I am moving all image ops verification from `mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp` into a separate file. So, I'll clean up the syntax as well as a part of that.

https://github.com/llvm/llvm-project/pull/124124


More information about the Mlir-commits mailing list