From 6576d41c7de7ebc3226d60182bd3d23685eddc2f Mon Sep 17 00:00:00 2001 From: edTheGuy00 Date: Sat, 19 Sep 2026 04:14:19 +0700 Subject: [PATCH] =?UTF-8?q?fix(metal):=20report=20indirect=20execution=20a?= =?UTF-8?q?nd=20256-byte=20uniform=20alignment=20=E2=80=A6=20(#10189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Connor Fitzgerald --- CHANGELOG.md | 1 + wgpu-hal/src/metal/adapter.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e06e76cd0..3fcde0774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -244,6 +244,7 @@ By @sagudev in [#10109](https://github.com/gfx-rs/wgpu/pull/10109). - Report an error instead of panicking when Metal declines to create a texture view, which can occur for some views of textures with `TRANSIENT_ATTACHMENT` usage. By @matthargett in [#10145](https://github.com/gfx-rs/wgpu/pull/10145). - BREAKING: Advertise `CompositeAlphaMode::PreMultiplied` instead of `PostMultiplied`, matching the premultiplied alpha compositing that Core Animation actually performs for a non-opaque `CAMetalLayer`. By @nicoburns in [#9922](https://github.com/gfx-rs/wgpu/pull/9922). - If you previously hard-coded `PostMultiplied` to get a transparent macOS window, you will start receiving `UnsupportedAlphaMode` validation errors for this. Those affected should migrate to `PreMultiplied` instead. +- Report `DownlevelFlags::INDIRECT_EXECUTION` and a 256-byte `min_uniform_buffer_offset_alignment` on the iOS Simulator (`target_abi = "sim"`). The Simulator advertises only the Apple2 GPU family but executes indirect draw/dispatch on the host GPU, so compute renderers such as vello previously failed with "Downlevel flags DownlevelFlags(INDIRECT_EXECUTION) are required but not supported". Note that Metal API Validation still rejects indirect commands there. By @edTheGuy00 in [#10189](https://github.com/gfx-rs/wgpu/pull/10189). - Fix a crash in `Surface::configure` on iOS below 16. `wantsExtendedDynamicRangeContent` is iOS 16+ and is now only called there. By @VladasZ in [#10257](https://github.com/gfx-rs/wgpu/pull/10257). - Fix a crash when creating a declared alternate sRGB view of a render-attachment-only surface with Metal API Validation enabled. By @jinleili in [#10280](https://github.com/gfx-rs/wgpu/pull/10280). diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index cfdef666f..cd7a24b19 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -681,7 +681,7 @@ impl super::CapabilitiesQuery { // // Along with the different OSes, there is also two other modes that // applications can run in: the Simulator, and Mac Catalyst. This can - // be detected using `cfg!(target_env = "sim")` or + // be detected using `cfg!(target_abi = "sim")` or // `cfg!(target_env = "macabi")`. // // Finally, iOS applications can be run on macOS and visionOS directly @@ -799,7 +799,8 @@ impl super::CapabilitiesQuery { MUTABLE_COMPARISON_SAMPLER_SUPPORT, ), sampler_clamp_to_border: Self::supports_any(device, SAMPLER_CLAMP_TO_BORDER_SUPPORT), - indirect_draw_dispatch: Self::supports_any(device, INDIRECT_DRAW_DISPATCH_SUPPORT), + indirect_draw_dispatch: Self::supports_any(device, INDIRECT_DRAW_DISPATCH_SUPPORT) + || cfg!(target_abi = "sim"), base_vertex_first_instance_drawing: Self::supports_any( device, BASE_VERTEX_FIRST_INSTANCE_SUPPORT, @@ -937,10 +938,11 @@ impl super::CapabilitiesQuery { 64 }, // "Minimum constant buffer offset alignment" - constant_buffer_offset_alignment: if matches!( - os_type, - super::OsType::Macos | super::OsType::VisionOs - ) { + // The iOS Simulator requires 256-byte constant buffer offsets, like macOS + // (Apple: "Developing Metal apps that run in Simulator"). + constant_buffer_offset_alignment: if cfg!(target_abi = "sim") + || matches!(os_type, super::OsType::Macos | super::OsType::VisionOs) + { 256 } else if device.supportsFeatureSet(MTLFeatureSet::macOS_GPUFamily2_v1) { 32