run_gpu_tests.py (run_cmd) and check.py (run, the mesh harness) start each GPU program with
LEONIDA_GPU_TEST_TIMEOUT seconds (default 120, 0 = no limit). A program that runs longer is
killed and its test fails with 'timed out after N s'. The translator step over the whole suite
keeps no limit. Seen on an Intel UHD 770, where cs_barrier_divergent can hang vk_compute_test.
The T# records an absolute mip clamp, but sampled views ignored it. Preserve the exposed mip range while applying the encoded clamp and use the descriptor fallback when a logical device cannot represent it.
R8G8, R16G16, R16G16B16A16, R32G32 (UINT/SINT), R32G32B32A32_SINT and R10G10B10A2_UINT fell into the float path and stored raw float bits. Clamp/truncate numerically like WARP; A2B10G10R10 alpha clamps to 3. Tests cover 19 formats on CPU and 15 against WARP.
CreateQueryHeap makes one VkQueryPool per heap: occlusion (OCCLUSION and
BINARY_OCCLUSION queries), timestamp and copy-queue timestamp, and pipeline
statistics (all eleven Vulkan counters, whose order is the field order of
D3D12_QUERY_DATA_PIPELINE_STATISTICS). Other heap types are logged and
refused with E_NOTIMPL.
BeginQuery, EndQuery and ResolveQueryData are recorded in the command-list
IR with D3D12's rules for the calls, and replayed as vkCmdResetQueryPool +
vkCmdBeginQuery/vkCmdEndQuery, vkCmdWriteTimestamp at BOTTOM_OF_PIPE and
vkCmdCopyQueryPoolResults (64-bit, WAIT). Heap types, index ranges and the
destination buffer are checked before anything is written. A query that was
never ended resolves to zeros instead of stalling the GPU on WAIT_BIT.
GetTimestampFrequency is 1e9 / timestampPeriod. The devices enable
occlusionQueryPrecise and pipelineStatisticsQuery where the GPU has them.
Overlapping queries of one kind (valid D3D12, one active query per type in
Vulkan) are refused as unsupported, and binary occlusion is not clamped to
0/1 yet; both are written down in docs/d3d12_vulkan.md section 4.6.
Tested on an RTX 5070 (driver 621.01) under VK_LAYER_KHRONOS_validation.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows 10's d3d12.dll refuses shader models 6.7-6.9 and root signature 1.2 with E_INVALIDARG, where a newer runtime clamps them, so the SHADER_MODEL / ROOT_SIGNATURE comparison from #704 counted 4 mismatches on every Windows 10 machine. A request above the highest one the host answered is now checked against the layer's own clamp (S_OK, 6.0 / 1.1) instead, and the count is printed.
Upload-heap buffers asked for HOST_VISIBLE | HOST_COHERENT memory only, so the GPU read every vertex, index and
constant buffer a game uploads over PCIe from system memory. They now prefer DEVICE_LOCAL | HOST_VISIBLE |
HOST_COHERENT when the device has Resizable BAR: such a type in a device-local heap larger than the 256 MiB BAR
window (leonida::resizable_bar, runtime/src/vulkan_memory.h). Without Resizable BAR that type is a window of
256 MiB or less that every upload buffer would share, so they stay in system memory there. A full VRAM heap falls
back to system memory through DeviceState::allocate's existing order.
The device logs where upload heaps live, LEONIDA_UPLOAD_SYSMEM=1 keeps them in system memory for comparison, and
vulkan_memory_flags / device_upload_in_vram report the choice to tests. d3d12_state_map_test checks the detection
on the heap layouts of an RTX 5060 Ti with Resizable BAR, an RTX 3090 without it, a 256 MiB window and an
integrated GPU; d3d12_vulkan_device_test checks that its upload buffer is placed accordingly, and its GPU copies
then read that buffer in both placements.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vk_pipeline_check <spirv dir> --stats FILE enables VK_KHR_pipeline_executable_properties, creates the
pipelines with CAPTURE_STATISTICS and writes, for the executable that runs each translated shader (not
the partner stub's), every statistic the driver reports as CSV rows name,stage,statistic,value. On RADV:
instructions, VGPRs, SGPRs, spills, scratch size, waves per SIMD, and more.
scripts/shader_stats.py <stats.csv> <disasm dir> [--details] compares them with the original RDNA
listings: code growth, VGPRs against the highest VGPR the original uses, and which shaders use scratch or
spill (a register file that went to memory, e.g. through v_movrels with an unbounded index). Over the
corpus it says how many shaders compile badly.
RX 5700 XT (RADV), the repository's test shaders: 47 pipelines, no scratch or spills in any.
New tests/test_shader_stats.py (standard library only).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ds_read_u8_d16, ds_read_u8_d16_hi, ds_read_i8_d16 and ds_read_i8_d16_hi
(RDNA2 DS opcodes 162-165) were rejected. They reuse the u8/i8/u16_d16
path: the byte is zero- or sign-extended 8->16 into one half of the
destination and the other half is kept.
Tests: CPU value test on the new cs_w32_lds_u8_d16 fixture (mini
interpreter now accepts Workgroup variables for one invocation), GPU
dump cs_w32_lds_u8_d16.asm registered in check.py and run_gpu_tests.py,
lds_fuzz generates the four reads. Contract row in docs/design.md and
shader_validation.md updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
image_descriptor named the depth-plane SRV's format from the stored Vulkan
format, so a D24 texture the layer keeps as D32_SFLOAT_S8_UINT (no D24 on the
GPU, the Radeon 880M) got the X24_8_32_FLOAT code instead of the 8_24_UNORM the
console's own descriptor has, and d3d12_descriptor_test failed there. The T#
now carries the format of the texture as created; bind_image views the image
as stored (its own format, depth aspect), since a D24 view of a D32 image is
not valid. A depth-plane view of a texture of the other depth family is
refused.
The D24 comparison test checks the T# codes of the depth and stencil plane
SRVs instead of printing a known gap (depth-plane and stencil-plane views
exist on main now); the docs say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps both sides; the discard emit now passes the binding to image_barrier
as main's version takes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A resource created with Alignment 0 read back Alignment 0 from the Vulkan-backed
device. The PC runtime and WARP report the placement alignment instead: 64 KiB,
or 4 MiB for a multisampled texture, and keep one the description asked for.
d3d12_resource_desc_test compares every GetDesc field of 26 committed and
reserved descriptions with the default adapter and WARP.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The stencil side of #767. image_descriptor accepted X24_TYPELESS_G8_UINT
and X32_TYPELESS_G8X24_UINT plane-1 views on either family, so an
R32G8X24_TYPELESS texture with an X24_TYPELESS_G8_UINT view (or the
other way round) got a live 8_UINT T# where D3D12 refuses the view.
Each stencil view format is now accepted on its own DXGI family only:
X24_TYPELESS_G8_UINT on R24G8_TYPELESS / D24_UNORM_S8_UINT,
X32_TYPELESS_G8X24_UINT on R32G8X24_TYPELESS / D32_FLOAT_S8X24_UINT. The
family is the DXGI format, not the Vulkan one behind it.
d3d12_descriptor_test checks that the other family's stencil view
format leaves the slot null on both textures; on main that check fails.
A region with NumSubresources = UINT_MAX was recorded like a null region and
skipped the FirstSubresource check. DiscardResource now has a whole flag;
explicit ranges are checked in 64-bit at recording and replay. Tests at the
UINT_MAX boundary in command_list_test, part F and the COM device test.
Found by matheuskshn in review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SetEventOnMultipleFenceCompletion narrowed its UINT count to int for the
ALL countdown, so a count past INT_MAX started negative, looked done and
never set the event. The waiter now counts down a std::atomic<UINT> that
stops at zero, so later ANY hits do not wrap. It moves to
shims/d3d12_fence_waiter.h, and the new ctest d3d12_fence_waiter checks
counts past INT_MAX, ALL, and hits past zero without a GPU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>