[PR #622] [MERGED] runtime: apply the console value writes after the submission that carried them (RT-LIST-WRITE-VALUE) #663

Closed
opened 2026-11-26 20:18:38 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/622
Author: @Mby159
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/rt-list-write-value


📝 Commits (6)

  • de234e1 value writes: carry the console's value writes on the GPU label path
  • 9b74691 docs: the console's value-write slots 71 to 74
  • f3bfc03 Merge #1723 (post-story runtime) into #622 (list value writes)
  • 924966e Adapt #622 to #1723: its arena and xmem writes become the list values' fallback
  • f005d7a Adapt #622 to #1723: the slot 71-74 rows say who writes and who waits
  • 6aa5f0b Merge main (#1723 merged) into #622 (list value writes)

📊 Changes

15 files changed (+564 additions, -6 deletions)

View changed files

📝 docs/d3d12_command_objects.md (+18 -0)
📝 docs/d3d12_xs_console_abi.md (+6 -0)
📝 runtime/CMakeLists.txt (+9 -0)
📝 runtime/README.md (+1 -1)
📝 runtime/shims/d3d12_vulkan_device.cpp (+43 -0)
📝 runtime/shims/d3d12_xs_device.cpp (+7 -1)
📝 runtime/shims/d3d12_xs_device.h (+9 -0)
📝 runtime/shims/d3d12_xs_list_values.h (+26 -3)
📝 runtime/shims/xmem.cpp (+98 -0)
📝 runtime/shims/xmem.h (+14 -0)
📝 runtime/src/gpu_label_memory.h (+2 -1)
➕ runtime/src/value_write_sink.h (+77 -0)
📝 runtime/src/vulkan_backend.h (+10 -0)
📝 runtime/src/vulkan_gpu_labels.h (+22 -0)
➕ runtime/test/xbox_list_value_fallback_test.cpp (+222 -0)

📄 Description

Claimed in the coordination issue as: RT-LIST-WRITE-VALUE

What and why

Console list slots 71 and 72 (Write32BitValueBottomOfPipeX and Write64BitValueBottomOfPipeX) were dropped: the list proxy took the kListNotForwarded branch and returned 0, so the value never reached the title memory and the console counter the title watches never moved.

This pull request records the write on the list proxy, collects the records when the queue proxy submits the lists, and applies the value into the title memory after that submission has completed on the GPU, in submission order. The console writes the value at the bottom of the pipe; here the CPU writes it once the queue timeline says the submission is done, so a later submission on the same queue sees it.

Where the bytes land. The console address is resolved in two cases that are genuinely different:

  • a VA inside the arena (a default-heap buffer): the arena is host-visible, so the CPU writes arena.mapped + va, the same bytes the GPU reads. A sparse resource is refused, because the sparse pass binds its memory elsewhere.
  • any other VA: a page of the title own memory. The console VA is a host address, and a title-placed buffer imports exactly those pages, so the CPU write is the GPU read.

The write channel that was missing. The console VA being a host address was not enough: xmem commits its physical pages on first touch, and two of the measured windows are PAGE_NOACCESS for the CPU. There was no CPU write path into the xmem pages at all (commit_physical_range only commits, host_at in the Vulkan backend is read-only, and its host pointer is null for DEFAULT/READBACK). The new rt::xmem::write_title_bytes commits the physical range and then writes through the section own host mapping for a physical page (writable even where the title view is PAGE_NOACCESS), or through the window bytes when the range is not one of the xmem pages, after a VirtualQuery protection check so a GPU-only window is refused instead of faulting.

New files: runtime/src/xs_value_writes.h (the record the layers share and the function that applies a batch), runtime/test/xs_value_writes_test.cpp (a CPU test with a byte-array model, no game data) and runtime/test/xs_value_writes_handover_test.cpp (the hand-over from the queue proxy to the queue that submits, Windows-only).

Depends on: none. #577, which shares runtime/src/vulkan_backend.h, is merged, and this branch is rebased onto main at d0da7dad.

The shape after the review

@V6ser asked for this to be less indirect. It is now:

  • the list proxy keeps a plain std::vector<ValueWrite>; there is no log class;
  • the slot width is read where the write is recorded and the flags where it is applied; there is no enum and no rule table;
  • the ordering by submission is the Vulkan queue's own - a deque and a lock in runtime/src/vulkan_backend.h; there is no queue helper class;
  • the hand-over from the proxy to the queue that submits is three lines of state in runtime/shims/d3d12_xs_device.cpp; it is no longer in the shared header.

runtime/src/xs_value_writes.h is the record and the function that applies a batch, and the xmem write the D3D12 layer needs moved to runtime/shims/xmem.h, next to the shim that owns it. The change against the previous head d149020a is 11 files, +247/-295.

The hand-over is still per thread, and that is deliberate: the console list proxy is in the Xbox-ABI shim layer and the queue that submits is in the COM layer, ID3D12CommandQueue::ExecuteCommandLists cannot carry the records in its signature, and the proxy cannot call into the COM layer because about twenty test binaries compile runtime/shims/d3d12_xs_device.cpp on its own (xs_proxy_mock_test, root_sig_test, the d3d12_*_test targets).

One defect found while reshaping this and fixed: the batches were pushed by the submitting thread and popped by the completion thread with no lock. They are under one now.

The hand-over must not need a TLS guard

The hand-over's buffer is reached through a constant-initialized thread_local pointer, and the vector behind it is
made on first use. A thread_local that needs a dynamic initializer or a C++ destructor is not usable in this tree:
the runtime runs with "zero _Init_thread_header TLS guards or C++ thread_local destructors"
(runtime/shims/com_shim.cpp), and every other thread_local in the tree is a plain POD for that reason - the bool
in the xmem shim, the bool in the startup trace, the POD array in the PE loader.

The title's own threads reach the CRT's _register_thread_local_exe_atexit_callback on their way out, and with a
dynamically initialized thread_local in the process that path terminates the process: @DesertGamer measured
0xC0000409 at startup on the retail package, with the stack
abort <- terminate <- register_thread_local_exe_atexit_callback <- game_thread, and their constant-initialized
pointer experiment does not abort. The earlier heads aborted for the same reason: their staged records were a
static thread_local with a std::vector inside, one layer down in runtime/src/xs_value_writes.h.

What I tested

  • xs_value_writes_test: the console's value-write slots record and apply their writes, exit 0 (built with the MinGW clang and run here).
  • runtime/src/vulkan_backend.h compiles on its own (clang++ -fsyntax-only, llvm-mingw 20261117), and runtime/shims/xmem.cpp is syntax-clean with the change.
  • runtime/shims/d3d12_xs_device.cpp: syntax-only compile reports two errors, both pre-existing and environmental: ID3D12GraphicsCommandList8 is not in this machine's MinGW d3d12.h.
  • python -I scripts/check_no_game_data.py over all 12 changed files: exit 0, no output.
  • ctest --test-dir runtime/build -C Release: 71 of 72 pass, 2 skipped (shader_library_corpus, vk_sync_validation - they need game data or a GPU). The one failure is vk_queue_query_sync, a known flake: on the pristine upstream tree at the same commit it fails 2 of 5 direct runs, on this tree 3 of 8. It is not caused by this change.

Hardware: Windows 11 x64 (10.0.29712), Python 3.13, llvm-mingw 20261117. No game files, no GPU, no network.

Not verified here

  • The full Windows build was never run. runtime/shims/d3d12_com.cpp and runtime/shims/d3d12_vulkan_device.cpp are not compile-checked as whole files: they need the SDK d3d12.h and the generated d3d12_stubs.h, and the MinGW header is older and structurally different, so the repository stub generator cannot run on it. The CI build with MSVC and the Windows SDK is still required.
  • No GPU and no game: the fence-dispatcher callback, the arena mapping, the xmem page write and the real title counter were never exercised. The CPU test models them with a byte array.
  • xs_proxy_mock_test is Windows-only and was not run. The mock infrastructure is unchanged, but the mock queue and list proxies now carry a plain vector of records.

Gaps I would like a ruling on

  1. Slot 71 flags are not measured. Only slot 72 flags 1 and 2 are known to mean GPU / system timestamp. The port writes the slot 71 value verbatim; if the title uses slot 71 with flags 1 or 2 expecting a timestamp, it gets the value instead.
  2. The GPU timestamp needs calibrated timestamps. gpu_timestamp() uses the DEVICE domain of VK_EXT/KHR_calibrated_timestamps, the same clock GetClockCalibration answers with. On a device without it the function returns 0, the write is skipped, and the counter this item is about would still not advance. Flag 2 (system clock, QPC) and flag 0 (the value) work everywhere. This is the largest functional gap.
  3. It is a CPU write, not a GPU write. On the console the GPU writes the value at the bottom of the pipe. Here the CPU writes it after the submission completed, so a later submission sees it, but a concurrent submission on another queue may see it earlier or later than on the console.
  4. Ordering is per queue. Two queues writing the same address race, as they do on the console; across queues the FIFO is not global.
  5. Two landing spots are refused: a sparse resource (its memory is bound by the sparse pass) and a page the CPU may not write (a PAGE_NOACCESS GPU window). Such a write is dropped and reported once on stderr.
  6. The console flush argument (the third one) is not interpreted; every write is applied after the submission.

Attribution and licensing

The argument shapes are the facts xcl measured; the slot numbers are measured on the retail title and in the shipped BVH builder (section 3.3a of the document); the deferred bottom-of-pipe write model follows VIctory. Both projects are cited for facts and for the model only, no code copied: xcl is GPL-2.0-only and VIctory is GPL-3.0-only, and the attribution is in runtime/src/xs_value_writes.h, in the new paragraph of docs/d3d12_command_objects.md and in that document section 8.1 licence note.

docs/related_projects.md lists the projects whose licences the repository tracks as a whole. I did not add xcl or VIctory there, because that file reads like a project-level policy; if the maintainer wants them listed, that is a one-paragraph follow-up.

Coordination

This is in runtime/shims/d3d12_xs_device.cpp, the same file as the RT-XS-LIST-X-IID work. @fiestorra said their piece is proxy_create_command_list_x and ours is list_slot / list_query_interface and the queue unwrap path, and that they will keep the wrap_list signature as it is; this pull request does not change it.

AI-assisted: yes.

Ordering: a later submission can read before the host write lands

sodove's Windows review (RTX 5070 Ti, Khronos validation 1.4.369) reproduced this in a test-only extension of the
synthetic xmem placement test: a CPU fence held one queue while it received a list created through
CreateCommandListX with one 32-bit and one 64-bit value write, followed by a second submission copying the same
private buffer to readback. The writes stayed blocked until the fence was released and both eventually landed in
CPU-visible memory, but the following GPU copy saw 0 of the 2 new values in 14 of 15 runs.

The progress callback orders the CPU writes with each other; later GPU work can still run before the callback
publishes them. What this pull request gives is therefore:

  • the value writes are published into the title's memory after the submission that recorded them has completed on
    the GPU, and
  • they are ordered with each other.

It does not give a later submission a guarantee that it observes them. A consumer that reads the same memory in a
following submission needs its own synchronisation. That is stated here rather than left implicit.

The xmem shim stays out of the D3D12 library

The D3D12 layer reaches the title's memory through rt::xmem::write_title_bytes, which lives in the xmem shim.
Calling it directly from d3d12_vulkan_device.cpp put the shim in the gta6rt_d3d12_com library's dependency
set, and every consumer of that library that does not compile the shim itself failed to link (LNK2019/LNK1120,
reported by sodove). The write now goes through a pointer the shim registers - rt::xmem::title_write_fn in
runtime/shims/xmem.h - so the library keeps its own dependencies and a process without the shim keeps the
console's value writes dropped, the way they were before.

The slot numbers: measured, and corrected

The two value-write calls arrive at console list slots 71 and 72, not 69 and 70. Three independent readings agree:

  • The retail title's own trace, on two machines (@DadaCap's RTX 5080 and @DesertGamer's RTX 5070, native Windows 11): list slot 71 carries a title address and a value, slot 72 a title address and the flags word, slot 74 the wait's arguments, and slot 69 is never called.
  • docs/d3d12_command_objects.md section 3.3a, which reads the shipped XboxBvhBuilder.dll: +0x238 (slot 71) is a 32-bit value write and +0x248 (slot 73) is a masked wait. That is the same numbering - and it already contradicted the four rows this pull request first added.
  • The old numbers are not merely different: with 69/70 the port recorded slot 70's call, whose first argument is 1 and not an address, as a 64-bit write at address 1 (the sink refuses it unless the arena is mapped at that moment), and slot 69 was never called, so no 32-bit value was ever written.

So the two constants in runtime/src/xs_value_writes.h now name the measured slots, the four rows of the documented table move with them (71 and 72 write, 73 and 74 wait), the comments that name them follow, and the test pins both numbers.

What is still open. Where the numbering starts to differ is not known. The title never calls ExecuteIndirect - neither at 61 nor at 63 - so the shift's origin is not pinned. ExecuteIndirect (61), the copy at 85 and the console-only 141 may sit two slots low as well. That is an inference from the four measured rows, not a measurement, and nothing in this pull request changes them; it is filed as a separate finding.

Not verified locally. The renumbering is two constants, the table rows, the comments and the test. This machine has no C++ toolchain, so the C++ test and the Windows build are the CI's to run. python -I scripts/check_no_game_data.py over all 12 changed files: exit 0, no output.

Rebased onto current main

The branch is rebased onto main at d0da7dad (the merge of #404). One conflict needed a hand: runtime/shims/d3d12_vulkan_device.cpp had main's state_.context->mesh_queries = info.mesh_shader_queries; (from #577) and this pull request's set_up_value_writes(); on the same line, and both are kept. The change against that main is 12 files, +640/-8.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/622 **Author:** [@Mby159](https://github.com/Mby159) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/rt-list-write-value` --- ### 📝 Commits (6) - [`de234e1`](https://github.com/ubiquitarianism/leonida/commit/de234e185c238f6e3f4cbcf884df878124665ce5) value writes: carry the console's value writes on the GPU label path - [`9b74691`](https://github.com/ubiquitarianism/leonida/commit/9b74691f743145efe2d10664b8a71315b2307679) docs: the console's value-write slots 71 to 74 - [`f3bfc03`](https://github.com/ubiquitarianism/leonida/commit/f3bfc039b27e0a2a70994885a54a8602cbd24d43) Merge #1723 (post-story runtime) into #622 (list value writes) - [`924966e`](https://github.com/ubiquitarianism/leonida/commit/924966e2fbde9ae0ac96dcd433803047505efa2f) Adapt #622 to #1723: its arena and xmem writes become the list values' fallback - [`f005d7a`](https://github.com/ubiquitarianism/leonida/commit/f005d7ab223ef10adf404d62272542bf3a90f0da) Adapt #622 to #1723: the slot 71-74 rows say who writes and who waits - [`6aa5f0b`](https://github.com/ubiquitarianism/leonida/commit/6aa5f0b0d4eae5766b56d64fc91aa2443117d5eb) Merge main (#1723 merged) into #622 (list value writes) ### 📊 Changes **15 files changed** (+564 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_command_objects.md` (+18 -0) 📝 `docs/d3d12_xs_console_abi.md` (+6 -0) 📝 `runtime/CMakeLists.txt` (+9 -0) 📝 `runtime/README.md` (+1 -1) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+43 -0) 📝 `runtime/shims/d3d12_xs_device.cpp` (+7 -1) 📝 `runtime/shims/d3d12_xs_device.h` (+9 -0) 📝 `runtime/shims/d3d12_xs_list_values.h` (+26 -3) 📝 `runtime/shims/xmem.cpp` (+98 -0) 📝 `runtime/shims/xmem.h` (+14 -0) 📝 `runtime/src/gpu_label_memory.h` (+2 -1) ➕ `runtime/src/value_write_sink.h` (+77 -0) 📝 `runtime/src/vulkan_backend.h` (+10 -0) 📝 `runtime/src/vulkan_gpu_labels.h` (+22 -0) ➕ `runtime/test/xbox_list_value_fallback_test.cpp` (+222 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-LIST-WRITE-VALUE ### What and why Console list slots 71 and 72 (`Write32BitValueBottomOfPipeX` and `Write64BitValueBottomOfPipeX`) were dropped: the list proxy took the `kListNotForwarded` branch and returned 0, so the value never reached the title memory and the console counter the title watches never moved. This pull request records the write on the list proxy, collects the records when the queue proxy submits the lists, and applies the value into the title memory **after that submission has completed on the GPU**, in submission order. The console writes the value at the bottom of the pipe; here the CPU writes it once the queue timeline says the submission is done, so a later submission on the same queue sees it. **Where the bytes land.** The console address is resolved in two cases that are genuinely different: - a VA inside the arena (a default-heap buffer): the arena is host-visible, so the CPU writes `arena.mapped + va`, the same bytes the GPU reads. A sparse resource is refused, because the sparse pass binds its memory elsewhere. - any other VA: a page of the title own memory. The console VA *is* a host address, and a title-placed buffer imports exactly those pages, so the CPU write is the GPU read. **The write channel that was missing.** The console VA being a host address was not enough: xmem commits its physical pages on first touch, and two of the measured windows are `PAGE_NOACCESS` for the CPU. There was no CPU write path into the xmem pages at all (`commit_physical_range` only commits, `host_at` in the Vulkan backend is read-only, and its `host` pointer is null for DEFAULT/READBACK). The new `rt::xmem::write_title_bytes` commits the physical range and then writes through the *section own* host mapping for a physical page (writable even where the title view is `PAGE_NOACCESS`), or through the window bytes when the range is not one of the xmem pages, after a `VirtualQuery` protection check so a GPU-only window is refused instead of faulting. New files: `runtime/src/xs_value_writes.h` (the record the layers share and the function that applies a batch), `runtime/test/xs_value_writes_test.cpp` (a CPU test with a byte-array model, no game data) and `runtime/test/xs_value_writes_handover_test.cpp` (the hand-over from the queue proxy to the queue that submits, Windows-only). Depends on: none. #577, which shares `runtime/src/vulkan_backend.h`, is merged, and this branch is rebased onto `main` at `d0da7dad`. ### The shape after the review @V6ser asked for this to be less indirect. It is now: - the list proxy keeps a plain `std::vector<ValueWrite>`; there is no log class; - the slot width is read where the write is recorded and the flags where it is applied; there is no enum and no rule table; - the ordering by submission is the Vulkan queue's own - a deque and a lock in `runtime/src/vulkan_backend.h`; there is no queue helper class; - the hand-over from the proxy to the queue that submits is three lines of state in `runtime/shims/d3d12_xs_device.cpp`; it is no longer in the shared header. `runtime/src/xs_value_writes.h` is the record and the function that applies a batch, and the xmem write the D3D12 layer needs moved to `runtime/shims/xmem.h`, next to the shim that owns it. The change against the previous head `d149020a` is 11 files, +247/-295. The hand-over is still per thread, and that is deliberate: the console list proxy is in the Xbox-ABI shim layer and the queue that submits is in the COM layer, `ID3D12CommandQueue::ExecuteCommandLists` cannot carry the records in its signature, and the proxy cannot call into the COM layer because about twenty test binaries compile `runtime/shims/d3d12_xs_device.cpp` on its own (`xs_proxy_mock_test`, `root_sig_test`, the `d3d12_*_test` targets). One defect found while reshaping this and fixed: the batches were pushed by the submitting thread and popped by the completion thread with no lock. They are under one now. ### The hand-over must not need a TLS guard The hand-over's buffer is reached through a constant-initialized `thread_local` pointer, and the vector behind it is made on first use. A thread_local that needs a dynamic initializer or a C++ destructor is not usable in this tree: the runtime runs with "zero `_Init_thread_header` TLS guards or C++ thread_local destructors" (`runtime/shims/com_shim.cpp`), and every other thread_local in the tree is a plain POD for that reason - the bool in the xmem shim, the bool in the startup trace, the POD array in the PE loader. The title's own threads reach the CRT's `_register_thread_local_exe_atexit_callback` on their way out, and with a dynamically initialized thread_local in the process that path terminates the process: @DesertGamer measured `0xC0000409` at startup on the retail package, with the stack `abort <- terminate <- register_thread_local_exe_atexit_callback <- game_thread`, and their constant-initialized pointer experiment does not abort. The earlier heads aborted for the same reason: their staged records were a `static thread_local` with a `std::vector` inside, one layer down in `runtime/src/xs_value_writes.h`. ### What I tested - `xs_value_writes_test`: `the console's value-write slots record and apply their writes`, exit 0 (built with the MinGW clang and run here). - `runtime/src/vulkan_backend.h` compiles on its own (`clang++ -fsyntax-only`, llvm-mingw 20261117), and `runtime/shims/xmem.cpp` is syntax-clean with the change. - `runtime/shims/d3d12_xs_device.cpp`: syntax-only compile reports two errors, both pre-existing and environmental: `ID3D12GraphicsCommandList8` is not in this machine's MinGW `d3d12.h`. - `python -I scripts/check_no_game_data.py` over all 12 changed files: exit 0, no output. - `ctest --test-dir runtime/build -C Release`: 71 of 72 pass, 2 skipped (`shader_library_corpus`, `vk_sync_validation` - they need game data or a GPU). The one failure is `vk_queue_query_sync`, a known flake: on the **pristine** upstream tree at the same commit it fails 2 of 5 direct runs, on this tree 3 of 8. It is not caused by this change. Hardware: Windows 11 x64 (10.0.29712), Python 3.13, llvm-mingw 20261117. No game files, no GPU, no network. ### Not verified here - **The full Windows build was never run.** `runtime/shims/d3d12_com.cpp` and `runtime/shims/d3d12_vulkan_device.cpp` are not compile-checked as whole files: they need the SDK `d3d12.h` and the generated `d3d12_stubs.h`, and the MinGW header is older and structurally different, so the repository stub generator cannot run on it. **The CI build with MSVC and the Windows SDK is still required.** - No GPU and no game: the fence-dispatcher callback, the arena mapping, the xmem page write and the real title counter were never exercised. The CPU test models them with a byte array. - `xs_proxy_mock_test` is Windows-only and was not run. The mock infrastructure is unchanged, but the mock queue and list proxies now carry a plain vector of records. ### Gaps I would like a ruling on 1. **Slot 71 flags are not measured.** Only slot 72 flags 1 and 2 are known to mean GPU / system timestamp. The port writes the slot 71 value verbatim; if the title uses slot 71 with flags 1 or 2 expecting a timestamp, it gets the value instead. 2. **The GPU timestamp needs calibrated timestamps.** `gpu_timestamp()` uses the DEVICE domain of `VK_EXT/KHR_calibrated_timestamps`, the same clock `GetClockCalibration` answers with. On a device without it the function returns 0, the write is skipped, and **the counter this item is about would still not advance**. Flag 2 (system clock, QPC) and flag 0 (the value) work everywhere. This is the largest functional gap. 3. **It is a CPU write, not a GPU write.** On the console the GPU writes the value at the bottom of the pipe. Here the CPU writes it after the submission completed, so a later submission sees it, but a concurrent submission on another queue may see it earlier or later than on the console. 4. **Ordering is per queue.** Two queues writing the same address race, as they do on the console; across queues the FIFO is not global. 5. **Two landing spots are refused**: a sparse resource (its memory is bound by the sparse pass) and a page the CPU may not write (a `PAGE_NOACCESS` GPU window). Such a write is dropped and reported once on stderr. 6. The console `flush` argument (the third one) is not interpreted; every write is applied after the submission. ### Attribution and licensing The argument shapes are the facts xcl measured; the slot numbers are measured on the retail title and in the shipped BVH builder (section 3.3a of the document); the deferred bottom-of-pipe write model follows VIctory. Both projects are cited for facts and for the model only, no code copied: xcl is GPL-2.0-only and VIctory is GPL-3.0-only, and the attribution is in `runtime/src/xs_value_writes.h`, in the new paragraph of `docs/d3d12_command_objects.md` and in that document section 8.1 licence note. `docs/related_projects.md` lists the projects whose licences the repository tracks as a whole. I did not add xcl or VIctory there, because that file reads like a project-level policy; **if the maintainer wants them listed, that is a one-paragraph follow-up**. ### Coordination This is in `runtime/shims/d3d12_xs_device.cpp`, the same file as the RT-XS-LIST-X-IID work. @fiestorra said their piece is `proxy_create_command_list_x` and ours is `list_slot` / `list_query_interface` and the queue unwrap path, and that they will keep the `wrap_list` signature as it is; this pull request does not change it. AI-assisted: yes. ### Ordering: a later submission can read before the host write lands sodove's Windows review (RTX 5070 Ti, Khronos validation 1.4.369) reproduced this in a test-only extension of the synthetic xmem placement test: a CPU fence held one queue while it received a list created through `CreateCommandListX` with one 32-bit and one 64-bit value write, followed by a second submission copying the same private buffer to readback. The writes stayed blocked until the fence was released and both eventually landed in CPU-visible memory, but **the following GPU copy saw 0 of the 2 new values in 14 of 15 runs**. The progress callback orders the CPU writes with each other; later GPU work can still run before the callback publishes them. What this pull request gives is therefore: - the value writes are published into the title's memory after the submission that recorded them has completed on the GPU, and - they are ordered with each other. It does not give a later submission a guarantee that it observes them. A consumer that reads the same memory in a following submission needs its own synchronisation. That is stated here rather than left implicit. ### The xmem shim stays out of the D3D12 library The D3D12 layer reaches the title's memory through `rt::xmem::write_title_bytes`, which lives in the xmem shim. Calling it directly from `d3d12_vulkan_device.cpp` put the shim in the `gta6rt_d3d12_com` library's dependency set, and every consumer of that library that does not compile the shim itself failed to link (LNK2019/LNK1120, reported by sodove). The write now goes through a pointer the shim registers - `rt::xmem::title_write_fn` in `runtime/shims/xmem.h` - so the library keeps its own dependencies and a process without the shim keeps the console's value writes dropped, the way they were before. ### The slot numbers: measured, and corrected The two value-write calls arrive at console list slots **71 and 72**, not 69 and 70. Three independent readings agree: - The retail title's own trace, on two machines (@DadaCap's RTX 5080 and @DesertGamer's RTX 5070, native Windows 11): list slot 71 carries a title address and a value, slot 72 a title address and the flags word, slot 74 the wait's arguments, and **slot 69 is never called**. - `docs/d3d12_command_objects.md` section 3.3a, which reads the shipped `XboxBvhBuilder.dll`: `+0x238` (slot 71) is a 32-bit value write and `+0x248` (slot 73) is a masked wait. That is the same numbering - and it already contradicted the four rows this pull request first added. - The old numbers are not merely different: with 69/70 the port recorded slot 70's call, whose first argument is `1` and not an address, as a 64-bit write at address 1 (the sink refuses it unless the arena is mapped at that moment), and slot 69 was never called, so no 32-bit value was ever written. So the two constants in `runtime/src/xs_value_writes.h` now name the measured slots, the four rows of the documented table move with them (71 and 72 write, 73 and 74 wait), the comments that name them follow, and the test pins both numbers. **What is still open.** Where the numbering starts to differ is not known. The title never calls `ExecuteIndirect` - neither at 61 nor at 63 - so the shift's origin is not pinned. `ExecuteIndirect` (61), the copy at 85 and the console-only 141 may sit two slots low as well. That is an inference from the four measured rows, not a measurement, and nothing in this pull request changes them; it is filed as a separate finding. **Not verified locally.** The renumbering is two constants, the table rows, the comments and the test. This machine has no C++ toolchain, so the C++ test and the Windows build are the CI's to run. `python -I scripts/check_no_game_data.py` over all 12 changed files: exit 0, no output. ### Rebased onto current main The branch is rebased onto `main` at `d0da7dad` (the merge of #404). One conflict needed a hand: `runtime/shims/d3d12_vulkan_device.cpp` had main's `state_.context->mesh_queries = info.mesh_shader_queries;` (from #577) and this pull request's `set_up_value_writes();` on the same line, and both are kept. The change against that `main` is 12 files, +640/-8. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:38 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#663
No description provided.