Repository navigation
Conversation
|
I checked GPU output parity for the indirect whole-pipeline fallback on RTX 5070 / NVIDIA 616.92 at head The guarded console compute program went through the production I repeated both controls in fresh processes with the translated cache disabled and enabled: four focused passes, zero skips. Settings included This validates the selected whole fallback and GPU results for this synthetic program. The harness does not execute the title's AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report. |
|
Thanks for running the parity check through the production hook and AI use: Claude Code (Claude Opus 5.5) wrote this reply; Prime posted it. |
|
Combined Windows check of #3047, #3048, #3049, and #3050. I applied exact heads
The same nine test instances failed on both trees, including the shader-cache test; the combination added six passes and no new suite failure on this machine. I would not call the four drafts ready together yet: the two boundary failures below still need fixes. This test does not establish world-load RAM savings. I found a correctness gap in #3047's deferred whole shader. If Candidate #3047 fix and isolated regressiondiff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
index 4f8f069e..2da19c2f 100644
--- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
+++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
@@ -71,11 +71,12 @@ impl PipelineBuilder {
struct WholeSource {
console: Vec<u8>,
wave32: bool,
+ windows: u32,
}
impl WholeSource {
fn code(&self) -> Result<Vec<u8>, String> {
- crate::gpu::recomp::pso::console_to_dxil_for(&self.console, pso::Stage::Compute, 0, self.wave32).map(|c| c.dxil)
+ crate::gpu::recomp::pso::console_to_dxil_in(&self.console, pso::Stage::Compute, 0, self.wave32, self.windows).map(|c| c.dxil)
}
}
@@ -132,7 +133,7 @@ pub(super) unsafe fn build(this: *mut c_void, create: PsoFn, desc: &D3D12_COMPUT
let mut pieces = built.into_iter().collect::<Option<Vec<_>>>()?.into_iter();
let first = pieces.next()?;
let chain = Arc::new(Chain { builder, tail: pieces.collect(), words: plan.dwords_per_group,
- whole_source: WholeSource { console: console.to_vec(), wave32 }, whole: OnceLock::new(), build_whole: Mutex::new(()), whole_sent: Default::default() });
+ whole_source: WholeSource { console: console.to_vec(), wave32, windows: pso::mem_windows() }, whole: OnceLock::new(), build_whole: Mutex::new(()), whole_sent: Default::default() });
PROGRAMS.fetch_add(1, Ordering::Relaxed);
PIECES.fetch_add(plan.pieces.len() as u64, Ordering::Relaxed);
*result = first.into_raw();
@@ -351,11 +352,52 @@ mod tests {
}
Err(e) => panic!("the console program does not translate: {e}"),
};
- let source = super::WholeSource { console: blob.clone(), wave32: false };
+ let source = super::WholeSource { console: blob.clone(), wave32: false, windows: crate::gpu::recomp::pso::mem_windows() };
assert_eq!(source.code().unwrap(), first, "the DXIL the chain was split from");
assert!(source.console.len() < first.len(), "a chain keeps less than the DXIL: {} against {}", source.console.len(), first.len());
}
+ #[test]
+ fn deferred_whole_keeps_the_original_memory_window_mode() {
+ // The title-window setting is process-global; keep the variant comparison
+ // out of the parallel workspace test process.
+ const CHILD: &str = "XCL_TEST_DEFERRED_WHOLE_MODE_CHILD";
+ if std::env::var_os(CHILD).is_none() {
+ let status = std::process::Command::new(std::env::current_exe().unwrap())
+ .args(["--exact", "hle::d3d12x::real::dispatch_chain::tests::deferred_whole_keeps_the_original_memory_window_mode", "--nocapture", "--test-threads=1"])
+ .env(CHILD, "1")
+ .status()
+ .unwrap();
+ assert!(status.success(), "isolated memory-window regression failed");
+ return;
+ }
+ use crate::gpu::recomp::{pso, HEAP_WINDOWS};
+ use crate::gpu::recomp::pso::Stage;
+ use crate::gpu::xbox::tests::{fssm, sample};
+ let code: Vec<u8> = [
+ crate::gpu::rdna2::encode("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 0), ("DATA", 0), ("SADDR", 0)], None).unwrap(),
+ crate::gpu::rdna2::encode("S_ENDPGM", "ENC_SOPP", &[], None).unwrap(),
+ ].concat();
+ let mut f = fssm(&code, &[(6, 0)]);
+ f[0x138..0x13c].copy_from_slice(&4u32.to_le_bytes());
+ for offset in [0x13C, 0x140, 0x144] {
+ f[offset..offset + 4].copy_from_slice(&1u32.to_le_bytes());
+ }
+ let blob = sample(5, &[f]);
+ pso::set_title_windows(2 | HEAP_WINDOWS);
+ assert_eq!(pso::mem_windows(), 2 | HEAP_WINDOWS);
+ let (expected, source) = pso::in_switch_form(|| {
+ assert_eq!(pso::mem_windows(), 2);
+ let expected = pso::console_to_dxil_for(&blob, Stage::Compute, 0, false).unwrap().dxil;
+ let source = super::WholeSource { console: blob.clone(), wave32: false, windows: pso::mem_windows() };
+ (expected, source)
+ });
+ let ambient = pso::console_to_dxil_for(&blob, Stage::Compute, 0, false).unwrap().dxil;
+ assert_ne!(ambient, expected, "fixture must distinguish heap and switch forms");
+ assert!(source.code().unwrap() == expected, "whole form must use the chain's memory mode");
+ pso::set_title_windows(0);
+ }
+
const MB: u64 = 1 << 20;
#[test]For #3048, a separate focused regression shows that the opt-in driver-cache switch can deny a title-owned lookalike path. The #3049 heap-counter self-attribution was already reported, and #3050 has existing upload-cap and readback coverage. I did not duplicate those tests. I have not run a combined retail title, measured RAM or frame times, or produced clean-commit paired smoke blocks for these drafts. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), rustc 1.99.1 MSVC, SDK DXC 1.8.2502.11. AI use: Codex (GPT-6.2 Sol) combined the drafts, resolved the local conflict, ran both suites and the focused regressions, and drafted this report; Codex (GPT-6.2 Astra) independently traced the #3047 and #3048 code paths. |
|
Wine corroboration of @thehollowedone's deferred-window finding above, on standalone #3047 head A local ignored/fresh-process CPU regression builds a real synthetic memory-store program inside Wine11/Linux6.17, Rust1.98.1 Windows-MSVC target, DXC/dxil1.9.2609.5. Original fresh build32.77s; corrected source was freshly compiled33.62s in the intervening fixture build, then this isolated check reused that same binary (0.05s Cargo /0.03s test). Local paths:
This supports preserving the successful fallback choice/cache identity. It does not demonstrate a root-signature incompatibility—the source documents common bindings—or a retail crash, memory saving, Game-Init fence fix, or asynchronous Late-path correctness. Local production correction/test retained; no contribution PR. AI-assisted local verification. Completed retained-source GPU follow-through (same local mode correction)On The earlier absent-chain fixture was misconfigured: it omitted the FSSM Wave32 header (
Each process uses a distinct private disk-cache directory. The in-process translation cache remains enabled and its hit counts are asserted in both legs; this is not an all-caches-disabled test. No ExecuteIndirect, asynchronous |
|
I checked the previously untested asynchronous With The harness invokes AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report. |
Refresh xcl-dev#3047 on the current NVIDIA base while preserving its worker protections. Keep smaller console shader sources instead of whole DXIL copies and save the original window and wave settings for later whole-form builds. The legacy worker-setting control fails as expected and all seven targeted module tests pass; clean-head retail and full workspace validation remain pending. Assisted-by: Codex (GPT-6)
79aaead to
3780227
Compare
|
Ran the split-chain reconstruction tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. All seven tests pass, including the retained-size/reconstruction case and the real-worker test that distinguishes root-UAV from descriptor-heap translations. They are CPU-side tests; I did not run a title with an indirect whole-form fallback. The thread has GPU-parity runs on RTX 5070 and other cards, but no desktop 5070 Ti. Not tested: a retail indirect dispatch, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game data. AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
Independent Windows/NVIDIA check of #3047 head The unfiltered workspace run on the head terminated its
The only failed test on both is I also checked the revised source path: initial translation captures the wave and resolved window mode, and deferred reconstruction uses those same values. I found no new correctness blocker in that path. This is a source review, not a GPU output comparison of an indirect whole-form dispatch. Not tested here: world-load behavior, indirect whole-form GPU output, retail RAM savings on this revision, AMD or Intel. The PR remains draft while its description and branch checks are outstanding. Paired clean-head smoke follow-up: I built The head clears the numeric smoke gates (frames at least 80% of main; peak commit at most 125% of main), with zero removals and crashes. The script supplied no menu input, so this checks launch/menu stability, not world load or the indirect whole-form path. The author can paste these two blocks under Regression run in the PR description; the comment alone does not satisfy the description check. AI use: Codex (GPT-6.2 Sol) ran the suites and paired smoke; Codex (GPT-6.2 Astra) independently traced the deferred shader path. |
Refresh xcl-dev#3047 on the current NVIDIA base while preserving its worker protections. Keep smaller console shader sources instead of whole DXIL copies and save the original window and wave settings for later whole-form builds. The legacy worker-setting control fails as expected and all seven targeted module tests pass; clean-head retail and full workspace validation remain pending. Assisted-by: Codex (GPT-6)
3780227 to
e87bdba
Compare
|
Independent current-head Windows/NVIDIA check of #3047 at After
I found two source-level allocation paths worth correcting before the next head:
A focused regression should count source resolutions under concurrent whole requests, inside the OOM cooldown, and with the indirect budget already exhausted. The count should stay zero for requests rejected before a build. The existing whole-build tests only count driver-build closures, so they do not detect this work. This is a review and a failed current-head suite, not a merge-ready verdict. I did not run paired smoke on this head. AI use: Codex (GPT-6.2 Sol) checked the source and ran the tests; Codex (GPT-6.2 Astra) independently reviewed the allocation paths. |
How this was run: the suite ran once on the 11 of your PRs that build on this base, merged together (#3047 #3048 #3049 #3091 #3092 #3103 #3104 #3105 #3107 #3123 #3125; a local tree, only #3125 needed a resolution in README and the AI use: Claude Code (Claude Opus 5.5 and Claude Fable 5.2) ran the builds, tests and title runs, reviewed the diff and wrote this; the code points cited were checked against the merged tree. |
|
Follow-up to my current-head finding on On Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, DXC 1.8.2502.11, The separate Candidate gate change and focused regressionsdiff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
index 795cdc2b..ca03d1f0 100644
--- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
+++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
@@ -142,24 +142,32 @@ impl<T: Clone> WholeBuild<T> {
}
pub(super) fn get_or_build(&self, now: std::time::Instant, build: impl FnOnce() -> Result<T, HRESULT>) -> Result<T, HRESULT> {
+ self.get_or_build_prepared(|| now, || Ok(()), |()| build()).expect("infallible preparation")
+ }
+
+ /// Preparation errors are retryable and retain their message; only driver outcomes are cached
+ /// or subject to the OOM cooldown. Neither preparation nor build runs before admission.
+ fn get_or_build_prepared<P>(&self, now: impl Fn() -> std::time::Instant,
+ prepare: impl FnOnce() -> Result<P, String>, build: impl FnOnce(P) -> Result<T, HRESULT>) -> Result<Result<T, HRESULT>, String> {
if let Some(result) = self.result.get() {
- return result.clone();
+ return Ok(result.clone());
}
- let mut retry_at = self.retry_at.lock().unwrap();
+ let mut retry_at = self.retry_at.lock().unwrap_or_else(|e| e.into_inner());
if let Some(result) = self.result.get() {
- return result.clone();
+ return Ok(result.clone());
}
- if retry_at.is_some_and(|at| now < at) {
- return Err(crate::util::E_OUTOFMEMORY);
+ let started = now();
+ if retry_at.is_some_and(|at| started < at) {
+ return Ok(Err(crate::util::E_OUTOFMEMORY));
}
- match build() {
+ match build(prepare()?) {
Err(hr) if hr == crate::util::E_OUTOFMEMORY => {
- *retry_at = Some(now + WHOLE_RETRY);
- Err(hr)
+ *retry_at = Some(now() + WHOLE_RETRY);
+ Ok(Err(hr))
}
result => {
let _ = self.result.set(result.clone());
- result
+ Ok(result)
}
}
}
@@ -238,14 +246,15 @@ impl Chain {
/// thread is synchronously blocked waiting for this compile (registers a long PC call).
unsafe fn whole(&self, on_title_thread: bool) -> Result<ID3D12PipelineState, String> {
let result = match self.whole.ready() {
- Some(result) => result,
+ Some(result) => Ok(result),
None => {
// (only when a title thread is held while this compile lasts, as in any other long PC call)
let _call = on_title_thread.then(super::super::pso_async::pc_call);
- let code = self.whole_source.code().map_err(|e| format!("whole compute program: {e}"))?;
- self.whole.get_or_build(std::time::Instant::now(), || self.builder.pipeline(&code, &pc_iid(Kind::PipelineState)))
+ self.whole.get_or_build_prepared(std::time::Instant::now,
+ || self.whole_source.code().map_err(|e| format!("whole compute program: {e}")),
+ |code| self.builder.pipeline(&code, &pc_iid(Kind::PipelineState)))
}
- };
+ }?;
result.map_err(|hr| if hr == crate::util::E_OUTOFMEMORY { "whole compute pipeline: out of memory".into() } else { format!("whole compute pipeline ({hr:#x})") })
}
}
@@ -1103,6 +1112,58 @@ mod tests {
assert_eq!(deterministic.get_or_build(at + WHOLE_RETRY, || Ok(8)), Err(crate::util::E_INVALIDARG));
}
+ #[test]
+ fn whole_preparation_runs_only_after_admission() {
+ let at = std::time::Instant::now();
+ let whole: WholeBuild<u32> = WholeBuild::new();
+ let mut prepared = 0;
+ let mut built = 0;
+ assert_eq!(whole.get_or_build_prepared(|| at, || {
+ prepared += 1;
+ Ok(11)
+ }, |_| { built += 1; Err(crate::util::E_OUTOFMEMORY) }), Ok(Err(crate::util::E_OUTOFMEMORY)));
+ assert_eq!(whole.get_or_build_prepared(|| at + WHOLE_RETRY / 2, || {
+ prepared += 1;
+ Ok(12)
+ }, |_| { built += 1; Ok(8) }), Ok(Err(crate::util::E_OUTOFMEMORY)));
+ assert_eq!((prepared, built), (1, 1), "the cooling-down chain must not regenerate or build");
+ assert_eq!(whole.get_or_build_prepared(|| at + WHOLE_RETRY, || {
+ prepared += 1;
+ Ok(13)
+ }, |_| { built += 1; Ok(7) }), Ok(Ok(7)));
+ assert_eq!(whole.get_or_build_prepared(|| at + WHOLE_RETRY * 2, || {
+ prepared += 1;
+ Ok(14)
+ }, |_| { built += 1; Ok(8) }), Ok(Ok(7)));
+ assert_eq!((prepared, built), (2, 2), "the ready chain must reuse its result");
+ }
+
+ #[test]
+ fn whole_preparation_error_keeps_its_message_and_can_retry() {
+ let at = std::time::Instant::now();
+ let whole: WholeBuild<u32> = WholeBuild::new();
+ assert_eq!(whole.get_or_build_prepared(|| at, || Err::<(), _>("whole compute program: translation unavailable".into()),
+ |()| unreachable!()),
+ Err("whole compute program: translation unavailable".into()));
+ assert!(whole.ready().is_none(), "a source error is not a permanent driver result");
+ assert_eq!(whole.get_or_build_prepared(|| at, || Ok(()), |()| Ok(7)), Ok(Ok(7)));
+ }
+
+ #[test]
+ fn whole_oom_cooldown_begins_after_a_slow_preparation() {
+ use std::cell::Cell;
+ let at = std::time::Instant::now();
+ let finished = at + WHOLE_RETRY * 2;
+ let calls = Cell::new(0);
+ let clock = || { let n = calls.get(); calls.set(n + 1); if n == 0 { at } else { finished } };
+ let whole: WholeBuild<u32> = WholeBuild::new();
+ assert_eq!(whole.get_or_build_prepared(clock, || Ok(()), |()| Err(crate::util::E_OUTOFMEMORY)),
+ Ok(Err(crate::util::E_OUTOFMEMORY)));
+ assert_eq!(whole.get_or_build_prepared(|| finished + WHOLE_RETRY / 2, || unreachable!(), |()| unreachable!()),
+ Ok(Err(crate::util::E_OUTOFMEMORY)));
+ assert_eq!(whole.get_or_build_prepared(|| finished + WHOLE_RETRY, || Ok(()), |()| Ok(7)), Ok(Ok(7)));
+ }
+
#[test]
fn whole_worker_runs_all_jobs_on_one_late_thread() {
use std::collections::HashSet;AI use: Codex (GPT-6.2 Sol) wrote and ran the local candidate; Codex (GPT-6.2 Astra) reviewed the low-level gate design. Second local candidate: admit indirect source before regeneration. The separate At unchanged head
The budget tracks admitted source lengths, not transient translator scratch. I did not measure frame time or memory savings, run an indirect whole-form GPU output comparison, or produce clean-commit paired smoke on this uncommitted candidate. The PR remains draft. Candidate indirect-source reservation and regressionsdiff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
index 795cdc2b..df8971e5 100644
--- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
+++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
@@ -179,6 +179,7 @@ const WHOLE_RETRY: std::time::Duration = std::time::Duration::from_secs(10);
struct WholeSource {
console: Vec<u8>,
wave32: bool,
+ whole_len: usize,
// Preserve the first translation's window count and heap/switch form: a later worker
// does not inherit `in_switch_form` from the thread that built the split pieces.
windows: u32,
@@ -207,14 +208,17 @@ struct IndirectChain {
signature: ID3D12RootSignature,
whole: ID3D12PipelineState,
pieces: Vec<ID3D12PipelineState>,
- _charge: IndirectCharge,
+ _charge: IndirectCharge<'static>,
}
-struct IndirectCharge(usize);
+struct IndirectCharge<'a> {
+ used: &'a AtomicUsize,
+ bytes: usize,
+}
-impl Drop for IndirectCharge {
+impl Drop for IndirectCharge<'_> {
fn drop(&mut self) {
- INDIRECT_VARIANT_SOURCE.fetch_sub(self.0, Ordering::AcqRel);
+ self.used.fetch_sub(self.bytes, Ordering::AcqRel);
}
}
@@ -323,6 +327,25 @@ fn reserve_indirect_source(used: &AtomicUsize, bytes: usize, limit: usize) -> bo
}).is_ok()
}
+/// Admit source bytes before recreating the whole DXIL. The original translation supplies an
+/// estimate; reconcile any size difference before creating driver objects.
+fn indirect_source_with_budget<'a>(used: &'a AtomicUsize, plan_bytes: usize, whole_len: usize, limit: usize,
+ translate: impl FnOnce() -> Result<Vec<u8>, HRESULT>) -> Result<(Vec<u8>, IndirectCharge<'a>), HRESULT> {
+ let expected = plan_bytes.checked_add(whole_len).ok_or(E_OUTOFMEMORY)?;
+ if !reserve_indirect_source(used, expected, limit) { return Err(E_OUTOFMEMORY); }
+ let mut charge = IndirectCharge { used, bytes: expected };
+ let code = translate()?;
+ let actual = plan_bytes.checked_add(code.len()).ok_or(E_OUTOFMEMORY)?;
+ if actual > expected {
+ if !reserve_indirect_source(used, actual - expected, limit) { return Err(E_OUTOFMEMORY); }
+ charge.bytes = actual;
+ } else if actual < expected {
+ charge.bytes = actual;
+ used.fetch_sub(expected - actual, Ordering::AcqRel);
+ }
+ Ok((code, charge))
+}
+
#[derive(Default)]
struct PlanCache {
bytes: usize,
@@ -353,15 +376,12 @@ fn retain_indirect_plan(plan: Arc<DispatchChain>) {
fn build_indirect(chain: &Arc<Chain>) -> Result<Arc<IndirectChain>, HRESULT> {
let plan = chain.plan.upgrade().ok_or(E_INVALIDARG)?;
// (the whole form is not kept: made again from the console program, `WholeSource`)
- let whole_code = chain.whole_source.code().map_err(|e| {
- crate::xlog_warn!("D3D12.X: whole compute program for an indirect split variant: {e}");
- E_INVALIDARG
- })?;
- let source_bytes = plan.pieces.iter().map(Vec::len).sum::<usize>().saturating_add(whole_code.len());
- if !reserve_indirect_source(&INDIRECT_VARIANT_SOURCE, source_bytes, INDIRECT_VARIANT_BYTES) {
- return Err(E_OUTOFMEMORY);
- }
- let charge = IndirectCharge(source_bytes);
+ let plan_bytes = plan.pieces.iter().try_fold(0usize, |bytes, code| bytes.checked_add(code.len())).ok_or(E_OUTOFMEMORY)?;
+ let (whole_code, charge) = indirect_source_with_budget(&INDIRECT_VARIANT_SOURCE, plan_bytes,
+ chain.whole_source.whole_len, INDIRECT_VARIANT_BYTES, || chain.whole_source.code().map_err(|e| {
+ crate::xlog_warn!("D3D12.X: whole compute program for an indirect split variant: {e}");
+ E_INVALIDARG
+ }))?;
let signature = unsafe { signature_for(&chain.builder.device, &chain.builder.samplers, true) }.ok_or(E_INVALIDARG)?;
let builder = Arc::new(PipelineBuilder {
device: chain.builder.device.clone(),
@@ -458,7 +478,7 @@ pub(super) unsafe fn build(this: *mut c_void, create: PsoFn, desc: &D3D12_COMPUT
let mut pieces = built.into_iter().collect::<Option<Vec<_>>>()?.into_iter();
let first = pieces.next()?;
let chain = Arc::new(Chain { builder, tail: pieces.collect(), words: plan.dwords_per_group,
- whole_source: WholeSource { console: console.to_vec(), wave32, windows }, whole: WholeBuild::new(), plan: Arc::downgrade(&plan),
+ whole_source: WholeSource { console: console.to_vec(), wave32, windows, whole_len: whole.len() }, whole: WholeBuild::new(), plan: Arc::downgrade(&plan),
indirect: IndirectBuild::new(), indirect_noted: AtomicBool::new(false), whole_sent: AtomicBool::new(false) });
retain_indirect_plan(plan.clone());
// Initialize the journal on this preparation worker, never on the first recording call.
@@ -861,7 +881,7 @@ mod tests {
}
Err(e) => panic!("the console program does not translate: {e}"),
};
- let source = super::WholeSource { console: blob.clone(), wave32: false, windows };
+ let source = super::WholeSource { console: blob.clone(), wave32: false, windows, whole_len: first.len() };
assert_eq!(source.code().unwrap(), first, "the DXIL the chain was split from");
assert!(source.console.len() < first.len(), "a chain keeps less than the DXIL: {} against {}", source.console.len(), first.len());
}
@@ -886,7 +906,7 @@ mod tests {
let mut forms = Vec::new();
for windows in [4, 4 | HEAP_WINDOWS] {
let expected = pso::console_to_dxil_in(&blob, pso::Stage::Compute, 0, false, windows).unwrap().dxil;
- let source = super::WholeSource { console: blob.clone(), wave32: false, windows };
+ let source = super::WholeSource { console: blob.clone(), wave32: false, windows, whole_len: expected.len() };
let (tx, rx) = mpsc::channel();
assert!(super::enqueue_whole(Box::new(move || { let _ = tx.send(source.code()); })));
let actual = rx.recv_timeout(std::time::Duration::from_secs(30)).expect("whole worker completed").unwrap();
@@ -933,6 +953,58 @@ mod tests {
assert_eq!(used.load(Ordering::Relaxed), 100);
}
+ #[test]
+ fn indirect_source_rejection_does_not_translate() {
+ let used = AtomicUsize::new(9);
+ let mut calls = 0;
+ let result = indirect_source_with_budget(&used, 1, 1, 10, || {
+ calls += 1;
+ Ok(vec![0])
+ });
+ assert_eq!(result.err(), Some(E_OUTOFMEMORY));
+ assert_eq!((calls, used.load(Ordering::Relaxed)), (0, 9));
+ }
+
+ #[test]
+ fn indirect_source_charge_reconciles_growth_and_shrink() {
+ let used = AtomicUsize::new(2);
+ let (code, charge) = indirect_source_with_budget(&used, 2, 3, 10, || {
+ assert_eq!(used.load(Ordering::Relaxed), 7, "reserve before translation");
+ Ok(vec![0; 6])
+ }).unwrap();
+ assert_eq!((code.len(), used.load(Ordering::Relaxed)), (6, 10));
+ let shared = Arc::new(charge);
+ let second = shared.clone();
+ drop(shared);
+ assert_eq!(used.load(Ordering::Relaxed), 10, "charge lives through the final owner");
+ drop(second);
+ assert_eq!(used.load(Ordering::Relaxed), 2);
+
+ let (_, charge) = indirect_source_with_budget(&used, 2, 6, 10, || {
+ assert_eq!(used.load(Ordering::Relaxed), 10);
+ Ok(vec![0; 2])
+ }).unwrap();
+ assert_eq!(used.load(Ordering::Relaxed), 6);
+ drop(charge);
+ assert_eq!(used.load(Ordering::Relaxed), 2);
+ }
+
+ #[test]
+ fn indirect_source_failure_restores_only_its_own_reservation() {
+ let used = AtomicUsize::new(1);
+ let result = indirect_source_with_budget(&used, 2, 3, 10, || {
+ assert!(reserve_indirect_source(&used, 4, 10), "competing source");
+ Ok(vec![0; 6])
+ });
+ assert_eq!(result.err(), Some(E_OUTOFMEMORY));
+ assert_eq!(used.load(Ordering::Relaxed), 5, "retain the competing four bytes");
+ used.fetch_sub(4, Ordering::AcqRel);
+
+ let result = indirect_source_with_budget(&used, 2, 3, 10, || Err(E_INVALIDARG));
+ assert_eq!(result.err(), Some(E_INVALIDARG));
+ assert_eq!(used.load(Ordering::Relaxed), 1, "translation error refunds admission");
+ }
+
#[test]
fn signature_identity_includes_sampler_words_order_and_comparison() {
let a = ([1, 2, 3, 4], false);
@@ -1061,12 +1133,12 @@ mod tests {
let plan = Arc::new(DispatchChain { pieces: vec![dxil.clone(), dxil.clone()], dwords_per_group: 4 });
assert!(reserve_indirect_source(&INDIRECT_VARIANT_SOURCE, 1, INDIRECT_VARIANT_BYTES));
let indirect = Arc::new(IndirectChain { signature: rs.clone(), whole: first.clone(),
- pieces: vec![first.clone(), first.clone()], _charge: IndirectCharge(1) });
+ pieces: vec![first.clone(), first.clone()], _charge: IndirectCharge { used: &INDIRECT_VARIANT_SOURCE, bytes: 1 } });
let indirect_build = IndirectBuild::new();
indirect_build.requested.store(true, Ordering::Relaxed);
indirect_build.result.set(Ok(indirect)).unwrap_or_else(|_| unreachable!());
CHAINS.lock().unwrap().insert(key, Arc::new(Chain { builder, tail: vec![first.clone()], words: 4,
- whole_source: WholeSource { console: Vec::new(), wave32: false, windows: 0 }, whole, plan: Arc::downgrade(&plan), indirect: indirect_build,
+ whole_source: WholeSource { console: Vec::new(), wave32: false, windows: 0, whole_len: 0 }, whole, plan: Arc::downgrade(&plan), indirect: indirect_build,
indirect_noted: AtomicBool::new(false), whole_sent: AtomicBool::new(false) }));
let ty = D3D12_COMMAND_LIST_TYPE_COMPUTE;
let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(ty).unwrap();AI use for this follow-up: Codex (GPT-6.2 Sol) wrote the candidate and tests, ran them, and drafted the report; Codex (GPT-6.2 Astra) independently reviewed reservation ownership and concurrency. Combined-candidate check: I applied both collapsed diffs above, in order, to the unchanged #3047 head On the same RTX 3080 Ti / 621.35 Windows setup, This checks build and test interaction. The combined candidate's indirect whole-form GPU output, memory or latency benefit, and clean-commit paired smoke remain untested. Prime can apply or adapt both changes on a new head, then run those gates. AI use: Codex (GPT-6.2 Sol) combined the patches and ran the checks; Codex (GPT-6.2 Astra) reviewed their interaction. Exact-head GPU readback: I added a test-only fixture to unchanged #3047 head |
bmjask
left a comment
There was a problem hiding this comment.
Critical review of current head e87bdba4. Repeated indirect dispatch can defeat the intended memory/compile saving: when the whole-program DXIL is absent, its translation occurs before the existing build-once/cooldown gate. A failing or slow driver build can therefore make each retry regenerate the whole DXIL, including during cooldown. Move translation inside the same single-build gate and test repeated indirect submissions with slow/failing builds. The current-head Windows follow-up tested such a candidate locally. The source-retention change itself is sound, but this retry path needs fixing. No local Windows run.
|
Review (head e87bdba, diff read, not a merge-check; draft and conflicting, so not built or run):
Fine: the memory-window form is captured at the first translation (tested), the console bytes are copied out of title memory, driver-cache names don't change when the new translation is identical (tested), and the GPU tests use AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
A split compute chain now retains its smaller console shader source instead of an additional whole-program DXIL copy. When an indirect dispatch needs the whole form, it reconstructs it with the original wave mode and memory-window form. Part of #2688.
Rebased onto main (2026-11-28).
nvidia-devwas merged intomainby #3203, so this PR now targetsmainand its branch was rebased ontomain765b2c5bfff6754e8c9886a73e188a86aca3c64c: heade87bdba4e37aebbe4853d93ff9292da2efd694eb(was37802271a56db9201209b801cc15fe9fa09ab83b).mainhad added indirect split pipelines todispatch_chain.rssince (12 commits), so this is a hand port. The chain keeps the console program with its window and wave settings as before;buildstill receives the whole DXIL for the immediate cached-blob check; the indirect variant translates the whole form again when it is built. The README sentence moved undermain's rewritten preparation text. That port needs a review. The test run leaves out onemaintest that already fails alone on plainmain765b2c5bon this PC withadopted class. On the rebased head, on the same RTX 3060 Ti PC, debug profile:cargo check -p xcl --all-targetsexited 0, andcargo test -p xcl --lib -- --test-threads=4 dispatch_chain whole --skip failed_binding_keeps_indirect_commands_until_allocator_resetgave 63 passed, 0 failed, 1 ignored, anddispatch_chain_native_wave64_builds_wholeSKIPPED (no wave64). The whole suite and the paired title runs have not been rerun on this head; every other result below is from the earlier head. The rebase and its conflict resolution were done with Claude Code.What is in it
54225f5884a94cd23b7aab3f703a7c975070aa77, preserving the current persistent worker, panic recovery, title-thread accounting and submission guard.mem_windows()value alongside wave32 at the initial translation. The later worker usesconsole_to_dxil_inwith those saved settings; it does not recompute thread-local switch/heap selection.e429936cstill retainsChain::whole_code. Shaders: share owned bytecode across derived and pending pipelines #3091 covers shared SDK-derived bytecode; D3D12.X: pipelines that share a shader share one copy of its bytes #827 covers async descriptor interning; Recompiler: count split shader pieces in the NVIDIA cache budget #3103 covers cache admission accounting. Those are distinct allocation owners. This updates the existing PR, not a new competing implementation.Tested
cargo test --locked -p xcl --lib --target-dir <isolated-target> --no-run: both control and corrected binaries built.cargo test --locked -p xcl --lib --target-dir <isolated-target> hle::d3d12x::real::dispatch_chain::tests:: -- --nocapture --test-threads=1: 7 passed, 0 failed, 0 ignored, 1,801 filtered; no SKIPPED messages.the_whole_worker_preserves_each_programs_memory_windowswith--exactgave 0 passed, 1 failed, 0 ignored, 1,807 filtered; no skips. It reconstructed the wrong0x104memory-window form. This is a behavioral control, not a run of the untouched old PR head.Regression run
Pending new paired clean-head main/PR title runs for
37802271a56db9201209b801cc15fe9fa09ab83b. The old79aaead0smoke results are historical and do not validate this refresh.Not tested
AI use
The original retention change was written with Claude Code (Claude Opus 5.5), as recorded in the previous description. Codex (GPT-6) reviewed duplication and worker identity, refreshed the change, added and ran the focused control/tests, and updated this PR at Prime's request.
Optional temporary Discord for coordinating contributor work, testing and comparing results: https://discord.gg/6B4TykyC4W