[WebGPU] Add the ability to interop with external textures#9530
Open
AdrianEddy wants to merge 6 commits into
Open
[WebGPU] Add the ability to interop with external textures#9530AdrianEddy wants to merge 6 commits into
AdrianEddy wants to merge 6 commits into
Conversation
Member
|
The description of this sounds really reasonable. |
Collaborator
|
We normally assign PRs to maintainers on Wednesday, but some didn't get assigned this week. I'll try to take a look anyway and it'll most likely be assigned to someone next week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds two complementary pieces of public API on the WebGPU backend so external interop crates can read and inject
GPUTexturehandles without copy:as_webgpu()accessors onTexture,TextureView,Buffer,Queue, andDevice- returnOption<&webgpu::Gpu*>, the WebGPU counterpart ofas_hal(which always returnsNoneon this backend, since WebGPU is not awgpu_halAPI).Device::create_texture_from_webgpu_handle(texture, desc)- wraps a foreignwebgpu::GpuTexture(e.g. from canvasgetCurrentTexture()) as awgpu::Texturewithout copy. The wrapped texture is external: itsdestroy()is a no-op, since the JS handle's lifetime is the caller's responsibility.The vendored handle types (
GpuTexture,GpuTextureView,GpuBuffer,GpuQueue,GpuDevice) are re-exported under a new public modulewgpu::webgpu.The
unsafecontract oncreate_texture_from_webgpu_handleis documented in detail (same-device, descriptor-must-match, lifetime-must-extend); cross-device or descriptor-mismatch surfaces as a WebGPU validation error at first use, which wgpu cannot prevent at construction time because the spec exposes noGPUTexture.devicereflection.Testing
Explain how this change is tested.
Squash or Rebase?
Squash
Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.