Commit Graph

4696 Commits

Author SHA1 Message Date
c682bbd0d3 tests: several threads make the first CheckFeatureSupport(D3D12_OPTIONS1) call of a new device
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:20:20 +03:00
cf0671b488 frame_pacer: a present before the origin event is armed is not a frame in flight
PresentX presents with sync interval 0 until SetFrameIntervalX and
ScheduleFrameEventX are both done, but the pacer queued each of those
presents for its own vblank as soon as the interval was set. Blank
presents of a loading screen made the first WaitFrameEventX wait one
period for each of them (1000 presents: 1000 periods).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:19:12 +03:00
fe21bbd0cc vk_pc_tail: destroy the --pc-tail-ubo block so vk_bindless_test leaks nothing
PcTail::create made two set layouts, a descriptor pool with its set, a
buffer and its memory, and kept the pool, buffer and memory only in
locals. vk_bindless_test destroys everything before vkDestroyDevice, so
with LEONIDA_PC_TAIL_UBO=1 and LEONIDA_VK_VALIDATION=1 the validation
layer reported the six leaked objects (VUID-vkDestroyDevice-device-05137)
and ps_tex failed with "1 validation errors" although every pixel was
right.

Keep the handles in PcTail, add destroy(), and call it in
vk_bindless_test's teardown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:18:52 -06:00
9ec296cc40 Runtime: unbind scissor rectangles on zero-count D3D12 call 2026-11-22 20:16:54 -05:00
7204c1d52c build.py: -h and --help print the usage instead of building into "./--help"
main() took sys.argv[1] as the output folder, so `build.py --help` translated every
test shader into a folder named "--help". Now -h/--help print the module docstring and
exit 0; every other invocation is unchanged.
2026-11-23 02:16:26 +01:00
003baa94c1 Merge origin/main into queue-wait-before-signal 2026-11-23 02:15:15 +01:00
85a6cf6095 Merge remote-tracking branch 'origin/main' into bindless-per-queue-retire
# Conflicts:
#	runtime/src/vulkan_replay.h
#	runtime/test/d3d12_descriptor_test.cpp
2026-11-23 02:14:56 +01:00
921a959b72 Merge upstream main into pipeline checker input protection
Keep both the filesystem header for identity checks and the upstream type traits for the large-module budget. Preserve the input checks and CLI coverage.

AI-assisted (Codex).
2026-11-22 22:14:33 -03:00
3693ce73e6 d3d12_xs: let a fence at SignalX slot 25 carry the newer-layout evidence
shdann's report on #2490: on a device whose queue layout is still
undetected, the first SignalX at slot 25 answered S_OK without
signalling — the fence never completes and a title waiting on that
value hangs. The Signal/Wait detection at slots 16/17 only helps a
title that calls them; one that signals exclusively through SignalX
(the console-native path) would lose every signal, not just the first.

Per the measured table (docs/d3d12_xs_console_abi.md §4) the
fence-first queue methods are Signal/Wait/SignalX only, so a proxy
fence arriving at slot 25 while the layout is fully unknown is the
newer layout's SignalX: mark the shared detection newer and forward it
as Signal. A proven-older device still leaves slot 25 to the
console-only no-op, and a fence at slot 23 forwards without pinning so
a newer title's own SignalX detection stays open.

The mock's new check_signalx_detection covers the lost-signal repro
(hr=0 calls=0 on the first SignalX), detection inheritance on a second
queue, the proven-older no-op at 25 and the non-pinning forward at 23.

