Skip to content

fix(desktop): use DXC for Windows shaders - #2135

Open
Hona wants to merge 2 commits into
CapSoftware:mainfrom
Hona:windows-dxc
Open

fix(desktop): use DXC for Windows shaders#2135
Hona wants to merge 2 commits into
CapSoftware:mainfrom
Hona:windows-dxc

Conversation

@Hona

@Hona Hona commented Aug 19, 2026

Copy link
Copy Markdown

Fixes #2134

Summary

Use Microsoft's official DXC redistributable for Windows DX12 shader compilation.

Cap keeps the existing WGSL unchanged. Windows setup downloads and verifies the official Microsoft.Direct3D.DXC NuGet package, stages the matching architecture DLLs, and packages the runtime and license notices with the desktop app. The renderer selects the adjacent DXC pair and falls back to FXC when the bundle is unavailable.

Why DXC

The current FXC path spends most of editor startup compiling composite-video-frame.wgsl. Five runs on the affected NVIDIA RTX 3080 Ti Laptop GPU measured:

Compiler Average Range
FXC 26,207.059 ms 22,171.644-28,926.749 ms
DXC, unchanged WGSL 254.666 ms 204.120-378.561 ms

DXC reduces composite pipeline creation by 99.03%, or 102.9x, without introducing shader variants or changing the blur algorithm.

This option was selected because it:

  • preserves the current WGSL and rendering behavior;
  • uses WGPU's maintained Windows compiler path;
  • avoids mode-specific shader permutations and dynamic-loop compatibility problems;
  • uses Microsoft's official redistributable instead of WebView2-private DLLs;
  • retains FXC behavior for builds that do not contain the verified DXC bundle.

Rendering verification

A deterministic 360-frame stress sequence exercised directional blur, radial zoom blur, resampling, rounded corners, shadows, borders, color grading, and grain.

Metrics were calculated on raw RGBA frames before video compression:

Comparison PSNR SSIM
FXC vs unchanged WGSL compiled by DXC 86.553432 dB 0.999999

The compilers produce negligible floating-point differences, but no visible quality regression was found. The full methodology and root-cause analysis are in #2134.

Implementation

  • Download Microsoft.Direct3D.DXC 1.9.2607.13 from NuGet during Windows native setup.
  • Verify the package against a pinned SHA-256 digest before extraction.
  • Stage x64 or ARM64 dxcompiler.dll and dxil.dll for local and target builds.
  • Include the official LLVM and Microsoft notices in the desktop bundle.
  • Resolve DXC beside the executable, including Cargo's target/*/deps test layout.
  • Use FXC when the verified runtime is not present.

Validation

  • cargo fmt --all -- --check
  • cargo check -p cap-rendering
  • cargo test -p cap-rendering --lib -- --nocapture (151 passed, 1 ignored)
  • pnpm dlx @biomejs/biome@2.2.0 check --write scripts/setup.js apps/desktop/scripts/prepare.js
  • node --check scripts/setup.js
  • node --check apps/desktop/scripts/prepare.js
  • Generated tauri.windows.conf.json includes the DXC DLLs and notices.
  • Verified NuGet SHA-256, x64 extraction, and valid Microsoft Authenticode signatures locally.

Greptile Summary

This PR adds a verified Microsoft DXC download and staging flow for Windows, packages the runtime DLLs and notices with the desktop application, and configures the shared renderer to prefer adjacent DXC libraries with an FXC fallback.

  • Downloads and verifies the pinned DXC NuGet package during Windows setup.
  • Stages architecture-specific runtime DLLs into Cargo profile directories and desktop resources.
  • Selects dynamic DXC for DX12 shader compilation when both required DLLs are available.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking cache-recovery issue in the Windows DXC setup flow.

The runtime compiler selection retains an FXC fallback, while the only accepted concern is that a corrupted cached DXC package must be deleted manually before Windows setup can succeed again.

Files Needing Attention: scripts/setup.js

Important Files Changed

Filename Overview
scripts/setup.js Adds verified DXC acquisition and staging, but an invalid cached archive causes persistent setup failures without automatic recovery.
crates/rendering/src/lib.rs Configures Windows DX12 rendering to use adjacent DXC libraries while retaining FXC fallback behavior.
apps/desktop/scripts/prepare.js Adds the DXC runtime DLLs and license notices to generated Windows Tauri resources.
Prompt To Fix All With AI
### Issue 1
scripts/setup.js:597-600
**Invalid DXC cache persists**

When the cached DXC package is truncated or corrupted, checksum verification throws without deleting it, so every subsequent Windows setup reuses the same invalid archive and fails until it is manually removed.

```suggestion
	if (actualHash !== asset.sha256) {
		await fs.rm(archivePath, { force: true });
		throw new Error(
			`${asset.name} SHA-256 mismatch: got ${actualHash}, expected ${asset.sha256}; removed the invalid cached archive`,
		);
	}
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(desktop): use DXC for Windows shader..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Copilot AI lite review requested due to automatic review settings August 19, 2026 06:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread scripts/setup.js Outdated
Comment on lines +597 to +600
if (actualHash !== asset.sha256)
throw new Error(
`${asset.name} SHA-256 mismatch: got ${actualHash}, expected ${asset.sha256}`,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Invalid DXC cache persists

When the cached DXC package is truncated or corrupted, checksum verification throws without deleting it, so every subsequent Windows setup reuses the same invalid archive and fails until it is manually removed.

Suggested change
if (actualHash !== asset.sha256)
throw new Error(
`${asset.name} SHA-256 mismatch: got ${actualHash}, expected ${asset.sha256}`,
);
if (actualHash !== asset.sha256) {
await fs.rm(archivePath, { force: true });
throw new Error(
`${asset.name} SHA-256 mismatch: got ${actualHash}, expected ${asset.sha256}; removed the invalid cached archive`,
);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/setup.js
Line: 597-600

Comment:
**Invalid DXC cache persists**

When the cached DXC package is truncated or corrupted, checksum verification throws without deleting it, so every subsequent Windows setup reuses the same invalid archive and fails until it is manually removed.

```suggestion
	if (actualHash !== asset.sha256) {
		await fs.rm(archivePath, { force: true });
		throw new Error(
			`${asset.name} SHA-256 mismatch: got ${actualHash}, expected ${asset.sha256}; removed the invalid cached archive`,
		);
	}
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7e36577. A checksum mismatch now removes the invalid cached archive before returning the error. I also reproduced the recovery path with a corrupt cache entry and confirmed the archive was deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: editor startup blocks for ~26s compiling composite shader with FXC

2 participants