docs/bvh.md 3.1: u32@0x20 = 0x140 + 64 * totalSizeIn64BNodes, 271,627 of
271,627 streams. xdxr_build.comp wrote total_size / 64; the copy and
postbuild paths read the field as the whole size, and tools/xdxr_bvh.py
wrote and validated it the same way. Now the header writes total / 64 - 1,
MODE_COPY_AS and MODE_POSTBUILD use (field + 1) * 64, validate() and the
reference builder agree, xdxr_build.inc is regenerated (glslc 2026.4) and
d3d12_xdxr_rt_test reads the size the same way.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MoltenVK's vkGetDescriptorSetLayoutSupport compares every layout with maxPerSetDescriptors (1212, the limit without
argument buffers) and rejects even 1212 itself, although it creates and samples a 65536-image, 4096-sampler
update-after-bind set correctly (native repro; d3d12_descriptor_test under Wine with the set grown). On MoltenVK the
D3D12 device no longer asks it: size_bindings' per-type update-after-bind limits, which MoltenVK takes from Metal's
argument-buffer limits, decide, and the set grows to 65536 2D images and 4096 samplers on an M3 Max.
Microsoft's reference page says IGameInput::GetTemporalReading "was never
implemented in v0" and returns E_NOTIMPL, and v1 removed it, so the shim's
E_NOTIMPL already matches the API the title was built against. A history
lookup would answer what no GameInput runtime does. The v0 header (NuGet
Microsoft.GameInput 0.2303.22621.3038) declares (timestamp, device,
reading), the shim's layout; the page's five-parameter form doesn't match it.
Pin the behaviour in gameinput_test (E_NOTIMPL with the reading cleared, for
past, present and current timestamps, with and without a device filter;
E_POINTER for a null output) and say so in docs/gameinput.md instead of
listing the method as a gap.
Review of #2111 (@matheuskshn): a vk_pipeline_check built before this PR takes any argument it doesn't know as the
cache path. Run with --inflight-file F, it would write the Vulkan pipeline cache into F and exit 0; make_game.py would
then delete F and report success, with no pipeline_cache.bin. That happens with a reused runtime build or a supplied
Windows build (#2194).
- make_game.py asks the checker first: run without arguments it prints its usage before touching Vulkan, and only a
build that lists --inflight-file and --skip-file gets them and the crash retry. An older build runs exactly as before
(one call, a crash stops the stage), with a log line saying to rebuild the runtime stage for crash recovery.
- vk_pipeline_check: an unknown --option or a second positional argument is now a usage error (exit 2) instead of
silently becoming the cache path, so the next new option can't be swallowed the same way.
Tested on Windows 11 Pro 25H2, MSVC 14.51 + Ninja, RTX 5070 Ti / 621.24:
- checker_supports: True for this build, False for a 6a6704df build (before this PR).
- the new checker: --no-such-option and a second cache path exit 2 with a message.
- make_game.pipelines on 62 real compute modules: with this build and a simulated crash, the module is skipped and
the other 61 checked, as before; with the 6a6704df build, one call without the new flags, exit 0, and the cache in
pipeline_cache.bin (6.7 MB), nothing written to pipeline_inflight.txt.
- tests/test_make_game_pipelines.py: 11 tests, 2 new (an older checker gets the old invocation and isn't retried;
support is read from the usage line). All 14 test_make_game*.py files pass.
No game data. AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add in-memory ID3D12ShaderCacheSession support (FindValue, StoreValue, SetDeleteOnDestroy, GetDesc) and ID3D12Device9::ShaderCacheControl on the Vulkan-backed D3D12 device, matching the Windows D3D12 host runtime's validation, size queries, duplicate rejection, cross-session sharing, and delete-on-destroy lifecycle.
Verified with synthetic test d3d12_shader_cache_test comparing the Vulkan layer against the host Windows D3D12 runtime under LEONIDA_VK_VALIDATION=1.
Review of #1847: (1) read_index returned on the closing brace without checking
that only whitespace follows, so {}garbage was accepted: now it is malformed.
(2) Malformed and empty input keep 'malformed JSON in ...' (open PR #1735's CLI
test asserts it); only a file that cannot be opened or read says 'cannot read'.
(3) The file is read with read() and its gcount checked, since
istreambuf_iterator bypasses the stream state. (4) The test's find_binary also
checks runtime/build/vk_pipeline_check.exe (single-config Windows Ninja).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ps_vcmp_int32 runs v_cmp_{eq,ne,lt,le,gt,ge,f,t}_{u32,i32} in the e32 and
e64 forms with inline constants and literals, on operands where signed and
unsigned disagree. Words derived by hand in the .asm header; the same shader
is a tests/semantic fixture with a plain-Python reference.
AI-assisted.
In an f16 SDWA op, Gen.src_h returned a float inline constant as its f16
bits without the operand's src_sel. On RDNA2 the constant is the f16 value
over a zero high half and src_sel then narrows it like a register:
v_add_f16_sdwa d, 1.0, v src0_sel:WORD_1 reads +0.0 (measured on gfx1036).
The translator added 1.0.
GPU test ps_sdwa_f16_const (hand-derived words, measured on gfx1036) with a
semantic fixture; it also covers an SGPR source and the integer path
(v_cvt_f16_u16_sdwa of 1.0), which were already right. docs/design.md row.
AI-assisted.
- d3d12_vulkan_device.cpp, vk_test_device.h: #760 chained VkPhysicalDeviceCustomBorderColorFeaturesEXT onto
enable13, which #1706 replaced with leonida::Vulkan13Features; it goes at *v13.next() like the other later
feature structs. The runtime and the GPU test harness didn't compile.
- check_vk_pipeline_cli.cmake: #1958's lds_bytes cases matched "malformed JSON"; the index parser reports where it
stopped ("... at byte 37"), which the check now matches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A translated PS can need VK_KHR_fragment_shader_barycentric (BaryCoordKHR / PerVertexKHR reads), VK_EXT_fragment_shader_interlock (the POPS shaders' PixelInterlockOrderedEXT) or VK_KHR_maintenance8 (texel offsets outside gathers, the index's needs_maintenance8). vk_harness enables all three; the device the Xbox path creates, which builds pixel shaders too, enabled none. Each is now queried and enabled with its feature where the GPU has it.
A 16-bit op in SDWA form (f16 VOP1/VOP2, v_cvt_u16/i16_f16, v_cvt_f16_u16/i16)
with dst_sel:DWORD writes the result zero-extended on RDNA2, whatever
dst_unused says. Gen.insn only marked an SDWA destination for a dst_sel other
than DWORD, so write_lo16 applied the non-SDWA keep-the-high-half rule and the
translator returned 0xdead4000 where gfx1036 returns 0x00004000.
Mark every SDWA VGPR destination and let write_lo16 skip the keep for it.
ps_sdwa_dword_hi.asm (GPU) and its semantic fixture pin four ops and three
dst_unused values; docs/design.md gets the contract row.
AI-assisted.
Expose XMemVirtualAlloc and the write-watch queries through the xmem shim. Map ordinary and 64 KiB allocations to host virtual memory, and reject unsupported page modes instead of silently using the wrong alignment.
- Re-prepare the compose target after the acquire/out-of-date retry and check the extent in
record_planes; xbox_present_test resizes the window between composed presents.
- XboxPresentPlaneParameters follows the public field order exactly (adds ExtendedDescCount,
pExtendedDescs); implausible placement / unknown filter / extended descs are ignored and
logged once, not refused.
- Plane 1 is composed only with our overlay flag (SDR/SDR no longer blends by default).
- present_planes rejects a non-positive or NaN SDR white level.
- ResourceCount != 1 is refused with DXGI_ERROR_UNSUPPORTED before either path (found by Flyander).
- Docs: PQ-space filtering, HDR10 swapchain verified on RTX 5080 by JavierBlanco23.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
process_cmdline_test now checks the return values of _putenv_s/_wputenv_s and says
when _wenviron already exists at startup, so the first-call check cannot pass
silently without exercising the lazy wide-table creation. process.cpp notes that
the returned table is the CRT's own and valid until the next _putenv, as with the
msvcrt.dll original.
GetCursorPos deltas stop at the screen edge and include pointer
acceleration. A message-only window on its own thread now registers for
raw mouse input (RIDEV_INPUTSINK) and sums the relative counts; the poll
takes the difference of that total. Absolute reports are ignored, and
GetCursorPos stays as the fallback if registration fails.
With raw input on and a window of this process in the foreground, the
cursor is clipped to that window's client area (re-applied every 100 ms),
and released on focus loss or when the pad is turned off.
LEONIDA_MOUSE_SENSITIVITY (0.1..10, default 1) scales the axis units per
count.
ID3D12PipelineState::GetCachedBlob returns a blob with the adapter, driver, pipelineCacheUUID and a SHA-256 of the description (without Flags; shaders keyed by their DXBC checksum), sealed by a checksum. Create{Compute,Graphics}PipelineState check a supplied CachedPSO before creating the PSO and answer as the PC runtime does, measured on an RTX 3060 and WARP. Rebased onto main (one commit). AI-assisted.
A draw recorded in a bundle took the bundle's own viewport, targets, root
arguments and buffers. A bundle cannot set a viewport, so every bundle draw
was dropped without an error, and nothing of the parent's state reached it.
Only the stencil reference and the blend factor were handed back.
Inside a bundle, state calls, draws and Dispatch are now kept as deferred
calls, and ExecuteBundle plays them on the parent through the members a
direct call uses, between the bundle's state-free commands, in order. A
draw sees the parent's state plus what the bundle set, and what the bundle
set stays on the parent, as measured on the PC runtime. This replaces the
stencil-reference and blend-factor carry-back fields. Trace lines are
written once, when the bundle records the call.
ClearUnorderedAccessView is refused in a bundle, like the other clears.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The if-init `info` of the AccelerationStructurePostbuild branch stays in scope through the following
`else if`, so the BLAS/TLAS build branch's VkAccelerationStructureBuildGeometryInfoKHR `info` hid it,
and the branch's loop `i` hid emit's command index. Both are renamed (`postbuild`, `s`); no change in
behaviour.
rdna2spirv maps a legacy GS's LDS write to an output slot from its
offset alone and drops the VGPR address (the lane's GSVS area), but
wave64_halves read that address as the store's data, so a GS whose lane
id only forms its GSVS base was tier C lane-id. It now checks only the
data operands of a GS ds_write.
w64_graphics.py draws gs_w64_a_ring and gs_w64_c_lane_id at wave64 and
wave32 (RADV_PERFTEST=gewave32), build.py builds gs_* fixtures with
gs_tri's signatures, docs/testing.md explains how to run and extend the
wave64 graphics checks, and docs/design.md records the rule and that the
corpus GS are written for wave64. Checked on an RX 9070 XT (GFX1201) and
a Ryzen 9800X3D iGPU (GFX1036), RADV Mesa 26.3.1: 23/23.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
set_command_line kept _environ/_wenviron pointers. The host CRT has no wide
environment until a wide environment function first runs, and _putenv/_wputenv
reallocate both tables, so a wide-character startup calling __wgetmainargs got
a null or dangling environment. The shims now read the tables when asked and
make the CRT create a missing one first.
process_cmdline_test covers both functions: the first wide call, and variables
set before and after set_command_line.
On MoltenVK (1.4.2, 1.4.3) the check sampled zeros: vkGetDescriptorSetLayoutSupport there accepts only layouts
of fewer than maxPerSetDescriptors (1212) descriptors, so size_bindings keeps the default 4096 2D images and
1024 samplers, and the test's 5001st view and 2100th sampler were refused as the arrays filled. MoltenVK does
create and sample a 65536-image, 4096-sampler set correctly (a native reproduction, and the whole test passes
under Wine with growth forced), so that is MoltenVK's to fix; the runtime keeps following the driver's answer.
The test now asks the set how much room it has (rt::d3d12::bindless_room, from BindlessSet::free_images and
free_samplers). Where the set holds the full counts nothing changes. Where it holds fewer, the test fills each
short array to its last index, checks the last view through the last sampler gives the texture, and that one
more view and sampler are refused and read as the fallbacks. The device logs at startup when its set holds
fewer samplers than a full shader-visible sampler heap. bindless_sizing_test gets MoltenVK's limits;
vk_bindless_test checks the free counts.
Rescheduling an origin event can make an existing frame look late before its original vblank. Keep the original deadline for both the tear decision and its display statistic.
Since dcd8ecf the two #881/#884 giants pass spirv-val and are back in the corpus. On NVIDIA the larger one runs the
driver's compiler out of memory (LLVM ERROR: out of memory, exit 0x80000003), vk_pipeline_check dies with it, and the
pipelines stage stops: on @VeTkN's RTX 5070 (#884, c603b8f) about 5,750 pipelines after it were never checked or
cached, and make_game.py exited 1.
vk_pipeline_check:
- --inflight-file F keeps the names of the modules being compiled in F. It is rewritten when a module over
--large-module-bytes starts or finishes (those compile alone, #903, so F then names exactly that module), by the 5 s
watchdog for the others, and emptied at the end of the pass.
- --skip-file F: modules named in F are not compiled; each is reported as `MODULE CRASH <name> (<stage>, killed the
driver in an earlier run; not retried)` and counted as a failed pipeline, as --isolate does on POSIX. --isolate
passes it on to its children. A missing F is a usage error (exit 2).
make_game.py, pipelines stage:
- runs the checker with --inflight-file. When it exits other than 0, 1 or 2 (a crash, not Ctrl+C), the modules in
the in-flight file are added to pipeline_crashes.txt and the checker runs again with --skip-file; what was already
compiled comes back from pipeline_cache.bin (checkpointed every 10 minutes). If several modules were compiling, each
is tried alone (--start/--count in the checker's name-sorted index) and only those that crash alone are skipped.
- a crash no module can be named for is not retried, nor is Ctrl+C, and there are at most 5 restarts.
- the stage still fails when anything failed, now after checking everything else, and names the modules that took
the driver down. pipeline_crashes.txt is cleared at the start of each pipelines stage, so a module gets a fresh
chance after a translator change.
- run() takes check=False and returns the exit code.
The --isolate child-process mode stays POSIX-only; with a multi-GB pipeline cache per child it is too heavy for the
default path. A memory cap for the checker on Windows, so the OOM doesn't take other programs down, is a follow-up.
Tested on Windows 11 Pro 25H2, MSVC 14.51 + Ninja, RTX 5070 Ti / 621.24:
- tests/test_make_game_pipelines.py: 6 new cases (a named crasher is skipped and the rest checked; several in flight
are tried alone and only the crasher is skipped; no suspect or Ctrl+C is not retried; the retry limit; a clean run is
one call and an old skip list is dropped). All 14 test_make_game*.py files pass.
- end to end on 62 real compute modules from my own copy's work folder (2 over 4 MiB), through make_game.pipelines:
with VK_PIPELINE_CHECK_SIMULATE_CRASH on one large module, the first run died (exit 3), the in-flight file named
that module, the second run checked the other 61 (all ok) and saved the cache, and the stage failed naming it.
Without the hook: one call, 62/62, exit 0. The in-flight file is empty after a clean pass.
No game data. AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
store_inputs() gave y and w the same value for two-component formats, so run_stores could not
tell the translator's (x, y) from the Radeon 880M's (x, w) for buffer_store_format_*; the zero
mismatches did not validate the second component. The probe now uses a different value in every
register and also runs _xy stores. The hardware model routes a two-component
buffer_store_format_* to (x, w) (_xy: (x, 0)); tbuffer_store_format_* takes (x, y) like the
translator. Those stores are counted as known-difference elements, outside the validated count:
1,330,469 validated elements, 0 mismatches, plus 26,523 known-difference elements.
The translator is unchanged (RDNA2 unmeasured); the difference is pinned as an expectedFailure
in test_buffer_formats_all.py. docs/buffer_formats.md and the design.md row say so.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A compute fixture loads through the nine narrow integer formats (DST_SEL
XYZW, X011 and d16) and stores edge values through each with the
runtime's selectors. check.py's 136 expected words are the same program's
output run natively on gfx1036 (tools/hw_oracle, wave32 and wave64), and
the interpreter test runs the fixture against them too.
Depends on #1871.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- d3d12_typeless_families_test also draws a full-screen pass (GLSL stand-ins of translated shaders found by FSSM
hash; the host's HLSL through d3dcompiler_47) into R16G16B16A16_UINT/FLOAT/UNORM, R32_UINT/FLOAT,
R10G10B10A2_UINT/UNORM and R8G8B8A8_UINT RTVs of TYPELESS textures, PSO RTVFormats naming the typed format:
8 of 8 equal the host D3D12 on the same adapter, no validation error.
- Draws need no layer change: the replay's draw attachment view already takes the PSO's RTVFormats[slot]
(GraphicsPipeline::color_formats), which D3D12 requires to equal the RTV's; the same draws matched before the
clear fix too.
- test/glsl/ps_typeless_float.frag, ps_typeless_uint.frag; docs/d3d12_vulkan.md typeless RTV section.
AI-assisted.
Creating an SRV of a depth texture (D16_UNORM/R16_TYPELESS or D32_FLOAT/R32_TYPELESS) with a colour format (e.g. R16_FLOAT, R16_SNORM, R16_UINT, R16_SINT, R32_UINT, R32_SINT) previously produced a colour-format VkImageView with VK_IMAGE_ASPECT_DEPTH_BIT, violating VUID-VkImageViewCreateInfo-image-01762. Tighten vulkan_view_format(), image_descriptor() and bind_image() so depth/stencil textures only accept their own family's depth/stencil SRV formats and colour textures reject depth/stencil view formats. Adds exhaustive unit tests and GPU + Vulkan validation tests.
ClearUnorderedAccess previously decoded encoded bytes into p.binding.format and cleared whole views via vkCmdClearColorImage, which corrupted non-float values (such as R16G16_UNORM 1.0 = 0xffff or R32_UINT sNaN bits) on SFLOAT-backed typeless textures. When view_format differs from p.binding.format and supports COLOR_ATTACHMENT, decode in view_format and clear through an attachment view of view_format (preserving the R32_UINT path for emulated R9G9B9E5_SHAREDEXP). Adds replay and GPU readback tests.
Address @Flyander's post-merge review feedback on #1817 (D3D-236):
- Only fall back from OpenThreadToken to OpenProcessToken when GetLastError() == ERROR_NO_TOKEN, failing closed on ERROR_CANT_OPEN_ANONYMOUS or any other thread-token error.
- Log the standard-priority Vulkan queue approximation once on the granted global-realtime path.
- Remove the +not_elevated skip predicate from compare_invalid_arguments and add a SecurityAnonymous impersonation regression test.
A plain single plane keeps the old blit. A plane with pDestPlacementBase, a point/linear
ScaleFilter, the HDR10 colour space, or a second overlay plane goes through
VulkanPresenter::present_planes: a compute pass (present_compose.comp, SPIR-V embedded)
into an RGBA16F image that is copied to the swapchain. HDR10 uses an ST.2084 swapchain
when the surface lists one, else is clipped to SDR. An SDR plane 1 next to an HDR10 plane 0
is the GameDVR copy (public HDR sample) unless flagged an overlay. The layouts, flag values
and alpha convention are ours; xbox_present_test checks every case against a CPU model.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From @Flyander's review of #2001: one_f16_step pixels were counted but not limited, so a regression that
moved every covered pixel by one half step would pass (only differ == 0 was checked). An adjacent half only
appears where the f32 interpolant is a few ulps from an f16 truncation boundary (1 pixel of 12,804 covered on
the RTX 3060), so at most one covered pixel in a thousand may be one step apart.
Checked both ways: the real image passes (1 pixel); a reference with all 12,804 covered pixels moved one half
step fails at the new bound.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ColorViewFormat now holds the view's VkFormat number (the RGBA8 names keep their values), and
CreateRenderTargetView accepts any typed format of a TYPELESS color texture's family (B8G8R8A8 and
B8G8R8X8 kept apart), not only RGBA8.
- ResourceBinding::rgba8_typeless becomes typeless (any TYPELESS color resource); color_view_format accepts a
format of the resource's family (typeless_view_family, R8 included for when it is mapped), so clears go
through a view in the RTV's format. Attachment views of every typeless image ask for color-attachment usage
only.
- d3d12_typeless_families_test: every typed RTV format of each family, two clear values, bytes compared with
the host D3D12 on the same adapter (LUID) and reported against WARP.
- docs/d3d12_vulkan.md: the typeless RTV section.
AI-assisted.
ps_w64_a_permlane, ps_w64_a_swizzle and ps_w64_a_bpermute check v_permlane16/x16, ds_swizzle
(quad-permute, swap, broadcast) and ds_bpermute in a wave64 pixel shader with words that only
depend on the 2x2 quad layout of fragment lanes. They give the derived words on an RTX 5070.
wave64_halves.py called a ds_bpermute/ds_permute whose address comes from the lane id tier C
(lane-id). The id is 0..63 in the wave and 0..31 in a half, equal modulo 32 lanes, and a wave64
permute uses address bits 2..6 of its half only, so an address that is the same modulo 128
bytes reads the same lane. The classifier now tracks that modulus through sums, differences,
bitwise ops with invariant values and left shifts; shifts by less than 2, right shifts and the
low count alone stay tier C. Classification and wave-interpreter tests (64 lanes against two
waves of 32) cover the rule and its near misses.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The calls docs/runtime_imports.md listed as not mapped now follow the RT-97
rules, under kernel32, kernelbase and the api-ms-win-core-file-* sets:
- CreateDirectory/CreateDirectoryEx make the folder in the overlay; a name the
title can already see, package-only folders included, is ERROR_ALREADY_EXISTS.
- RemoveDirectory needs the folder empty in the title's view. An overlay folder
is removed; a package folder is hidden by a .gta6rt-dir marker file inside its
marker folder and stays on disk (deleted() now also checks that file, on top
of the regular-file rule from 3f26a95a).
- MoveFile/MoveFileEx write the destination in the overlay; a moved package file
is copied there and its old name deleted by a marker. MOVEFILE_WRITE_THROUGH
flushes that copy and the marker before returning (review on #1742). Package
folders are not moved (ERROR_ACCESS_DENIED), GAME: <-> host is
ERROR_NOT_SAME_DEVICE and MOVEFILE_DELAY_UNTIL_REBOOT is ERROR_INVALID_PARAMETER.
- CopyFile/CopyFileEx/CopyFile2 read like a read and write a GAME: destination
in the overlay; fail-if-exists counts names only the package has.
- SetFileAttributes sets the overlay copy (copy-up or folder mirror first).
file_system: 123/123 checks. No game files.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>