forked from 1b-agent/opencadstudio-upstream
Add GPU backend probe with automatic fallback for older GPUs
Older GPUs without usable DirectX 12 Feature Level 12_0 or working Vulkan support (e.g. legacy Intel iGPUs and other old parts), and old GLES drivers whose shader compiler rejects iced's own shaders, crash at startup or on the first drawing viewport: StagingBelt aborts in Buffer::get_mapped_range (panic=abort, silent exit) on the DX12 path, and shader compilation fails inside iced's gradient pipeline on the GLES path. Selecting a working backend via WGPU_BACKEND before iced boots avoids both classes. - Probe each candidate backend (Windows: dx12,vulkan,gl; Linux: vulkan,gl) in an isolated --gpu-probe child: device request, staging-style mapped upload, render pipeline creation (its fragment shader reads a private vec4 array, catching old-Mesa compile failures), offscreen render and readback. First fully-passing backend wins; explicit --backend / WGPU_BACKEND / --safe-mode always win, and Windows keeps preferring DX12/Vulkan (#55). - Software adapters (WARP/llvmpipe/SwiftShader) are the last resort before a best-effort GL attempt: slow but alive. - The crash sentinel names the attempted backend so only implicated backends are skipped next launch. - Winning probes report adapter limits; GPUs without shader storage buffers get the packed compatibility renderer automatically, with a startup command-line notice so the switch is never silent.
This commit is contained in:
1 parent
472bb9883d
commit
2b38f798c0
7 files changed
+1105
-15
No files matched your search
+13
@@ -100,6 +100,13 @@ pub struct Cli {
|
||||
#[arg(help = crate::t!("Log level (error|warn|info|debug|trace). Also reads RUST_LOG.").into_owned(), long_help = None)]
|
||||
pub log: Option<String>,
|
||||
|
||||
/// Internal: probe one GPU backend offscreen (`dx12|vulkan|gl|sw`), print
|
||||
/// one JSON line on success, then exit 0/1. Spawned by the GPU backend
|
||||
/// resolver so a legacy-driver abort kills only the probe child, never
|
||||
/// the editor itself.
|
||||
#[arg(long, value_name = "BACKEND", hide = true)]
|
||||
pub gpu_probe: Option<String>,
|
||||
|
||||
/// Internal: run as the plugin runner child process.
|
||||
#[arg(long, value_names = ["SOCKET", "CDYLIB"], num_args = 2, hide = true)]
|
||||
pub ocs_plugin_runner: Option<Vec<String>>,
|
||||
@@ -124,6 +131,12 @@ pub struct GuiConfig {
|
||||
pub compat_renderer: bool,
|
||||
/// Command lines to run once the editor is up.
|
||||
pub script_lines: Vec<String>,
|
||||
/// Why this launch switched graphics backend, if it did. Shown once
|
||||
/// as a command-line warning so the switch is never silent.
|
||||
pub gpu_fallback_notice: Option<String>,
|
||||
/// The GPU probe found no shader storage buffers: the packed
|
||||
/// compatibility renderer was enabled automatically for this session.
|
||||
pub gpu_compat_auto: bool,
|
||||
}
|
||||
|
||||
/// Set once by `main` before the GUI boots; read by `app::boot`.
|
||||
|
||||
Reference in new issue
Block a user