mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 14:07:34 -06:00
Issue #136: app.gpu {wait:false} still says why the GPU is off; Settings shows "GPU: starting…" while the device is created
Review follow-up: with GPU rendering off (preference, environment, earlier failure) the no-wait reply now reports available=false and the reason at once, without creating the device. The Performance tab no longer calls gpu::available() while the device is still being created, which could block the UI thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6376b1cebf
commit
32e55afee8
@@ -226,18 +226,21 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"versions": ph.versions.iter().map(|v| json!({"name": v.name, "created": v.created})).collect::<Vec<_>>(),
|
||||
}))
|
||||
}),
|
||||
cmd!(query "app.gpu", "GPU Rendering", [], None, "{enabled?: bool, wait?: bool} — allow/forbid GPU rendering (CPU fallback; LIGHTCRAFT_GPU=0 forbids it for the process); returns {enabled, available, adapter, reason (why the GPU is off), lastFallback (latest render redone on the CPU, and why)}. wait: false never waits for a device still being created (available, adapter and reason are then null)", always, |_, p| {
|
||||
cmd!(query "app.gpu", "GPU Rendering", [], None, "{enabled?: bool, wait?: bool} — allow/forbid GPU rendering (CPU fallback; LIGHTCRAFT_GPU=0 forbids it for the process); returns {enabled, available, adapter, reason (why the GPU is off), lastFallback (latest render redone on the CPU, and why)}. wait: false never waits for a device still being created (available, adapter and reason are then null; with GPU rendering off they say so at once)", always, |_, p| {
|
||||
if let Some(on) = p.get("enabled").and_then(Value::as_bool) {
|
||||
lightcraft_gpu::set_enabled(on);
|
||||
}
|
||||
// the UI applies the setting on its first frame: it must not wait seconds for the
|
||||
// device there (issue #136; `warm_up` creates it off the UI thread)
|
||||
if p.get("wait").and_then(Value::as_bool) == Some(false) && !lightcraft_gpu::ready() {
|
||||
// off (preference, environment): known at once, and asking the adapter would
|
||||
// create the device; on: still being created, so nothing is known yet
|
||||
let on = lightcraft_gpu::enabled();
|
||||
return Ok(json!({
|
||||
"enabled": lightcraft_gpu::enabled(),
|
||||
"available": null,
|
||||
"enabled": on,
|
||||
"available": if on { Value::Null } else { Value::Bool(false) },
|
||||
"adapter": null,
|
||||
"reason": null,
|
||||
"reason": if on { None } else { lightcraft_gpu::unavailable_reason() },
|
||||
"lastFallback": lightcraft_gpu::last_fallback(),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user