WebGPURenderer: Make generateMipmap work in compatibility mode#32906
Merged
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
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.
59d74ed to
6ed6294
Compare
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. |
This was referenced Feb 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
createViewto 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
flipYis used. It doesn't appear to be used in any of the example, nor by the library itself.flipYis 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.