Skip to content
Merged
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
7 changes: 7 additions & 0 deletions crates/xcl/src/hle/d3d12x/pso_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ pub(super) fn build_is_wanted() -> bool {
BUILDING.with(|b| b.borrow().as_ref().is_some_and(|p| p.demand.lock().unwrap().wanted()))
}

/// This thread is a worker building a pipeline a bind waited for and went on without
/// (`resolve_within`): nobody waits for it now, but the title's draws or dispatches with it are
/// left out until it is built (`real::huge_compile_turn`).
pub(super) fn build_is_late() -> bool {
BUILDING.with(|b| b.borrow().as_ref().is_some_and(|p| p.late.load(Ordering::Acquire)))
}

/// This thread is a backlog worker building a pipeline nobody has used yet: its huge driver
/// compile gives its turn to any other (`real::big_compile_turn`).
pub(super) fn build_is_ahead() -> bool {
Expand Down
24 changes: 23 additions & 1 deletion crates/xcl/src/hle/d3d12x/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4680,7 +4680,17 @@ pub(super) fn huge_compile_turn(bytes: usize) -> SlotGuard {
if !slots.ahead && super::pso_async::build_is_ahead() {
super::pso_async::build_parks();
}
big_compile_turn(slots, || big_compile_commit_free(big_compile_headroom(bytes)), super::pso_async::build_is_wanted, super::pso_async::build_is_ahead)
big_compile_turn(slots, || big_compile_commit_free(headroom_for(bytes, super::pso_async::build_is_late())), super::pso_async::build_is_wanted, super::pso_async::build_is_ahead)
}

/// The commit headroom a huge compile of `bytes` waits for (`big_compile_headroom`), halved for
/// one whose pipeline the title already uses and draws without (`late`): with a wait budget no
/// build stays wanted, and on a machine short of commit every one of them then stood at the gate
/// for the full headroom while the frames that needed them were left out (33 builds held, one for
/// 129 s, with 4.5 GB of commit free and 44,596 draws skipped meanwhile).
fn headroom_for(bytes: usize, late: bool) -> u64 {
let full = big_compile_headroom(bytes);
if late { full / 2 } else { full }
}

/// Commit headroom a big driver compile waits for: 3 GB for the class that starts at
Expand All @@ -4706,6 +4716,18 @@ mod big_compile_tests {
use std::sync::atomic::AtomicBool;
use std::time::{Duration, Instant};

#[test]
fn a_late_build_waits_for_half_the_headroom() {
let bytes = huge_pso_bytes();
assert_eq!(headroom_for(bytes, false), big_compile_headroom(bytes));
assert_eq!(headroom_for(bytes, true), big_compile_headroom(bytes) / 2);
// (the class's floor: 3 GB, 1.5 GB for a late one - what one such compile takes)
assert_eq!(headroom_for(1 << 20, false), 3 << 30);
assert_eq!(headroom_for(1 << 20, true), 3 << 29);
// a giant program keeps a headroom that grows with it
assert_eq!(headroom_for(32 << 20, true), (32u64 << 20) * 256);
}

#[test]
fn wanted_builds_bypass_commit_and_unwanted_slot_but_respect_hard_cap() {
static S: Slots = Slots::new(1, 2);
Expand Down
Loading