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

Manually merged
github merged 6 commits from gh-pr/622/head into gh-pr/622/base 2026-11-26 09:12:23 +00:00
Owner

@⁠Mby159 on GitHub · 2026-11-24 10:03 UTC · original
Mby159:fix/rt-list-write-value → main · +564 −6 · 15 files · 6 commits · merged 2026-11-25 11:48 UTC

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.

**@⁠Mby159** on GitHub · 2026-11-24 10:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622) `Mby159:fix/rt-list-write-value` → `main` · +564 −6 · 15 files · 6 commits · merged 2026-11-25 11:48 UTC 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.
main records the console's value writes (list slots 71 and 72) as GPU completion labels since #939. This widens where a completed label may land: the GPU address arena, and the pages the title maps, which main does not track and whose title view may be PAGE_NOACCESS for the CPU. The recording stays main's; the landing and the default are ours.
The four rows of the measured console list slots, with the slot numbers the retail title's trace gives and the attribution of the call shapes and the write model.
Conflicts:
- runtime/README.md: #1723's LEONIDA_GPU_LABELS row (opt-in, only for
  lists the list values do not track). The rows #622 changed are
  brought in line with #1723 in the commits after this merge.
- runtime/shims/d3d12_vulkan_device.cpp: both sides. #622 tracks the
  arena for the label path; #1723 resets the arena's block tree under
  its lock and starts the arena after the null region.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1723's list values own list slots 71 to 74 of the lists they track and
hand 71/72 to the GPU-label path only for lists they do not track. This
keeps that, and keeps what #622 adds that #1723 lacks: landing a value
in the GPU address arena and on an xmem page the title's view refuses.

- LEONIDA_GPU_LABELS stays opt-in (`1`), as on main and in #1723.
- src/value_write_sink.h: one place for the two targets a host store
  cannot reach, used by both writers. The device answers for the arena
  (an address below its size that is not the title's memory, the rule
  resolve_title_memory uses); xmem registers write_title_bytes for its
  pages. Replaces #622's label-only sink and xmem's title_write_fn.
- The pump's land(): the arena is asked before any host store, so an
  arena offset is never stored to as a host address; then
  kernel_writes::store as before; then xmem's mapping when that store
  faults. Counted as writes_arena and writes_title_pages.
- The arena refuses its reserved start (null region, zero page, quad
  indices) and a write past its end, stores an aligned value in one
  access, and is unregistered when its device goes.
- xmem's write_title_bytes stores an aligned value in one access.
- The label path keeps the same order for untracked lists.

Test, no game data: xbox_list_value_fallback. A tracked list's writes to
title memory land through the host store; to a default-heap buffer's
arena offset land in the arena (read back by a GPU copy); to the arena's
reserved start are dropped; to an xmem page the title made PAGE_NOACCESS
land through xmem's mapping. LEONIDA_GPU_LABELS=1 throughout, and no
write is handed to the label path. Without the arena step it fails at
line 168, without the xmem step at line 208 (llvmpipe and the iGPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#622's rows had slots 73 and 74 as no-ops and the GPU-label path as the
only writer of 71 and 72. Under #1723 the list values record all four
for the lists they track (waits included), and LEONIDA_GPU_LABELS=1
writes 71/72 only for the others. The command-object table, the value
write paragraph, §5.5 of the console ABI notes and the README row now
say so, and name the arena and xmem fallbacks (src/value_write_sink.h).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
No conflicts. Brings #1723's final form: the README rows for 32
LEONIDA_* variables and indirect_clamp_test's ctest registration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:12:21 +00:00
github manually merged commit 6aa5f0b0d4 into gh-pr/622/base 2026-11-26 09:12:23 +00:00
Author
Owner

@⁠sodove on GitHub · 2026-11-24 10:17 UTC · original

Independent Windows verification of 927289f (MSVC 19.44 Release, RTX 5070 Ti 610.74, Khronos Vulkan validation 1.4.369). The gta6rt target builds, and the standalone value-writes test and stock xmem placement test pass.

  1. Windows Vulkan test build regression. d3d12_clear_formats_test fails to link with LNK2019/LNK1120 for rt::xmem::write_title_bytes, referenced from Device::set_up_value_writes in gta6rt_d3d12_com. That test links the D3D12 library without xmem.cpp. On the same machine, the same target builds and passes on the PR base 21625bc. The xmem placement test already links xmem.cpp and builds on the PR.
  2. A following submission can read before the host write. 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. The following GPU copy saw 0/2 new values in 14 of 15 runs and 2/2 in the other. The 12-run repeat had Vulkan validation active on every run and zero validation errors. The progress callback orders the CPU writes with each other, but later GPU work can run before the callback publishes them. Any intended guarantee for subsequent GPU consumers needs to account for that gap.

All runs used synthetic inputs. AI-assisted.

**@⁠sodove** on GitHub · 2026-11-24 10:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7128565305) Independent Windows verification of `927289f` (MSVC 19.44 Release, RTX 5070 Ti 610.74, Khronos Vulkan validation 1.4.369). The `gta6rt` target builds, and the standalone value-writes test and stock xmem placement test pass. 1. **Windows Vulkan test build regression.** `d3d12_clear_formats_test` fails to link with LNK2019/LNK1120 for `rt::xmem::write_title_bytes`, referenced from `Device::set_up_value_writes` in `gta6rt_d3d12_com`. That test links the D3D12 library without `xmem.cpp`. On the same machine, the same target builds and passes on the PR base `21625bc`. The xmem placement test already links `xmem.cpp` and builds on the PR. 2. **A following submission can read before the host write.** 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. The following GPU copy saw 0/2 new values in 14 of 15 runs and 2/2 in the other. The 12-run repeat had Vulkan validation active on every run and zero validation errors. The progress callback orders the CPU writes with each other, but later GPU work can run before the callback publishes them. Any intended guarantee for subsequent GPU consumers needs to account for that gap. All runs used synthetic inputs. AI-assisted.
Author
Owner

@⁠V6ser on GitHub · 2026-11-24 10:24 UTC · original

This can be much simpler and self-contained in the existing types. For example:

  • Keeping a small std::vector<ValueWrite> on ListProxy, rather than adding a separate log class.
  • Passing that vector directly through ExecuteCommandLists and storing it on HeldOperation or the queue.
  • Inlining timestamp resolution and memory writes in the existing Vulkan/device code.

There is no need for separate enums, queue helpers, thread-local staging state, or xs_value_writes.h. That adds indirection without isolating a distinct subsystem. I’d keep the implementation in d3d12_xs_device.cpp and vulkan_backend.h, with only the data types they share kept in the nearest existing header.

**@⁠V6ser** on GitHub · 2026-11-24 10:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7128732071) This can be much simpler and self-contained in the existing types. For example: - Keeping a small `std::vector<ValueWrite>` on `ListProxy`, rather than adding a separate log class. - Passing that vector directly through `ExecuteCommandLists` and storing it on `HeldOperation` or the queue. - Inlining timestamp resolution and memory writes in the existing Vulkan/device code. There is no need for separate enums, queue helpers, thread-local staging state, or `xs_value_writes.h`. That adds indirection without isolating a distinct subsystem. I’d keep the implementation in `d3d12_xs_device.cpp` and `vulkan_backend.h`, with only the data types they share kept in the nearest existing header.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 11:08 UTC · original

@⁠sodove your review found a real defect in the pull request, and it is fixed in d149020a (parent 927289f8).

The link error. rt::xmem::write_title_bytes was called directly from d3d12_vulkan_device.cpp, and that file is in the gta6rt_d3d12_com library. Every consumer of that library therefore had to link the xmem shim, and the ones that do not compile it themselves - d3d12_clear_formats_test among them - failed with LNK2019/LNK1120. The shim is deliberately compiled per target in this tree (the comment at runtime/CMakeLists.txt:222 says why), so it cannot simply be added to the library without pulling the export table and the vectored exception handler into every D3D12 test binary.

The write now goes through a pointer that the shim owns:

  • runtime/src/xs_value_writes.h gains leonida::title_write_fn and leonida::write_title_bytes;
  • runtime/shims/xmem.cpp registers the implementation in a static initialiser;
  • runtime/shims/d3d12_vulkan_device.cpp calls leonida::write_title_bytes and no longer includes xmem.h.

So the D3D12 library keeps its own dependencies, a process that links the shim gets the real write, and a process without it keeps the console value writes dropped, the way they were before. Verified here: the patched xmem.cpp compiles, and a program that links it and only the header sees the pointer set by the initialiser and the call go through it.

The ordering gap is real, and the pull request now says so. Your second finding - the following GPU copy saw 0 of the 2 new values in 14 of 15 runs - is a property of the design as it stands, not of the regression above: the progress callback orders the CPU writes with each other, but later GPU work can run before the callback publishes them. What this pull request gives is that the writes are published after the submission that recorded them has completed on the GPU, and that 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. The pull request body now states that instead of leaving it implicit.

Could you re-run the Windows build and the value-writes test on d149020a? The gta6rt target, the standalone value-writes test and the stock xmem placement test are what I would like to see green on the new head.

AI-assisted (MiniMax Code).

**@⁠Mby159** on GitHub · 2026-11-24 11:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7129703330) @⁠sodove your review found a real defect in the pull request, and it is fixed in `d149020a` (parent `927289f8`). **The link error.** `rt::xmem::write_title_bytes` was called directly from `d3d12_vulkan_device.cpp`, and that file is in the `gta6rt_d3d12_com` library. Every consumer of that library therefore had to link the xmem shim, and the ones that do not compile it themselves - `d3d12_clear_formats_test` among them - failed with LNK2019/LNK1120. The shim is deliberately compiled per target in this tree (the comment at `runtime/CMakeLists.txt:222` says why), so it cannot simply be added to the library without pulling the export table and the vectored exception handler into every D3D12 test binary. The write now goes through a pointer that the shim owns: - `runtime/src/xs_value_writes.h` gains `leonida::title_write_fn` and `leonida::write_title_bytes`; - `runtime/shims/xmem.cpp` registers the implementation in a static initialiser; - `runtime/shims/d3d12_vulkan_device.cpp` calls `leonida::write_title_bytes` and no longer includes `xmem.h`. So the D3D12 library keeps its own dependencies, a process that links the shim gets the real write, and a process without it keeps the console value writes dropped, the way they were before. Verified here: the patched `xmem.cpp` compiles, and a program that links it and only the header sees the pointer set by the initialiser and the call go through it. **The ordering gap is real, and the pull request now says so.** Your second finding - the following GPU copy saw 0 of the 2 new values in 14 of 15 runs - is a property of the design as it stands, not of the regression above: the progress callback orders the CPU writes with each other, but later GPU work can run before the callback publishes them. What this pull request gives is that the writes are published after the submission that recorded them has completed on the GPU, and that 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. The pull request body now states that instead of leaving it implicit. Could you re-run the Windows build and the value-writes test on `d149020a`? The `gta6rt` target, the standalone value-writes test and the stock xmem placement test are what I would like to see green on the new head. AI-assisted (MiniMax Code).
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 11:20 UTC · original

Independent run on the retail package (Windows 11, RTX 5070, Visual Studio 2026 toolchain), #622 at d149020ab merged alone on main 21625bca8, gta6rt --run with --trace-d3d12, one build per tree:

  • main alone: 13 D3D12 calls, then the title's int3 (exit 3).
  • main + #622: the host process ends with 0xC0000409 (abort() inside ucrtbase) during startup, after the title's fifth XMemVirtualAlloc and before any D3D12 call. There is no [rt] process: the game called abort() line, so it is not the title's own abort. Same exit with and without LEONIDA_D3D12=vulkan.
  • It also fails on the earlier head 927289f87 and with #601 + #417 underneath. The same stack without #622 (#601, #417, #387, #546, #360, #207, #602) reaches 1,639 calls.
    Not known: which host code calls abort(). No debugger here, and the startup trace is buffered, so its last event is not the crash point. The unit tests of this PR were not run on my side. AI-assisted.
