MoltenVK reports subgroups 4..32 and requiredSubgroupSizeStages 0, so VKC_SUBGROUP_SIZE=32 printed "not available"
and the 32-lane compute tests skipped. The translator emits SPIR-V 1.5, where varying subgroup sizes are not allowed,
so Vulkan fixes SubgroupSize at the device's subgroupSize (32 there). vk_compute_test now runs a probe shader
(cs_wave_probe.comp, embedded) with the test's local size and flags first, checks every invocation's lane, subgroup
number and ballot width, and runs the test if they match. If they don't, the test fails (exit 1) instead of being
skipped. Full subgroups are requested where local size X is a multiple of maxSubgroupSize. Devices whose default
isn't the requested size keep printing "not available".
The device tracks the arena's peak end offset, its peak live bytes overall
and per use (buffers, shader-visible descriptor heaps, shader code and
D3D12 heaps), and its allocations and refusals, and prints one line at
release. LEONIDA_ARENA_LOG=1 also logs every VA handed out, every refused
request, and upload/readback VAs outside the arena. This answers open
question 5 (how large the arena must be) once the game runs.
Rebased onto main now that #291 is in: arena_allocate/arena_release take
the use, and every call site passes it, including the heap ranges #291
added since.
A wave64 pixel shader that kills pixels with `s_andn2_b64 live, live, exec/vcc` and branches with
`s_cbranch_scc0` to a block that only empties EXEC from that mask, exports and ends was tier C
unsafe-vote-branch. It is exact on 32-wide subgroups: a half whose live mask is empty writes nothing in
the exit and discards its pixels, and in the wave its lanes stay off to the end.
The rule accepts it only when:
- the branch tests the mask's own "not empty": the last SCC writer is a 64-bit logic op into that mask
(or s_cmp_lg_u64 mask, 0) and nothing rewrites the mask before the branch (or vccz/vccnz);
- the exit only sets EXEC from that mask (or 0), exports and ends: no other code, store or successor;
- the run side narrows EXEC into the mask's whole quads before anything but mask arithmetic runs and
keeps it inside on every path, loops included (a must-dataflow over narrowings and copies, unions and
s_wqm of registers known to be inside);
- no `exp ... vm` can run before the vote (a latched vm export would keep the pixels alive in the wave).
Also: s_mov_b64 / s_cselect_b64 of a lane mask no longer tag SCC as a vote on their destination (they
do not write SCC); the branch could take a lane-count compare for a vote and come out tier A.
Tests: classification of the kill (wqm + s_and, v_cmpx + s_mov, direct s_and / s_mov / s_wqm exec,
exit through exec 0, an if/endif after it) and near misses (exit with code, a store, an SGPR write,
another mask, a jump back; a run side that does not narrow or widens again; the mask rewritten after
the vote; SCC = mask == 0; a vm export before the vote; a shared exit), and 64 vs 2x32 vertex runs.
GPU fixture ps_w64_a_discard: RX 580 (RADV, required size 64) and RTX 5070 (32, against the 580
reference) equal the derived words.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match RDNA2 mode-0 denormal semantics and legacy zero override; flush product before output scaling and normalize modifier zeros. Add synthetic semantic/GPU fixtures and documentation. AI-assisted (GPT-6).
The dead-owner case relied on the spawned child's PID staying free until the
sweep ran, which is not guaranteed on a busy machine; a reused PID turned the
check into a SKIP. The deletable stand-in now uses this process's own PID
instead: the sweep runs before this process has created any clone, so a file
named with the current PID is always a leftover of a dead run there, and the
live-PID and handle-held skip cases keep their own deterministic stand-ins.
Both did EXPECT(d.create()), which turns "no Vulkan driver" into a failure. The hosted Windows CI runner has no
GPU, so d3d12_msaa_draw was the one red test on every Windows run. They now take vktest::Device::initialize()
and return 77 (their SKIP_RETURN_CODE) on DeviceStatus::unavailable, like d3d12_clear_test and the rest; a device
that exists but fails to come up is still a failure.
Reproduced locally with VK_LOADER_DRIVERS_SELECT matching no driver: d3d12_msaa_draw exited 1 ("line 49:
d.create()") on main and exits 77 now (ctest: Skipped); d3d12_translated_draw likewise. With the GPU both still
pass under LEONIDA_VK_VALIDATION=1. d3d12_translated_draw only builds with llvm-mc, which the hosted runner
lacks, so it never showed there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Present is queued behind held work (QueueHolds::after_held) and submitted in order by the releasing thread.
- Held batches keep the pipeline states and root signatures of their lists; fences a queue waits on or signals are
kept until the submission has completed on the GPU (a D3D12 queue holds them).
- A held Signal released below an unheld one on the same fence leaves the Vulkan signal out (claimed under the submit lock).
- A queue destroyed with held Signals completes the CPU waits on their fences and reports it.
- A failed held batch is reported (take_held_failure, last_execute_result), its waits stay for the next submission,
and the Signal behind it still signals.
- d3d12_queue_handover_test: pairs, two-thread signalling stress, held Signal of a released fence, shared fence,
teardown with a CPU waiter; --two-queues and --shared-queue modes on a caller-owned device.
- Tests for each fix in vk_presenter_sync_test, vk_queue_query_sync_test and d3d12_m4_compute_test; docs section 4.4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run under VK_LAYER_KHRONOS_validation with GPU-assisted validation (VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1),
which instruments the translated shaders, the llvmpipe GPU suite gives two errors. Both are in the tests,
not the translator, and both passed only because llvmpipe tolerates them:
- vk_bindless_test (ps_tex): the synthetic T#'s word 1, 0x22222222, has FORMAT 34 (10_11_11_UINT). The
translator picks the uint alias of the image array for a UINT T#, so every draw sampled the test's
R8G8B8A8_UNORM views through a uint image, which Vulkan leaves undefined
(VUID-vkCmdDraw-format-07753). The T# now has FORMAT 56 (8_8_8_8_UNORM), checked by a static_assert.
- cs_w64_mask_detect: every lane stored at lane * 64 through a V# that allows any offset, so lanes 4-63
wrote past the 256 bytes vk_compute_test gives one group, through the buffer's device address
(VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819). It stores at lane * 4 now; out[0] is still 48.
docs/testing.md: how to run the shader test programs under validation, GPU-AV and sync validation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reject cache, stats and snapshot paths that point to the shader index or skip list before opening them. Check file identity so case differences and filesystem links cannot hide an alias.
Slot 8 is the private XAsyncBeginAlloc: no public page, never called by the package's DLLs, signature not measured.
The generic private slot answered 0, so a caller got S_OK for an async call whose provider never received
XAsyncOp::Begin and whose completion never arrives. It now returns E_NOTIMPL and logs once.
Test: xgameruntime_test calls slot 8 with a provider that counts XAsyncOp::Begin and requires either a failure or one
Begin. Fails on ec8ec4c9 (S_OK, 0 Begin), passes with the change; the mutant answering S_OK is caught.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The method returned E_NOTIMPL and a zero cookie. It now returns S_OK with a unique cookie for UnregisterVideoMemoryBudgetChangeNotification; the budget is recomputed on every QueryVideoMemoryInfo, so the event is never signalled. Test: dxgi_swapchain.
A compute program that reads its inputs from memory (a root table, descriptors,
data) needs them in the heap before it runs; VKC_SGPRS only reaches s4..s31.
VKC_HEAP_INIT=<file> copies the file to Xbox VA 0 after the default fill. A file
larger than the buffer, or one that can't be read, is refused (exit 2).
cs_heap_init.asm loads four words the file put at 0x100 and stores them at 0;
check.py and run_gpu_tests.py write the file and check the words and the
file's zeros past them. First part of TEST-594 (the BVH builder's programs read
their root table from the heap).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateDXGIFactory2(IID_IDXGIFactory7) and QueryInterface for
IDXGIFactory6/7 failed on the layer's factory, which stopped at
IDXGIFactory5.
- EnumAdapterByGpuPreference returns the one Vulkan adapter at index 0
for every preference.
- RegisterAdaptersChangedEvent / UnregisterAdaptersChangedEvent keep a
cookie registry. The adapter list never changes, so the event is
never signalled.
Every return code follows the host dxgi.dll, measured on Windows 11
with an RTX 3070:
- a preference outside the enum is accepted;
- a null out is DXGI_ERROR_INVALID_CALL;
- past the end is DXGI_ERROR_NOT_FOUND with *out cleared;
- a non-adapter riid is E_NOINTERFACE;
- a null event or cookie, and an event registered twice, are
DXGI_ERROR_INVALID_CALL;
- cookies start at 1 and are separate from the occlusion cookies;
- an unknown cookie is DXGI_ERROR_NOT_FOUND.
dxgi_swapchain_test checks each answer. With main's factory it fails
at QueryInterface(IDXGIFactory6/7).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The startup purge deleted every leonida_tls_host_*.dll in the temp directory, so it could remove the
clone of a concurrent process that had copied its helper but not reached LoadLibraryExW yet. Clones
are now copied to a staging name and renamed into place while the copy step's guard handle is open, so
a final-name clone never exists without a handle, and the purge skips files that fail an exclusive
open or whose owner process (from the file name) is still alive.
std::atexit cleanup never ran on the --run path because main ends with ExitProcess; the loader now
exposes cleanup_tls_clones() and main calls it before ExitProcess (atexit still covers normal exits).
on_host_thread_event wrapped the whole slot loop in one try/catch, so one throwing slot killed the
events for every other module. The catch is now per slot, and the detach path releases the slot even
when the callbacks threw, instead of leaking the block to the OS loader.
README and the initialize_tls comment no longer claim only one mapped TLS module can be live; the
loader_tls_test gained purge-ownership and explicit-cleanup checks.
Under GPU paravirtualization (Windows Sandbox, RTX 5060 Ti, driver 617.42) the dispatcher's
infinite vkWaitSemaphores is a kernel wait that cannot be interrupted. A process that exits with
a wait pending, as d3d12_queue_wait_timeout does by design, never finishes exiting, and
TerminateProcess from CTest cannot end it. Bounded slices let the thread return to user mode;
the loop re-arms the same wait and completions still wake it at once.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RSSetViewports, RSSetScissorRects, OMSetRenderTargets and ClearState had
no bundle check, so the layer accepted them in a bundle while the PC
runtime fails that bundle's Close (measured on an RTX 4060 Ti and WARP,
no debug layer). They now invalidate the bundle like the other calls a
bundle may not make.
New host-comparison test d3d12_bundle_forbidden: ten calls, each in a
bundle and, as a control, on a direct list, against the PC runtime on
the default adapter and WARP.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A castable-format list may name the other family of a B8G8R8X8 or
B8G8R8A8 texture (relaxed casting). WARP and AMD's D3D12 driver accept
such lists both ways, typed and TYPELESS, and an SRV in a listed format
reads by its own format: alpha 1 for B8G8R8X8, the stored byte for
B8G8R8A8, and red and blue swapped when the list crosses channel orders
(an R8G8B8A8 texture read as B8G8R8A8 or B8G8R8X8). The layer kept the
list only as Vulkan formats, where both families are BGRA8, so it refused
a view across them, and its T# took the channel order from the image's
format, so a B8G8R8A8 view of an R8G8B8A8 texture read unswapped.
The resource now also keeps the list as the application gave it,
image_descriptor lets a view cross the families when the list names its
format, the alpha swizzle follows the view's format, and a colour view in
the other channel order takes its swizzle from that order (both orders
share one T# format code).
d3d12_descriptor_test adds a B8G8R8A8_UNORM texture listing
B8G8R8X8_UNORM, a B8G8R8X8_UNORM one listing B8G8R8A8_UNORM, and two
R8G8B8A8_UNORM ones listing B8G8R8X8_UNORM and B8G8R8A8_UNORM, each viewed
through the listed format: T# formats and swizzles, an unlisted format
refused, and the same bytes sampled through the bindless set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateGraphicsPipelineState previously logged that instance step rates above 1 were not modelled and left per-instance slots stepping every instance.
Query and enable vertexAttributeInstanceRateDivisor via VK_KHR_vertex_attribute_divisor (falling back to VK_EXT_vertex_attribute_divisor) in create_vulkan_device() and vk_test_device.h, chain VkPipelineVertexInputDivisorStateCreateInfoEXT onto VkPipelineVertexInputStateCreateInfo::pNext when a per-instance slot has InstanceDataStepRate > 1 (refusing with E_NOTIMPL when the feature is unavailable), and add a synthetic GPU instanced draw test in d3d12_draw_test for step rate 2 with a step-rate 1 negative control.
Rebased onto upstream/main (16282101), chaining divisor feature structs via v13.next()/v13_.next() and moving step_fence to 60 after x8_fence.
AI-assisted.
Modules that declare Float64 now also get
OpExecutionMode %main SignedZeroInfNanPreserve 64, so -0, NaN and inf in
native f64 ops no longer rest on driver defaults. Same gating as the
32-bit mode from #664: the index entry lists
shaderSignedZeroInfNanPreserveFloat64 next to Float32, vk_pipeline_check
skips the shader where that property is false, and --no-float-controls
leaves both modes out. Modules without Float64 are unchanged.
Found by @Jolymmiles (issue #3047).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rule added with the M2 formats test (#1996) ran build.py through
cmake -E env "PATH=${LEONIDA_SPIRV_TOOLS_NATIVE};$ENV{PATH}". The ;s in
that string make it a CMake list, so on Windows cmake -E env received
each PATH entry as its own argument and tried to run one as the command:
"no such file or directory" (MSB8066) at "Translating vs_m2, ps_m2 and
ps_m2_array", which stopped every Windows build that has llvm-mc. The
sibling rules pass LEONIDA_SPIRV_TOOLS, which build.py prepends to PATH;
this one does the same now.
AI-assisted (Claude Code).
#2109 made the PSO stages {vs, gs, ps}; the --f16-interp-fallback link (SHADER-378, #2389) still read the PS from
stages[1], found the empty GS slot and never ran, so d3d12_f16_halves drew nothing. With a GS the PS reads the GS's
outputs, so the VS/PS link is skipped there (logged once). Also: xgameruntime_test re-reads the package id after
clearing the LEONIDA_PACKAGE_ID override.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The factory answered S_OK for every flags value, while the host rejects anything
outside DXGI_MWA_NO_WINDOW_CHANGES, DXGI_MWA_NO_ALT_ENTER and
DXGI_MWA_NO_PRINT_SCREEN with DXGI_ERROR_INVALID_CALL (measured on Windows 11
with the system DXGI), so an invalid call looked accepted. Reject unknown bits
before recording the window, and cover the accepted combinations and two unknown
bits in the swapchain test.
ResizeTarget answered S_OK and ignored its argument, so a windowed game that
switches resolution through the DXGI 1.0 path kept the old window: the host
moves the target's client area to the mode's Width x Height and leaves the back
buffers alone until ResizeBuffers (where 0 means the new client area).
Measured on Windows 11 with the system DXGI (RX 7900 XTX): ResizeTarget(nullptr)
is DXGI_ERROR_INVALID_CALL, ResizeTarget(0x0) is accepted and the window's
minimum tracking size decides the result, ResizeTarget(234x156) gives a 234x156
client area with the buffers at 128x128, and ResizeBuffers(0, 0, 0) then takes
234x156. The swapchain test now covers the same sequence on the shim.
The shim opens each pad's HID device with SDL_hid_* (by SDL's device path, else the one game-pad collection with the
pad's vendor and product id) and reads its report descriptor for every input, output and feature report's id and
size. Such a pad reports GameInputKindRawDeviceReport and GameInputDeviceRawIoEnabled and fills inputReportInfo,
outputReportInfo and featureReportInfo (no item tables). Readings carry the newest raw input report, and
IGameInputReading::GetRawReport returns it as an IGameInputRawDeviceReport. CreateRawDeviceReport,
GetRawDeviceFeature, SetRawDeviceFeature and SendRawDeviceOutput work through the backend; an undeclared id or kind
is E_INVALIDARG, a failed transfer E_FAIL, and a pad without a HID device keeps E_NOTIMPL.
gameinput_abi.h declares IGameInputRawDeviceReport, GameInputRawDeviceReportKind and the three raw report info
structs, checked against Microsoft's v0 header (offsetof for every field, the 12 vtable slots, the IID). Xbox pads on
Windows go through XInput, whose HID interface SDL's hidapi skips, so they have no raw I/O; the log says so.
gameinput_test covers the descriptor parser and the whole path with a fake HID backend (24 checks);
gameinput_probe prints each pad's report tables and newest raw input report. docs/gameinput.md: "Raw HID".
Stage the full in-flight report before replacing its destination, using the existing checked checkpoint writer. Preserve the last complete snapshot if staging or replacement fails.
Review follow-up. Dispatch took events one at a time from the live
queue, so readings queued during the call (by the poll thread, or by a
callback) were delivered in the same call: with an unlimited quota a busy
queue could keep the title inside Dispatch, and each erase at the front
made a drain O(n^2) under deliver_mu.
Dispatch now swaps out the batch present at entry and walks it in order;
events it leaves (quota spent) go back to the front of the queue, ahead of
newer ones. gameinput_test adds a callback that queues a reading from
inside the call: each Dispatch(UINT64_MAX) runs exactly its starting batch
and returns true (the previous version never returned). The docs say so,
and the dispatcher row's open column reads a dash instead of a blank.
- tests/semantic: BaseVertex/BaseInstance read 0 in the wave interpreter; the LDS MockGens follow
SHADER-309 (lds_bound, lds_access, lds_atomic); abs emission tests load their operand, since
SHADER-315 folds scalar ALU on constants.
- test_translate: the dynamic gather sampler is a loaded word, not s16 + 0 (SHADER-315 folds it).
- test_world_build: DDS downscale weights colours by alpha (62804d0d).
- test_fspx_shaders_stage: the fake disassembler writes the listing make_game now checks.
- xgameruntime_test: re-read the package id after clearing the LEONIDA_PACKAGE_ID override.
- docs: one row per topic again in design.md (72 topics) and README.md; one Other languages line;
embedded_shaders.md keeps one copy of each bullet; animation.md links the heading anchor.
- tools/scripts: character_textures uses report_paths.same_report_path; stdout guard on six programs;
LF write in vs_input_survey; the cl.exe fallback compiles winhttp_offline.cpp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>