From 973aedefb71492351fa09d19949d366b061d4d48 Mon Sep 17 00:00:00 2001 From: ekirz <359386453+realekirz@users.noreply.github.com> Date: Tue, 24 Nov 2026 10:29:19 +0700 Subject: [PATCH 1/2] Render: skip the viewport pipeline prebuild on a one-sample backend The background prebuild exists to compile the single-sample viewport pipelines early. On OpenGL the startup viewports are already one-sample (startup_samples == 1), so the prebuilt set is the viewport's own: the compiling thread holds the shared GL context longer than wgpu-hal's 1 s lock timeout (gles/wgl.rs) and the main thread panics with "Could not lock adapter context. This is most-likely a deadlock." about a second after startup (Intel HD 4600, shipped 0.5.1, GL 4.3). Vulkan/DX12 keep four samples and keep prebuilding; the existing RUSTUDIO_NO_PIPELINE_PREBUILD still forces the prebuild off. --- crates/rustudio-render/src/render.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/rustudio-render/src/render.rs b/crates/rustudio-render/src/render.rs index 0b018da1..214e3f74 100644 --- a/crates/rustudio-render/src/render.rs +++ b/crates/rustudio-render/src/render.rs @@ -3794,7 +3794,14 @@ impl Renderer { let one_sample_likely = rustudio_core::rustudio_settings::weak_gpu() || rustudio_core::rustudio_settings::performance_value("quality") == "automatic" || rustudio_core::rustudio_settings::performance_value("detail") == "low"; - if one_sample_likely && std::env::var_os("RUSTUDIO_NO_PIPELINE_PREBUILD").is_none() { + // On a backend that already starts at one sample (OpenGL) the prebuilt + // set is the viewport's own: compiling it on a second thread holds the + // shared GL context, and wgpu-hal's context lock gives up after 1 s + // ("Could not lock adapter context"). + if startup_samples(&caps) != 1 + && one_sample_likely + && std::env::var_os("RUSTUDIO_NO_PIPELINE_PREBUILD").is_none() + { let (device, queue) = (device.clone(), queue.clone()); let (g, t, gl, tr, reduced) = (r.globals_layout.clone(), r.tex_layout.clone(), r.glass_layout.clone(), r.terrain_layout.clone(), r.reduced); let (tx, rx) = std::sync::mpsc::channel(); From 9dc89e5f8bbe782f3d9e42ee754a4ffb975216be Mon Sep 17 00:00:00 2001 From: rippelz <67251456+rippelz@users.noreply.github.com> Date: Wed, 25 Nov 2026 17:06:26 -0800 Subject: [PATCH 2/2] Fix borrow of moved caps (use &r.caps) --- crates/rustudio-render/src/render.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rustudio-render/src/render.rs b/crates/rustudio-render/src/render.rs index 214e3f74..9ba55d48 100644 --- a/crates/rustudio-render/src/render.rs +++ b/crates/rustudio-render/src/render.rs @@ -3798,7 +3798,7 @@ impl Renderer { // set is the viewport's own: compiling it on a second thread holds the // shared GL context, and wgpu-hal's context lock gives up after 1 s // ("Could not lock adapter context"). - if startup_samples(&caps) != 1 + if startup_samples(&r.caps) != 1 && one_sample_likely && std::env::var_os("RUSTUDIO_NO_PIPELINE_PREBUILD").is_none() {