Commit Graph

264 Commits

Author SHA1 Message Date
1aefed0dac runtime: fix present_mutex AB-BA deadlock, cross-queue relay cycle, and held-queue stalls 2026-11-29 21:05:26 -05:00
f051ae5183 d3d12/tests: fix Windows MSVC build, CopyMemory collision, copy parity guard, and --no-ftz32 probe 2026-11-29 11:41:49 -05:00
091bfa8d4d d3d12/vulkan(r9a): fix pending_stream dword6 refill, gpu_owned eviction, COPY_CLIP, and sync slots 131/132 2026-11-29 09:25:40 -05:00
399a5eabdf d3d12/vulkan: implement Xbox OMSetSampleMaskX (slot 142) with runtime SPIR-V quad mask 2026-11-29 07:17:27 -05:00
85f806b916 rendering(r8a): forward Xbox DispatchMesh (slot 129), queries (28-30), and CopyMemoryToMemoryX (62)
Xbox console list slot 129 (DispatchMesh -> PC slot 79) was silently dropped as unforwarded, skipping all direct mesh-shader 3D-to-UV ped/decoration texture bakes and leaving 9/10 BC3_UNORM_SRGB (and BC7/BC1) composited textures 100% all-zero on the GPU.

Forward list slot 129 -> PC 79 (DispatchMesh) with bundle deferral and z==0 draw guard, forward live query slots 28..30 -> PC 52..54 (BeginQuery/EndQuery/ResolveQueryData, updating kConsoleBeginQuery/kConsoleEndQuery), implement CopyMemoryToMemoryX (slot 62, older layout slot 60) via VA-based CopyMemory replay with split-chunk and overlap-staged copies, and add replay + mock unit tests.
2026-11-29 06:36:45 -05:00
b620db492f rendering(r6b): use 16-byte descriptor stride for D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER
Xbox Series shaders (10,584 shaders / 39.9% of the corpus) index directly-indexed sampler heaps at 16-byte stride (4-dword hardware S#). Previously the runtime hardcoded 32-byte stride for SAMPLER heaps, so every odd sampler slot (0x430, 0x4b0, etc.) read zeroed upper bytes and fell back to fallback_sampler_ (NEAREST + CLAMP_TO_EDGE -> 1D clamped road stripes and nearest-neighbor textures), while even slots read wrong sampler N/2.

Introduce sampler_descriptor_size = 16 and descriptor_increment(type) across GetDescriptorHandleIncrementSize, CreateSampler/CreateSampler2, DescriptorHeap, CopyDescriptors*, scan_title_table, materialize_table, console_heap_range_plausible, local_write_through/copy_title_slots/pull_title_descriptors/local_mirror_table, proxy_create_sampler_x, and d3d12_com.cpp; add packed 16-byte even/odd sampler regression tests.
2026-11-29 06:36:03 -05:00
edcc7f3dca rendering(r6a): forward CopyResourceX and mark GPU-copied placed TitleTextures as gpu_written
Ped head compositing writes BC3/BC7 blocks into placed slot-133 TitleTextures via CopyTextureRegionX (slot 85) and CopyResourceX (slot 86). Previously slot 86 was dropped as unforwarded, and placed BC textures (which cannot carry RT/DS/UAV flags) stayed gpu_written=false, causing place_title_view() and refresh_title_textures() to overwrite GPU-composited ped skin with zeroed CPU pages (intermittent pitch-black heads).

Forward list slot 86 (CopyResourceX) to PC slot 17 (CopyResource); synchronously promote placed texture destinations of CopyTextureRegion/CopyResource/ResolveSubresource to gpu_written=true on ExecuteCommandLists (preserving unmodified mips on partial copies and avoiding fill_unlocked TOCTOU); add UNORM/sRGB mutability on placed textures for cross-alias format_family matching; fix evict_and_replace() gpu_placements cleanup; and add unit + Wine regression tests.
2026-11-29 06:35:28 -05:00
eb1cf5e96e rendering(r3): fix Blob A CB_TARGET_MASK (+0xcc), depth bias, T# bugs 1A-1D, OMSetDepthBounds replay, and stage-link polish 2026-11-29 06:34:13 -05:00
7ba56174b8 rendering(r1): fix read-only DSV HTILE layout, D16S8 SRVs, non-array T# decode, and PRESENT_DUMP
- U1: preserve D3D12_DSV_FLAG_READ_ONLY_* on TargetView; remap read-only depth layouts to GENERAL when sampled_in_general; emit shader-read barrier visibility and gated VK_ATTACHMENT_STORE_OP_NONE
- U2: add VK_FORMAT_D16_UNORM_S8_UINT to gfx10::format_table so DXGI 119 SRVs succeed on AMD/RADV
- T1/T2: decode non-array GFX10 image_1d/image_2d/image_2d_msaa as layer_count=1 (ignoring linear pitch/depth in WORD4[12:0]); route image_1d_array to TEXTURE1D
- P0: keep capture_ptr_ alive across splash handoff when LEONIDA_PRESENT_DUMP is enabled
- Add capped tsharp-refuse and slot-57 fallback diagnostics + unit/VVL GPU tests
2026-11-29 06:34:13 -05:00
314b4e73dd Merge upstream ProjectLeonida/mandy main (b589e0fe0) into round10 base
# Conflicts:
#	docs/design.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/src/queue_holds.h
#	runtime/src/shader_library.h
#	runtime/src/vulkan_backend.h
#	runtime/src/vulkan_replay.h
#	runtime/test/vk_harness.cpp
#	tests/semantic/test_wave32_lane_select.py
#	tools/lane_masks.py
#	tools/rdna2spirv.py
2026-11-29 06:33:39 -05:00
02c3ef96d1 Merge pull request #1390 from Diegobecker07/old-9990-slot-caller
d3d12_xs: the first call of a forwarded device slot names its caller (OLD-9990, RT-526)
2026-11-29 09:10:05 +01:00
f64162d0a3 Merge pull request #2516 from Tyrannys/claude/xs-console-placement-layout
Size read-only console textures in the title's swizzle mode (RT-XS-CONSOLE-PLACEMENT-TITLE-LAYOUT)
2026-11-29 02:04:39 +01:00
193a692863 Merge pull request #2498 from Tyrannys/rt-xs-descriptor-mirror-gaps
d3d12_xs: CreateSamplerX writes through; mapped descriptor ranges are left to the submission-time pull (RT-XS-DESCRIPTOR-MIRROR-GAPS)
2026-11-29 02:04:23 +01:00
b2c9695962 Fix NVIDIA sparse arena, MSVC TLS callbacks, FTZ32 probe, teardown leaks, and cross-GPU tests 2026-11-28 16:34:52 -05:00
66d4723f40 Merge upstream ProjectLeonida/mandy main (d48a957bb) into test/round10
Resolved conflicts in docs/design.md, runtime/CMakeLists.txt, and tests/semantic/spirv_wave_interp.py.
AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-28 07:00:01 -05:00
0040a3d15a runtime: Round 10b WS-A — bare write-group vis_seq bump, exact landed-value check, wait_met re-check, relay_wait gate preservation & signal-only vis_seq transitivity
AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-28 06:29:45 -05:00
6bd17e22a1 runtime: Round 10 WS3 — GPU-met gate vis_seq=0, retroactive GPU-to-GPU wait relay, coalescer reorder, readable fast path & decoupled GPU profile resolve
- Add VulkanFence::signal_gpu_relay() (vis_seq=0) strictly for GPU-landed list-value gates (!force && !lost && !action && !cpu_met)
- Retroactive GPU-to-GPU relay via QueueHolds::relay_wait() + VulkanQueue wait substitution (never GPU-signaling values->gate, reversing wait() before add_gate(), requiring after_gate==0 && different queue)
- Decouple gpu_profile_.resolve() onto lazy resolver thread off FenceWaitDispatcher & throttle take_open() device-loss checks
- Reorder BeforeExecuteCoalescer to wb -> mirror -> flush -> tex -> shadows -> 2nd flush -> conditional 2nd tex (killing in_feed CPU fallbacks)
- Hoist host_stop & add negative caching in TextureVqCache + Stage 2b all-16 Cell::restore[] readability bypass

AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-28 05:38:11 -05:00
59db4b62b0 runtime: Round 8 WS3 — fix list-value gate TOCTOU, offload QueueHolds barriers, empty-batch/wait coalescing, replay floor & batched xmem slot-31
- Fix Pump::choose_release() TOCTOU on already-completed unlanded write groups/action gates + 10 ms quiet window on Reason::present
- Skip before_execute/visibility_seq on empty batches (preserving pending_wait_vis_seq_), coalesce past GPU-completed Waits (merging CPU vis_seq), cache CommandList summary, atomic unbuilt_sync_pipelines_ & BindlessSet clean fast-paths, hoist EmitScratch
- Dedicated QueueHolds barrier-drain thread with active_work_ tracking, wait_barriers_drained() ordering, cancel_after() wait, and non-blocking VulkanQueue::release_ready()
- Batch copy_page_mappings() per contiguous range & notify Event::replaced on mirror_heap decommit in xmem.cpp
- SEH-guarded aligned volatile read_value() (no noexcept under /EHsc) + 1000 ms slot-12 Vulkan fence mirror timeout

AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-28 03:31:06 -05:00
59feb165bd d3d12_xs: leave a mapped descriptor range to the queue's pull at submission
From timbot103's review of #2498.

A mapped real range is the Vulkan device's live arena: shaders of lists
already submitted read it, and the queue rewrites the slots it pulls there
in place (title buffer addresses rebased) when it submits. local_mirror_table
copied the title's raw slots into it while a list was being recorded
(SetGraphicsRootDescriptorTable / SetComputeRootDescriptorTable), which could
overwrite a translated slot an earlier submission was still reading. The
first commit of this PR made that happen on Wine as well; on Windows, where
VirtualQuery reports the arena as accessible, main already did it.

local_mirror_table now leaves a mapped range alone. The queue pulls the
title's slots of every bound table itself at submission
(pull_title_descriptors through title_va_aliases), which needs no
VirtualQuery of the arena, so Wine loses nothing.

xs_proxy_mock_test, check_descriptor_mirror case 2: with a translated value
in the real slot, binding a table over it (graphics and compute) leaves the
slot as it was, and the submission-time pull then takes the title's slot.
The previous commit fails the first of these checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 20:11:24 -06:00
c05dc2ff52 Size read-only console textures in the title's swizzle mode
Slots 25 and 108 size a list from the PC form of its descriptions
(pc_resource_desc), which drops the title's layout word (0x100 | swizzle
mode). console_texture_layout read the layout from that PC form, so a
texture only the CPU fills was sized in XG's default mode instead of the
one the title named: a 64x64 BC7 texture in SW_64KB_S came out 4 KiB
instead of 64 KiB, a 32x32 RGBA8 linear texture 4 KiB instead of 8 KiB.

