Commit Graph

4163 Commits

Author SHA1 Message Date
55e2bd9e9e Merge pull request #2230 from Tyrannys/rt-indirect-dispatch-group-limit
indirect clamp: bound dispatch records by the device's maxComputeWorkGroupCount, not 65,535 (RT-INDIRECT-DISPATCH-GROUP-LIMIT)
2026-11-26 22:43:12 +01:00
627163c8eb Merge pull request #2407 from aslan2142/vsharp-slot-records
d3d12: console heap slots record what their V#s resolved to; a release re-fixes only the slots naming it (RT-VSHARP-SLOT-RECORDS)
2026-11-26 22:41:53 +01:00
20c46b646c Merge pull request #2406 from aslan2142/bindless-dimension-limits
bindless: size every sampled dimension alike and name a full array as its own refusal (RT-BINDLESS-DIMENSION-LIMITS)
2026-11-26 22:41:22 +01:00
b6873ce3dc Merge branch 'bindless-dimension-limits' into descriptor-refill 2026-11-26 16:39:14 -05:00
be1b4da8a2 Merge branch 'vsharp-slot-records' into descriptor-refill 2026-11-26 16:39:14 -05:00
5d30fcdad3 Merge remote-tracking branch 'upstream/main' into d3d-sample-positions
# Conflicts:
#	runtime/src/vulkan_replay.h
2026-11-26 20:57:16 +00:00
595b1325d9 Merge main (fac8b4bb9) into #2230: keep the device-bound dispatch limit and #2378's unfilled draw records
main's #2378 (a draw record of 2^23 vertices or more runs empty and charges nothing) changed indirect_clamp.comp
next to this branch's dispatch bound. The .comp, vulkan_indirect_clamp.h and indirect_clamp_test.cpp merged without
conflicts and keep both changes. The only conflict was the generated indirect_clamp_spv.h: it is regenerated from the
merged indirect_clamp.comp as its header comment says (glslangValidator 16.6.0, -V --target-env vulkan1.2 -Os
--spirv-val; spirv-val passes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 15:05:45 -05:00
7d5d820779 bindless: size every sampled dimension alike and name a full array as its own refusal (RT-BINDLESS-DIMENSION-LIMITS)
World runs fill one bindless image array a few minutes in: `a bindless image array is full; dimension 3: 4096
indices, 4092 T#s of 4090 textures`. Dimension 3 is 1D (ImageDimension: 2D, 2D array, 3D, 1D). From then on every
new 1D T# reads the fallback's zeros, and the console heaps count it as "no view for the T#'s format or range",
which went from 2-28 a window to over 4000.

Nothing leaks: the 4096 indices are the fallback, 4092 entries of image_entries and 3 replaced views, every one
held by a texture the runtime still has registered, and a texture's indices go back when it goes (forget_image,
the deferred bindless_slot release, remove_image). The cause is the size: size_bindings grew 2D images to 65536
but 3D and 1D only to 4096 and 2D arrays to 16384, constants that guessed how many textures of each dimension a
title keeps, whatever the device holds (RADV allows 8388606 sampled images, llvmpipe 1015808).

