Skip to content

Render: skip the viewport pipeline prebuild on a one-sample (OpenGL) backend - #39

Merged
rippelz merged 2 commits into
rippelz:mainfrom
realekirz:fix/gl-no-prebuild-on-gl
Nov 26, 2026
Merged

rippelz merged 2 commits into
rippelz:mainfrom
realekirz:fix/gl-no-prebuild-on-gl

Conversation

@realekirz

Copy link
Copy Markdown
Contributor

Summary

Renderer::with_caps starts a background thread that prebuilds the
single-sample viewport pipelines whenever one_sample_likely (weak GPU /
automatic quality / low detail). On the OpenGL backend the startup viewports
are already one-sample (startup_samples(&caps) == 1), so the "prebuilt" set
is the viewport's own pipelines — and compiling them on a second thread holds
the shared GL context past wgpu-hal's one-second lock timeout
(gles/wgl.rs, CONTEXT_LOCK_TIMEOUT_SECS = 1). The main thread then panics:

wgpu-hal-30.0.1/src/gles/device.rs:874:39:
Could not lock adapter context. This is most-likely a deadlock.

about 1.1 s after "rustudio 0.5.1 ready" — i.e. during the background build.

Change

One condition: only prebuild when the startup viewports are not already
one-sample.

if startup_samples(&caps) != 1
    && one_sample_likely
    && std::env::var_os("RUSTUDIO_NO_PIPELINE_PREBUILD").is_none()
  • OpenGL (sampled_msaa() == false → 1): no thread; the viewport pipelines are
    built on the main thread as the scene needs them, exactly what
    RUSTUDIO_NO_PIPELINE_PREBUILD=1 already does today.
  • Vulkan / DX12 (4 samples): unchanged, the single-sample variants are still
    prebuilt in the background.
  • RUSTUDIO_NO_PIPELINE_PREBUILD still forces the prebuild off.

Verification on the affected machine

Intel HD Graphics 4600, GL 4.3 (20.19.15.5126), Windows 10, released
0.5.1 binary (rustudio-windows-x64.zip), default backend (automatic quality,
weak-GPU mode on):

  • Without the guard (shipped build, no env): panic at the line above,
    --demo --screenshot exits 2 without writing a picture. App log:
    ...01:32:40.699 INFO rustudio::editor "rustudio 0.5.1 ready. ..."
    ...01:32:41.835 ERROR rustudio::crash "Panic at ...gles/device.rs:874:39"
    
  • With the guard's code path (RUSTUDIO_NO_PIPELINE_PREBUILD=1, which takes
    the same branch as the new condition): 3/3 --demo --screenshot runs finish
    clean (~640 KB PNG each), and --demo (real GUI) stays up with no panic.

Tests

crates/rustudio-render/tests/opengl.rs runs gpu_check::build_and_draw, which
calls Renderer::with_caps on a real GL device — on a GL-only machine that
test panics before this change and passes after. The CI adapters are
Vulkan/DX12, where this code path is intentionally unchanged, so the test suite
does not exercise it in CI.

I could not compile this tree on the affected machine (8 GB, the full workspace
build runs out of memory, unrelated to this change); the branch is the v0.5.1
tag plus that one condition, verified through the shipped binary with the
env-var equivalent.

realekirz and others added 2 commits November 24, 2026 10:29
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.
@rippelz
rippelz merged commit 3f1ada8 into rippelz:main Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants