Commit Graph

4696 Commits

Author SHA1 Message Date
ff06694255 xg_xs_test: the model comparison reads through the public detile()
Layout::walk is private; detile() is the same copy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:01:34 -05:00
3ff2a2adcd Merge pull request #1491 from madhyn/feat/xma2-prebuilt-lib
runtime: accept prebuilt XMA2 decoder via -DLEONIDA_XMA2_DECODER_LIB (BUILD-XMA2-PREBUILT-LIB)
2026-11-25 03:00:08 +01:00
46e078824d docs: build the prebuilt XMA2 decoder yourself, from this checkout
Configure checks only that the file passed with -DLEONIDA_XMA2_DECODER_LIB
exists, not which source, version or target it was built from. Say so, and
give the command that builds the library from this checkout's
runtime/xma_decoder for x86_64-pc-windows-msvc, where it lands, that it
needs only the Rust target (so it works on Linux), that the option stops
CMake from rebuilding the decoder after source changes, and that a
relative path given with -D is resolved against the directory CMake runs in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:59:12 -05:00
45f5467e38 xg_xs_test: the two texture layout models are compared on every texture both lay out
The merge keeps two models of the console's texture layout: xg_xs_layout.h, which the XG computer answers the title with and the title-texture registry reads back with, and console_texture_layout.h, which the linear and tiled uploads of #939 read with. For 2D textures in seven formats, four modes and ten shapes the new case checks that both give one size, the same mip extents, and that what the first tiles the second detiles to the same rows, for every mip and array slice.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:58:44 -05:00
a127c11a84 GPU labels reach a title page the D3D12 layer keeps read-only while it watches it
A completed label was stored only into a page that was read-write at that moment and dropped otherwise. The
base makes title pages read-only while a shadow or the geometry watch waits for the title's next write, so a
label for such a page was lost, and a title that waits for a completion label then waits for ever. The store
now announces the write the way a kernel write is announced (kernel_writes::begin_write): the layer opens the
pages it guards and copies them again at its next refresh. A page that is still read-only after that is the
title's own doing and the label is dropped as before; so are guard, no-access and decommitted pages and a
released allocation. The store moves out of the class as label::store_value so that it can be tested.

gpu_label_store_test (CPU only, registered as gpu_label_store) covers each of those cases with a stand-in for
the layer's opener.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:58:44 -05:00
a9761ab2f9 tests: GPU fixtures for the ds_wrxchg2_rtn_b32 pair cases and ds_wrxchg2st64_rtn_b32 (TEST-WRXCHG2-B32-EXT)
docs/design.md's ds_wrxchg2_rtn_b32 row names cs_w32_new_ops as its fixture, and that fixture
compares only the first returned word and data1 in LDS. Four things the row states were therefore
never checked on a GPU: the second returned word, data0, the st64 step, and vdst aliasing the data
VGRs. The row's own note also records the non-st64 step indirectly only on gfx1100.

Two branchless fixtures, one lane each (32 lanes on one LDS address would race):

  cs_w32_wrxchg2_ext   both offsets on one dword: the first exchange returns the old word and the
                       second returns data0, not the word the first wrote; a neighbouring LDS word
                       is untouched; with vdst aliased onto the data VGPRs the data is read before
                       the result is written, so vdst gets the old pair and LDS the new one.
  cs_w32_wrxchg2st64   the st64 unit is 64 dwords: base 0x80 with offsets 1/2 addresses 0x180 and
                       0x280. 0x84/0x88 (where a 4-byte step would land) and 0x140/0x2c0 (one step
                       either side of the real elements) are seeded and must come back untouched,
                       which is what pins the stride rather than assuming it.

Both are registered in check.py (CS_DUMPS, WAVE32_DUMPS, WAVE32_LANE_DUMPS) and
scripts/run_gpu_tests.py, and judge all eight words in hex.

Measured on a Radeon RX 6900 XT (RDNA2, GFX1030, RADV Mesa 26.2.4, Nobara Linux 44), main d0da7da:
  build.py          283 shaders: 283 translated, 283 pass spirv-val
  check.py          217 of 222 pass, 3 skipped, 2 failed
  run_gpu_tests.py  233/251 passed, 16 skipped, 2 failed (native and LEONIDA_W64_EMULATE=1 alike)
  --filter wrxchg2  2/2 PASS both modes, every word exact (16/16)
The two failures in the full runs are cs_imgload_tfe and cs_imgload_d16_tfe, the pre-existing
SHADER-1266/#31 pair, unchanged by this commit.

No game files, nothing online. AI-assisted (Hermes Agent).
2026-11-25 08:53:57 +07:00
0ce9f8992c first-run-ui: a variable that is set but empty does not count as the caller's setting
run_tiny_first_run_ui clears two variables by passing them empty. Windows cannot hold an empty variable, so there they are unset; under Wine they exist, and the profile's size-only query reported them as set and kept them. The test failed that way on #939's head too. The profile now reads the first character, so an empty value gets the profile's default on both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:53:47 -05:00
b25da08cb6 d3d12_quad_index runs with the pack() root layout its vertex shader was written for
vs_quad_inst reads its root arguments from s0, the layout #939 had by default. The merged default is the console layout (from s8), which both measured boots ran with, so the test asks for the other one with LEONIDA_GRAPHICS_STAGE_LAYOUT set to 0. What it tests, the expansion of indexed quad lists, does not depend on the layout.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:53:46 -05:00
7be70a9f56 xbox_geometry_upload_batch: the buffers over the title's vertex pages outlive the lists
In the merge a vertex view that names title memory gets the base's buffer over those pages (make_title_buffer), kept until the device goes and holding a device reference each; #939 uploaded the bytes per submission and kept nothing. The large-batch run of d3d12_draw_test therefore no longer ends with one reference on the proxy. The other runs still check for exactly one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:53:45 -05:00
5d06b469c3 d3d12_depth_stencil_uav_test: the console size of a depth-stencil target may be the smaller one
The test of #939 sized its guest range through device slot 25 and expected at least the PC device's size. The merged slot 25 is the base's, which lays a console depth-stencil target out more tightly than the PC device (console_depth_stencil_size) because the title sums these sizes against a fixed pool. The range takes the larger of the two; the slot's answer only has to be valid.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:53:44 -05:00
aa23d709c9 A sampled view of a placed texture that waits for its memory is remembered, not bound
CreateShaderResourceView asked for the image to tell a texture from a buffer. In the base that accessor binds a deferred placed image, so with prepare_on_bind the memory was bound before write_image_descriptor could remember the view, and #939's first-use path never ran (xbox_staged_texture_views, xbox_visible_texture_views). A texture that still waits for its memory is recognised without asking for the image. xbox_placed_texture_first_use expected a placed sampled texture to wait without prepare_on_bind as well; in the merge it waits only with it (the base backs every other title image when it is made), and the test says so.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:53:43 -05:00
85caf5815b A submission scans its tables with its own device's scanner
The merge had taken the base's process-wide scan hook (title_va_aliases), which belongs to the first device that registered. A second device over the same GPU then had its tables scanned by the first: d3d12_rebound_second_device, a test of #939, failed on it. #939 scans through the context of the device (VulkanContext::set_table_scanner), which the merged device still registers. That one is asked first now and the process-wide hook serves a context without a scanner.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:53:43 -05:00
871e4b8b99 Merge pull request #1090 from milk4sale/test-w64-sdst-pair-gpu
tests: a GPU fixture and whole-corpus counts for one-register wave64 mask destinations (TEST-W64-SDST-PAIR-GPU)
2026-11-24 20:50:01 -05:00
8a57b3b1d3 Merge pull request #1114 from milk4sale/gpu-test/salu-ext
tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-EXT)
2026-11-24 20:49:40 -05:00
22171d092f B4G4R4A4 targets stored as RGBA8 carry #939's flag: clears quantised, footprint copies still made
The base's early return for such a target came before #939's lines, so Format::rgba4_render_fallback was never set: #939's pixel-shader quantisation ran (it keys on the pipeline), its clear quantisation and its refusal of footprint copies did not. The flag is set now, so a clear stores what a draw would. The refusal of footprint copies is not taken as the default: the story-load boots of #984 ran with those copies made; LEONIDA_RGBA4_COPY_REFUSE=1 gives #939's refusal. Neither test device here lacks a 4444 colour attachment, so this path is exercised only on a GPU that does (NVIDIA).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:46:02 -05:00
22f2a04afd Console D16S8 textures keep #939's D16/S8 path where the GPU has no D24S8 attachment
The base turns the console's depth family (DXGI 118 to 120) into the D24S8 family at every entry, so #939's
D16/S8 code was in the tree and unreachable. On a GPU without D24_UNORM_S8_UINT as a depth-stencil attachment
the D24S8 family is itself stored as D32_SFLOAT_S8_UINT, a third precision the title did not ask for, and that
is the AMD case, the one #939 was measured on. The device now decides when it is created: with a D24S8
attachment the base's mapping stays (the NVIDIA boots of #984), without one the family is kept and takes
#939's path (D16_UNORM_S8_UINT where the GPU has it, 16-bit quantised clears and stores).
LEONIDA_CONSOLE_D16S8=native or =d24 chooses for every GPU; the device logs which it took and what the GPU
offers. xbox_d16s8_storage and xbox_d16s8_surface ask for native (registered in the previous commit), so they
test #939's path on a GPU that has D24S8 too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:44:46 -05:00
a85a47a835 d3d12_existing_heap_test: the device is told robustImageAccess is on
The merged image descriptor writer binds a Texture3D or Texture1D UAV only with VulkanDeviceInfo::robust_image_access (#939's rule: such views are read and written without a format), and the runtime's own device sets it wherever the GPU has the feature. The base's test of a slot 71 view of a placed Texture3D built its device without the flag, so the view was no longer bound and write_placed_texture_view answered false.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:44:26 -05:00
73c37e19db Constant-buffer view tests follow the merged rule: console rows unless LEONIDA_CBV_RAW=1
The merged device writes every constant-buffer V# in the console's form of 16-byte rows (the base's rule, which both measured boots had for the title's own views); #939 kept the byte-address form for a view made on the device itself. xbox_cbv_vectors and the rebound-table cases of d3d12_title_va_test expected #939's form for that producer. They now read the switch as d3d12_compute_test does, and xbox_cbv_vectors_raw runs the first with LEONIDA_CBV_RAW=1, which is #939's behaviour.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:44:26 -05:00
287778279f LEONIDA_LINEAR_MAP_FIRST=1 gives #939's Map as it was, refusal included
With the switch on, a leased linear texture takes #939's mapping and its result, not the placement address as a second answer: xbox_linear_texture_map expects Map to fail once the title's pages are unmapped, and the address would have been handed out there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:44:01 -05:00
d3741102e4 runtime: accept prebuilt XMA2 decoder via -DLEONIDA_XMA2_DECODER_LIB (BUILD-XMA2-PREBUILT-LIB) 2026-11-24 22:43:53 -03:00
c5510733e9 Merge main (with #984) into RT-QUEUE31 (#968)
main now contains the #984 merge this branch was built on, plus its last
commits (the five tests of #984 settled under Wine, and the title's hang
watchdog staying armed by default). No conflicts: runtime/test/xmem_test.cpp
and docs/d3d12_vulkan.md merged cleanly, with test_copy_page_mappings and
test_copy_page_mappings_cpu_view each defined and called once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:38:14 -05:00
38bd89d44e Merge the #984 result as of 71a783e56 into the #939 merge
Fourteen commits the #984 merge gained after 8a242efeb: its own failing tests (xmem_test under Wine, check_tls_index0, vk_bindless_grow, xs_present_lazy_test), the console-heap probe and the poke experiment behind their switches, Python tool fixes, and the title watchdog default. No conflicts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:37:26 -05:00
545e8d51f1 Map of a slot 133 linear texture: the placement address first, #939's linear mapping behind LEONIDA_LINEAR_MAP_FIRST=1
A slot 133 texture leased as linear has two answers to Map: the base's (the placement address, the title texture registry fills the image) and #939's (pinned pages, read-back of a GPU-written texture). The base's is what the retail boot ran through the intro movie and the story load on, and the video planes are such textures; #939's was measured to the first-run screens, which come before the movie. So the base's is asked first again, #939's first only with LEONIDA_LINEAR_MAP_FIRST=1, and a leased linear texture with no placement address (slots 76, 127) takes #939's mapping as before. xbox_linear_texture_map and xbox_linear_gpu_staging set the switch, so they still test #939's path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:37:05 -05:00
9ef598da7b Vulkan device: the final resolution of d3d12_vulkan_device.cpp and d3d12_com.h
The merge commit was assembled from the resolver's copy of 20:23; its final copy of 20:34 differs in these places: a slot 133 texture is also registered under #939's title address, so a raw slot 70 view finds it instead of making a second image of the same pages; a lazy graphics pipeline re-applies #939's 4444 quantisation of the pixel shader when it re-reads its words; the UAV counter offset is added once; LEONIDA_GRAPHICS_STAGE_LAYOUT is on unless 0; Map asks #939's linear mapping first for a leased linear texture (changed in the next commit); an unused mutex is gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:35:42 -05:00
b8447eec01 xs_proxy_mock_test: device slot 57 asks the native factory first and falls back on E_NOTIMPL
No test covered the chain the merge builds for slot 57: #939's NativeGraphicsFactory first, the base's PC description path (CreateGraphicsPipelineState with the bare programs) when the factory answers E_NOTIMPL. The new case checks, on the mock device: no factory reaches the PC path; a factory answering E_NOTIMPL is asked once and the PC path then runs; a factory that succeeds is the answer and the PC path is not asked; E_INVALIDARG, E_OUTOFMEMORY and E_FAIL are returned as they are; an unreadable description is refused before the factory; removing the factory restores the PC path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:32:47 -05:00
77ded8a050 Device slots 78 to 81 stay on the device unless LEONIDA_FRAME_PACING=1
The merge had turned #939's opt-in round (on unless =0). The story-load boots of #984 were measured with the frame-event slots answered from the device's token counter, and handing them to the presentation without the title's interval makes the next WaitFrameEventX fail. So the base's behaviour is the default again and #939's hand-over, with the interval and origin event replayed to the pacer, is behind LEONIDA_FRAME_PACING=1 as on #939. The --first-run-ui profile sets it, so that profile keeps what #939 measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:32:47 -05:00
71a783e56f main: the title's hang watchdog stays armed unless LEONIDA_TITLE_WATCHDOG=0
The retail title runs its own hang watchdog: when the game's main loop has
not reported for 30 seconds, it ends itself. #984 kept that watchdog from
firing by default, because under the runtime the game thread can wait
longer than that, for example while the driver compiles pipelines on the
first boot after a driver update.

By the maintainer's decision the watchdog now stays armed by default, as on
the console, so a real hang still ends the run. LEONIDA_TITLE_WATCHDOG=0
turns on the runtime thread that keeps it from firing; as before, it only
acts in the build the watchdog was measured in. The README's environment
table and the log line say the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:32:26 -05:00
1ace960c59 d3d12 translated-draw and mesh tests: no first_use_backend_pipelines
The merge keeps one first-use mechanism, the base's lazy pipelines; #939's DeviceInfo::first_use_backend_pipelines is gone from d3d12_com.h and vk_test_device.h, and these two tests still copied it. prepare_on_bind and cold_graphics_compile stay.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:28:22 -05:00
116c6ca478 xs_proxy_mock_test: the placed-at-VA handlers take the clear value
The merged PlacedAtVaHandler keeps #939's seventh argument (the title's clear value, which the Vulkan device's create_placed_xbox_resource uses); the base's two test lambdas had six.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:28:22 -05:00
154e4ec034 Merge the #984 result (main + RT-PROTON-STORY-LOAD) into #939
The base is 8a242efeb, the merge of main and #984. 68 files conflicted; they were resolved in seven groups by
one rule: the same change in two forms keeps the base's form, everything only #939 has is kept, and where the
two solve one problem in two ways the base's is the frame and #939's plugs into it.

A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with #939's additions
ported in. Device slot 57 asks #939's NativeGraphicsFactory first and falls back to the base's
proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from #939: the providers (texture lease,
raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages),
the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: #939's
duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in.

A2 (xs_proxy_mock_test.cpp): the base's test with #939's slot 70 raw-buffer case; presentation cases follow
#939's rule that a device which ever had a handler has no queue fallback.

B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h,
pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; #939's pending_base_compile
and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps
the base's signature; #939's deferred backing is folded into the base's placed-memory binder. #939's quad
lists as triangle indices.

B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list,
shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where
both carry the same case, #939's cases added (rebound tables, linear texture map, large vertex batch,
executable shaders, default A8 views).

C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h,
rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp,
replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its #1055 release rule and its
rectangle generator; #939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the
label fence on the base's submit.

D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test,
main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with
#939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's
answering first; --first-run-ui kept without host speech in its profile.

E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py,
scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's
v_dot4 decode, #281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the
base's executable-shader step with #939's cache fix; 366 registered tests.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:26:00 -05:00
461efcde4d check_tls_index0.cmake: skip the failed-reservation half where TMP cannot be overridden
The second half of run_tiny_tls_ga (new in #984) points TMP and TEMP at a missing folder so that the home clone cannot be written and the loader must refuse the image. Under an emulator the override never reaches the loader: Wine gives the process the temporary folder of its prefix whatever the caller's environment says, so the reservation succeeds, --run returns 0 and the script failed with '--run without the reservation returned 0' (on #984's head too).

When the script runs the loader through an emulator it first asks --dry-run, which maps the image and names index 0 in a note when the reservation fails, without running any of its code. If that note is missing the override is not in effect: the script prints 'SKIP the failed-reservation half: TMP and TEMP set for <runner> do not reach the loader's GetTempPathW' and stops there, after the first half (the image gets index 0 and reads its TLS from slot 0) has passed. A native run is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:18:37 -05:00
2deadb0763 xmem_test: view checks that hold under Wine, and say what Wine cannot show
Three checks of the physical-page views fail under Wine, two of them on main as well (xmem is a known Wine failure there) and one that #984 adds; with #984 registering the test twice more (xmem_write_watch, xmem_no_write_watch) that made three red tests. Measured under Wine 11: a page of a reserved section view that has been written and reads back is still reported by VirtualQuery as MEM_RESERVE with protection 0 (type MEM_MAPPED, allocation protection PAGE_READWRITE), where Windows reports MEM_COMMIT and PAGE_READWRITE.

- 'unmapping one of them afterwards keeps the others' memory' (#984) asked whether the neighbours were still mapped through reserved_only(), which is the reported state. It asks for the view itself now (in_view: the region's type is MEM_MAPPED), which is what the check is about, and also that the unmapped page is no longer in one. Same on both hosts.
- The two checks of the reported state and protection of a written view page print SKIP with the reason when the host is Wine and gives exactly that answer; the first then still checks that the page is a read-write view holding what was written. On Windows both run as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:18:35 -05:00
8223f28256 d3d12: the console-heap probe is made only when a diagnostic reads it
Follow-up to the LEONIDA_LOCAL_DIAGNOSTICS commit: the desc-probe still registered every console descriptor heap and printed a line for each of the first 48 view creations ('... outside the console heaps'), switch or not. A heap probe is only created when LEONIDA_LOCAL_DIAGNOSTICS or the compute probe is on, and the per-view line is behind the switch like the rest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:18:34 -05:00
255f170017 xmem: map slot-31 copies at the GPU-only range's paired CPU view too
Applies the fix oscarlosu-lab proposed on #968:
https://github.com/ubiquitarianism/leonida/pull/968#issuecomment-7142206199

