GPU: pipelines off the render thread and cached; indirect execution on

With indirect execution the world's first frame asked for over 1,200
pipelines at once and took more than 30 s, so the title's own GPU
watchdog ended the run. Host pipelines are now made by worker threads: a
first use waits at most 0.5 s per title frame, and that pipeline's draws
are dropped until it is ready. The world presents frames again, and
indirect execution is the default (the switch is gone).

Pipelines are cached across runs:
- every host pipeline goes into a pipeline library saved under the cache
  folder (named by a hash of the translated code, our root signature and
  the state; a blob the device rejects starts an empty library);
- the pipelines drawn with are remembered and started during loading on
  the next run.
One cold and one warm run: the last pipeline was ready 38 s after the
world's first frame cold, 1.4 s warm; the first world frame took 3.2 s
cold, 0.37 s warm.

Also:
- Copy-backs of shader-written ranges return only the bytes the GPU
  changed; they used to overwrite what the title's CPU wrote meanwhile,
  which crashed the title.
- Indirect dispatch records are bounded (group counts were not), and the
  console's single-dispatch argument type runs as a dispatch.
- Per-shader counts of dropped draws in the diagnostics log; a switch
  that submits and times each list alone.

Not working yet: the world shows no geometry, and runs end on a GPU page
fault after at most about 55 s.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
MarvisandClaude Fable 5.2 committed 2026-11-24 01:02:11 +01:00
1 parent 97c78d1087
commit 35b054ec03
13 files changed
+1018 -101

No files matched your search

+19 -18
View File
@@ -1129,14 +1129,14 @@ extern "system" fn draw(_: This) {
}
/// `ExecuteIndirect(signature, max count, arguments, offset, count buffer,
/// offset)`. Grand Theft Auto VI's signatures (2026-11-23) hold one
/// argument each: draw (stride 16), indexed draw (20), dispatch (12), mesh
/// dispatch (12), and a console type 105 (stride 12, fields 0, 60000, 0,
/// over its 174 MB buffer) whose meaning is unknown. Those of PC types run
/// offset)`. Grand Theft Auto VI's signatures (title+0x2479466, 2026-11-24)
/// hold one argument each: draw (stride 16), indexed draw (20), dispatch
/// (12), mesh dispatch (12), and the console's single-pass dispatch, type
/// 105 (stride 12: the three group counts; its flags live in the
/// signature, the title passes none), run as a plain dispatch. They run
/// through the host's indirect execution (`State::execute_indirect`).
/// shortcut: type 105 and signatures that change root arguments are
/// dropped (logged once per signature); decode 105 when its draws are
/// missed.
/// shortcut: signatures that change root arguments are dropped (logged
/// once per signature).
extern "system" fn execute_indirect(
this: This,
signature: This,
@@ -1153,22 +1153,23 @@ extern "system" fn execute_indirect(
let address = crate::resource::buffer_bytes(arguments).map(|(p, _)| p as u64 + offset);
let counter = crate::resource::buffer_bytes(count).map(|(p, _)| p as u64 + count_offset);
let mut ran = false;
// shortcut: off unless `VICTORY_INDIRECT` is set (diagnostics builds):
// with it the world presented no frame for 30 s and the title's own
// GPU watchdog ended it (2026-11-24, cause not found); without it the
// world runs, with most geometry missing.
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
let on = *ON.get_or_init(|| {
cfg!(feature = "diagnostics") && std::env::var_os("VICTORY_INDIRECT").is_some()
});
#[cfg(windows)]
if on
&& let ([[kind, ..]], Some(address)) = (args, address)
if let ([[kind, ..]], Some(address)) = (args, address)
&& (count.is_null() || counter.is_some())
{
const DISPATCH: u32 = 2;
const DISPATCH_SINGLE: u32 = 105;
let kind = if *kind == DISPATCH_SINGLE { DISPATCH } else { *kind };
with_state(this, |list, s| {
ran = s.execute_indirect(list, (*kind, stride, max), address, counter);
ran = s.execute_indirect(list, (kind, stride, max), address, counter);
});
} else {
#[cfg(all(windows, feature = "diagnostics"))]
crate::pipeline::note_why(format!(
"indirect signature {args:?}: arguments in a buffer {}, count in a buffer {}",
address.is_some(),
count.is_null() || counter.is_some()
));
}
if ran {
return;