Written with AI assistance (Devin). Verified with the clang-cl/xwin
cross-build under Wine: xs_proxy_mock_test PASS, loader_test 87/0.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 18:00:25 -07:00
0a2b6edb90 vulkan_present: ask for COLOR_ATTACHMENT on the window swapchain, for overlays
The presenter only blits or copies into the swapchain images, so it asked
for TRANSFER_DST (and TRANSFER_SRC with capture). Overlays that hook the
swapchain draw their own frame into those images through a framebuffer:
Bandicam's VK_LAYER_bandicam_helper raised 22 VUID-VkFramebufferCreateInfo-
pAttachments-00877 and 22 VUID-VkImageViewCreateInfo-image-04441 in
xbox_present. Every surface reports COLOR_ATTACHMENT, and the DXGI
swapchain already requests it; with it the overlay's framebuffers are
valid. docs/d3d12_vulkan.md no longer calls the swapchain TRANSFER_DST-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:59:34 -03:00
6c2f31e61e fix(xtaskqueue): harden wait registration lifetime and dispatch
(cherry picked from commit 4129a8ae9508c88b96301b6422d3131525e1d02d)
2026-11-22 21:59:14 -03:00
aac68ca651 fix(xtaskqueue): prevent reentrant context enumeration deadlocks
Replace AtomicVector context visits with cursor-based enumeration and safe pinning. Add deterministic reentrancy and concurrent attach/detach regression tests.

Compatibility: contexts without the private pinning capability are rejected. Win32 WaitRegistration lifetime issues remain outside this commit.
(cherry picked from commit d808cfb538d8a65e24b42a86b89afd22d497b14b)
2026-11-22 21:59:14 -03:00
c93b8ea8c6 feat(xtaskqueue): add safe context pinning capability
(cherry picked from commit 2381f5c749b7e284535ad5614a27101a98751de5)
2026-11-22 21:59:14 -03:00
2c1a143f9e refactor(xtaskqueue): integrate atomic API reference lifecycle
(cherry picked from commit eb2ee925db613467e237c032bc7b8eb99ae156aa)
2026-11-22 21:59:14 -03:00
e05b3da707 refactor(xtaskqueue): introduce atomic API reference state
(cherry picked from commit 2c16a9c16ee4f8112d1a1a8d51802d2d30e775cb)
2026-11-22 21:59:14 -03:00
a6f9bc4b24 slot 67: the description pinned from the DLL's code, a test built the DLL's way, every failed call logged
A tester on #3951 saw a slot-67 lookup miss with the real FidelityFX DLL where the base build had none, and read it as
the proxy taking one program's kind 6 with another program's kind 0.

Pinned from the DLL's code and run on all 29 payloads: its FSPX reader (0x1a20) and the same loop inline for a
container store kinds 0, 1, 6 and 7 in four pairs from one payload, and the pipeline function copies them to +0x08,
+0x18, +0x28 (the kind-6 copy, with kind 6's own size at +0x30) and +0x38 of the description. That is the layout the
proxy reads, and code and state of one call always come from the same program. A harness that maps the DLL without
running it, calls its reader on each payload and builds the description that way resolves every translated program
to its own entry through slot 67 on the Vulkan device (26 of 29 on main aa2988cc; the other 3 are refused), on
llvmpipe, the integrated GPU and the RX 7900 XTX.

So the proxy does not mix programs. What fits the report: with slot 11 answered, the DLL goes on to its next pipeline,
which that translation (20 of 29) does not have; only the first call of a slot is announced, so the miss read as the
first call's.

- d3d12_xs_device.cpp: every failed slot-67 call is logged with its number and the four sizes.
- d3d12_fspx_compute_test: dll_slot67 builds the description from a container's own directory the way the DLL does
  (reader pair order, pointers into the payload, kind 6 copied into a 256-rounded buffer padded with 0xcc); each
  program resolves to its own translation with its own state. A proxy that read kind 0 from +0x18 or kind 6 with
  the rounded size fails the test.
- docs/fspx.md, d3d12_command_objects.md, d3d12_vulkan.md: how the layout was pinned, and what happens when a later
  program is not translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:54:26 -05:00
a6f6f054c5 Load the packaged shader directory on Wine and Windows 2026-11-23 00:53:11 +00:00
137dcfbb88 Reject incomplete and non-finite computed I/J frames 2026-11-23 01:53:09 +01:00
36aecce11c Honor cgroup v2 limits at the mounted root 2026-11-23 01:53:09 +01:00
f95bea1d88 shims/loader: GetModuleFileName answers for the mapped images
GetModuleFileName was host-bound, so a mapped image asking for its own
path got gta6rt.exe's. The bundled-module ops now expose the main image
and each module's load path: GetModuleFileNameA/W return the mapped
module's path (the exe for a null handle, any bundled module for its
base) and GetModuleFileName falls through to the host otherwise.
GetModuleHandle(nullptr) answers the mapped exe's base the same way.
A unix-absolute stored path is spelled Z:\... under Wine.

