engine
engine copied to clipboard
WebGPU MSAA render target with depth buffer fails
It is not possible to create a multisampled render target and specify a target depth texture roughly like so:
const colorBuffer = createTexture(widthPixels, heightPixels, PIXELFORMAT_RGBA8);
const depthBuffer = createTexture(widthPixels, heightPixels, PIXELFORMAT_DEPTH);
const renderTarget = new RenderTarget({
name: 'rt',
colorBuffer: colorBuffer,
depthBuffer: depthBuffer,
flipY: false,
samples: device.maxSamples,
autoResolve: false
});
The resulting error is:
Yep, this is not supported at the moment. What needs to happen for this to work:
- in WebgpuRenderTarget, when samples > 1 and a depthBuffer is passed in, we need to allocate multi-sampled depth buffer for rendering. We cannot specify the provided single-sampled buffer as a resolve target, as WebGPU cannot automatically resolve depth.
- then in the endPass for WebGPU, just before
passEncoder.end
(so using existing pass encoder) use WebgpuResolver to manually resolve the depth, which it already handles. - we possibly might need to update framegraph for the render pass in question to store the multisampled depth, as by default I think it just gets discarded.