Merge pull request #69 from storytold/pr/gpu-gl-fallback

GPU on wgpu's OpenGL backend (FreeBSD / Linux without Vulkan)
This commit is contained in:
Brandon Thomas
2026-10-05 11:29:02 -04:00
committed by GitHub
21 changed files with 289 additions and 60 deletions
+9 -2
View File
@@ -21,15 +21,22 @@ fn settle(h: &mut Harness<'_, EffectcraftApp>) {
#[test]
fn viewer_draws_gpu_frames_that_match_the_cpu() {
if effectcraft_gpu::Gpu::headless().is_none() {
let Some(probe) = effectcraft_gpu::Gpu::headless() else {
eprintln!("no GPU adapter: skipping");
return;
}
};
// egui-wgpu creates its GL device with WebGL2's limits, which the compositor declines.
let gl = effectcraft_engine::render::Accelerator::name(&probe).ends_with("(Gl)");
drop(probe);
let mut s = Session::default();
s.execute("file.openDemoProject", json!({})).unwrap();
s.execute("time.set", json!({"time": 2.0})).unwrap();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|_| EffectcraftApp::new(s));
settle(&mut h);
if gl && h.state().gpu_adapter().is_none() {
eprintln!("egui-wgpu's GL device has WebGL2 limits: the viewer stays on the CPU, skipping");
return;
}
assert!(h.state().gpu_adapter().is_some(), "GPU compositor on egui-wgpu's device");
let gpu_px = h.state_mut().viewer_pixels().expect("read back the GPU frame");
let gpu_shot = h.render().expect("render");
+6
View File
@@ -10,6 +10,10 @@ use effectcraft_engine::offload::{Inbox, Offload, Post, WorkerReply, WorkerReque
use effectcraft_gpu::Gpu;
use serde_json::json;
/// One device at a time in this test binary: wgpu's OpenGL backend (Mesa llvmpipe on FreeBSD,
/// Linux without Vulkan) panics or crashes when tests create and drive devices concurrently.
static GPU_LOCK: Mutex<()> = Mutex::new(());
/// Holds offloaded jobs until the test runs them.
#[derive(Default)]
struct Manual(Mutex<Vec<(WorkerRequest, Arc<Inbox>)>>);
@@ -59,6 +63,7 @@ fn page() -> (Session, Arc<Manual>) {
#[test]
fn render_queue_jobs_render_on_the_worker_gpu() {
let _gpu = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let Some(g) = Gpu::headless_deferred() else {
eprintln!("no GPU adapter: skipped");
return;
@@ -97,6 +102,7 @@ fn render_queue_jobs_render_on_the_worker_gpu() {
#[test]
fn analyses_render_their_input_on_the_worker_gpu() {
let _gpu = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let Some(g) = Gpu::headless_deferred() else {
eprintln!("no GPU adapter: skipped");
return;