Render workspace uses the window's graphics backend on Windows (#6592) (#6629)

* claim: #6592

* Keep Windows Render setup on the viewport backend
This commit is contained in:
raykholo
2026-10-26 11:10:32 +00:00
committed by GitHub
parent b20f522f5d
commit 30e9b87b48
2 changed files with 28 additions and 2 deletions
+12 -2
View File
@@ -92,11 +92,16 @@ pub fn host() -> Result<ImageHost> {
/// Open an independent job device on the viewport's selected adapter. In particular,
/// software fallback and safe mode must not rediscover a failing hardware driver.
/// An explicit incompatible SOLIDCRAFT_GPU policy leaves this executor unavailable.
/// The path tracer runs on Vulkan only: a viewport on another backend is reopened on the same
/// GPU through Vulkan, and without one the executor is unavailable and images render on the CPU.
/// The path tracer runs on Vulkan only. On Windows it must keep the viewport's backend:
/// opening Vulkan drivers that startup avoided can crash inside native driver code.
/// Elsewhere a viewport on another backend is reopened on the same GPU through Vulkan.
/// Without a usable Vulkan adapter the executor is unavailable; CPU image methods remain usable.
pub fn host_on_adapter(adapter: &wgpu::Adapter) -> Result<ImageHost> {
let policy = crate::select::Policy::from_env().map_err(gpu)?;
let info = adapter.get_info();
if !viewport_path_backends(info.backend, cfg!(target_os = "windows")).contains(wgpu::Backends::VULKAN) {
return Err(gpu(format!("{VULKAN_ONLY}; the viewport uses {:?}", info.backend)));
}
if !policy.admits(crate::select::tier_of(info.device_type)) {
return Err(gpu(format!("viewport adapter does not satisfy SOLIDCRAFT_GPU={}", policy.name())));
}
@@ -115,6 +120,11 @@ pub fn host_on_adapter(adapter: &wgpu::Adapter) -> Result<ImageHost> {
// D3D12 shader compilation is avoided; the user can select a CPU image method instead.
const VULKAN_ONLY: &str = "the GPU path tracer requires a Vulkan driver; select a CPU image method when Vulkan is unavailable";
/// Backends a viewport's path device may open, before any driver is loaded.
fn viewport_path_backends(backend: wgpu::Backend, windows: bool) -> wgpu::Backends {
if windows { wgpu::Backends::from(backend) } else { wgpu::Backends::VULKAN }
}
// Path resources need six storage buffers (geometry, BVH, accumulation, HDRI,
// textures, medium-failure counts). Request that limit only on this independent path device: raster and
// tessellation keep their existing four-buffer downlevel requirement.
+16
View File
@@ -543,6 +543,22 @@ fn path_devices_are_vulkan_only() {
}
}
#[test]
fn viewport_path_backends_keep_windows_on_its_selected_backend() {
for backend in [wgpu::Backend::Dx12, wgpu::Backend::Gl, wgpu::Backend::Vulkan] {
let allowed = viewport_path_backends(backend, true);
assert_eq!(allowed, wgpu::Backends::from(backend));
assert_eq!(allowed.contains(wgpu::Backends::VULKAN), backend == wgpu::Backend::Vulkan);
}
}
#[test]
fn viewport_path_backends_preserve_other_platforms() {
for backend in [wgpu::Backend::Vulkan, wgpu::Backend::Gl, wgpu::Backend::Metal] {
assert_eq!(viewport_path_backends(backend, false), wgpu::Backends::VULKAN);
}
}
#[test]
fn admission_rejects_hostile_parameters_and_transparency() {
let mut scene = sphere(white());