Commit Graph

3171 Commits

Author SHA1 Message Date
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
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
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
a672a59800 Check buffer NaN compare-and-swap memory post-state 2026-11-23 22:43:28 -08: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
86ba7556ba test: gate VIDEO_ENCODE allocator parity on host video support 2026-11-24 08:58:15 +03:00
1c69700851 store: offline *Async slots start and complete their XAsyncBlock with E_FAIL (M11)
The offline XStore table returned E_FAIL synchronously without ever starting the caller's XAsyncBlock, so a title that waits on the block (XAsyncGetStatus wait=true) or on its completion callback hung forever. Each *Async slot now locates its block by argument position and runs it through XAsyncRun, failing with E_FAIL; the Result partners keep returning E_FAIL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:38:18 -08:00
8f481cf16f Merge pull request #393 from oddmaniv/fix/test-fs-host-drive
test: keep host fixtures unambiguous on G: and T: (TEST-FS-HOST-DRIVE)
2026-11-24 00:09:56 -05:00
29f66ba0fe Merge pull request #389 from lines9686-rgb/dxgi-resizebuffers-lost
OLD-8171: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host
2026-11-24 00:09:51 -05:00
e210804659 Merge pull request #369 from Mumogg/slot127-committed-resource3
d3d12_xs: device slot 127 creates the committed resource, again (RT-SLOT127)
2026-11-24 00:04:49 -05:00
2a2b1680c6 Merge pull request #362 from Mumogg/slot25-struct-return
d3d12_xs: device slot 25 takes the console's struct-return form too (RT-SLOT25)
2026-11-24 00:00:31 -05:00
d2cd6c0d97 Merge pull request #328 from Mumogg/xmem-view-protect
xmem: map physical pages without a cache modifier in the view protection, again (RT-XMEM-VIEW-PROTECT)
2026-11-23 23:31:15 -05:00
e57a7558ac test: keep host fixtures unambiguous on G: and T: (TEST-FS-HOST-DRIVE) 2026-11-24 15:25:51 +11:00
eeeda84c90 dxgi_swapchain_count_test: every chain is the offscreen ring on main now, so the failed-resize cases with matching counts expect it too
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:19:41 +03:00
3746bff239 dxgi: SetSourceSize checks the requested size after a failed ResizeBuffers; the comparison treats DXGI_STATUS_OCCLUDED as S_OK
Review by @KarolKurzyna in the original repository:
- The host answers DXGI_STATUS_OCCLUDED from Present for a window that isn't on screen, which depends on the
  desktop, so compare_failed_resize now counts it as S_OK. The failures stay strict.
- After a failed ResizeBuffers the host checks SetSourceSize against the size that was asked for (RTX 3060 Ti:
  after 16x16385, 100x10 is DXGI_ERROR_INVALID_CALL; after 16385x16 it is S_OK), so the layer does too. The
  comparison gains those two steps (17 now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:16:48 +03:00
a3090aab2d dxgi: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host
Measured against the host runtime (RTX 3060 Ti, NVIDIA 610.88, and WARP): once ResizeBuffers accepts its arguments
the old buffers are gone. If the new ones can't be made it fails, and the swap chain stays without buffers. GetDesc1
already reports the requested size and count, GetBuffer and Present are DXGI_ERROR_INVALID_CALL, and the next
successful ResizeBuffers restores everything. A side above 16384 is E_INVALIDARG on the hardware device. A call
refused for its arguments (a back buffer still held) changes nothing.

The layer answered E_FAIL and kept describing the old buffers. It now answers E_INVALIDARG for a side above 16384
before calling Vulkan (it used to pass the extent to vkCreateImage, past the device's limits) and E_OUTOFMEMORY when
Vulkan fails. It reports the requested description, refuses Present, and recovers on the next ResizeBuffers.

dxgi_swapchain_test compares 15 steps of that with the host's default adapter. dxgi_swapchain_count_test gets
failure injection on its fake Vulkan table: whether the offscreen ring or vkCreateSwapchainKHR fails (the latter
retires the old swapchain anyway), on the offscreen and on the direct path, the next resize builds a working
swapchain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 07:16:33 +03:00
81e8a6f2a4 d3d12_xs: device slot 127 creates the committed resource (CreateCommittedResource3 with Xbox descriptors, RT-5 stop 15)
Slot 127 is past the PC device vtable and was refused with E_NOTIMPL. It has the argument list of ID3D12Device10::CreateCommittedResource3; the proxy now calls the PC device's with the Xbox layout word and flag bits cleaned as slot 76 does. Measured in #6982.

(cherry picked from commit 8d622049ae)
2026-11-23 22:14:29 -06:00
992b19bd44 device_proxy_test: the slot 26 hit-count checks measure from the start of their block
The slot 25/26 cases added before this block call slot 26 four times, so its absolute counts (3, then 4) failed
on Windows. The counts are now increases from the block's start, and the forwarding check no longer shares a
line with a counter, so a counter failure is not reported as a forwarding failure.

Patch by BadgersMC, from the review of #362 (found and tested on native Windows with WARP; device_proxy_test
does not run under Wine here).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 22:14:29 -06:00
9bc1f8f1a8 xs_proxy_mock_test: device slot 25 in the console's form and the PC's
The mock device answers GetResourceAllocationInfo, and the new case calls slot 25 with the return buffer in RCX
and the device in RDX, then in the PC form: both reach the PC method with the mask, count and descriptions, and
only the struct is written.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 21:54:57 -06:00
91575fda3a d3d12_xs: device slots 25/26 take the title's C-ABI struct return
The retail executable calls GetCustomHeapProperties (device slot 26) with the
C convention: the hidden return buffer in RCX and the device in RDX. The
proxy's generic forwarder assumed the PC C++ form (this in RCX, buffer in
RDX), took the buffer for the device and crashed on its vtable right after
D3D12XboxCreateDevice.

Slots 25 (GetResourceAllocationInfo, same rule, inferred) and 26 (measured)
now get thunks that accept either form: whichever of the first two arguments
is the device proxy is `this`. The runtime's own code still calls the proxy
through d3d12.h in the PC form. device_proxy_test calls both slots in both
forms against WARP.

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

Adapted to main by Mumogg: slot 26 keeps the thunk it already has (86b8e04e4), so of this commit's two thunks
only slot 25's is installed.
2026-11-23 21:54:29 -06:00
f9d20bf9b0 d3d12_xs: Xbox device slot 70 writes a null shader-resource view instead of reaching PC CreatePlacedResource1 (retail boot chain stop 14)
(cherry picked from commit 3073250df5)
2026-11-23 21:52:25 -06:00
9e6f8ae133 d3d12_xs: device slot 48 creates a command queue proxy from the 32-byte Xbox description
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0cde63d618)

Adapted to main by Mumogg: main already routes slot 48 through its Xbox slot table (LEONIDA_XS_QUEUE_X_SLOT),
so the route now calls proxy_create_command_queue_xbox instead of a fixed slot 48 branch, and xs_proxy_mock's
check_xbox_slots and the environment case pass the console's 32-byte description.
2026-11-23 21:48:33 -06:00
c4954581ae d3d12_xs: device slot 26 takes the console's struct-return form
The retail executable calls GetCustomHeapProperties with the return buffer in RCX and the device in RDX. The forwarder took RCX for the proxy and faulted.

AI-assisted.

