#1384 made the loader answer LoadLibrary/GetProcAddress for shim-owned modules, because the package's GDK
modules load xgameruntime.dll at run time instead of importing it. Only a registry-level unit test covered
it. tiny_gdk_load.exe has no xgameruntime.dll import and does what xgameruntime.lib's thunks do:
LoadLibraryW, GetProcAddress of the five entry points, InitializeApiImplEx2, QueryApiImpl for XThreadingImpl
and UninitializeApiImpl. ctest run_tiny_gdk_load runs it under gta6rt --run, so its own kernel32 imports go
through the loader's binding, and checks the verdict from outside as run_tiny_async does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without occlusion-resolve memory the queue has no compute helper, so a split statistics query could not be
summed and its later resolve would be refused where main copies it. Create the statistics segment pool only
when the helper is available; otherwise plan() leaves the queries whole and keeps main's behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replay refused binary occlusion resolves, and ordinary resolves that need a sum, while a pipeline-statistics
query was active: their compute helper would count in the application's CSInvocations.
A statistics query that contains a resolve (other than a timestamp copy) is now split. Its counters go to
physical PIPELINE_STATISTICS segments in a pool of the submission's own (flags 0x7ff, as the device creates
the heap). A segment ends before each such resolve and the next begins after it, so no helper dispatch runs
inside the application's query. The query's result is the sum of its segments: a new 11-counter compute shader
(statistics_sum.comp, encoded in statistics_sum_spirv.h like the occlusion helpers) adds them on the
occlusion-resolve scratch buffer. That sum is a helper dispatch too, and is kept out of any statistics query
still running by the same split. Whether a resolve dispatches is only known when the list is planned against
the heaps, so every such resolve splits the query.
The single-list replay() has no segment pool. It keeps refusing a resolve that dispatches inside statistics,
and now allows a binary resolve that only writes zeros. SetPredication and predicated copies are still refused
while statistics are active.
Tests, all with the Khronos validation layer on:
- vk_binary_occlusion: a binary resolve inside one statistics query, then the statistics sum of that query
inside a second one. Every counter of both is 0. With the split disabled, CSInvocations reads 64.
- vk_overlapping_occlusion: a 261-segment occlusion sum inside a statistics query, with a native draw in each
segment. The split query, and a second one split around the statistics sum, equal two unsplit queries with the
same draws on every counter, and CSInvocations is 0.
- replay_query_predication (CPU): the exact begin/end/dispatch order of a split query, and the refusal without a
segment pool.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1440's meta-command checks use IID_ID3D12MetaCommand, which only dxguid.lib defines, so the test didn't link.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MoltenVK compiles MSL with Metal fast-math on by default, and Metal then folds
an f32 compare of a NaN with itself: v_cmpx_eq/le_f32 on (NaN, NaN) give true
(ps_vcmpx_forms fails on every Mac). The MSL is byte-identical with fast-math
on and off, so it's Metal's compile option, not the translation; "on demand"
(2) doesn't help, 0 does.
runtime/test/vulkan_loader.h, which every Vulkan test program loads MoltenVK
through, now sets MVK_CONFIG_FAST_MATH_ENABLED=0 before loading it unless the
variable is already set. docs/design.md gets a contract row: fast-math off
doesn't remove the optnone NoContraction helpers (the cost part, @Jolymmiles)
and doesn't fix SHADER-182 (same valu_fuzz f16 mismatch either way).
Apple A18 Pro, macOS 26.6.2, MoltenVK 1.4.2: ps_vcmpx_forms 4096/4096 exact;
run_gpu_tests.py 85 pass/52 skip/2 fail -> 86/52/1 native, 114/23/2 ->
115/23/1 with wave64 emulation (the remaining failure is ps_interp_f16_high,
fixed by #1407); ctest 25/25 either way; semantic suite 1220 OK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted
Which float formats resolve is up to the GPU (the RX 9070 XT's driver
reports no R9G9B9E5 resolve, WARP does), so the host comparison only
checks the rule the layer implements: no resolve of UINT/SINT formats.
The depth-stencil multisample query checks image_format_properties like
the other calls do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a GPU without Vulkan D24_UNORM_S8_UINT (AMD), a D24 texture is a D32_SFLOAT_S8_UINT image (#737), but
CheckFeatureSupport answered from the D24 format itself: FORMAT_SUPPORT gave Support1 = 0 for
D24_UNORM_S8_UINT and R24G8_TYPELESS, and MULTISAMPLE_QUALITY_LEVELS gave 0 levels for R24G8_TYPELESS at
every count, while CreateCommittedResource(ALLOW_DEPTH_STENCIL) succeeded (found by @zneel, #1380 item 2).
- FORMAT_SUPPORT queries D32_SFLOAT_S8_UINT when the format resolves to D24 and the device can't use D24.
- MULTISAMPLE_QUALITY_LEVELS takes the creation path for typeless formats that are only valid as depth.
- d3d12_d24_support_test checks the layer against itself on any GPU: DEPTH_STENCIL is reported exactly when
a 1x depth-stencil texture is created, and a quality level exactly when a 2x/4x/8x one is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two pixel tests for ops that had CPU checks only. ps_valu16_mad: the u16
product plus S2 wraps at 32 bits, i16 sign-extends (also op_sel high
halves), and the destination dword is overwritten. ps_valu16_subrev:
S1 - S0 in _e32 and _e64 (neg, clamp) with the destination high half
kept. Registered in check.py and run_gpu_tests.py and added as semantic
fixtures with hand constants and a Python reference.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Five pixel fixtures, inputs from memory, for v_add_lshl_u32, v_and_or_b32,
v_xor3_b32, v_bfi_b32, v_bfm_b32, v_bfrev_b32, v_mad_i32_i24,
v_mul_hi_u32_u24, v_max3_u32, v_min3_i32 and v_max/min_i32/u32. Operands
cover 24-bit sign extension with garbage in bits 24-31, shifts and field
sizes of 32 and more, and signed vs unsigned min/max. Expected words are
derived in the .asm headers; the same shaders are semantic fixtures.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The layer turned Vulkan feature bits straight into D3D12 support bits. On an
RX 9070 XT that disagreed with native D3D12 on the same adapter in 169
reported-but-absent bits and 761 absent-but-native ones. This change only
reports what the layer provides:
- UAV_TYPED_LOAD with every typed UAV (reads use the sampled binding), not
from STORAGE_IMAGE_ATOMIC; the UAV atomic bits other than exchange for
R32_UINT, the format with the r32ui storage view
- MIP where the image can have mips; SHADER_GATHER with SHADER_SAMPLE;
MULTISAMPLE_RENDERTARGET for depth formats
- no integer MULTISAMPLE_RESOLVE, no 1D block-compressed, no 3D or shader
reads of depth formats, and TYPELESS formats report only texture
dimensions and MIP
d3d12_vulkan_device_test compares these format-defined bits with native
D3D12 on the same adapter: 0 mismatches over 78 formats with this change,
249 on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The device can allocate 1D textures and set 0 has a sampled 1D binding, but default and explicit views previously sampled the fallback. Use the texture dimension and the requested mip range when registering the view.
RT-54 switched to WARP only on NVIDIA (PCI vendor 0x10DE). AMD faults the same way: on an RX 7900 XTX the
XboxBvhBuilder constructor ends with 0xC0000005 right after the first slot 62 call (found by
@ThatZaliaSGuy, #166). The test now uses WARP whenever there is a hardware adapter, prints the vendor id it
skipped, and LEONIDA_BVH_HARDWARE=1 still keeps the hardware device. docs/d3d12_vulkan.md updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pipelines (graphics and compute) whose translated shader declares set-0 bindings were refused. Their layout now
holds the device's bindless set 0 and replay binds it at every draw and dispatch. d3d12_m2_textured_test drives
heaps, SRVs, a POINT sampler, two root descriptor tables and DrawIndexedInstanced with a translated PS that
loads the T#/S# from the tables; 4096 of 4096 pixels match, and the descriptor hash table is checked.
d3d12_translated_draw_test is registered with ctest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CopyResource and CopyTextureRegion between D32_FLOAT and R32_FLOAT/UINT/SINT,
and between D16_UNORM and R16_FLOAT/UNORM, were refused at execution because
vkCmdCopyImage cannot mix a depth and a colour aspect. Host D3D12 and WARP
copy the bits, and #1134 listed these as not covered.
The replay now stages each such region image -> scratch buffer -> image.
The scratch comes from a new ScratchBuffers pool (vulkan_scratch.h):
device-local chunks handed out while a list is prepared and retired with
the submission's timeline value, like the depth24 converter's scratch, but
enabled on every GPU. Without it the copy is refused as unsupported before
anything is written.
Still refused: depth with stencil (two planes), D24 stored as D32, and
multisampled textures.
Tests: d3d12_copy_xfmt gains five depth <-> colour cases (R16 -> D16 both
ways, D32 -> R32_UINT, three mips, and a D32 -> R16 negative control), and a
depth <-> colour mismatch now fails it. vk_command_replay_test part H runs a
D32 -> R32 -> D32 round trip through the replay, and checks that a list is
refused with no scratch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
valu_fuzz.py, lds_fuzz.py and crosslane_fuzz.py ask vk_compute_test for
32-lane subgroups (VKC_SUBGROUP_SIZE=32) for wave32 programs, but they
ignored its "compute subgroup size: 32 not available" line. On a device
that can't pin that size (Mesa llvmpipe: 8 lanes) every wave32 program
was judged at the driver's size and its cross-lane results came out as
translator mismatches. On main f85582e with llvmpipe, lds_fuzz --emulate
--programs 400 --seed 5150 gave 215 mismatches, all wave32, and
crosslane_fuzz --wave 32 --no-maskdata gave 68 of 100.
Those wave32 programs are now skips, as check.py's unpinned_subgroup_skip
does for its lane-mask dumps. Programs translated with --wave64-emulate
use no subgroup operations, so they are still compared at any size
(400 of 400 match on llvmpipe). crosslane_fuzz counts the skips in its
summary and exits 2 when every program was skipped, as the other two
fuzzers already do.
The line is parsed by compute_fixture.unpinned_subgroup, shared by the
three fuzzers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MoltenVK can't compile PerVertexKHR to MSL, so ps_interp_f16_high failed at
pipeline creation on every Mac. With --f16-interp-fallback every VS/mesh param
(and the --mesh-compute VS) also exports its two f16 halves decoded to f32,
low halves at location 29 - 2N and high halves at 30 - 2N, and a PS *_f16 read
takes them as ordinary smooth inputs. A producer skips halves that would land
on its own params; a PS whose half location is also an attribute is rejected.
The index records f16_halves on both sides.
tools/vk_subgroup_info.py reports per_vertex_inputs (false without
fragmentShaderBarycentric or on MoltenVK); make_game.py and run_gpu_tests.py
turn the flag on where it is false. Without the flag all 139 GPU-test modules
are byte-identical to main's, so NVIDIA/AMD keep the exact per-vertex path.
Apple A18 Pro, macOS 26.6.2, MoltenVK 1.4.2: ps_interp_f16_high passes, all
4096 pixels bit-exact; run_gpu_tests.py 84 pass/50 skip/1 fail -> 85/50/0
native, 112/22/1 -> 113/22/0 with wave64 emulation; ms_f16_pack passes through
--mesh-compute. Semantic suite 1194 -> 1203 OK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted
main is at bb2e1842. Three conflicts, both sides kept:
- runtime/test/vk_store_test.cpp: main added the "load-d16" mode (a row of
16-bit boundary values in the fill, for the saturating d16 loads) and
VK_KHR_shader_fma support; this branch added the "words" mode. Both modes
and both includes stay; main's boundary row applies to "load-d16" only, so
"words" keeps the plain fill its expected words are derived from.
- runtime/test/shaders/check.py: main lengthened CS_STORE on the line next to
this branch's cs_bvh32 entry. Both lines.
- tests/test_shader_checks.py: main counts cs_fma_fused (8 -> 9) on the line
after this branch's STORE_WORDS and GET_LOD_TESTS terms. Both.
The automatic merges were read as well: vk_compute_test.cpp keeps the larger
bvh heap next to main's shader_fma code, and check.py and run_gpu_tests.py
run cs_imgload_d16 in "load-d16" next to the "words" fixtures.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
After the native attachment and feature-mask changes merged, Radeon could create and clear the resource despite a negative capability query. Check the advertised bit against the physical attachment capability before a focused test can skip.
Narrowing a channel to an eight- or sixteen-bit UINT field must clamp high values before packing. Native RDNA2 returns all ones for an overflowing field, while masking wrapped it to the low bits.
s_absdiff_i32, s_lshl2_add_u32 (and the SCC of s_lshl1_add_u32),
s_pack_lh_b32_b16, s_mul_hi_i32, v_mul_hi_i32_i24, v_sad_u8 and v_lerp_u8 were
added with semantic tests only. cs_w32_int_ext.asm has lane 0 of a wave32
group store one result of each; check.py and run_gpu_tests.py expect the
eight words (derived in the .asm header), so CI runs it on llvmpipe.
tests/semantic/test_int_ext_fixture.py runs the fixture on the CPU, checks the
words against values computed from the ISA definitions, and that both GPU
runners expect the same words.
With initialise() run, the module's TLS callbacks take thread events, so the
thread that ends after ~Loader has delivered the process detach and unmapped
the image checks that no DLL_THREAD_DETACH callback runs into freed memory.
~Loader (#1172) clears initialised before delivering DLL_PROCESS_DETACH; with
the thread events that write goes through the TLS lock, so a thread that ends
during or after the detach no longer runs the module's callbacks.
GetProcAddress follows forwarders, so a host import can land in another DLL
than the one named in the import table. The throw calls the RtlPcToFileHeader
import of the module that implements _CxxThrowException, so that module is
redirected too. On Windows it is vcruntime140.dll itself (no change).
Under Wine, without this, run_tiny_game_eh faults inside a Wine DLL after the
throw, reading 0xE080, an offset inside tiny_game's image size (consistent with
a base of 0). With it, the fork's CI run of this branch prints "PASS a C++
exception is thrown and caught inside the image" under Wine. Which Wine DLL
implements _CxxThrowException was not checked.
runtime/README.md: the RtlPcToFileHeader redirect, and the thread events in
place of "the loader does not deliver thread attach/detach events"; mapped
DLLs' DllMain still gets no thread events. design.md: the CPU-code row.
The thread_local and C++ exception checks were switched on by LEONIDA_RUN_TLS=1
and LEONIDA_RUN_EH=1. scripts/run_wine_tests.py passes a test's command line but
not its ENVIRONMENT property, so under Wine an environment-based test would only
ever see the SKIP path. They now take arguments after "hello 42" (`tls`, `eh`),
and CTest runs each in its own test, run_tiny_game_tls and run_tiny_game_eh.
run_tiny_game keeps running without them. stdout is unbuffered, so a crash still
shows how far the run got.
_CxxThrowException (vcruntime140.dll) stores the throwing image's base in the
exception record, from RtlPcToFileHeader(pThrowInfo), and the frame handler adds
the throw's RVAs to it. Windows only knows images its own loader mapped, so for
a mapped image the base is 0, no catch matches, and the process ends with
0xE06D7363: tiny_game's LEONIDA_RUN_EH=1 check on main.
When the loader binds a host copy of the MSVC runtime (prefer_host_copy, direct
or through a forwarder), it points that DLL's imports of RtlPcToFileHeader by
name at a version that asks Windows first and then the live Loaders' mapped
modules. vcruntime140.dll, vcruntime140_1.dll and msvcp140.dll in System32
import it (llvm-readobj --coff-imports); the package's FidelityFX upscaler and
XboxBvhBuilder.dll import _CxxThrowException from vcruntime140.dll. The redirect
is done once per DLL, before any mapped code runs, and stays for the process
lifetime; with no live Loader it answers as Windows does.
tiny_tls counts DLL_THREAD_ATTACH/DETACH only for a thread the test names, so
threads the process starts for itself can't change the counts; the test starts
that thread suspended and names it before it runs. Checks: one attach before the
thread's code runs, with the template value already readable in the callback;
one detach when it ends; and a thread that is still running when its Loader is
destroyed gets its copy freed when it ends, with the process carrying on.
Until now only the thread that called load() had the mapped image's TLS; any
other thread read gta6rt_tls_host.dll's block through _tls_index, so a
thread_local on the game's own threads (gta6rt runs the entry point on a new
thread) started from the wrong data: tiny_game's thread_local check fails on
main with LEONIDA_RUN_TLS=1.
The loader now registers for the helper's thread events. On DLL_THREAD_ATTACH
the new thread gets a fresh copy of the template in the reserved slot; on
DLL_THREAD_DETACH the helper's own block goes back before the Windows loader
frees the array. Once initialise() has run the module, the events also run its
TLS callbacks (as Windows does: thread events only after DLL_PROCESS_ATTACH),
with the copy already in place.
An SRW lock orders the owner's publication, its initialised flag and its
retirement in ~Loader against the events, which run under the loader lock; the
exclusive sections only write fields. ~Loader retires the owner before
uninstalling, so a thread that outlives its Loader frees its copy from its own
record without touching the freed Module. Module::tls_block stays the loading
thread's copy, now set by initialize_tls only. install_tls_for_thread remains
for threads that existed before load(); on a thread that already has the copy
it is a no-op, which the updated worker check shows.
The Windows loader calls gta6rt_tls_host.dll's DllMain with DLL_THREAD_ATTACH
on every new thread, after it has built the thread's TLS array, and with
DLL_THREAD_DETACH before it frees it. A new export,
gta6rt_tls_host_set_thread_event, lets the loader receive those events, so it
can give each thread the mapped image's TLS. DllMain still touches no TLS (the
helper's own slot is the one the loader swaps); the callback pointer is a plain
global. Nothing registers it yet.
Use the current common image packer and its boundary-value fixture for the sample shader. Keep the merged explicit-gather paths and the headless presentation skip.