**@⁠DesertGamer** on GitHub · 2026-11-24 11:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7129965047) Independent run on the retail package (Windows 11, RTX 5070, Visual Studio 2026 toolchain), #622 at d149020ab merged alone on main 21625bca8, `gta6rt --run` with `--trace-d3d12`, one build per tree: - main alone: 13 D3D12 calls, then the title's int3 (exit 3). - main + #622: the host process ends with 0xC0000409 (abort() inside ucrtbase) during startup, after the title's fifth XMemVirtualAlloc and before any D3D12 call. There is no `[rt] process: the game called abort()` line, so it is not the title's own abort. Same exit with and without `LEONIDA_D3D12=vulkan`. - It also fails on the earlier head 927289f87 and with #601 + #417 underneath. The same stack without #622 (#601, #417, #387, #546, #360, #207, #602) reaches 1,639 calls. Not known: which host code calls abort(). No debugger here, and the startup trace is buffered, so its last event is not the crash point. The unit tests of this PR were not run on my side. AI-assisted.
Author
Owner

@⁠sodove on GitHub · 2026-11-24 11:20 UTC · original

@⁠Mby159 Verified exact head d149020a on Windows 11, MSVC 19.44 Release, RTX 5070 Ti (610.74) and Khronos Vulkan validation 1.4.369.

  • gta6rt, xs_value_writes_test, d3d12_xmem_placed_test, and the previously failing d3d12_clear_formats_test all build and link. All three CTests pass. The format checks match WARP 251/251, and both Vulkan tests run with zero validation errors.
  • I also rechecked the shim registration through the Xbox proxy with a temporary synthetic xmem fixture. The 32-bit and 64-bit writes stayed held behind an unsignaled queue fence. Both landed when it was released, and a GPU copy submitted after observing the writes matched the CPU buffer. Five runs passed with Vulkan validation active and zero validation errors.

AI-assisted, synthetic inputs only.

**@⁠sodove** on GitHub · 2026-11-24 11:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7129974004) @⁠Mby159 Verified exact head `d149020a` on Windows 11, MSVC 19.44 Release, RTX 5070 Ti (610.74) and Khronos Vulkan validation 1.4.369. - `gta6rt`, `xs_value_writes_test`, `d3d12_xmem_placed_test`, and the previously failing `d3d12_clear_formats_test` all build and link. All three CTests pass. The format checks match WARP 251/251, and both Vulkan tests run with zero validation errors. - I also rechecked the shim registration through the Xbox proxy with a temporary synthetic xmem fixture. The 32-bit and 64-bit writes stayed held behind an unsignaled queue fence. Both landed when it was released, and a GPU copy submitted after observing the writes matched the CPU buffer. Five runs passed with Vulkan validation active and zero validation errors. AI-assisted, synthetic inputs only.
Author
Owner

@⁠trigger337 on GitHub · 2026-11-24 11:29 UTC · original

Cross-check on a second machine (Linux CachyOS x86_64, Wine 11.0 / Proton, AMD Radeon RX 6900 XT / RADV Navi 21, retail package 1.0.2.1):

  • Cross-compiled gta6rt.exe via clang-cl (cmake/clang-cl-xwin.cmake) on main commit 21625bca8 and on main + #622 (d149020ab):
    • main alone: exited with code 3 (int 3 soft assert at game_scarlett_master.exe+0x5925915), 0 [d3d12-trace] calls, no host abort.
    • main + #622 alone: exited with code 3 (matching main), 0 [d3d12-trace] calls, 0 host aborts (no 0xC0000409 crash).
  • Native Linux test: xs_value_writes_test built and passed cleanly (the console's value-write slots record, order and apply their writes).
  • Clean-room check: python3 -I scripts/check_no_game_data.py clean on all modified files.

The 0xC0000409 abort appears specific to the Windows 11 / VS 2026 ucrtbase environment. Under Wine/Linux, #622 behaves identically to main and does not trigger an abort.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 11:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130171617) Cross-check on a second machine (Linux CachyOS x86_64, Wine 11.0 / Proton, AMD Radeon RX 6900 XT / RADV Navi 21, retail package 1.0.2.1): * Cross-compiled `gta6rt.exe` via `clang-cl` (`cmake/clang-cl-xwin.cmake`) on `main` commit `21625bca8` and on `main + #622` (`d149020ab`): * **main alone**: exited with code 3 (`int 3` soft assert at `game_scarlett_master.exe+0x5925915`), 0 `[d3d12-trace]` calls, no host abort. * **main + #622 alone**: exited with code 3 (matching `main`), 0 `[d3d12-trace]` calls, 0 host aborts (no `0xC0000409` crash). * Native Linux test: `xs_value_writes_test` built and passed cleanly (`the console's value-write slots record, order and apply their writes`). * Clean-room check: `python3 -I scripts/check_no_game_data.py` clean on all modified files. The `0xC0000409` abort appears specific to the Windows 11 / VS 2026 ucrtbase environment. Under Wine/Linux, `#622` behaves identically to `main` and does not trigger an abort. agent: yes AI-assisted: yes
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 11:36 UTC · original

@⁠V6ser your review was right about most of it, and I have taken it. The value-write path is smaller now: 9f25a4ce (parent d149020a), 11 files, +247/-295.

What is gone:

  • the ValueWriteLog class: the list proxy keeps a plain std::vector<ValueWrite>;
  • the ValueWriteKind enum: the flags are read where the write is applied;
  • the ValueWriteQueue helper: the ordering by submission is the Vulkan queue's own (a deque and a lock in runtime/src/vulkan_backend.h);
  • the thread-local staging state in the shared header: the hand-over is now three lines of state in runtime/shims/d3d12_xs_device.cpp, next to the proxy that fills it.

runtime/src/xs_value_writes.h is the record and the function that applies a batch (190 lines shorter), and the xmem write the D3D12 layer needs moved to runtime/shims/xmem.h, next to the shim that owns it. The implementation is in runtime/shims/d3d12_xs_device.cpp, runtime/shims/d3d12_com.cpp and runtime/src/vulkan_backend.h.

Two things I did not do, and why:

  • The hand-over is still a hand-over, and still per thread. 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). So the records wait in the proxy for the call it forwards and the COM queue takes them during that call.
  • The shared header stayed. The record type is shared by three translation units in two layers, and the repository keeps pure logic in a small header of its own so that the CPU job can check it without a GPU (src/buffer_va_index.h, src/statistics_sum.h). What is in the header now is the data and the one function that uses it.

The tests follow the code: runtime/test/xs_value_writes_test.cpp keeps the record, the flag rule and the apply function on the CPU (the Linux job), and the new runtime/test/xs_value_writes_handover_test.cpp covers the hand-over (the Windows job).

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.

@⁠sodove the head moved while you were claiming the re-run - it is 9f25a4ce now, not d149020a. The link fix and the ordering behaviour are unchanged; the difference is the shape above, so please run against 9f25a4ce.

AI-assisted (MiniMax Code).

**@⁠Mby159** on GitHub · 2026-11-24 11:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130322555) @⁠V6ser your review was right about most of it, and I have taken it. The value-write path is smaller now: `9f25a4ce` (parent `d149020a`), 11 files, +247/-295. What is gone: - the `ValueWriteLog` class: the list proxy keeps a plain `std::vector<ValueWrite>`; - the `ValueWriteKind` enum: the flags are read where the write is applied; - the `ValueWriteQueue` helper: the ordering by submission is the Vulkan queue's own (a deque and a lock in `runtime/src/vulkan_backend.h`); - the thread-local staging state in the shared header: the hand-over is now three lines of state in `runtime/shims/d3d12_xs_device.cpp`, next to the proxy that fills it. `runtime/src/xs_value_writes.h` is the record and the function that applies a batch (190 lines shorter), and the xmem write the D3D12 layer needs moved to `runtime/shims/xmem.h`, next to the shim that owns it. The implementation is in `runtime/shims/d3d12_xs_device.cpp`, `runtime/shims/d3d12_com.cpp` and `runtime/src/vulkan_backend.h`. Two things I did not do, and why: - **The hand-over is still a hand-over, and still per thread.** 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). So the records wait in the proxy for the call it forwards and the COM queue takes them during that call. - **The shared header stayed.** The record type is shared by three translation units in two layers, and the repository keeps pure logic in a small header of its own so that the CPU job can check it without a GPU (`src/buffer_va_index.h`, `src/statistics_sum.h`). What is in the header now is the data and the one function that uses it. The tests follow the code: `runtime/test/xs_value_writes_test.cpp` keeps the record, the flag rule and the apply function on the CPU (the Linux job), and the new `runtime/test/xs_value_writes_handover_test.cpp` covers the hand-over (the Windows job). 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. @⁠sodove the head moved while you were claiming the re-run - it is `9f25a4ce` now, not `d149020a`. The link fix and the ordering behaviour are unchanged; the difference is the shape above, so please run against `9f25a4ce`. AI-assisted (MiniMax Code).
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 11:38 UTC · original

Follow-up to my startup-abort report above: the abort now has a stack and a condition that removes it.

