mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Choose the graphics adapter on multi-GPU Linux machines (#1885)
With the backend on auto, Linux installed no adapter selector, so wgpu took the first discrete GPU the driver listed. On a machine with an eGPU, a laptop dGPU and an iGPU that was not the one the user wanted. - performance.gpuAdapter: a case-insensitive piece of the adapter's name (several words must all appear); empty is automatic. - PHOTOCRAFT_GPU_ADAPTER overrides it for one launch. - Preferences > Performance > Advanced > GPU adapter lists the adapters the instance found; a saved adapter that is absent stays listed, marked. - A missing adapter, or one that can't present to the window, falls back to the automatic choice with a note in System Info. CPU mode ignores it. - Shown on Linux only; tested on Linux only. Windows and macOS need their own work (the startup code honours the setting there, but it is untested). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
d95fdf3181
commit
b892c0412e
29 files changed
+246
-15
No files matched your search
@@ -228,6 +228,8 @@ pub struct Candidate {
|
||||
pub backend: wgpu::Backend,
|
||||
/// Can present to the window.
|
||||
pub surface_ok: bool,
|
||||
/// Its name matches the adapter the user asked for ([`adapter_matches`]).
|
||||
pub wanted: bool,
|
||||
}
|
||||
|
||||
/// Rank of an adapter (lower is better): high-performance device types first (egui's power
|
||||
@@ -259,9 +261,38 @@ fn rank(a: &Candidate, backend: GpuBackend, os: Os) -> (u8, u8, u8) {
|
||||
(fallback, ty, be)
|
||||
}
|
||||
|
||||
/// The adapter to use among `adapters` (`None` when there is none).
|
||||
/// The adapter to use among `adapters` (`None` when there is none). Adapters the user asked for
|
||||
/// win over the rest when any of them can present; otherwise the ranking decides (see
|
||||
/// [`wanted_missed`]).
|
||||
pub fn pick(adapters: &[Candidate], backend: GpuBackend, os: Os) -> Option<usize> {
|
||||
adapters.iter().enumerate().filter(|(_, a)| a.surface_ok).min_by_key(|(i, a)| (rank(a, backend, os), *i)).map(|(i, _)| i)
|
||||
let usable = |a: &&Candidate| a.surface_ok;
|
||||
let any_wanted = adapters.iter().filter(usable).any(|a| a.wanted);
|
||||
adapters
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, a)| a.surface_ok && (a.wanted || !any_wanted))
|
||||
.min_by_key(|(i, a)| (rank(a, backend, os), *i))
|
||||
.map(|(i, _)| i)
|
||||
}
|
||||
|
||||
/// Whether an adapter called `name` is the one the user asked for: `wanted` is a case-insensitive
|
||||
/// piece of its name ("nvidia"), or several words that each appear in it ("arc a370m" finds
|
||||
/// "Intel(R) Arc(tm) A370M Graphics"). An empty `wanted` matches nothing.
|
||||
pub fn adapter_matches(name: &str, wanted: &str) -> bool {
|
||||
let name = name.to_lowercase();
|
||||
let mut words = wanted.split_whitespace().peekable();
|
||||
words.peek().is_some() && words.all(|w| name.contains(&w.to_lowercase()))
|
||||
}
|
||||
|
||||
/// The user asked for an adapter and none of `adapters` that can present is it.
|
||||
pub fn wanted_missed(adapters: &[Candidate], wanted: Option<&str>) -> bool {
|
||||
wanted.is_some() && !adapters.iter().any(|a| a.surface_ok && a.wanted)
|
||||
}
|
||||
|
||||
/// The adapter to ask for: `PHOTOCRAFT_GPU_ADAPTER` when set (for one launch), else
|
||||
/// `performance.gpuAdapter`; `None` is automatic.
|
||||
pub fn wanted_adapter(env: Option<&str>, pref: &str) -> Option<String> {
|
||||
[env.unwrap_or(""), pref].iter().map(|s| s.trim()).find(|s| !s.is_empty()).map(str::to_string)
|
||||
}
|
||||
|
||||
/// Whether picking `chosen` applied the Intel-on-Windows DX12 default (a Vulkan adapter of the
|
||||
@@ -285,7 +316,7 @@ fn skips_indirect_validation(os: Os, intel: bool) -> bool {
|
||||
/// Configure eframe's wgpu setup for `plan`: instance backends, the DX12 shader compiler, adapter
|
||||
/// selection (Intel on Windows, software adapters for `cpu`) and the marker update once the
|
||||
/// adapter is chosen. `note` receives a remark for System Info (e.g. the Intel default).
|
||||
pub fn configure(setup: &mut egui_wgpu::WgpuSetup, plan: &Plan, os: Os, sentinel: SharedSentinel, note: Arc<Mutex<Option<String>>>) {
|
||||
pub fn configure(setup: &mut egui_wgpu::WgpuSetup, plan: &Plan, os: Os, wanted: Option<String>, sentinel: SharedSentinel, note: Arc<Mutex<Option<String>>>) {
|
||||
if let egui_wgpu::WgpuSetup::CreateNew(create) = setup {
|
||||
if let Some(b) = backends(plan, os) {
|
||||
create.instance_descriptor.backends = b;
|
||||
@@ -298,7 +329,9 @@ pub fn configure(setup: &mut egui_wgpu::WgpuSetup, plan: &Plan, os: Os, sentinel
|
||||
let env = std::env::var("WGPU_DX12_COMPILER").ok();
|
||||
create.instance_descriptor.backend_options.dx12.shader_compiler = dx12_compiler(env.as_deref(), exe.as_deref().and_then(Path::parent));
|
||||
}
|
||||
let select = plan.env.is_none() && (plan.backend == GpuBackend::Cpu || (plan.backend == GpuBackend::Auto && os == Os::Windows));
|
||||
// CPU mode wants a software adapter, whatever the preference says.
|
||||
let wanted = wanted.filter(|_| plan.backend != GpuBackend::Cpu);
|
||||
let select = wanted.is_some() || (plan.env.is_none() && (plan.backend == GpuBackend::Cpu || (plan.backend == GpuBackend::Auto && os == Os::Windows)));
|
||||
if select {
|
||||
let backend = plan.backend;
|
||||
create.native_adapter_selector = Some(Arc::new(move |adapters: &[wgpu::Adapter], surface: Option<&wgpu::Surface<'_>>| {
|
||||
@@ -311,10 +344,15 @@ pub fn configure(setup: &mut egui_wgpu::WgpuSetup, plan: &Plan, os: Os, sentinel
|
||||
device_type: i.device_type,
|
||||
backend: i.backend,
|
||||
surface_ok: surface.is_none_or(|s| a.is_surface_supported(s)),
|
||||
wanted: wanted.as_deref().is_some_and(|w| adapter_matches(&i.name, w)),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let i = pick(&cands, backend, os).ok_or_else(|| "no graphics adapter found".to_string())?;
|
||||
if let Some(w) = wanted.as_deref().filter(|_| wanted_missed(&cands, wanted.as_deref())) {
|
||||
*note.lock().unwrap_or_else(PoisonError::into_inner) =
|
||||
Some(format!("No graphics adapter named \"{w}\" can draw the window; using the automatic choice"));
|
||||
}
|
||||
if backend == GpuBackend::Cpu && cands.get(i).is_some_and(|c| c.device_type != wgpu::DeviceType::Cpu) {
|
||||
*note.lock().unwrap_or_else(PoisonError::into_inner) =
|
||||
Some("CPU image rendering; no software graphics adapter is available, so the window uses hardware graphics".into());
|
||||
@@ -443,6 +481,13 @@ pub fn read_display_server(path: Option<&Path>) -> photocraft_engine::prefs::Lin
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Preferences › Performance › Graphics Adapter (`performance.gpuAdapter`), read before the window
|
||||
/// opens; empty (automatic) when the file or value is missing.
|
||||
pub fn read_gpu_adapter(path: Option<&Path>) -> String {
|
||||
let v: Value = path.and_then(|p| std::fs::read_to_string(p).ok()).and_then(|t| serde_json::from_str(&t).ok()).unwrap_or(Value::Null);
|
||||
v.get("performance").and_then(|p| p.get("gpuAdapter")).and_then(Value::as_str).unwrap_or("").chars().take(256).collect()
|
||||
}
|
||||
|
||||
/// Preferences › Performance › Low-Latency Drawing (`performance.lowLatencyDrawing`, off unless
|
||||
/// turned on), read before the window opens: it picks the surface's present mode.
|
||||
pub fn read_low_latency(path: Option<&Path>) -> bool {
|
||||
@@ -604,7 +649,60 @@ mod tests {
|
||||
}
|
||||
|
||||
fn cand(vendor: u32, device_type: wgpu::DeviceType, backend: wgpu::Backend) -> Candidate {
|
||||
Candidate { vendor, device_type, backend, surface_ok: true }
|
||||
Candidate { vendor, device_type, backend, surface_ok: true, wanted: false }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_requested_adapter_beats_the_automatic_ranking() {
|
||||
use wgpu::{Backend as B, DeviceType as T};
|
||||
// The order Vulkan lists this machine's GPUs in: iGPU, dGPU, eGPU.
|
||||
let mut a = [cand(INTEL, T::IntegratedGpu, B::Vulkan), cand(INTEL, T::DiscreteGpu, B::Vulkan), cand(0x10de, T::DiscreteGpu, B::Vulkan)];
|
||||
assert_eq!(pick(&a, Auto, Os::Other), Some(1), "automatic takes the first discrete adapter, the Arc");
|
||||
a[2].wanted = true;
|
||||
assert_eq!(pick(&a, Auto, Os::Other), Some(2));
|
||||
a[2].wanted = false;
|
||||
a[0].wanted = true;
|
||||
assert_eq!(pick(&a, Auto, Os::Other), Some(0), "even the iGPU, when asked for");
|
||||
// A wanted adapter that can't present is skipped, not an error.
|
||||
a[0].surface_ok = false;
|
||||
assert_eq!(pick(&a, Auto, Os::Other), Some(1));
|
||||
assert!(wanted_missed(&a, Some("iris")));
|
||||
assert!(!wanted_missed(&a, None));
|
||||
a[0].surface_ok = true;
|
||||
assert!(!wanted_missed(&a, Some("iris")));
|
||||
// Among several wanted ones (same GPU on Vulkan and GL) the usual ranking decides.
|
||||
let mut gl = [cand(0x10de, T::DiscreteGpu, B::Gl), cand(0x10de, T::DiscreteGpu, B::Vulkan)];
|
||||
gl.iter_mut().for_each(|c| c.wanted = true);
|
||||
assert_eq!(pick(&gl, Auto, Os::Other), Some(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adapter_names_match_loosely_and_the_environment_wins() {
|
||||
assert!(adapter_matches("NVIDIA GeForce RTX 5060 Ti", "nvidia"));
|
||||
assert!(adapter_matches("Intel(R) Arc(tm) A370M Graphics (DG2)", " ARC A370M "));
|
||||
assert!(!adapter_matches("Intel(R) Iris(R) Xe Graphics (ADL GT2)", "arc"));
|
||||
assert!(!adapter_matches("anything", ""));
|
||||
assert!(!adapter_matches("anything", " "));
|
||||
assert_eq!(wanted_adapter(None, ""), None);
|
||||
assert_eq!(wanted_adapter(Some(" "), "iris"), Some("iris".into()));
|
||||
assert_eq!(wanted_adapter(Some("nvidia"), "iris"), Some("nvidia".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gpu_adapter_is_read_before_the_window_opens() {
|
||||
let dir = std::env::temp_dir().join(format!("photocraft-gpu-adapter-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let file = dir.join("preferences.json");
|
||||
let read = |json: &str| {
|
||||
std::fs::write(&file, json).unwrap();
|
||||
read_gpu_adapter(Some(&file))
|
||||
};
|
||||
assert_eq!(read(r#"{"performance":{"gpuAdapter":"nvidia"}}"#), "nvidia");
|
||||
assert_eq!(read(r#"{"performance":{"gpuAdapter":7}}"#), "");
|
||||
assert_eq!(read(r#"{"performance":{}}"#), "");
|
||||
assert_eq!(read("not json"), "");
|
||||
assert_eq!(read_gpu_adapter(None), "");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -894,7 +992,7 @@ mod tests {
|
||||
// The app's setup replaces wgpu's default (`Auto`: DXC by name from the search path).
|
||||
let mut setup = egui_wgpu::WgpuSetup::without_display_handle();
|
||||
let plan = plan(Auto, None, None, false, Os::Windows);
|
||||
configure(&mut setup, &plan, Os::Windows, Arc::new(Mutex::new(None)), Arc::default());
|
||||
configure(&mut setup, &plan, Os::Windows, None, Arc::new(Mutex::new(None)), Arc::default());
|
||||
let egui_wgpu::WgpuSetup::CreateNew(create) = &setup else { panic!("a new instance") };
|
||||
if std::env::var_os("WGPU_DX12_COMPILER").is_none() {
|
||||
let safe = match &create.instance_descriptor.backend_options.dx12.shader_compiler {
|
||||
@@ -918,13 +1016,13 @@ mod tests {
|
||||
let mut setup = egui_wgpu::WgpuSetup::without_display_handle();
|
||||
let egui_wgpu::WgpuSetup::CreateNew(before) = &setup else { panic!("a new instance") };
|
||||
let before = before.instance_descriptor.flags;
|
||||
configure(&mut setup, &plan(Auto, None, None, safe_gpu, os), os, Arc::new(Mutex::new(None)), Arc::default());
|
||||
configure(&mut setup, &plan(Auto, None, None, safe_gpu, os), os, None, Arc::new(Mutex::new(None)), Arc::default());
|
||||
let egui_wgpu::WgpuSetup::CreateNew(create) = &setup else { panic!("a new instance") };
|
||||
assert_eq!(create.instance_descriptor.flags, before, "{os:?}: flags untouched");
|
||||
}
|
||||
if cfg!(target_arch = "x86_64") && std::env::var_os("WGPU_VALIDATION_INDIRECT_CALL").is_none() {
|
||||
let mut setup = egui_wgpu::WgpuSetup::without_display_handle();
|
||||
configure(&mut setup, &plan(Auto, None, None, false, Os::Mac), Os::Mac, Arc::new(Mutex::new(None)), Arc::default());
|
||||
configure(&mut setup, &plan(Auto, None, None, false, Os::Mac), Os::Mac, None, Arc::new(Mutex::new(None)), Arc::default());
|
||||
let egui_wgpu::WgpuSetup::CreateNew(create) = &setup else { panic!("a new instance") };
|
||||
assert!(!create.instance_descriptor.flags.contains(wgpu::InstanceFlags::VALIDATION_INDIRECT_CALL));
|
||||
}
|
||||
|
||||
@@ -678,7 +678,11 @@ fn main() -> eframe::Result {
|
||||
}
|
||||
let gpu_note: std::sync::Arc<std::sync::Mutex<Option<String>>> = Default::default();
|
||||
// The adapter's real texture limits (egui asks for 8192 px), so big documents stay on the GPU.
|
||||
gpu_startup::configure(&mut options.wgpu_options.wgpu_setup, &plan, os, sentinel.clone(), gpu_note.clone());
|
||||
let wanted_adapter = gpu_startup::wanted_adapter(
|
||||
std::env::var("PHOTOCRAFT_GPU_ADAPTER").ok().as_deref(),
|
||||
&gpu_startup::read_gpu_adapter(services::prefs_file().as_deref()),
|
||||
);
|
||||
gpu_startup::configure(&mut options.wgpu_options.wgpu_setup, &plan, os, wanted_adapter, sentinel.clone(), gpu_note.clone());
|
||||
// Preferences › Performance › Low-Latency Drawing (#1343): without vsync a stroke shows about
|
||||
// 50 ms sooner; wgpu picks Immediate, else Mailbox, else Fifo by what the driver offers.
|
||||
if gpu_startup::read_low_latency(services::prefs_file().as_deref()) {
|
||||
@@ -774,6 +778,7 @@ fn main() -> eframe::Result {
|
||||
info.canvas = "cpu".into();
|
||||
if let Some(rs) = cc.wgpu_render_state.clone() {
|
||||
app.perf.gpu_info.set_adapter(&rs.adapter.get_info());
|
||||
app.perf.gpu_info.set_available(&rs.available_adapters);
|
||||
let software_window = rs.adapter.get_info().device_type == eframe::wgpu::DeviceType::Cpu;
|
||||
if software_window && mode != photocraft_engine::prefs::RenderingMode::Cpu {
|
||||
app.perf.gpu_info.fallback = Some("No compatible hardware graphics adapter; using software graphics.".into());
|
||||
|
||||
@@ -525,6 +525,11 @@ pub struct Performance {
|
||||
pub rendering_mode: Option<RenderingMode>,
|
||||
/// Graphics backend (applies at next launch; see [`GpuBackend`]).
|
||||
pub gpu_backend: GpuBackend,
|
||||
/// Which graphics adapter the window and canvas use on a machine with several (applies at
|
||||
/// next launch): part of the adapter's name, matched case-insensitively ("nvidia", "arc"). Empty
|
||||
/// is automatic. `PHOTOCRAFT_GPU_ADAPTER` overrides it for one launch. If nothing matches or the
|
||||
/// match can't present to the window, startup falls back to automatic and says so.
|
||||
pub gpu_adapter: String,
|
||||
/// Live previews of large documents (adjustment and filter dialogs, an adjustment layer's
|
||||
/// sliders while they drag) render on a reduced copy: fast, but blocky when zoomed in. Off:
|
||||
/// they render at full resolution.
|
||||
@@ -570,6 +575,7 @@ impl Default for Performance {
|
||||
use_gpu: true,
|
||||
rendering_mode: None,
|
||||
gpu_backend: GpuBackend::Auto,
|
||||
gpu_adapter: String::new(),
|
||||
low_resolution_previews: true,
|
||||
low_latency_drawing: false,
|
||||
linux_display_server: LinuxDisplayServer::Auto,
|
||||
@@ -1059,7 +1065,7 @@ pub fn is_hidden(path: &str) -> bool {
|
||||
|
||||
/// Preferences that only do something on Linux; the dialog doesn't show them elsewhere. They
|
||||
/// still load, save and round-trip on every platform.
|
||||
pub const LINUX_ONLY: &[&str] = &["performance.linuxDisplayServer"];
|
||||
pub const LINUX_ONLY: &[&str] = &["performance.linuxDisplayServer", "performance.gpuAdapter"];
|
||||
|
||||
/// Choices of an enumerated preference (dotted path, e.g. `"cursors.painting"`).
|
||||
pub fn choices(path: &str) -> Option<&'static [&'static str]> {
|
||||
|
||||
@@ -493,6 +493,22 @@ fn right_click_with_painting_tools_pref() {
|
||||
assert_eq!(old.right_click_with_painting_tools, RightClickPaint::BrushPicker);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gpu_adapter_round_trips_and_defaults_to_automatic() {
|
||||
let mut s = session();
|
||||
assert_eq!(s.prefs().performance.gpu_adapter, "");
|
||||
s.execute("prefs.set", json!({"path": "performance.gpuAdapter", "value": "NVIDIA"})).unwrap();
|
||||
assert_eq!(s.prefs().performance.gpu_adapter, "NVIDIA");
|
||||
assert!(s.execute("prefs.set", json!({"path": "performance.gpuAdapter", "value": 3})).is_err());
|
||||
assert_eq!(s.prefs().performance.gpu_adapter, "NVIDIA");
|
||||
let mut t = Session::new();
|
||||
t.load_prefs_json(&s.prefs_to_json()).unwrap();
|
||||
assert_eq!(t.prefs().performance.gpu_adapter, "NVIDIA");
|
||||
let mut u = Session::new();
|
||||
u.load_prefs_json(r#"{"performance": {"useGpu": true}}"#).unwrap();
|
||||
assert_eq!(u.prefs().performance.gpu_adapter, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gpu_backend_round_trips_and_validates() {
|
||||
let mut s = session();
|
||||
@@ -553,7 +569,9 @@ fn notification_autohide_preferences() {
|
||||
fn linux_only_preferences_show_only_on_linux() {
|
||||
assert_eq!(is_hidden("performance.linuxDisplayServer"), !cfg!(target_os = "linux"));
|
||||
assert!(!is_hidden("performance.gpuBackend"));
|
||||
assert!(LINUX_ONLY.iter().all(|p| choices(p).is_some()), "every Linux-only preference is a real one");
|
||||
assert!(LINUX_ONLY.contains(&"performance.gpuAdapter"));
|
||||
let free_text = ["performance.gpuAdapter"];
|
||||
assert!(LINUX_ONLY.iter().all(|p| free_text.contains(p) || choices(p).is_some()), "every Linux-only preference is a real one");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1058,6 +1058,9 @@ pub struct GpuInfo {
|
||||
pub video_memory_mb: Option<u64>,
|
||||
/// `performance.gpuBackend` at launch.
|
||||
pub preference: String,
|
||||
/// Every graphics adapter the window could have used, by name (Preferences › Performance ›
|
||||
/// Graphics Adapter lists them). Empty in hosts that don't set it.
|
||||
pub adapters: Vec<String>,
|
||||
/// The backend startup chose ("auto", "dx12", "cpu", …, or "env" for `WGPU_BACKEND`).
|
||||
pub selected: String,
|
||||
/// Why startup didn't use the preference as is (previous start crashed, `--safe-gpu`,
|
||||
@@ -1073,6 +1076,17 @@ pub struct GpuInfo {
|
||||
}
|
||||
|
||||
impl GpuInfo {
|
||||
/// Record the adapters the instance found, without duplicates (one GPU shows up once per backend).
|
||||
pub fn set_available(&mut self, adapters: &[wgpu::Adapter]) {
|
||||
self.adapters.clear();
|
||||
for a in adapters {
|
||||
let name = a.get_info().name;
|
||||
if !name.is_empty() && !self.adapters.contains(&name) {
|
||||
self.adapters.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Fill the adapter fields from `info`.
|
||||
pub fn set_adapter(&mut self, info: &wgpu::AdapterInfo) {
|
||||
self.adapter = info.name.clone();
|
||||
|
||||
@@ -3838,3 +3838,6 @@ navigator Zoom Zvětšení
|
||||
Increase Brush Size Zvětšit velikost štětce
|
||||
Decrease Brush Hardness Snížit tvrdost štětce
|
||||
Increase Brush Hardness Zvýšit tvrdost štětce
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptér GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3230,3 +3230,6 @@ curves Smooth Glätten
|
||||
GPU Memory (MB, 0 = Automatic) GPU-Speicher (MB, 0 = Automatisch)
|
||||
{name} was changed by another app after it was opened or saved here. {name} wurde von einer anderen App geändert, nachdem es hier geöffnet oder gespeichert wurde.
|
||||
Replace it with this document, or cancel and use File › Save As to keep both. Ersetze die Datei durch dieses Dokument oder brich ab und nutze Datei › Speichern unter, um beide zu behalten.
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU-Adapter
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3930,3 +3930,6 @@ curves Smooth Εξομάλυνση
|
||||
Increase Brush Size Αύξηση μεγέθους πινέλου
|
||||
Decrease Brush Hardness Μείωση σκληρότητας πινέλου
|
||||
Increase Brush Hardness Αύξηση σκληρότητας πινέλου
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Προσαρμογέας GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 1030 and column 18.
|
@@ -4192,3 +4192,6 @@ navigator Zoom Zoom
|
||||
Increase Brush Size Aumentar tamaño del pincel
|
||||
Decrease Brush Hardness Reducir dureza del pincel
|
||||
Increase Brush Hardness Aumentar dureza del pincel
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptador de GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -3238,3 +3238,6 @@ curves Smooth Lisser
|
||||
Increase Brush Size Augmenter la taille du pinceau
|
||||
Decrease Brush Hardness Réduire la dureté du pinceau
|
||||
Increase Brush Hardness Augmenter la dureté du pinceau
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptateur GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4149,3 +4149,6 @@ cameraRaw Yellow Sárga
|
||||
Increase Brush Size Ecsetméret növelése
|
||||
Decrease Brush Hardness Ecsetkeménység csökkentése
|
||||
Increase Brush Hardness Ecsetkeménység növelése
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU-adapter
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3225,3 +3225,6 @@ curves Smooth Haluskan
|
||||
Increase Brush Size Perbesar ukuran kuas
|
||||
Decrease Brush Hardness Kurangi kekerasan kuas
|
||||
Increase Brush Hardness Tambah kekerasan kuas
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptor GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -4347,3 +4347,6 @@ shape Appearance Aspetto
|
||||
GPU Memory (MB, 0 = Automatic) Memoria GPU (MB, 0 = Automatico)
|
||||
{name} was changed by another app after it was opened or saved here. {name} è stato modificato da un'altra app dopo essere stato aperto o salvato qui.
|
||||
Replace it with this document, or cancel and use File › Save As to keep both. Sostituiscilo con questo documento, oppure annulla e usa File › Salva con nome per tenerli entrambi.
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adattatore GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 2653 and column 53.
|
@@ -3907,3 +3907,6 @@ curves Smooth スムーズ
|
||||
Increase Brush Size ブラシサイズを大きく
|
||||
Decrease Brush Hardness ブラシの硬さを下げる
|
||||
Increase Brush Hardness ブラシの硬さを上げる
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU アダプター
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3411,3 +3411,6 @@ curves Smooth 매끄럽게
|
||||
Increase Brush Size 브러시 크기 늘리기
|
||||
Decrease Brush Hardness 브러시 경도 줄이기
|
||||
Increase Brush Hardness 브러시 경도 늘리기
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU 어댑터
|
||||
|
Can't render this file because it contains an unexpected character in line 3167 and column 53.
|
@@ -3990,3 +3990,6 @@ curves Smooth Vloeiend maken
|
||||
Increase Brush Size Penseelgrootte vergroten
|
||||
Decrease Brush Hardness Penseelhardheid verlagen
|
||||
Increase Brush Hardness Penseelhardheid verhogen
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU-adapter
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -3829,3 +3829,6 @@ curves Smooth Wygładź
|
||||
Increase Brush Size Zwiększ rozmiar pędzla
|
||||
Decrease Brush Hardness Zmniejsz twardość pędzla
|
||||
Increase Brush Hardness Zwiększ twardość pędzla
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Karta GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4020,3 +4020,6 @@ layerLabel No Color Sem cor
|
||||
Increase Brush Size Aumentar tamanho do pincel
|
||||
Decrease Brush Hardness Diminuir dureza do pincel
|
||||
Increase Brush Hardness Aumentar dureza do pincel
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptador de GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3203,3 +3203,6 @@ curves Smooth Сгладить
|
||||
Increase Brush Size Увеличить размер кисти
|
||||
Decrease Brush Hardness Уменьшить жёсткость кисти
|
||||
Increase Brush Hardness Увеличить жёсткость кисти
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Адаптер GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4303,3 +4303,6 @@ shape Appearance Izgled
|
||||
Increase Brush Size Povećaj veličinu četkice
|
||||
Decrease Brush Hardness Smanji tvrdoću četkice
|
||||
Increase Brush Hardness Povećaj tvrdoću četkice
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU adapter
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3960,3 +3960,6 @@ cameraData Lens Lens
|
||||
Increase Brush Size Fırça boyutunu büyüt
|
||||
Decrease Brush Hardness Fırça sertliğini azalt
|
||||
Increase Brush Hardness Fırça sertliğini artır
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU bağdaştırıcısı
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -3938,3 +3938,6 @@ curves Smooth Згладити
|
||||
This shape layer must be rasterized before proceeding. It will no longer be editable as a shape. Rasterize the shape? Щоб продовжити, потрібно растеризувати цей шар фігури. Після цього його більше не можна буде редагувати як фігуру. Растеризувати фігуру?
|
||||
This Smart Object must be rasterized before proceeding. Its contents will no longer be editable. Rasterize the Smart Object? Щоб продовжити, потрібно растеризувати цей смартоб’єкт. Після цього його вміст більше не можна буде редагувати. Растеризувати смартоб’єкт?
|
||||
This fill layer must be rasterized before proceeding. Its fill content will no longer be editable. Rasterize the layer? Щоб продовжити, потрібно растеризувати цей шар заливки. Після цього його заливку більше не можна буде редагувати. Растеризувати шар?
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Адаптер GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 1388 and column 18.
|
@@ -3717,3 +3717,6 @@ curves Smooth Làm mượt
|
||||
Increase Brush Size Tăng kích thước cọ
|
||||
Decrease Brush Hardness Giảm độ cứng của cọ
|
||||
Increase Brush Hardness Tăng độ cứng của cọ
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Bộ điều hợp GPU
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2853,3 +2853,6 @@ curves Smooth 平滑
|
||||
Increase Brush Size 增大画笔大小
|
||||
Decrease Brush Hardness 减小画笔硬度
|
||||
Increase Brush Hardness 增大画笔硬度
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU 适配器
|
||||
|
Can't render this file because it contains an unexpected character in line 2601 and column 53.
|
@@ -2838,3 +2838,6 @@ curves Smooth 平滑
|
||||
Increase Brush Size 放大筆刷大小
|
||||
Decrease Brush Hardness 降低筆刷硬度
|
||||
Increase Brush Hardness 提高筆刷硬度
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU 介面卡
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1013,6 +1013,7 @@ impl PhotocraftApp {
|
||||
let tile = self.session.prefs().performance.cache_tile_size;
|
||||
// Escaped driver/setup panics must leave the session and CPU canvas alive.
|
||||
self.perf.gpu_info.set_adapter(&rs.adapter.get_info());
|
||||
self.perf.gpu_info.set_available(&rs.available_adapters);
|
||||
let gpu = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| gpu_canvas::GpuCanvas::with_tile(&rs, Some(tile)))) {
|
||||
Ok(gpu) => gpu,
|
||||
Err(payload) => {
|
||||
|
||||
@@ -1058,6 +1058,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
|
||||
let mut info = app.perf.gpu_info.lines();
|
||||
info.extend(gpu_memory_lines(app));
|
||||
f.insert("__gpuInfo".into(), json!(info));
|
||||
f.insert("__gpuAdapters".into(), json!(app.perf.gpu_info.adapters));
|
||||
let system = system_theme(app, ui.ctx());
|
||||
prefs_body(ui, f, system);
|
||||
}
|
||||
@@ -1287,7 +1288,7 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map<String, Value>, system: Option<egui
|
||||
);
|
||||
}
|
||||
if section == "performance" {
|
||||
gpu_status_rows(ui, f.get("__gpuInfo"), obj);
|
||||
gpu_status_rows(ui, f.get("__gpuInfo"), f.get("__gpuAdapters"), obj);
|
||||
}
|
||||
ui.add_space(8.0);
|
||||
}
|
||||
@@ -1312,7 +1313,7 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map<String, Value>, system: Option<egui
|
||||
|
||||
/// Preferences › Performance: what the app renders with now, and a reset of the GPU backend
|
||||
/// (a crashed start may have moved it to a safer choice).
|
||||
fn gpu_status_rows(ui: &mut egui::Ui, info: Option<&Value>, obj: &mut Map<String, Value>) {
|
||||
fn gpu_status_rows(ui: &mut egui::Ui, info: Option<&Value>, adapters: Option<&Value>, obj: &mut Map<String, Value>) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
ui.add_space(10.0);
|
||||
ui.label(RichText::new(tl!("Graphics")).font(crate::theme::semibold(12.5)).color(t.text));
|
||||
@@ -1331,9 +1332,34 @@ fn gpu_status_rows(ui: &mut egui::Ui, info: Option<&Value>, obj: &mut Map<String
|
||||
crate::widgets::dropdown(ui, "graphics-backend", &mut current, &pairs, 220.0);
|
||||
obj.insert("gpuBackend".into(), json!(current));
|
||||
});
|
||||
if !prefs::is_hidden("performance.gpuAdapter") {
|
||||
graphics_adapter_row(ui, adapters, obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Preferences › Performance › Graphics Adapter: which GPU draws on a machine with several. The
|
||||
/// value is the adapter's name; empty is automatic. A saved adapter that isn't present now (an
|
||||
/// unplugged eGPU) stays listed, marked ⚠, so opening the dialog doesn't silently change the choice.
|
||||
fn graphics_adapter_row(ui: &mut egui::Ui, adapters: Option<&Value>, obj: &mut Map<String, Value>) {
|
||||
let mut current = obj.get("gpuAdapter").and_then(Value::as_str).unwrap_or("").to_string();
|
||||
let mut names: Vec<String> = adapters.and_then(Value::as_array).into_iter().flatten().filter_map(Value::as_str).map(str::to_string).collect();
|
||||
let missing = !current.is_empty() && !names.contains(¤t);
|
||||
if missing {
|
||||
names.push(current.clone());
|
||||
}
|
||||
let automatic = tl!("Automatic");
|
||||
let labels: Vec<String> = names.iter().map(|n| if missing && *n == current { format!("⚠ {n}") } else { n.clone() }).collect();
|
||||
let mut pairs: Vec<(String, &str)> = vec![(String::new(), automatic)];
|
||||
pairs.extend(names.iter().cloned().zip(labels.iter().map(String::as_str)));
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(tl!("GPU adapter"));
|
||||
crate::widgets::dropdown_literal(ui, "graphics-adapter", &mut current, &pairs, 320.0);
|
||||
});
|
||||
ui.label(RichText::new(tl!("Applies at next launch.")).color(Tokens::get(ui.ctx()).text_faint));
|
||||
obj.insert("gpuAdapter".into(), json!(current));
|
||||
}
|
||||
|
||||
/// One user-facing choice; legacy flags remain compatible with older settings.
|
||||
fn rendering_mode_row(ui: &mut egui::Ui, obj: &mut Map<String, Value>) {
|
||||
let mut current = rendering_mode_value(obj);
|
||||
@@ -1566,7 +1592,7 @@ fn field_visible(section: &str, obj: &Map<String, Value>, k: &str, query: &str)
|
||||
let drawn_elsewhere = (section == "interface" && matches!(k, "theme" | "appearanceMode" | "darkTheme" | "lightTheme" | "favoriteThemes"))
|
||||
// View › Rulers (⌘R) sets it, as in Photoshop.
|
||||
|| path == "unitsAndRulers.showRulers"
|
||||
|| (section == "performance" && matches!(k, "useGpu" | "gpuBackend" | "renderingMode"))
|
||||
|| (section == "performance" && matches!(k, "useGpu" | "gpuBackend" | "gpuAdapter" | "renderingMode"))
|
||||
// The browser presents frames itself: Low-Latency Drawing does nothing there.
|
||||
|| (cfg!(target_arch = "wasm32") && path == "performance.lowLatencyDrawing")
|
||||
|| (section == "export" && !export_field_visible(obj, k))
|
||||
|
||||
+2
-1
@@ -86,7 +86,7 @@ On Windows and Linux the first PhotoCraft holds an exclusive lock on `instance.l
|
||||
|
||||
## Graphics startup and device loss
|
||||
|
||||
`--safe-gpu` starts with the CPU renderer for one launch (no GPU canvas; a software adapter for the window where the platform has one: WARP on Windows, llvmpipe over GL on Linux). Before creating the wgpu device the app writes and locks `gpu-starting.json` in the config directory; it clears it once the first frames have rendered. A launch that finds an unlocked marker knows the previous start died inside the graphics driver (#4) and uses the next safer backend (Windows: Vulkan → DX12 → CPU; Linux: Vulkan → GL → CPU; macOS: Metal → CPU), remembering a working hardware backend in `performance.gpuBackend` (Preferences › Performance › GPU Backend, with **Reset GPU Backend**). CPU recovery is temporary until **Keep Using CPU** is chosen in the recovery dialog; dismissing the dialog or quitting without a choice preserves the previous GPU preference (#3483). With `auto`, Intel adapters on Windows use DX12. Help › System Info shows the adapter, backend, driver and fallback state.
|
||||
`--safe-gpu` starts with the CPU renderer for one launch (no GPU canvas; a software adapter for the window where the platform has one: WARP on Windows, llvmpipe over GL on Linux). Before creating the wgpu device the app writes and locks `gpu-starting.json` in the config directory; it clears it once the first frames have rendered. A launch that finds an unlocked marker knows the previous start died inside the graphics driver (#4) and uses the next safer backend (Windows: Vulkan → DX12 → CPU; Linux: Vulkan → GL → CPU; macOS: Metal → CPU), remembering a working hardware backend in `performance.gpuBackend` (Preferences › Performance › GPU Backend, with **Reset GPU Backend**). CPU recovery is temporary until **Keep Using CPU** is chosen in the recovery dialog; dismissing the dialog or quitting without a choice preserves the previous GPU preference (#3483). With `auto`, Intel adapters on Windows use DX12. On a machine with several GPUs (say an eGPU, a discrete laptop GPU and an iGPU), `auto` takes the first discrete adapter the driver lists; choose another in Preferences › Performance › Advanced › GPU adapter (`performance.gpuAdapter`, Linux; a case-insensitive piece of the adapter's name, empty is automatic), or for one launch with `PHOTOCRAFT_GPU_ADAPTER=nvidia`. An adapter that is missing or can't present to the window falls back to the automatic choice, with a note in System Info. Help › System Info shows the adapter, backend, driver and fallback state.
|
||||
|
||||
On DX12 the shader compiler is FXC (`d3dcompiler_47.dll`, part of Windows), or a `dxcompiler.dll` placed beside `photocraft.exe`, loaded by its full path. wgpu's default looks `dxcompiler.dll` up by name, which reaches the current directory and `PATH` and loaded other programs' incompatible builds (#712).
|
||||
|
||||
@@ -116,6 +116,7 @@ By default PhotoCraft's own crates log at `info` and everything else at `warn`.
|
||||
| `PHOTOCRAFT_AUTOMATION_WRITE_ROOT` | Desktop app only: automation write root. Headless CLI modes require the `--automation-write-root` flag |
|
||||
| `PHOTOCRAFT_CPU_CANVAS=1` | Force the CPU canvas path instead of the wgpu shader canvas |
|
||||
| `PHOTOCRAFT_NATIVE_WAYLAND=1` | Linux: stay on native Wayland when a pen is attached (by default the window then opens through Xwayland, because Wayland gives the app no pen input; #639). A pen is an input device with `BTN_TOOL_PEN` and the `ABS_X`/`ABS_Y` axes; virtual keyboards that claim every key are not pens (#1072) |
|
||||
| `PHOTOCRAFT_GPU_ADAPTER=nvidia` | Use the graphics adapter whose name contains this (case-insensitive); overrides `performance.gpuAdapter` for one launch |
|
||||
| `WGPU_BACKEND=dx12` | Pick the wgpu backend(s) (`vulkan`, `dx12`, `metal`, `gl`); overrides `performance.gpuBackend` and the startup fallback |
|
||||
| `WGPU_DX12_COMPILER=fxc` | DX12 shader compiler (`fxc`, `dxc`, `auto`); `dxc` and `auto` look `dxcompiler.dll` up through the DLL search path |
|
||||
| `PHOTOCRAFT_GPU_TILE=2048` | Force GPU canvas tiling (tests tile seams) |
|
||||
|
||||
@@ -22,6 +22,7 @@ HDR display to verify.
|
||||
| GPU filters (Blur Gallery, Liquify, Smart Sharpen, Camera Raw) | yes | CPU (rayon) for filters; GPU for compose and effects | partial |
|
||||
| Documents larger than the GPU texture limit | yes (tiled) | CPU fallback; tiling in progress (#49) | partial |
|
||||
| CPU-only fallback when no GPU | yes, reduced | `cpu` canvas preference; fails to start without an adapter on some Linux systems (#2519, #2412) | partial |
|
||||
| Choosing the GPU on a multi-GPU machine | Preferences › Performance › Use Graphics Processor | Linux: Preferences › Performance › Advanced › GPU adapter and `PHOTOCRAFT_GPU_ADAPTER` (#1885); Windows and macOS not yet | partial |
|
||||
| Old / integrated GPUs | yes | black line on Intel HD (#2426), OpenCore Macs fail (#1859), Rgba32Float panic (#2020) | partial |
|
||||
|
||||
## Pen tablets
|
||||
@@ -62,3 +63,4 @@ HDR display to verify.
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-10 | major | First version |
|
||||
| 2026-10-19 | minor | Graphics Adapter choice on Linux (#1885) |
|
||||
Reference in new issue
Block a user