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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 21:50:49 +01:00
parent f65750baed
commit 2761349d98
+15 -4
View File
@@ -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).