Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Supporting Image Operands in spirv-std #364

@XAMPPRocky

Description

@XAMPPRocky

A lot of image operations (mainly those around sampling, or getting/setting texels from images) support additional optional operands. At the SPIR-V level this comes in the form of an operand at the end of each instruction which is a 8 bit integer that acts as a bit mask for indicating the how many operands follow and what they are used for. Additionally certain operands can only be used with certain image parameters, (such as the Bias operand only being available for single sampled 1D, 2D, 3D, and Cube image.)

The question becomes how to best support using these operands at the Rust level and validate these constraints.

Possibilities

  • Have a different function for each operand.
    • Advantage Simplest to implement.
    • Drawback Requires dozens if not hundreds of functions to cover every possible combination for each instruction, leading to a lot of repetition.
  • Use const generics on the functions for each instruction.
    • Advantage Potential to avoid a lot of repetition
    • Drawback Unclear how generic it could be at this point.

One example of where it's unclear with constant generics is the Grad operand. Which allows you to pass 2 vectors or scalars of the same size as the Dim, so right now I'm unsure how we'd allow that to generically while also validating the length.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: imageIssues related to image operations in SPIR-V.c: spirv-stdIssues specific to the spirv-std cratet: enhancementA new feature or improvement to an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions