Commit Graph

4696 Commits

Author SHA1 Message Date
c108c53894 d3d12_xs: the console render-target sizes of slots 25 and 56 are for console-form calls only
With the console tile sizes applied to every caller, a PC-form call through the proxy no longer answered what the
PC device answers, and the code that compares the two failed on Windows: device_proxy_test's two slot 25 checks
and d3d12_vulkan_device_test's allocation_mismatches (reported on #375 from MSVC builds on AMD and NVIDIA, the
first bad commit being the one that cleans the descriptions). Together with b4d1ba179, which scopes the cleaning
the same way, a PC-form caller now gets the PC device's own answer for its own description; the title's call,
which comes in the console form, gets the cleaned description and the console sizes as before.

xs_proxy_mock_test: the PC-form slot 25 case expects the mock device's size (it expected the console size), and
the mixed slot 56 case is asked in the console form. device_proxy_test includes d3d12_xs_desc_clean.h for the
cleaned description b4d1ba179's check compares with.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-24 03:49:26 -06:00
4056d185e7 ladder: kXboxTiledResourceLayout is inline const, not constexpr (clang-cl rejects 0x101 for the unfixed enum)
Reported by YaBulochka and sovljanskii on #7154; #7110's current head has the same form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit bee47186f6)
2026-11-24 03:48:25 -06:00
24914e7298 d3d12: preserve PC descriptor validation in slot 25
(cherry picked from commit b4d1ba1794)
2026-11-24 03:48:25 -06:00
713eec5031 acphal: stabilize APU mappings and reuse XMA PCM storage 2026-11-24 06:47:57 -03:00
e090be908d d3d12_xs: committed resources lease their size through the title's XMem hooks (RT-5 stop 17)
On the console a committed resource's memory is allocated with XMemAlloc, so it goes
through the title's __XMemAllocationHooks__. The retail title budgets its first
full-screen render targets with a per-thread hook that bump-allocates out of a range it
reserved and asserts that less than 2 MiB is left; PC resources never allocated through
the hooks, so the assert always fired. Slots 76 and 127 now allocate the slot-25 size of
each resource through the hooks, held by the resource with SetPrivateDataInterface and
freed when it is destroyed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ae322dafc5)

Adapted to main by Mumogg: the lease size is the later form of this series (d61755d4d, a render target's console
tile size, else the PC size), since console_render_target_extra is gone after 359390833.
2026-11-24 03:47:22 -06:00
8eaccded7f d3d12_xs: console render target sizes follow each resource's alignment, slot 56 offsets, full mip chains, rounded-up mip extents, B5G5R5A1, saturating sums
(cherry picked from commit 359390833f)
2026-11-24 03:47:22 -06:00
6b75cbafbc d3d12_xs: device slot 25 gives the PC device clean resource descriptions (RT-5 stop 16)
The title's descriptions carry the Xbox layout word and flag bits above the PC ones. Slot 25 now passes a copy with PC flags and a PC layout; the title's array is not written. Depends on #7078.