Stack at the abort (main 21625bca8 + #622 d149020ab, RTX 5070, Windows 11 26200, VS 2026 toolchain; captured with a small debugger using gta6rt.pdb, so the frame walk is a scan for return addresses, not unwind data):
abort <- terminate <- register_thread_local_exe_atexit_callback (host CRT) <- rt::process game_thread

What in the PR is involved: static thread_local StagedValueWrites staged in runtime/src/xs_value_writes.h (line 185 at d149020ab). The type has a non-trivial destructor, and main has no thread_local with one in runtime/src or runtime/shims. The title imports _register_thread_local_exe_atexit_callback, and the header comment of runtime/shims/process.cpp says that callback is not covered yet and still reaches the host CRT.

Two experiments, each one changed line in that function, nothing else, same machine, --run with --trace-d3d12 and LEONIDA_D3D12=vulkan:

  • static StagedValueWrites staged; (no thread_local): no abort, 13 D3D12 calls, ends on the title's int3 (0x80000003), like main.
  • static thread_local StagedValueWrites* staged allocated on first use (trivially destructible): the same result. xs_value_writes_test passes in both.

So on this machine the abort needs a thread_local with a destructor in host code. Not shown: why terminate() is reached. My guess is a second registration of that callback from the same CRT, but I did not verify that against the UCRT source. trigger337's Wine run above sees no abort, which fits a Windows-UCRT-specific cause.

Not checked: other thread_local objects with destructors elsewhere (none found by grep in main), and whether keeping the thread_local but registering it differently also avoids the abort. I am not proposing a patch; how the staging buffer should live is your call.

AI-assisted: yes

**@⁠DesertGamer** on GitHub · 2026-11-24 11:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130356579) Follow-up to my startup-abort report above: the abort now has a stack and a condition that removes it. Stack at the abort (main 21625bca8 + #622 d149020ab, RTX 5070, Windows 11 26200, VS 2026 toolchain; captured with a small debugger using gta6rt.pdb, so the frame walk is a scan for return addresses, not unwind data): abort <- terminate <- register_thread_local_exe_atexit_callback (host CRT) <- rt::process game_thread What in the PR is involved: `static thread_local StagedValueWrites staged` in runtime/src/xs_value_writes.h (line 185 at d149020ab). The type has a non-trivial destructor, and main has no thread_local with one in runtime/src or runtime/shims. The title imports `_register_thread_local_exe_atexit_callback`, and the header comment of runtime/shims/process.cpp says that callback is not covered yet and still reaches the host CRT. Two experiments, each one changed line in that function, nothing else, same machine, `--run` with `--trace-d3d12` and `LEONIDA_D3D12=vulkan`: - `static StagedValueWrites staged;` (no thread_local): no abort, 13 D3D12 calls, ends on the title's int3 (0x80000003), like main. - `static thread_local StagedValueWrites* staged` allocated on first use (trivially destructible): the same result. xs_value_writes_test passes in both. So on this machine the abort needs a thread_local with a destructor in host code. Not shown: why terminate() is reached. My guess is a second registration of that callback from the same CRT, but I did not verify that against the UCRT source. trigger337's Wine run above sees no abort, which fits a Windows-UCRT-specific cause. Not checked: other thread_local objects with destructors elsewhere (none found by grep in main), and whether keeping the thread_local but registering it differently also avoids the abort. I am not proposing a patch; how the staging buffer should live is your call. AI-assisted: yes
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 11:43 UTC · original

@⁠DesertGamer thanks - that is worth having on an open pull request, and @⁠trigger337's Wine cross-check narrows it down already.

What the abort is not.

  • It is not the link fix: it happens on 927289f87 too, which is before it.
  • It is not the build: this repository's Windows job builds and runs the CTests on every push of this branch, and @⁠sodove built and ran gta6rt, xs_value_writes_test, d3d12_xmem_placed_test and d3d12_clear_formats_test on d149020a on an RTX 5070 Ti under Vulkan validation (3/3 pass, zero validation errors).
  • It does not reproduce away from Windows: @⁠trigger337 cross-checked main + #622 on Wine 11.0 / Proton on an RX 6900 XT and got the same exit 3 as main, with no host abort.

What this pull request runs before the title's first D3D12 call: nothing. The recording happens when the title calls list slots 69 and 70, the hand-over happens inside ExecuteCommandLists, and the write into the title's memory happens after a submission has completed on the GPU. The only thing added at load time is the registration of the xmem write pointer in runtime/shims/xmem.cpp - a pointer assignment in a static initialiser. The device's setup (set_up_value_writes) runs when the D3D12 device is created, which is the title's first D3D12 call; the trace is buffered and flushed at exit, so "zero [d3d12-trace] lines" does not place the abort before that call.

The cheapest split is one line. In runtime/shims/d3d12_vulkan_device.cpp, make the sink in set_up_value_writes() return false straight away: the value writes are then recorded and dropped and no xmem page is ever written. If the abort is still there, it is not in the write path; if it is gone, it is in rt::xmem::write_title_bytes or in what it commits.

@⁠naorleizer, your second machine would settle that. The three numbers you asked for - the real exit code, the number of [d3d12-trace] lines and whether the "game called abort()" line appears - for main, main + #622, and main + #622 with the sink disabled.

The head moved to 9f25a4ce in the meantime (a reshaping of the same code, no change on the startup path), so please use that one.

I have no debugger and no game files, so I cannot reproduce it here.

AI-assisted (MiniMax Code).

**@⁠Mby159** on GitHub · 2026-11-24 11:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130472673) @⁠DesertGamer thanks - that is worth having on an open pull request, and @⁠trigger337's Wine cross-check narrows it down already. **What the abort is not.** - It is not the link fix: it happens on `927289f87` too, which is before it. - It is not the build: this repository's Windows job builds and runs the CTests on every push of this branch, and @⁠sodove built and ran `gta6rt`, `xs_value_writes_test`, `d3d12_xmem_placed_test` and `d3d12_clear_formats_test` on `d149020a` on an RTX 5070 Ti under Vulkan validation (3/3 pass, zero validation errors). - It does not reproduce away from Windows: @⁠trigger337 cross-checked `main + #622` on Wine 11.0 / Proton on an RX 6900 XT and got the same exit 3 as `main`, with no host abort. **What this pull request runs before the title's first D3D12 call:** nothing. The recording happens when the title calls list slots 69 and 70, the hand-over happens inside ExecuteCommandLists, and the write into the title's memory happens after a submission has completed on the GPU. The only thing added at load time is the registration of the xmem write pointer in `runtime/shims/xmem.cpp` - a pointer assignment in a static initialiser. The device's setup (`set_up_value_writes`) runs when the D3D12 device is created, which is the title's first D3D12 call; the trace is buffered and flushed at exit, so "zero `[d3d12-trace]` lines" does not place the abort before that call. **The cheapest split is one line.** In `runtime/shims/d3d12_vulkan_device.cpp`, make the sink in `set_up_value_writes()` return false straight away: the value writes are then recorded and dropped and no xmem page is ever written. If the abort is still there, it is not in the write path; if it is gone, it is in `rt::xmem::write_title_bytes` or in what it commits. @⁠naorleizer, your second machine would settle that. The three numbers you asked for - the real exit code, the number of `[d3d12-trace]` lines and whether the "game called abort()" line appears - for `main`, `main + #622`, and `main + #622` with the sink disabled. The head moved to `9f25a4ce` in the meantime (a reshaping of the same code, no change on the startup path), so please use that one. I have no debugger and no game files, so I cannot reproduce it here. AI-assisted (MiniMax Code).
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 11:44 UTC · original

@⁠Mby159 follow-up on the thread_local finding above, now on 9f25a4cea. It still aborts at startup (0xC0000409, 0 D3D12 calls, same stack: abort <- terminate <- register_thread_local_exe_atexit_callback <- game_thread); the remaining thread_local is staged_value_writes (a std::vector) at runtime/shims/d3d12_xs_device.cpp:2467.

I also have to correct my earlier wording ("needs a thread_local with a destructor"). Two one-line experiments on this head, same machine and command as before:

  • thread_local std::vector<ValueWrite>& staged = *new std::vector<ValueWrite>; (no destructor, dynamic initializer): still aborts.
  • thread_local std::vector<ValueWrite>* ptr = nullptr; (constant initializer), vector created on first use: no abort, 13 D3D12 calls, ends on the title's int3 like main.
    So what separates them is a dynamically initialized thread_local, not the destructor; a constant-initialized one is fine. runtime/shims/com_shim.cpp already says the same ("zero _Init_thread_header TLS guards or C++ thread_local destructors"). Why terminate() is reached is still unverified.

Not checked: the host's ctest, other threads than the game thread, and whether the pointer variant is acceptable for your hand-over.

AI-assisted: yes

**@⁠DesertGamer** on GitHub · 2026-11-24 11:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130479735) @⁠Mby159 follow-up on the thread_local finding above, now on 9f25a4cea. It still aborts at startup (0xC0000409, 0 D3D12 calls, same stack: abort <- terminate <- register_thread_local_exe_atexit_callback <- game_thread); the remaining thread_local is `staged_value_writes` (a std::vector) at runtime/shims/d3d12_xs_device.cpp:2467. I also have to correct my earlier wording ("needs a thread_local with a destructor"). Two one-line experiments on this head, same machine and command as before: - `thread_local std::vector<ValueWrite>& staged = *new std::vector<ValueWrite>;` (no destructor, dynamic initializer): still aborts. - `thread_local std::vector<ValueWrite>* ptr = nullptr;` (constant initializer), vector created on first use: no abort, 13 D3D12 calls, ends on the title's int3 like main. So what separates them is a dynamically initialized thread_local, not the destructor; a constant-initialized one is fine. runtime/shims/com_shim.cpp already says the same ("zero _Init_thread_header TLS guards or C++ thread_local destructors"). Why terminate() is reached is still unverified. Not checked: the host's ctest, other threads than the game thread, and whether the pointer variant is acceptable for your hand-over. AI-assisted: yes
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 11:45 UTC · original

@⁠Mby159 thanks for the split, my 11:46 comment above answers part of it, and it was written after yours.

On "nothing runs before the title's first D3D12 call": the trace being buffered is right, so I do not rely on the "0 calls" count; the stack alone (abort <- terminate <- register_thread_local_exe_atexit_callback <- game_thread) puts it in the host's CRT thread-local registration, not in the write path.

Your one-line split, as far as I can tell it from what I measured: with thread_local std::vector<ValueWrite>* ptr = nullptr (constant initializer) the device is created (so set_up_value_writes has run and the sink is set up), the run goes on to D3D12 call 13 and ends on the title's int3 like main, no abort. So the abort is not in the setup of the sink. What that run does not exercise is the write path itself (slots 69/70, the hand-over and the xmem write): the title stops at call 13, before it. I did not run the sink-disabled variant you describe.

So I would read it as: not the write path, and the dynamic thread_local initializer in d3d12_xs_device.cpp is what the host aborts on; the pointer variant in my 11:46 comment is the smallest change I know that avoids it.

AI-assisted: yes

**@⁠DesertGamer** on GitHub · 2026-11-24 11:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130505885) @⁠Mby159 thanks for the split, my 11:46 comment above answers part of it, and it was written after yours. On "nothing runs before the title's first D3D12 call": the trace being buffered is right, so I do not rely on the "0 calls" count; the stack alone (abort <- terminate <- register_thread_local_exe_atexit_callback <- game_thread) puts it in the host's CRT thread-local registration, not in the write path. Your one-line split, as far as I can tell it from what I measured: with `thread_local std::vector<ValueWrite>* ptr = nullptr` (constant initializer) the device is created (so `set_up_value_writes` has run and the sink is set up), the run goes on to D3D12 call 13 and ends on the title's int3 like main, no abort. So the abort is not in the setup of the sink. What that run does not exercise is the write path itself (slots 69/70, the hand-over and the xmem write): the title stops at call 13, before it. I did not run the sink-disabled variant you describe. So I would read it as: not the write path, and the dynamic thread_local initializer in d3d12_xs_device.cpp is what the host aborts on; the pointer variant in my 11:46 comment is the smallest change I know that avoids it. AI-assisted: yes
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 11:47 UTC · original

@⁠DesertGamer that is the missing piece, and your second experiment settles it: the trigger is a dynamically initialized thread_local, not the destructor.

runtime/shims/com_shim.cpp already says the runtime runs with "zero _Init_thread_header TLS guards or C++ thread_local destructors", and every other thread_local in the tree is a plain POD for that reason - thread_local bool busy in the xmem shim, thread_local bool in_handler in the startup trace, the POD array in the PE loader. The staged records vector broke that rule and I did not follow it.

Fixed in b51912e7 (parent 9f25a4ce): the records now live behind a constant-initialized thread_local std::vector<ValueWrite>*, and the vector behind it is made on first use - exactly the shape your second experiment used. The buffer belongs to the thread and is not destroyed, because a thread_local cannot own a C++ destructor here: one vector per submitting thread, holding the records of the largest submission that thread made.

That also explains the earlier heads. 927289f87 and d149020a had the same thing one layer down, in runtime/src/xs_value_writes.h (static thread_local StagedValueWrites staged, with a std::vector inside), so they aborted for the same reason and not for the link fix. Your finding about the link fix and the ordering gap still stands on its own.

What I would still like:

  • a re-run of the retail package on b51912e7, with the same command and the same three numbers (the real exit code, the number of [d3d12-trace] lines, whether the "game called abort()" line appears). If the abort is gone, the thread_local was it.
  • your note that the host's ctest was not run on that head. Our CI runs it on every push of the branch, and @⁠sodove built and ran gta6rt, xs_value_writes_test, d3d12_xmem_placed_test and d3d12_clear_formats_test on d149020a.

The one thing I cannot do from here is verify it on the retail package: no game files on this machine, and the clean-room rules keep them off it. The hand-over itself has a CPU test of its own now (runtime/test/xs_value_writes_handover_test.cpp), but only the retail run can show the abort is gone.

AI-assisted (MiniMax Code).

**@⁠Mby159** on GitHub · 2026-11-24 11:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130555553) @⁠DesertGamer that is the missing piece, and your second experiment settles it: the trigger is a **dynamically initialized** thread_local, not the destructor. `runtime/shims/com_shim.cpp` already says the runtime runs with "zero `_Init_thread_header` TLS guards or C++ thread_local destructors", and every other thread_local in the tree is a plain POD for that reason - `thread_local bool busy` in the xmem shim, `thread_local bool in_handler` in the startup trace, the POD array in the PE loader. The staged records vector broke that rule and I did not follow it. Fixed in `b51912e7` (parent `9f25a4ce`): the records now live behind a constant-initialized `thread_local std::vector<ValueWrite>*`, and the vector behind it is made on first use - exactly the shape your second experiment used. The buffer belongs to the thread and is not destroyed, because a thread_local cannot own a C++ destructor here: one vector per submitting thread, holding the records of the largest submission that thread made. That also explains the earlier heads. `927289f87` and `d149020a` had the same thing one layer down, in `runtime/src/xs_value_writes.h` (`static thread_local StagedValueWrites staged`, with a `std::vector` inside), so they aborted for the same reason and not for the link fix. Your finding about the link fix and the ordering gap still stands on its own. What I would still like: - **a re-run of the retail package on `b51912e7`**, with the same command and the same three numbers (the real exit code, the number of `[d3d12-trace]` lines, whether the "game called abort()" line appears). If the abort is gone, the thread_local was it. - your note that the host's ctest was not run on that head. Our CI runs it on every push of the branch, and @⁠sodove built and ran `gta6rt`, `xs_value_writes_test`, `d3d12_xmem_placed_test` and `d3d12_clear_formats_test` on `d149020a`. The one thing I cannot do from here is verify it on the retail package: no game files on this machine, and the clean-room rules keep them off it. The hand-over itself has a CPU test of its own now (`runtime/test/xs_value_writes_handover_test.cpp`), but only the retail run can show the abort is gone. AI-assisted (MiniMax Code).
Author
Owner