What was wrong: queue slot 31 (CopyPageMappingsBatchX) targets the title's
GPU-only reservation, but the D3D12 layer reads that memory at its paired CPU
view (title_gpu_views::to_cpu). copy_page_mappings mapped the pages only at the
GPU-only address, so the paired CPU view stayed reserved and the layer's reads of
that memory (the slot-70 views waiting for readable memory) never became
possible.

The change, in copy_page_mappings:
- when the destination is in a paired GPU-only range and its CPU range is a
  physical-page window, every page mapped or unmapped at the destination is
  mapped or unmapped at the CPU address as well, with that window's protection;
- a source page not mapped at a GPU-only address is looked up at its CPU
  address.

Cost: a second view per copied page, so such a page is mapped at three
addresses (pool, GPU-only, CPU) and counts as aliased: the shadow tracker copies
it at every submission. Risk: the pairing is a heuristic (the CPU reservation of
the same size made just before the GPU-only one); if it is ever wrong, the
mirror replaces the title's own mappings in that CPU range.

The comment reports 9 alias checks but does not give them, so the test is new:
xmem_test's test_copy_page_mappings_cpu_view reserves a CPU + GPU-only pair and
checks that after a batch copy onto the GPU-only range the CPU range is
committed and shows the same bytes (and a write there is one memory with the
pool), that a GPU-only source mapped only at its CPU range is found there, and
that a null source unmaps both ranges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:17:45 -05:00
6fdeadfe50 Merge main with #984 into RT-QUEUE31 (#968)
Merges the local m984-on-main (1d89b20c5f), main with #984
merged, into #968's head f2268abea.

