spirv_std

Macro Image

Source
Image!() { /* proc-macro */ }
Expand description

A macro for creating SPIR-V OpTypeImage types. Always produces a spirv_std::image::Image<...> type.

The grammar for the macro is as follows:

Image!(
    <dimensionality>,
    <type=...|format=...>,
    [sampled[=<true|false>],]
    [multisampled[=<true|false>],]
    [arrayed[=<true|false>],]
    [depth[=<true|false>],]
)

=true can be omitted as shorthand - e.g. sampled is short for sampled=true.

A basic example looks like this:

#[spirv(vertex)]
fn main(#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled)) {}

§Arguments

  • dimensionality — Dimensionality of an image. Accepted values: 1D, 2D, 3D, rect, cube, subpass.
  • type — The sampled type of an image, mutually exclusive with format, when set the image format is unknown. Accepted values: f32, f64, u8, u16, u32, u64, i8, i16, i32, i64.
  • format — The image format of the image, mutually exclusive with type. Accepted values: Snake case versions of ImageFormat.
  • sampled — Whether it is known that the image will be used with a sampler. Accepted values: true or false. Default: unknown.
  • multisampled — Whether the image contains multisampled content. Accepted values: true or false. Default: false.
  • arrayed — Whether the image contains arrayed content. Accepted values: true or false. Default: false.
  • depth — Whether it is known that the image is a depth image. Accepted values: true or false. Default: unknown.

Keep in mind that sampled here is a different concept than the SampledImage type: sampled=true means that this image requires a sampler to be able to access, while the SampledImage type bundles that sampler together with the image into a single type (e.g. sampler2D in GLSL, vs. texture2D).