Pass the title's layout word to console_texture_layout in
console_placement and apply_console_placement, as the unordered-access
rule already does.

Found by kevincommits (#1608).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 18:09:12 -06:00
427ec8426b runtime: wire Round 2 fast-paths, atomic batch uploads, and review fixes
AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-27 18:27:12 -05:00
34173ab04b runtime: Stage 4 same-queue submit merge, async geometry epoch, and O(1) floor 2026-11-27 17:53:44 -05:00
a23273b5c0 d3d12_xs: CreateSamplerX writes through, and mapped heaps take bound tables
Two gaps in mirroring title-backed descriptor heaps on the Xbox console path:

- Xbox device slot 61 (CreateSamplerX) created the sampler in the real heap only. Every other
  descriptor creator and copier also stores the result at the title's address (local_write_through),
  so a title that copies samplers out of its own heap memory read zeros. Slot 61 now writes through
  as slot 22 does.
- local_mirror_table, run when a descriptor table is bound (list slots 35/36), checked the real range
  with VirtualQuery even when it is a mapped range. Wine can report a live vkMapMemory span as
  MEM_FREE, so on Wine the table was never mirrored. It now skips the check for a mapped range, as
  local_write_through does.

From kevincommits' finding in #1608 (item 2). xs_proxy_mock_test gains check_descriptor_mirror, with
the mock's real heap pointed at memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:38:27 -06:00
038980a387 d3d12_xs: avoid full registry walks when unwrapping objects
(cherry picked from commit 95621062dfe5a3d5337e9f7d789d25faea8b53cf)
2026-11-27 12:52:37 -06:00
10eb178253 d3d12_xs: keep child proxies alive during queue calls
(cherry picked from commit f6586decf7e5e0b26c084825b3bd26a760bf6c67)
2026-11-27 12:52:37 -06:00
adc74d5d65 runtime: per-frame CPU line and the floor of an unchanged submission, beside the submit phases line
Two always-on lines every LEONIDA_SUBMIT_FRAME_SECONDS (10 by default, 0
off), from the counters the phase line already keeps and a few more:

[rt] submit frame: frames presented and, per frame, the submissions by
queue kind and the milliseconds the title's threads spent in the layer:
the existing phases counted per frame instead of per submission, plus
what the phase line leaves out - ExecuteCommandLists outside the phases
(list unwrapping, the console's list-value waits and writes, the queue
lock), the queues' Signal and Wait, and the present. Inside those, the
vkQueueSubmit calls and waits for contended submission-path locks are
given apart. Then the window's worst frame and the time of our own
threads per frame: the submit worker (LEONIDA_SUBMIT_ASYNC), the texture
read threads and filler, the console heap resolver, the geometry
refresher, the list values' pump and releaser, the fence callbacks.

[rt] submit floor: how many submissions changed nothing (no heap slot or
page, shadow page, geometry, texture fill or pipeline build), their
average and least cost and their phases, against all submissions.

Title calls are timed once, at their outermost entry, less the phases
inside them; a WorkerScope marks our own threads so their phases are not
counted as the title's. A frame ends at each present the presenter takes.

submit_frame_test checks a scripted run on the CPU (frame sums, title and
own threads, worst frame, floor) and, with a Vulkan device, that the floor
of 20 empty submissions through VulkanQueue sums to exactly what the
phase totals grew by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 05:19:48 -05:00
b54413e879 xmem: slot-31 copies onto a paired range make no host call; the host reads and writes those pages through the frame table (RT-MEMORY-MODEL)
Step 2 of the memory model. After step 1 the console queue's CopyPageMappingsBatchX gave a paired GPU-only page its
physical page by table, but still host-mapped the paired CPU page (the "twin") for the D3D12 layer and DirectStorage,
which read and write GPU-only memory there: one unmap plus MapViewOfFile3 per page through Wine's server. In the newest
local world run that was 47% of slot 31's pages and most of its 1.7-2.5 s of mapping per 10 s. By the log every host
remap was such a twin (pages by table minus pages by host equals the twins the title mapped itself, which are kept);
destinations with no CPU pair were none.

Now the twin is a table page too (map_table_page), and the host reaches table pages through their frames:
- src/title_frames.h: xmem's lookup (page -> its section's scratch view, held alive), its peers, monotonic bounds so
  other memory costs two loads, and for_each_part / run_end to split a range into table and host parts.
