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
25 changes: 24 additions & 1 deletion docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -9699,7 +9699,30 @@ an earlier fixture that did so, the split left the result at its sentinel.
The scratch is kept with the recording's desktop allocator
(`x2w_d3d12_recording_scratches` reports how many it holds) and is released
only when that allocator is reset after every queue that ran it has passed its
fence.
fence. The rewrite's root signature and pipeline are kept for the life of the
process in an instance that is never destroyed. In #2683 the instance was a
function-local static: on an RX 9070 XT (driver 32.0.32029.2010) its destructor
released the pipeline during DLL detach and the process exited with 0xC0000409
in `amdxc64.dll` after every readback had passed. A never-destroyed instance
exited 0 in 3 of 3 runs there.
[Review](https://github.com/R0Y00/Xbox2Windows/pull/2683)
On the same adapter and driver, with this change merged onto main,
`startup_indirect_count_split_hardware` passed and 6 of 6 direct runs exited 0;
with only `split_indirect_dispatch.h` restored to the static, 4 of 4 runs ended
in 0xC0000409, the dump showing the static's destructor in
`_execute_onexit_table` at DLL detach.
[Measurement](https://github.com/R0Y00/Xbox2Windows/pull/2734)

The cache is process-owned and released only by process exit. Explicitly
unloading and reloading `d3d12_xs.dll` in a live host is not a supported path:
each load allocates a new cache and nothing tears the previous one down outside
the loader lock. Supporting it needs that teardown and its own coverage. The
kept root signature and pipeline each hold a reference to their device: on the
RX 5700 XT and WARP 10.0.26100.9818 the device count went from 1 to 3 with both
objects created, and stayed at 2 after the application released its own
reference. So a cached device is never destroyed, and `entry_for`, which matches
devices by pointer, cannot see a new device at a reused address while an entry
holds those objects. An entry whose build failed holds neither.

`startup_indirect_count_(warp|hardware)` keep the native call. On the RX 5700
XT (driver 32.0.21045.29003) the hardware test still fails at its first case
Expand Down
12 changes: 10 additions & 2 deletions src/startup_stubs/split_indirect_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,18 @@ class SplitIndirectDispatch {
std::vector<std::unique_ptr<Entry>> entries_;
};

// Never destroyed: a function-local static would release its root signatures and pipelines in the destructor during
// DLL detach, and on an RX 9070 XT (driver 32.0.32029.2010) the driver fail-fasts there (0xC0000409 in amdxc64,
// review of #2683). The entries are already kept for the life of the process (see entry_for).
// Lifetime boundary: this cache is process-owned and released only by process exit. Explicitly unloading and
// reloading d3d12_xs.dll in a live host is not a supported path: each load allocates a new cache and nothing tears
// the previous one down outside the loader lock, so its entries stay allocated. Supporting it needs that teardown
// and its own coverage. The kept root signature and pipeline each hold a reference to their device, so a cached
// device is never destroyed and its address cannot be reused by another device while the entry lives.
inline SplitIndirectDispatch& split_indirect_dispatch()
{
static SplitIndirectDispatch splitter;
return splitter;
static SplitIndirectDispatch* const splitter = new SplitIndirectDispatch;
return *splitter;
}

} // namespace x2w_startup
Loading