Skip to content

Add ExternalTexture BindingType behind new Feature flag #7732

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

@jamienicol jamienicol commented May 28, 2025

Connections
Part of #4386
No dependencies

Description
Adds a new feature flag, EXTERNAL_TEXTURE, indicating device support
for our implementation of WebGPU's GPUExternalTexture [1] which will
land in upcoming patches. Conceptually this would make more sense as a
downlevel flag, as it is a core part of the WebGPU spec which we do not
yet support. We do not want, however, to cause applications to reject
adapters because we have not finished implementing this, so for now we
are making it an opt-in feature.

As an initial step towards supporting this feature, this patch adds a
new BindingType corresponding to WebGPU's
GPUExternalTextureBindingLayout [2]. This binding type dictates that
when creating a bind group the corresponding entry must be either an
external texture or a texture view with certain additional requirements
[3].

As of yet wgpu has no concept of an external texture (that will follow
in later patches) but for now this patch ensures that texture views
corresponding to an external texture binding type are validated
correctly. Note that as the feature flag is not yet supported on any
real backends, bind group layout creation will fail before getting the
chance to attempt to create a bind group. But in the added tests using
the noop backend we can see this validation taking place.

[1] https://www.w3.org/TR/webgpu/#gpuexternaltexture
[1] https://www.w3.org/TR/webgpu/#dictdef-gpuexternaltexturebindinglayout
[2] https://gpuweb.github.io/gpuweb/#bind-group-creation

Testing
Added validation test. Enabling CTS tests will follow (need some deno_webgpu changes)

Squash or Rebase?

Don't mind

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.

@jamienicol jamienicol requested a review from a team as a code owner May 28, 2025 08:10
@jamienicol jamienicol force-pushed the external-texture-binding-type branch from 53b96c7 to 06a6824 Compare May 28, 2025 18:18
@jamienicol jamienicol marked this pull request as draft May 28, 2025 20:41
@jamienicol jamienicol force-pushed the external-texture-binding-type branch 5 times, most recently from 5a37c32 to 4644ee9 Compare May 30, 2025 14:57
@jamienicol jamienicol changed the title Add ExternalTexture BindingType which can be used with TextureViews Add ExternalTexture BindingType behind new Feature flag May 30, 2025
@jamienicol jamienicol marked this pull request as ready for review May 30, 2025 15:35
@jamienicol jamienicol force-pushed the external-texture-binding-type branch 3 times, most recently from 86c41a1 to 1eddf23 Compare June 4, 2025 15:06
Adds a new feature flag, `EXTERNAL_TEXTURE`, indicating device support
for our implementation of WebGPU's `GPUExternalTexture` [1] which will
land in upcoming patches. Conceptually this would make more sense as a
downlevel flag, as it is a core part of the WebGPU spec which we do not
yet support. We do not want, however, to cause applications to reject
adapters because we have not finished implementing this, so for now we
are making it an opt-in feature.

As an initial step towards supporting this feature, this patch adds a
new `BindingType` corresponding to WebGPU's
`GPUExternalTextureBindingLayout` [2]. This binding type dictates that
when creating a bind group the corresponding entry must be either an
external texture or a texture view with certain additional requirements
[3].

As of yet wgpu has no concept of an external texture (that will follow
in later patches) but for now this patch ensures that texture views
corresponding to an external texture binding type are validated
correctly. Note that as the feature flag is not yet supported on any
real backends, bind group layout creation will fail before getting the
chance to attempt to create a bind group. But in the added tests using
the noop backend we can see this validation taking place.

[1] https://www.w3.org/TR/webgpu/#gpuexternaltexture
[1] https://www.w3.org/TR/webgpu/#dictdef-gpuexternaltexturebindinglayout
[2] https://gpuweb.github.io/gpuweb/#bind-group-creation
@jamienicol jamienicol force-pushed the external-texture-binding-type branch from 1eddf23 to 895bfc4 Compare June 10, 2025 07:29
Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like @jimblandy is ramping up on review now, so I won't drive a full review myself, but I'll comment on some things I noticed before I left on vacation and now.

/// ```
///
/// Corresponds to [WebGPU `GPUExternalTextureBindingLayout`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuexternaltexturebindinglayout).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Maybe a reference to Features::EXTERNAL_TEXTURE would be good here?

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.

3 participants