- vulkan_bindless.h: one maximum (max_images, 65536) for the sampled array of every single-sample dimension, in
  place of max_2d_images, max_2d_array_images, max_3d_images and max_1d_images. The 2D-array, 3D and 1D arrays
  grow together after 2D and the storage arrays, so on a device whose limits stop growth earlier none of them is
  favoured. The bound is memory (each generation's pool holds every element): 325729 descriptors on an RTX 5070,
  10-20 MiB at 32-64 bytes a descriptor. The shaders declare runtime arrays, so no shader changes; the set layout
  changes, so compute pipelines get new journal names (hash_bindless_layout) and the pipeline cache is rebuilt.
- BindlessSet::image_refusal says why add_image returned 0: no array for the dimension, the array is full, or only
  its shorter storage range is.
- d3d12_vulkan_device.cpp: bind_image_locked and bind_image_views_locked report that reason; bind_title_image
  counts it ("the bindless array of the T#'s dimension is full", or "the bindless storage arrays of the T#'s
  dimension are full") instead of "no view for the T#'s format or range". The once-per-dimension line names the
  dimension, the storage range and how many of the textures holding indices are still registered at their address.
- docs/d3d12_vulkan.md: the sizes, and the new reason.

Tests: bindless_sizing_test checks RADV's and llvmpipe's limits (every sampled dimension at 65536; on main 1D and 3D
stop at 4096) and that the three dimensions share a short budget alike. vk_bindless_dimensions_test (new, GLSL
shader) sizes a set from the device, gives 5000 live 1D, 2D-array and 3D images an index each and reads every one
through its index, then fills the rest of the array: the next is refused as full, and removed indices come back at
once or, after an erased key, at the next flush. On main it fails at "1D: 4096 indices in the set".
vk_bindless_test's index-space case filled 1D expecting the first index to be 1, which held only while the 1D
array was as short as its storage arrays; it now checks every index once and that indices above the storage arrays
go first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 14:48:57 -05:00
84db5cd027 d3d12: console heap slots record what their V#s resolved to; a release re-fixes only the slots naming it (RT-VSHARP-SLOT-RECORDS)
After any arena release, title-window or geometry block destroyed, or alias change, the next submission walked
every live V# slot of the console heap (about 580,000 in world runs), reading each from the copy in ReBAR VRAM:
1.1-1.5 s a walk whatever the scene, about 2.9 s of a 4.6 s frame. It existed only because nothing recorded
which slot resolved into which backing.

Each V# half of a console resource heap's copy now has a record in host RAM (src/console_heap_slot_records.h):
the title's base and span, the device address its copy names, and whether it resolved or waits. Two indexes
(by base, by target; per power-of-two span class and 64 KiB-or-larger granule) find the halves near a range.
fix_console_slot, the only writer of a slot's copy, writes them; a zeroed range, a deferred slot and a
rewritten slot drop theirs; a destroyed heap takes them with it.

Releases (backing(), title_block_gone), alias ranges removed or replaced (TitleVaAliases tells its listeners
as it happens, forget_copy included) and additions (backings, alias ranges, title memory) go on an unbounded
per-device list. refresh_console_heaps takes it whole; every heap re-fixes exactly the slots it touches: a
release or removal every half naming the range, an addition the waiting halves over it. A new heap log line
gives the changes, slots looked at, slots fixed again and ms per submission.

Removed: the live_vsharps walk and its bitset (console_heap_vsharp_slots.h and its test), the release
generation checks (released_backings, TitleVaAliases::invalidations), LEONIDA_CONSOLE_RELEASE_FILTER, the
4,096-entry DescriptorRangeChanges ring with its full-sweep overflow and changed_ranges(), the empty-slot probe
and retry_unmapped_slots (unreachable: nothing set its flag). LEONIDA_CONSOLE_GPU_FILTER now defaults to unset
instead of the removed variable's value. The T# retries (retry_console_slots) stay.

Tests: console_heap_slot_records_test (portable): releasing a buffer 10 of 60,010 slots name looks at 10
entries and fixes 10 slots; an alias moved, removed and added back; overwritten and zeroed slots; partial
overlap; two slots on one backing; a buffer back; a refused alias copy backed later; a large span; a destroyed
heap; and 400 random rounds compared with a full re-resolution of every slot. d3d12_unmapped_vsharp_test now
expects all 128 waiting slots restored at the first submission after their alias comes (was: 16 by the probe in
64 submissions), none after it goes, and the slots naming a released buffer null. title_va_alias_test and
geometry_views_test check the listener in place of the ring.

Linux ctest 113/113; Windows suite under Wine (clang-cl, iGPU, RADV) equal to main 2d43417d4 test by test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 14:47:29 -05:00
aaff77b831 mem probe: a breakdown line of the runtime's Vulkan memory by consumer (RT-MEMORY-BREAKDOWN-AND-SPARSE-ARENA)
The `mem-probe t=` line sums our vkAllocateMemory bytes per memory type, but not who holds them: in a late world
run 7.5 GB of device-local memory and up to 1.2 GB of the Resizable BAR type could not be attributed. Every tick
now also prints

  [rt] mem-probe breakdown t=<s>: allocated N MiB = arena A (n) [reserved, bound, in use: buffers, descriptor
  heaps, shader code, heaps] + geometry copies + title windows and shadows + upload heaps + staging + texture
  blocks + sampled textures + render targets and depth + other; imported M MiB; not in the total: bindless
  tables, shader modules, pipelines and swapchain images

whose parts add up to the allocated bytes of the t= line. Diagnostic only: nothing changes what is allocated or
where, and with LEONIDA_MEM_PROBE unset nothing is installed.

- src/memory_breakdown.h (new, standard library only): the consumers, an Owner scope (thread-local) that names
  the allocations a thread makes while it lives, the tally and the line's text.
- src/mem_probe.h: the vkAllocateMemory wrapper records the thread's owner; vkCreateImage/vkDestroyImage/
  vkBindImageMemory are wrapped too, so memory nobody named that a dedicated image is bound to counts as a render
  target or depth buffer (attachment usage) or a sampled texture. Named blocks keep their name.
- Owner scopes at the allocation sites: the arena (create_arena), geometry copies (GeometryViews' pool), title
  windows outside the arena and slot-133 shadow buffers with their own memory, upload/readback heap buffers,
  texture staging and copy scratch, and the texture blocks (ImageMemory, TitleImagePool).
- The device adds the arena's reserved, bound and in-use bytes (by kind) and the bindless table bytes, read under
  the arena's and the descriptor locks; BindlessSet allocates through its own function table, so its bytes are
  shown beside the total, not in it.
- runtime/README.md: LEONIDA_MEM_PROBE's row names the three lines.

Test: memory_breakdown_test (CPU): the tally sums to the total with imported memory kept apart, owner scopes nest
and stay on their thread, image usage picks the kind, and the text lists every part. It does not build on main
(the header is new).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 14:31:34 -05:00
3b5b36edd1 Merge remote-tracking branch 'origin/main' into fix/pso-stream-view-instancing 2026-11-27 02:19:16 +07:00
3ae707cede d3d12_xs: capture a pipeline stream that carries a VIEW_INSTANCING subobject
The stream parser that decides creation models `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING`: it refuses a
non-zero `ViewInstanceCount` and accepts the subobject with a count of 0. The capture walker that keeps a stream for
derivation (`layout_of` in `shims/d3d12_xs_pso_stream.cpp`) did not model it, so that same stream created a PSO and
was never captured. The PSO then carried no `PsoStreamRecord`, and every `CreateDerivedPipelineState` on it failed
with E_FAIL ("base PSO has no kept stream"), which is a silent loss of the derived states the title asks for.

Model the subobject's size and alignment in the capture walker. Only the count == 0 shape reaches it (a non-zero count
is refused before a PSO is created), so the payload's `pViewInstanceLocations` is never read: the walk needs the
entry's own size and alignment to step over it, nothing more.

`pso_stream_test` gains `test_view_instancing_is_captured`: a synthetic stream built the same way as the existing
cases, plus a zero-count `VIEW_INSTANCING` entry, must be captured, keep the entry's payload offset, and still derive a
tag-1 record. It fails on `main` ("a stream with a zero-count VIEW_INSTANCING subobject is captured") and passes with
this change.
2026-11-27 02:15:36 +07:00
7ffcb8e260 Merge upstream/main into input-out-of-the-box
docs/gameinput.md conflicted on two passages, both kept:
- main's new LEONIDA_INPUT_FILE paragraph, with this branch's sentence on
  make_game.py running build_runtime.ps1 with -FetchSdl3 (and --no-sdl3)
  added to main's wording of the build paragraph;
- the settings table keeps this branch's LEONIDA_KEYBOARD_PAD default (1,
  focused; off removes it), which gameinput.cpp reads, and takes main's longer
  LEONIDA_INPUT_SCRIPT row (button@seconds:hold, the six-reads rule), saying
  "on unless LEONIDA_KEYBOARD_PAD=off" for the keyboard pad.

No code conflicted. Tested: full ctest, 113 of 113, on Linux (the portable
subset; the gameinput shim is Windows-only).

Changes made by Claude Code (AI-assisted).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
2026-11-26 18:59:07 +00:00
2d43417d49 Merge pull request #1647 from OreoFR/shader-vopcx-dpp
rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP)
2026-11-26 19:54:03 +01:00
e57bc63bc5 Merge pull request #2378 from kawaii-shakal/indirect-draw-unfilled-count
indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT)
2026-11-26 19:43:11 +01:00
f107ae0446 Merge pull request #2395 from aslan2142/integration/tls-exit-and-scripted-input
[integration] Runtime: the EXE's thread-local exit callback (#2315) and scripted input between reads (#2372) (INTEGRATION-ZRO-DRAFTS)
2026-11-26 19:30:07 +01:00
bbf861fbb4 Merge main into fix/depth16-quantise-fallback
runtime/CMakeLists.txt: main added the heavy_pipeline_cache, pipeline_cache_journal and compile_helper tests where this branch adds depth24_fragment; both sides are kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 13:17:55 -05:00
657808a7df gameinput (no SDL3): take the script's changes between two reads at their own time instead of a clock thread (maintainer fix on #2372)
#2372 started a detached thread that took the input lock every 8 ms, so that a scripted press that begins and ends
while the title is not reading reaches the reading history. That works around the cause and adds its own: the
history then depends on how the host schedules a Sleep(8) thread (a slow or loaded machine keeps fewer edges, and a
Windows timer tick of 15.6 ms drops a short hold), the thread never ends, and it contends with the title's reads.

