metal: assert on texture_generate_mipmaps for non-mipmapped textures#637
Open
benface wants to merge 1 commit into
Open
metal: assert on texture_generate_mipmaps for non-mipmapped textures#637benface wants to merge 1 commit into
texture_generate_mipmaps for non-mipmapped textures#637benface wants to merge 1 commit into
Conversation
c0678b5 to
14e7f18
Compare
not-fl3
reviewed
Jun 15, 2026
Calling `texture_generate_mipmaps` on a texture allocated without
mipmaps is a programmer error 99% of the time. Today the Metal
implementation unconditionally calls `generateMipmapsForTexture:`,
which Metal validation rejects when the texture has
`mipmapLevelCount == 1`:
-[MTLDebugBlitCommandEncoder generateMipmapsForTexture:]:1105:
failed assertion `Generate Mipmaps For Texture Validation
[tex mipmapLevelCount](1) must be > 1.`
Raise the failure at the call site with a clear panic message
instead of crashing deep inside the blit encoder. The fix is on
the caller: pass `TextureParams::allocate_mipmaps = true` at
creation if you intend to generate mipmaps later.
14e7f18 to
2d8823b
Compare
Contributor
Author
|
Switched to a panic with a clearer message — agreed that catching the bug at the call site is better than a silent no-op. Branch + PR title now reflect the new behaviour ('assert on |
texture_generate_mipmaps for non-mipmapped texturestexture_generate_mipmaps for non-mipmapped textures
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.
Problem
RenderingBackend::texture_generate_mipmaps's doc comment already promises:But the Metal implementation in
graphics/metal.rsunconditionally callsgenerateMipmapsForTexture:without checking the texture'sallocate_mipmapsflag. With Metal validation on, the call fails on any texture that hasmipmapLevelCount == 1:Fix
Early-return when
texture.params.allocate_mipmapsis false. Honours the documented contract and matches the OpenGL backend's behaviour.Tested on
iPhone 17 simulator on iOS 27 beta — assert gone for macroquad apps that call
set_filter(which routes throughtexture_generate_mipmapsfor the mipmap filter mode) on non-mipmapped textures.