From d4bfc9cf52bb985b5ac84a64e0667bc83c1dd64c Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:05:48 +0000 Subject: [PATCH 01/15] fix(rendering): fall back to FXC when bundled DXC fails to load on Windows --- crates/rendering/src/lib.rs | 165 ++++++++++++++++++++++++++++++++++-- 1 file changed, 159 insertions(+), 6 deletions(-) diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs index 6147779cc5f..2816592299d 100644 --- a/crates/rendering/src/lib.rs +++ b/crates/rendering/src/lib.rs @@ -318,18 +318,91 @@ pub fn create_wgpu_instance_sync() -> wgpu::Instance { let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default()); #[cfg(target_os = "windows")] - let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { + let instance = match DX12_SHADER_COMPILER.get() { + Some(compiler) => dx12_instance(compiler.clone()), + None => { + let (instance, compiler) = dx12_instance_with_fxc_fallback(bundled_dxc_compiler()); + let _ = DX12_SHADER_COMPILER.set(compiler); + instance + } + }; + + instance +} + +/// The compiler the first instance ended up on, so later instances skip a +/// DXC that already failed to load. +#[cfg(target_os = "windows")] +static DX12_SHADER_COMPILER: std::sync::OnceLock = std::sync::OnceLock::new(); + +#[cfg(target_os = "windows")] +fn dx12_instance_descriptor(shader_compiler: wgpu::Dx12Compiler) -> wgpu::InstanceDescriptor { + wgpu::InstanceDescriptor { backends: wgpu::Backends::DX12, backend_options: wgpu::BackendOptions { - dx12: wgpu::Dx12BackendOptions { - shader_compiler: bundled_dxc_compiler(), - }, + dx12: wgpu::Dx12BackendOptions { shader_compiler }, ..Default::default() }, ..Default::default() - }); + } +} - instance +#[cfg(target_os = "windows")] +fn dx12_instance(shader_compiler: wgpu::Dx12Compiler) -> wgpu::Instance { + wgpu::Instance::new(&dx12_instance_descriptor(shader_compiler)) +} + +/// wgpu drops a backend that fails to initialise and only logs it at debug +/// level, so a DXC that will not load leaves an instance with no DX12 adapters +/// at all, not even WARP. FXC ships with Windows, so rebuild on it instead. +#[cfg(target_os = "windows")] +fn dx12_instance_with_fxc_fallback( + compiler: wgpu::Dx12Compiler, +) -> (wgpu::Instance, wgpu::Dx12Compiler) { + let instance = dx12_instance(compiler.clone()); + // SAFETY: the raw instance is only checked for presence, never used. + let has_dx12 = unsafe { instance.as_hal::() }.is_some(); + if has_dx12 || matches!(compiler, wgpu::Dx12Compiler::Fxc) { + return (instance, compiler); + } + + tracing::warn!( + error = dx12_init_error(compiler), + "DX12 with bundled DXC failed to initialise; retrying with FXC" + ); + ( + dx12_instance(wgpu::Dx12Compiler::Fxc), + wgpu::Dx12Compiler::Fxc, + ) +} + +/// wgpu does not surface why a backend failed, so initialise the DX12 backend +/// directly once more to get the error for the log. +#[cfg(target_os = "windows")] +fn dx12_init_error(compiler: wgpu::Dx12Compiler) -> String { + use wgpu_hal::Instance as _; + + let desc = dx12_instance_descriptor(compiler); + let hal_desc = wgpu_hal::InstanceDescriptor { + name: "wgpu", + flags: desc.flags, + backend_options: desc.backend_options, + }; + // SAFETY: the same call wgpu-core makes in `Instance::new`; the instance, + // if any, is dropped straight away. + match unsafe { wgpu_hal::dx12::Instance::init(&hal_desc) } { + Ok(_) => "unknown".to_string(), + Err(error) => { + let mut message = error.to_string(); + let mut source = std::error::Error::source(&error); + while let Some(cause) = source { + message.push_str(": "); + message.push_str(&cause.to_string()); + source = cause.source(); + } + message + } + } } #[cfg(target_os = "windows")] @@ -11684,3 +11757,83 @@ mod per_frame_cache_tests { assert!(layers.background_color_grade.bind_groups_created() <= 2); } } + +#[cfg(all(test, target_os = "windows"))] +mod dx12_compiler_fallback_tests { + use super::*; + + #[test] + fn unloadable_dxc_falls_back_to_fxc() { + let dir = tempfile::tempdir().expect("temp dir"); + let dxc_path = dir.path().join("dxcompiler.dll"); + let dxil_path = dir.path().join("dxil.dll"); + std::fs::write(&dxc_path, b"").expect("write dxcompiler.dll"); + std::fs::write(&dxil_path, b"").expect("write dxil.dll"); + let broken = wgpu::Dx12Compiler::DynamicDxc { + dxc_path: dxc_path.to_string_lossy().into_owned(), + dxil_path: dxil_path.to_string_lossy().into_owned(), + max_shader_model: wgpu::DxcShaderModel::V6_7, + }; + + assert!( + dx12_instance(broken.clone()) + .enumerate_adapters(wgpu::Backends::all()) + .is_empty(), + "a DXC that fails to load should drop the DX12 backend" + ); + println!("dx12 init error: {}", dx12_init_error(broken.clone())); + + let (instance, compiler) = dx12_instance_with_fxc_fallback(broken); + assert!(matches!(compiler, wgpu::Dx12Compiler::Fxc)); + let adapter = + pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions::default())) + .expect("FXC instance has a DX12 adapter"); + let (device, _queue) = + pollster::block_on(request_rendering_device(&adapter)).expect("device on FXC"); + + // FXC compiles at pipeline creation, so build one to prove it works. + device.push_error_scope(wgpu::ErrorFilter::Internal); + device.push_error_scope(wgpu::ErrorFilter::Validation); + let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: None, + source: wgpu::ShaderSource::Wgsl( + "@group(0) @binding(0) var out: array;\n\ + @compute @workgroup_size(1) fn main() { out[0] = 7u; }" + .into(), + ), + }); + device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { + label: None, + layout: None, + module: &module, + entry_point: Some("main"), + compilation_options: Default::default(), + cache: None, + }); + let validation = pollster::block_on(device.pop_error_scope()); + let internal = pollster::block_on(device.pop_error_scope()); + assert!( + validation.is_none() && internal.is_none(), + "pipeline on FXC failed: {validation:?} {internal:?}" + ); + + let info = adapter.get_info(); + println!( + "device created on FXC: adapter={} backend={:?} type={:?}", + info.name, info.backend, info.device_type + ); + } + + #[test] + fn loadable_bundled_dxc_is_kept() { + let compiler = bundled_dxc_compiler(); + if matches!(compiler, wgpu::Dx12Compiler::Fxc) { + println!("no bundled DXC next to the test binary; nothing to check"); + return; + } + + let (instance, kept) = dx12_instance_with_fxc_fallback(compiler); + assert!(matches!(kept, wgpu::Dx12Compiler::DynamicDxc { .. })); + assert!(!instance.enumerate_adapters(wgpu::Backends::DX12).is_empty()); + } +} From 131835b9b81cf88fb8413ec987ec44601243db3b Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:05:48 +0000 Subject: [PATCH 02/15] test(rendering): temporary Windows DXC fallback proof --- .github/workflows/dxc-fallback-proof.yml | 66 ++++++++++++++++++++++ crates/rendering/tests/dxc_fallback_e2e.rs | 62 ++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 .github/workflows/dxc-fallback-proof.yml create mode 100644 crates/rendering/tests/dxc_fallback_e2e.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml new file mode 100644 index 00000000000..935af463f1d --- /dev/null +++ b/.github/workflows/dxc-fallback-proof.yml @@ -0,0 +1,66 @@ +name: DXC fallback proof (temporary) + +on: + push: + branches: + - fix/windows-dxc-fxc-fallback + workflow_dispatch: + +permissions: + contents: read + +jobs: + proof: + runs-on: windows-2022 + timeout-minutes: 90 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@1.88.0 + + - uses: ./.github/actions/setup-rust-cache + with: + target: x86_64-pc-windows-msvc + prefix-key: v1-rust-sync + save-cache: false + + - uses: actions/setup-node@v4 + with: + node-version: 24 + + - name: Native dependencies + env: + RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc + run: node scripts/setup.js + + - name: Add FFmpeg DLLs to PATH + shell: pwsh + run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" + + - name: Bundled DXC is staged next to the test binaries + shell: bash + run: ls -la target/debug/dxcompiler.dll target/debug/dxil.dll + + - name: After (this branch) + shell: bash + run: | + cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee after-unit.txt + cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture 2>&1 | tee after.txt + echo "----- summary -----" + grep -h "PROOF RESULT\|retrying with FXC\|dx12 init error\|device created on FXC\|no bundled DXC\|test result\|^test " after-unit.txt after.txt + + - name: Before (main's crates/rendering/src/lib.rs) + shell: bash + run: | + git show origin/main:crates/rendering/src/lib.rs > crates/rendering/src/lib.rs + git diff --stat + if cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > before.txt 2>&1; then + cat before.txt + echo "::error::main unexpectedly created a device with an unloadable DXC" + exit 1 + fi + echo "----- summary -----" + grep -h "PROOF RESULT\|test result\|panicked\|^test " before.txt + grep -q "PROOF RESULT: Err(No GPU adapter found)" before.txt diff --git a/crates/rendering/tests/dxc_fallback_e2e.rs b/crates/rendering/tests/dxc_fallback_e2e.rs new file mode 100644 index 00000000000..f926bcf6126 --- /dev/null +++ b/crates/rendering/tests/dxc_fallback_e2e.rs @@ -0,0 +1,62 @@ +#![cfg(target_os = "windows")] + +use std::path::PathBuf; + +struct UnloadableBundledDxc { + files: Vec<(PathBuf, Option)>, +} + +impl UnloadableBundledDxc { + fn install() -> Self { + let exe = std::env::current_exe().expect("test exe"); + let dir = exe.parent().expect("test exe dir"); + let mut files = Vec::new(); + for name in ["dxcompiler.dll", "dxil.dll"] { + let path = dir.join(name); + let backup = path.exists().then(|| { + let backup = dir.join(format!("{name}.proof-backup")); + std::fs::rename(&path, &backup).expect("back up dll"); + backup + }); + std::fs::write(&path, b"").expect("write zero-byte dll"); + files.push((path, backup)); + } + Self { files } + } +} + +impl Drop for UnloadableBundledDxc { + fn drop(&mut self) { + for (path, backup) in &self.files { + let _ = std::fs::remove_file(path); + if let Some(backup) = backup { + let _ = std::fs::rename(backup, path); + } + } + } +} + +#[test] +fn shared_device_with_unloadable_bundled_dxc() { + let _ = tracing_subscriber::fmt() + .with_max_level(tracing::Level::INFO) + .try_init(); + let _dlls = UnloadableBundledDxc::install(); + + match pollster::block_on(cap_rendering::create_shared_device()) { + Ok(shared) => { + let info = shared.adapter.get_info(); + println!( + "PROOF RESULT: Ok, device created on adapter={} backend={:?} type={:?}", + info.name, info.backend, info.device_type + ); + let second = pollster::block_on(cap_rendering::create_shared_device()); + println!("PROOF RESULT: second instance ok={}", second.is_ok()); + assert!(second.is_ok()); + } + Err(error) => { + println!("PROOF RESULT: Err({error})"); + panic!("create_shared_device failed: {error}"); + } + } +} From 0100607993a160ccfb68e0b58464ad419c5b27ef Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:10:41 +0000 Subject: [PATCH 03/15] test(rendering): keep the FXC proof pipeline bound --- crates/rendering/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs index 2816592299d..3e65731b5f5 100644 --- a/crates/rendering/src/lib.rs +++ b/crates/rendering/src/lib.rs @@ -11802,7 +11802,7 @@ mod dx12_compiler_fallback_tests { .into(), ), }); - device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { + let _pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { label: None, layout: None, module: &module, From 6fb2d2b025f351db7de34d05078c7e3c18fa9832 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:16:21 +0000 Subject: [PATCH 04/15] test(rendering): drop the temporary DXC fallback proof --- .github/workflows/dxc-fallback-proof.yml | 66 ---------------------- crates/rendering/tests/dxc_fallback_e2e.rs | 62 -------------------- 2 files changed, 128 deletions(-) delete mode 100644 .github/workflows/dxc-fallback-proof.yml delete mode 100644 crates/rendering/tests/dxc_fallback_e2e.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml deleted file mode 100644 index 935af463f1d..00000000000 --- a/.github/workflows/dxc-fallback-proof.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: DXC fallback proof (temporary) - -on: - push: - branches: - - fix/windows-dxc-fxc-fallback - workflow_dispatch: - -permissions: - contents: read - -jobs: - proof: - runs-on: windows-2022 - timeout-minutes: 90 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: dtolnay/rust-toolchain@1.88.0 - - - uses: ./.github/actions/setup-rust-cache - with: - target: x86_64-pc-windows-msvc - prefix-key: v1-rust-sync - save-cache: false - - - uses: actions/setup-node@v4 - with: - node-version: 24 - - - name: Native dependencies - env: - RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc - run: node scripts/setup.js - - - name: Add FFmpeg DLLs to PATH - shell: pwsh - run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" - - - name: Bundled DXC is staged next to the test binaries - shell: bash - run: ls -la target/debug/dxcompiler.dll target/debug/dxil.dll - - - name: After (this branch) - shell: bash - run: | - cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee after-unit.txt - cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture 2>&1 | tee after.txt - echo "----- summary -----" - grep -h "PROOF RESULT\|retrying with FXC\|dx12 init error\|device created on FXC\|no bundled DXC\|test result\|^test " after-unit.txt after.txt - - - name: Before (main's crates/rendering/src/lib.rs) - shell: bash - run: | - git show origin/main:crates/rendering/src/lib.rs > crates/rendering/src/lib.rs - git diff --stat - if cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > before.txt 2>&1; then - cat before.txt - echo "::error::main unexpectedly created a device with an unloadable DXC" - exit 1 - fi - echo "----- summary -----" - grep -h "PROOF RESULT\|test result\|panicked\|^test " before.txt - grep -q "PROOF RESULT: Err(No GPU adapter found)" before.txt diff --git a/crates/rendering/tests/dxc_fallback_e2e.rs b/crates/rendering/tests/dxc_fallback_e2e.rs deleted file mode 100644 index f926bcf6126..00000000000 --- a/crates/rendering/tests/dxc_fallback_e2e.rs +++ /dev/null @@ -1,62 +0,0 @@ -#![cfg(target_os = "windows")] - -use std::path::PathBuf; - -struct UnloadableBundledDxc { - files: Vec<(PathBuf, Option)>, -} - -impl UnloadableBundledDxc { - fn install() -> Self { - let exe = std::env::current_exe().expect("test exe"); - let dir = exe.parent().expect("test exe dir"); - let mut files = Vec::new(); - for name in ["dxcompiler.dll", "dxil.dll"] { - let path = dir.join(name); - let backup = path.exists().then(|| { - let backup = dir.join(format!("{name}.proof-backup")); - std::fs::rename(&path, &backup).expect("back up dll"); - backup - }); - std::fs::write(&path, b"").expect("write zero-byte dll"); - files.push((path, backup)); - } - Self { files } - } -} - -impl Drop for UnloadableBundledDxc { - fn drop(&mut self) { - for (path, backup) in &self.files { - let _ = std::fs::remove_file(path); - if let Some(backup) = backup { - let _ = std::fs::rename(backup, path); - } - } - } -} - -#[test] -fn shared_device_with_unloadable_bundled_dxc() { - let _ = tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .try_init(); - let _dlls = UnloadableBundledDxc::install(); - - match pollster::block_on(cap_rendering::create_shared_device()) { - Ok(shared) => { - let info = shared.adapter.get_info(); - println!( - "PROOF RESULT: Ok, device created on adapter={} backend={:?} type={:?}", - info.name, info.backend, info.device_type - ); - let second = pollster::block_on(cap_rendering::create_shared_device()); - println!("PROOF RESULT: second instance ok={}", second.is_ok()); - assert!(second.is_ok()); - } - Err(error) => { - println!("PROOF RESULT: Err({error})"); - panic!("create_shared_device failed: {error}"); - } - } -} From 8886d60c2f39d191ec28d69cb941bf6bc3cc69a7 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:00:44 +0000 Subject: [PATCH 05/15] test(rendering): build the production pipelines in the FXC fallback test --- crates/rendering/src/lib.rs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs index 3e65731b5f5..f843f49fef9 100644 --- a/crates/rendering/src/lib.rs +++ b/crates/rendering/src/lib.rs @@ -11788,28 +11788,17 @@ mod dx12_compiler_fallback_tests { let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions::default())) .expect("FXC instance has a DX12 adapter"); - let (device, _queue) = + let (device, queue) = pollster::block_on(request_rendering_device(&adapter)).expect("device on FXC"); - // FXC compiles at pipeline creation, so build one to prove it works. + // FXC compiles at pipeline creation, so build every production + // rendering pipeline on the fallback device. device.push_error_scope(wgpu::ErrorFilter::Internal); device.push_error_scope(wgpu::ErrorFilter::Validation); - let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: None, - source: wgpu::ShaderSource::Wgsl( - "@group(0) @binding(0) var out: array;\n\ - @compute @workgroup_size(1) fn main() { out[0] = 7u; }" - .into(), - ), - }); - let _pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { - label: None, - layout: None, - module: &module, - entry_point: Some("main"), - compilation_options: Default::default(), - cache: None, - }); + let started = Instant::now(); + let _layers = RendererLayers::new(&device, &queue); + let _transitions = TransitionCompositor::new(&device); + let compile_time = started.elapsed(); let validation = pollster::block_on(device.pop_error_scope()); let internal = pollster::block_on(device.pop_error_scope()); assert!( @@ -11819,7 +11808,7 @@ mod dx12_compiler_fallback_tests { let info = adapter.get_info(); println!( - "device created on FXC: adapter={} backend={:?} type={:?}", + "device created on FXC: adapter={} backend={:?} type={:?} pipelines={compile_time:?}", info.name, info.backend, info.device_type ); } From 9647cc86723b8a35451e19fca4f3335cdb308ca0 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:00:44 +0000 Subject: [PATCH 06/15] ci: temporary Windows FXC suite run --- .github/workflows/dxc-fallback-proof.yml | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/dxc-fallback-proof.yml diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml new file mode 100644 index 00000000000..78931e3fec3 --- /dev/null +++ b/.github/workflows/dxc-fallback-proof.yml @@ -0,0 +1,57 @@ +name: DXC fallback proof (temporary) + +on: + push: + branches: + - fix/windows-dxc-fxc-fallback + workflow_dispatch: + +permissions: + contents: read + +jobs: + proof: + runs-on: windows-2022 + timeout-minutes: 120 + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@1.88.0 + + - uses: ./.github/actions/setup-rust-cache + with: + target: x86_64-pc-windows-msvc + prefix-key: v1-rust-sync + save-cache: false + + - uses: actions/setup-node@v4 + with: + node-version: 24 + + - name: Native dependencies + env: + RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc + run: node scripts/setup.js + + - name: Add FFmpeg DLLs to PATH + shell: pwsh + run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" + + - name: Fallback unit tests (bundled DXC intact) + shell: bash + run: | + cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee unit.txt + echo "----- summary -----" + grep -h "device created on FXC\|dx12 init error\|no bundled DXC\|test result\|^test " unit.txt + + - name: Whole cap-rendering suite with an unloadable bundled DXC (every GPU test on FXC) + shell: bash + run: | + cargo test --locked -p cap-rendering --no-run + printf '' > target/debug/deps/dxcompiler.dll + printf '' > target/debug/deps/dxil.dll + ls -la target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll + cargo test --locked -p cap-rendering -- --nocapture --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: --skip loadable_bundled_dxc_is_kept 2>&1 | tee fxc-suite.txt + echo "----- summary -----" + grep -h "test result\|FAILED\|panicked" fxc-suite.txt + grep -h "test result" fxc-suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' From cbbf9b205f01f4349b8804c9ab4150a48659e181 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:07:17 +0000 Subject: [PATCH 07/15] ci: temporary Windows FXC suite run, single-threaded --- .github/workflows/dxc-fallback-proof.yml | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml index 78931e3fec3..bfdbf3ad60c 100644 --- a/.github/workflows/dxc-fallback-proof.yml +++ b/.github/workflows/dxc-fallback-proof.yml @@ -46,12 +46,38 @@ jobs: - name: Whole cap-rendering suite with an unloadable bundled DXC (every GPU test on FXC) shell: bash + env: + RUST_BACKTRACE: "0" run: | cargo test --locked -p cap-rendering --no-run printf '' > target/debug/deps/dxcompiler.dll printf '' > target/debug/deps/dxil.dll ls -la target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll - cargo test --locked -p cap-rendering -- --nocapture --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: --skip loadable_bundled_dxc_is_kept 2>&1 | tee fxc-suite.txt + set +e + cargo test --locked --no-fail-fast -p cap-rendering -- --test-threads=1 --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: --skip loadable_bundled_dxc_is_kept > fxc-suite.txt 2>&1 + echo "exit=$?" + set -e echo "----- summary -----" - grep -h "test result\|FAILED\|panicked" fxc-suite.txt + grep -h "test result\|FAILED\|panicked\|device is lost\|Device lost\|DEVICE_REMOVED\|removed\|Running " fxc-suite.txt | head -200 grep -h "test result" fxc-suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' + + - name: Same suite on DXC, single-threaded (baseline) + if: always() + shell: bash + run: | + rm -f target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll + set +e + cargo test --locked --no-fail-fast -p cap-rendering -- --test-threads=1 --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: > dxc-suite.txt 2>&1 + echo "exit=$?" + set -e + echo "----- summary -----" + grep -h "test result\|FAILED\|panicked\|device is lost\|Running " dxc-suite.txt | head -200 + grep -h "test result" dxc-suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: suite-logs + path: | + fxc-suite.txt + dxc-suite.txt From bd75c3df57b46b07ffb1252a8a9c1d8749998d06 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:19:10 +0000 Subject: [PATCH 08/15] ci: temporary FXC render debug run --- .github/workflows/dxc-fallback-proof.yml | 51 +++---- crates/rendering/tests/fxc_debug.rs | 185 +++++++++++++++++++++++ 2 files changed, 205 insertions(+), 31 deletions(-) create mode 100644 crates/rendering/tests/fxc_debug.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml index bfdbf3ad60c..3674001f7f9 100644 --- a/.github/workflows/dxc-fallback-proof.yml +++ b/.github/workflows/dxc-fallback-proof.yml @@ -37,47 +37,36 @@ jobs: shell: pwsh run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" - - name: Fallback unit tests (bundled DXC intact) + - name: Render one frame on FXC and on DXC with wgpu logs shell: bash run: | - cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee unit.txt - echo "----- summary -----" - grep -h "device created on FXC\|dx12 init error\|no bundled DXC\|test result\|^test " unit.txt - - - name: Whole cap-rendering suite with an unloadable bundled DXC (every GPU test on FXC) - shell: bash - env: - RUST_BACKTRACE: "0" - run: | - cargo test --locked -p cap-rendering --no-run + cargo test --locked -p cap-rendering --test fxc_debug --no-run + set +e printf '' > target/debug/deps/dxcompiler.dll printf '' > target/debug/deps/dxil.dll - ls -la target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll - set +e - cargo test --locked --no-fail-fast -p cap-rendering -- --test-threads=1 --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: --skip loadable_bundled_dxc_is_kept > fxc-suite.txt 2>&1 - echo "exit=$?" + cargo test --locked -p cap-rendering --test fxc_debug imported_portrait -- --nocapture > fxc-debug.txt 2>&1 + echo "fxc exit=$?" + rm -f target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll + cargo test --locked -p cap-rendering --test fxc_debug imported_portrait -- --nocapture > dxc-debug.txt 2>&1 + echo "dxc exit=$?" set -e - echo "----- summary -----" - grep -h "test result\|FAILED\|panicked\|device is lost\|Device lost\|DEVICE_REMOVED\|removed\|Running " fxc-suite.txt | head -200 - grep -h "test result" fxc-suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' + for f in fxc-debug.txt dxc-debug.txt; do + echo "===== $f" + grep -a "FXC DEBUG\|ERROR\|WARN\|lost\|Lost\|removed\|failed\|D3D12\|test result\|panicked" "$f" | cut -c1-400 | head -80 + done - - name: Same suite on DXC, single-threaded (baseline) + - name: Display driver events if: always() - shell: bash + shell: pwsh run: | - rm -f target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll - set +e - cargo test --locked --no-fail-fast -p cap-rendering -- --test-threads=1 --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: > dxc-suite.txt 2>&1 - echo "exit=$?" - set -e - echo "----- summary -----" - grep -h "test result\|FAILED\|panicked\|device is lost\|Running " dxc-suite.txt | head -200 - grep -h "test result" dxc-suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' + Get-WinEvent -FilterHashtable @{LogName='System'; StartTime=(Get-Date).AddHours(-2)} -ErrorAction SilentlyContinue | + Where-Object { $_.ProviderName -match 'Display|dxgkrnl|BasicRender|Dxgkrnl' -or $_.Id -eq 4101 } | + Format-List TimeCreated, ProviderName, Id, Message | Out-String -Width 400 - uses: actions/upload-artifact@v4 if: always() with: - name: suite-logs + name: fxc-debug-logs path: | - fxc-suite.txt - dxc-suite.txt + fxc-debug.txt + dxc-debug.txt diff --git a/crates/rendering/tests/fxc_debug.rs b/crates/rendering/tests/fxc_debug.rs new file mode 100644 index 00000000000..905d1aca862 --- /dev/null +++ b/crates/rendering/tests/fxc_debug.rs @@ -0,0 +1,185 @@ +use cap_project::{ + AspectRatio, BackgroundSource, Crop, CursorEvents, FrameConfiguration, FrameStyle, + ProjectConfiguration, RecordingMeta, XY, +}; +use cap_rendering::{ + DecodedFrame, DecodedSegmentFrames, FrameRenderer, ProjectUniforms, RenderOptions, + RenderVideoConstants, RendererLayers, ZoomTransformTimeline, +}; + +#[test] +fn portrait_vertical_without_padding_fills_the_output() { + let options = RenderOptions { + screen_size: XY::new(1080, 1920), + camera_size: None, + preserve_screen_alpha: false, + }; + let project = ProjectConfiguration { + aspect_ratio: Some(AspectRatio::Vertical), + ..ProjectConfiguration::default() + }; + let resolution = XY::new(1080, 1920); + + assert_eq!( + ProjectUniforms::get_output_size(&options, &project, resolution), + (1080, 1920) + ); + assert_eq!( + ProjectUniforms::display_offset(&options, &project, resolution).coord, + XY::new(0.0, 0.0) + ); + assert_eq!( + ProjectUniforms::display_size(&options, &project, resolution).coord, + XY::new(1080.0, 1920.0) + ); +} + +#[tokio::test] +async fn imported_portrait_fills_a_vertical_output() { + let _ = tracing_subscriber::fmt() + .with_max_level(tracing::Level::DEBUG) + .try_init(); + let started = std::time::Instant::now(); + struct Elapsed(std::time::Instant); + impl Drop for Elapsed { + fn drop(&mut self) { + eprintln!("FXC DEBUG elapsed {:?}", self.0.elapsed()); + } + } + let _elapsed = Elapsed(started); + let instance = cap_rendering::create_wgpu_instance_sync(); + if instance + .request_adapter(&wgpu::RequestAdapterOptions::default()) + .await + .is_err() + { + eprintln!("no GPU adapter available, skipping portrait layout regression"); + return; + } + let options = RenderOptions { + screen_size: XY::new(1920, 1080), + camera_size: None, + preserve_screen_alpha: false, + }; + let recording_meta: RecordingMeta = serde_json::from_value(serde_json::json!({ + "pretty_name": "portrait-import", + "display": { "path": "display.mp4", "fps": 30 }, + "camera": null, + "audio": null, + "cursor": null + })) + .unwrap(); + let meta = recording_meta.studio_meta().unwrap().clone(); + let mut constants = RenderVideoConstants::new_with_options(options, recording_meta, meta) + .await + .unwrap(); + let mut project = ProjectConfiguration { + aspect_ratio: Some(AspectRatio::Vertical), + ..ProjectConfiguration::default() + }; + project.background.shadow = 0.0; + project.background.source = BackgroundSource::Color { + value: [0, 0, 0], + alpha: 255, + }; + project.cursor.hide = true; + let cursor = CursorEvents::default(); + let source_size = XY::new(1080, 1920); + let frames = DecodedSegmentFrames { + screen_size: options.screen_size, + screen_frame: Some(DecodedFrame::new( + [255, 0, 0, 255].repeat((source_size.x * source_size.y) as usize), + source_size.x, + source_size.y, + )), + camera_frame: None, + segment_time: 0.0, + recording_time: 0.0, + segment_has_camera: false, + }; + for decoded in [true, false] { + let mut frames = frames.clone(); + if !decoded { + frames.screen_frame = None; + frames.screen_size = source_size; + } + let uniforms = uniforms_for(&constants, &project, &frames, source_size); + assert_eq!(uniforms.frame_layout().output_size, [1080, 1920]); + assert_bounds(uniforms.frame_layout().display, [0.0, 0.0, 1080.0, 1920.0]); + } + + constants.options.screen_size = source_size; + project.aspect_ratio = Some(AspectRatio::Wide); + let mut landscape = frames.clone(); + landscape.screen_frame = Some(DecodedFrame::new(Vec::new(), 1920, 1080)); + let imported = uniforms_for(&constants, &project, &landscape, options.screen_size); + assert_eq!(imported.frame_layout().output_size, [1920, 1080]); + assert_bounds(imported.frame_layout().display, [0.0, 0.0, 1920.0, 1080.0]); + constants.options = options; + project.aspect_ratio = Some(AspectRatio::Vertical); + + for style in [FrameStyle::Browser, FrameStyle::MacOS] { + project.background.frame = Some(FrameConfiguration { + style, + ..Default::default() + }); + let imported = uniforms_for(&constants, &project, &frames, source_size); + constants.options.screen_size = source_size; + let native = uniforms_for(&constants, &project, &frames, source_size); + constants.options = options; + assert_bounds( + imported.frame_layout().display, + native.frame_layout().display, + ); + } + + project.background.frame = None; + project.background.crop = Some(Crop { + position: XY::new(480, 0), + size: XY::new(960, 1080), + }); + let cropped = uniforms_for(&constants, &project, &frames, source_size); + assert_bounds(cropped.frame_layout().display, [270.0, 0.0, 810.0, 1920.0]); + + project.background.crop = None; + let uniforms = uniforms_for(&constants, &project, &frames, XY::new(180, 320)); + let mut renderer = FrameRenderer::new(&constants); + let mut layers = RendererLayers::new(&constants.device, &constants.queue); + let rendered = renderer + .render_immediate(frames, uniforms, &cursor, true, &mut layers) + .await + .unwrap(); + assert_eq!((rendered.width, rendered.height), (180, 320)); + for (x, y) in [(90, 5), (5, 160), (174, 160), (90, 314)] { + let offset = y * rendered.padded_bytes_per_row as usize + x * 4; + let pixel = &rendered.data[offset..offset + 4]; + assert!( + pixel[0] > 240 && pixel[1] < 10 && pixel[2] < 10, + "{x},{y}: {pixel:?}" + ); + } +} + +fn assert_bounds(actual: [f32; 4], expected: [f32; 4]) { + for (actual_value, expected_value) in actual.iter().zip(expected) { + assert!( + (actual_value - expected_value).abs() < 2.0, + "display {actual:?}, expected {expected:?}", + ); + } +} + +fn uniforms_for( + constants: &RenderVideoConstants, + project: &ProjectConfiguration, + frames: &DecodedSegmentFrames, + resolution: XY, +) -> ProjectUniforms { + let cursor = CursorEvents::default(); + let zoom = + ZoomTransformTimeline::from_project(project, &cursor, 1.0, constants.options.screen_size); + let shared = std::sync::Arc::new(project.clone()); + ProjectUniforms::new( + constants, &shared, 0, 30, resolution, &cursor, frames, 1.0, &zoom, + ) +} From 5abfd8bb8fe30515286f06b9b017c15e1480dff4 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:26:17 +0000 Subject: [PATCH 09/15] ci: temporary Windows test bundle for GPU run --- .github/workflows/dxc-fallback-proof.yml | 52 ++++++++---------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml index 3674001f7f9..d4a71dbfbc1 100644 --- a/.github/workflows/dxc-fallback-proof.yml +++ b/.github/workflows/dxc-fallback-proof.yml @@ -10,9 +10,11 @@ permissions: contents: read jobs: - proof: + bundle: runs-on: windows-2022 - timeout-minutes: 120 + timeout-minutes: 90 + env: + CARGO_PROFILE_DEV_DEBUG: "0" steps: - uses: actions/checkout@v4 @@ -33,40 +35,22 @@ jobs: RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc run: node scripts/setup.js - - name: Add FFmpeg DLLs to PATH - shell: pwsh - run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" - - - name: Render one frame on FXC and on DXC with wgpu logs + - name: Build cap-rendering test binaries shell: bash run: | - cargo test --locked -p cap-rendering --test fxc_debug --no-run - set +e - printf '' > target/debug/deps/dxcompiler.dll - printf '' > target/debug/deps/dxil.dll - cargo test --locked -p cap-rendering --test fxc_debug imported_portrait -- --nocapture > fxc-debug.txt 2>&1 - echo "fxc exit=$?" - rm -f target/debug/deps/dxcompiler.dll target/debug/deps/dxil.dll - cargo test --locked -p cap-rendering --test fxc_debug imported_portrait -- --nocapture > dxc-debug.txt 2>&1 - echo "dxc exit=$?" - set -e - for f in fxc-debug.txt dxc-debug.txt; do - echo "===== $f" - grep -a "FXC DEBUG\|ERROR\|WARN\|lost\|Lost\|removed\|failed\|D3D12\|test result\|panicked" "$f" | cut -c1-400 | head -80 - done - - - name: Display driver events - if: always() - shell: pwsh - run: | - Get-WinEvent -FilterHashtable @{LogName='System'; StartTime=(Get-Date).AddHours(-2)} -ErrorAction SilentlyContinue | - Where-Object { $_.ProviderName -match 'Display|dxgkrnl|BasicRender|Dxgkrnl' -or $_.Id -eq 4101 } | - Format-List TimeCreated, ProviderName, Id, Message | Out-String -Width 400 + mkdir -p bundle + cargo test --locked -p cap-rendering --no-run --message-format=json \ + | jq -r 'select(.reason == "compiler-artifact" and .profile.test == true and .executable != null) | .executable' \ + > executables.txt + cat executables.txt + while read -r exe; do cp "$(cygpath -u "$exe")" bundle/; done < executables.txt + cp target/ffmpeg/bin/*.dll bundle/ + cp target/debug/dxcompiler.dll target/debug/dxil.dll bundle/ + ls -la bundle + du -sh bundle - uses: actions/upload-artifact@v4 - if: always() with: - name: fxc-debug-logs - path: | - fxc-debug.txt - dxc-debug.txt + name: rendering-test-bundle + path: bundle + retention-days: 2 From fa0b1cd79fe5eca19cdafe501effe45599a6a948 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:03:28 -0500 Subject: [PATCH 10/15] fix(rendering): keep the FXC fallback on hardware adapters --- crates/rendering/src/lib.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs index f843f49fef9..a78ed5fed86 100644 --- a/crates/rendering/src/lib.rs +++ b/crates/rendering/src/lib.rs @@ -335,6 +335,21 @@ pub fn create_wgpu_instance_sync() -> wgpu::Instance { #[cfg(target_os = "windows")] static DX12_SHADER_COMPILER: std::sync::OnceLock = std::sync::OnceLock::new(); +#[cfg(target_os = "windows")] +static DX12_FXC_FALLBACK: AtomicBool = AtomicBool::new(false); + +/// WARP crashes on the first frame rendered with FXC-compiled shaders, so the +/// FXC fallback only renders on hardware adapters. +#[cfg(not(target_arch = "wasm32"))] +fn software_adapters_unusable() -> bool { + #[cfg(target_os = "windows")] + let unusable = DX12_FXC_FALLBACK.load(Ordering::Acquire); + #[cfg(not(target_os = "windows"))] + let unusable = false; + + unusable +} + #[cfg(target_os = "windows")] fn dx12_instance_descriptor(shader_compiler: wgpu::Dx12Compiler) -> wgpu::InstanceDescriptor { wgpu::InstanceDescriptor { @@ -370,6 +385,7 @@ fn dx12_instance_with_fxc_fallback( error = dx12_init_error(compiler), "DX12 with bundled DXC failed to initialise; retrying with FXC" ); + DX12_FXC_FALLBACK.store(true, Ordering::Release); ( dx12_instance(wgpu::Dx12Compiler::Fxc), wgpu::Dx12Compiler::Fxc, @@ -2674,6 +2690,9 @@ pub async fn create_shared_device() -> Result if force_software_adapter { tracing::warn!("Forcing software WGPU adapter"); } + let usable = |adapter: &wgpu::Adapter| { + !software_adapters_unusable() || !is_software_wgpu_adapter(&adapter.get_info()) + }; let adapter_phase = readiness::Phase::start("wgpu.adapter"); let preferred = if force_software_adapter { @@ -2697,7 +2716,7 @@ pub async fn create_shared_device() -> Result let device_phase = readiness::Phase::start("wgpu.device"); let mut last_error = None; let mut created = None; - if let Some(adapter) = preferred { + if let Some(adapter) = preferred.filter(usable) { match try_rendering_device(adapter).await { Ok(found) => created = Some(found), Err(error) => last_error = Some(error), @@ -2707,7 +2726,11 @@ pub async fn create_shared_device() -> Result // without compute shaders, a broken install). Only then are the others // enumerated, hardware first, then the fallback adapter. if created.is_none() { - for adapter in other_wgpu_adapters(&instance, force_software_adapter).await { + for adapter in other_wgpu_adapters(&instance, force_software_adapter) + .await + .into_iter() + .filter(usable) + { match try_rendering_device(adapter).await { Ok(found) => { created = Some(found); From 16880640bc0636f26547b27f64322b8f4548106a Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:03:28 -0500 Subject: [PATCH 11/15] ci: temporary WARP e2e check and GPU bundle --- .github/workflows/dxc-fallback-proof.yml | 37 ++++++++++++-- crates/rendering/tests/dxc_fallback_e2e.rs | 56 ++++++++++++++++++++++ 2 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 crates/rendering/tests/dxc_fallback_e2e.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml index d4a71dbfbc1..b567fcc6d2d 100644 --- a/.github/workflows/dxc-fallback-proof.yml +++ b/.github/workflows/dxc-fallback-proof.yml @@ -10,13 +10,15 @@ permissions: contents: read jobs: - bundle: + proof: runs-on: windows-2022 timeout-minutes: 90 env: CARGO_PROFILE_DEV_DEBUG: "0" steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: dtolnay/rust-toolchain@1.88.0 @@ -35,19 +37,44 @@ jobs: RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc run: node scripts/setup.js - - name: Build cap-rendering test binaries + - name: Add FFmpeg DLLs to PATH + shell: pwsh + run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" + + - name: Fallback unit tests (bundled DXC intact) + shell: bash + run: | + cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee unit.txt + echo "----- summary -----" + grep -h "device created on FXC\|dx12 init error\|no bundled DXC\|test result\|^test " unit.txt + + - name: WARP-only runner, unloadable DXC (this branch) + shell: bash + run: | + cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > after.txt 2>&1 + echo "----- summary -----" + grep -h "PROOF RESULT\|retrying with FXC\|test result" after.txt + + - name: WARP-only runner, unloadable DXC (main's lib.rs) + shell: bash + run: | + git show origin/main:crates/rendering/src/lib.rs > crates/rendering/src/lib.rs + cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > before.txt 2>&1 + echo "----- summary -----" + grep -h "PROOF RESULT\|retrying with FXC\|test result" before.txt + git checkout -- crates/rendering/src/lib.rs + + - name: Build test bundle for the GPU box shell: bash run: | mkdir -p bundle cargo test --locked -p cap-rendering --no-run --message-format=json \ | jq -r 'select(.reason == "compiler-artifact" and .profile.test == true and .executable != null) | .executable' \ > executables.txt - cat executables.txt while read -r exe; do cp "$(cygpath -u "$exe")" bundle/; done < executables.txt cp target/ffmpeg/bin/*.dll bundle/ cp target/debug/dxcompiler.dll target/debug/dxil.dll bundle/ - ls -la bundle - du -sh bundle + ls bundle - uses: actions/upload-artifact@v4 with: diff --git a/crates/rendering/tests/dxc_fallback_e2e.rs b/crates/rendering/tests/dxc_fallback_e2e.rs new file mode 100644 index 00000000000..8d8c720de8d --- /dev/null +++ b/crates/rendering/tests/dxc_fallback_e2e.rs @@ -0,0 +1,56 @@ +#![cfg(target_os = "windows")] + +use std::path::PathBuf; + +struct UnloadableBundledDxc { + files: Vec<(PathBuf, Option)>, +} + +impl UnloadableBundledDxc { + fn install() -> Self { + let exe = std::env::current_exe().expect("test exe"); + let dir = exe.parent().expect("test exe dir"); + let mut files = Vec::new(); + for name in ["dxcompiler.dll", "dxil.dll"] { + let path = dir.join(name); + let backup = path.exists().then(|| { + let backup = dir.join(format!("{name}.proof-backup")); + std::fs::rename(&path, &backup).expect("back up dll"); + backup + }); + std::fs::write(&path, []).expect("write zero-byte dll"); + files.push((path, backup)); + } + Self { files } + } +} + +impl Drop for UnloadableBundledDxc { + fn drop(&mut self) { + for (path, backup) in &self.files { + let _ = std::fs::remove_file(path); + if let Some(backup) = backup { + let _ = std::fs::rename(backup, path); + } + } + } +} + +#[test] +fn shared_device_with_unloadable_bundled_dxc() { + let _ = tracing_subscriber::fmt() + .with_max_level(tracing::Level::INFO) + .try_init(); + let _dlls = UnloadableBundledDxc::install(); + + match pollster::block_on(cap_rendering::create_shared_device()) { + Ok(shared) => { + let info = shared.adapter.get_info(); + println!( + "PROOF RESULT: Ok, device created on adapter={} backend={:?} type={:?}", + info.name, info.backend, info.device_type + ); + } + Err(error) => println!("PROOF RESULT: Err({error})"), + } +} From 0fc5065e56c97b8bc2cc35107ef24db87e88770e Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 18:27:23 -0500 Subject: [PATCH 12/15] test(rendering): drop the temporary DXC fallback proof --- .github/workflows/dxc-fallback-proof.yml | 83 --------- crates/rendering/tests/dxc_fallback_e2e.rs | 56 ------- crates/rendering/tests/fxc_debug.rs | 185 --------------------- 3 files changed, 324 deletions(-) delete mode 100644 .github/workflows/dxc-fallback-proof.yml delete mode 100644 crates/rendering/tests/dxc_fallback_e2e.rs delete mode 100644 crates/rendering/tests/fxc_debug.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml deleted file mode 100644 index b567fcc6d2d..00000000000 --- a/.github/workflows/dxc-fallback-proof.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: DXC fallback proof (temporary) - -on: - push: - branches: - - fix/windows-dxc-fxc-fallback - workflow_dispatch: - -permissions: - contents: read - -jobs: - proof: - runs-on: windows-2022 - timeout-minutes: 90 - env: - CARGO_PROFILE_DEV_DEBUG: "0" - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: dtolnay/rust-toolchain@1.88.0 - - - uses: ./.github/actions/setup-rust-cache - with: - target: x86_64-pc-windows-msvc - prefix-key: v1-rust-sync - save-cache: false - - - uses: actions/setup-node@v4 - with: - node-version: 24 - - - name: Native dependencies - env: - RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc - run: node scripts/setup.js - - - name: Add FFmpeg DLLs to PATH - shell: pwsh - run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" - - - name: Fallback unit tests (bundled DXC intact) - shell: bash - run: | - cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee unit.txt - echo "----- summary -----" - grep -h "device created on FXC\|dx12 init error\|no bundled DXC\|test result\|^test " unit.txt - - - name: WARP-only runner, unloadable DXC (this branch) - shell: bash - run: | - cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > after.txt 2>&1 - echo "----- summary -----" - grep -h "PROOF RESULT\|retrying with FXC\|test result" after.txt - - - name: WARP-only runner, unloadable DXC (main's lib.rs) - shell: bash - run: | - git show origin/main:crates/rendering/src/lib.rs > crates/rendering/src/lib.rs - cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > before.txt 2>&1 - echo "----- summary -----" - grep -h "PROOF RESULT\|retrying with FXC\|test result" before.txt - git checkout -- crates/rendering/src/lib.rs - - - name: Build test bundle for the GPU box - shell: bash - run: | - mkdir -p bundle - cargo test --locked -p cap-rendering --no-run --message-format=json \ - | jq -r 'select(.reason == "compiler-artifact" and .profile.test == true and .executable != null) | .executable' \ - > executables.txt - while read -r exe; do cp "$(cygpath -u "$exe")" bundle/; done < executables.txt - cp target/ffmpeg/bin/*.dll bundle/ - cp target/debug/dxcompiler.dll target/debug/dxil.dll bundle/ - ls bundle - - - uses: actions/upload-artifact@v4 - with: - name: rendering-test-bundle - path: bundle - retention-days: 2 diff --git a/crates/rendering/tests/dxc_fallback_e2e.rs b/crates/rendering/tests/dxc_fallback_e2e.rs deleted file mode 100644 index 8d8c720de8d..00000000000 --- a/crates/rendering/tests/dxc_fallback_e2e.rs +++ /dev/null @@ -1,56 +0,0 @@ -#![cfg(target_os = "windows")] - -use std::path::PathBuf; - -struct UnloadableBundledDxc { - files: Vec<(PathBuf, Option)>, -} - -impl UnloadableBundledDxc { - fn install() -> Self { - let exe = std::env::current_exe().expect("test exe"); - let dir = exe.parent().expect("test exe dir"); - let mut files = Vec::new(); - for name in ["dxcompiler.dll", "dxil.dll"] { - let path = dir.join(name); - let backup = path.exists().then(|| { - let backup = dir.join(format!("{name}.proof-backup")); - std::fs::rename(&path, &backup).expect("back up dll"); - backup - }); - std::fs::write(&path, []).expect("write zero-byte dll"); - files.push((path, backup)); - } - Self { files } - } -} - -impl Drop for UnloadableBundledDxc { - fn drop(&mut self) { - for (path, backup) in &self.files { - let _ = std::fs::remove_file(path); - if let Some(backup) = backup { - let _ = std::fs::rename(backup, path); - } - } - } -} - -#[test] -fn shared_device_with_unloadable_bundled_dxc() { - let _ = tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .try_init(); - let _dlls = UnloadableBundledDxc::install(); - - match pollster::block_on(cap_rendering::create_shared_device()) { - Ok(shared) => { - let info = shared.adapter.get_info(); - println!( - "PROOF RESULT: Ok, device created on adapter={} backend={:?} type={:?}", - info.name, info.backend, info.device_type - ); - } - Err(error) => println!("PROOF RESULT: Err({error})"), - } -} diff --git a/crates/rendering/tests/fxc_debug.rs b/crates/rendering/tests/fxc_debug.rs deleted file mode 100644 index 905d1aca862..00000000000 --- a/crates/rendering/tests/fxc_debug.rs +++ /dev/null @@ -1,185 +0,0 @@ -use cap_project::{ - AspectRatio, BackgroundSource, Crop, CursorEvents, FrameConfiguration, FrameStyle, - ProjectConfiguration, RecordingMeta, XY, -}; -use cap_rendering::{ - DecodedFrame, DecodedSegmentFrames, FrameRenderer, ProjectUniforms, RenderOptions, - RenderVideoConstants, RendererLayers, ZoomTransformTimeline, -}; - -#[test] -fn portrait_vertical_without_padding_fills_the_output() { - let options = RenderOptions { - screen_size: XY::new(1080, 1920), - camera_size: None, - preserve_screen_alpha: false, - }; - let project = ProjectConfiguration { - aspect_ratio: Some(AspectRatio::Vertical), - ..ProjectConfiguration::default() - }; - let resolution = XY::new(1080, 1920); - - assert_eq!( - ProjectUniforms::get_output_size(&options, &project, resolution), - (1080, 1920) - ); - assert_eq!( - ProjectUniforms::display_offset(&options, &project, resolution).coord, - XY::new(0.0, 0.0) - ); - assert_eq!( - ProjectUniforms::display_size(&options, &project, resolution).coord, - XY::new(1080.0, 1920.0) - ); -} - -#[tokio::test] -async fn imported_portrait_fills_a_vertical_output() { - let _ = tracing_subscriber::fmt() - .with_max_level(tracing::Level::DEBUG) - .try_init(); - let started = std::time::Instant::now(); - struct Elapsed(std::time::Instant); - impl Drop for Elapsed { - fn drop(&mut self) { - eprintln!("FXC DEBUG elapsed {:?}", self.0.elapsed()); - } - } - let _elapsed = Elapsed(started); - let instance = cap_rendering::create_wgpu_instance_sync(); - if instance - .request_adapter(&wgpu::RequestAdapterOptions::default()) - .await - .is_err() - { - eprintln!("no GPU adapter available, skipping portrait layout regression"); - return; - } - let options = RenderOptions { - screen_size: XY::new(1920, 1080), - camera_size: None, - preserve_screen_alpha: false, - }; - let recording_meta: RecordingMeta = serde_json::from_value(serde_json::json!({ - "pretty_name": "portrait-import", - "display": { "path": "display.mp4", "fps": 30 }, - "camera": null, - "audio": null, - "cursor": null - })) - .unwrap(); - let meta = recording_meta.studio_meta().unwrap().clone(); - let mut constants = RenderVideoConstants::new_with_options(options, recording_meta, meta) - .await - .unwrap(); - let mut project = ProjectConfiguration { - aspect_ratio: Some(AspectRatio::Vertical), - ..ProjectConfiguration::default() - }; - project.background.shadow = 0.0; - project.background.source = BackgroundSource::Color { - value: [0, 0, 0], - alpha: 255, - }; - project.cursor.hide = true; - let cursor = CursorEvents::default(); - let source_size = XY::new(1080, 1920); - let frames = DecodedSegmentFrames { - screen_size: options.screen_size, - screen_frame: Some(DecodedFrame::new( - [255, 0, 0, 255].repeat((source_size.x * source_size.y) as usize), - source_size.x, - source_size.y, - )), - camera_frame: None, - segment_time: 0.0, - recording_time: 0.0, - segment_has_camera: false, - }; - for decoded in [true, false] { - let mut frames = frames.clone(); - if !decoded { - frames.screen_frame = None; - frames.screen_size = source_size; - } - let uniforms = uniforms_for(&constants, &project, &frames, source_size); - assert_eq!(uniforms.frame_layout().output_size, [1080, 1920]); - assert_bounds(uniforms.frame_layout().display, [0.0, 0.0, 1080.0, 1920.0]); - } - - constants.options.screen_size = source_size; - project.aspect_ratio = Some(AspectRatio::Wide); - let mut landscape = frames.clone(); - landscape.screen_frame = Some(DecodedFrame::new(Vec::new(), 1920, 1080)); - let imported = uniforms_for(&constants, &project, &landscape, options.screen_size); - assert_eq!(imported.frame_layout().output_size, [1920, 1080]); - assert_bounds(imported.frame_layout().display, [0.0, 0.0, 1920.0, 1080.0]); - constants.options = options; - project.aspect_ratio = Some(AspectRatio::Vertical); - - for style in [FrameStyle::Browser, FrameStyle::MacOS] { - project.background.frame = Some(FrameConfiguration { - style, - ..Default::default() - }); - let imported = uniforms_for(&constants, &project, &frames, source_size); - constants.options.screen_size = source_size; - let native = uniforms_for(&constants, &project, &frames, source_size); - constants.options = options; - assert_bounds( - imported.frame_layout().display, - native.frame_layout().display, - ); - } - - project.background.frame = None; - project.background.crop = Some(Crop { - position: XY::new(480, 0), - size: XY::new(960, 1080), - }); - let cropped = uniforms_for(&constants, &project, &frames, source_size); - assert_bounds(cropped.frame_layout().display, [270.0, 0.0, 810.0, 1920.0]); - - project.background.crop = None; - let uniforms = uniforms_for(&constants, &project, &frames, XY::new(180, 320)); - let mut renderer = FrameRenderer::new(&constants); - let mut layers = RendererLayers::new(&constants.device, &constants.queue); - let rendered = renderer - .render_immediate(frames, uniforms, &cursor, true, &mut layers) - .await - .unwrap(); - assert_eq!((rendered.width, rendered.height), (180, 320)); - for (x, y) in [(90, 5), (5, 160), (174, 160), (90, 314)] { - let offset = y * rendered.padded_bytes_per_row as usize + x * 4; - let pixel = &rendered.data[offset..offset + 4]; - assert!( - pixel[0] > 240 && pixel[1] < 10 && pixel[2] < 10, - "{x},{y}: {pixel:?}" - ); - } -} - -fn assert_bounds(actual: [f32; 4], expected: [f32; 4]) { - for (actual_value, expected_value) in actual.iter().zip(expected) { - assert!( - (actual_value - expected_value).abs() < 2.0, - "display {actual:?}, expected {expected:?}", - ); - } -} - -fn uniforms_for( - constants: &RenderVideoConstants, - project: &ProjectConfiguration, - frames: &DecodedSegmentFrames, - resolution: XY, -) -> ProjectUniforms { - let cursor = CursorEvents::default(); - let zoom = - ZoomTransformTimeline::from_project(project, &cursor, 1.0, constants.options.screen_size); - let shared = std::sync::Arc::new(project.clone()); - ProjectUniforms::new( - constants, &shared, 0, 30, resolution, &cursor, frames, 1.0, &zoom, - ) -} From 91c847fe7ab0f2dbcf42343bf48928d4bde6862f Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:14:53 -0500 Subject: [PATCH 13/15] fix(rendering): record the FXC fallback with the cached compiler choice --- crates/rendering/src/lib.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs index a78ed5fed86..4ec21ae78b9 100644 --- a/crates/rendering/src/lib.rs +++ b/crates/rendering/src/lib.rs @@ -319,10 +319,13 @@ pub fn create_wgpu_instance_sync() -> wgpu::Instance { #[cfg(target_os = "windows")] let instance = match DX12_SHADER_COMPILER.get() { - Some(compiler) => dx12_instance(compiler.clone()), + Some((compiler, _)) => dx12_instance(compiler.clone()), None => { - let (instance, compiler) = dx12_instance_with_fxc_fallback(bundled_dxc_compiler()); - let _ = DX12_SHADER_COMPILER.set(compiler); + let bundled = bundled_dxc_compiler(); + let uses_dxc = !matches!(bundled, wgpu::Dx12Compiler::Fxc); + let (instance, compiler) = dx12_instance_with_fxc_fallback(bundled); + let fxc_fallback = uses_dxc && matches!(compiler, wgpu::Dx12Compiler::Fxc); + let _ = DX12_SHADER_COMPILER.set((compiler, fxc_fallback)); instance } }; @@ -331,19 +334,19 @@ pub fn create_wgpu_instance_sync() -> wgpu::Instance { } /// The compiler the first instance ended up on, so later instances skip a -/// DXC that already failed to load. +/// DXC that already failed to load, and whether that is the FXC fallback. #[cfg(target_os = "windows")] -static DX12_SHADER_COMPILER: std::sync::OnceLock = std::sync::OnceLock::new(); - -#[cfg(target_os = "windows")] -static DX12_FXC_FALLBACK: AtomicBool = AtomicBool::new(false); +static DX12_SHADER_COMPILER: std::sync::OnceLock<(wgpu::Dx12Compiler, bool)> = + std::sync::OnceLock::new(); /// WARP crashes on the first frame rendered with FXC-compiled shaders, so the /// FXC fallback only renders on hardware adapters. #[cfg(not(target_arch = "wasm32"))] fn software_adapters_unusable() -> bool { #[cfg(target_os = "windows")] - let unusable = DX12_FXC_FALLBACK.load(Ordering::Acquire); + let unusable = DX12_SHADER_COMPILER + .get() + .is_some_and(|(_, fxc_fallback)| *fxc_fallback); #[cfg(not(target_os = "windows"))] let unusable = false; @@ -385,7 +388,6 @@ fn dx12_instance_with_fxc_fallback( error = dx12_init_error(compiler), "DX12 with bundled DXC failed to initialise; retrying with FXC" ); - DX12_FXC_FALLBACK.store(true, Ordering::Release); ( dx12_instance(wgpu::Dx12Compiler::Fxc), wgpu::Dx12Compiler::Fxc, From 0a0056ca461529858827b6fdf1fb093087c94a0c Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:14:53 -0500 Subject: [PATCH 14/15] ci: temporary WARP e2e recheck --- .github/workflows/dxc-fallback-proof.yml | 72 ++++++++++++++++++++++ crates/rendering/tests/dxc_fallback_e2e.rs | 56 +++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 .github/workflows/dxc-fallback-proof.yml create mode 100644 crates/rendering/tests/dxc_fallback_e2e.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml new file mode 100644 index 00000000000..1659efd97a4 --- /dev/null +++ b/.github/workflows/dxc-fallback-proof.yml @@ -0,0 +1,72 @@ +name: DXC fallback proof (temporary) + +on: + push: + branches: + - fix/windows-dxc-fxc-fallback + workflow_dispatch: + +permissions: + contents: read + +jobs: + proof: + runs-on: windows-2022 + timeout-minutes: 90 + env: + CARGO_PROFILE_DEV_DEBUG: "0" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@1.88.0 + + - uses: ./.github/actions/setup-rust-cache + with: + target: x86_64-pc-windows-msvc + prefix-key: v1-rust-sync + save-cache: false + + - uses: actions/setup-node@v4 + with: + node-version: 24 + + - name: Native dependencies + env: + RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc + run: node scripts/setup.js + + - name: Add FFmpeg DLLs to PATH + shell: pwsh + run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" + + - name: Whole cap-rendering suite in parallel (bundled DXC intact) + shell: bash + run: | + cargo test --locked -p cap-rendering -- --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: > suite.txt 2>&1 || true + grep -h "test result\|FAILED" suite.txt + grep -h "test result" suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' + + - name: Fallback unit tests (bundled DXC intact) + shell: bash + run: | + cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee unit.txt + echo "----- summary -----" + grep -h "device created on FXC\|dx12 init error\|no bundled DXC\|test result\|^test " unit.txt + + - name: WARP-only runner, unloadable DXC (this branch) + shell: bash + run: | + cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > after.txt 2>&1 + echo "----- summary -----" + grep -h "PROOF RESULT\|retrying with FXC\|test result" after.txt + + - name: WARP-only runner, unloadable DXC (main's lib.rs) + shell: bash + run: | + git show origin/main:crates/rendering/src/lib.rs > crates/rendering/src/lib.rs + cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > before.txt 2>&1 + echo "----- summary -----" + grep -h "PROOF RESULT\|retrying with FXC\|test result" before.txt + git checkout -- crates/rendering/src/lib.rs diff --git a/crates/rendering/tests/dxc_fallback_e2e.rs b/crates/rendering/tests/dxc_fallback_e2e.rs new file mode 100644 index 00000000000..8d8c720de8d --- /dev/null +++ b/crates/rendering/tests/dxc_fallback_e2e.rs @@ -0,0 +1,56 @@ +#![cfg(target_os = "windows")] + +use std::path::PathBuf; + +struct UnloadableBundledDxc { + files: Vec<(PathBuf, Option)>, +} + +impl UnloadableBundledDxc { + fn install() -> Self { + let exe = std::env::current_exe().expect("test exe"); + let dir = exe.parent().expect("test exe dir"); + let mut files = Vec::new(); + for name in ["dxcompiler.dll", "dxil.dll"] { + let path = dir.join(name); + let backup = path.exists().then(|| { + let backup = dir.join(format!("{name}.proof-backup")); + std::fs::rename(&path, &backup).expect("back up dll"); + backup + }); + std::fs::write(&path, []).expect("write zero-byte dll"); + files.push((path, backup)); + } + Self { files } + } +} + +impl Drop for UnloadableBundledDxc { + fn drop(&mut self) { + for (path, backup) in &self.files { + let _ = std::fs::remove_file(path); + if let Some(backup) = backup { + let _ = std::fs::rename(backup, path); + } + } + } +} + +#[test] +fn shared_device_with_unloadable_bundled_dxc() { + let _ = tracing_subscriber::fmt() + .with_max_level(tracing::Level::INFO) + .try_init(); + let _dlls = UnloadableBundledDxc::install(); + + match pollster::block_on(cap_rendering::create_shared_device()) { + Ok(shared) => { + let info = shared.adapter.get_info(); + println!( + "PROOF RESULT: Ok, device created on adapter={} backend={:?} type={:?}", + info.name, info.backend, info.device_type + ); + } + Err(error) => println!("PROOF RESULT: Err({error})"), + } +} From 82d3a7c3123d96df5dd87cd9756f2e091ca4f3fb Mon Sep 17 00:00:00 2001 From: x Date: Fri, 6 Nov 2026 19:26:00 -0500 Subject: [PATCH 15/15] test(rendering): drop the temporary WARP recheck --- .github/workflows/dxc-fallback-proof.yml | 72 ---------------------- crates/rendering/tests/dxc_fallback_e2e.rs | 56 ----------------- 2 files changed, 128 deletions(-) delete mode 100644 .github/workflows/dxc-fallback-proof.yml delete mode 100644 crates/rendering/tests/dxc_fallback_e2e.rs diff --git a/.github/workflows/dxc-fallback-proof.yml b/.github/workflows/dxc-fallback-proof.yml deleted file mode 100644 index 1659efd97a4..00000000000 --- a/.github/workflows/dxc-fallback-proof.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: DXC fallback proof (temporary) - -on: - push: - branches: - - fix/windows-dxc-fxc-fallback - workflow_dispatch: - -permissions: - contents: read - -jobs: - proof: - runs-on: windows-2022 - timeout-minutes: 90 - env: - CARGO_PROFILE_DEV_DEBUG: "0" - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: dtolnay/rust-toolchain@1.88.0 - - - uses: ./.github/actions/setup-rust-cache - with: - target: x86_64-pc-windows-msvc - prefix-key: v1-rust-sync - save-cache: false - - - uses: actions/setup-node@v4 - with: - node-version: 24 - - - name: Native dependencies - env: - RUST_TARGET_TRIPLE: x86_64-pc-windows-msvc - run: node scripts/setup.js - - - name: Add FFmpeg DLLs to PATH - shell: pwsh - run: Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}\\target\\ffmpeg\\bin" - - - name: Whole cap-rendering suite in parallel (bundled DXC intact) - shell: bash - run: | - cargo test --locked -p cap-rendering -- --skip zoom_spring::tests::precompute_cost_is_bounded_for_long_projects --skip decoder::model:: > suite.txt 2>&1 || true - grep -h "test result\|FAILED" suite.txt - grep -h "test result" suite.txt | awk '{p+=$4; f+=$6} END {print "TOTAL passed", p, "failed", f}' - - - name: Fallback unit tests (bundled DXC intact) - shell: bash - run: | - cargo test --locked -p cap-rendering --lib dx12_compiler_fallback_tests -- --nocapture 2>&1 | tee unit.txt - echo "----- summary -----" - grep -h "device created on FXC\|dx12 init error\|no bundled DXC\|test result\|^test " unit.txt - - - name: WARP-only runner, unloadable DXC (this branch) - shell: bash - run: | - cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > after.txt 2>&1 - echo "----- summary -----" - grep -h "PROOF RESULT\|retrying with FXC\|test result" after.txt - - - name: WARP-only runner, unloadable DXC (main's lib.rs) - shell: bash - run: | - git show origin/main:crates/rendering/src/lib.rs > crates/rendering/src/lib.rs - cargo test --locked -p cap-rendering --test dxc_fallback_e2e -- --nocapture > before.txt 2>&1 - echo "----- summary -----" - grep -h "PROOF RESULT\|retrying with FXC\|test result" before.txt - git checkout -- crates/rendering/src/lib.rs diff --git a/crates/rendering/tests/dxc_fallback_e2e.rs b/crates/rendering/tests/dxc_fallback_e2e.rs deleted file mode 100644 index 8d8c720de8d..00000000000 --- a/crates/rendering/tests/dxc_fallback_e2e.rs +++ /dev/null @@ -1,56 +0,0 @@ -#![cfg(target_os = "windows")] - -use std::path::PathBuf; - -struct UnloadableBundledDxc { - files: Vec<(PathBuf, Option)>, -} - -impl UnloadableBundledDxc { - fn install() -> Self { - let exe = std::env::current_exe().expect("test exe"); - let dir = exe.parent().expect("test exe dir"); - let mut files = Vec::new(); - for name in ["dxcompiler.dll", "dxil.dll"] { - let path = dir.join(name); - let backup = path.exists().then(|| { - let backup = dir.join(format!("{name}.proof-backup")); - std::fs::rename(&path, &backup).expect("back up dll"); - backup - }); - std::fs::write(&path, []).expect("write zero-byte dll"); - files.push((path, backup)); - } - Self { files } - } -} - -impl Drop for UnloadableBundledDxc { - fn drop(&mut self) { - for (path, backup) in &self.files { - let _ = std::fs::remove_file(path); - if let Some(backup) = backup { - let _ = std::fs::rename(backup, path); - } - } - } -} - -#[test] -fn shared_device_with_unloadable_bundled_dxc() { - let _ = tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .try_init(); - let _dlls = UnloadableBundledDxc::install(); - - match pollster::block_on(cap_rendering::create_shared_device()) { - Ok(shared) => { - let info = shared.adapter.get_info(); - println!( - "PROOF RESULT: Ok, device created on adapter={} backend={:?} type={:?}", - info.name, info.backend, info.device_type - ); - } - Err(error) => println!("PROOF RESULT: Err({error})"), - } -}