Skip to content

WebGPURenderer: Fix MSAA using mipmap levels#31544

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
NoxDawnsong:webgpu-fix-msaa-texture-mipmaps
Aug 2, 2025
Merged

WebGPURenderer: Fix MSAA using mipmap levels#31544
Mugen87 merged 2 commits into
mrdoob:devfrom
NoxDawnsong:webgpu-fix-msaa-texture-mipmaps

Conversation

@NoxDawnsong
Copy link
Copy Markdown
Contributor

Description

According to the MDN-Documentation on createTexture, textures cannot have mipmap levels if they also use MSAA/samples. This fix aims to prevent blank render-targets, which specify both mipmaps and MSAA, see #31542 (comment)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 1, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.84
79.07
338.84
79.07
+0 B
+0 B
WebGPU 566.16
156.5
566.18
156.51
+18 B
+7 B
WebGPU Nodes 564.77
156.26
564.78
156.27
+18 B
+6 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.26
113.77
470.26
113.77
+0 B
+0 B
WebGPU 637.36
172.49
637.38
172.5
+18 B
+6 B
WebGPU Nodes 592.01
161.73
592.03
161.74
+18 B
+6 B

@NoxDawnsong NoxDawnsong changed the title WebGPU: Fix MSAA using mipmap levels WebGPURenderer: Fix MSAA using mipmap levels Aug 1, 2025
Comment thread src/renderers/webgpu/utils/WebGPUTextureUtils.js Outdated

msaaTextureDescriptorGPU.label = msaaTextureDescriptorGPU.label + '-msaa';
msaaTextureDescriptorGPU.sampleCount = samples;
msaaTextureDescriptorGPU.mipLevelCount = 1; // See https://www.w3.org/TR/webgpu/#texture-creation
Copy link
Copy Markdown
Collaborator

@Mugen87 Mugen87 Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunag Should be report warning to the user if samples is set to a value greater than 0 and mipmapping is enabled? In engine components like FX modules, we can control this ourselves when creating render targets but I wonder if this kind of patch leads to unexpected behavior on user level.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. good question, I can't calculate it right away either, we can merge and test during the r180dev I think.

@Mugen87 Mugen87 merged commit 3dd226d into mrdoob:dev Aug 2, 2025
9 checks passed
@Mugen87 Mugen87 added this to the r180 milestone Aug 2, 2025
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.

3 participants