Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion d3d12/crates/leonida-gpu/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 18 additions & 7 deletions d3d12/crates/leonida-gpu/src/pipeline/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(&amplified, || format!("{shaders:?} amplified"));
Some((amplified, at))
Expand Down Expand Up @@ -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<D3D12_SHADER_BYTECODE>,
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).
///
Expand All @@ -1214,13 +1226,12 @@ fn graphics_depth_bounds_pipeline(
fn mesh_pipeline(
device: &ID3D12Device,
root: &ID3D12RootSignature,
amplify: Option<D3D12_SHADER_BYTECODE>,
ms: D3D12_SHADER_BYTECODE,
ps: D3D12_SHADER_BYTECODE,
code: MeshShaders,
g: &GraphicsState,
depth_bounds: bool,
name: Option<&str>,
) -> windows::core::Result<ID3D12PipelineState> {
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)]
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 10 additions & 3 deletions d3d12/crates/leonida-gpu/src/pipeline/known.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> = which.iter().copied().collect();
let mut entries = HashMap::new();
walk_pipelines(dir, |n, bytes| {
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion d3d12/crates/leonida-hle/src/modules/glyphs/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub fn counters(memory: &impl Memory, slot: Slot) -> Option<Counters> {

/// 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))
}

Expand Down
4 changes: 4 additions & 0 deletions d3d12/crates/leonida-shader/src/emit/valu_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading