GPU: the compositor declines OpenGL adapters at once (#243)

On OpenGL the compositor translated its compute kernels for tens of
seconds (22 s on an RTX 4090) before one failed validation and it fell
back to CPU compositing, all before the window's first frame. It now
declines GL adapters up front, as it declines adapters without compute
shaders. OpenGL is what Window Graphics falls back to for drivers that
crash with DirectX 12 or Vulkan.

Test: opengl_adapters_get_cpu_compositing_at_once (gpu tests_init;
skips without an OpenGL adapter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic 2026-10-08 13:57:08 +07:00
parent 4d5765f158
commit fdb655e78e
2 changed files with 18 additions and 0 deletions

View File

@ -335,6 +335,11 @@ impl GpuContext {
if !adapter.get_downlevel_capabilities().flags.contains(wgpu::DownlevelFlags::COMPUTE_SHADERS) {
return Err(format!("{} ({:?}): no compute shaders", info.name, info.backend));
}
// OpenGL (Window Graphics ▸ OpenGL for drivers that crash otherwise, #243) translates the
// kernels for tens of seconds before one fails validation: CPU compositing at once.
if info.backend == wgpu::Backend::Gl {
return Err(format!("{} (Gl): the GPU compositor needs DirectX 12, Vulkan, Metal or WebGPU", info.name));
}
// egui-wgpu asks for WebGL2's limits on GL (no storage buffers at all): building the
// pipelines there would be a validation error, which release builds only log.
let l = device.limits();

View File

@ -136,6 +136,19 @@ fn initialization_unwind_drains_all_scopes_before_the_next_operation() {
/// Acceptance for the captured RTX 5090 / FXC failure. Future compiler/shader fixes can
/// legitimately make FXC succeed; this diagnostic is deliberately outside portable CI.
/// On OpenGL the compositor declines at once instead of translating its kernels for tens of
/// seconds and then failing (#243). Skips where there is no OpenGL adapter.
#[test]
fn opengl_adapters_get_cpu_compositing_at_once() {
let mut desc = wgpu::InstanceDescriptor::new_without_display_handle();
desc.backends = wgpu::Backends::GL;
let Some((adapter, device, queue)) = native_device(desc, false) else { return };
let t = std::time::Instant::now();
let error = crate::Gpu::new(&adapter, device, queue).err().expect("no GPU compositor on OpenGL");
assert!(error.contains("(Gl)"), "{error}");
assert!(t.elapsed() < std::time::Duration::from_secs(1), "{:?}", t.elapsed());
}
#[test]
#[cfg(target_os = "windows")]
#[ignore = "requires the reproduced Windows DX12/FXC pointwise compiler failure; no adapter skips"]