Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jun 3, 2025

Related issue: #30995

Description

This PR is one step towards full MSAA support for RTT with the WebGL backend of WebGPURenderer.

The depth and stencil data were never honored during the blit operation so far. That explains why examples like webgpu_custom_fog_background failed with PassNode using MSAA since getViewZNode() or getLinearDepthNode() returned nodes operating on empty buffers.

The WebGL backend uses the same approach like in WebGLRenderer to avoid this issue:

if ( renderTarget.resolveDepthBuffer ) {
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
}

/cc @cabanier

@github-actions
Copy link

github-actions bot commented Jun 3, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 337.4
78.67
337.4
78.67
+0 B
+0 B
WebGPU 553.83
153.48
553.93
153.5
+103 B
+15 B
WebGPU Nodes 553.18
153.33
553.28
153.34
+103 B
+15 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 468.59
113.33
468.59
113.33
+0 B
+0 B
WebGPU 628.8
170.19
628.9
170.21
+103 B
+18 B
WebGPU Nodes 583.65
159.53
583.76
159.55
+103 B
+15 B

@Mugen87 Mugen87 changed the title WebGLBackend: Honor depth/stencil in bindFramebuffer(). WebGLBackend: Honor depth/stencil in blitFramebuffer(). Jun 3, 2025
@cabanier
Copy link
Contributor

cabanier commented Jun 3, 2025

LGTM! Will you also add the option to use multisampled renderbuffers for platforms that don't support render-to-texture?

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jun 3, 2025

What platforms don't support this workflow?

@cabanier
Copy link
Contributor

cabanier commented Jun 3, 2025

What platforms don't support this workflow?

I believe only Quest and Pico browsers support this so Chrome and Safari need MSAA renderbuffers. We need to render to a MSAA texture because that is the only way to get foveation to work.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jun 3, 2025

Understood. At the moment the goal is to fix #30995 so MSAA with post processing and MRT works with the WebGL backend. I'll work on the MSAA/MRT combination next.

@Mugen87 Mugen87 added this to the r178 milestone Jun 3, 2025
@Mugen87 Mugen87 merged commit 7b8e83f into mrdoob:dev Jun 3, 2025
12 checks passed
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