- GPU address arena (docs 3.3), when the device has bufferDeviceAddress: one
host-visible, device-addressable buffer (LEONIDA_ARENA_MB, default 256,
max 4095 so VAs fit 32-bit table pointers). Default-heap buffers are
64 KiB-aligned ranges with VA = offset, zeroed through the mapping;
shader-visible descriptor heaps live there (CPU handle = mapping, GPU
handle = VA); upload/readback buffers get VA = device address - heap
base; GetGPUVirtualAddress returns these.
- CreateRootSignature on main's model (rt::rootsig): parse_rts0, then
pack() for each parameter's place in the 32 user-data dwords; what pack()
refuses is refused with its reason. CreateComputePipelineState (PC slot
11, Xbox slot 62 via the proxy) finds the shader by the SHA-256 of its
FSSM program in the translator's index (VulkanDeviceInfo::shader_dir or
LEONIDA_SHADERS); its FSSM blob is copied into the arena as the code base.
Shaders that declare set-0 bindings are refused with a log until the
bindless set exists (M2).
- Command list: root signatures (arguments cleared on change), pipeline
state, constant / root view / descriptor-table setters for compute and
graphics, SetDescriptorHeaps, Dispatch recording the user data as it is,
ClearState (which also resets #164's stencil references); misuse makes
Close return E_INVALIDARG.
- Test helper and standalone device enable bufferDeviceAddress.
Test: d3d12_compute_test (through the proxy) creates the root signature
from the PC serializer's blob and the PSO through slot 62 in the measured
(desc, 0, 0, riid, out) shape (28cf235) from a container shaped like the
game's, sets root constants, a root UAV and a table whose
application-written entry points at an upload buffer, runs two dispatches
that each keep their own arguments, and reads the results back: 64/64
twice. Its shader is GLSL written to the translator's push-constant and
address contract, compiled with glslangValidator. Clean under the Khronos
validation layer, as are the other GPU tests; 13/13 ctest.
DiscardResource's per-subresource loop in vulkan_replay.h declared `i`, which
hides the command loop's `i`. MSVC /W4 reported C4456 in 15 targets. The loop
behaves the same; only the name changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amd_fidelityfx_upscaler_xbox.dll, measured with Ghidra 12.2 (through REA)
and run by fsr_dispatch_test on PC devices (RTX 2000 Ada and WARP) behind
the Xbox-ABI proxy.
Backend descriptor: the provider's create walks the chain for type
0x01000002, {header, device} with the device at +0x10, and ends in
FFX_API_RETURN_ERROR without it (what RT-3 got with 0x0200000x). With it
the DLL creates its backend through the proxy: device slots 14, 15, 18, 19,
27, 38 and 76 and heap slot 9, at the shapes the PC order and the measured
overrides predict; slot 76 takes the seven CreateCommittedResource
arguments. No earlier test here reached slot 76 or heap slot 9.
Two runtime bugs it found:
- XMemGetWorkingSetStatistics takes (kind, stats*): all seven call sites
pass kind 0x20000001 in ECX and a stack buffer in RDX. The one-argument
shim wrote to address 0x20000001.
- Device slot 67 is a console-only compute-pipeline call (a code blob in its
desc), not the PC CreateProtectedResourceSession1 the proxy forwarded it
to. The proxy now refuses it (E_NOTIMPL).
The context: on the RTX 2000 Ada the create stops at the DLL's HRESULT
check, because the driver refuses its R9G9B9E5_SHAREDEXP texture with
ALLOW_UNORDERED_ACCESS (WARP takes it). The test reports that stop and
retries with one PC stand-in (that texture as R32_UINT). On the context it
records one ffxDispatch into a logging command list that is never executed.
The console command list, from that run and the DLL's recorder (RVA
0x59a0), the same 13 calls on both devices: slots 14, 15, 25 and 26 at
their PC positions, then SetDescriptorHeaps at 32 (PC 28, seen in the run),
SetComputeRootDescriptorTable at 35 (PC 31), ClearUnorderedAccessViewUint
at 53 (PC 49, seen in the run), ExecuteIndirect at 61 (PC 59), and
console-only methods at 85 and 141. 33 and 41 fit SetComputeRootSignature
and SetComputeRootConstantBufferView by shape; the docs mark them inferred.
The logging list forwards only measured slots. The list object also carries
a write cursor and limits (+0x18, +0x28, +0x30) the DLL writes root
arguments and dispatches through while there is room; with the cursor at
the limit every command takes the vtable. These are the fields docs section
3.4 measured in the BVH builder without a meaning.
The dispatch stops at the DLL's compute pipeline: its 29 shaders are DXBC
with an ACCC part (payload tag FSPX) and no DXIL, and the PC runtime
refuses them at slot 62; the dispatch goes on with the null pipeline and
faults, which the test reports as the documented PC limit. Its C++ `throw`
also shows the loader gap: _CxxThrowException finds no image base for a
manually mapped image.
The test's fault report gives the faulting module and RVA, the access, the
C++ throw's ThrowInfo, image base and unwound stack, and the HRESULT the
DLL formatted with the DLL frames that made the failing call.
Docs: d3d12_vulkan.md Appendix A.3 and open question 2,
d3d12_command_objects.md 3.4 and 3.5a, design.md and runtime/README.md.
First pieces of D3D-3 (compute path), no pipelines wired up yet:
- shader_library.h: FSSM extraction from the DXBC container (DXIL, XDAT
0x0D, XBCH, zlib), SHA-256, a minimal JSON reader and the
spirv/index.json lookup by fssm_sha256. Self-contained inflate, no
dependencies.
- IR Dispatch with user data captured at record time; replay binds the
pipeline, pushes the 144-byte block (s0..s31, heap base, code base) and
dispatches. Arena buffers get a buffer_offset that copies honour.
- Root signatures use main's model (runtime/src/root_signature.h); the docs
say so.
Tests: shader_library_test (FIPS 180-4 vectors; stored, fixed and dynamic
deflate blocks; corrupt and truncated streams; FSSM from a synthetic
container) joins ctest; command_list_test covers dispatch recording.
D3D12 leaves where the packed tail starts to the driver (#654 made the test
accept any host's split). The layer used NVIDIA's: packed from the first mip
smaller than a tile on any axis. The console is RDNA2, so it now follows AMD's
PC runtime, as @traeb0n (D3D-20) recommended on #634.
AMD's rule, measured on an RX 9070 XT (RDNA4, 32.0.31041.1004) and a Ryzen 7
9800X3D iGPU (RDNA2, 32.0.21045.5002), identical on both: a mip stays standard
while it is wider than half the tile or taller than the tile; depth does not
count. It fits all 47 measured layouts: compare_tiling's 17 and 30 edge cases
(a mip exactly at or just past half a tile, thin and tall textures, non-square
2D and volume tiles). The rule first proposed on #374 ("every axis at most half
the tile's largest side") fitted the 17 but missed four tall or deep ones.
- src/resource_tiling.h: the new split; a standard mip smaller than a tile
takes one tile on that axis.
- resource_tiling_test: the five layouts that change expect the AMD values,
plus a table of all 47 AMD layouts checking standard and packed mips, the
packed start and NumTilesForPackedMips (AMD's in 45; for the two deep
volumes that pack from mip 0, AMD reserves 2 tiles and the layer's tight
count gives 1).
- docs/d3d12_vulkan.md 4.2: the rule and the measurement.
AI-assisted (Claude Code).
Map XR_BIAS to the bit-compatible A2B10G10R10 UNORM Vulkan format, report only the 2D and cast-within-bit-layout support the layer provides, and refuse the mip, MSAA and 3D cases the PC runtime refuses. Test creation, allocation, footprints and the resource-method variants.
Two GPUs of one vendor share one driver, so the loader's driver filters
cannot tell them apart, and the D3D12 tests always took the last discrete
GPU (an RTX 3060 next to an RTX 5070 Ti). LEONIDA_VK_DEVICE is part of the
device name, compared without case, read by vk_test_device.h and by the
layer's standalone device. A value that matches no device fails the run
instead of testing another GPU, as LEONIDA_HOST_ADAPTER does. The shader GPU
tools (vk_compute_test, vk_harness, ...) keep their own pickers for now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_pe_loader_bounds maps images at 0x140000000 like loader_test, so it
links with GTA6RT_HOST_BASE too (under Wine every case was rejected with
"preferred base is taken").
run_wine_tests.py: a test whose command is a tool of the Windows runner
(gameinput's cmake -P, d3d12_trace's python) is reported as skipped with
that reason instead of failing as missing from the artifact.
CheckFeatureSupport already reported TEXTURE1D, but CreateCommittedResource
rejected the dimension. Create 1D images with a height-one extent, reject
non-unit heights and attachment flags, and teach GetCopyableFootprints and
GetResourceAllocationInfo the 1D shape. The device test now uploads and reads
back a 1D texture and a layer of a 1D array, and compares allocation and
footprint results with the PC runtime.
D3D12_RESOURCE_STATE_PREDICATION is the same bit as INDIRECT_ARGUMENT
(and SYNC/ACCESS_PREDICATION the same as EXECUTE_INDIRECT /
INDIRECT_ARGUMENT), and the layer mapped that bit only to
INDIRECT_COMMAND_READ at DRAW_INDIRECT. vkCmdBeginConditionalRenderingEXT
reads the predicate with CONDITIONAL_RENDERING_READ at the
CONDITIONAL_RENDERING stage, so ResolveQueryData -> COPY_DEST to
PREDICATION barrier -> SetPredication had no dependency from the copy's
write to the predicate read (and none the other way before the next
resolve).
With the extension enabled (the only case those flags are valid),
vulkan_access and vulkan_barrier_scope now add the conditional-rendering
access and stage for that bit; GENERIC_READ, which contains it, gets
them too. The replay passes the flag from its conditional-rendering
entry points.
d3d12_vulkan_device_test now enables conditional rendering on its device
and runs an occlusion query resolved into a predicate: EQUAL_ZERO skips a
clear, NOT_EQUAL_ZERO runs one, and the predicate is resolved into again
after the read, once through legacy barriers and once through enhanced
buffer barriers. d3d12_state_map_test checks both mappings with and
without the extension.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loader_test: the probe for security software that holds newly written
images also stops when writing and reading one back averages over
25 ms. Under Wine there is no such software and its file I/O alone took
38-40 ms in the wine job, so there only the refusals and contents are
checked.
The host comparisons move from d3d12_vulkan_device_test's
create_host_device to copycmp::create_host, so the copy comparisons are
skipped under Wine too (with them, winevulkan asserted in
vkBindBufferMemory).
From VictorJulianiR's review of the presenter, with Vonsek's measurements:
- A failed blit submission left the frame's fence reset with nothing to signal it, so the next present waited
forever (Vonsek: the retry reached vkWaitForFences with UINT64_MAX). An empty batch now takes the acquire
semaphore and signals the fence, and the swapchain is recreated next time to give back the image that was
never presented. If that batch fails too, or a fence wait or reset fails, the presenter stops (ok() is
false). A back buffer the device does not know is refused before an image is acquired for it.
- A swapchain recreation published the new swapchain before its per-image semaphores existed, so a failed
semaphore left a presenter that could submit with a null one. The images and semaphores are now built in
local storage and published only when all exist; on a failure the partial objects are released and the next
present tries again.
- An out-of-date present was counted as presented (Vonsek: 69 VK_SUCCESS and one VK_ERROR_OUT_OF_DATE_KHR
reached 70). presented() now counts VK_SUCCESS and VK_SUBOPTIMAL_KHR only; the caller still gets VK_SUCCESS.
d3d12_present_test gives the device and presenter their functions through a driver double that forwards to the
real driver. It counts real out-of-date presents (the frame counts allow for them) and live binary semaphores.
It reports one present as out of date and one as suboptimal, fails the second semaphore of a recreation, and
fails one blit submission. Against the old presenter the test fails at the frame count after the resize, where
this RTX 5060 Ti reported a real out-of-date present.
Docs: the presenter is named as leonida::VulkanPresenter, made by rt::d3d12::create_window_presenter, and the
test is described as 60 frames then 10 after a resize (AlxcBTW).
vk_texture_test returned 1 instead of the unsupported code 77 when
maxPushConstantsSize is below the 144 bytes it needs (only --two-mip got 77),
and run_gpu_tests.py treated any non-zero exit of the bindless texture tests and
ps_gather_wrap as a failure. On a 128-byte device that reported 8 FAILs instead
of SKIPs. Both now skip with the device's own reason; check.py already mapped 77
to a skip.
The debug messenger in test/vk_test_device.h counted every error-severity
message, so a broken third-party implicit layer (ReShade's, reported on an
RTX 5090) failed every GPU test. Only VALIDATION-type errors are counted now;
general loader and layer messages are still printed, marked "not counted".
A real validation error still fails the test (checked by replaying part B of
vk_command_replay_test without the layout tracker). runtime/README.md says
so and mentions VK_LOADER_LAYERS_DISABLE.
- vulkan_present.h: VulkanPresenter blits a back buffer (an ordinary texture
in D3D12's PRESENT state, layout tracked like any other) to an acquired
swapchain image and presents it on the same VkQueue, after the
application's work. Two frames in flight, a present semaphore per image,
FIFO for vsync else MAILBOX/IMMEDIATE, swapchain recreated on resize or
out-of-date/suboptimal, minimised windows skip presents.
- rt::d3d12::create_window_presenter / WindowPresenter: Win32 surface for a
Vulkan device created with presentation; holds the device. This is the back
end a DXGI shim or PresentX would call; the game's own front end is still
open (docs question 6), so neither is invented here.
- Standalone device enables VK_KHR_surface/win32_surface and VK_KHR_swapchain
when present; the test helper can too.
Test: d3d12_present_test opens a window and presents 60 frames through the
Xbox-ABI proxy (reset, PRESENT->RENDER_TARGET, clear, ->PRESENT, execute,
present, fence), resizes the window (swapchain recreated, scaled blit),
switches to unsynchronised presents, and reads the screen with GDI:
51,153,229 for a 51,153,230 clear. Clean under the Khronos validation layer,
as are the other GPU tests; 6/6 ctest.
SupportedSampleCountsWithNoOutputs was framebufferNoAttachmentsSampleCounts
masked to 1..32. Every GPU here reports 2x there, but D3D12's no-output
counts are the target-independent-rasterization ones (ForcedSampleCount
0, 1, 4, 8, 16; DirectX-Specs VulkanOn12.md: a driver reports at least
0b11101), and the PC runtime's hosts report 0x1d. On the Radeon 880M the
layer answered 0xf, not a subset of the host's 0x1d, so
d3d12_vulkan_device_test failed options_mismatches against every host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reused or lower fence value makes SetEventOnCompletion return at once, so a
block read results the GPU had not written yet (#278 hit this twice after
rebases). Every wait on the main fence now goes through submit_and_wait, which
signals the next value and waits for it, including the query blocks that landed
with 10 and 11. Fences that belong to one block (ms_fence, the standalone
device's) keep their own values.
Its host comparisons take Microsoft's d3d12.dll as the reference. Wine's
(vkd3d) lays out depth-stencil formats in one plane, rejects R9G9B9E5
and BC footprints and accepts descriptions Microsoft's runtime refuses,
so under Wine (ntdll exports wine_get_version) create_host_device
answers as when there is no host device: each comparison is printed as
skipped. Windows compares as before.
device_proxy and d3d12_xs_root_signature need a WARP adapter, which
Wine doesn't have: without one they exit 77, which CTest reads as a
skip (SKIP_RETURN_CODE). A missing DXGI factory still fails.
root_sig_test checked that the host serializer rejects the Xbox flag
byte. Microsoft's d3d12.dll does; Wine's (vkd3d) doesn't validate it.
That is a property of the host, not of the shim, so a host that accepts
it is reported as a skip, as the deserializer check already does.
A mismatch now prints the node masks and heap flags the case asked for (the four mask cases share a name).
Corrects a comment that said CREATE_NOT_ZEROED is kept (the host drops it), and wraps lines over 120 columns.
No change to what is compared: 18 of 18 heap and 8 of 8 descriptor heap cases match on the default adapter
and WARP; against main's shim 18 heap and 4 descriptor heap cases differ on each.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ID3D12DescriptorHeap::GetDesc and ID3D12Resource::GetHeapProperties echoed their inputs. On the host, a node
mask of 0 reads back as 1 (one node), and a committed resource reports the heap flags the runtime resolves:
its own flags, without CREATE_NOT_RESIDENT and CREATE_NOT_ZEROED, plus DENY_* bits for the resource classes
it is not (buffers 0xC0, textures without render-target or depth use 0x44, the others 0x84).
Measured with a probe on the default adapter (RTX 3060, driver 596.36) and WARP, Windows 10 19041 runtime.
d3d12_node_mask_test compares 18 heap cases and 8 descriptor heap cases with the host on both; before this
change every descriptor heap with node mask 0 and every committed buffer or texture differed on each reference. Not in ctest, like d3d12_resource_desc_test.
AI-assisted (Claude Code). Tested: d3d12_node_mask_test with and without LEONIDA_VK_VALIDATION=1 (0 validation
errors); full ctest, where d3d12_vulkan_device fails on CheckFeatureSupport shader model and root signature
(Windows 10 host predates them, #816), as on main.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Main's depth-plane SRV T# code follows the texture's backing format (X24_8_32_FLOAT
where D24 is stored as D32), so the override from f9addf5 is dropped and the
D24 comparison test expects the backing format's code. The family refusal and
bind_image are main's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On an RTX 4080 SUPER (Windows 617.14) the host_device_local placement's memory type 4
(DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT) refuses a 160 KiB allocation with
VK_ERROR_OUT_OF_DEVICE_MEMORY. alloc_buffer_mt returned false without a word and the
placement loop exited 1, so a default run measured only the 1k table.
alloc_buffer_mt now reports the failing call and its VkResult. The optional ReBAR placement
is skipped with a note, as when no such memory type exists; a device_local or host_visible
allocation that fails is still an error, now with its reason.
The query fell through to E_INVALIDARG. It now reports the Vulkan physical
device's subgroup operations and wave-size range, with TotalLaneCount held to
one full wave because Vulkan has no device-wide lane count.
Map XR_BIAS to the bit-compatible A2B10G10R10 UNORM Vulkan format, report only the 2D and cast-within-bit-layout support the layer provides, and refuse the mip, MSAA and 3D cases the PC runtime refuses. Test creation, allocation, footprints and the resource-method variants.
The hardware depth function is zero for both a regular sampler and a NEVER comparison. Give layer-created NEVER comparisons a separate descriptor key so Vulkan binds a comparison-enabled sampler.
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.