Skip to content

feat(webgpu): support HTML-in-Canvas textures via copyElementImageToTexture#8810

Merged
mvaligursky merged 2 commits into
mainfrom
mv-webgpu-html-textures
May 29, 2026
Merged

feat(webgpu): support HTML-in-Canvas textures via copyElementImageToTexture#8810
mvaligursky merged 2 commits into
mainfrom
mv-webgpu-html-textures

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented May 29, 2026

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:

  • WebGPU device now reports supportsHtmlTextures = true when the browser exposes queue.copyElementImageToTexture (the WebGPU counterpart to WebGL's texElementImage2D).
  • WebGPU 2D texture uploads route generic HTML elements through a new copyElementImageToTexture path, scaling the element's rendered image to the texture dimensions.

Examples:

  • Updated html-texture and html-texture-configurator to reflect that HTML-in-Canvas now works on both WebGL and WebGPU.
Screenshot 2026-05-29 at 16 08 48

…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
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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.copyElementImageToTexture and exposes it through device.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.

Comment thread src/platform/graphics/webgpu/webgpu-texture.js Outdated
@mvaligursky mvaligursky merged commit cfad4ec into main May 29, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-html-textures branch May 29, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: examples area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants