From b937c3373af532f8f09f57a731e166378ed829de Mon Sep 17 00:00:00 2001 From: John Howard <49204095+Royalflamejlh@users.noreply.github.com> Date: Tue, 24 Nov 2026 16:39:25 -0700 Subject: [PATCH] Shaders: -O0 compiles leave out DXC's debug no-ops A source over 8 MB is compiled at -O0, and at that level DXC adds loads of dx.nothing.a as no-ops for its debugger. In a 12.5 MB compute program of a retail pack that is 197 453 of the 780 095 instructions of its DXIL, and the driver compiles every one. Such a source now gets -opt-disable debug-nops as well. Sources under 8 MB are compiled as before. A DXC that does not know the name takes it without an error and compiles as before. Measured on main 20cf130 under Wine with DXC 1.9.2609.5, the pack's six compute programs over 8 MB of HLSL, split wave64 form, one compile each: 89 477 996 B of DXIL become 69 159 484 B (-22.7 %; each program 18.0 to 24.4 % smaller, none larger). DXC took 79 s for the 12.5 MB program against 70 s. The new test fails without the change. Co-Authored-By: Claude Fable 5.2 --- crates/xcl/src/gpu/recomp/dxc.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/xcl/src/gpu/recomp/dxc.rs b/crates/xcl/src/gpu/recomp/dxc.rs index 907511e63..fe5664f58 100644 --- a/crates/xcl/src/gpu/recomp/dxc.rs +++ b/crates/xcl/src/gpu/recomp/dxc.rs @@ -258,6 +258,23 @@ mod version_tests { assert_eq!(lib(0, 0, "10.0.1.2").to_string(), "(file 10.0.1.2)"); } + #[test] + fn a_source_compiled_at_o0_has_no_debug_noops() { + if location().is_err() { + crate::gpu::recomp::runner::skip_test("no DXC"); + return; + } + let src = "RWByteAddressBuffer m : register(u0);\n[numthreads(1, 1, 1)] void main() { uint a = m.Load(0); uint b = a + 1u; m.Store(4, b); }\n"; + let padded = format!("{src}{}", " ".repeat(8 * 1024 * 1024)); + let with_noops = compile(src, "main", "cs_6_6", &["-O0"]).unwrap(); + let without = compile(src, "main", "cs_6_6", &["-O0", "-opt-disable", "debug-nops"]).unwrap(); + if without.len() == with_noops.len() { + println!("this DXC has no debug-nops switch"); + return; + } + assert_eq!(compile(&padded, "main", "cs_6_6", &[]).unwrap().len(), without.len()); + } + /// The DXC of this PC, when it has one: what `report.json` says of it. #[test] fn the_loaded_dxc_is_identified() { @@ -489,7 +506,7 @@ fn compile_here(src: &str, entry: &str, profile: &str, extra: &[&str]) -> Result // a 19 600-instruction CS: 13.5 s instead of 17.7 at -O3; -O0 10.6 s, but twice the DXIL) if !extra.iter().any(|a| a.starts_with("-O")) { if src.len() > 8 * 1024 * 1024 { - args.push(crate::util::wide("-O0")); + args.extend(["-O0", "-opt-disable", "debug-nops"].map(crate::util::wide)); } else if src.len() > 1024 * 1024 { args.push(crate::util::wide("-O1")); }