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:
1 parent
97c78d1087
commit
35b054ec03
13 files changed
+1018
-101
No files matched your search
@@ -115,7 +115,8 @@ static DROPPED: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
/// Marks the last traced draw as not run on the host.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
fn dropped() {
|
||||
fn dropped(pipeline: usize) {
|
||||
crate::pipeline::note_drop(pipeline as This);
|
||||
if let Some(last) = FRAME.lock().unwrap_or_else(|e| e.into_inner()).last_mut() {
|
||||
last.push_str(" DROPPED");
|
||||
}
|
||||
@@ -494,6 +495,8 @@ impl State {
|
||||
"a dispatch without a host pipeline dropped"
|
||||
);
|
||||
DROPPED.fetch_add(1, Ordering::Relaxed);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
crate::pipeline::note_drop(self.pipeline as This);
|
||||
return;
|
||||
};
|
||||
if !p.compute {
|
||||
@@ -565,7 +568,7 @@ impl State {
|
||||
if !ran {
|
||||
DROPPED.fetch_add(1, Ordering::Relaxed);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
dropped();
|
||||
dropped(self.pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,7 +821,7 @@ impl State {
|
||||
if !ran {
|
||||
DROPPED.fetch_add(1, Ordering::Relaxed);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
dropped();
|
||||
dropped(self.pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,7 +908,7 @@ impl State {
|
||||
if !ran {
|
||||
DROPPED.fetch_add(1, Ordering::Relaxed);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
dropped();
|
||||
dropped(self.pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -928,14 +931,22 @@ impl State {
|
||||
const INDEXED: u32 = 1;
|
||||
const DISPATCH: u32 = 2;
|
||||
const MESH: u32 = 10;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
let why = |what: &str| crate::pipeline::note_why(format!("indirect kind {kind}: {what}"));
|
||||
#[cfg(not(feature = "diagnostics"))]
|
||||
let why = |_: &str| {};
|
||||
let len = u64::from(stride) * u64::from(max.max(1));
|
||||
let Some(args) = crate::shadow::find(arguments, len) else {
|
||||
why("arguments outside title buffers");
|
||||
return false;
|
||||
};
|
||||
let counter = match count {
|
||||
Some(at) => match crate::shadow::find(at, 4) {
|
||||
Some(s) => Some((s, at)),
|
||||
None => return false,
|
||||
None => {
|
||||
why("count outside title buffers");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
@@ -943,6 +954,7 @@ impl State {
|
||||
.then(|| host_signature(kind, stride))
|
||||
.flatten()
|
||||
else {
|
||||
why("no host signature");
|
||||
return false;
|
||||
};
|
||||
args.refresh(list, arguments, len);
|
||||
@@ -951,6 +963,7 @@ impl State {
|
||||
}
|
||||
// Bounded first: the clamp binds a compute pipeline of its own.
|
||||
if !crate::indirect::bound(list, &args.buffer, args.gpu(arguments), (kind, stride, max)) {
|
||||
why("not bounded (no clamp, or arguments not 4-byte aligned)");
|
||||
return false;
|
||||
}
|
||||
self.host_pipeline = 0;
|
||||
@@ -969,6 +982,11 @@ impl State {
|
||||
};
|
||||
if !ran {
|
||||
crate::indirect::done(list, &args.buffer);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
match crate::pipeline::host_pipeline(self.pipeline as This) {
|
||||
None => crate::pipeline::note_drop(self.pipeline as This),
|
||||
Some(p) => why(&format!("prepare failed (compute {}, mesh {})", p.compute, p.mesh)),
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#[cfg(feature = "diagnostics")]
|
||||
|
||||
Reference in new issue
Block a user