The cause is that update() looked only at the state at the moment of the read. It now first adds a reading for every
start and end of a press since the last update, stamped with the script's time, then the state at the read: the
history is the same however often the title reads, on any machine, and no thread runs. The press log lines carry the
script's time of the press.

Also: LEONIDA_INPUT_TRACE (added by #2372) is documented in docs/gameinput.md and runtime/README.md, as
tests/test_docs_env_vars.py requires. gameinput_no_sdl_script gains y@10, which the title never reads while it is down
(reads at 4.5 s and 60 s): the press and its release must be in the history with their own timestamps. On main the
history has no Y reading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 13:17:06 -05:00
48f87a9c9b process: call the EXE's thread-local destructor callback with its real signature, before the atexit handlers (maintainer fix on #2315)
#2315 kept `_register_thread_local_exe_atexit_callback` away from the host UCRT, which fast-fails a second
registration in the process (gta6rt's own startup makes the first). Review points fixed on top:

- The callback is a `_tls_callback_type` (UCRT process.h: `void (__stdcall*)(void*, unsigned long, void*)`), not
  `void (*)()`: vcruntime's TLS destructor callback reads its reason argument, which was left as whatever rdx held.
  It is now called as `(nullptr, DLL_PROCESS_DETACH, nullptr)`, as the UCRT does.
- `exit` and `_cexit` call it before the atexit table, as the UCRT does: the leaving thread's thread_local objects end
  before the static ones ([basic.start.term]). #2315 ran it after the static destructors, and not in `_cexit`.
- The extra call on every thread detach is dropped, with the per-thread flag and the loader's include of the process
  shim: the loader already calls the same function from the executable's TLS directory with DLL_THREAD_DETACH, and
  the UCRT never calls the registered one there. The call after a returning entry point is dropped too (MSVC's
  mainCRTStartup calls exit itself).
- run_tiny_atexit gains thread_local_exit and thread_local_cexit: a thread_local object of the main thread must end
  before the handlers and destructors. On main the --run path never ends it (Wine) or stops at the second
  registration (Windows).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 13:15:17 -05:00
76109561f4 d3d12: --precompile-pipelines builds the skip-listed programs unless --skip-listed
LEONIDA_SKIP_COMPUTE is a play-time setting: the game drops the listed programs' dispatches. The precompile also
refused to build them, one "not built (LEONIDA_SKIP_COMPUTE)" line each and no override. Players run it with the
game's environment (docs/running.md), so their skip list kept those programs out of the journal for good, and a later
run without the list compiled them in the game.

- precompile_compute_pipelines builds every compute entry; with the list set it says how many entries it names.
  --skip-listed leaves them out on purpose, one line each.
- The last line counts the whole run: built (compiled, from a cache), journaled already, being built by another
  process, failed; left out: of those the list names, not buildable, filtered out (--filter, the size bounds and now
  --limit too).
- BuildHost::unbuildable no longer checks the list. The compile server checks it itself, as before: the game that
  starts it drops those dispatches.

Docs: running.md, linux_proton.md and d3d12_vulkan.md no longer give compile time as the reason for the skip list.
The 89-167 s per program came from wave64-emulated packs; with a native wave64 pack on an RX 7900 XTX (RADV, Mesa
26.3.1, Wine) all 721 library programs of 2 MiB or more built, 360 of them in 170 s on 32 threads, 2.5-32 s each, the
largest (13 MiB) in 28.5 s alone, at a peak of 14 GiB of RAM. Two world runs on that card with all of them journaled
and no skip list took them all from the journal and got no further than runs with the list (a stop with the GPU
idle at 404 s; an idle-queue device loss at about 214 s, which also happens with the list set). Their output is
not checked, so the docs keep the skip list and LEONIDA_RT_AS=off as the setting of our longest runs.

Test: precompile_skip_list (test/check_precompile_skip_list.cmake) precompiles two synthetic compute modules, one of
them listed, three times: with the list set both are built; with --skip-listed only the other one is, and the listed
one is named; a second run into the first journal finds both journaled. It fails on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 12:40:56 -05:00
b59ff42107 Merge main into shadow-keep-gpu-writes: main removed the console heap mirror test (#2370); the shadow_keep test stays
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-26 17:54:55 +01:00
8e3f4c6b82 test: name gta6rt's TLS callbacks from the linker map
Link gta6rt with /MAP and read gta6rt.map to name each TLS callback.
Fail on the C++ runtime's __dyn_tls_init (tlsdyn.obj) and __dyn_tls_dtor (tlsdtor.obj), allow Rust std's thread-local callback, fail on the rest.
A callback the map does not name, a missing map or a stale map fails with a message.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 17:51:01 +01:00
694ba09ffa console_heap_gpu: fix erase_overlapping overflow and preserve newer slot flags on rollback (CONSOLE-HEAP-GPU-OVERFLOW-AND-ROLLBACK) 2026-11-26 17:45:26 +01:00
71f54be482 shadow keep: a newly filled target brings its pieces to the other targets and the sums (review by lixonik)
The sums stand for what every target holds. fill() gave a new target the title's current bytes while the sums kept
the bytes the other targets were refreshed with, so a title that wrote the old bytes back before the next refresh left
the new target behind (no piece differed from its sum). fill() now compares the filled range, widened to whole pieces,
with the sums as a refresh does: the pieces that differ are copied to every target over them and their sums updated.
New test d3d12_shadow_keep_refill (and _off with LEONIDA_SHADOW_KEEP=0): the reviewer's sequence, two overlapping
targets; it failed before this change (A held 1, B held 2) and passes now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-26 17:41:55 +01:00
935a2cd5b6 Merge pull request #2222 from DadaCap/xdxr-update-source-check
xdxr: check the update source and bound the builder's reads (RT-XDXR-UPDATE-SOURCE-CHECK)
2026-11-26 17:41:06 +01:00
d5634defe4 Merge pull request #2359 from DadaCap/xgamesave-unpadded-read
xgamesave: a blob read accepts the unpadded buffer size (RT-XGAMESAVE-UNPADDED-READ)
2026-11-26 17:29:15 +01:00
6b281fc25d Merge remote-tracking branch 'origin/main' into feat/pipeline-order-recorder
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-26 17:16:30 +01:00
61c681e47d Merge remote-tracking branch 'origin/main' into test/gta6rt-no-tls-callbacks 2026-11-26 17:08:08 +01:00
b0767fd657 d3d12, xmem: remove remap release and the console heap mirror
Both came in with #2350 as additions on top of stopgap mechanisms, broke world runs (remap release: a GPUVM page
fault and a lost device; the mirror: a GPU hang) and were made opt-in by #2356. They go completely; with both
variables unset, main behaves as before.

Remap release (LEONIDA_GEOMETRY_REMAP_RELEASE, from 36771ec53):
- xmem.cpp: RemapReleases, remap_releases_enabled() and the page recording in unmap_range_locked; the four call
  sites (XMemMapPhysicalPages, the scatter call, both copy_page_mappings).
- xmem.h/xmem.cpp: the test seam rt::xmem::reload_remap_release_setting().
- xmem_test: test_remap_releases (and the title_geometry_watch.h include only it used).
- README row, the docs/d3d12_vulkan.md paragraph; comments that named it.

Console heap mirror (LEONIDA_HEAP_MIRROR, LEONIDA_HEAP_MIRROR_CHECK, from 746059011):
- src/console_heap_copy.h goes. ConsoleHeap::copy is a plain std::uint8_t* again, written with memcpy/memset as
  before the mirror, including the zeroing site that #2350's merge of #2162 resolved as heap.copy.zero(); the
  compute-input probe reads it directly again. Without the mirror, view() was the copy itself, so nothing changes.
- heap_mirror_enabled(), heap_mirror_check_enabled(), check_console_heap_mirror(), the per-heap check counters and
  log line, and the test API console_heap_mirror_mismatches() (d3d12_com.h).
- Tests console_heap_copy, d3d12_console_heap_mirror, _off and _default with their CMake entries; README rows and
  the docs/d3d12_vulkan.md sentences.

Kept, because other paths use them or main's behaviour with the variable unset depends on them:
- LEONIDA_GEOMETRY_HOST and its DeviceState memory-type assert (dc9ef1a0b).
- The final copy at retirement (GeometryViews::retire_range's final_copy, "copied at retirement" in the geometry
  buffers line): XMemFree of a title heap block (free_title_block) reports a release while the block's memory stays
  committed and readable, so that copy is still made without remap release. Comments now say that instead of
  naming remaps; geometry_views_test case 15 stays.
- forget_pool_span and "retired with their copy" in the title memory line: any retirement (free, decommit, unmap)
  feeds it.
- The release queue's joining of touching ranges (title_geometry_watch.h): unmaps report page runs too;
  geometry_views_test case 16 stays.
- LEONIDA_CONSOLE_RELEASE_FILTER, which predates the mirror; its sweep reads the copy again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 10:43:18 -05:00
248b58c42d d3d12: the console heap's host-RAM mirror only with LEONIDA_HEAP_MIRROR=1
The mirror (746059011, in #2350) was on by default. World runs on merged main on an RX 7900 XTX (RADV), the same
settings otherwise:

- remap release on, mirror on: GPU page fault and a lost device about 40 s into the world;
- remap release off, mirror on: no evictions and no page fault, but a hang in a library compute program on the
  direct queue about a minute in, a ring timeout and a lost device;
- both off: past five minutes in the world with no fault or hang, ending where the build before #2350 ended, on the
  title's own breakpoint.

Why the mirror hangs the GPU is not known. It is off unless the variable is 1; the release sweep then reads the copy,
as before the mirror.

Tests: d3d12_console_heap_mirror sets LEONIDA_HEAP_MIRROR=1; a new ctest entry, d3d12_console_heap_mirror_default,
runs the same program without the variable and expects no mirror (it fails on main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 10:28:43 -05:00
d6b97a97b5 Merge main into shadow-keep-gpu-writes: shadow_keep and console_heap_copy tests side by side in CMakeLists
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-26 16:27:35 +01:00
be829a4d64 xgameruntime_gamesave: accept an XGameSaveReadBlobData buffer of the unpadded size
A title sizes the read buffer as the sum of sizeof(XGameSaveBlob), the data and
the name with its NUL for each blob. The shim required the 8-byte aligned layout
and refused such a buffer with E_GS_PROVIDED_BUFFER_TOO_SMALL. The minimum (and
the async result size) is now the unpadded sum; the blobs are packed aligned
when the buffer has room for that and back to back otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-26 16:21:19 +01:00
4a6a8a633e xmem: read LEONIDA_GEOMETRY_REMAP_RELEASE once, with a test seam to read it again
GetEnvironmentVariableA at every remap ran under g_phys_mutex in every scatter call; with it, xmem_test's split race
("the reader of the views' last pages never faults or misreads") failed in two full Wine runs in a row, where main
passed it twice. The value is cached as before #2350's default changed; rt::xmem::reload_remap_release_setting lets
test_remap_releases switch it. Two full runs since: no change against main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 10:05:43 -05:00
1f7cbeff9a xmem: a remap retires geometry copies only with LEONIDA_GEOMETRY_REMAP_RELEASE=1
Since #2350 a remap of physical pages that gives a page another frame retired the geometry copies over it, on by
default. In the first world run of that main on an RX 7900 XTX (RADV) the copies were retired by the thousand
(evicted 15010 in about 40 s) and the run ended in a GPUVM page fault (TCP read) and a lost device; the same build
settings without it ran eight minutes with evicted 0 and no fault.

A remap leaves the address valid on the console, so the title keeps using what names it, and not everything that
names a copy's address is rewritten when the copy goes:

- a root view is resolved while its list is recorded (d3d12_com.cpp, GraphicsCommandList::address); a list recorded
  before the retirement and executed in an ExecuteCommandLists begun after it is not among the replays the
  retirement waits for (kAfterExecutes covers only those in progress), so it reads the freed copy;
- a placed buffer view written outside a console heap carries the copy's address for as long as the descriptor lives.

The remap release is now off unless the variable is 1, read at every remap; the copies follow the new pages through
the refresh, as before #2350. Freeing, decommitting and unmapping still retire copies.

Tests: xmem_test test_remap_releases checks that a remap releases nothing by default and with 0, then the existing
checks with 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:57:50 -05:00
41332d4665 Merge remote-tracking branch 'upstream/main' into indirect-draw-unfilled-count 2026-11-26 14:46:31 +00: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
6d3904860e Merge #2144 from klikso: a scripted press can be held longer, button@seconds:hold (INPUT-SCRIPT-HOLD)
Head 7bd4cec02.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:17:34 -05:00
cb825bb786 Merge #2124 from QemmHD: reads into physical pages wait for the title's Submit (DSTORAGE-HOLD-PAGE-READS)
Head 6b09de493.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:17:29 -05:00
dbe7cf36b4 Merge #2129 from star41905453-coder: a window's GPU writes go back to the title's pages (RT-TITLE-WINDOW-WRITE-BACK)
Head 5fa864e53. The conflict in the title-window members keeps #2129's write-back state and the comment of the geometry copies' retirement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:17:29 -05:00
6a405cdd48 Merge #2162 from abnalstlll-byte: never defer buffer V#s past the console-fix budget (RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP)
Head 2769c5a73. The conflict in fix_console_slots keeps #2162's buffer V# exception and the heap mirror's heap.copy.zero().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:17:01 -05:00
062623063e Merge #2097 from Snooozs: a mesh PSO with conservative rasterization needs no topology type (RT-MESH-PSO-CONSERVATIVE-TOPOLOGY)
Head b986d274b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:16:34 -05:00
0f7868ffad Merge #1957 from IlyassRS3: work-aware timeout clock for console command-list value waits
Head 9520db518.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:16:31 -05:00
399ecdd511 Merge #2044 from BubsMcgee: decode Opus packets through a Rust sidecar (RT-XAPU-OPUS-DECODE), with #1144 from nicoco23: xapu.dll as a command queue (RT-XAPU-CONNECT-LAYOUTS)
Head 4cfbdfc0b, which contains #1144's head 6ee7ef89b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:16:29 -05:00
f5f67b4a9d Merge #2240 from zmasi: sync TitleTexture readability against title_memory_map between passes (RT-TITLE-TEXTURE-MAP-GEN)
Head d088ea79b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:16:27 -05:00
32a04b17f9 Merge #1914 from kawaii-shakal: a pipeline cache for the offline cache's misses (RT-HEAVY-PIPELINE-CACHE)
Head a42bffdc3. The conflict in docs/d3d12_vulkan.md keeps main's session-cache cap (#1886) and #1914's heavy cache text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:16:06 -05:00
25621c61a0 d3d12: LEONIDA_ADDRESS_GUARD=1 keeps the guarded shaders' page table current
The arena keeps [0x70000, 0x80000) for the guard header and its two sinks (in the null region when
LEONIDA_ARENA_NULL_MB makes one). The page table is a host-visible buffer of its own; the header holds
its address minus heap_base, the arena's size and the magic, written last. Before each submission,
after the heap refresh, the windows and the geometry copies, update_address_guard makes the table say
exactly what is backed outside the arena: gpu_backings, the geometry copies' blocks and the separate
window buffers, the same set as the console heap pass's backed table but without its 100 ms limit.
Only changed words are written, level 2 before level 1; a chunk keeps its block for good; past 62
blocks a chunk passes unchecked, which is logged. Refusals the shaders count are logged at most once
a second with the last refused offset.

src/address_guard.h holds the format and the table (address_guard_test); docs/d3d12_vulkan.md 3.3
"Address guard" the design, the cost per access and what is and is not covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:53 -05:00
1156672942 rdna2spirv: --address-guard checks every heap_base access against the runtime's page table
Every Gen.host_addr access (buffer, global_, scalar and BVH loads, stores and atomics) calls one
%guard_fn with its sign-extended 48-bit heap offset, kind and span. Below the arena's size it passes
after a compare; elsewhere the 4 KiB pages of its first and last byte are looked up in a two-level
page table (level 1 by offset bits 47..32, level 2 one bit per page). A refused load reads the zero
area, a refused store or atomic the dump area (an atomic returns 0), and the refusal is counted in
the guard header. Without the header's magic every access passes; without the flag the module is
unchanged byte for byte.

tools/address_guard.py is the Python reference of the table and the check. cs_address_guard is the
fixture of the translator test and of scripts/run_address_guard_gpu_test.py, which runs it on a heap
where every address it touches is real memory, so no run can fault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:52 -05:00
36771ec53d d3d12: geometry copies in system memory, and retired when the title remaps their pages
Geometry copies held 4.4-6 GB of VRAM in world runs and were never evicted: a view retired only when its range was
freed, decommitted or unmapped, and the title streams by remapping the frames of its pools.

- LEONIDA_GEOMETRY_HOST (unset by default): 1 puts the copies in system memory outside VRAM, write-back where the
  device offers a cached host type; 2 write-combined. The memory type is picked among the host-visible types that are
  not device-local (memory_type_order alone would give the BAR first); a device with none keeps its types. Logged once
  and in the geometry buffers line.
- LEONIDA_GEOMETRY_REMAP_RELEASE (on by default, 0 off): XMemMapPhysicalPages with pages, the scatter call and
  CopyPageMappingsBatchX report the pages whose frame changed (or went) as released (xmem's RemapReleases, collected
  under the fault lock, reported after it), so GeometryViews retires the copies over them through #2094's
  drain_released and kAfterExecutes reaping. A page mapped again to its own frame is no change.
- A retired view is copied once more from its pages when they are readable: a list recorded before a remap that took
  the view's address reads the new bytes, as the refresh this replaces would have given it.
- A stream-pool extent backed by a retired copy leaves pool_spans (it was kept for the device's life).
- A full release queue joins touching ranges before it collapses into one covering range.

Tests: geometry_views_test cases 14-16, xmem_test test_remap_releases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:51 -05:00
7460590114 d3d12: host-RAM mirror of a console heap's copy for the release sweep
A console resource heap's translated copy lies in the GPU address arena when the
import of host memory is not used, and the arena prefers DEVICE_LOCAL |
HOST_VISIBLE memory (ReBAR): the filtered release sweep
(LEONIDA_CONSOLE_RELEASE_FILTER=1) read words 0-2 of both V# halves of every
live slot from it, uncached across PCIe, 0.9-1.0 s a rescan in game runs.

ConsoleHeap::copy is now a leonida::ConsoleHeapCopy (src/console_heap_copy.h):
the copy plus an optional host-RAM mirror of the heap's bytes. Every CPU write
goes through write()/zero(), which write both; CPU reads use view(). The raw
pointer is no longer reachable by accident, so a missed write site does not
compile. No mirror for a copy in an import of host memory, for a sampler heap,
with LEONIDA_HEAP_MIRROR=0, or once the LEONIDA_CONSOLE_HEAP_GPU pass writes
the copy (dropped at attach).

LEONIDA_HEAP_MIRROR_CHECK=1 compares the mirror with the copy at every release
sweep and logs the first differing slots and a count per heap log line.

The sweep over 536k live slots of an 18 MiB heap with the mirror: about 5 ms
(console_heap_copy_test, host RAM). Tests: console_heap_copy (portable) and
d3d12_console_heap_mirror (first refresh, title writes and zeroes, a filtered
release sweep; again with LEONIDA_HEAP_MIRROR=0).

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:51 -05:00
1be69fd56c pipeline_wait: guard non-positive window and signed subtraction overflow in title_submitting 2026-11-26 14:01:09 +00:00