The first room renders right: byte-copied descriptor records are mirrored, views off their copy's elements get their own bytes, card room for the first world frame, levels on demand run on the card

- Descriptor records the title copies into its heap as bytes are mirrored
  before each submission (pull request #305 by Flyander, after upstream
  VIctory 86a5ed6), with a per-slot fingerprint so only records that
  changed are mirrored, the page read through the kernel, a switch
  (VICTORY_HEAP_SYNC=0) and a counter: about 40,000 records a frame on the
  test machine.
- A buffer view off its copy's elements gets a copy of its own bytes
  (after upstream 86a5ed6; VICTORY_VIEW_OWN_COPY=0: refused as before).
- Room on the card for the world's first-frame bursts: buffer copies
  (VICTORY_CARD_ROOM_FOR_BUFFERS, now on) and render targets
  (VICTORY_CARD_ROOM_FOR_TARGETS_MB, 3,072); a copy turned down gives its
  room up and is logged; the texture pass asks again every 32 MiB. 98
  buffer copies made (945 MB) where earlier runs made 1; 25 MB compared
  on the processor a frame where it was 550 to 710.
- Levels on demand: the fixes of pull request #747 by AscilCH. First run
  on a card (RTX 4070, VICTORY_LEVELS_ON_DEMAND=1): no device loss, 3.1 GB
  not allocated for levels the title does not hold. Still off by default.
- The guarded blocks under storage writes into physical pages are opened
  by default (VICTORY_PAGE_WRITES=0: counted only).
- Shaders: a program is translated with first-half interpolation pairs
  only if it was refused for one (with it on for every program 8,551
  working pixel programs came out changed); parked lane-mask pairs,
  f64 conversions and sums, lane permutations: 14 more programs translate.
- Counted, not fixed: an indirect compute pass asks for about 77,500
  groups in x and is cut to 65,535.

One five-minute game run of these changes on the test machine: no device
loss, no failed request. This merged tree was built; its test suites
were not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
fxcelessandClaude Fable 5.2 committed 2026-11-25 01:46:49 -05:00
1 parent 847a0af35e
commit 6afd80f252
13 files changed
+1188 -58

No files matched your search

+81 -1
View File
@@ -95,10 +95,20 @@ fn native_of(body: &[u32], wave64: bool, threads: u32) -> NativeProgram {
/// `program()` for a host of 32-lane waves, with the branches closing `wide` taken wave-wide.
fn lowered(native: &NativeProgram, p: &ir::Program, wide: &HashSet<usize>) -> Result<HostShader, ShaderError> {
lowered_on(native, p, wide, 32)
}
/// [`lowered`] for a host whose waves have at most `host_wave` lanes.
fn lowered_on(
native: &NativeProgram,
p: &ir::Program,
wide: &HashSet<usize>,
host_wave: u32,
) -> Result<HostShader, ShaderError> {
let st = structure::structure_wide(p, wide).expect("structure");
let res = resource::track(p, &native.layout, native.stage, Some(&st)).expect("resource::track");
let io = io::raise(p, native).expect("io::raise");
let was = lower::TEST_HOST_WAVE.replace(Some(32));
let was = lower::TEST_HOST_WAVE.replace(Some(host_wave));
let lowered = lower::lower(&lower::Parts {
native,
p,
@@ -199,6 +209,76 @@ fn a_sum_of_halves_over_the_wave_is_the_consoles_tree_bit_for_bit() {
eprintln!("ran on the hardware device: the sum {:#x} of the console's tree", tree[0]);
}
/// The console's 16-bit wave sum where the lanes at or past s0 have left the program (a
/// thread past the end of the data): on the console they add +0, and after each step of the
/// tree they hold their run's partial sum all the same. On a host of 64-lane waves (AMD) the
/// lanes that are here read each partner run's sum from a lane of it that is here.
#[test]
fn a_sum_of_halves_where_lanes_have_left_is_the_consoles_tree_bit_for_bit() {
let mut words = vec![
0x7DA8_0000, // v_cmpx_gt_u32 exec, s0, v0: the lanes below s0 stay
0, // s_cbranch_execz to the end (filled in below)
0x340C_0085, // v_lshlrev_b32 v6, 5, v0
0x340E_0082, // v_lshlrev_b32 v7, 2, v0
0x4A0E_0F06, // v_add_nc_u32 v7, v6, v7
0x4A0E_0F00, // v_add_nc_u32 v7, v0, v7
0x4A0E_0EFF,
0x0000_3C00, // v_add_nc_u32 v7, 0x3c00, v7
];
words.extend(super::wave::WAVE_OR_V7_TO_S7.iter().map(|&w| if w >> 25 == 28 { w & 0x01FF_FFFF | 50 << 25 } else { w }));
words.extend_from_slice(&[
0x7E00_0207, // v_mov_b32 v0, s7
0x38 << 26 | 0x1C << 18,
0x80 << 24 | 2 << 16, // buffer_store_dword v0, off, s[8:11], 0
]);
// past every word after it, to the program's end
words[1] = 0xBF88_0000 | (words.len() as u32 - 2);
let native = native(&words);
let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build");
let shader = lowered_on(&native, &p, &HashSet::new(), 64).expect("lower");
if let Ok(mut v) = validator::Validator::load(validator::Validator::default_path().as_deref()) {
let mut copy = shader.dxil.clone();
v.validate(&mut copy).expect("DXIL validation failed");
}
let wide = |h: u16| {
if h == 0 {
0.0
} else {
f32::from_bits((u32::from(h >> 10) + 112) << 23 | u32::from(h & 0x3FF) << 13)
}
};
let narrow = |f: f32| {
if f == 0.0 {
return 0;
}
let b = f.to_bits();
let h = ((b >> 23) - 112) << 10 | (b >> 13 & 0x3FF);
let rest = b & 0x1FFF;
(h + u32::from(rest > 0x1000 || rest == 0x1000 && h & 1 == 1)) as u16
};
let add = |a: u16, b: u16| narrow(wide(a) + wide(b));
let _one = super::valu_tests::ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner());
let mut ran = false;
for stay in [64u32, 63, 40, 33, 32, 17, 5, 1] {
let terms: Vec<u16> = (0..64u32)
.map(|t| if t < stay { (0x3C00 + 37 * t) as u16 } else { 0 })
.collect();
let mut tree = terms.clone();
while tree.len() > 1 {
tree = tree.chunks(2).map(|c| add(c[0], c[1])).collect();
}
let Some(got) = on_the_card(&shader, [stay, 0]) else {
return;
};
ran = true;
// (the high half is lane 0's term's: zero)
assert_eq!(got, u32::from(tree[0]), "{stay} lanes stay: got {got:#x}, the console's tree {:#x}", tree[0]);
}
if ran {
eprintln!("ran on the hardware device: the console's tree with lanes gone, in every case");
}
}
/// One `v_add_f16` whose exact result lies between two halves: 1 + 3/1024 (0x3C03) plus 2
/// (0x4000) is 3 + 1.5 steps of that range, which the console rounds up to 0x4202. The
/// host's `f32tof16` may give 0x4201 (toward zero); with `VICTORY_F16_NEAREST=1` the