@⁠sodove on GitHub · 2026-11-24 11:47 UTC · original · edited 2026-11-24 11:52 UTC

Retest of the fix in b51912e7. @⁠Mby159 The early Windows process abort is gone on this machine. I retested exact PR head, its parent, and current main twice each under the same conditions described below, reversing the order for the second pass. Both runs of each build gave the same result.

Revision Windows process exit D3D12 trace lines Title abort message
Main 21625bca 0x80000003 (breakpoint) 13 absent
Parent 9f25a4ce 0xC0000409 0 absent
Fix b51912e7 0x80000003 (breakpoint) 13 absent

A synthetic positive control confirmed that the collector detects the title abort message. The fixed build reached the same stopping point observed on main, with zero successful presents. All four CTests listed below passed on exact b51912e7 as well.


@⁠Mby159 I reproduced the startup failure on a second native Windows 11 machine with VS 2022 (MSVC 19.44, Release), RTX 5070 Ti, driver 610.74. I ran each build twice with Vulkan selected, a fresh overlay per run, and networking blocked for the process.

Build D3D12 trace lines per run Windows process exit in both runs
Current main, 21625bca 13 0x80000003 (breakpoint)
Exact PR head, 9f25a4ce 0 0xC0000409
21625bca with 9f25a4ce merged 0 0xC0000409

The trace counts are the lines emitted before process exit. On the merged build, all four stock CTests passed (xs_value_writes, xs_value_writes_handover, d3d12_xmem_placed, and d3d12_clear_formats). The format test matched WARP in all 251 cases.

AI-assisted.

**@⁠sodove** on GitHub · 2026-11-24 11:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7130556419) · edited 2026-11-24 11:52 UTC **Retest of the fix in `b51912e7`.** @⁠Mby159 The early Windows process abort is gone on this machine. I retested exact PR head, its parent, and current main twice each under the same conditions described below, reversing the order for the second pass. Both runs of each build gave the same result. | Revision | Windows process exit | D3D12 trace lines | Title abort message | | --- | --- | ---: | --- | | Main `21625bca` | `0x80000003` (breakpoint) | 13 | absent | | Parent `9f25a4ce` | `0xC0000409` | 0 | absent | | Fix `b51912e7` | `0x80000003` (breakpoint) | 13 | absent | A synthetic positive control confirmed that the collector detects the title abort message. The fixed build reached the same stopping point observed on main, with zero successful presents. All four CTests listed below passed on exact `b51912e7` as well. --- @⁠Mby159 I reproduced the startup failure on a second native Windows 11 machine with VS 2022 (MSVC 19.44, Release), RTX 5070 Ti, driver 610.74. I ran each build twice with Vulkan selected, a fresh overlay per run, and networking blocked for the process. | Build | D3D12 trace lines per run | Windows process exit in both runs | | --- | ---: | --- | | Current main, `21625bca` | 13 | `0x80000003` (breakpoint) | | Exact PR head, `9f25a4ce` | 0 | `0xC0000409` | | `21625bca` with `9f25a4ce` merged | 0 | `0xC0000409` | The trace counts are the lines emitted before process exit. On the merged build, all four stock CTests passed (`xs_value_writes`, `xs_value_writes_handover`, `d3d12_xmem_placed`, and `d3d12_clear_formats`). The format test matched WARP in all 251 cases. AI-assisted.
Author
Owner

@⁠DadaCap on GitHub · 2026-11-24 12:31 UTC · original

A measurement on the retail title for this pull request (1.0.2.1, native Windows, the open boot stack): the slots look two higher than 69/70.

list slot what the title passes reads as
70 (1, pointer to the caller's stack, 0, ...), about three times a frame a count and an array, not (address, value)
71 addresses 4 bytes apart in a ring of three entries; value 0, 1, 2, ... one higher each frame, and a constant in the next dword Write32BitValueBottomOfPipeX
72 addresses 8 bytes apart in pairs, value 0, flags 1 Write64BitValueBottomOfPipeX with a GPU timestamp, begin and end
74 (one fixed address, 7, 1, 1) once a frame a wait

With 69/70 the recorded "address" is 1 and nothing the title waits on is written. With 71/72 the run went from roughly 1,000 to 330 presents a second, as if paced by the labels (not proved to be the reason).

Second: the hand-over is only on queue slot 10. The title submits through console queue slot 35 (#391), so stage_value_writes has to be called there too, or every batch is dropped. I added it in queue_execute_command_lists locally.

Could you check 70's shape against the xcl measurement? Its numbering may belong to another SDK version. AI-assisted (Claude Code).

**@⁠DadaCap** on GitHub · 2026-11-24 12:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7131556921) A measurement on the retail title for this pull request (1.0.2.1, native Windows, the open boot stack): **the slots look two higher than 69/70.** | list slot | what the title passes | reads as | |---|---|---| | 70 | `(1, pointer to the caller's stack, 0, ...)`, about three times a frame | a count and an array, not `(address, value)` | | 71 | addresses 4 bytes apart in a ring of three entries; value 0, 1, 2, ... one higher each frame, and a constant in the next dword | `Write32BitValueBottomOfPipeX` | | 72 | addresses 8 bytes apart in pairs, value 0, flags 1 | `Write64BitValueBottomOfPipeX` with a GPU timestamp, begin and end | | 74 | `(one fixed address, 7, 1, 1)` once a frame | a wait | With 69/70 the recorded "address" is 1 and nothing the title waits on is written. With 71/72 the run went from roughly 1,000 to 330 presents a second, as if paced by the labels (not proved to be the reason). Second: the hand-over is only on queue slot 10. The title submits through console queue slot 35 (#391), so `stage_value_writes` has to be called there too, or every batch is dropped. I added it in `queue_execute_command_lists` locally. Could you check 70's shape against the xcl measurement? Its numbering may belong to another SDK version. AI-assisted (Claude Code).
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 12:32 UTC · original

@⁠sodove thank you - that is the result we needed: the early process abort is gone on the retail path at b51912e7, on a second machine and with the run order reversed. Two things follow from it.

The head is final for now: b51912e7 carries the same tree as 9f25a4ce plus the constant-initialized handover buffer, so the value-write semantics you verified on d149020a (what is recorded, the flags rules, the submission order, when the writes land) are unchanged - only the shape of the handover moved.

And the cause was the one this repository already forbids: a dynamically initialized thread_local pulls in a _Init_thread_header guard, and runtime/shims/com_shim.cpp says the runtime runs with zero such guards and no C++ thread_local destructors. The buffer is now a constant-initialized thread_local std::vector<ValueWrite>*, created on first use and never destroyed, so there is no guard and no destructor to register.

If the retail package still aborts anywhere else on your machine, a stack would still help; if it does not, this closes the thread on our side.

**@⁠Mby159** on GitHub · 2026-11-24 12:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7131586341) @⁠sodove thank you - that is the result we needed: the early process abort is gone on the retail path at `b51912e7`, on a second machine and with the run order reversed. Two things follow from it. The head is final for now: `b51912e7` carries the same tree as `9f25a4ce` plus the constant-initialized handover buffer, so the value-write semantics you verified on `d149020a` (what is recorded, the flags rules, the submission order, when the writes land) are unchanged - only the shape of the handover moved. And the cause was the one this repository already forbids: a dynamically initialized `thread_local` pulls in a `_Init_thread_header` guard, and `runtime/shims/com_shim.cpp` says the runtime runs with zero such guards and no C++ `thread_local` destructors. The buffer is now a constant-initialized `thread_local std::vector<ValueWrite>*`, created on first use and never destroyed, so there is no guard and no destructor to register. If the retail package still aborts anywhere else on your machine, a stack would still help; if it does not, this closes the thread on our side.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 13:07 UTC · original

@⁠DadaCap this is the most useful measurement on this pull request, and it lines up with what our own code would do if the table's numbering is two slots low. Here is where our numbers come from, why our numbering is the same as yours, and the two facts that settle it.

Where 69/70 comes from. docs/d3d12_command_objects.md lists the console command list's methods by their index in the console list's own vtable: row 69 (+0x228) Write32BitValueBottomOfPipeX, row 70 (+0x230) Write64BitValueBottomOfPipeX, rows 71 and 72 the two waits. The page cites xcl (crates/xcl/src/hle/d3d12x/list_x.rs, GPL-2.0-only) for the shape only. runtime/src/xs_value_writes.h turns those two indices into constants, and the list proxy records the write when the console calls that slot.

Our numbering is yours. The proxy's vtable is filled entry by entry with the thunk of the console method of that index - fill_list_vtable puts list_slot<I> at entry I - so the port's trace line [rt] d3d12_xs: list slot N first call (args ...) prints the console list's method index. No offset inside the proxy could shift what you measured.

A two-slot shift predicts exactly your table. With our numbers the port records the call whose first argument is 1 - your row for slot 70 - so the recorded address is 1, and the two calls that carry the write shapes (your 71 and 72) arrive at the slots our code treats as the waits, which are no-ops, so nothing the title waits on is ever written. Your four rows are our four rows shifted by two.

What we will not do. We are not going to move the two constants on a guess: if the table is right and we moved them, the wait-shaped calls would start being recorded as writes, which is worse than recording nothing. So the head stays as it is until the numbering is settled, and this pull request is not merge-ready until it is. For the record, with the current numbers the recorded address 1 is inside the title's arena, so the port would write 4 or 8 bytes at the arena's offset 1 for each of those calls - that is not a state we want to ship either.

Two questions.

  1. Does your trace show [rt] d3d12_xs: list slot 71 first call (args ...) and list slot 72 first call (args ...) for the two write-shaped calls? If the port prints something else there - an ordinal rather than the vtable index - then the two numbering schemes differ and nothing is wrong here.
  2. In the same run, at which slot does the title's ExecuteIndirect arrive? Our mapping expects console slot 61 (console_to_pc_list_slot: 61 -> PC 59). If it arrives at 63, the whole table shifts by two above 61; if it arrives at 61, then only the rows 69-72 are wrong and the console's two extra methods sit between 62 and 69.

When we know, the change is two constants in runtime/src/xs_value_writes.h, the four rows of docs/d3d12_command_objects.md, and the two tests that name the slots.

**@⁠Mby159** on GitHub · 2026-11-24 13:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7132374396) @⁠DadaCap this is the most useful measurement on this pull request, and it lines up with what our own code would do if the table's numbering is two slots low. Here is where our numbers come from, why our numbering is the same as yours, and the two facts that settle it. **Where 69/70 comes from.** `docs/d3d12_command_objects.md` lists the console command list's methods by their index in the console list's own vtable: row 69 (`+0x228`) `Write32BitValueBottomOfPipeX`, row 70 (`+0x230`) `Write64BitValueBottomOfPipeX`, rows 71 and 72 the two waits. The page cites xcl (`crates/xcl/src/hle/d3d12x/list_x.rs`, GPL-2.0-only) for the *shape* only. `runtime/src/xs_value_writes.h` turns those two indices into constants, and the list proxy records the write when the console calls that slot. **Our numbering is yours.** The proxy's vtable is filled entry by entry with the thunk of the console method of that index - `fill_list_vtable` puts `list_slot<I>` at entry `I` - so the port's trace line `[rt] d3d12_xs: list slot N first call (args ...)` prints the console list's method index. No offset inside the proxy could shift what you measured. **A two-slot shift predicts exactly your table.** With our numbers the port records the call whose first argument is 1 - your row for slot 70 - so the recorded address is 1, and the two calls that carry the write shapes (your 71 and 72) arrive at the slots our code treats as the waits, which are no-ops, so nothing the title waits on is ever written. Your four rows are our four rows shifted by two. **What we will not do.** We are not going to move the two constants on a guess: if the table is right and we moved them, the wait-shaped calls would start being recorded as writes, which is worse than recording nothing. So the head stays as it is until the numbering is settled, and this pull request is not merge-ready until it is. For the record, with the current numbers the recorded address 1 is inside the title's arena, so the port would write 4 or 8 bytes at the arena's offset 1 for each of those calls - that is not a state we want to ship either. **Two questions.** 1. Does your trace show `[rt] d3d12_xs: list slot 71 first call (args ...)` and `list slot 72 first call (args ...)` for the two write-shaped calls? If the port prints something else there - an ordinal rather than the vtable index - then the two numbering schemes differ and nothing is wrong here. 2. In the same run, at which slot does the title's `ExecuteIndirect` arrive? Our mapping expects console slot 61 (`console_to_pc_list_slot`: 61 -> PC 59). If it arrives at 63, the whole table shifts by two above 61; if it arrives at 61, then only the rows 69-72 are wrong and the console's two extra methods sit between 62 and 69. When we know, the change is two constants in `runtime/src/xs_value_writes.h`, the four rows of `docs/d3d12_command_objects.md`, and the two tests that name the slots.
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 13:15 UTC · original

