Rust-GPU / Rust-GPU/rust-gpu

[Migrated] Image macro doesn't fully enforce valid use of non-sampled storage images

Open
#116 2 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/812
Old labels: t: bug,s: blocked
Originally creatd by fu5ha on 2021-11-29T20:17:40Z


Currently, if we create an image type with the image macro as such:

Image!(2D, type=f32, sampled=false),

the image will still be able to be .read/.fetched, and the spirv Image object won't be decorated as NonReadable. However, according to vulkan spec, "If shaderStorageImageReadWithoutFormat is not enabled, any variable created with a "Type" of OpTypeImage that has a "Sampled" operand of 2 and an "Image Format" operand of Unknown must be decorated with NonReadable."

This can be solved for now by just using an explicit format=blah in the Image macro instead of type, but I think we could also handle this/validate it in the macro automatically. I think the best way forward would be:

  • Make a readable flag in the macro which gets auto-disabled under the above conditions, and when disabled, decorates the OpTypeImage with NonReadable and doesn't allow to do .read/.fetch on the Image.
  • However, if it is manually enabled, then we do the current behavior, allowing read etc. (assuming shaderStorageImageReadWithoutFormat is enabled).

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 at the Image macro and trace how type, sampled=false, and .read/.fetch affect the generated OpTypeImage. Check how NonReadable is emitted and how read operations are permitted. Done means invalid non-sampled storage images are marked NonReadable and cannot be read unless explicitly enabled, with behavior checked against the Vulkan rule described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.