feat(webgpu): support HTML-in-Canvas textures via copyElementImageToTexture#8810
Merged
Conversation
…exture Adds WebGPU support for the HTML-in-Canvas API, previously WebGL-only. Generic HTML elements can now be used as live texture sources on the WebGPU backend. - WebGPU device reports supportsHtmlTextures = true when the browser exposes queue.copyElementImageToTexture - WebGPU 2D texture uploads route generic HTML elements through a new copyElementImageToTexture path - Updated html-texture and html-texture-configurator examples
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the engine’s HTML-in-Canvas texture support to the WebGPU backend by detecting GPUQueue.copyElementImageToTexture support and routing HTML element texture uploads through a new WebGPU upload path. It also updates example headers to reflect that the feature now works on both WebGL and WebGPU.
Changes:
- Detects HTML-in-Canvas support on WebGPU via
queue.copyElementImageToTextureand exposes it throughdevice.supportsHtmlTextures. - Adds a WebGPU 2D texture upload path for generic HTML elements using
copyElementImageToTexture. - Updates example descriptions to document dual WebGL/WebGPU support.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/platform/graphics/webgpu/webgpu-texture.js | Adds HTML-element upload routing and a new uploadElementImage method using queue.copyElementImageToTexture. |
| src/platform/graphics/webgpu/webgpu-graphics-device.js | Sets supportsHtmlTextures for WebGPU devices based on availability of copyElementImageToTexture. |
| examples/src/examples/misc/html-texture.example.mjs | Updates example header comments to describe WebGPU support and the WebGPU copy API. |
| examples/src/examples/misc/html-texture-configurator.example.mjs | Updates example header/pipeline comments to describe WebGPU support and the WebGPU copy API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Adds WebGPU support for the HTML-in-Canvas API, previously WebGL-only. Generic HTML elements can now be used as live texture sources on the WebGPU backend.
https://www.webgpu.com/news/google-html-in-canvas-webgl-webgpu/
Changes:
supportsHtmlTextures = truewhen the browser exposesqueue.copyElementImageToTexture(the WebGPU counterpart to WebGL'stexElementImage2D).copyElementImageToTexturepath, scaling the element's rendered image to the texture dimensions.Examples:
html-textureandhtml-texture-configuratorto reflect that HTML-in-Canvas now works on both WebGL and WebGPU.