Skip to content

WebGPURenderer: Make generateMipmap work in compatibility mode#32906

Merged
sunag merged 1 commit into
mrdoob:devfrom
greggman:generate-mipmap-compat
Jan 31, 2026
Merged

WebGPURenderer: Make generateMipmap work in compatibility mode#32906
sunag merged 1 commit into
mrdoob:devfrom
greggman:generate-mipmap-compat

Conversation

@greggman

Copy link
Copy Markdown
Contributor

Related issue: #30725

Description

In compatibility mode, a texture, when used as a TEXTURE_BINDING (used in a bind group) can only be used with a single view dimension. A 2d texture, a 2d-array, or a cube. That means to generate mipmaps you need to adjust the shader to use that kind of texture.

Further, you can not choose sub range of array layers for texture view in a bind group in compatibility mode so you can not use createView to choose which array layer to read. Instead you must pass the layer index you want to read to the shader.

Note: I didn't see where flipY is used. It doesn't appear to be used in any of the example, nor by the library itself. flipY is using the the vertex shader from the mipmap shader module but since I couldn't find what's using it I didn't know why it there. As it is, it will also need similar treatment to work in compatibility mode.

Note2: The code used to take a baseArrayLayer and texture descriptor. The texture descriptor seemed superfluous as all the info is on the texture. Similarly the baseArrayLayer seemed to be being used from one level up but it's not needed AFAICT.

@github-actions

github-actions Bot commented Jan 31, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 359.21
85.29
359.21
85.29
+0 B
+0 B
WebGPU 623.28
173.16
624
173.4
+717 B
+246 B
WebGPU Nodes 621.86
172.91
622.58
173.25
+717 B
+335 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 490.47
119.49
490.47
119.49
+0 B
+0 B
WebGPU 689.94
186.32
690.66
186.57
+717 B
+251 B
WebGPU Nodes 639.32
173.74
640.04
173.99
+717 B
+256 B

In compatibilty mode, a texture, when used as a TEXTURE_BINDING
(used in a bind group) can only be used with a single view dimension.
A 2d texture, a 2d-array, or a cube. That means to generate mipmaps
you need to adjust the shader to use that kind of texture.

Further, you can not choose sub range of array layers for texture
view in a bind group in compatibility mode so you can not use `createView`
to choose which array layer to read. Instead you must pass the layer index
you want to read to the shader.
@greggman greggman force-pushed the generate-mipmap-compat branch from 59d74ed to 6ed6294 Compare January 31, 2026 03:55
@greggman

Copy link
Copy Markdown
Contributor Author

Found a bunch of examples that needed flipY. Updated to handle it. It's really just the same shader except flipping the texcoords so just made it do that.

@Mugen87 Mugen87 added this to the r184 milestone Jan 31, 2026
@sunag sunag merged commit f2beb96 into mrdoob:dev Jan 31, 2026
10 checks passed
@Mugen87 Mugen87 modified the milestones: r184, r183 Jan 31, 2026
@greggman greggman deleted the generate-mipmap-compat branch January 31, 2026 23:49
@mrdoob mrdoob changed the title WebGPU: Make generateMipmap work in compatibility mode WebGPURenderer: Make generateMipmap work in compatibility mode Feb 10, 2026
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