First use measured: the package's game_scarlett_master.exe (a payload
verification probe, not the engine) took its own module path as the
scan root and verified the full 1.0.2.1 payload through the file
layer — 104/104 files, 223,534,748,018 bytes, rpf 22/22, ttpf 57/57,
png 5/5, dll 16/16, bad magic 0 — verdict PASS, exit 0.

Tested: clang-cl 20 + xwin cross-build clean; loader_test 87 checks,
xs_proxy_mock_test PASS under Wine. AI-assisted.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:53:08 -07:00
4c8082bb95 vk_pipeline_check: count big-skipped stages in the isolate summary (BUILD-1232)
The parent built all_stages from modules_ok, modules_bad and stats but not big_skipped, so a stage whose only result was a BIG SKIP never got an ISO-RESULT and was missing from the summary. Use a shared summary_stages() helper that includes all four maps, with a CPU fixture that fails on the old helper.
2026-11-22 16:52:50 -08:00
c77338e673 docs: DirectStorage ABI evidence, chosen console ABI and the shim
docs/directstorage.md records which DLL and ABI the console title is expected
to use (dstorage_xs.dll medium, xcrdapi.dll and dstorage.dll low confidence),
what is not public (vtable order, interface ids, some constants) and the choice
made for each, what owning the modules shadows at run time, what the shim does
(including the order of its request checks), and what later PRs add (zlib,
BCPack, swizzle, physical pages, GPU-backed destinations, parallel reads).
Index row in docs/README.md; the owned-module list in runtime_imports.md and
the shim list in runtime/README.md name the new modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:48:51 +01:00
f87d05fdd3 runtime: console DirectStorage (DStorageGetFactory) with file-to-memory reads
Serve the Xbox DirectStorage API (IDStorageFactoryX2, IDStorageQueueX2,
IDStorageFileX, IDStorageStatusArrayX) under dstorage_xs.dll, xcrdapi.dll and
dstorage.dll. Declarations are our own (shims/dstorage_xs_abi.h), written from
the public GDK reference; layouts are pinned with static_asserts.

- OpenFile goes through the registry's kernel32!CreateFileW, so GAME: paths use
  the console path mapping and the write overlay. GetHandle returns a ReOpenFile
  handle with its own file position.