- xmem: g_table_frames under its own SRW lock (readers never wait behind g_phys_mutex), g_page_tables per physical
  page. A table page is aliased, its alias peers being its physical page's host views (note_mapping keeps them in
  step), so #1867's alias cells guard it where the title's CPU can write it. The title's unmap of a table page now
  tells its readers. transfer_physical pins and notifies table pages too.
- Readers: copy_guarded, texture_memory_readable, readable_page / readable_run_end (stream-pool extents),
  to_host_view, the ShadowPages walk and fill (a table page is read like a read-only page that is not the tracker's,
  clean while its cells are; a block with no host view anywhere is armed on its own cell), the geometry provider,
  the title buffers for vertex and index views, raw sampled surfaces, console value reads.
- Writers: kernel_writes::write and store write the frame and pin its peers; read_file reads into a bounce buffer
  first. DirectStorage goes through these.
- The slot-31 line keeps "pages N by table, M by host remap" and adds the paths behind them.

Not through the table: imports (a table page has no host pages; such buffers are shadows), GPU write-back into a
table page (left out like every aliased page; per-frame write-back is step 6), the LEONIDA_MAP_READBACK diagnostic,
the fsdraw and compute-input probes (host pages only), the batch hook's LEONIDA_SLOT31_CPU_TWIN mirror (not installed
in retail runs), and the title's own ReadFileEx/ReadFileScatter (the title has no CPU mapping there on the console).

