Skip to content

[naga wgsl-in wgsl-out] WGSL support for texture_external texture type #7822

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

jamienicol
Copy link
Contributor

Connections
Part of #4386

Description
Make wgsl-in correctly parse texture_external texture declarations, and allow such textures to be used in textureDimensions(), textureSampleBaseClampToEdge(), and textureLoad() function calls. In IR these are represented by the ImageClass::External image class, which is a 2D, non-multisampled, non-mipmapped, float-sampled image.

Adds a new Capability TEXTURE_EXTERNAL and ensure validation rejects shaders containing external textures if this capability flag is not set. This capability is enabled for validation by wgpu devices which support the TEXTURE_EXTERNAL feature (currently only when using the noop backend), and by the Naga CLI when validating-only or when outputting WGSL.

The WGSL backend can of course emit ImageClass::External images directly as texture_external textures. Other backends are, for now, unimplemented.

Lastly, we add a snapshot test covering all the valid uses of a texture_external texture. These are:

  • As a global variable declaration
  • As an argument to the built-in functions textureDimensions(), textureSampleBaseClampToEdge(), and textureLoad()
  • As an argument to user-defined function declarations and calls.

We keep these in their own test so that we can control which targets to run them against (currently WGSL and IR). When external textures are supported by all Naga backends we can, if so inclined, integrate these with existing texture tests.

Testing
Snapshot test

Squash or Rebase?
Either. But if squashing make sure the commit message is tidy

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

I don't think this by itself deserves a changelog entry - when we add at least one non-wgsl backend that would be more noteworthy

Make wgsl-in correctly parse `texture_external` texture declarations,
and allow such textures to be used in `textureDimensions()`,
`textureSampleBaseClampToEdge()`, and `textureLoad()` function
calls. In IR these are represented by the `ImageClass::External` image
class, which is a 2D, non-multisampled, non-mipmapped, float-sampled
image.

Adds a new Capability `TEXTURE_EXTERNAL` and ensure validation rejects
shaders containing external textures if this capability flag is not
set. This capability is enabled for validation by wgpu devices which
support the `TEXTURE_EXTERNAL` feature (currently only when using the
noop backend), and by the Naga CLI when validating-only or when
outputting WGSL.

The WGSL backend can of course emit `ImageClass::External` images
directly as `texture_external` textures. Other backends are, for now,
unimplemented.

Lastly, we add a snapshot test covering all the valid uses of a
texture_external texture. These are:
  - As a global variable declaration
  - As an argument to the built-in functions `textureDimensions()`,
    `textureSampleBaseClampToEdge()`, and `textureLoad()`
  - As an argument to user-defined function declarations and calls.

We keep these in their own test so that we can control which targets
to run them against (currently WGSL and IR). When external textures
are supported by all Naga backends we can, if so inclined, integrate
these with existing texture tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants