feat(webgpu): support transient (memoryless) attachments#8816
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds WebGPU transient (“memoryless”) attachment support to reduce VRAM allocation for MSAA color buffers and engine-owned depth buffers on tile-based GPUs by using GPUTextureUsage.TRANSIENT_ATTACHMENT, plus runtime guards to enforce clear/discard usage.
Changes:
- Adds
transientColor/transientDepthhints onRenderTarget(andcreateGraphicsDeviceoptions for the backbuffer). - Allocates eligible WebGPU MSAA color and engine-owned depth textures as transient attachments when supported.
- Adds render-time validation/guardrails (force clear+discard and log once; block depth resolve/grab paths that are incompatible).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform/graphics/webgpu/webgpu-render-target.js | Marks attachments as transient and enforces clear/discard ops at render-pass setup time. |
| src/platform/graphics/webgpu/webgpu-graphics-device.js | Detects transient support; wires backbuffer options; prevents incompatible depth resolve/copy operations. |
| src/platform/graphics/render-target.js | Introduces transient flags/options and getters on RenderTarget. |
| src/platform/graphics/graphics-device.js | Adds default init options for transient flags. |
| src/platform/graphics/graphics-device-create.js | Documents new createGraphicsDevice options. |
| examples/src/examples/graphics/render-to-texture.example.mjs | Demonstrates enabling transient attachments for backbuffer and offscreen RT. |
💡 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.
https://github.com/gpuweb/gpuweb/blob/main/proposals/transient-attachments.md
Adds support for WebGPU transient ("memoryless") attachments
(GPUTextureUsage.TRANSIENT_ATTACHMENT, shipped in Chrome 146+). On
tile-based GPUs (mobile / Apple Silicon) the driver can keep such an
attachment's contents in on-chip tile memory and skip VRAM allocation
entirely, as its contents only need to live within a single render pass.
This applies to attachments that are cleared on load and discarded on
store, and never sampled, copied or resolved — most notably the MSAA
color resolve-source buffer and depth buffers that are not read back.
Changes:
GraphicsDevice#supportsTransientAttachments.TRANSIENT_ATTACHMENT(suppressing COPY_SRC / TEXTURE_BINDING on depth)when requested and supported.
logs
Debug.errorOnceif a transient attachment is ever reloaded orstored (e.g. a later pass reuses the target, or a color/depth grab pass),
preventing a WebGPU validation error.
API Changes:
createGraphicsDeviceoptions: newtransientColor/transientDepthbooleans (default false), applied to the back-buffer.
RenderTargetconstructor options: newtransientColor/transientDepthbooleans (default false), plus matching read-only getters.
for single-sampled color, or when an explicit depthBuffer is provided.
Incompatible with scene color grab (sceneColorMap) and scene depth grab
(sceneDepthMap) / depth prepass.
Examples:
off-screen render target and the main back-buffer.