-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[spv-in] Improve detection of ImageClass #8758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
[spv-in] Improve detection of ImageClass #8758
Conversation
40a43b5 to
b01e594
Compare
b01e594 to
ff3764f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the SPIR-V input frontend's detection of ImageClass to correctly handle cases where textures have explicit formats specified (e.g., Texture2D<uint> in Slang generating R32Uint format). The fix refines the logic for determining whether an image is a storage texture, sampled texture, or depth texture based on the combination of the is_sampled flag and explicit format specification.
Changes:
- Enhanced
ImageClassdetection logic to properly handle unknown sampling information with explicit formats - Improved error messages to distinguish between different multisampling-related validation failures
- Added validation to prevent depth images from being storage textures
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| naga/src/front/spv/mod.rs | Updated ImageClass detection logic to infer storage class from explicit format when sampling info is unknown |
| naga/src/front/spv/error.rs | Renamed error variant and added new error for depth+storage combination |
| naga/src/valid/expression.rs | Split InvalidImageOtherIndex into two specific errors and added debug statement |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| _ => { | ||
| e => { | ||
| std::dbg!(e, class); |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement (std::dbg!) should be removed before merging. This appears to be leftover debugging code that will pollute stderr output in production.
| std::dbg!(e, class); |
Wumpf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, great errors. but leftover dbg needs to go. Pre-approving
| }, | ||
| _ => { | ||
| e => { | ||
| std::dbg!(e, class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover dbg
Small thing I found that if you write
Texture2D<uint>in slang, it will add a format of R32Uint to the image, which tripped up our detection. This makes the behavior better. If anyone runs into this and doesn't have this patch, add [[vk::image_format("unknown")]] and it will generate the spirv we expect.