(cherry picked from commit c7ca0f2d1c)
2026-11-24 03:47:22 -06:00
f59167ef9c d3d12_xs: device slot 25 pads a render target to whole console tiles (RT-5 stop 17)
The retail title asserts when its first full-screen render targets leave more than 2 MiB of a fixed budget unused (docs/retail_boot_chain.md, #6982). The PC size is about width x height x element bytes; the console takes whole RDNA2 SW_64KB tiles. Slot 25 adds the difference per render target description and never lowers a size. Depends on #6973.

(cherry picked from commit 8897855399)
2026-11-24 03:47:22 -06:00
522faa2ee4 d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles
(cherry picked from commit 355201c51e)
2026-11-24 03:47:22 -06:00
e4dc13b079 build: declare file_mode in translator dependency lists
Address review of #558: include file_mode.py in CMake shader dependencies,
make_game translation source digests, and both Runtime workflow path filters.
AI-assisted with Codex.
2026-11-24 10:35:33 +01:00
4e9407a409 acphal: isolate voice failures and keep input transitions ordered 2026-11-24 06:21:32 -03:00
49d904fef6 tests: GPU readback for dynamic 64-bit vector shifts (GPU-VALU64-SHIFTS)
Exercise boundary counts and overlapping destination registers with runtime inputs.
AI-assisted with Codex.
2026-11-24 10:15:23 +01:00
10b0052e57 cs_div_fmas_f64_rt: the run-time-operand twin, and name the measured GPUs
Review of #8750: the fused half of the claim had no fixture. The new
cs_div_fmas_f64_rt reads the same a and c from s4..s7 (VKC_SGPRS), so the
driver cannot fold the Fma; it is fused under the default GLSL Fma on the
RTX 4090 here. design.md now names the measured GPUs: the all-constant
Fma is split on the RTX 4090, RTX 3070 and Quadro RTX 4000 (Turing,
Linux) and fused on an RTX 5060 Laptop (Blackwell).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 11:41:59 +03:00
ce75f144c7 docs/design.md, rdna2spirv: NVIDIA splits a binary64 Fma only when it folds an all-constant one
Correcting #6635's wording. On an RTX 4090 (621.24) the split 0 of the
fma(a, a, c) probe comes from the driver folding an all-constant GLSL Fma
while compiling the pipeline: cs_div_fmas_f64's operands are literals.
The same values read at run time from user SGPRs (VKC_SGPRS) give the
fused 2^-60, as #4536 saw on an RTX 4070. --fma khr is still what makes
both single-rounded. Wording only in design.md's floating-point row,
cs_div_fmas_f64.asm's header, Gen.emit_fma64's docstring, the runner's
split note and test_fma_khr_f64's docstring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 11:41:59 +03:00
0fe9c0bdfb acphal: recover SHAPE allocation and preserve XMA stream state 2026-11-24 05:27:55 -03:00
0a81e16316 docs: clarify the pipeline library host comparison 2026-11-24 13:12:14 +05:00
779f901084 fs, dstorage: a ReadFile into first-touch title memory commits the pages and reads again (RT-READFILE-NOACCESS)
xmem maps the title's physical pages as views of a reserve-only section and commits each page in a vectored handler
when user-mode code first faults on it. A kernel write raises no such fault: ReadFile into a page nobody touched yet
fails with ERROR_NOACCESS (998). The retail title's file reader treats any error but 6, 0x26 and 0x57 as transient
and calls Sleep(1) and ReadFile again forever, so the boot never leaves its first frame loop; DirectStorage reads
into the same memory came back as E_DSTORAGE_ACCESS_VIOLATION and the title stopped on an int3.

The ReadFile import of the file shims, and DirectStorage's read_file_range, now read one byte of every page of the
destination from user mode on ERROR_NOACCESS (the handler commits them) and read again once. file_system_test checks
it on a reserve-only section with a first-touch handler: the host ReadFile fails with ERROR_NOACCESS, the shimmed one
reads every byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:50:32 -06:00
0d27fdcf9a GPU fixture cs_imgstore_cube: image_store on dim:SQ_RSRC_IMG_CUBE (GPU-CUBE-STORE)
The "Typed image stores" contract row said a cube storage image was
CPU-checked only (test_image_cube_store_glc.py) and that no GPU fixture
covered it. This adds one:

- runtime/test/shaders/cs_imgstore_cube.asm: rgba8 unorm, r32 uint and
  r32 sint T#s (word3 TYPE = SQ_RSRC_IMG_CUBE); 64 threads store to every
  texel of all six faces, with per-face values so a wrong layer shows.
- vk_store_test "cube": three cube-compatible 8x8 six-layer images bound
  as six-layer 2D-array storage views at bindings 11/12/13, as the
  runtime binds a cube UAV; checks every texel of every layer.
- run_gpu_tests.py and check.py run it; test_shader_checks.py counts it.
- docs/design.md: the row names the fixture and the GPUs it passes on.
  Builds on #44, which rewrote that row.

Passes on an RTX 4070 Ti (NVIDIA 620.70.06) and a Radeon 610M (gfx1036,
RADV Mesa 26.2.6), native and LEONIDA_W64_EMULATE=1. The same fixture
with the face held at 0 fails on both (320/384/384 bad texels).

AI-assisted. No game files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:47:49 -06:00
367d91ef23 GPU fixture cs_imgatomic_ext: image_atomic_{swap,inc,dec,fmin,fmax,fcmpswap} (GPU-IMG-ATOMIC-EXT)
The row for the six remaining 32-bit MIMG image atomics was CPU-checked
only (tests/semantic/test_image_atomics_32.py) and said "Not GPU-verified
on RDNA2". This adds the GPU fixture, judged through vk_store_test's
"words" mode and check.py's STORE_WORDS like cs_imgatomic/cs_imgatomic3d:

- all six ops on the 2D r32 uint image (binding 4) and the volume
  (binding 7); inc/dec on both sides of their wrap and with a D that is
  negative as a signed number; fmin/fmax with a NaN data register;
  fcmpswap equal, unequal, +0 against -0 and NaN; glc and non-glc
- inc/dec/fmin/fmax from all 64 threads on one texel, which runs the
  translator's CAS loops under contention
- inactive lanes held on a trap texel that must keep its fill

The cases leave out what the ISA and SPIR-V leave open: NaN or denormal
texels for fmin/fmax/fcmpswap and +0 against -0 for fmin/fmax.

Exact on a Radeon 610M (gfx1036, RDNA2, RADV Mesa 26.2.6) and an RTX
4070 Ti (NVIDIA 620.70.06), native and LEONIDA_W64_EMULATE=1. Five
planted translator faults (signed inc/dec compare, fmin/fmax exchanged,
fcmpswap without the +0/-0 rule, no inactive-lane guard, no glc return
from swap) each fail it on both. docs/design.md records the GPU check.

AI-assisted. No game files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:47:48 -06:00
67417a0525 Merge pull request #531 from nickfmbg/fix/bindless-churn-temp-dir
Why merged: d3d12_bindless_churn and its --validated run now use separate temp folders per process, fixing a race between parallel runs.
Why it's good: security-reviewed; reproduced on main d42773d (the pair failed 4 of 6 runs at -j2); with this PR 8 of 8 runs passed and no stale folders were left.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 02:39:22 -05:00
20d90cc6ba Merge pull request #515 from csmith105/codex/fcmpswap-nan-poststate
Why merged: the fcmpswap fixture now checks memory after the NaN atomic instead of the returned value, which can't tell a match from a miss; a negative control proves it catches an integer compare.
Why it's good: security-reviewed; on main d42773d the new test fails and passes with this PR (5/5); the GPU fixture passes on an RTX 4070 SUPER.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 02:39:07 -05:00
01aee11332 Merge pull request #507 from csmith105/codex/lds-u8-d16-fixture
Why merged: the LDS u8_d16 GPU fixture now has only lane 0 touch shared memory, removing a race between the 32 lanes.
Why it's good: security-reviewed; on main d42773d the new test fails and passes with this PR (3/3); the GPU fixture passes on an RTX 4070 SUPER (driver 621.24).

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 02:38:52 -05:00
5aedbc2230 Merge pull request #501 from Kal0s-design/fix/loader-iat-tls-header-writes
Why merged: the PE loader now refuses an import address table or TLS index placed inside the headers, where the write would overwrite e_lfanew.
Why it's good: security-reviewed; built with VS 2022 + Ninja on main d42773d: the 4 new rejection cases fail on main; with this PR pe_loader, pe_loader_bounds and pe_loader_fuzz pass, and 7/7 loader-related ctests pass.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 02:38:37 -05:00
e02ec36bf3 acphal: synchronize XMA context words and bound the output ring 2026-11-24 04:29:18 -03:00
e9f521cebb gfx10_descriptors: zero mipLodBias for unnormalized samplers (VK-SAMPLER-UNNORM-BIAS) 2026-11-24 15:08:36 +08:00
14513af943 tests: separate pipeline library blob validation from host parity (TEST-PIPELINE-LIBRARY-OWN-FORMAT) 2026-11-24 12:04:30 +05:00
a0327ee1af runtime: target the MSVC ABI for the Rust XMA2 decoder 2026-11-24 04:03:39 -03:00
a99a3fb6ad acphal: preserve XMA packet chains and context lifetime 2026-11-24 04:03:38 -03:00
ace35e632b tests: d3d12_bindless_churn and its --validated run each get their own temp folder (TEST-CHURN-TEMP-DIR)
Both ctest entries run d3d12_bindless_churn_test with one fixed
%TEMP%\leonida_bindless_churn_test folder. Under ctest -j the first to finish
removes the folder and the other fails creating its pipeline ("cannot open
...\index.json"). The folder now carries the process id, as
d3d12_execute_indirect_validation_test does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 23:01:49 -08:00
1d4310bc71 vulkan_replay: enforce 4-byte vkCmdFillBuffer alignment in zero_compressed_image 2026-11-24 14:58:19 +08:00
4d64b64d1b translator deps: list rdna2_decode and rdna2_isa_tables
Since #462, tools/rdna2spirv.py imports rdna2_decode, which imports rdna2_isa_tables. Neither module was in the
three lists that track what the translator reads: LEONIDA_TRANSLATOR_DEPS (runtime/cmake/translator_deps.cmake),
TRANSLATION_SOURCES (make_game.py) and the runtime workflow's path filters. So test_cmake_translator_deps,
test_shader_stage_resume and test_runtime_paths fail on main, and an edit to the decoder neither rebuilds the GPU
test shaders, nor reruns translation, nor starts the runtime workflow.
2026-11-24 07:58:02 +01:00
cfcedb58e2 acphal: decode XMA contexts with runtime/xma_decoder when cargo is available
Replace the hand-written C++ XMA2/WMA Pro decoder with the Rust decoder
already on main. runtime/CMakeLists.txt builds it at configure time when
cargo is on PATH and links it into gta6rt and acphal_test
(LEONIDA_HAVE_XMA2_DECODER); without cargo, if that build fails, or with
the cl.exe fallback, XMA voices output silence for each packet's frame
count.

The ring engine decodes whole 2048-byte packets: the read offset and the
loop points are used per packet, so a loop plays its end packet in full
and restarts with a fresh decoder at the packet holding the loop start.
The C ABI gains leonida_xma2_decoder_create_hardware (no first-frame drop,
no 64-sample start skip), since the context carries its own skip.

Tested: acphal_test 129 checks (silence) and 125 checks (Rust decoder,
gnullvm build), 0 failures, 3 runs each, clang 23 / mingw x64; cargo fmt
and cargo test (gnullvm); pytest build/docs suites 204 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:53:37 -03:00
4ed6229e73 Merge remote-tracking branch 'origin/main' into fix/windows-present-window-pump 2026-11-24 14:53:19 +08:00
ce3e5153f1 d3d12_xs: keep the fallback PresentX window responsive during rendering
Create and dispatch the Win32 window on its own thread. Shut that thread down after the presenter has released the surface and test window messages and closure independently of the submitting thread.
2026-11-24 14:53:10 +08:00
aab57e15b9 vulkan_scratch: avoid uint64 overflow when aligning chunk.used 2026-11-24 11:52:12 +05:00
d6ca1fdaea mods: reject bare 0x/0X prefix in parse_model_id 2026-11-24 11:51:04 +05:00
28052acd70 d3d12: B4G4R4A4 render targets are RGBA8 images where no 4444 format is a colour attachment (RT-4444-TARGET)
NVIDIA has no renderable 4444 Vulkan format (A4R4G4B4, R4G4B4A4, B4G4R4A4 are sampled only), so a B4G4R4A4_UNORM
texture with ALLOW_RENDER_TARGET was refused and GetResourceAllocationInfo answered UINT64_MAX. Such a texture is now
an RGBA8 image, which holds every 4-bit value exactly: RTVs and PSO target formats follow the image, SRV T#s still
name 4_4_4_4, and bind_image views the RGBA8 image with A4R4G4B4's channels. Not covered: buffer copies of it move
4-byte texels.

Test: d3d12_b4g4r4a4_target (size and creation, RTV clears read back, SRV T# format; 0 validation errors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 08:50:40 +02:00
a672a59800 Check buffer NaN compare-and-swap memory post-state 2026-11-23 22:43:28 -08:00
7d50f3b749 d3d12/vulkan: implement multi-viewport and multi-scissor rendering (1..16 viewports/scissors) 2026-11-24 01:38:53 -05:00
d4eacf7d05 Restrict LDS byte-read fixture accesses to lane zero 2026-11-23 22:34:02 -08:00
c023a365a9 Merge pull request #473 from Dezmonius/test-warp-video-encode-allocator
Why merged: a minimal gate in the D3D12/Vulkan device test for hosts without D3D12 video support.
Why it's good: security-reviewed (7-line test change). Built and ran d3d12_vulkan_device_test with VS 2022 on an RTX 4070 SUPER (driver 621.24): passes before and after with identical output, as expected on a host that has video (the gate is a no-op there); the change is correct for hosts without it.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 01:33:36 -05:00
db8a0cc793 pe_loader: refuse an import address table or TLS index in the headers
After map_image, the loader writes into the mapped image twice: the bound
address of every import and the image's TLS index. Every step after it
(parse_exports, bind_imports, protect_sections, register_unwind,
initialise, ~Loader) reads the headers back from the mapping. A
FirstThunk or AddressOfIndex below SizeOfHeaders therefore replaced
e_lfanew or the section table, and the next read went outside the image
or used headers nobody validated. The loader already refuses a section
or a base relocation there; this closes the two remaining writes.

An index at RVA 0 is refused too: index_rva doubles as "no index", so the
index was silently never written.

Found by mutation fuzzing rt::Loader::load. The six new cases in
test_pe_loader_bounds build their images by hand; four of them fail
without this change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 07:29:32 +01:00
3b8c1555d8 cpu_emulation: update CMP flags on partial CLZERO batches and post-prefix faults 2026-11-24 07:25:21 +01:00
12536c2ab3 acphal: stop the XMA worker it was meant to stop
stop_worker set a shared stopping_ flag, moved the thread out and joined it
after releasing worker_mutex_. A wake in that window reset stopping_ and
started a second worker, so the old one kept running and the join could hang.
Each worker is now a std::jthread with its own stop_token (waits use
condition_variable_any with the token), so a stop only reaches its own thread.

acphal_test races 20000 context alloc/release rounds against ENABLE_XMA on a
second thread (the unfixed code hung there intermittently).

AI-assisted. Tested: acphal_test 115 checks, 0 failures, repeated runs
(clang 23 / mingw x64).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:15:02 -03:00
5a67c51a49 vulkan_backend: pass byte length to BufferVaIndex::find in host_at 2026-11-24 11:13:12 +05:00
2a3e7a23ea d3d12_xs: route presentation slots safely, hold the handler across calls
- Queue routes: PresentX defaults to slot 30 (XCL's older layout; 32 is the
  newer one, set with LEONIDA_XS_PRESENT_X_SLOT). SuspendX/ResumeX slots are
  unmeasured, so they are routed only when their variables are set; two
  routes on one slot are refused with a log instead of shadowing each other.
- One env_slot() parser for device and queue slots (no duplicated copy).
- GetFrameStatisticsX is a route like 78-80 (LEONIDA_XS_FRAME_STATISTICS_SLOT,
  default 81). Without a presenter it answers S_FALSE with a zero count
  instead of reaching PC slot 81 (ID3D12Device13::OpenExistingHeapFromAddress1).
- The presentation handler is called with its lock held shared, so a detach
  cannot destroy the presenter under an in-flight call.
- frame_pacer.h: the new event/flag constants are marked provisional again.
- xbox_present.h: attach_xbox_presentation is documented as the seam the
  presenter will use; gta6rt does not create an XboxPresentation yet.

AI-assisted. Tested with clang 23 / mingw x64: xs_proxy_mock_test (all checks
but the pre-existing kLong allocation-injection ones, which also fail on main
under mingw), --env-slots, --env-slots-invalid, frame_pacer_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:11:24 -03:00
60905fe78d shader_library: guard zlib limit sums and reject malformed f16_halves keys 2026-11-24 11:09:18 +05:00
d2f6033ee7 xdxr_build: pre-validate build inputs and avoid 32-bit workgroup overflow 2026-11-24 11:09:18 +05:00
36e9f9fce9 xdxr_descs: require complete 16-byte StreamRecords in find_stream_record 2026-11-24 11:09:18 +05:00
259772edb4 Merge remote-tracking branch 'ubiq/main' into feat/acphal-xma2-decoder 2026-11-24 03:05:41 -03:00