fix: Metal depth24 crash on Apple Silicon (M1/M2/M3/M4)#87
Merged
Conversation
Depth24PlusStencil8 was hardcoded to MTLPixelFormatDepth24UnormStencil8 (255), unsupported on Apple Silicon. Depth24Plus was missing entirely. - Detect isDepth24Stencil8PixelFormatSupported at adapter enumeration - Fall back to Depth32Float/Depth32FloatStencil8 on Apple Silicon - Use capability-aware mapTextureFormat() in CreateTexture, CreateTextureView, CreateRenderPipeline Follows wgpu-rs pattern (wgpu-hal/src/metal/adapter.rs). Fixes gogpu/ui#23.
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.
Summary
Depth24PlusStencil8was hardcoded toMTLPixelFormatDepth24UnormStencil8(255) — unsupported on Apple Silicon (only legacy AMD GPUs in Intel-era Macs)Depth24Pluswas completely missing from the format mapping — returnedMTLPixelFormatInvalid(0)isDepth24Stencil8PixelFormatSupportedat adapter enumeration and fall back toDepth32Float/Depth32FloatStencil8on Apple Siliconwgpu-hal/src/metal/adapter.rs:668)Fixes gogpu/ui#23
Changes
hal/metal/adapter.goformatDepth24Stencil8capability field +mapTextureFormat()methodhal/metal/api.goisDepth24Stencil8PixelFormatSupportedat adapter enumerationhal/metal/conv.goDepth24Pluscase, changeD24S8default to safeD32FS8hal/metal/device.gotextureFormatToMTL()calls with capability-awaremapTextureFormat()CHANGELOG.mdTest plan
GOOS=darwin GOARCH=arm64 go build ./...— cross-compile passesgo test ./...— all existing tests passgolangci-lint run— 0 issuesgogpuandggbuilds pass