VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Part of #1459: the window's surface may be as large as the graphics adapter allows
bflatasticff6e136b9761
diff --git a/apps/vectorcraft/src/gpu.rs b/apps/vectorcraft/src/gpu.rsindex 51f6cbdd2..6819476da 100644--- a/apps/vectorcraft/src/gpu.rs+++ b/apps/vectorcraft/src/gpu.rs@@ -113,6 +113,13 @@ pub fn backends(default: Backends, env_set: bool) -> Backends {if cfg!(windows) && !env_set { Backends::DX12 | Backends::GL } else { default }}+/// The largest texture side to ask the device for, which bounds the window's surface: the+/// adapter's own limit when it is above eframe's `default` (8192 px), so a window larger than+/// that keeps its surface (#1459). Never below `default`, which is what was asked for before.+pub fn surface_limit(default: u32, adapter: u32) -> u32 {+ default.max(adapter)+}+/// One adapter, as [`adapter_order`] sees it.#[derive(Clone, Debug)]pub struct Candidate {@@ -547,6 +554,14 @@ mod tests {Candidate { key: format!("{backend:?}:{name}"), name: name.into(), backend, device_type, pci: (0, 0), presents: true }}+ /// #1459: a 9048 px wide window (two display scales' ratio past 8192) fits an adapter that+ /// takes 16384 px textures; an adapter with less than eframe asks for changes nothing.+ #[test]+ fn the_surface_may_be_as_large_as_the_adapter_allows() {+ assert_eq!(surface_limit(8192, 16384), 16384);+ assert_eq!(surface_limit(8192, 4096), 8192);+ }+fn names(c: &[Candidate], order: &[usize]) -> Vec<String> {order.iter().map(|&i| c[i].name.clone()).collect()}diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rsindex 2fb4695d3..b80e79ff2 100644--- a/apps/vectorcraft/src/main.rs+++ b/apps/vectorcraft/src/main.rs@@ -752,6 +752,16 @@ fn main() -> std::process::ExitCode {// losing the device before the first frame (#1194). `WGPU_DX12_COMPILER` picks another.create.instance_descriptor.backend_options.dx12.shader_compiler =eframe::wgpu::Dx12Compiler::from_env().unwrap_or(eframe::wgpu::Dx12Compiler::Fxc);+ // The window's surface may be as large as the adapter allows, not eframe's fixed+ // 8192 px: a window stretched over several monitors, or grown by a display scale+ // change, otherwise fails to configure its surface and the app closes (#1459).+ let device = create.device_descriptor.clone();+ create.device_descriptor = std::sync::Arc::new(move |adapter: &eframe::wgpu::Adapter| {+ let mut descriptor = device(adapter);+ let limit = &mut descriptor.required_limits.max_texture_dimension_2d;+ *limit = gpu::surface_limit(*limit, adapter.limits().max_texture_dimension_2d);+ descriptor+ });}options};