From the reviews and test runs on #291:
- A pipeline without vertex bindings (a full-screen pass from SV_VertexID) no longer declares the vertex-stride
dynamic state, which nothing would set (VUID-vkCmdDraw-pStrides-04913; aslan2142, AlxcBTW, ezwinxdlmao).
- Logic ops are applied from RenderTarget[0] instead of being logged and ignored (Vonsek's XOR case), and
DepthClipEnable = FALSE is depth clamping (AlxcBTW). Both need their feature (logicOp, depthClamp), or the
PSO is refused.
- The standalone device also enables shaderInt64, shaderFloat64, shaderInt16, shaderClipDistance and
shaderCullDistance where the GPU has them (AlxcBTW, whattheflop: VUID-...-pCode-08740), plus logicOp and
depthClamp.
- Among index entries for one program, a PSO takes the first that fits and declares no set-0 bindings, as
pipelines do not bind set 0 yet. This covers the compute group in poke900310's corpus count, where an entry
with 10 bindings shadowed a binding-free one.
- The command list holds a reference to every root signature and pipeline state it is given until Reset or
its release, so releasing them right after Set* (as D3D12 allows) no longer leaves dangling layouts or drops
the submission (AlxcBTW).
After the rebase onto main: main's SetPredication reads the predicate through the resource's VkBuffer, so a
default-heap buffer (a range of the GPU address arena) adds its offset in the arena, and the arena gets the
conditional-rendering usage when the extension is on (lahlousaad4's integration note).
Tests: d3d12_draw_test has a second pass with a full-screen triangle first in its submission and an XOR quad,
and a depth-clamp refusal. d3d12_compute_test releases its root signature and PSO right after setting them,
sets the signature again after the arguments, and has a bound entry ahead of the binding-free one in its
index. Each new fix, undone on its own, fails a test: pStrides-04913, wrong XOR pixels, a heap-corruption
crash without the hold, a refused PSO without the binding-free choice.
Documented as known gaps, not fixed here: wave64 subgroup size (AlxcBTW's follow-up in #313), cross-queue
waits on one VkQueue and CPU fence signals below a pending GPU signal (woreksami), and the linear buffer_at.
Shader library
- fssm_program takes the last XDAT 0x0D payload, as tools/fssm_unpack.py does by default (195 of 26,503
containers have two different ones, and fssm_sha256 is computed from the last).
- The JSON reader parses numbers with from_chars and \u escapes as exactly four hex digits, so a malformed
index is refused instead of throwing into the shim. Integer fields outside 0..2^32-1 read as 0.
- Index entries that share a program are all kept; CreateGraphicsPipelineState takes the VS whose input
signature the input layout feeds.
Command list
- Setting the root signature that is already bound keeps the root arguments, as D3D12 does.
- A draw with no viewport (never set, or RSSetViewports(0, ...)) or an empty one is not recorded: D3D12
rasterizes nothing and Vulkan forbids a 0x0 viewport.
- More than eight render targets is an invalid call, in OMSetRenderTargets and in a PSO.
Device
- Buffers of 0 bytes, or with a size that wraps when aligned, are E_INVALIDARG. The arena refuses zero-size
ranges, and its fit test cannot wrap.
- A shader-visible descriptor heap the arena cannot hold is E_OUTOFMEMORY instead of a host heap with GPU
handle 0.
- A failed arena releases its buffer and memory, so other buffers do not get raw device addresses as VAs.
- Graphics PSOs that need independentBlend, fillModeNonSolid, depthBiasClamp or dualSrcBlend are refused
unless VulkanDeviceInfo::features has them. The standalone device enables those the GPU supports.
- A draw that leaves a slot unbound where the PSO names a format uses a pipeline variant with that format
undefined (built on first use, kept with the PSO), instead of breaking
dynamicRenderingUnusedAttachments-08912.
- Instance step rate 0 reads element 0 for every instance (stride 0 at draw time).
- The Vulkan 1.0 graphics entry points are required; the 1.3 ones are checked before a graphics PSO is made.
Replay
- An unbound vertex slot, or an indexed draw with no index buffer, reads the arena's reserved first 64 KiB,
which is kept zero, as D3D12 reads zeros. A view that runs past its buffer is cut at the buffer's end
instead of failing the whole ExecuteCommandLists.
- The rendering layer count is the smallest layer count of the bound views.
Tests: shader_library_test covers two payloads, malformed JSON and duplicate programs. d3d12_draw_test
covers an unbound RT and DSV, a rebound root signature, step rate 0, an unbound vertex slot, a draw with no
viewport, the feature and count refusals, and bad buffer and heap sizes. Each of the rebind, step-rate and
variant fixes, undone on its own, makes the test fail.
Still open, documented: instance step rates above 1, read-only DSV layouts, and the index buffer's view size.
Review feedback from IAmNotSiob:
- Both PSO paths declared a 144-byte push-constant range without consulting #224's limit. On a device with
maxPushConstantsSize 128 (the Vulkan minimum) that breaks VUID-VkPushConstantRange-size-00298 and returns a
bare E_FAIL. Both paths now refuse with E_NOTIMPL and log the limit until the uniform-buffer tail exists.
d3d12_compute_test checks this with a device that reports 128 bytes.
- The graphics range's stage flags are now the whole stage table create_graphics accepts, kept in
GraphicsPipeline::push_stages, and the replay pushes with the same flags. A geometry or mesh stage added to
the table is covered without another change.
docs/d3d12_vulkan.md section 5.2 now counts code-base readers per stage with the current translator: of the 662
shaders with s_getpc_b64, 53 VS, 92 PS, 246 MS and 263 CS read the code base. VS+PS pairs are only known at
PSO creation.
Without Resizable BAR the only DEVICE_LOCAL | HOST_VISIBLE memory type sits in a heap of 256 MiB or less
(214 MiB on an RTX 3090, driver 616.56). The 256 MiB default arena preferred that type, so vkAllocateMemory
was asked for more than the heap holds (VUID-vkAllocateMemory-pAllocateInfo-01713). The NVIDIA driver still
returned VK_SUCCESS, so the fallback to plain host-visible memory never ran, and d3d12_compute_test and
d3d12_draw_test failed under validation. Reported by CharlyRien.
memory_type_order (vulkan_backend.h) now leaves out every type whose heap is smaller than the allocation,
so the preference falls through to system memory there. DeviceState::allocate uses it for every allocation.
d3d12_state_map_test checks the order on that card's heap layout and with Resizable BAR on.
- CreateGraphicsPipelineState (PC slot 10): VS and PS found by the SHA-256
of their FSSM programs in the translator's index. Input-layout elements are
matched to the VS input signature by semantic name and index; location =
the element's register (the translator's vertex-fetch rule); a layout that
leaves an input unfed is refused, as D3D12 does. Rasterizer, blend and
depth-stencil state map one to one; viewport, scissor, topology, vertex
strides, stencil references and blend factor are dynamic; dynamic
rendering takes the RTV/DSV formats. Hull/domain/geometry, stream output,
MSAA, set-0 bindings and two code-base stages (question 14) are refused
with a log.
- Command list: IASetPrimitiveTopology / VertexBuffers / IndexBuffer,
RSSetViewports / ScissorRects (first of each), OMSetRenderTargets (views
read at the call, single-range handles too), OMSetBlendFactor,
OMSetStencilRef and CommandList8's front/back references (now applied),
DrawInstanced / DrawIndexedInstanced recording a copy of that state.
CreateCommandList's initial pipeline state is applied. Reset and
ClearState share one state reset.
- Replay: vertex/index views resolve to buffers by VA (arena or upload),
attachments move to attachment layouts through the tracker (first use
zero-fills), the draw runs in a dynamic-rendering scope with a flipped
viewport (translated VS write D3D clip coordinates), stencil references
per face, then vkCmdDraw / vkCmdDrawIndexed. Render-target views take the
pipeline's formats (the view cache keys on format).
- shader_library.h reads the index's input_signature and PS outputs.
Test: d3d12_draw_test (through the proxy) builds a VS+PS PSO whose input
layout order differs from the VS registers, uploads a vertex buffer into the
arena, reads indices from an upload heap, and draws two indexed quads with
different root constants and root CBVs plus a back-facing triangle: all 4096
read-back pixels match (which also checks the viewport flip and winding).
Shaders are GLSL written to the translator's contract. d3d12_com_test now
uses SetMarker as its unimplemented-method example, since DrawInstanced is
implemented. 13/13 ctest; all six GPU tests clean under the Khronos
validation layer.
- 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.
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>
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.
- 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>
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>
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.
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.
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>
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>
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>