Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal: refactor texture_format_capabilities function #2522

Merged
merged 1 commit into from
Mar 3, 2022
Merged

metal: refactor texture_format_capabilities function #2522

merged 1 commit into from
Mar 3, 2022

Conversation

jinleili
Copy link
Contributor

@jinleili jinleili commented Mar 3, 2022

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 the GPUFamilyMacX, 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 excludes Rg16Uint Rg16Sint and Rg16Float .

  • R16Float : supports all capabilities on all GPU families

  • R32Float : included in MTLReadWriteTextureTier1 and there is no need to distinguish between GPU families, supports all capabilities on macOS, supports Write | Color | MSAA | Blend on all GPUFamilyAppleX.

  • R8Snorm Rg8Snorm and Rgba8Snorm don't support Resolve on GPUFamilyApple1.

  • R32Uint R32Sint supports Write | Color on all GPU families, support MSAA only on macOS.

  • Rg32Float: Supports write | blend on all GPU families, support Resolve on macOS.

  • Rgba32Uint Rgba32Sint : Supports Write | Color on all GPU families, support MSAA on macOS and GPUFamilyApple7+.

  • Rgba32Float: Supports Write | Color on all GPU families, supports all other capabilities on macOS, support MSAA only on GPUFamilyApple7+

  • Depth24Plus: no GPU family supports it.

  • Depth24PlusStencil8: only macOS supports it.

  • Rgb9e5Ufloat : only support Filter 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:

  • Each format capabilities is modified separately against the pixel format capabilities table
  • Combine formats with the same capabilities and validate them against the pixel format capabilities table again.
  • Then, the next day, I checked it again.

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.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@kvark kvark merged commit d3c2101 into gfx-rs:master Mar 3, 2022
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.

2 participants