Tests: title_frames_test (portable); xmem_test copy_page_mappings_cpu_view (no host view at either page, no host map,
reads and host writes through the frame, a write through the title's own mapping seen, remaps, kept twins, views
replaced once); d3d12_xmem_placed queue_remap_default_route (slot-133 buffers over the GPU-only pages and the twin read
them, a guarded title write through the pool's own mapping and a remap reach the GPU, no host remap).
Linux ctest (llvmpipe) 119/119; Wine suite on the iGPU against main e5a7c8942: no pass-to-fail (432 pass, the same 23
failures).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 18:52:44 -05:00
04e60ec7cb Local test merge: value waits held until met (458a2805d)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:37:55 -05:00
458a2805df d3d12_xs: hold console value waits until met; release only when nothing else can make progress
A list value wait (wait32/wait64) that is not met at submission holds its queue until memory meets it. The fixed
200 ms timeout, LEONIDA_VALUE_WAIT_TIMEOUT_MS and the 4 ms demotions are removed (in Linux world runs 14-63 gates a
run timed out with the writer's value not there yet).

A held gate goes without its value only when nothing else can make progress (releaser idle, no title
ExecuteCommandLists in progress, nothing of the pump's running on the GPU; work the layer holds behind a wait is not
running, asked through the new rt::d3d12::fence_signal_submitted), and then only: in a cycle (at once), at a present
queued behind it (VIctory-Belobug-AMD's rule, queue/behind.rs step, queue.rs release_held), or when the title has made
no queue call for 2 s; every gate goes at device loss. src/list_value_progress.h (portable) replaces
list_value_wait_budget.h. Each release is logged with gate, queue, wait and reason; released waits met later are
counted. stop() drops gates it leaves shut so they no longer hold their queues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:37:42 -05:00
8f606046f4 xmem: slot-31 page copies onto a paired GPU-only range are table updates, not host remaps (RT-MEMORY-MODEL)
The console queue's CopyPageMappingsBatchX goes through xmem's range callback in a retail run. It host-mapped every
destination page of a paired GPU-only range twice: the GPU-only page and its CPU twin. Each map is a VirtualQuery, a
placeholder split and a MapViewOfFile3/UnmapViewOfFile2, which are wineserver round trips under Wine. All of it ran on
the render thread under g_phys_mutex, which DirectStorage's page transfers take too. A local world run spent 3.9-6.0 s
mapping per 10-12 s.

Nothing on the host reads a GPU-only address of a paired range:
- the D3D12 layer, DirectStorage and the texture refresh read the CPU twin (title_gpu_views::to_cpu);
- the runtime reads a page by number through its section's scratch view (host_page);
- the title's CPU never touches the range (PAGE_NOACCESS on the console).

So such a page now gets its physical page in g_mapped and g_table_pages alone, with no host view, as the console edits
GPU page tables only. The twin is mapped as before, and so is a destination with no CPU pair: an independent-pages
range (LEONIDA_SLOT31_RUNS), whose pages are read where they are.
- A view the title mapped there itself is unmapped once when a copy lands on it.
- unmap_range_locked drops table pages in its range, so the title's own unmap or release clears them.
- A table page is not one of its physical page's host addresses (no note_mapping, no alias peer). It can be neither
  written nor guarded on the host, so a twin plus a GPU-only page is no longer "aliased" for the slot-133 shadows and
  the geometry watch.
- A table update raises title_memory_map::changed and geometry_writes::notify(replaced) for the GPU-only address, as
  a host remap did. A remap changes bytes, not what a V# resolves to, so the slot-record change list is not involved.
- The periodic slot-31 line gains "pages N by table, M by host remap" (slot31_mapping_counts).

Tests (Wine):
- xmem_test, test_copy_page_mappings_cpu_view: no host view on the GPU-only range; one host remap per page, not two;
  a copy from a GPU-only page finds what its table entry holds; a page the title mapped there is replaced by a table
  entry; the title's unmap clears the table.
- d3d12_xmem_placed, queue_remap_default_route: it read the GPU-only pages directly (the old behaviour). It now reads
  them through a slot-31 copy and checks that they have no host view.

Wine suite on the iGPU: 425 pass / 23 fail, the same as main e5a7c8942, nothing changed. Linux ctest on llvmpipe:
115/115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:33:58 -05:00
63c4978d2a Merge #1972 from kurrutako: a slot-31 copy leaves the title's own mappings at the paired CPU range (RT-SLOT31-CPU-TWIN-TITLE-PAGES)
Head 28fc0262d. Closed by its author as incomplete; merged because world run 41 had it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:32:25 -05:00
2f18a46e71 d3d12_xs: LEONIDA_UPLOAD_ALIAS=1 enters upload chunks in the title VA table
An experiment for descriptors the title builds from AllocateUploadMemory pointers (the console's memory is
unified, so the CPU pointer is also its GPU address): each upload chunk's CPU range is entered as an alias
of the chunk's console VA (device address minus heap_base), so the in-place V# rewrite before each
submission reaches the chunk instead of writing an empty V#. Removed with the upload state. Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:51 -05:00
b186d7c45c d3d12_xs: LEONIDA_UPLOAD_LOG=1 logs upload chunks and AllocateUploadMemory offsets
A diagnostic for descriptors that hold pool offsets: each upload chunk (CPU base, device address, size) and
the first 96, then every 8192nd, AllocateUploadMemory result as an offset into its chunk, to match with the
addresses in the title's T#s and V#s. Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:51 -05:00
b3e541b224 d3d12_xs: drop the null-RTV marks of a descriptor heap when it is released
The null-view marks (#1504, by ubiquitarianism) are kept by the real CPU
handle. They were moved by descriptor copies and cleared by a view made
with a resource, but never dropped when the heap went away, so an RTV heap
made later at the same address inherited stale marks and its clears were
skipped. The heap proxy now records an RTV heap's real CPU range and
heap_release drops the marks in it. The barrier conversion keeps no state
across calls, so it needs nothing here.

xs_proxy_mock_test: an RTV heap's marked view is skipped while the heap
lives and cleared after it is released; a mark outside it stays; a second
heap at the same address starts unmarked and marks again. docs/d3d12_vulkan.md
says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:03:00 -05:00
8d686309b0 Merge main into integration/boot-combined (RT-BOOT-COMBINED)
Conflict in runtime/shims/d3d12_xs_device.cpp, proxy_copy_descriptors_simple:
keep this branch's copy_null_rtv_marks call and main's fsdraw::enabled()
gate for the descriptor-copy diagnostic.

tools/rdna2spirv.py merged without a textual conflict, but #1662 on main
calls restore_dot4_inline_sel in the exact re-anchoring path, which this
branch had deleted. The merge puts main's function back so that call
resolves; the next commits reconcile it with the dot4 op_sel rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:49:53 -05:00
7551c8aa8c Merge branch 'fix/rt-null-barrier-clear-v2' into local/boot-combined
# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
2026-11-25 16:06:44 -05:00
9f98dcc617 Improve post-load GPU memory and pipeline handling (RT-POST-LOAD-GPU-MEMORY)
Fall back to a dedicated buffer allocation when the shared arena fills.
Update console descriptors and resource backing, preserve pipeline cache
entries, and replay mesh records using bounded indirect arguments. Keep
scripted input available until read and cover the runtime and translator
paths with synthetic tests.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 14:30:51 -06:00
28fc0262d2 d3d12_xs, test: say which route slot 31 remaps through; cover the retail route
queue_copy_page_mappings logs once whether CopyPageMappingsBatchX goes to an
installed batch hook or to the default adapter over xmem's range callback
(copy_page_mappings_fn), so a boot's read-fault reports can be matched to the
implementation the tests cover. Nothing in the runtime installs a hook, so a
retail run takes the default adapter.

d3d12_xmem_placed_test gains queue_remap_default_route, for that route: no
hook, a legacy-paired GPU-only destination, and a GPU-only pool backed only
through its CPU alias. The title maps a page of its own at one CPU twin while
the remap waits behind queue work (deferred with list values, waited for with
LEONIDA_LIST_VALUES=0), so ownership is checked when the remap is applied.
After the copy the GPU-only pages hold the pool's bytes, the other twin follows
them and the title's page keeps its bytes; after an unmap the GPU-only pages
and the mirrored twin are reserved and the title's page still holds its bytes.
On the code before this pull request the title's page check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:04:43 +01:00
e86b3ceaa8 d3d12_xs: LEONIDA_TITLE_HUD shows frame rate, memory and pipeline compiles in the window's title bar (RT-TITLE-HUD)
A tester has no way to see, during a boot, whether the game is slow because of frame time, memory pressure or
pipelines compiled in the frame. With LEONIDA_TITLE_HUD=1 the window the title presents in gets, twice a
second:
- fps and the average and worst frame time from PresentX;
- private memory and working set;
- local GPU memory against the DXGI budget, and shared GPU memory;
- pipelines created and the seconds spent in vkCreate*Pipelines in the last interval (with
  LEONIDA_MEM_PROBE);
- time since the first present.

A thread of its own sets the text with SendMessageTimeout, so a busy or hung window thread never holds a
present. title_hud_test drives a real window from another thread and checks the text and the shutdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 20:51:50 +05:00
94ba78348e d3d12_xs: slot caller via a formatter hook, cleared on reset (review of #9990)
- The proxy no longer calls rt::shims::module_offset itself: gta6rt sets it
  with set_device_slot_caller_formatter; with none set the address is shown
  in hex, so xs_proxy_mock_test links d3d12_xs_device.cpp alone as before.
- reset_device_proxy_stats() clears the stored caller with the first-call
  flag; xs_proxy_mock_test checks call -> caller -> reset -> empty -> call.
- The accessor comment says which slots it covers and that it is a
  diagnostic observation (flag set before the caller is stored).

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:33:54 -03:00
f1119e2906 d3d12_xs: the first call of a forwarded device slot names its caller (RT-526)
The first call of every Xbox device slot the proxy forwards by number now
logs the title code that made it as module+offset, and
device_slot_first_caller(slot) returns the same text. Finding a new
Xbox-only slot in the executable no longer needs a debugger.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:33:36 -03:00
924966e2fb Adapt #622 to #1723: its arena and xmem writes become the list values' fallback
#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 <noreply@anthropic.com>
2026-11-25 06:43:13 -05:00
f3bfc039b2 Merge #1723 (post-story runtime) into #622 (list value writes)
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 <noreply@anthropic.com>
2026-11-25 06:24:18 -05:00
d0b0b453f1 Merge main into integration/post-story-runtime (#1723), with #1558
runtime/test/xs_proxy_mock_test.cpp: main added check_depth_provider_refusal()
next to check_placed_resource_x() (#1558); this branch added the list-values
checks, which must run last because they start and stop the list-values
threads. Both kept, the list-values checks still last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:21:12 -05:00
59c54c1eb0 d3d12_xs: list slots 71/72 have one writer, the list values, when they track the list
Found by the comparison agent, not by a failing test. #1723's console
list slot path still handed slots 71 and 72 to main's GPU-label hook
(record_gpu_label, LEONIDA_GPU_LABELS) when its own list values track
the list (track_values, on by default with LEONIDA_LIST_VALUES). The
--first-run-ui profile sets LEONIDA_GPU_LABELS=1 (runtime/src/main.cpp).
With both on, two threads stored to one title address, one from a
Vulkan command buffer's completion and query, the other from the part's
fence and a D3D12 timestamp query. A late label could rewind a rising
counter or split a begin/end pair. The suite did not catch it:
xbox_gpu_label_completion submits its real list straight to the queue,
so only the label path landed there.

The list values are the right owner. They land slots 71 to 74 in
queue order behind the gates, and they also do the waits the labels
cannot do. Now:
- The label hook runs only for a list the list values do not track
  (LEONIDA_LIST_VALUES=0, bundles). Each handoff is counted in
  ListValueStats::labels_handed.
- The --first-run-ui profile no longer sets LEONIDA_GPU_LABELS.
  runtime/README.md and docs/first_run_ui.md say so.
- xbox_gpu_label_completion runs its label section with the list values
  off, as it always measured the label path alone, and checks that all
  five writes went there. A new section turns both on and records one
  write32 and one write64 on a tracked list, submitted through the queue
  proxy. Each lands exactly once: writes_landed == 2, labels_handed == 0,
  and the values are in memory. With the old condition this section
  fails at line 136 (labels_handed was 2), on llvmpipe and the iGPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:16:46 -05:00
bcaa13dad3 Merge pull request #1558 from ubiquitarianism/claude/d16s8-uav-nvidia-fallback
Merging.

**Why merged**
- Fixes the NVIDIA startup stop that #939 introduced. Slot 133 asks for a D16S8 (format 118) depth texture with unordered access. On NVIDIA, `pc_format()` maps it to D24S8 and the depth provider refuses UAV on that, so the boot died early. With this PR the refusal is logged once and the texture is made without UAV, i.e. the pre-#939 stand-in.
- Independent real-boot confirmations past the stop, each against the same build without the PR stopping there:
  - RTX 4070 SUPER, Windows 11;
  - RTX 5060 Ti, Windows 10 (Snooozs);
  - RTX 3070 Ti, Wine 11.22 (djrolfes);
  - RTX 3080 Ti, Wine 11.17 (slauko: 603 s, no exception);
  - RTX 3090, Proton (azsekazvamdimitar).
  - On AMD (adrianmjim, RX 7900 XT) the native path is untouched and the related tests pass, including a GPU without D24S8 that falls back to D32S8.
- Re-tested here merged onto 3de22a190 (after #1547) on an RTX 4070 SUPER, and the merge onto the current main (57ba40bd6, which only adds #1493's translator change) is also clean:
  - fresh RelWithDebInfo build;
  - full ctest 410/411, where the only failure is `d3d12_depth_resolve`, the known NVIDIA MFAA sample-position case fixed by #1505;
  - the PR's 16 related tests pass, also with `LEONIDA_VK_VALIDATION=1`;
  - the consistency set is the same as main.

**Why it's good**
- It's a narrow fallback, used only when the provider refuses. Consoles and GPUs that accept the format keep the native path.
- It comes with tests for the refused and accepted cases.
- It unblocks every NVIDIA tester at the same spot.

**Known and separate:** the slot 133 stand-in leaks about 60 Vulkan objects at device teardown under validation. That leak predates this PR and is reported in #1608. Full D16S8 UAV semantics on NVIDIA remain a follow-up.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-25 05:38:42 -05:00
eedc7c8db9 d3d12_xs: queue slot 31 without a mapper keeps the unmodelled answer
xs_proxy_mock failed at line 4791: on a queue whose presentation is
managed outside (set_presentation_handler), raw(queue, 31, 0) must be
E_NOTIMPL and must not reach SuspendX. #1723's CopyPageMappingsBatchX
dispatch answered every slot-31 call itself, and with no hook and no
xmem (a proxy compiled alone) queue_copy_page_mappings returned S_OK
having mapped nothing.

The test was right. The file's own comment says that without xmem the
slot is refused as before, and check_queue_copy_page_mappings expects
the console-only answer every unmodelled queue slot gets in that case.
The new dispatch now runs only when something can remap (a hook set
with set_copy_page_mappings_hook, or xmem's copy_page_mappings_fn);
otherwise the call goes on to the presentation routes and the
unmodelled-slot answer as on main. With xmem linked, as in gta6rt,
nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 05:31:36 -05:00
ba626820ec Integrate post-story-load memory, queue and Vulkan runtime changes
Preserve physical window aliases across remaps, order console list values,
and replay bounded indirect graphics with captured draw state. Coordinate
pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU
and GPU coverage for the integrated paths.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 03:44:43 -06:00
87e4787c0a d3d12_xs: the state-blob field log line is in English (RT-STATE-BLOB-LOG-ENGLISH)
runtime/shims/d3d12_xs_device.cpp printed "[rt] d3d12_xs: state blob: campo
sin identificar en 0x%03x = 0x%08x", the only Spanish [rt] line; it came in
with #984. It now reads "unidentified field at", as aslan2142 proposed in
the coordination issue (#1608). The format arguments are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:56:22 +01:00
970837c753 d3d12_xs: null-resource texture barriers and null-view RTV clears on the console list
List slot 146 (Barrier -> GCL7 80): a texture barrier with no resource, which
the console takes as a global barrier, is forwarded as a D3D12_GLOBAL_BARRIER
with the same sync and access; a mixed texture group is split into runs in
order, in storage that lives for the call. Calls with nothing to convert keep
the title's pointer. A group array that cannot be read safely (null with a
nonzero count, an unknown group type, absurd counts) is refused whole and
logged once per reason.

List slot 52 (ClearRenderTargetView -> PC 48): the device proxy marks the real
handle when CreateRenderTargetView gets no resource (moved by RTV descriptor
copies, cleared by a view made with a resource), and the clear of a marked view
is skipped, as on the console. Other views keep today's path.

Before this, both calls put the PC list in its error state, so Close failed and
ExecuteCommandLists dropped the submission. xs_proxy_mock_test models that
error state in its mock list and covers both paths; the two old slot-146 cases
that passed garbage words now pass valid ones.

The null-resource barrier and null-view clear behaviour were first reported by luizwidmer/palmetto.
2026-11-25 00:51:27 -05:00