-
Notifications
You must be signed in to change notification settings - Fork 249
Supporting Image Operands in spirv-std #364
Description
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.