From 2761349d98199a2695e629bf2f911c2d0db7a6c8 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 21:50:49 +0100 Subject: [PATCH] Renderer: no indirect buffer usage without indirect draws (OpenGL before 4.3) wgpu refuses to create a buffer with INDIRECT usage on a device without DownlevelFlags::INDIRECT_EXECUTION (OpenGL before 4.3 without compute shaders), so the game panicked creating 'Section draws'. Multi-draw now also needs indirect execution, and without it the buffer has no INDIRECT usage: sections are drawn one direct draw each, as they already were without INDIRECT_FIRST_INSTANCE. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/gfx.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/gfx.rs b/crates/horizon-client/src/gfx.rs index baa8c5099..cd40ea22e 100644 --- a/crates/horizon-client/src/gfx.rs +++ b/crates/horizon-client/src/gfx.rs @@ -2182,15 +2182,26 @@ impl Renderer { ) }); let sorted_indices = arena::Arena::indices(&device, 1 << 16, flat.is_some()); + let multi_draw = device + .features() + .contains(wgpu::Features::INDIRECT_FIRST_INSTANCE) + && adapter + .get_downlevel_capabilities() + .flags + .contains(wgpu::DownlevelFlags::INDIRECT_EXECUTION); + // Without indirect draws (OpenGL before 4.3 without compute shaders) + // even creating an indirect buffer fails; one draw per section reads + // `draws` on the CPU instead. let indirect = device.create_buffer(&wgpu::BufferDescriptor { label: Some("Section draws"), size: 1024 * 20, - usage: wgpu::BufferUsages::INDIRECT | wgpu::BufferUsages::COPY_DST, + usage: if multi_draw { + wgpu::BufferUsages::INDIRECT | wgpu::BufferUsages::COPY_DST + } else { + wgpu::BufferUsages::COPY_DST + }, mapped_at_creation: false, }); - let multi_draw = device - .features() - .contains(wgpu::Features::INDIRECT_FIRST_INSTANCE); // HORIZON_GPU_CULL=0 turns occlusion culling off, `all` culls every // frame however few its draws and little it hides, `shader` tests in // the shader as on Metal (A/B checks).