v146 · Web APIs · Transient Demo

Transient Demo

Renders a triangle using WebGPU with a depth buffer created with TRANSIENT_ATTACHMENT usage. On tile-based GPUs, the depth buffer is discarded at pass end without being written to main memory.

TRANSIENT_ATTACHMENT is an optimization hint — the GPU driver decides whether to keep the texture in tile memory. On desktop GPUs (non tile-based), the flag is accepted but may not produce memory savings. The API behaviour is identical either way.

render output

Initializing…

WebGPU status

device capabilities

WebGPU supportedChecking…
TRANSIENT_ATTACHMENT flagChecking…
adapter type
last render

code

const depthTex = device.createTexture({
  size: [canvas.width, canvas.height, 1],
  format: 'depth24plus',
  usage: GPUTextureUsage.RENDER_ATTACHMENT |
         GPUTextureUsage.TRANSIENT_ATTACHMENT,
});

const pass = encoder.beginRenderPass({
  colorAttachments: [{
    view: ctx.getCurrentTexture().createView(),
    loadOp: 'clear',
    clearValue: [0.05, 0.05, 0.05, 1],
    storeOp: 'store',
  }],
  depthStencilAttachment: {
    view: depthTex.createView(),
    depthLoadOp: 'clear',
    depthClearValue: 1.0,
    depthStoreOp: 'discard',  // content not needed after pass
  },
});

pass.setPipeline(pipeline);
pass.draw(3);
pass.end();

see also