Skip to content

Commit

Permalink
Fix M1 in macOS incorrectly reports supported compressed texture form…
Browse files Browse the repository at this point in the history
…ats (#2453)

* Metal: Correctly identify ASTC and EAC/ETC2 support

* Metal: Correctly expose ASTC / BC / EAC/ETC2 compressed texture support

* Metal: Only call supports_family when supported, and use Apple6 for ASTC check
  • Loading branch information
superdump authored Feb 4, 2022
1 parent e903a2b commit 5e2c2f8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,12 @@ impl super::PrivateCapabilities {
format_min_srgb_channels: if os_is_mac { 4 } else { 1 },
format_b5: !os_is_mac,
format_bc: os_is_mac,
format_eac_etc: !os_is_mac,
format_astc: Self::supports_any(device, ASTC_PIXEL_FORMAT_FEATURES),
format_eac_etc: !os_is_mac
// M1 in macOS supports EAC/ETC2
|| (family_check && device.supports_family(MTLGPUFamily::Apple7)),
format_astc: Self::supports_any(device, ASTC_PIXEL_FORMAT_FEATURES)
// A13/A14/M1 and later always support ASTC
|| (family_check && device.supports_family(MTLGPUFamily::Apple6)),
format_any8_unorm_srgb_all: Self::supports_any(device, ANY8_UNORM_SRGB_ALL),
format_any8_unorm_srgb_no_write: !Self::supports_any(device, ANY8_UNORM_SRGB_ALL)
&& !os_is_mac,
Expand Down Expand Up @@ -1010,7 +1014,6 @@ impl super::PrivateCapabilities {
use wgt::Features as F;

let mut features = F::empty()
| F::TEXTURE_COMPRESSION_BC
| F::INDIRECT_FIRST_INSTANCE
| F::MAPPABLE_PRIMARY_BUFFERS
| F::VERTEX_WRITABLE_STORAGE
Expand All @@ -1020,6 +1023,10 @@ impl super::PrivateCapabilities {
| F::CLEAR_TEXTURE
| F::TEXTURE_FORMAT_16BIT_NORM;

features.set(F::TEXTURE_COMPRESSION_ASTC_LDR, self.format_astc);
features.set(F::TEXTURE_COMPRESSION_BC, self.format_bc);
features.set(F::TEXTURE_COMPRESSION_ETC2, self.format_eac_etc);

features.set(F::DEPTH_CLIP_CONTROL, self.supports_depth_clip_control);

features.set(
Expand Down

0 comments on commit 5e2c2f8

Please sign in to comment.