- One worker thread per queue runs submitted entries in order: file and memory
  requests, status arrays, ID3D12Fence::Signal, EnqueueSetEvent (on a duplicate
  of the title's handle taken at enqueue).
- Auto-submit at half the capacity (or disabled through DSTORAGE_QUEUE_OPTIONS),
  enqueue into a full queue waits, CancelRequestsWithTag (a cancelled request is
  a success and not a failure), error record and error event, Close and the last
  Release drain the queue, IDStorageFileX::Close waits for the file's submitted
  reads.
- Request checks: reserved bits, source type, BCPack/swizzle ranges, sizes,
  1 GiB limit, null and foreign objects and closed files (also for zero-size
  requests), end of file, inaccessible memory.
- zlib, BCPack, swizzle and physical pages return E_NOTIMPL (later PRs).
- Interface ids of the X interfaces are not public: a creating call accepts and
  logs a new id per object kind, but refuses system COM ids (IMarshal,
  IAgileObject, ...) and the PC DirectStorage ids; QueryInterface accepts only
  IUnknown, the PC IDStorageStatusArray id (same shape) and the ids creating
  calls accepted for that kind. Bad arguments are logged once per method.
- registry.cpp classifies xcrdapi.dll!DStorageGetFactory as HRESULT; the cl.exe
  fallback in build_runtime.ps1 builds the new shim too.

ctest dstorage: 258 checks over synthetic files in %TEMP%, no GPU, no game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:48:51 +01:00
7c2252609d D3D-448: console root-argument layout, measured for compute and used there
rt::rootsig::pack_stage() lays a root signature out for one stage the
way the console compiler does: root order from the stage base, a table
one dword (its 32-bit VA), a root view two, constants one per value,
and the first parameter that does not fit refused (the spill array
behind s[0:1] is not modelled).

Compute (base s4) is measured: on the package's FidelityFX DLL, whose 29
compute containers carry their RTS0 next to the console-compiled program,
base plus span equals RSRC2 USER_SGPR in 29 of 29, and
root_sig_contract.py --model console finds all 20 translated programs
compatible (the s0 model contradicts 7). VS/PS/GS s8 and MS s16 stay a
census hypothesis.

The compute bind point now uses this layout; graphics keeps pack(),
since every stage reads one push-constant block and a mesh shader (s16)
and a pixel shader (s8) would collide. A signature carries both
layouts; binding it where its layout refused it invalidates the list.

Test fixtures follow: the compute GLSL shaders read the new places, and
the asm fixtures a D3D12 compute PSO runs are built with
LEONIDA_USER_DATA_SHIFT=4 (compute_fixture.py shifts every SGPR and the
RSRC2 user count), so the standalone harness keeps using them at s0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:44:40 +01:00
309052ad31 shims: harden the shared device state on the review pass
- upload_state is installed by compare-exchange: lists record on
  several threads at once, and the first two AllocateUploadMemory
  calls could each build an arena — the loser's chunks stay valid
  but unreachable by upload_translate, so their VAs would cross to
  the GPU untranslated.
- A queue on a proven-newer layout no longer downgrades the shared
  detection to older when a non-fence argument reaches slot 16/17
  (a malformed Signal/Wait): once a fence marks the newer layout it
  is not reversed.
- The queue-proxy comment said the console slots were still refused
  with E_NOTIMPL; PresentX is wired to the presentation now, SignalX
  forwards as Signal and the unmodelled pacing slots answer S_OK.

Tested: clang-cl 20 + xwin cross-build clean; xs_proxy_mock_test
PASS under Wine. AI-assisted.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 17:44:11 -07:00
bac101ae8b pe_loader: refuse a section that overlaps the headers
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 01:42:59 +01:00
2036d725c5 file_system: T:\ is a root: always a folder, never removed or moved
Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
2026-11-23 01:42:59 +01:00
5b3eb785cb DXGI: RegisterStereoStatusWindow/Event return S_OK with a cookie
Both returned E_NOTIMPL, which Microsoft documents only for the Windows 7 Platform Update. They now return S_OK with a unique cookie for UnregisterStereoStatus; stereo is never enabled so nothing is notified. Test: dxgi_swapchain.
2026-11-22 19:42:00 -05:00
0fbf9cd92f d3d12_boot_movie: wait on the fence, skip sRGB and label the round-trip checks
Address the review nits: a real Win32 event makes run_list wait for the fence
instead of relying on the readback Map; the two always-PASS check(true, ...)
calls become labelled checks of upload_and_verify with an early return; an sRGB
swapchain skips the pixel comparison with an explicit line instead of failing on
gamma-encoded bytes; <memory> is included for std::make_unique.

Verified with the real 3840x2160 movie under Wine/Xvfb: 1:1 exact
8,294,400/8,294,400, worst 0; temporary 1600x900 window: 1,440,000/1,440,000
within 2, worst 1.
2026-11-22 21:39:24 -03:00
d76b715f7e w64_graphics: skip fixtures that need many live lanes on the measured fragment width (ps_live_width), not the reported subgroup size 2026-11-22 19:38:57 -05:00
a3f28baa34 bvh_builder_test: hold a reference on each hooked PSO until its vtable is restored
restore_all_pso_vtables could write into a PSO the builder had already released.
Take an AddRef through the original vtable when hooking and drop it after the restore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:38:25 +01:00
9366e54f97 Loader: delete helper clones at exit again; a throwing reservation fails cleanly
From the second review of 89cec3b8:

- The first load_tls_host_clone call is now the home clone, from .CRT$XCT,
  and it registered cleanup_tls_clones_at_exit with atexit before
  g_tls_clones was dynamically initialized in .CRT$XCU. The vector's
  destructor then ran first and the cleanup walked a destroyed vector, so
  --dry-run, --init and every return-1 path left the slot clones'
  leonida_tls_host_<pid>_<slot>.dll files in %TEMP%. g_tls_clones is now
  allocated with the first record and never destroyed, and the atexit
  handler is registered there. The home clone cannot be deleted while it is
  mapped (DeleteFileW and a POSIX-semantics delete both fail with
  ERROR_ACCESS_DENIED), so it is left for the next run's sweep, as the
  README says.
- process_alive() took an ended process as alive while another process
  still held a handle to it (CMake's execute_process does), so the next
  run's sweep skipped its files; it now reads the exit code.
- reserve_tls_index0 catches what reserve_index0 throws (for example
  std::filesystem::temp_directory_path) and stores it as the reason, so the
  reservation fails before main with a message instead of ending gta6rt.
  The owner's file name is taken before the move, so nothing can throw
  between the move and recording it.
- Tests: run_tiny_tls_clone_cleanup runs gta6rt --dry-run, --init and
  --dry-run on tiny_tls_clones.exe (three TLS modules, so one slot clone)
  and checks that each run's PID leaves no clone file but its home clone and
  that the next run deletes that one; it fails with the old cleanup.
  run_tiny_tls_ga also runs with TMP and TEMP naming a missing folder: the
  reservation fails, --run and --init refuse the image with the reason and
  run none of it, --dry-run maps it with the note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:38:19 +01:00
a2542ccd6f Loader: reserve TLS index 0 at start, with a home template that copies the EXE's
Fixes from the review of the index-0 change:

- The lazy move at the first executable map stopped other threads and swapped
  their slots, guarded by a "thread is inside gta6rt.exe" check. That is not
  enough: MSVC keeps &ThreadLocalStoragePointer[_tls_index] across calls
  (zlib_inflate saves it at [rbp-80h] across memset, push_back and
  inflate_codes, then reads _Init_thread_epoch through it), so a thread
  stopped in the heap or memset still reads the wrong slot afterwards. The
  move is now rt::reserve_tls_index0(), done once at process start: gta6rt
  calls it from a .CRT$XCT initializer, before its own static initializers
  and before any of its threads; the CRT startup frames above it hold no TLS
  slot address (checked in the disassembly). It swaps slots 0 and home on the
  calling thread only; no thread enumeration, suspension, TEB writes or
  TlsAlloc mark are left.
- The home clone's block was the helper's 514 bytes, smaller than
  gta6rt.exe's 1398-byte TLS. The home clone is now written from
  gta6rt_tls_host.dll with its TLS directory pointed at a new 16 KiB export,
  gta6rt_tls_home_template, filled with a copy of the EXE's template and its
  alignment (LdrpAllocateTls copies End - Start and ignores SizeOfZeroFill,
  so the zero fill is part of the range). Every new thread then has a fresh
  copy of gta6rt.exe's TLS at the home index from its first instruction, so
  no adoption step or window before the helper's DLL_THREAD_ATTACH is left.
  The mapped template is checked against the EXE's after the load.
- The owner is GetModuleHandleW(nullptr) with _tls_index 0, not any module
  whose index reads 0.
- A primary helper without gta6rt_tls_host_set_thread_event is refused.
- An executable that does not get index 0 (no reservation, or another
  executable holds it) is refused by --run and --init with an error; its /GA
  code would read and write another module's TLS through slot 0. The README
  no longer says it "reads the first one's slot 0".
- Thread attach installs every module's copy before any TLS callback runs,
  as Windows allocates all blocks before the first DllMain.
- Tests: loader_tls_index0 (runs) checks this EXE's block moving from slot 0
  to the home index by identity, the home template's size and content, and
  that the getter reads slot 0 with its _tls_index pointing elsewhere (fails
  for a non-/GA build of the fixture); loader_tls_index0_threads reserves
  while threads are being created, with one suspended thread that has no TLS
  array yet and tiny_thread_hook.dll running test code before the helper's
  DLL_THREAD_ATTACH; loader_tls_index0_noreserve maps without the
  reservation. The tiny_tls_ga.cpp comment names the real test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:38:19 +01:00
66a7dbc1cd Loader: a mapped executable owns module TLS index 0
Windows gives the process executable module TLS index 0, and MSVC code built
with /GA reads TEB->ThreadLocalStoragePointer[0] without loading _tls_index.
The loader gave a mapped EXE a gta6rt_tls_host.dll clone's index instead, so a
thread_local int v = 42 EXE built /O2 /GA /MD printed tls_index=6 value=0
under gta6rt --run (natively tls_index=0 value=42).

Index 0 belongs to gta6rt.exe itself (and to each test EXE that links
pe_loader.cpp): measured through _tls_index == 0 before any mapping and the
new tls_index0 trace event. All of its own TLS reads go through _tls_index,
so the first time an executable is mapped the loader loads one more helper
clone (leonida_tls_host_<pid>_home.dll), stops the other threads, swaps
slots 0 and the clone's index on every thread and writes that index into the
owner's _tls_index. Threads started later swap their own slots first thing
in the helper's DLL_THREAD_ATTACH. Both pointers are OS-allocated blocks of
that thread and the OS frees every slot at thread exit, so the swap is
permanent and nothing is restored. The executable then takes slot 0
(kMainImageSlot) through the existing per-thread install, thread events and
~Loader paths; DLLs keep the helper indices. A second executable mapped
while one is live, or a move that cannot be made (a thread kept running in
the owner's code for 250 ms), gets a helper index and a stderr note.

Measured on Windows 11 26300 to make the swap safe: a new thread publishes
its TLS array in the TEB only once it is filled (LdrpAllocateTls), an ending
one clears it before freeing the blocks (LdrpFreeTls), LoadLibrary of a TLS
DLL updates other threads in one NtSetInformationProcess call, and an EXE's
TLS callbacks run after every DllMain for thread attach and detach.

Tests: loader_tls_index0 maps tiny_tls_ga.exe (built /GA, code shape
checked) next to tiny_tls.dll: 42 on the loading thread, a pre-existing
thread and new threads, this EXE's own TLS intact on all of them, two runs
in a row, a second executable at once, and a busy thread holding the move
off. run_tiny_tls_ga runs it under gta6rt --run and --init and checks the
trace names gta6rt.exe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:38:19 +01:00
fdbb95d6db Runtime: compare fence and queue semantics with the host (D3D-48)
Add a comparison test that runs the same Signal/SetEventOnCompletion/GetCompletedValue sequence on both the shim and the host PC runtime and asserts their completed value and HRESULT agree. A signal of an already-passed (lower) value is a documented deviation (the shim stays monotonic because a Vulkan timeline cannot go back), so it is checked against the documented behaviour rather than the host. No game files; runs on WARP or any D3D12/Vulkan GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:37:32 +01:00
5079b48734 test(shader): cover mesh allocation across a wave64 barrier
Exercise the round scheduler with both waves sending the allocation, and
the structured scheduler with only wave 1 sending before wave 0 exports.
Both fixtures keep the existing full-frame gradient expectation.

Refs: #4247, #4084
2026-11-22 19:34:41 -05:00
39edabb2ea d3d12_buffer_uav: excuse only the measured Intel R11G11B10_FLOAT clamp
The layer and model() share uav_clear::encode, so "the layer matches
uav_clear.h" proved nothing and the previous loop excused any mismatch on
any adapter. Report a host quirk only for an Intel adapter (vendorID
0x8086), R11G11B10_FLOAT, host bytes equal to the clear clamped to [0, 1],
and layer bytes equal to model(); everything else is compared with the
host as before. The message names the first differing byte.

AI-assisted (Claude Code).
2026-11-22 19:33:59 -05:00
45a4d888e8 d3d12_state_sweep_test: blend, depth and stencil state against the host D3D12 device
482 full-screen draws (every colour and alpha blend factor pair, blend
operations, write masks, sRGB, float, 10-bit, 16-bit and SNORM targets,
the depth comparison functions with and without writes, stencil
functions, pass, fail and depth-fail operations, read and write masks, and
the back face's own state) run on the layer and on the host device on the
same adapter, and the colour and stencil bytes are compared.

AI-assisted.
2026-11-23 01:33:20 +01:00
1e0b4cdd56 Runtime: refuse unlisted RTV formats on typed BGRA8 textures with a list
A typed B8G8R8A8 or B8G8R8X8 texture with a castable-format list took
an RTV in a format the list doesn't name (its own sRGB format, say) and
silently kept the image's format, where a typed R8G8B8A8 texture with a
list refuses it. CreateRenderTargetView now refuses it for these
textures too; without a list they keep the image's format, as before.

d3d12_clear_test's negative check covers a B8G8R8A8 texture listing
R8G8B8A8 and a B8G8R8X8 one listing B8G8R8A8 next to the R8G8B8A8 one:
each takes its own and its listed format and refuses 3 formats its list
doesn't name. Without the shim change it fails on the B8G8R8A8 texture's
unlisted B8G8R8A8_UNORM_SRGB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:33:07 -03:00
1c604af1a0 vk_pipeline_check: large modules share a memory budget instead of compiling alone
Modules over --large-module-bytes compiled one at a time with every other thread waiting. On the translated
corpus that is 695 modules (the ray-tracing compute shaders, ~14k RDNA2 instructions each, ~4.9 MB of SPIR-V),
about 12 s and 2 GB each on RADV GFX1201, so the pipelines stage spent hours mostly single-threaded.

large_module_gate.h lets large modules in while 512 bytes per SPIR-V byte fits 3/4 of the memory available at
start (Linux: MemAvailable and the cgroup v2 memory.max room up the tree; Windows: ullAvailPhys), one always
admitted when none is in, small modules never held back. Unknown memory keeps the old exclusive gate, as does
--large-parallel 1. malloc_trim(0) after each large module returns what glibc kept in per-thread arenas.

40 modules (27 large), Mesa shader cache off, RX 9070 XT / Mesa 25.3.6: 297 s -> 83 s on 6 threads (7.1 -> 8.3 GB
peak), 56 s on 12 threads (15.1 GB).

Tested: large_module_gate_test (Linux, and the clang-cl build under Proton), ctest on Linux (40 passed, 2
skipped), vk_pipeline_check over 40 real modules in three modes, and the pipelines stage over the corpus with the
gate: 26,000+ of 26,503 modules in 15 min, none failed. The largest module (26 MB of SPIR-V) was still compiling
alone on RADV after 25 min, as it would under the old gate. AI-assisted.
2026-11-23 00:30:02 +00:00
e27efbc11d dxgi: CheckInterfaceSupport reports the adapter's real UMD driver version
IDXGIAdapter::CheckInterfaceSupport(IDXGIDevice) reported a user-mode
driver version of 0. Host DXGI reports the adapter's, which titles read
as the driver version. The layer now reads it the way DXGI does,
D3DKMTOpenAdapterFromLuid + D3DKMTQueryAdapterInfo(
KMTQAITYPE_UMD_DRIVER_VERSION) on the adapter's Vulkan deviceLUID,
looked up from gdi32 at run time (0 kept when missing or failing, e.g.
under Wine); the host dxgi.dll isn't used. Measured equal to host DXGI
on an RTX 5060 Ti (0x0020000000100842, driver 621.14) and on WARP.

dxgi_swapchain_test compares it with the host adapter of the same LUID
(host dxgi.dll loaded at run time); fails on main with 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:28:55 +01:00
a55ba1febb Runtime: prototype explicit InnerCoverage library contract and GPU comparison 2026-11-22 20:27:48 -04:00
77f00b6027 d3d12: refuse GPU-written KHR instance lists before CPU staging
Only CPU-writable heaps expose a host pointer to replay, so DEFAULT and READBACK pointer lists are refused as unsupported instead of being read from possibly stale mapped bytes. Reuse completed staging buffers and write translated addresses directly. Adds a GPU-copy-produced placed-DEFAULT regression with a negative control.

AI-assisted (OpenCode)
2026-11-23 03:24:21 +03:00
429edff313 dxgi: Set/GetMatrixTransform answer DXGI_ERROR_INVALID_CALL, as on the host
IDXGISwapChain2::SetMatrixTransform/GetMatrixTransform stored and
returned a matrix on every swapchain. A matrix transform belongs to
composition swapchains (CreateSwapChainForComposition, E_NOTIMPL in the
layer); host DXGI answers DXGI_ERROR_INVALID_CALL to both on an HWND
swapchain, with a matrix and with null (Windows 11, RTX 5060 Ti, driver
621.14). Both now give that answer, and the stored matrix goes.

dxgi_swapchain_test asserted the round-trip; it now checks the host's
answer for the four calls (fails on main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:24:19 +01:00
bea9a6d590 shader_library: build the JSON object without a pair of an incomplete Json (Clang) 2026-11-23 03:22:43 +03:00
b9a8aca16a GPU tests: skip a draw when any stage needs OpFmaKHR the device lacks
docs/testing.md says a module that needs OpFmaKHR exits 77 (a SKIP) on a
device without VK_KHR_shader_fma, but only the fragment module was checked
in vk_harness, and vk_texture_test, vk_sampler_test and vk_bindless_test
never refused the vertex module (vs_ids carries FMAKHR). Under
LEONIDA_FMA=khr such a pair failed vkCreateGraphicsPipelines with -13 and
run_gpu_tests.py reported a FAIL.

ShaderFma::accepts_file() checks one module file. vk_harness (vertex module,
VKH_MESH_COMPUTE module), vk_texture_test, vk_sampler_test and
vk_bindless_test use it for every stage; vk_sampler_test also enables the
feature when the device has it, like the others. judge_cs_dump treats exit 77
with an "unsupported:" line as a skip for the non-wave64 dumps too
(cs_w32_new_ops).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015z45kpL5aWzXuYTbhn6b52
2026-11-22 21:19:17 -03:00
8dfe9bce1a runtime: notify QueueHolds when a held CPU Fence::Signal fires
When ID3D12Fence::Signal is deferred behind a pending GPU queue signal,
Fence::Signal enqueues a FenceWaitDispatcher callback that calls
vkSignalSemaphore directly instead of going through VulkanFence::signal.
That callback previously never notified QueueHolds via
holds().signaled(semaphore, value) and holds().pump_ready(), leaving any
cross-queue Wait-before-Signal batch stalled on that fence value
forever even after GetCompletedValue() reached it.

Record whether vkSignalSemaphore succeeded, decrement held_ first, and
then call holds().signaled(semaphore, value) and holds().pump_ready()
with no dispatcher or queue lock held. Add cross-queue regression cases
to check_held_cpu_signal in d3d12_fence_timing_test.cpp covering both a
Wait queued before the held CPU Signal and a Wait queued while the CPU
Signal is already held.

Claim: https://github.com/ItsNotRexed/Leonida/issues/4084#issuecomment-7088187469
AI-assisted: yes (Antigravity)
2026-11-22 21:17:10 -03:00
7ef3295f7a d3d12_buffer_uav: report a host typed-clear quirk when the layer matches uav_clear.h
Intel's D3D12 on Xe-LP (32.0.101.7092) writes the R11G11B10_FLOAT clear
(1.0, 2.0, 0.5) as 0x701e03c0 (G = 1.0, as if clamped to [0, 1]); the
layer, uav_clear.h and NVIDIA's D3D12 give 0x702003c0. Check each supported
case against model() too: when the host differs from it and the layer
matches it, report a host quirk and don't count the case, as
d3d12_depth24_compare.h does. A layer that differs from uav_clear.h still
fails.

AI-assisted (Claude Code).
2026-11-22 19:15:07 -05:00
f73fba1b4c runtime/winhttp_offline: accept blank-line blocks and enforce RFC 7230 header-name token chars 2026-11-23 01:12:22 +01:00
a3481c0a18 runtime: keep the command-buffer cap when the wait for room times out (review)
A timeout retries the wait in kQueuedWaitNs slices instead of allocating past the cap; a device lost while waiting makes execute() submit nothing. vk_queue_test makes the first three waits time out and checks the cap still holds.
2026-11-23 01:10:49 +01:00