pub fn instance_flags() -> InstanceFlagsExpand description
The InstanceFlags to build a wgpu instance with: wgpu’s own defaults,
read from the environment, minus VALIDATION_INDIRECT_CALL.
That flag is set in release builds too — it comes from
InstanceFlags::from_build_config’s non-debug branch, so it is not a
debug-only cost. It makes Device::new build a set of compute and render
pipelines that validate the arguments of indirect draws. This renderer
issues no indirect draws at all — not one draw_indirect,
dispatch_indirect or multi_draw_* anywhere in the workspace — so those
pipelines check nothing we will ever submit.
That alone would only be wasted startup work. The reason the flag is
cleared is that building those pipelines is also a way for device creation
to fail, and failing there is not survivable.
wgpu_core::device::resource::Device::new creates the hal device, then its
empty_bgl — which registers a bind-group layout with the Vulkan backend’s
DescriptorAllocator — and only then calls IndirectValidation::new(..)?.
A driver that cannot build them takes that ?, and the early return drops
the hal device without unregistering empty_bgl, because hal objects are
not RAII and need an explicit destroy. Drop for DescriptorAllocator then
finds a non-empty bucket and panics — “buckets are not empty, at least one
BGL has not been unregistered” — from an ordinary, non-unwinding drop, so
its own thread::panicking() guard does not suppress it.
The process therefore dies inside request_device, and neither caller
can do anything about it there: a backend search cannot search past a
panic, and an offscreen renderer cannot fall back to a software adapter.
Reported from the field on an older Windows 10 machine where an app never
opened a window, and confirmed there by setting
WGPU_VALIDATION_INDIRECT_CALL=0, which let the window open. D3D12 has no
DescriptorAllocator and never runs the assertion, which is why forcing
WGPU_BACKEND=dx12 looked like a graphics fix when it was really a way of
not reaching this code.
WGPU_VALIDATION_INDIRECT_CALL is honoured in both directions, so the flag
stays reachable for anyone debugging wgpu itself.