Skip to content

feat(webgpu): support transient (memoryless) attachments#8816

Merged
mvaligursky merged 2 commits into
mainfrom
mv-transient-attachments
Jun 1, 2026
Merged

feat(webgpu): support transient (memoryless) attachments#8816
mvaligursky merged 2 commits into
mainfrom
mv-transient-attachments

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented Jun 1, 2026

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:

  • Detect support via GraphicsDevice#supportsTransientAttachments.
  • Allocate the MSAA color buffer and engine-owned depth buffer with
    TRANSIENT_ATTACHMENT (suppressing COPY_SRC / TEXTURE_BINDING on depth)
    when requested and supported.
  • A render-time guard in the WebGPU render target forces clear/discard and
    logs Debug.errorOnce if a transient attachment is ever reloaded or
    stored (e.g. a later pass reuses the target, or a color/depth grab pass),
    preventing a WebGPU validation error.

API Changes:

  • createGraphicsDevice options: new transientColor / transientDepth
    booleans (default false), applied to the back-buffer.
  • RenderTarget constructor options: new transientColor / transientDepth
    booleans (default false), plus matching read-only getters.
  • Both are WebGPU-only hints, silently ignored on WebGL2, where unsupported,
    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:

  • render-to-texture: enables transientColor/transientDepth on both the
    off-screen render target and the main back-buffer.

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

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 / transientDepth hints on RenderTarget (and createGraphicsDevice options 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.

Comment thread src/platform/graphics/render-target.js Outdated
Comment thread src/platform/graphics/webgpu/webgpu-graphics-device.js
Comment thread src/platform/graphics/graphics-device.js
Comment thread src/platform/graphics/render-target.js Outdated
Comment thread src/platform/graphics/webgpu/webgpu-graphics-device.js
Comment thread src/platform/graphics/graphics-device.js
@mvaligursky mvaligursky merged commit 1667b1d into main Jun 1, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-transient-attachments branch June 1, 2026 10:52
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.

2 participants