metal: refactor texture_format_capabilities function #2522
Merged
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.
Description
Although the WebGPU spec already limits the pixel format capabilities, it is necessary to accurately detect the capabilities that the platform can actually provide.
The changes below are based on the Metal pixel format capabilities table:
The M1 Mac belongs to both the
GPUFamilyAppleX
and theGPUFamilyMacX
, so the M1 Mac meets the union of the feature sets of the two families. Usually either AppleX feature sets (A) belongs to MacX feature sets (M) or M belongs to A, if A ∈ M, the M condition needs to be placed first when detecting pixel format capabilities.MTLReadWriteTextureTier1 | 2
excludesRg16Uint
Rg16Sint
andRg16Float
.R16Float
: supports all capabilities on all GPU familiesR32Float
: included inMTLReadWriteTextureTier1
and there is no need to distinguish between GPU families, supports all capabilities on macOS, supportsWrite | Color | MSAA | Blend
on all GPUFamilyAppleX.R8Snorm
Rg8Snorm
andRgba8Snorm
don't supportResolve
on GPUFamilyApple1.R32Uint
R32Sint
supportsWrite | Color
on all GPU families, supportMSAA
only on macOS.Rg32Float
: Supportswrite | blend
on all GPU families, supportResolve
on macOS.Rgba32Uint
Rgba32Sint
: SupportsWrite | Color
on all GPU families, supportMSAA
on macOS and GPUFamilyApple7+.Rgba32Float
: SupportsWrite | Color
on all GPU families, supports all other capabilities on macOS, supportMSAA
only on GPUFamilyApple7+Depth24Plus
: no GPU family supports it.Depth24PlusStencil8
: only macOS supports it.Rgb9e5Ufloat
: only supportFilter
on GPUFamilyMac, supports all on GPUFamilyApple3+.Testing
Testing all formats and capabilities is difficult and my current testing is inadequate.
Modify the code in 3 steps to ensure the correctness of the changes:
Tested wgpu examples on M1 | Intel Mac was not broken.
Tested wgpu-on-app demos and my private app 字习 Pro on both Mac and iPhone devices was not broken.