Conflicts and their resolutions:

- runtime/shims/xmem.h: both sides appended to the end of rt::xmem. Kept
  geometry_aliases and transfer_physical from #984 and appended #968's
  CopyPageMappingsFn typedef and the inline copy_page_mappings_fn after them.
- runtime/shims/xmem.cpp: copy_page_mappings and the self-registering
  g_copy_page_mappings_set stay right after XMemMapPhysicalPagesScatter,
  followed by #984's shadows_write_watch. One-line port: #984's g_mapped stores
  the page number itself (HostUnorderedMap<uintptr_t, uint64_t>), so
  `it->second.page` becomes `it->second`.
- runtime/shims/d3d12_xs_device.cpp:
  - includes: #968's "xmem.h" beside "d3d12_trace.h", then #984's includes;
  - constants: #984's block kept, kQueueCopyPageMappingsBatchX = 31 added after
    kQueueExecuteCommandListsX and its static_assert;
  - the slot-31 section (ConsolePageRange/Batch, copy_console_page_range,
    queue_copy_page_mappings) goes after #984's queue_execute_command_lists and
    before the "PresentX is at queue slot 30" comment;
  - child_slot: #984's queue block kept; the slot-31 dispatch (beyond the PC
    table and with xmem's hook set) goes just before the qroutes lookup, ahead
    of the presentation routes and the console-only S_OK tail. Newer-layout
    PresentX is 32, so 31 does not clash.
