Rust-GPU / Rust-GPU/rust-gpu

[Migrated] Supporting Image Operands in spirv-std

Open
#137 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/364
Old labels: t: enhancement,c: spirv-std,a: image
Originally creatd by XAMPPRocky on 2021-01-05T12:34:20Z


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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked SPIR-V Image Operands specification and reviewing the existing spirv-std image-operation APIs. Determine how optional operands and constraints should be represented at the Rust level, including the Grad operand's vector or scalar lengths. Done means a settled API and validation design for the supported image operands.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.