Streaming, copy queue, texture pools and a shader cache that survives rebuilds

Textures and staging cut from 64 MB blocks; a kept view per page section and
page lists read again until the title has filled them in; the GPU side told
when streamed bytes land; results fetched over the copy queue
(VICTORY_RELAY_COPY=1); the write-watch journal behind a reader-writer lock;
the shader cache keyed by the translator's sources and `victory shaders`;
helper lanes as in upstream 1733 (VICTORY_HELPER_OWN).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-24 18:55:40 -06:00
1 parent 204047cb5c
commit dd3307943c
20 files changed
+1629 -232

No files matched your search

+36 -1
View File
@@ -1016,6 +1016,12 @@ fn own_bits_on() -> bool {
*ON.get_or_init(|| std::env::var_os("VICTORY_WAVE_OWN_BITS").is_none_or(|v| v != "0"))
}
/// What the translator was told of the host, for a cache's key: the widest
/// wave and the view heap's limit.
pub fn host_settings() -> [u32; 2] {
[host_max_wave(), super::shader::view_heap_limit()]
}
pub(super) fn host_max_wave() -> u32 {
#[cfg(test)]
if let Some(lanes) = TEST_HOST_WAVE.get() {
@@ -4203,7 +4209,30 @@ impl<'a> Lower<'a> {
/// `x` in the first lane of this host wave where `guard` holds, and whether it has such a
/// lane: the console reads the first lane of EXEC, and a lane that got here with EXEC clear
/// (a guard, not a branch) is not one. With none, `x` of the wave's first lane here.
///
/// A helper lane of a pixel shader takes its own value: the console's whole-quad mode has
/// helper lanes in EXEC, so a waterfall loop serves them too, and the host's wave operations
/// leave them out. Once only helper lanes are left in such a loop none of them ever matched:
/// they ran to the iteration limit, and left with no sample for their quad's derivatives,
/// along every triangle's edges (upstream #908, the fix of #1733 for this tree's form).
fn first_lane(&mut self, x: V, guard: Option<V>) -> (V, V) {
let (first, any) = self.first_live_lane(x, guard);
if !self.s.pixel || !super::helper_own() {
return (first, any);
}
let helper = self.helper_lane();
let c = self.cur;
let yes = self.s.m.bool(true);
(self.s.m.select(c, helper, x, first), self.s.m.select(c, helper, yes, any))
}
/// Whether this lane of a pixel shader is a helper lane.
fn helper_lane(&mut self) -> V {
let i1t = self.s.t.i1;
self.s.op(self.cur, "isHelperLane.i1", Attr::ReadOnly, i1t, 221, &[])
}
fn first_live_lane(&mut self, x: V, guard: Option<V>) -> (V, V) {
let c = self.cur;
let i32t = self.s.t.i32;
self.s.flags |= flags::WAVE_OPS;
@@ -5823,7 +5852,13 @@ impl<'a> Lower<'a> {
if per_lane {
self.s.flags |= flags::WAVE_OPS;
let i32t = self.s.t.i32;
d = self.s.op(c, "waveReadLaneFirst.i32", Attr::NoUnwind, i32t, 118, &[d]);
let first = self.s.op(c, "waveReadLaneFirst.i32", Attr::NoUnwind, i32t, 118, &[d]);
d = if self.s.pixel && super::helper_own() {
let helper = self.helper_lane();
self.s.m.select(c, helper, d, first)
} else {
first
};
}
addr = self.s.m.bin(c, Bin::Add, addr, d);
}
+35 -1
View File
@@ -112,7 +112,7 @@ use crate::{ShaderError, io, ir, resource, structure};
pub use bitcode::census;
pub use sampler::StaticSampler;
pub use lower::set_host_max_wave;
pub use lower::{host_settings, set_host_max_wave};
pub use rect::rect_list_gs;
pub use shader::{
MEMORY_FAULTS, MEMORY_PAGES, ROOT_CBV_SPACE, SAMPLER_SPACE, SLOT_FAULTS, SLOT_MEMORY, SLOT_STRIDES,
@@ -143,6 +143,14 @@ pub fn loop_limit() -> u32 {
})
}
/// Whether a pixel shader's helper lane reads its own value where the console reads the first
/// lane's (`lower.rs` `first_lane`); on unless `VICTORY_HELPER_OWN=0`. Part of the translation:
/// the shader cache keys on it.
pub fn helper_own() -> bool {
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*ON.get_or_init(|| std::env::var_os("VICTORY_HELPER_OWN").is_none_or(|v| v != "0"))
}
/// Which of a translated program's group barriers wait for the whole
/// group (`GroupMemoryBarrierWithGroupSync`); the others keep their memory
/// fence and lose the wait. A wait that some thread of the group never
@@ -1546,6 +1554,32 @@ mod barycentric_tests {
emit(&c, &native, &p, &st, &io, &res)
}
/// A pixel program's first-lane loop (no table entry in it, so not a waterfall the tracker
/// knows) asks for helper lanes, which is valid DXIL (upstream #946's program).
#[test]
fn a_pixel_first_lane_loop_serves_helper_lanes() {
let shader = pixel(
&[
0xD765_0000, 0x0001_00C1, // v_mbcnt_lo_u32_b32 v0, -1, 0
0x7E02_0280, // v_mov_b32 v1, 0
0xBE97_037E, // s_mov_b32 s23, exec_lo
0x7E18_0500, // v_readfirstlane_b32 s12, v0
0x7D84_000C, // v_cmp_eq_u32 vcc, s12, v0
0xBE95_3C6A, // s_and_saveexec_b32 s21, vcc_lo
0xBF80_0000, // s_nop 0
0x7E02_02FF, 0x3F80_0000, // v_mov_b32 v1, 1.0
0x897E_157E, // s_xor_b32 exec_lo, exec_lo, s21
0xBF89_FFF8, // s_cbranch_execnz loop
0xBEFE_0317, // s_mov_b32 exec_lo, s23
0xF800_180F, 0x0101_0101, // exp mrt0 v1 v1 v1 v1 done vm
0xBF81_0000, // s_endpgm
],
0,
)
.unwrap();
validate(&shader);
}
/// The translation's `SFI0` features and `ISG1` rows.
fn parts(shader: &HostShader) -> (u64, Vec<SigElement>) {
let c = Container::parse(&shader.dxil).unwrap();
+5
View File
@@ -125,6 +125,11 @@ pub fn set_view_heap_limit(null_slot: u32) {
VIEW_LIMIT.store(null_slot, std::sync::atomic::Ordering::Relaxed);
}
/// See [`set_view_heap_limit`].
pub(super) fn view_heap_limit() -> u32 {
VIEW_LIMIT.load(std::sync::atomic::Ordering::Relaxed)
}
pub(crate) struct Shader {
pub m: Module,
pub t: Types,