diff --git a/crates/victory-shader/src/emit/bitcode/opt.rs b/crates/victory-shader/src/emit/bitcode/opt.rs index d3ce5cd3..dc01baa4 100644 --- a/crates/victory-shader/src/emit/bitcode/opt.rs +++ b/crates/victory-shader/src/emit/bitcode/opt.rs @@ -743,6 +743,12 @@ impl Module { Op::Cmp(p, a, b) => Key::Cmp(*p, *a, *b), Op::Select(c, t, f) => Key::Select(*c, *t, *f), Op::Extract(a, n) => Key::Extract(*a, *n), + // A size query stays where the lowering put it: AMD's D3D12 + // compiler (amdxc64 32.0.32029.2010, RDNA4) crashes making the + // pipeline of some compute programs when one `getDimensions` + // serves the uses of another below it (29 of the title's + // `CS_RaytracingResolve` programs; RDNA2 makes them either way). + Op::Call(f, _) if self.funcs[*f as usize].name == "dx.op.getDimensions" => return None, Op::Call(f, args) => Key::Call(*f, args.clone()), Op::Gep(ty, p, idx) => Key::Gep(*ty, *p, idx.clone()), Op::Load(p) => Key::Load(*p), @@ -1503,6 +1509,29 @@ mod tests { m.write(); } + #[test] + fn a_size_query_is_not_reused() { + let Diamond { + k: Kit { mut m, b, writes, .. }, + x, + y, + then, + .. + } = diamond(); + let i32t = m.int(32); + let fty = m.func_ty(i32t, vec![i32t, i32t]); + m.ptr(fty); + let dims = m.function("dx.op.getDimensions", fty, Some(Attr::ReadOnly), false); + let top = m.call(b, dims, vec![x, y]); + m.call(b, writes, vec![top, top]); + let again = m.call(then, dims, vec![x, y]); + m.call(then, writes, vec![again, again]); + m.optimise(REUSE); + assert_eq!(stores(&m, then), [[again, again]]); + assert_eq!(body(&m, then), 2); + m.write(); + } + #[test] fn a_branch_taken_says_what_its_condition_is() { let Diamond { diff --git a/crates/victory-shader/src/lib.rs b/crates/victory-shader/src/lib.rs index ed9c3e0b..51deaf36 100644 --- a/crates/victory-shader/src/lib.rs +++ b/crates/victory-shader/src/lib.rs @@ -26,7 +26,7 @@ pub mod structure; /// translated before is kept across the rebuild. `victory shaders` /// translates again what an earlier build of the translator cached and says /// how many came out different: if any did, the bump was due. -pub const TRANSLATOR_VERSION: u32 = 1; +pub const TRANSLATOR_VERSION: u32 = 2; pub use dxbc::{Container, FourCC, Part}; pub use dxil::{DxilProgram, ShaderKind, XboxExtras};