(cherry picked from commit 86b8e04e4c)
2026-11-23 21:46:43 -06:00
ece4ba5b31 Merge pull request #262 from Pixel-Katana/fix/reserved2-through-inner-device
d3d12_vulkan_device_test: CreateReservedResource2 through the inner device (slot 78 is SetFrameIntervalX on the Xbox proxy)
2026-11-23 22:36:36 -05:00
45676e838a Merge pull request #239 from natterman12/runtime/compat-load-no-error-dialog
pe_loader: a compat DLL Windows cannot load is refused without a "Bad Image" box (RT-COMPAT-ERRBOX)
2026-11-23 22:36:32 -05:00
c07ec72c49 Merge pull request #227 from bhimio1/feat/linux-native-support
Linux: versioned llvm-mc, Build.sh/Mods.sh, case diagnostic, portable runtime tests, docs/linux.md
2026-11-23 22:36:28 -05:00
dc3d140958 Merge pull request #194 from ItsMrDubey/cmake-spirv-translator-deps
runtime: build.py shader rules depend on every translator module (OLD-3752)
2026-11-23 22:36:24 -05:00
6b74e8ecfa Merge pull request #127 from Mumogg/gameinput-ordinal-1
gameinput: serve GameInput.dll's ordinal 1 again (RT-GAMEINPUT-ORD1)
2026-11-23 22:36:20 -05:00
61653ac772 Merge pull request #66 from Pixel-Katana/fix/depth-resolve-refused-lists
d3d12_depth_resolve_test: clears, resolve and read-back as three lists (refused cases fail since 4da716493)
2026-11-23 22:36:16 -05:00
fabe844cd8 Merge pull request #131 from Mumogg/restore-directstorage
runtime: restore the console DirectStorage shim, with the typed-error inflate it needs (RT-DSTORAGE-RESTORE, #47)
2026-11-23 22:36:12 -05:00
f70ed489f5 xmem_test: the write-combine window's page is written before its view is queried
main's xmem commits a physical page on first touch, so the check added with the view-protection fix has to touch
the page first, as the read-write case above it does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 21:10:20 -06:00
8d4dd7a80c xmem: keep PAGE_GUARD in the view protection; only the cache modifiers are dropped
PAGE_GUARD is an access alarm, not a cache modifier (review on #7492). The comment
also says what the write-combine bit does on Windows, where the view is created
write-combined and #7218's import of those pages refuses it.

(cherry picked from commit 954fcb1061)
2026-11-23 21:09:28 -06:00
80ed5dd304 xmem: map physical pages without a cache modifier in the view protection
Three of the retail executable's five physical-page windows carry 0x400
(PAGE_WRITECOMBINE on the PC) next to PAGE_READWRITE. host_protect drops only the
PAGE_GRAPHICS_* range, so map_page passed PAGE_READWRITE | PAGE_WRITECOMBINE to
MapViewOfFile3, which refuses it with ERROR_INVALID_PARAMETER: the first
XMemMapPhysicalPages into such a window failed and the title's descriptor-heap
setup returned false.

view_protect now drops PAGE_WRITECOMBINE, PAGE_NOCACHE and PAGE_GUARD.
xmem_test maps a page into a window reserved with that protection.

AI-assisted.

(cherry picked from commit 7e8e3c1db1)
2026-11-23 21:09:28 -06:00
bc887c4366 runtime: the build.py shader rules rebuild when any translator module changes 2026-11-24 08:38:21 +05:30
e1e6343b9a check: ms_wave_info_s3 is judged on a 32-wide device, only ms_w64x_ballot needs 64 lanes 2026-11-24 08:38:21 +05:30
0e0db89c68 check: a NaN in the mesh gradient readback is a failing pixel 2026-11-24 08:38:21 +05:30
5ab00f8003 d3d12_vulkan_device_test: shorter comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:58:09 -06:00
4f26b1de32 d3d12_depth_resolve_test: shorter comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:57:12 -06:00
fadad913ec d3d12_vulkan_device_test: CreateReservedResource2 through the inner device, not the Xbox proxy
2dbcb882c (#6935) routes the Xbox-ABI device proxy's slot 78 to the console's SetFrameIntervalX. On the PC
ABI that slot is ID3D12Device10::CreateReservedResource2, which this test called through the proxy, so the
call answered S_OK with a null resource and GetResourceTiling of it gave 0: "line 6576: tiles == 1"
("d3d12_xs: device slot 78 routed to SetFrameIntervalX" in the log).

The Device10 call now goes through the inner Vulkan device, and the test checks that both resources were
created, so a success without an object fails at the call instead of at the tile count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:54:29 -06:00
682fd0561c pe_loader: a compat DLL Windows cannot load is refused without a "Bad Image" box
resolve_compat() calls LoadLibraryExW on a file from LEONIDA_COMPAT_DIR. For
a file Windows cannot map (truncated, wrong machine, not a PE image) the
system raises a modal "Bad Image" hard-error box, and LoadLibraryExW does
not return until someone clicks OK. The loader reports that failure itself
one line later, so the box only stalls it: gta6rt hangs on a headless
machine, and loader_test, which writes such a file on purpose, waits for a
click in every unattended ctest run.

The load now runs with SEM_FAILCRITICALERRORS set on the calling thread, and
the thread's previous error mode is restored afterwards. The Windows error
code is read before the mode is put back.

loader_test checks that the mode comes back unchanged, that the message
still carries the error code, and that the refusal does not wait on a box.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 21:50:56 -05:00
e6ca5cb29e Merge pull request #19 from moffington/contrib/pipeline-library-upstream
Add slot-67 pipeline-library shader build and runtime loading
2026-11-23 21:27:26 -05:00
a5b38384bd Merge pull request #16 from Pixel-Katana/fix/main-test-regressions
Runtime tests: fix two failures on main (d3d12_com stale depth-clear check, root_sig merge of two checksum fixes)
2026-11-23 21:27:03 -05:00
e0f76d28b5 gameinput: serve GameInput.dll's ordinal 1, the retail executable's GameInputCreate import
The retail executable imports GameInputCreate from GameInput.dll by ordinal 1. The loader looks ordinal imports up
as "#1", which the shim table did not have, so the import bound to the host's GameInput.dll. On Windows the
installed GameInput answers; under Wine it is the builtin stub, the call fails and the title stops on its result.
The alias maps #1 to the same GameInputCreate, and gameinput_test checks it.

(cherry picked from commit 5e45c7da94)
2026-11-23 20:23:21 -06:00
2d7be48dec runtime: restore the console DirectStorage shim (DStorageGetFactory) on main
The merge that brought the mirrored pull requests into main (6dece9231) left the DirectStorage shim out, noting
that it "needs the typed-error zlib inflate". The shim's commits (f87d05fdd, ac1843da2, 00551ba00, by
mariuslozo-boop and Kelebek) are ancestors of main, but its files are not in the tree, so the retail
executable's XCRDAPI.dll!DStorageGetFactory import is unimplemented (issue #47, stop 5 of
docs/retail_boot_chain.md).

- shims/dstorage.cpp, shims/dstorage_xs_abi.h, test/dstorage_test.cpp and docs/directstorage.md are back as
  those commits left them.
- leonida::zlib_inflate reports why it failed through an optional ZlibError* (header, data, checksum, limit),
  which the shim turns into its E_DSTORAGE_ZLIB_* codes. This is the same interface the shim was written
  against, added to main's current table-driven inflater; callers that pass no pointer behave as before.
- registry.cpp classes xcrdapi.dll!DStorageGetFactory as an HRESULT import, the retail spelling #47 found
  missing.
- CMake and scripts/build_runtime.ps1 build the shim into gta6rt, and CMake builds and registers dstorage_test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
2026-11-23 20:23:21 -06:00
919715b83c d3d12_depth_resolve_test: clears, resolve and read-back as three lists
Since 4da716493 the layer refuses a whole ExecuteCommandLists batch that holds a list whose Close failed, as
D3D12 must not be given one. resolve_and_read recorded the clears, the resolve and the read-back copy in one
list, so a refused resolve now took the clears and the copy with it and the eight refused cases read back an
unwritten buffer: "refused D24S8 depth AVERAGE rect 1: Close 0x80070057, destination changed" and seven more.

The resolve is now a list of its own between a setup list (clears, edge draw, barriers) and a copy list
(barrier, read-back). Each runs as its own batch, so the layer refuses only the resolve and the test checks
that the destination keeps its clears. The host path is unchanged: a resolve whose Close fails is still never
executed there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:11:04 -06:00