diff --git a/d3d12/crates/leonida-gpu/src/host.rs b/d3d12/crates/leonida-gpu/src/host.rs index c5e110d4f0..c9f530cdb6 100644 --- a/d3d12/crates/leonida-gpu/src/host.rs +++ b/d3d12/crates/leonida-gpu/src/host.rs @@ -7432,7 +7432,11 @@ impl Host { } } - fn send_published(&self, mut h: Handoff) { + fn send_published(&self, h: Handoff) { + // The lists and the stamp are added to `h` only with `diagnostics`; without + // it nothing here writes it, and `mut` on the parameter is a warning. + #[cfg(feature = "diagnostics")] + let mut h = h; let started = std::time::Instant::now(); let waited = std::time::Instant::now(); drop(h.heaps); diff --git a/d3d12/crates/leonida-gpu/src/pipeline/host.rs b/d3d12/crates/leonida-gpu/src/pipeline/host.rs index 3ab7cbc626..b4f237a41f 100644 --- a/d3d12/crates/leonida-gpu/src/pipeline/host.rs +++ b/d3d12/crates/leonida-gpu/src/pipeline/host.rs @@ -913,7 +913,11 @@ impl HostPipeline { &state, ); let pso = match mesh_pipeline( - &host.device, &root, None, code(0), code(1), g, depth_bounds, + &host.device, + &root, + MeshShaders { amplify: None, ms: code(0), ps: code(1) }, + g, + depth_bounds, library.name(&name).as_deref(), ) { Ok(pso) => pso, @@ -935,7 +939,7 @@ impl HostPipeline { &[&code_bytes(&stage), &code_bytes(&code(0)), &code_bytes(&code(1))], &state, ); - match mesh_pipeline(&host.device, &root, Some(stage), code(0), code(1), g, depth_bounds, library.name(&name).as_deref()) { + match mesh_pipeline(&host.device, &root, MeshShaders { amplify: Some(stage), ms: code(0), ps: code(1) }, g, depth_bounds, library.name(&name).as_deref()) { Ok(amplified) => { crate::host::name(&lified, || format!("{shaders:?} amplified")); Some((amplified, at)) @@ -1200,6 +1204,14 @@ fn graphics_depth_bounds_pipeline( } } +/// The three shader bytecodes a mesh pipeline is made from: the amplification +/// stage when the title runs one indirectly, and the two the translation writes. +struct MeshShaders { + amplify: Option, + ms: D3D12_SHADER_BYTECODE, + ps: D3D12_SHADER_BYTECODE, +} + /// A mesh pipeline from the title's graphics state: the pipeline-state /// stream form (no input layout). /// @@ -1214,13 +1226,12 @@ fn graphics_depth_bounds_pipeline( fn mesh_pipeline( device: &ID3D12Device, root: &ID3D12RootSignature, - amplify: Option, - ms: D3D12_SHADER_BYTECODE, - ps: D3D12_SHADER_BYTECODE, + code: MeshShaders, g: &GraphicsState, depth_bounds: bool, name: Option<&str>, ) -> windows::core::Result { + let MeshShaders { amplify, ms, ps } = code; use windows::core::Interface; /// `A`: the amplification stage's subobject, or nothing (`()`, no bytes in the stream). #[repr(C)] @@ -1533,9 +1544,9 @@ mod tests { g.targets.NumRenderTargets = 1; g.targets.RTFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; let name = super::super::library::name("mesh test", &root_blob, &[&ms, &ps], &g.describe()); - mesh_pipeline(&host.device, &root, None, code(&ms), code(&ps), &g, false, Some(&name)).expect("made"); + mesh_pipeline(&host.device, &root, MeshShaders { amplify: None, ms: code(&ms), ps: code(&ps) }, &g, false, Some(&name)).expect("made"); let loaded = super::super::library::LOADED.load(Ordering::Relaxed); - mesh_pipeline(&host.device, &root, None, code(&ms), code(&ps), &g, false, Some(&name)).expect("made again"); + mesh_pipeline(&host.device, &root, MeshShaders { amplify: None, ms: code(&ms), ps: code(&ps) }, &g, false, Some(&name)).expect("made again"); assert!( super::super::library::LOADED.load(Ordering::Relaxed) > loaded, "the mesh pipeline was compiled again instead of loaded from the library" diff --git a/d3d12/crates/leonida-gpu/src/pipeline/known.rs b/d3d12/crates/leonida-gpu/src/pipeline/known.rs index c5830e0b78..ad1f116c40 100644 --- a/d3d12/crates/leonida-gpu/src/pipeline/known.rs +++ b/d3d12/crates/leonida-gpu/src/pipeline/known.rs @@ -243,7 +243,11 @@ pub fn save_library() { /// right after a precompile (run d287, 2026-12-01). The library is ours: what is stored stays. pub fn store(dir: &Path, which: &[usize], threads: usize, each: impl FnMut(usize, Option<(f64, bool)>) + Send) { let mut places = HashMap::new(); - walk_shaders(dir, |stage, hash, at, len| drop(places.insert(hash, (stage, at, len)))); + // `let _ =` rather than `drop`, as `make` below does: the inserted value is `Copy`, so there + // is nothing for `drop` to run and clippy is right to say so. + walk_shaders(dir, |stage, hash, at, len| { + let _ = places.insert(hash, (stage, at, len)); + }); let wanted: HashSet = which.iter().copied().collect(); let mut entries = HashMap::new(); walk_pipelines(dir, |n, bytes| { @@ -265,8 +269,11 @@ pub fn store(dir: &Path, which: &[usize], threads: usize, each: impl FnMut(usize file.read_exact(&mut bytes).ok()?; Some(bytes) }; - loop { - let Some(&n) = which.get(next.fetch_add(1, std::sync::atomic::Ordering::Relaxed)) else { break }; + // `while let` rather than `loop` + `let ... else { break }`: the number is the + // condition, and clippy is right that the two say the same thing. + while let Some(&n) = + which.get(next.fetch_add(1, std::sync::atomic::Ordering::Relaxed)) + { let Some(entry) = entries.get(&n) else { continue }; tell(n, None); let began = std::time::Instant::now(); diff --git a/d3d12/crates/leonida-hle/src/modules/glyphs/live.rs b/d3d12/crates/leonida-hle/src/modules/glyphs/live.rs index 8028eccfd0..97fd61b0bd 100644 --- a/d3d12/crates/leonida-hle/src/modules/glyphs/live.rs +++ b/d3d12/crates/leonida-hle/src/modules/glyphs/live.rs @@ -118,7 +118,7 @@ pub fn counters(memory: &impl Memory, slot: Slot) -> Option { /// Whether a find's counters hold what the code puts there: whole numbers from 0, below a billion. pub fn plausible(memory: &impl Memory, slot: Slot) -> bool { - let whole = |v: f64| v.is_finite() && v >= 0.0 && v < 1e9 && v.fract() == 0.0; + let whole = |v: f64| v.is_finite() && (0.0..1e9).contains(&v) && v.fract() == 0.0; counters(memory, slot).is_some_and(|c| whole(c.made) && whole(c.shown)) } diff --git a/d3d12/crates/leonida-shader/src/emit/valu_tests.rs b/d3d12/crates/leonida-shader/src/emit/valu_tests.rs index 2143641e01..fa730c8323 100644 --- a/d3d12/crates/leonida-shader/src/emit/valu_tests.rs +++ b/d3d12/crates/leonida-shader/src/emit/valu_tests.rs @@ -1028,6 +1028,10 @@ fn v_cmp_lg_is_false_for_nan() { /// fast math cannot fold its NaN case away: ordered compares are false with a NaN, unordered ones /// true, `o` and `u` say whether there is one (RDNA2 ISA). After voidopcode/vilocity 598050b /// (INFIERNOXIII, GPL-3.0-or-later), its `float_compares_with_nan_on_the_device`. +/// The negations and the `a < b || a > b` in it are the instruction's own semantics, which is why +/// clippy's suggestions would change what this asserts: `!(a >= b)` is true when either operand is +/// NaN and `a != b` is not, and `!(a < b || a > b)` is true for a NaN pair where `a == b` is false. +#[allow(clippy::neg_cmp_op_on_partial_ord, clippy::double_comparisons)] #[test] fn float_compares_with_nan_on_the_device() { super::lower::TEST_NAN_EXACT.set(Some(true));