@⁠Mby159 confirmed on b51912e74 (merged onto main 21625bca8): the early abort is gone on a third machine. Windows 11, RTX 5070 (driver 617.14), Vulkan backend, own 1.0.2.1 copy, two runs of gta6rt --run with the D3D12 trace: both stop after 13 D3D12 calls with 0x80000003 (the title int3), the same as main; the previous head 9f25a4cea aborted with 0xC0000409 and 0 calls in 6 runs out of 6 here. This only covers the startup abort; the value-write path itself is not exercised before the title reaches slot 73 (it is with #142/#641/#359 in the stack). Thank you for the quick fix.

AI-assisted: yes (Claude Code, Sonnet 5.5)

**@⁠DesertGamer** on GitHub · 2026-11-24 13:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7132577785) @⁠Mby159 confirmed on `b51912e74` (merged onto `main` 21625bca8): the early abort is gone on a third machine. Windows 11, RTX 5070 (driver 617.14), Vulkan backend, own 1.0.2.1 copy, two runs of `gta6rt --run` with the D3D12 trace: both stop after 13 D3D12 calls with `0x80000003` (the title int3), the same as `main`; the previous head `9f25a4cea` aborted with `0xC0000409` and 0 calls in 6 runs out of 6 here. This only covers the startup abort; the value-write path itself is not exercised before the title reaches slot 73 (it is with #142/#641/#359 in the stack). Thank you for the quick fix. AI-assisted: yes (Claude Code, Sonnet 5.5)
Author
Owner

@⁠DadaCap on GitHub · 2026-11-24 13:19 UTC · original

@⁠Mby159 your two questions, from a run that gets further (27 s, G-buffer targets and render lists submitted):

  1. Yes, these are the port's own lines, so the number is the vtable index of the proxy (first two argument words only, addresses shortened):
list slot 70 first call (args 0x1 <caller's stack> 0x0 ...)
list slot 71 first call (args <64 KiB title block>+0x8 0x0 ...)
list slot 72 first call (args <title address> 0x0 0x0 flags 1)
list slot 74 first call (args <same 64 KiB block> 0x7 0x1 ...)
  1. ExecuteIndirect has not been called in any run: neither 61 nor 63 appears, so I cannot say where the shift starts. The console list slots the title did call so far are 0, 9, 12-14, 20-25, 32-36, 40, 44, 47, 48, 50, 52, 70-72, 74, 75, 126, 131, 132, 139, 142, 146. 50 (OMSetRenderTargets) and 52 arrive with the shapes the existing map gives them, so the shift, if it is one, is between 53 and 70.

I agree not to move the constants on one machine's word alone. @⁠DesertGamer reaches the frame loop on a second machine; a log of those four lines from there would be the independent check (slot 71 and 72 are called every frame, so no special path is needed).

**@⁠DadaCap** on GitHub · 2026-11-24 13:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7132665698) @⁠Mby159 your two questions, from a run that gets further (27 s, G-buffer targets and render lists submitted): 1. **Yes**, these are the port's own lines, so the number is the vtable index of the proxy (first two argument words only, addresses shortened): ``` list slot 70 first call (args 0x1 <caller's stack> 0x0 ...) list slot 71 first call (args <64 KiB title block>+0x8 0x0 ...) list slot 72 first call (args <title address> 0x0 0x0 flags 1) list slot 74 first call (args <same 64 KiB block> 0x7 0x1 ...) ``` 2. **ExecuteIndirect has not been called** in any run: neither 61 nor 63 appears, so I cannot say where the shift starts. The console list slots the title did call so far are 0, 9, 12-14, 20-25, 32-36, 40, 44, 47, 48, 50, 52, 70-72, 74, 75, 126, 131, 132, 139, 142, 146. 50 (OMSetRenderTargets) and 52 arrive with the shapes the existing map gives them, so the shift, if it is one, is between 53 and 70. I agree not to move the constants on one machine's word alone. @⁠DesertGamer reaches the frame loop on a second machine; a log of those four lines from there would be the independent check (slot 71 and 72 are called every frame, so no special path is needed).
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 13:21 UTC · original

@⁠DadaCap independent check from the second machine (RTX 5070, driver 617.14, native Windows 11, own 1.0.2.1 copy; stack main 21625bca8 + #142 #427 #219 #602 #387 #357 #432, so without this PR; 420 s run, 888,983 PresentX ok, see #14). The four lines, first two argument words and the shape of the rest, addresses dropped:

list slot 70 first call (args 0x1 <caller stack> 0x0 <caller stack>)
list slot 71 first call (args <64 KiB block>+0x8 0x0 0x0 0x0)
list slot 72 first call (args <title address> 0x0 0x0 <word with low dword 1>)
list slot 74 first call (args <same 64 KiB block> 0x7 0x1 <word with low dword 1>)

So the same shapes as yours: slot 70 takes a 1 and a pointer into the caller's stack (a count and an array, not an address and a value), slot 71 an address 8 bytes into the block that slot 74 is given at offset 0 together with 7, slot 72 a title address with 0 and a flags dword of 1. The list slots the title called first in this run: 0, 9, 12, 20-25, 32, 34, 36, 44, 47, 48, 50, 52, 70-72, 74, 75, 126, 131, 132, 139, 142, 146 (no 61 or 63 here either, so no ExecuteIndirect on this machine). That is two machines with the same table; I did not look at what the title does with the values.

AI-assisted: yes (Claude Code, Sonnet 5.5)

**@⁠DesertGamer** on GitHub · 2026-11-24 13:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7132706966) @⁠DadaCap independent check from the second machine (RTX 5070, driver 617.14, native Windows 11, own 1.0.2.1 copy; stack `main` 21625bca8 + #142 #427 #219 #602 #387 #357 #432, so without this PR; 420 s run, 888,983 `PresentX ok`, see https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). The four lines, first two argument words and the shape of the rest, addresses dropped: ``` list slot 70 first call (args 0x1 <caller stack> 0x0 <caller stack>) list slot 71 first call (args <64 KiB block>+0x8 0x0 0x0 0x0) list slot 72 first call (args <title address> 0x0 0x0 <word with low dword 1>) list slot 74 first call (args <same 64 KiB block> 0x7 0x1 <word with low dword 1>) ``` So the same shapes as yours: slot 70 takes a 1 and a pointer into the caller's stack (a count and an array, not an address and a value), slot 71 an address 8 bytes into the block that slot 74 is given at offset 0 together with 7, slot 72 a title address with 0 and a flags dword of 1. The list slots the title called first in this run: 0, 9, 12, 20-25, 32, 34, 36, 44, 47, 48, 50, 52, 70-72, 74, 75, 126, 131, 132, 139, 142, 146 (no 61 or 63 here either, so no ExecuteIndirect on this machine). That is two machines with the same table; I did not look at what the title does with the values. AI-assisted: yes (Claude Code, Sonnet 5.5)
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 13:43 UTC · original

Two corrections to my message above - both about how firmly I put things.

  • The heading "Our numbering is yours" was too strong. What I verified is the port's side of it: the list proxy fills vtable entry I with the thunk of the console method of index I (fill_list_vtable), so the port's own trace label is the console list's method index. Whether the numbers in your table are those labels or a count of observed calls is your side of the link - which is why it is question 1 below - but the heading stated the conclusion before the answer came back. Read the whole comparison as conditional on your numbers being the port's slot labels; if they are call ordinals, none of it applies.
  • "The port would write 4 or 8 bytes at the arena's offset 1" needs a condition. write_value_bytes writes into the arena only while the arena is mapped and the address is not a sparse VA, and refuses the write otherwise. So the bogus write happens only when the arena is mapped at that moment; otherwise the sink drops it. The point I care about is unchanged and is the one your measurement shows: the two real write calls at 71/72 are dropped, so nothing the title waits on is ever written. The address 1 is not a title address either way, and I should not have written the consequence as settled without saying what it depends on.

The two questions are unchanged, and the head stays as it is until they are answered.

**@⁠Mby159** on GitHub · 2026-11-24 13:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7133253182) Two corrections to my message above - both about how firmly I put things. - **The heading "Our numbering is yours" was too strong.** What I verified is the port's side of it: the list proxy fills vtable entry `I` with the thunk of the console method of index `I` (`fill_list_vtable`), so the port's own trace label *is* the console list's method index. Whether the numbers in your table are those labels or a count of observed calls is your side of the link - which is why it is question 1 below - but the heading stated the conclusion before the answer came back. Read the whole comparison as conditional on your numbers being the port's slot labels; if they are call ordinals, none of it applies. - **"The port would write 4 or 8 bytes at the arena's offset 1" needs a condition.** `write_value_bytes` writes into the arena only while the arena is mapped and the address is not a sparse VA, and refuses the write otherwise. So the bogus write happens only when the arena is mapped at that moment; otherwise the sink drops it. The point I care about is unchanged and is the one your measurement shows: the two real write calls at 71/72 are dropped, so nothing the title waits on is ever written. The address 1 is not a title address either way, and I should not have written the consequence as settled without saying what it depends on. The two questions are unchanged, and the head stays as it is until they are answered.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 14:06 UTC · original · edited 2026-11-24 14:15 UTC

@⁠DadaCap @⁠DesertGamer - the two questions are answered and the head has moved. The slot numbers were two low; the constants now name the measured slots.

What changed. runtime/src/xs_value_writes.h: kConsoleWrite32BitValueSlot 69 -> 71 and kConsoleWrite64BitValueSlot 70 -> 72. The four rows of the "Command list" table move with them (71 and 72 write, 73 and 74 wait), the comments that name the slots follow, and the test pins both numbers. The branch is also rebased onto main at d0da7dad.

Why 71 and 72. Three readings, and they agree:

  1. Your trace and @⁠DesertGamer's, on two machines: 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. That settles your question 1 - the number is the proxy's vtable index, so the port's label is the console's method index - and it shows the four rows this pull request had added were two low.
  2. The document's own static reading of the shipped XboxBvhBuilder.dll, which is in main and not in this pull request: docs/d3d12_command_objects.md section 3.3a reads +0x238 - slot 71 - as a 32-bit value write and +0x248 - slot 73 - as a masked wait. The same numbering, already in the repository, contradicting the rows this pull request added.
  3. The old numbering is not merely different, it is not what the title does: with 69/70 the port recorded slot 70's call - whose first argument is 1, not an address - as a 64-bit write at address 1, and slot 69 was never called, so no 32-bit value was ever written. Holding the old numbers was not a neutral safe state either.

What is still open. Your question 2 is not answerable yet - the title never calls ExecuteIndirect, so the origin of the shift 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 it; it is filed as a finding in #14.

Not verified here. 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 the 12 changed files: exit 0, no output.

**@⁠Mby159** on GitHub · 2026-11-24 14:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7133862397) · edited 2026-11-24 14:15 UTC @⁠DadaCap @⁠DesertGamer - the two questions are answered and the head has moved. The slot numbers were two low; the constants now name the measured slots. **What changed.** `runtime/src/xs_value_writes.h`: `kConsoleWrite32BitValueSlot` 69 -> 71 and `kConsoleWrite64BitValueSlot` 70 -> 72. The four rows of the "Command list" table move with them (71 and 72 write, 73 and 74 wait), the comments that name the slots follow, and the test pins both numbers. The branch is also rebased onto `main` at `d0da7dad`. **Why 71 and 72.** Three readings, and they agree: 1. Your trace and @⁠DesertGamer's, on two machines: 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**. That settles your question 1 - the number is the proxy's vtable index, so the port's label is the console's method index - and it shows the four rows this pull request had added were two low. 2. The document's own static reading of the shipped `XboxBvhBuilder.dll`, which is in `main` and not in this pull request: `docs/d3d12_command_objects.md` section 3.3a reads `+0x238` - slot 71 - as a 32-bit value write and `+0x248` - slot 73 - as a masked wait. The same numbering, already in the repository, contradicting the rows this pull request added. 3. The old numbering is not merely different, it is not what the title does: with 69/70 the port recorded slot 70's call - whose first argument is `1`, not an address - as a 64-bit write at address 1, and slot 69 was never called, so no 32-bit value was ever written. Holding the old numbers was not a neutral safe state either. **What is still open.** Your question 2 is not answerable yet - the title never calls `ExecuteIndirect`, so the origin of the shift 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 it; it is filed as a finding in #14. **Not verified here.** 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 the 12 changed files: exit 0, no output.
Author
Owner

@⁠DadaCap on GitHub · 2026-11-24 14:10 UTC · original

@⁠Mby159 thank you, 71/72 match what my stack runs with, and it now gets much further (the first-run menus render, 590 s without a crash, title 1.0.2.1, Windows 11, RTX 5080).

One thing left from my first comment: the hand-over. On the head at refs/pull/622/head stage_value_writes is called in one place (runtime/shims/d3d12_xs_device.cpp:1361), and I see no console queue slot 35 there. The retail title submits through queue slot 35 (the route in #391), so once that lands, the same staging has to be in its handler or every batch is dropped. My stack does it in queue_execute_command_lists (branch boot-prototype on my fork). It need not hold this pull request if #391 is the one to carry it; a Depends on or a note would be enough.

I have nothing that answers where the shift starts: the title still never calls ExecuteIndirect.

AI-assisted (Claude Code, Opus 5.5).

**@⁠DadaCap** on GitHub · 2026-11-24 14:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7133945607) @⁠Mby159 thank you, 71/72 match what my stack runs with, and it now gets much further (the first-run menus render, 590 s without a crash, title 1.0.2.1, Windows 11, RTX 5080). One thing left from my first comment: the hand-over. On the head at `refs/pull/622/head` `stage_value_writes` is called in one place (`runtime/shims/d3d12_xs_device.cpp:1361`), and I see no console queue slot 35 there. The retail title submits through queue slot 35 (the route in #391), so once that lands, the same staging has to be in its handler or every batch is dropped. My stack does it in `queue_execute_command_lists` (branch `boot-prototype` on my fork). It need not hold this pull request if #391 is the one to carry it; a `Depends on` or a note would be enough. I have nothing that answers where the shift starts: the title still never calls `ExecuteIndirect`. AI-assisted (Claude Code, Opus 5.5).
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 14:10 UTC · original

Recheck on the new head d496f187c (it has #359, #357 and the rest of the stack under it, so it is not main + this alone). Windows 11, RTX 5070, driver 617.14, Vulkan backend, own 1.0.2.1 copy, two runs of gta6rt --run with the D3D12 trace: no early abort (no 0xC0000409); both runs pass the 13-call point and stop after 1,639 D3D12 calls at the title's int3, game_scarlett_master.exe+0x247af2d, the same stop as main with a slot-73 answer. So the startup path of this head is clean here; I did not look at the value-write slots 71 and 72 beyond the earlier trace (#622).

AI-assisted: yes (Claude Code, Sonnet 5.5)

**@⁠DesertGamer** on GitHub · 2026-11-24 14:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7133950916) Recheck on the new head `d496f187c` (it has #359, #357 and the rest of the stack under it, so it is not `main` + this alone). Windows 11, RTX 5070, driver 617.14, Vulkan backend, own 1.0.2.1 copy, two runs of `gta6rt --run` with the D3D12 trace: no early abort (no `0xC0000409`); both runs pass the 13-call point and stop after 1,639 D3D12 calls at the title's int3, `game_scarlett_master.exe+0x247af2d`, the same stop as `main` with a slot-73 answer. So the startup path of this head is clean here; I did not look at the value-write slots 71 and 72 beyond the earlier trace (https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/622). AI-assisted: yes (Claude Code, Sonnet 5.5)
Author
Owner

@⁠Dezmonius on GitHub · 2026-11-24 15:44 UTC · original

Checked exact head d496f187c on Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, SDK 10.0.26100, Vulkan validation 1.4.369. gta6rt built. All five stock tests passed: xs_value_writes, xs_value_writes_handover, xs_proxy_mock, d3d12_xmem_placed, and queue_proxy.

I also extended the synthetic xmem placement fixture locally. A list created through Xbox device slot 73 recorded literal writes through list slots 71/72 into two aligned offsets of a slot-133 imported physical window. A fence held the queue: the two original values and the incomplete completion fence were still observable while blocked. After the CPU released the fence, the exact 32-bit (truncated from the input word) and 64-bit values appeared. A subsequent, explicitly ordered GPU copy matched the CPU window. All three runs passed under Vulkan validation.

This exercised the standard proxy queue ExecuteCommandLists route (slot 10). The title's queue slot 35 and unsynchronized later GPU consumers were not tested. No game files or retail boot. AI-assisted (Codex).

**@⁠Dezmonius** on GitHub · 2026-11-24 15:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7136530892) Checked exact head `d496f187c` on Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, SDK 10.0.26100, Vulkan validation 1.4.369. `gta6rt` built. All five stock tests passed: `xs_value_writes`, `xs_value_writes_handover`, `xs_proxy_mock`, `d3d12_xmem_placed`, and `queue_proxy`. I also extended the synthetic xmem placement fixture locally. A list created through Xbox device slot 73 recorded literal writes through list slots 71/72 into two aligned offsets of a slot-133 imported physical window. A fence held the queue: the two original values and the incomplete completion fence were still observable while blocked. After the CPU released the fence, the exact 32-bit (truncated from the input word) and 64-bit values appeared. A subsequent, explicitly ordered GPU copy matched the CPU window. All three runs passed under Vulkan validation. This exercised the standard proxy queue ExecuteCommandLists route (slot 10). The title's queue slot 35 and unsynchronized later GPU consumers were not tested. No game files or retail boot. AI-assisted (Codex).
Author
Owner

@⁠Dezmonius on GitHub · 2026-11-24 15:50 UTC · original

Synthetic Windows follow-up to the queue-slot-35 handover question. Used #622 head d496f187c and locally adapted only the queue dispatch behavior from #391 tip 1bd72a87; its patch does not apply cleanly to this base. Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, Khronos validation 1.4.369.

Local build Raw queue slot 35 Same-list 16-byte GPU copy Deferred slot 71/72 writes
Exact #622 E_NOTIMPL No submission No writes
#622 + slot-35 route to native ExecuteCommandLists Success Match Both offsets kept their old values
Same route plus value-write handover Success Match Both exact values landed after releasing the blocking fence, 3/3

The test passed a count word with a nonzero upper dword and one list in the lower dword. The handover collects from the original console list array, stages the records before forwarding the unwrapped lists, then clears staging after the call. The caller list array remained intact. A subsequent, explicitly ordered GPU copy matched the CPU-visible window in all three successful runs. No validation diagnostics in the final runs.

The handover variant is a local prototype. Synthetic fixtures only; no game files or retail boot. AI-assisted (Codex).

**@⁠Dezmonius** on GitHub · 2026-11-24 15:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7136715000) Synthetic Windows follow-up to [the queue-slot-35 handover question](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/622). Used #622 head `d496f187c` and locally adapted only the queue dispatch behavior from #391 tip `1bd72a87`; its patch does not apply cleanly to this base. Windows 10 22H2, RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, Khronos validation 1.4.369. | Local build | Raw queue slot 35 | Same-list 16-byte GPU copy | Deferred slot 71/72 writes | |---|---|---|---| | Exact #622 | `E_NOTIMPL` | No submission | No writes | | #622 + slot-35 route to native ExecuteCommandLists | Success | Match | Both offsets kept their old values | | Same route plus value-write handover | Success | Match | Both exact values landed after releasing the blocking fence, 3/3 | The test passed a count word with a nonzero upper dword and one list in the lower dword. The handover collects from the original console list array, stages the records before forwarding the unwrapped lists, then clears staging after the call. The caller list array remained intact. A subsequent, explicitly ordered GPU copy matched the CPU-visible window in all three successful runs. No validation diagnostics in the final runs. The handover variant is a local prototype. Synthetic fixtures only; no game files or retail boot. AI-assisted (Codex).
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 17:03 UTC · original

The head has moved to 026bc0f3 (parent 82a2aabc, current main). The five commits are kept and the diff is unchanged: 12 files, +640/-8. The base had drifted to d0da7dad, so the checks were running on a stale tree. The two red jobs are not from this pull request:

  • windows: leonida_xma2_decoder.lib fails to link (LNK2019 on __imp_WaitOnAddress and __imp_WakeByAddressAll, then LNK1120) - the upstream XMA2 decoder crate.
  • linux-gpu-tools: ctest was 100% green, 70/70, including the new xs_value_writes test (Test #3, passed). The failing step is the gpu-native fixture run, on cs_imgload_tfe and cs_imgload_d16_tfe (r32 sint (sint view): 64 bad, texel(5,3) = 2071).

The same two fixtures fail with the same numbers on #662, whose diff is disjoint from this one, so the cause is in the shared base tree.

A dependency note, as @⁠DadaCap asked (their comment): the retail title submits through command-queue slot 35, which is the route in #391 (still open, by @⁠Mumogg). The handover here is therefore not reachable on the retail path until that route lands. @⁠Dezmonius's synthetic Windows run (comment) shows both exact values landing 3/3 once the slot-35 route and the handover are combined. This pull request need not carry #391; the note is what was asked for.

One more slot data point (@⁠DesertGamer on #14, comment): in the deepest runs the title called console list slots 0, 9, 12, 14, 20-25, 32-36, 44, 47, 48, 50, 52, 70-72, 74, 75, 126, 131, 132, 139, 142, 146. With this pull request's numbering that means both value-write slots, 71 and 72, are called and slot 73 is not. What places the value payload at 71 and the flags word at 72 is @⁠DadaCap's measurement, not the call list. The origin of the two-slot shift is still unpinned - the title never calls ExecuteIndirect - so DOC-LIST-SLOTS-SHIFT-ORIGIN stays open.

AI-assisted: yes

**@⁠Mby159** on GitHub · 2026-11-24 17:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7138620250) The head has moved to `026bc0f3` (parent `82a2aabc`, current `main`). The five commits are kept and the diff is unchanged: 12 files, +640/-8. The base had drifted to `d0da7dad`, so the checks were running on a stale tree. The two red jobs are not from this pull request: - `windows`: `leonida_xma2_decoder.lib` fails to link (`LNK2019` on `__imp_WaitOnAddress` and `__imp_WakeByAddressAll`, then `LNK1120`) - the upstream XMA2 decoder crate. - `linux-gpu-tools`: `ctest` was 100% green, 70/70, including the new `xs_value_writes` test (Test #3, passed). The failing step is the gpu-native fixture run, on `cs_imgload_tfe` and `cs_imgload_d16_tfe` (`r32 sint (sint view): 64 bad, texel(5,3) = 2071`). The same two fixtures fail with the same numbers on #662, whose diff is disjoint from this one, so the cause is in the shared base tree. **A dependency note, as @⁠DadaCap asked** ([their comment](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/622)): the retail title submits through command-queue slot 35, which is the route in #391 (still open, by @⁠Mumogg). The handover here is therefore not reachable on the retail path until that route lands. @⁠Dezmonius's synthetic Windows run ([comment](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/622)) shows both exact values landing 3/3 once the slot-35 route and the handover are combined. This pull request need not carry #391; the note is what was asked for. **One more slot data point** (@⁠DesertGamer on #14, [comment](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)): in the deepest runs the title called console list slots 0, 9, 12, 14, 20-25, 32-36, 44, 47, 48, 50, 52, 70-72, 74, 75, 126, 131, 132, 139, 142, 146. With this pull request's numbering that means both value-write slots, 71 and 72, are called and slot 73 is not. What places the value payload at 71 and the flags word at 72 is @⁠DadaCap's measurement, not the call list. The origin of the two-slot shift is still unpinned - the title never calls `ExecuteIndirect` - so `DOC-LIST-SLOTS-SHIFT-ORIGIN` stays open. AI-assisted: yes
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 17:35 UTC · original · edited 2026-11-24 17:38 UTC

Rebased onto main at 32950551. The diff is unchanged: 12 files, +640/-8, five commits kept.

Both red jobs from the last round were the base, not this pull request, and main has since fixed both:

  • windows: leonida_xma2_decoder.lib failed to link (LNK2019 on __imp_WaitOnAddress / __imp_WakeByAddressAll, then LNK1120). main now carries #877 (BUILD-XMA2-SYNCH-LIB), which adds synchronization to that target's link libraries - the same WaitOnAddress / WakeByAddress* symbols Rust's std imports.
  • linux-gpu-tools: ctest was green, 70/70, including the new xs_value_writes test (Test #3, passed). The failing step was the gpu-native fixture run, on cs_imgload_tfe and cs_imgload_d16_tfe (r32 sint (sint view): 64 bad, texel(5,3) = 2071). main now carries #892 (SHADER-1266), which corrects those two fixtures' resident TFE status expectations.

The same two fixtures failed on #662's tree as well, which does not touch them, so neither failure came from either change.

I am not claiming the checks are green now: the queue is long and I have not seen a conclusion for this head yet. What I can say is that neither failure is in the tree this head runs on any more.

Head 3464cb10. AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-24 17:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7139409667) · edited 2026-11-24 17:38 UTC Rebased onto `main` at `32950551`. The diff is unchanged: 12 files, +640/-8, five commits kept. Both red jobs from the last round were the base, not this pull request, and `main` has since fixed both: - `windows`: `leonida_xma2_decoder.lib` failed to link (`LNK2019` on `__imp_WaitOnAddress` / `__imp_WakeByAddressAll`, then `LNK1120`). `main` now carries #877 (BUILD-XMA2-SYNCH-LIB), which adds `synchronization` to that target's link libraries - the same `WaitOnAddress` / `WakeByAddress*` symbols Rust's std imports. - `linux-gpu-tools`: `ctest` was green, 70/70, including the new `xs_value_writes` test (Test #3, passed). The failing step was the gpu-native fixture run, on `cs_imgload_tfe` and `cs_imgload_d16_tfe` (`r32 sint (sint view): 64 bad, texel(5,3) = 2071`). `main` now carries #892 (SHADER-1266), which corrects those two fixtures' resident TFE status expectations. The same two fixtures failed on #662's tree as well, which does not touch them, so neither failure came from either change. I am not claiming the checks are green now: the queue is long and I have not seen a conclusion for this head yet. What I can say is that neither failure is in the tree this head runs on any more. Head `3464cb10`. AI-assisted.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 18:18 UTC · original

Rebased onto main at 3aa97542. The diff is unchanged: 12 files, +640/-8, five commits kept - all twelve changed-file blobs are byte-identical to the previous head, so the independent Windows verifications already posted here still describe this head.

The checks for this head are queued, so there is no CI signal yet. The merge ref now reads into 3aa97542, so the jobs will run on the current main tree.

Head 3e069886. AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-24 18:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7140447223) Rebased onto `main` at `3aa97542`. The diff is unchanged: 12 files, +640/-8, five commits kept - all twelve changed-file blobs are byte-identical to the previous head, so the independent Windows verifications already posted here still describe this head. The checks for this head are queued, so there is no CI signal yet. The merge ref now reads `into 3aa97542`, so the jobs will run on the current `main` tree. Head `3e069886`. AI-assisted.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-24 20:10 UTC · original

Rebased onto main at 6293c1c4f. Our changes are preserved: same 12 files, same +640/-8, five commits - the same file set and line counts as the previous head. The diff is now against the new base, and three of these files also carry upstream edits, so the surrounding context differs from the previous head.

One conflict, in runtime/shims/d3d12_vulkan_device.cpp: main added state_.context->set_depth_range_unrestricted(info.depth_range_unrestricted); directly above our set_up_value_writes();. Both lines are kept, in that order.

The checks for this head are queued, so there is no CI signal yet.

Head 335e12dd. AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-24 20:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7143139173) Rebased onto `main` at `6293c1c4f`. Our changes are preserved: same 12 files, same +640/-8, five commits - the same file set and line counts as the previous head. The diff is now against the new base, and three of these files also carry upstream edits, so the surrounding context differs from the previous head. One conflict, in `runtime/shims/d3d12_vulkan_device.cpp`: `main` added `state_.context->set_depth_range_unrestricted(info.depth_range_unrestricted);` directly above our `set_up_value_writes();`. Both lines are kept, in that order. The checks for this head are queued, so there is no CI signal yet. Head `335e12dd`. AI-assisted.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-25 00:09 UTC · original

Rebased onto main at 9c5e7066. The PR diff is unchanged: same 12 files, same +640/-8, five commits - the same file set and line counts as the previous head. main has since touched seven of the files this PR changes, so the diff is now computed against the new base.

Two conflicts, both in runtime/shims/d3d12_xs_device.h, both in the slot-documentation comment block:

  • main added notes for device slots 86, 101 and 108. Those are kept.
  • Our own renumbering commit conflicted with the earlier version of the same block in this series, which still placed the waits at slots 71/72. We kept only the renumbered text and dropped the stale lines, so the header now states the writes at list slots 71/72 and the waits at 73/74 - matching runtime/src/xs_value_writes.h and the table in docs/d3d12_command_objects.md.

The earlier head's CI results and the human test reports on this pull request apply to the pre-rebase tree. Checks for this head are still running.

Head 8b2dd8b7. AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-25 00:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7148203640) Rebased onto `main` at `9c5e7066`. The PR diff is unchanged: same 12 files, same +640/-8, five commits - the same file set and line counts as the previous head. `main` has since touched seven of the files this PR changes, so the diff is now computed against the new base. Two conflicts, both in `runtime/shims/d3d12_xs_device.h`, both in the slot-documentation comment block: - `main` added notes for device slots 86, 101 and 108. Those are kept. - Our own renumbering commit conflicted with the earlier version of the same block in this series, which still placed the waits at slots 71/72. We kept only the renumbered text and dropped the stale lines, so the header now states the writes at list slots 71/72 and the waits at 73/74 - matching `runtime/src/xs_value_writes.h` and the table in `docs/d3d12_command_objects.md`. The earlier head's CI results and the human test reports on this pull request apply to the pre-rebase tree. Checks for this head are still running. Head `8b2dd8b7`. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 02:39 UTC · original

Thanks for this, and for the slot measurements. main now covers slots 71 and 72 through #939's GPU completion labels, so merging this as it is would give the same console writes two paths:

  • list_slot in runtime/shims/d3d12_xs_device.cpp records 71 and 72 onto the real list (record_gpu_label), with the same flag rule (1 = GPU time, 2 = system time).
  • runtime/src/vulkan_gpu_labels.h writes the value after a per-command-buffer fence and uses timestamp queries, so no calibrated timestamps are needed; because the label rides on the list, it also works for queue slot 35, the retail path.
  • xbox_gpu_label_completion and gpu_label_store test it.

What this PR still adds beyond that:

  • writes into section-backed xmem pages and arena addresses (main writes only into MEM_PRIVATE title allocations, track_label_data and store_value);
  • writes on by default: main needs LEONIDA_GPU_LABELS=1, which only the --first-run-ui profile sets, so a plain --run writes nothing on these slots;
  • the rows for slots 71 to 74 in docs/d3d12_command_objects.md.

Could you rebuild it on top of the label path: widen track_label_data / store_value for xmem pages and arena addresses, decide the default with a measurement, and keep the docs rows? Slots 73 and 74 stay no-ops on both sides, as you decided.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 02:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7151017700) Thanks for this, and for the slot measurements. `main` now covers slots 71 and 72 through #939's GPU completion labels, so merging this as it is would give the same console writes two paths: - `list_slot` in `runtime/shims/d3d12_xs_device.cpp` records 71 and 72 onto the real list (`record_gpu_label`), with the same flag rule (1 = GPU time, 2 = system time). - `runtime/src/vulkan_gpu_labels.h` writes the value after a per-command-buffer fence and uses timestamp queries, so no calibrated timestamps are needed; because the label rides on the list, it also works for queue slot 35, the retail path. - `xbox_gpu_label_completion` and `gpu_label_store` test it. What this PR still adds beyond that: - writes into section-backed xmem pages and arena addresses (`main` writes only into `MEM_PRIVATE` title allocations, `track_label_data` and `store_value`); - writes on by default: `main` needs `LEONIDA_GPU_LABELS=1`, which only the `--first-run-ui` profile sets, so a plain `--run` writes nothing on these slots; - the rows for slots 71 to 74 in `docs/d3d12_command_objects.md`. Could you rebuild it on top of the label path: widen `track_label_data` / `store_value` for xmem pages and arena addresses, decide the default with a measurement, and keep the docs rows? Slots 73 and 74 stay no-ops on both sides, as you decided. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠Mby159 on GitHub · 2026-11-25 05:18 UTC · original

Rebuilt on the label path, as asked: the branch is now main plus a delta, and the list proxy's own recording is gone. main's GPU completion label path (#939) is the only path that records a write.

What the delta is:

  • runtime/src/vulkan_gpu_labels.h gains a sink. A completed label whose target is the runtime's own host-visible memory is written through it; the D3D12 device installs it. A target the sink declines - the title's own private pages - falls through to main's existing path, which opens a read-only page the way a kernel write does.
  • The sink covers the two targets main does not reach: an address in the GPU address arena (a default-heap buffer - the arena is host-visible and coherent, so the CPU writes the bytes the GPU reads), and a page of the title's own memory that the xmem shim owns (written through the section's own host mapping, which the CPU may write even where the title's own view of the page is PAGE_NOACCESS). A sparse resource is refused: the sparse pass binds its memory, not the arena's mapping.
  • The arena is tracked for the label path now (leonida::label::memory().track(0, arena.size, ...), base 0 because the console's address space starts at 0), so a capture of an arena address finds it.
  • The pages the title maps are found as well. main tracks the title's heap blocks and its own VirtualAlloc memory, but not the physical pages the title maps, so a capture of such an address found nothing. The xmem shim now answers that question (rt::xmem::label_target), and the region is tracked on demand, one per page. The list proxy asks it only when main's capture found nothing.
  • runtime/shims/xmem.cpp gains the host write itself, reached through a registered function pointer, so the D3D12 library does not have to link the xmem shim - the link error reported on 927289f should not come back.
  • The four rows for slots 71 to 74 are in docs/d3d12_command_objects.md, with the measured slot numbers.

One thing this removes: the hand-over. As you noted, the label rides on the list, so console queue slot 35 needs no staging of its own.

The default. LEONIDA_GPU_LABELS=0 turns the label path - and with it the two slots - off; they are on otherwise. The reason is functional, not a perf claim: the retail title calls slots 71/72 every frame (@⁠DadaCap, 7131556921), and with the writes handled their run reached the first-run menus and presented for 590 s without a crash (7133945607); with the wrong slots (69/70) nothing the title waits on was written. We do not have a clean on-vs-off A/B on this label-path delta: the ~1,000 to ~330 presents/s @⁠DadaCap saw compares the wrong-slot run with the right-slot run, and they caution the pacing cause is not proved. main's default-off has been run, but not measured against this delta, so the always-on fence/query cost of the new path is unmeasured; we accept it because the writes are functionally required, and 0 is the escape hatch.

Not verified here. This machine has no C++ toolchain - no cmake, no MSVC, no clang - so nothing here was compiled or run: the MSVC build and the CI are still needed, as before. The CPU-side model test that came with the previous implementation is gone with the implementation it modelled, and the widened store has no test of its own yet.

Two known gaps:

  • the ordering gap is inherited from the label model and is not fixed here: the value lands after the carrying submission completes, so a following submission can read the old value (@⁠sodove, 7128565305), and slots 73/74 are no-ops, so the port does not implement the console's wait that would order that consumer;
  • the sparse refusal is a limitation of this delta's sink: a sparse address is refused, so the value for it is dropped.

The checks for this head are queued; there is no CI signal yet.

Head 9b74691f. AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-25 05:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7153647153) Rebuilt on the label path, as asked: the branch is now `main` plus a delta, and the list proxy's own recording is gone. `main`'s GPU completion label path (#939) is the only path that records a write. What the delta is: - `runtime/src/vulkan_gpu_labels.h` gains a sink. A completed label whose target is the runtime's own host-visible memory is written through it; the D3D12 device installs it. A target the sink declines - the title's own private pages - falls through to `main`'s existing path, which opens a read-only page the way a kernel write does. - The sink covers the two targets `main` does not reach: an address in the GPU address arena (a default-heap buffer - the arena is host-visible and coherent, so the CPU writes the bytes the GPU reads), and a page of the title's own memory that the xmem shim owns (written through the section's own host mapping, which the CPU may write even where the title's own view of the page is `PAGE_NOACCESS`). A sparse resource is refused: the sparse pass binds its memory, not the arena's mapping. - The arena is tracked for the label path now (`leonida::label::memory().track(0, arena.size, ...)`, base 0 because the console's address space starts at 0), so a capture of an arena address finds it. - The pages the title maps are found as well. `main` tracks the title's heap blocks and its own `VirtualAlloc` memory, but not the physical pages the title maps, so a capture of such an address found nothing. The xmem shim now answers that question (`rt::xmem::label_target`), and the region is tracked on demand, one per page. The list proxy asks it only when `main`'s capture found nothing. - `runtime/shims/xmem.cpp` gains the host write itself, reached through a registered function pointer, so the D3D12 library does not have to link the xmem shim - the link error reported on `927289f` should not come back. - The four rows for slots 71 to 74 are in `docs/d3d12_command_objects.md`, with the measured slot numbers. One thing this removes: the hand-over. As you noted, the label rides on the list, so console queue slot 35 needs no staging of its own. **The default.** `LEONIDA_GPU_LABELS=0` turns the label path - and with it the two slots - off; they are on otherwise. The reason is functional, not a perf claim: the retail title calls slots 71/72 every frame (@⁠DadaCap, 7131556921), and with the writes handled their run reached the first-run menus and presented for 590 s without a crash (7133945607); with the wrong slots (69/70) nothing the title waits on was written. We do **not** have a clean on-vs-off A/B on this label-path delta: the ~1,000 to ~330 presents/s @⁠DadaCap saw compares the wrong-slot run with the right-slot run, and they caution the pacing cause is not proved. `main`'s default-off has been run, but not measured against this delta, so the always-on fence/query cost of the new path is unmeasured; we accept it because the writes are functionally required, and `0` is the escape hatch. **Not verified here.** This machine has no C++ toolchain - no cmake, no MSVC, no clang - so nothing here was compiled or run: the MSVC build and the CI are still needed, as before. The CPU-side model test that came with the previous implementation is gone with the implementation it modelled, and the widened store has no test of its own yet. Two known gaps: - the ordering gap is inherited from the label model and is not fixed here: the value lands after the carrying submission completes, so a following submission can read the old value (@⁠sodove, 7128565305), and slots 73/74 are no-ops, so the port does not implement the console's wait that would order that consumer; - the sparse refusal is a limitation of this delta's sink: a sparse address is refused, so the value for it is dropped. The checks for this head are queued; there is no CI signal yet. Head `9b74691f`. AI-assisted.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-25 06:25 UTC · original

Correction to the "Not verified here" paragraph above: it was wrong. This machine does have a C++ toolchain (llvm-mingw clang++ 23, cmake/ninja). No code changes; the head remains 9b74691f.

Syntax-checked the changed C++ files (clang++ -std=c++20 -fsyntax-only -fms-extensions -Wall -Wextra) and compared each one against the same command line on main: the diagnostic set is identical for every file - 0 new errors and 0 new warnings from this delta. The d3d12.h used is the MinGW one with the 26100 interfaces and symbols the runtime names added to it locally (not in the repo), because the Windows SDK is not installed here; the Vulkan headers are the commit .github/workflows/runtime.yml pins. One file does not come out clean: d3d12_vulkan_device.cpp has 5 errors, and main gives the same 5 under the same command line - old-SDK signature mismatches (CreateSampler2, GetDesc, two out-parameter overloads) - and none of them is on a line this delta touches. That is diagnostic parity, not a successful build; the MSVC build and upstream CI remain the real gate.

Ran (CPU only, no Vulkan device, no game data):

  • runtime/test/gpu_label_store_test.cpp (the upstream test for store_value and memory().track/capture, the functions this delta widens): 24 checks, 0 failures. main gives the same 24/0, so the delta does not regress it.
  • runtime/test/xmem_test.cpp (the xmem shim plus the registry): 216 checks pass, 0 fail, then the test dies with an access violation; main dies at the same check with the same output, so that is this machine, not the delta. (Built with a one-line scratch tweak for libc++'s missing wstring ifstream overload, applied identically to main; not committed.)

Still not verified: the widened store's new target - the page of the title's own memory the xmem shim owns - has no test of its own; the test above covers main's private-page path. xbox_gpu_label_test.cpp needs a Vulkan device and 26100 root signatures, so it was not run. The functional gaps from the earlier review are unchanged.

Label note: needs rebase is stale - GitHub reports mergeable: true, and the conflict-label workflow removes the label in that case, so it should clear on its own. I have not touched it.

AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-25 06:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7154775453) Correction to the "Not verified here" paragraph above: it was wrong. This machine does have a C++ toolchain (llvm-mingw clang++ 23, cmake/ninja). No code changes; the head remains `9b74691f`. **Syntax-checked** the changed C++ files (`clang++ -std=c++20 -fsyntax-only -fms-extensions -Wall -Wextra`) and compared each one against the same command line on `main`: **the diagnostic set is identical for every file - 0 new errors and 0 new warnings from this delta.** The `d3d12.h` used is the MinGW one with the 26100 interfaces and symbols the runtime names added to it locally (not in the repo), because the Windows SDK is not installed here; the Vulkan headers are the commit `.github/workflows/runtime.yml` pins. One file does not come out clean: `d3d12_vulkan_device.cpp` has 5 errors, and `main` gives the same 5 under the same command line - old-SDK signature mismatches (`CreateSampler2`, `GetDesc`, two out-parameter overloads) - and none of them is on a line this delta touches. That is diagnostic parity, not a successful build; the MSVC build and upstream CI remain the real gate. **Ran** (CPU only, no Vulkan device, no game data): - `runtime/test/gpu_label_store_test.cpp` (the upstream test for `store_value` and `memory().track`/`capture`, the functions this delta widens): 24 checks, 0 failures. `main` gives the same 24/0, so the delta does not regress it. - `runtime/test/xmem_test.cpp` (the xmem shim plus the registry): 216 checks pass, 0 fail, then the test dies with an access violation; `main` dies at the same check with the same output, so that is this machine, not the delta. (Built with a one-line scratch tweak for libc++'s missing `wstring` `ifstream` overload, applied identically to `main`; not committed.) **Still not verified:** the widened store's new target - the page of the title's own memory the xmem shim owns - has no test of its own; the test above covers `main`'s private-page path. `xbox_gpu_label_test.cpp` needs a Vulkan device and 26100 root signatures, so it was not run. The functional gaps from the earlier review are unchanged. Label note: `needs rebase` is stale - GitHub reports `mergeable: true`, and the conflict-label workflow removes the label in that case, so it should clear on its own. I have not touched it. AI-assisted.
Author
Owner

@⁠Mby159 on GitHub · 2026-11-25 07:12 UTC · original

One more piece of evidence on the gap named above: we ran the new label-target lookup and title-byte write in the repo's own xmem shim at runtime. The harness reproduces the title layout as the repo describes it - a CPU-mappable range and a same-size GPU-only range, paired as title_gpu_views pairs them, with the same physical pages mapped into both - and calls the shim directly:

  • label_target resolves an address in the GPU-only range to a 4-byte label target and tracks the page;
  • write_title_bytes at that address, through the section's own host mapping, succeeds;
  • the value reads back at the paired CPU address, which is where the D3D12 layer reads that memory.

12 checks, 0 failures. This exercises the shim's lookup/write against a simulated layout - not a retail title, and not the full submission path. The harness is local scratch and not in the branch; say the word and we'll add it as a test - we kept it out so the delta stays the rebuild you asked for. The rest of what is not verified is unchanged.

AI-assisted.

**@⁠Mby159** on GitHub · 2026-11-25 07:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7155610460) One more piece of evidence on the gap named above: we ran the new label-target lookup and title-byte write in the repo's own xmem shim at runtime. The harness reproduces the title layout as the repo describes it - a CPU-mappable range and a same-size GPU-only range, paired as `title_gpu_views` pairs them, with the same physical pages mapped into both - and calls the shim directly: - `label_target` resolves an address in the GPU-only range to a 4-byte label target and tracks the page; - `write_title_bytes` at that address, through the section's own host mapping, succeeds; - the value reads back at the paired CPU address, which is where the D3D12 layer reads that memory. 12 checks, 0 failures. This exercises the shim's lookup/write against a simulated layout - not a retail title, and not the full submission path. The harness is local scratch and not in the branch; say the word and we'll add it as a test - we kept it out so the delta stays the rebuild you asked for. The rest of what is not verified is unchanged. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 11:48 UTC · original

Merged, adapted to #1723's list values. Thanks to @⁠Mby159 for the arena and xmem value writes, and to @⁠sodove for the review cases.

  • #1723's list values own slots 71–74 of the lists they track. LEONIDA_GPU_LABELS stays opt-in and still writes 71/72 only for untracked lists.
  • #622's write_title_bytes and arena write are now a fallback for both writers (src/value_write_sink.h). An arena offset lands in the arena and is never stored to as a host address. An xmem page the title made PAGE_NOACCESS lands through xmem's own mapping.
  • The arena refuses its reserved start and writes past its end, and is unregistered when its device goes.
  • The docs no longer call slots 73/74 no-ops.
  • New test xbox_list_value_fallback: fails without either fallback. Full Windows suite under Wine (llvmpipe and the iGPU): nothing went from pass to fail.
  • Checked on main ed94fbef9 + 6aa5f0b0d: it merges cleanly; the semantic suite passes (489 files, 6,288 tests, 0 files failed); the 14 docs and writer tests pass; check_no_game_data.py is clean on the 15 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 11:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/622#issuecomment-7161525437) Merged, adapted to #1723's list values. Thanks to @⁠Mby159 for the arena and xmem value writes, and to @⁠sodove for the review cases. - #1723's list values own slots 71–74 of the lists they track. `LEONIDA_GPU_LABELS` stays opt-in and still writes 71/72 only for untracked lists. - #622's `write_title_bytes` and arena write are now a fallback for both writers (`src/value_write_sink.h`). An arena offset lands in the arena and is never stored to as a host address. An xmem page the title made `PAGE_NOACCESS` lands through xmem's own mapping. - The arena refuses its reserved start and writes past its end, and is unregistered when its device goes. - The docs no longer call slots 73/74 no-ops. - New test `xbox_list_value_fallback`: fails without either fallback. Full Windows suite under Wine (llvmpipe and the iGPU): nothing went from pass to fail. - **Checked on `main` `ed94fbef9` + `6aa5f0b0d`:** it merges cleanly; the semantic suite passes (489 files, 6,288 tests, 0 files failed); the 14 docs and writer tests pass; `check_no_game_data.py` is clean on the 15 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.