Max, min, legacy products, medians and fractions as the RDNA card's own (VICTORY_RDNA_FLOAT, on; 0: spelled out as before)

The console's v_max/v_min (seven host operations each, for the order of the
two zeros), v_mul_legacy (a product, two comparisons, an or and a select;
two thirds of all products of the lighting program), v_med3 and v_fract are
written as the one operation the driver makes the same instruction of, where
the host is an AMD card with waves of 32 and 64. Checked on the RX 7900 XTX
against the spelled-out forms with zeros, infinities and NaN (a legacy
product's zero may have the other sign).

RX 7900 XTX, yard capture replayed turn by turn with and without (12 loops
each): dispatches and draws 18.41 -> 17.58 ms, the lists' 29.2 -> 28.4 of a
36.6 ms frame; 0.4 of it without the legacy products. The picture is the same
(79 dB; two replays of one set differ by 68). A product that is only a
product would give 0.65 ms more and NaN where the console has 0.

Measured and left out (nothing): v_mad as one multiply-add, fast
reciprocals, scalar loads of four dwords at once, buffers picked from the
heap read without asking for their kind (0.12 ms), a wave size for every
compute program (32: +0.26 ms, 64: +0.1, the console's: +0.1), no barriers
at all (0). Changes the translator: every shader is translated again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 12:49:12 -06:00
1 parent 4fa965582f
commit 565ab8517e
7 files changed
+377 -5

No files matched your search

@@ -0,0 +1,74 @@
//! Not a test of the translator: what the host's compiler makes of DXIL.
//! `VICTORY_PROBE=<folder>` and `--ignored probe`: each `.dxil` there (a
//! compute program with a constant buffer `b0` of four dwords and a raw
//! buffer, slot 0 of the view heap) is run on the card. `sem*` programs are
//! given the bits of 0.0, infinity, -0.0 and a NaN and what they store is
//! printed; of the others the time is (several runs of 4096 groups).
use super::HostShader;
use super::host::{Dispatch, Host, Root, View};
use crate::native::{HwStage, RootType};
#[test]
#[ignore = "a tool: VICTORY_PROBE=<folder>"]
fn probe() {
let Some(folder) = std::env::var_os("VICTORY_PROBE") else { return };
let host = Host::new(false).expect("a card");
let mut files: Vec<_> = std::fs::read_dir(folder)
.expect("the folder")
.filter_map(|e| Some(e.ok()?.path()))
.filter(|p| p.extension().is_some_and(|e| e == "dxil"))
.collect();
files.sort();
for file in files {
let name = file.file_stem().unwrap_or_default().to_string_lossy().into_owned();
let shader = HostShader {
stage: HwStage::Cs,
dxil: std::fs::read(&file).expect("the file"),
user_data: (0..4)
.map(|n| super::UserData { index: n, slot: 0, root: RootType::Constants, dword: n })
.collect(),
samplers: Vec::new(),
static_samplers: Vec::new(),
root_cbvs: Vec::new(),
root_srvs: Vec::new(),
root_uavs: Vec::new(),
root_indexed_views: Vec::new(),
};
let (root, pso) = match host.compute_pipeline(&shader) {
Ok(made) => made,
Err(e) => {
println!("{name}: {e}");
continue;
}
};
let run = |constants: [u32; 4], groups: u32| {
let began = std::time::Instant::now();
let out = host
.dispatch(
&root,
&pso,
&Dispatch {
roots: vec![(0, Root::Constants(constants.to_vec()))],
views: &[View::RawUav(64)],
samplers: &[],
groups: [groups, 1, 1],
},
)
.expect("a dispatch");
(out[0].clone(), began.elapsed().as_secs_f64() * 1e3)
};
if name.starts_with("sem") {
let (out, _) = run([0, 0x7F80_0000, 0x8000_0000, 0x7FC0_0000], 1);
for (n, x) in out.iter().enumerate().take(40) {
println!("{name} {n:>2}: {x:08x} {}", f32::from_bits(*x));
}
continue;
}
let constants = [0.37f32.to_bits(), 0.11f32.to_bits(), 16384, 0];
run(constants, 64);
let mut times: Vec<f64> = (0..9).map(|_| run(constants, 4096).1).collect();
times.sort_by(f64::total_cmp);
println!("{name}: {:.2} ms (least {:.2})", times[times.len() / 2], times[0]);
}
}