- runtime/test/xs_proxy_mock_test.cpp:
  - includes: "../shims/xmem.h" beside #984's d3d12_xs_frame_events.h;
  - #984's descriptor-heap and later checks kept, check_queue_copy_page_mappings
    after them. Without xmem the merged proxy answers slot 31 with the
    console-only S_OK, so that check's `== E_NOTIMPL` becomes `== S_OK` (and its
    summary line says so);
  - main: `|| check_queue_copy_page_mappings()` appended after
    check_presentation_wiring().

runtime/test/xmem_test.cpp merged without conflict: test_copy_page_mappings runs
after test_physical_pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:09:14 -05:00
68eee6b71a gfx10_descriptors.h: the A8 row in the form the format table test reads
tests/test_gfx10_descriptors.py checks every row of the format table against Mesa's names and fails when a row does not have the form it parses. #984's A8 render target row carried a remark after the GFX10 name, so it was counted but not read (94 of 95 rows; fails on #984's head too). The remark is a comment line above the row now, and the row is checked like the others (the test already knows an extension's suffix is not part of the layout).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:07:54 -05:00
1d89b20c5f xs_present_lazy_test: the presenter the device proxy builds on PresentX
From rung-414-on-main (24a19ae8f), where it found the reference cycle fixed two commits ago, adapted to this tree: PresentX is called at queue slot 30 (a queue is in the older layout until a fence reaches slot 16 or 17), and the runtime's window is destroyed by the thread that owns it, so the last check waits for it to go (up to two seconds) instead of looking once.

It compiles the proxy with LEONIDA_VULKAN_DEVICE, as gta6rt does, and checks: the frame events before the first present are the device's own; nothing is built before the first PresentX and one window after it; WaitFrameEventX stays the device's and counts from the same token source the presenter checks (an unissued token is E_INVALIDARG, an issued one is accepted); a second PresentX builds no second window; and the window goes with the device proxy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:01:35 -05:00
fb10298ab1 d3d12: the poke experiment's table lookups only when it is on
The submission path looked up the origin of every bound descriptor table (a lock and a map lookup each) for the LEONIDA_FSDRAW_POKE_CB experiment, whether or not the experiment was on; poke_cb then returned at once. The loop now runs only with the experiment.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:00:47 -05:00
307ea4a3b9 vk_bindless_grow_test: no device-local fault where host memory is device-local too
#984's new test refuses device-local allocations to force the table into host memory, and says itself that the host fallback is not checked on a device with no host memory type outside device-local memory. But it injected the fault there too: llvmpipe has one memory type for everything, so every allocation was refused, the table could not grow and the check right after the frame failed (on #984's head, on Linux and under Wine; the test is in the portable subset, so a Linux CI run with lavapipe would be red). The fault is only injected where a separate host type exists; elsewhere the table grows normally in that step, and the all-memory-refused cases further down still run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 20:00:23 -05:00
85b8f5b7f0 cpu_emulation: rewrite CLWB in place at its first #UD (RT-CLWB-PATCH)
On a host without CLWB every execution of the instruction raised #UD and the vectored handler emulated it. The
retail title's GPU upload worker flushes whole buffers with CLWB in a 64-byte loop (exe+0x532f1b0 on 1.0.2.1), so a
buffer cost one exception per cache line; under Wine that kept the worker busy for minutes and the main thread
polling its event in session 0xd, so the boot never left the first-run pages.

The handler now rewrites the instruction at its first #UD: 66 0F AE /6 becomes 66 0F AE /7 (CLFLUSHOPT), the same
operand and length, which also writes the line back; a host without CLFLUSHOPT gets 66 0F 1F /0, a NOP of the same
length. LEONIDA_CLWB_PATCH=0 keeps the old per-execution emulation.

Tested: cpu_emulation_test under Wine 11.21 on an i9-9900KF (no CLWB, has CLFLUSHOPT): both sites rewritten, SIB and
displacement kept, the code runs again. Retail boot on the same machine with #984 + #968 (RTX 2070 SUPER, Fedora 44):
the worker that sat in the CLWB loop at 420, 540 and 660 s now moves on, and the title gets past the first-run pages
into the story load.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RBZntAmGCDe3LdLjbzZzuc
2026-11-25 01:58:20 +01:00
8a242efebf Merge main into RT-PROTON-STORY-LOAD (#984): #396 and #403
Brings the branch up to main at b4b7756e8: #396 (console list slot 139 is Reset) and #403 (queue slot 18 is the frequency getter for a guest caller). The first merge already resolved the proxy to these two forms, so nothing changes in the code:

- runtime/shims/d3d12_xs_device.cpp: one conflict, main's copy of the base list proxy, which #396 edited and the first merge had dropped for #984's list proxy (the Reset rule of #396 is in #984's list_slot). Ours.
- runtime/shims/d3d12_xs_device.h: merged clean, unchanged.
- runtime/test/xs_proxy_mock_test.cpp: git added main's console_to_pc_list_slot(139) check next to the copy the first merge had put two lines lower; one stays, in main's place.

Every line the two pull requests added to these three files is in the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:57:34 -05:00
7e3bfb4e33 PresentX: docs and a test state the one-slot-per-layout rule of the merge
The merged queue proxy recognises PresentX at slot 30 on a queue in the older layout and at slot 32 on a queue detected as the newer one (a fence at slot 16 or 17, or SignalX at 25), which is #984's measured behaviour, with main's LEONIDA_XS_PRESENT_X_SLOT pinning one slot and an attached handler answering first. Only one of the two is PresentX at a time: in the newer layout slot 30 is another method.

docs/d3d12_vulkan.md still had main's row (the queue slots stay refused, gta6rt creates no presentation) and runtime/README.md still said PresentX has an unknown slot. Both describe the merged code now. check_presentation_wiring gains the newer-layout case: before the fence 30 reaches the presenter and 32 does not, after it 32 does and 30 does not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:56:42 -05:00
1d28e6e361 device_proxy_test: made-up digests in the synthetic shader library case
The case that loads fspx/, fspx_gfx/ and bvh/ indexes calls itself synthetic and runs against index files it writes itself, but two of its keys were the SHA-256 digests of two programs of the game's pipeline library (the ones docs/fspx.md cites as programs 842 and 843), with those numbers in the file names. A hash is not content, but a synthetic test has no reason to carry real ones, and nothing in the case depends on the values. They are 3333... and 4444... now, next to the 1111... and 2222... the case already used, with file names _00001 and _00002.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:55:23 -05:00
595a147cf3 xg_xs_THIRD_PARTY.md: TuxBox is Apache-2.0, not unlicensed
The note called TuxBox unlicensed. GitHub reports brcly/TuxBox as Apache-2.0 now. The statement that it was a reference for behaviour only is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:55:15 -05:00
2d05d9292a d3d12_xs_pso_stream.h: name the source of the derived-PSO record layout
The header credited "TomBox's create_derived_pso_x, GPL-3.0" without saying where that is. The credit now names the repository, the file and the licence: omonkeyz/xbox-emulator, crates/compat/d3d12_xs/src/device_wrap.rs (the continuation of drycheetah84/TomBox), GPL-3.0-or-later. Only layout facts are shared with it (the record stride and the meaning of tags 0 to 3), no code.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:55:03 -05:00
428a746e58 Check 1D and 3D A8_UNORM textures next to A8 render targets
d3d12_a8_dimensions_test makes its device without the A8 render-target
path, so it covers 1D and 3D A8_UNORM textures only in the fallback.
d3d12_a8_copy_test now also checks them on a device that has the path:
a 128x1 1D and an 8x8x4 3D A8_UNORM texture are created as R8_UNORM
images (no VK_FORMAT_A8_UNORM_KHR image is made for them), so they are
never one side of a mixed-backing copy, and a 1D A8_UNORM render target is
refused rather than made in either backing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:54:46 -05:00
ea43b63b7a A8 render targets: guard test for device extensions, and the fallback case
From rung-428-on-main (554f0e4ec). The bug that commit fixed, VK_KHR_maintenance5 enabled inside maintenance8's #ifdef, is not in #984's copy of the A8 support: the enable already sits under its own guard here, so only the comment on it comes over. What the commit adds besides still applies:

tests/test_vulkan_extension_guards.py reads the runtime sources and fails on any device extension enabled inside another extension's #ifdef. d3d12_a8_copy_test also forces the fallback (a8_render_target false) on any device: A8_UNORM render targets are refused at creation, in GetResourceAllocationInfo and in the format support, no A8 image is created, and plain A8_UNORM textures still copy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:54:46 -05:00
869c889796 Stage copies between the two A8_UNORM backings through a buffer
An A8_UNORM render target is a VK_FORMAT_A8_UNORM_KHR image and any other
A8_UNORM texture an R8_UNORM image. CopyResource and CopyTextureRegion
between the two issued vkCmdCopyImage on that pair, which Vulkan does not
count as size-compatible: VUID-vkCmdCopyImage-srcImage-01548, although the
bytes came out right on the drivers tried. moffington reported it in the
review of #428 and Dezmonius confirmed it on native Windows with the
validation layer.

Such a copy now takes the replay's existing image -> transfer scratch ->
image route, the one depth <-> colour copies use, with one byte per texel
on both sides. Same-backing copies still copy image to image. This is the
approach of Dezmonius's proof of concept, which they described on the pull
request but did not publish; written here from that description.

d3d12_a8_copy_test copies A8 render target -> A8 texture and back, whole
(CopyResource) and a 3x3 box from a nonzero source offset to a nonzero
destination offset (CopyTextureRegion), and checks every texel read back:
the source bytes inside the box, the destination's own outside it. It wraps
vkCreateImage and vkCmdCopyImage behind the instance-proc pointer it hands
the layer and fails on any vkCmdCopyImage between VK_FORMAT_A8_UNORM_KHR and
another format, so it fails without this change even where the validation
layer is not installed; with LEONIDA_VK_VALIDATION=1 the layer's errors fail
it too. A8 -> A8 and R8 -> R8 copies are the controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:54:27 -05:00
501c7d5237 d3d12: remove the unused B4G4R4A4-as-BGRA8 stand-in flag
The merge kept main's B4G4R4A4 render target stand-in (an RGBA8 image) and dropped #984's (a BGRA8 image). #984's DeviceState::b4g4r4a4_target_stand_in was left behind: computed at device creation, read by nothing, and printed in the 'console format stand-ins' line as 'B4G4R4A4 target as BGRA8', which is no longer what happens. The flag and its clause of the log line are gone; main's stand-in logs itself when it is used.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:54:10 -05:00
e435715d4a d3d12_xs: the proxy's own presenter takes no reference on the proxy
The presentation the device proxy builds on the first PresentX (or for the package splash) is meant to go with the proxy: proxy_release destroys it before the device. It could not: create_window_presenter gives the presenter a reference on the device's outer identity, and for a device made by D3D12XboxCreateDevice that is the proxy (set_device_outer). The proxy owned the state, the state the presenter, the presenter a reference to the proxy, so after the first PresentX the proxy's count could not reach zero and the window, the swapchain and the device stayed until the process ended.

#984's presenter has this cycle as the #414 branch had it; the fix is the one made there (rung-414-on-main, ea9228dc0), applied to #984's form of present_state_for. create_window_presenter gets a hold_device argument, true by default so every other caller keeps its reference. The proxy passes false: it owns the presenter and destroys it before it releases the device, which is the order the reference was there to guarantee.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:53:36 -05:00