From ef9974f9c47ef3f98be76bfea6c3ce0abe5bd1e9 Mon Sep 17 00:00:00 2001 From: Teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 12 Jun 2026 13:27:27 +0200 Subject: [PATCH] [metal] don't advertise `TIMESTAMP_QUERY_INSIDE_ENCODERS` on Apple GPUs From my testing the workaround on Apple GPUs is now always writing 0. --- wgpu-hal/src/metal/adapter.rs | 7 ++++++- wgpu-hal/src/metal/command.rs | 3 +++ wgpu-types/src/features.rs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 4d359f0b0..968f3f9f4 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -1174,10 +1174,15 @@ impl super::CapabilitiesQuery { features.set(F::FLOAT32_BLENDABLE, true); features.set(F::INDIRECT_FIRST_INSTANCE, self.indirect_draw_dispatch); features.set( - F::TIMESTAMP_QUERY | F::TIMESTAMP_QUERY_INSIDE_ENCODERS, + F::TIMESTAMP_QUERY, self.timestamp_query_support .contains(TimestampQuerySupport::STAGE_BOUNDARIES), ); + features.set( + F::TIMESTAMP_QUERY_INSIDE_ENCODERS, + self.timestamp_query_support + .contains(TimestampQuerySupport::ON_BLIT_ENCODER), + ); features.set( F::TIMESTAMP_QUERY_INSIDE_PASSES, self.timestamp_query_support diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index 447f07df1..ccc1be3bb 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -163,6 +163,9 @@ impl super::CommandEncoder { debug_assert!(self.state.render.is_none() && self.state.compute.is_none()); let cmd_buf = self.raw_cmd_buf.as_ref().unwrap(); + // This code path is currently unused since the written timestamp is always 0. + // We should see if we can get it working again, if not remove the code. + // // Take care of pending timer queries. // If we can't use `sample_counters_in_buffer` we have to create a dummy blit encoder! // diff --git a/wgpu-types/src/features.rs b/wgpu-types/src/features.rs index 63656c729..e1534166d 100644 --- a/wgpu-types/src/features.rs +++ b/wgpu-types/src/features.rs @@ -711,7 +711,7 @@ bitflags_array! { /// Supported platforms: /// - Vulkan /// - DX12 - /// - Metal + /// - Metal (AMD & Intel, not Apple GPUs) /// - OpenGL (with GL_ARB_timer_query) /// /// This is a native only feature.