From a794f7ff9d2918f3b1abc96d25c15f292abbf850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralph=20K=C3=BCpper?= Date: Sat, 21 Nov 2026 17:10:33 +0100 Subject: [PATCH] GPU-driven renderer: no INDIRECT buffers on devices without indirect draws GpuDrivenRenderer::new created its indirect command and counter buffers with BufferUsages::INDIRECT unconditionally, even when the GPU-driven path stays disabled. wgpu rejects INDIRECT buffers without DownlevelFlags::INDIRECT_EXECUTION and its default error handler panics, so every app aborted at launch on the A8 Apple TV HD (AppleTV5,3, Metal tvOS GPU family 1; App Review tests tvOS apps on it) and in the iOS/tvOS simulators. Request INDIRECT only when the device has INDIRECT_FIRST_INSTANCE, which the GPU-driven path already requires before it issues indirect draws (and which Metal reports for the same GPU families as indirect execution). Elsewhere the buffers are only bound as storage. Verified: a tvOS app on Bloom launches and renders in the tvOS 26.5 simulator with this change. The App Review crash logs (tvOS 26.6, AppleTV5,3) show the abort in GpuDrivenRenderer::new -> create_buffer. --- native/shared/src/renderer/gpu_driven.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/native/shared/src/renderer/gpu_driven.rs b/native/shared/src/renderer/gpu_driven.rs index c33dd6af..e75c02ad 100644 --- a/native/shared/src/renderer/gpu_driven.rs +++ b/native/shared/src/renderer/gpu_driven.rs @@ -184,7 +184,7 @@ impl GpuDrivenRenderer { label: Some("gpu_driven_counters"), size: 16, usage: wgpu::BufferUsages::STORAGE - | wgpu::BufferUsages::INDIRECT + | indirect_usage(device) | wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::COPY_SRC, mapped_at_creation: false, @@ -1031,11 +1031,30 @@ fn create_indirect_buffer( device.create_buffer(&wgpu::BufferDescriptor { label: Some(label), size: (capacity * std::mem::size_of::()) as u64, - usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::INDIRECT, + usage: wgpu::BufferUsages::STORAGE | indirect_usage(device), mapped_at_creation: false, }) } +/// `INDIRECT` when the device can execute indirect draws, empty otherwise. +/// +/// wgpu rejects (and by default panics on) an `INDIRECT` buffer on devices +/// without `DownlevelFlags::INDIRECT_EXECUTION`, e.g. the A8 Apple TV HD +/// (Metal tvOS GPU family 1) and the iOS/tvOS simulators. Those devices never +/// enable the GPU-driven path (it needs `INDIRECT_FIRST_INSTANCE`, which Metal +/// reports for the same GPU families), so the buffers are only ever bound as +/// storage there. +fn indirect_usage(device: &wgpu::Device) -> wgpu::BufferUsages { + if device + .features() + .contains(wgpu::Features::INDIRECT_FIRST_INSTANCE) + { + wgpu::BufferUsages::INDIRECT + } else { + wgpu::BufferUsages::empty() + } +} + fn create_cull_layout(device: &wgpu::Device, routed_visibility: bool) -> wgpu::BindGroupLayout { let storage = |binding, read_only, visibility| wgpu::BindGroupLayoutEntry { binding,