WebGPU: MSAA-resolved texture cannot be read in compute shader

Hi,

I’m working on an environment probe system that renders 4 tetrahedral cameras to textures, then uses a compute shader to reproject them into an octahedral map.

The problem: When MSAA is enabled (samples > 1), the compute shader reads corrupted data (black squares at geometry edges), even though the textures appear correct when displayed via app.drawTexture().

Setup:

  • PlayCanvas 2.13.6
  • WebGPU (Chrome 131)
  • Windows

Code structure:

// Create render target with MSAA
const texture = new Texture(device, { ... });
const rt = new RenderTarget({
    colorBuffer: texture,
    samples: 4,
    depth: true
});

// Camera renders to rt...

// Later, in compute shader:
// textureSampleLevel(uTetra0, uTetra0Sampler, uv, 0.0) → black squares

Observations:

  1. app.drawTexture(texture) in debug preview shows clean image (no artifacts)
  2. Compute shader reading same texture via textureSampleLevel shows black squares
  3. With samples: 1 (no MSAA) — everything works perfectly
  4. Delaying compute dispatch by 1-2 frames doesn’t help
  5. rt.resolve() appears to be WebGL2-only

Question: Is there a way to read MSAA-resolved textures in a compute shader on WebGPU? Or is this a known limitation?

I’ve tried:

  • Manual resolve via drawQuadWithShader blit (but GLSL shader doesn’t work in WebGPU)
  • Creating separate texture and copying data
  • Various frame delays

Any guidance would be appreciated. Happy to provide a minimal repro project if helpful.

Thanks!

hmm I got Cursor to create me an example repro, and all seems to work as expected.

See the PR with code here: Test using resolved msaa texture in compute shader by mvaligursky · Pull Request #8190 · playcanvas/engine · GitHub
try it here: PlayCanvas Examples

  • left (orange cube) is rendering to single/multi sampled texture
  • right is single sampled texture color adjusted in compute

added a proper example to demonstrate this

2 Likes

@mvaligursky, thanks a lot for the example! I found the source of the problem: it was the Area Light, it had extremely invalid values, causing black artifacts. I added checks and there are no more artifacts, thanks for help!

1 Like