docs/d3d12_vulkan.md: drop stale "not implemented" status for buffer SRVs, streams, mesh PSOs and WriteBufferImmediate (DOC-D3D12-VULKAN-STALE-STATUS)
630 KiB
Xbox D3D12 (d3d12_xs) to Vulkan
Status: in progress. A Vulkan-backed ID3D12Device (queues, allocators, command lists, fences, descriptor heaps,
render-target and depth views, texture views and samplers, committed and reserved buffers, 2D textures and 3D texture transfers and color clears, and query heaps)
runs behind the Xbox-ABI device proxy, and a presenter puts back buffers in a window (section 3.2). The M0
milestone passes in a synthetic test (section 6), M1 with stand-in shaders in d3d12_draw_test, M1.5 with
hand-written RDNA2 run through the translator in d3d12_translated_draw_test, and the synthetic part of M2
(descriptor heaps, SRVs, a sampler and a translated textured-quad draw, 4,096 exact pixels) in
d3d12_m2_textured_test. D3D12XboxCreateDevice uses it when LEONIDA_D3D12=vulkan is
set and the host PC device otherwise. Root signatures (packed into the 32 user-data dwords), graphics and compute
PSOs, draws, dispatches, ExecuteIndirect, and presentation through PresentX or a DXGI swapchain are implemented
and have GPU tests; which present path the game uses is still open (question 6). Shader-resource views of buffers
are implemented, and so are pipeline-state streams (CreatePipelineState) and mesh PSOs with DispatchMesh
(D3D-29, section 3.6); MeshShaderTier is 1 only where the GPU has VK_EXT_mesh_shader. Tessellation,
stream-output and amplification-shader pipelines are not implemented. The device reports
RaytracingTier as NOT_SUPPORTED, yet BuildRaytracingAccelerationStructure builds XDXR BVH4 structures on the
GPU (section 4.8). This is the plan for
replacing the console's d3d12_xs.dll with an implementation that records D3D12 commands and replays them on
Vulkan, while producing exactly the shader-visible contract that tools/rdna2spirv.py already emits against (see
design.md).
The document is deliberately conservative about what is known. Every claim is marked:
- Verified — observed in this repository or in the game package, with a way to reproduce it.
- Public — documented in the Windows SDK, Microsoft's public GDK/D3D12 documentation, or the Vulkan specification.
- Assumption — a design choice that must be checked against the game's executable when it is available.
- Open — unknown; listed with a way to resolve it.
Nothing here uses game data, keys or decryption. The package is read-only; the executable that would answer most of the open questions is not in it.
1. The job
The game is an Xbox Series build (game_scarlett_master.exe, d3d12_xs.h / d3d12_xs.lib). It was compiled
against the Xbox flavour of D3D12 and calls the console driver through COM interfaces. The layer must:
- Intercept the D3D12 surface. Free functions exported by
d3d12_xs.dll(device creation, root-signature serialization) and every COM method the game calls on the returned objects. The objects are our own C++ objects; the vtables must have the exact method order the game was compiled against. - Preserve D3D12 semantics that affect output. Command lists record; execution is deferred; descriptors are values (GPU virtual addresses or CPU handles); resource states are explicit; root arguments are set at record time; allocators and fences control reuse.
- Produce the translator's shader contract. The translated SPIR-V is already written against a bindless set 0, a 144-byte push-constant block, a descriptor hash table and one GPU address space. Changing that contract would invalidate 26,503 translated shaders and the GPU tests that check them.
The layer is not a general D3D12-on-Vulkan compatibility layer. It only needs the calls this game makes, but each call it accepts must behave like D3D12.
2. What is verifiable today
| Fact | Evidence | Confidence |
|---|---|---|
The public D3D12 interface chain and method order are in the Windows SDK d3d12.h (10.0.26100.0 here). The Xbox public reference lists the same base interfaces and method names under d3d12_xs.h / d3d12_xs.lib; the measured Xbox device ABI is mostly that order, with deviations at slots 62/76 and heap slots 9/10 (section 7). |
Local SDK header; Xbox public graphics reference; e.g. CreateCommittedResource | Public; measured deviations in section 7 |
The game's raytracing helper is a shipped DLL, XboxBvhBuilder.dll, whose export signatures name ID3D12Device11, ID3D12GraphicsCommandList4, ID3D12GraphicsCommandList6 and ID3D12GraphicsCommandList8, plus Xbox XDXR batched/streaming acceleration-structure types. |
PE export table of XboxBvhBuilder.dll (884,224 bytes); see Appendix A |
Verified |
That DLL imports only d3d12_xs.dll!D3D12SerializeVersionedRootSignature and xmem.dll!XMemVirtualQuery from console libraries. It receives the device and command lists from the game. |
PE import table; Appendix A | Verified |
amd_fidelityfx_upscaler_xbox.dll imports only d3d12_xs.dll!D3D12CreateRootSignatureDeserializer and contains the base ID3D12Device, ID3D12Resource, ID3D12PipelineState, ID3D12RootSignature, ID3D12Heap, ID3D12DescriptorHeap and ID3D12CommandSignature IIDs. |
PE import table and GUID byte scan; Appendix A | Verified |
None of the other scanned non-CRT DLLs (amd_fidelityfx_loader_xbox, Bink2Scarlett, libHttpClient.GDK, XCurl) imports d3d12_xs. |
PE import scan; Appendix A | Verified |
The package layout lists game_scarlett_master.exe, but the file is not in the package folder. |
layout_..._xs.xml, chunk 1001; directory listing |
Verified |
gameos.xvd is an XVD (msft-xvd at file offset 0x200, format version 3) with a high-entropy payload and no plaintext PE headers or D3D12 strings. Extracting d3d12_xs.dll from it would require keys, which this project does not do. |
Entropy and string scan; Appendix A | Verified |
Prior art runs the package DLLs against a PC D3D12 device and measured the Xbox ABI: 6 Xbox-specific static imports across the 16 DLLs, D3D12XboxCreateDevice, device slots 62/76, descriptor-heap start handles in RAX, root-signature flags 0x03000000, and the BVH builder's Xbox DXIL shaders. |
PLATFORM_SURFACE.md, platform README | Verified by the prior art (running the package DLLs / static imports; section 7) |
| The translator and its GPU tests already define the shader contract: set 0 bindings 0–19, 144-byte push constants, heap/code base, FNV-1a descriptor hash table, buffer device addresses. | design.md; runtime/test/vk_texture_test.cpp |
Verified |
What this does not tell us: the full d3d12_xs.dll export list, the D3D12XboxCreateDevice params/flag
layout, the remaining Xbox slot deviations (presentation, command lists, queues, fences), the
root-signature-to-s0..s31 mapping, the console descriptor layout, the present path, the raytracing path, and the
GPU VA window. Section 8.2 lists each with a way to resolve it.
The first run with the executable should be a trace build: every free function and COM method is a logging stub that returns a failure, and the methods are filled in in the order the game calls them. Section 3.1 describes the interception; section 8.2 turns the trace into a work list.
3. Architecture
3.1 Interception and COM
The current shim (runtime/shims/d3d12_xs.cpp) forwards only two free functions to the host d3d12.dll. That is
enough for the bundled middleware's d3d12_xs calls, not for the game. The layer adds:
- Free functions. Every
d3d12_xs.dllexport the executable imports. The import table is the source of truth. Prior art names the device entry pointD3D12XboxCreateDevice(adapter, params, riid, out); its 24-word params struct is only logged there, and the signature is taken from public documentation rather than a header. Treat the params/flag layout as Open, accept the call, log the words, and create the device. Do not assumeD3D12CreateDeviceis the console entry point. - COM objects.
Device,CommandQueue,CommandAllocator,GraphicsCommandList,RootSignature,PipelineState,DescriptorHeap,Resource,Heap,Fence,QueryHeap,CommandSignature,PipelineLibrary, and the raytracing/lifetime objects if used. - Vtable layout. Use the Windows SDK's
d3d12.hdeclarations for the public chain, but treat the vtable as mostly public, not universally public. Prior art measured device slots 1, 15, 18, 19, 27 and 38 in the desktop order, but also an extra texture-creation method at slot 76, aCreateComputePipelineStatecall at slot 62 where the PC interface it forwarded to presentsCreateStateObject(different arity), and descriptor-heap start handles returned in RAX at heap slots 9/10. Implement the public chain plus those measured overrides explicitly; do not assume every slot. On the retail executable's higher device slots (runtime/shims/d3d12_xs_device.cpp), slot 86 routesCreatePipelineState(desc, riid, out)to PC slot 47 (ID3D12Device2::CreatePipelineState) and keeps a deep copy of the stream on the PSO it returns; slot 55 (CreateDerivedPipelineState(pBasePSO, n, pRecords, riid, out),n= 1..4 records of 0x14c bytes: a u32 tag, then the payload at +4) patches a copy of that stream and creates the PSO through the same path. Tags 0 (D3D12_DEPTH_STENCIL_DESC, on DEPTH_STENCIL or DEPTH_STENCIL1), 1 (D3D12_RASTERIZER_DESC), 2 (D3D12_BLEND_DESC) and 3 (sample mask) are the TomBox layout (GPL-3.0,create_derived_pso_x), checked against the title's record writes in the retail build: tag 1 is the rasterizer (0x2c bytes, always record 0 when present), tag 0 the DEPTH_STENCIL (0x34), tag 2 the BLEND (0x148). Tag 3 (sample mask, from TomBox) is served although that function does not write it. Tag 5 (0x16 bytes: 16 zero bytes, then the StencilReadMask and StencilWriteMask bytes at the DEPTH_STENCIL offsets 0x10/0x11, then zeros) overlays only those two bytes of the base's DEPTH_STENCIL or DEPTH_STENCIL1, in record order; this is inferred from the title's writes, not measured at run time. Any other tag, or a base that was not created through slot 86/55, is refused (E_INVALIDARG/E_FAIL, null output). The stream copy lives inruntime/shims/d3d12_xs_pso_stream.cppand goes with the PSO (private data, released with it),D3D12_PIPELINE_STATE_SUBOBJECT_TYPEvalues that the module does not walk (VIEW_INSTANCING) are not kept, so a PSO built from them is refused as a base, slot 101 routesCreateStateObject(desc, riid, out)to PC slot 62 (ID3D12Device5::CreateStateObject), and slot 108 routesGetResourceAllocationInfo2(accepting the console C-ABI struct return with the return buffer inRCXand the device inRDX, expanding 56-byteD3D12_RESOURCE_DESCentries toD3D12_RESOURCE_DESC1and normalizing Xbox layout words and flag bits on the copy) to PC slot 68 (ID3D12Device8::GetResourceAllocationInfo2). Device 11 addsCreateSampler2; command list 8 addsOMSetFrontAndBackStencilRef(public SDK). - Unknown IIDs and slots.
QueryInterfacemust log the IID and returnE_NOINTERFACEif it is not in the public chain. If the game then fails, the IID and the call site identify the Xbox-specific interface to reverse. Do not invent a vtable for an unknown IID: a wrong slot is worse than a clean failure. - No host D3D12 or DXGI. The PE loader currently lets unknown system DLLs bind to the host.
dxgi.dllandd3d12.dllmust be shimmed, not resolved from System32. Host DXGI would hand the game a desktop adapter and swapchain that cannot see our Vulkan device, and host D3D12 would create a second, unrelated device. This is an integration requirement, not an optimisation. - Trace first.
gta6rt --trace-d3d12emits numbered records for device entry points, Vulkan device operations, command-list recording and queue submission. Records contain fixed API names and outcomes only. See the runtime guide for collecting a trace.
Measured, not assumed: the Xbox device ABI is not uniformly the desktop order. Slots 1/15/18/19/27/38 matched in the prior art, while slots 62 and 76 and the heap start-handle return convention did not. Treat every slot as unverified until traced; the public interface names and IIDs may still be usable, but the slot mapping is not guaranteed.
3.2 Record and replay
D3D12 command lists are recorded, then executed later. Vulkan command buffers are also recorded, but the layer must not simply translate each D3D12 call into a Vulkan call as it arrives, because:
- descriptor heaps can be updated between recording and execution;
- a command list can be reset and rerecorded;
- a bundle is recorded once and executed many times.
The design is therefore an IR per command list:
SetPipelineState, root arguments, vertex/index buffers, viewport/scissor, render targets, descriptor-heap bindings and the other sticky state update a state block.- Each draw/dispatch/copy/barrier appends a compact command with a snapshot of the state that affects it. GPU descriptor tables can refer to shader-visible heap entries at execution. CPU descriptors such as RTVs are consumed while recording, so their view contents go into the IR. An application can reuse the CPU descriptor slot after the call. See Microsoft's descriptor overview.
ExecuteCommandListsreplays the IR into a freshVkCommandBuffer, resolving descriptors, uploading dirty descriptor ranges and the hash table, and emitting barriers. Bundles are inlined when they are executed (seeExecuteBundlebelow).Reseton a command list discards its IR; the allocator owns the memory. D3D12 already requires the application not to reset an allocator whose lists are in flight; the layer can rely on that and assert in debug builds.- Command-list and allocator misuse returns what the PC runtime returns (D3D-51).
d3d12_vulkan_device_testruns the same 25 calls on the host runtime and on this layer and compares the HRESULTs. One list at a time records into an allocator: creating or resetting a second list onto it givesE_INVALIDARG, and resetting the allocator while a list records into it givesE_FAIL.Closetwice andResetof an open list giveE_FAIL. Resetting an allocator whose lists are still executing givesS_OKon the PC runtime too (keeping that safe is the application's job). Two differences remain.Resetwith a null allocator crashes the PC runtime, while ours returnsE_INVALIDARG, so that call is not compared. Executing a list that is still open removes the PC device (GetDeviceRemovedReasongivesDXGI_ERROR_INVALID_CALL), while this layer submits nothing and keeps the device: an invalid call does not remove it. Creation answers as the host runtime too (compare_invalid_arguments, "command allocator:", "command list:" and "command list1:", RTX 5070 / 621.14): a type pastVIDEO_ENCODEand a node other than node 0 areE_INVALIDARG, checked before the output; a null output is thenE_UNEXPECTED. Video list types are created as graphics lists here, while the host hands out a video list (E_NOINTERFACEforID3D12GraphicsCommandList), so they are not compared. Closefreezes the IR.ExecuteBundleis accepted only on a direct list, with an already-closed bundle as its callee; the bundle's recorded commands and calls are replayed at the call site, so the source can be reused or reset without changing the parent. Command-list creation and reset require an allocator of the same type. A bundle cannot be submitted directly to a command queue.- Bundle restrictions are checked while recording for the IR operations currently implemented here (barriers, clears, copies, resolves,
SetPredication,DiscardResource, the atomic copies,RSSetViewports,RSSetScissorRects,OMSetRenderTargetsandClearState;WriteBufferImmediateis allowed in a bundle); those calls are not legal inside a D3D12 bundle and makeClosereturnE_INVALIDARG.d3d12_bundle_forbidden_testmeasured the last four on the PC runtime without the debug layer: the bundle'sClosefails (E_FAIL, where this layer givesE_INVALIDARG) on the default adapter and on WARP, and executing a bundle whoseClosefailed crashes the runtime, so the layer refuses it inExecuteBundleinstead. A bundle has no render targets, viewport or root signature of its own, so its state calls (pipeline state, root signature and arguments, vertex and index buffers, topology, blend factor, stencil references) and its draws and dispatches are kept as they were called, andExecuteBundleplays them on the parent through the same members the application would have called. A draw then snapshots the parent's state plus what the bundle set, and what the bundle set stays on the parent afterwards. Commands that need no state (markers, immediate writes) are copied between them in order.d3d12_bundle_testmeasured the rule on the PC runtime, where the default adapter (an RTX 4060 Ti) and WARP drew the same picture in every case it ran. A bundle's draws see the parent's render targets, viewport and scissor, root signature and arguments (also when the bundle sets the same root signature first, so those arguments stay), and vertex and index buffers. A bundle starts with the pipeline state it was created or reset with, not the parent's. AfterExecuteBundlethe parent has that pipeline state and whatever else the bundle set: topology, root arguments, vertex and index buffers, and a different root signature with the bundle's arguments in place of the parent's. Topology: the default adapter takes the parent's when the bundle sets none. That is more lenient than Microsoft's stated rule (topology is undefined when a bundle begins), and WARP follows the rule by removing the device when a bundle draws or hands back without one, so a bundle should set it; the layer follows the default adapter. A bundle that sets a root argument before any root signature crashes the NVIDIA driver (the layer applies it to the parent's signature). The deferred calls are checked when they play, against the parent's root signature, so a bad one makes the parent'sClosefail, not the bundle's. A per-list state setter must go through the deferred path (defer()ind3d12_com.cpp, replaying through a private member that does not trace) to work in a bundle.ExecuteIndirectin a bundle is deferred the same way (seeCreateCommandSignatureandExecuteIndirectbelow): a single DRAW, DRAW_INDEXED, DISPATCH or DISPATCH_MESH operation with no count buffer plays at eachExecuteBundlewith the parent's state at that call, and a count buffer or a signature with root or IA arguments makes the bundle'sClosefail.d3d12_bundle_indirect_dispatchmeasured the DISPATCH case on the PC runtime (an RTX 4060, driver 610.88, and WARP, Windows 11 10.0.26300.9974): a bundle created with a compute pipeline and no root signature, executed twice with a different root UAV bound on the parent each time, wrote each run's counters through the parent's root UAV of that call, also when the bundle set the parent's root signature first, and a directDispatchright after the secondExecuteBundle(behind a UAV barrier, with no rebind) still wrote through the parent's root UAV, so the parent keeps its root signature and arguments. Both host adapters returnE_INVALIDARGfrom the bundle'sClosefor a count buffer and for a root-constant signature, the code this layer gives. BundleDispatchitself has no GPU test. - What
Closereturns after one recorded call is compared with the PC runtime over WARP (no debug layer) byd3d12_close_parity_test, 116 cases on fresh lists, nothing executed. 85 agree (three of them enhanced texture barriers, two intoLAYOUT_UNDEFINED: section 4.3); the other 31 are listed in the test as known differences. In 16 the layer fails a list WARP closes: draws and dispatches with no pipeline, root arguments before a root signature, aCopyTextureRegionbox that is empty or inverted, footprint to footprint or at an unaligned footprint offset or pitch,CopyResourceof a resource onto itself,ClearDepthStencilViewwith an unknown flag, vertex-buffer slots past 31, 17 viewports, anOCCLUSIONquery ended asBINARY_OCCLUSION, andWriteBufferImmediateat an address that is not 4-aligned. Since one failed list fails the wholeExecuteCommandLists, each of these drops a submission D3D12 would run. In 15 the layer closes a list WARP fails (redundant or out-of-range barriers, copies past a resource's end or between formats of another family, resolves the PC runtime refuses, a query index past the heap); what the layer does with those at execution is not part of this test. A refused list's code is alwaysE_INVALIDARGhere, where the PC runtime also answersE_FAIL, so the test compares the verdict and prints both codes. - A queue's
ExecuteCommandListssubmits in order with one timeline semaphore signal.Wait/Signalbecome timeline-semaphore waits/signals.Presentqueues after the frame's work.
The command-list surface maps to the IR as follows:
| Recorded call | IR / replay |
|---|---|
SetPipelineState |
state; bind the VkPipeline before the next draw/dispatch |
SetGraphicsRootSignature / SetComputeRootSignature |
state; select the pipeline layout and root map |
Set*Root32BitConstant(s) / Set*Root*View / Set*RootDescriptorTable |
update root args; build the push-constant block at the draw/dispatch |
SetDescriptorHeaps |
state; scan/populate the bindless arrays and hash table at execute |
IASetVertexBuffers / IASetIndexBuffer / IASetPrimitiveTopology |
state; bind arena buffer + offset, dynamic topology. The console's rectangle list (17, PSO topology type 19) and quad list (19) are drawn as triangles, see Console rectangle and quad lists below |
RSSetViewports / RSSetScissorRects |
state; dynamic viewport/scissor |
OMSetRenderTargets / OMSetBlendFactor / OMSetStencilRef |
state; rendering scope and dynamic state |
DrawInstanced / DrawIndexedInstanced |
command with a state snapshot |
Dispatch / DispatchMesh |
command with a state snapshot |
Copy* / Resolve* / Clear* |
copy/clear command |
ResourceBarrier / Barrier |
barrier command; state tracking |
DiscardResource / WriteBufferImmediate / AtomicCopyBufferUINT(64) |
discard, immediate-write and atomic-copy commands (section 4.2) |
BeginQuery / EndQuery / ResolveQueryData |
query commands |
ExecuteIndirect |
command; signature + argument buffer |
BeginRenderPass / EndRenderPass |
rendering scope |
ExecuteBundle |
play the bundle's state calls and draws on this list, copy its state-free commands in order |
The IR is the place to add the trace, validation and "unsupported call" reporting. It also lets the layer replay a frame deterministically from a capture, which is valuable for comparing against the game.
What is implemented (all of it testable without the game):
-
IR (
runtime/src/command_list.h): legacy barriers (transition, UAV, aliasing; split barriers record their end half), enhanced barriers (global, buffer, texture; the half withSyncAfter = SPLITis dropped and the other is replayed as a full barrier),ClearRenderTargetView/ClearDepthStencilView, whole view or rectangles,CopyBufferRegion/CopyTextureRegion/CopyResource, colour resolves,ClearUnorderedAccessViewUint/ClearUnorderedAccessViewFloat(whole view or rectangles), (D3D-26)DiscardResource,WriteBufferImmediateandAtomicCopyBufferUINT/AtomicCopyBufferUINT64, andBeginQuery/EndQuery/ResolveQueryData(section 4.6). Views and rectangles are copied while recording, so the CPU descriptor slot can be rewritten afterwards. AClearDepthStencilViewflag for a plane the view's format doesn't have is ignored, as the PC runtime (WARP) does:STENCILon aD32_FLOATview clears nothing andDEPTH | STENCILclears the depth plane. Until 2026-11-23preparereturnedinvalid_clearfor it and the whole list was dropped (D3D-437);d3d12_clear_testcompares three such cases with WARP. The depth value is kept as given: on aD32_FLOATtarget WARP stores 1.5, -0.5 and NaN unchanged, and a clear whose flags name no plane clears nothing, so neither fails the list any more (d3d12_clear_testreads the texels back on WARP and here;d3d12_close_parity_testcompares theCloseverdicts). -
Replay (
runtime/src/vulkan_replay.h):prepareresolves and checks a list without writing anything,emitwrites it. Legacy states map through the section 4.3 table (vulkan_access), enhanced barriers throughvulkan_sync/vulkan_barrier_access/vulkan_layouttovkCmdPipelineBarrier2. Whole-view clears are transfer clears inside a layout round trip; rectangle clears arevkCmdClearAttachmentsin a dynamic-rendering scope, with rectangles clipped to the mip. Copies becomevkCmdCopyBuffer,vkCmdCopyBufferToImage,vkCmdCopyImageToBufferandvkCmdCopyImage. A placed footprint's row pitch becomesbufferRowLength, and block-compressed extents stop at the mip edge (D3D12 pads footprints to whole blocks, Vulkan does not; a texture-to-texture box of a block-compressed format is rounded up to whole blocks, as on the PC runtime, must fit the destination's padded mip, and the Vulkan extent is cut where it reaches an image's edge; Vulkan wants that per image, so when no single cut extent is a block multiple or at the edge of both images, for example a 4x4 box into a 3x3 mip, the copy goes through transfer scratch (vulkan_scratch.h, as depth <-> colour copies do):vkCmdCopyImageToBufferwith the source's own cut extent into whole blocks, thenvkCmdCopyBufferToImagewith the destination's. The box fits the source's padded mip, so the scratch holds every block the destination reads). Each range and buffer bound is checked before anything is written. A copy runs inTRANSFER_SRC/TRANSFER_DST, or in place inGENERALwhen the texture is inCOMMON: that is D3D12's implicit promotion to a copy state. A same-subresourceCopyTextureRegionusesGENERALfor both sides; preparation rejects overlapping regions. Cross-formatCopyTextureRegionfrom an uncompressed texture into a partial BC edge block also uses transfer scratch. Each source texel supplies one block, and the destination's write extent stops at the actual mip edge. A 3D mip is one subresource. Boxed volume transfers preserve the full footprint's row and slice strides. Whole-resource depth/stencil copies issue onevkCmdCopyImageper aspect, with a transfer write-to-read/write dependency between them; all mips and layers stay batched within each aspect. This avoids stencil corruption observed on RX 5700 XT, Windows driver 32.0.21045.5002, when both aspects share one multi-region copy command. A standalone synthetic Vulkan multi-mip array reproduces the corruption with validation clean; this is a conservative compatibility measure, not evidence that the Vulkan specification requires this dependency.d3d12_stencil_copy_testchecks D24S8/D32S8 across mip/layer counts and odd dimensions against WARP (CTest) orLEONIDA_HOST_ADAPTER(manual runs), plus the deterministic upload pattern for both planes and sources. Depth ↔ colour copies (CopyResource/CopyTextureRegionbetweenD32_FLOATandR32_FLOAT/UINT/SINT, orD16_UNORMandR16_FLOAT/UNORM, single-sampled, single-plane depth) copy the bits as the PC runtime does.vkCmdCopyImagerefuses mismatched aspects, so each region goes image → scratch buffer → image (src/vulkan_scratch.h: device-local chunks kept until the submission completes, on every GPU). Not covered: depth with stencil (two planes), a D24 stored as D32, and multisampled textures; they are still refused. A float written into aD32_SFLOATimage outside [0, 1] is undefined in Vulkan withoutVK_EXT_depth_range_unrestricted, where D3D12 keeps the bits;d3d12_copy_xfmt_testuses values in [0, 1). D24_UNORM_S8_UINT without a native D24 (the Radeon 880M, AMD hardware generally, RADV): the layer storesD32_SFLOAT_S8_UINTand makes it behave as D24 (src/depth24.h,src/vulkan_depth24.h). A footprint of the depth plane holds 24-bit UNORM words (bits 0-23; the top byte is unspecified, the PC runtime reads it as nothing and writes 0), the stencil plane is plain bytes. An upload converts the words with a compute pass (src/depth24_convert.comp, integer arithmetic) into a scratch buffer of floats, the nearest float tod / 16777215, whichvkCmdCopyBufferToImagethen moves into the image; a readback copies the image into the scratch and the pass writes the words (a float is multiplied by 16777215 in float and rounded to nearest, ties to even, which is what WARP and AMD's D3D12 driver do; NaN and negatives are 0, 1 and above the maximum). Every 24-bit word makes the round trip unchanged (checked on all 16777216 bydepth24_convert_test). Texture to texture copies move the floats as they are.ClearDepthStencilViewof any D24 texture, native or stored as D32, clears with the float of the quantised value (an exact 24-bit value, so no driver tie rounding is left), so the texture reads back as D3D's quantisation of the clear value. The scratch buffers and descriptors live until the submission that used them completes. A copy larger than the device'smaxStorageBufferRange(128 MiB at least) is split into several dispatches, by slices or by rows of one slice. The dispatch runs even under aSetPredicationthat would skip copies: the layer runs copies unpredicated (section 4.7) and the conversion must go with them, so conditional rendering is ended around it. The D3D11.3 functional spec (3.2.3.6, FLOAT to UNORM) says: NaN is 0, the value is clamped to 0..1, multiplied by 2^n - 1 in float, 0.5 is added and the fraction dropped, with a tolerance of 0.6 ULP on the integer side; read literally a tie rounds up, and 3.2.2 lists this conversion as an exception to round-to-nearest-even without fixing ties. WARP and AMD's D3D12 driver were measured to round the float product to nearest even (2.5 gives 2, 0.5 gives 0), which the tolerance allows; NVIDIA's D3D12 driver (and a native D24 clear in its Vulkan driver) breaks some of those ties the other way; the layer follows WARP and AMD there, a measurement and not a rule of the spec. Draws (D3D-309,src/depth24_fragment.h): a single-sampled graphics pipeline with depth enabled and a D24 DSV stored as D32 has its pixel stage writeFragDepth = quantise(z + bias), with D3D's bias in D24 units (DepthBias / (2^24 - 1) + SlopeScaledDepthBias * max(|dz/dx|, |dz/dy|), clamped byDepthBiasClamp) and the same quantisation asdepth24_convert.comp, so depth tests and stored depth match D24; the rasteriser's bias is off for these pipelines (so a clamp needs nodepthBiasClampthere). A pipeline without a pixel shader, with or without a geometry shader, gets a built-in one; a shader that writes its own depth has it quantised, unbiased, as in D3D. The slope comes from the derivatives of the interpolated depth, so a slope-scaled bias can land up to two 24-bit steps from D24 hardware's plane-exact one (d3d12_depth24_draw_test). Not covered: multisampled targets (aFragDepthwrite is per pixel; they keep float bias and precision, logged), pixel shaders withEarlyFragmentTests(which ignore aFragDepthwrite; logged), a viewport depth range narrower than the biased depth (D3D clamps before quantising), and early depth testing, which aFragDepthwrite turns off for these pipelines. A depth texture sampled in a shader still sees the float.ResolveSubresourcebecomesvkCmdResolveImagein the same layouts as a copy: a multisampled colour subresource into a single-sampled one of the same size and format. Integer colour formats in the requested format or either resource are refused at recording;Closefails.ResolveSubresourceRegionuses the same Vulkan operation for non-integer colour with average mode, taking a source rectangle (or the entire subresource) and a destination offset. AResolveSubresourceRegionof one depth or stencil plane (the subresource's plane slice, the same on both sides) runs in a rendering scope of its own with no draws: the multisampled plane is the depth or stencil attachment (loadLOAD, storeNONE), the destination its resolve target with the mode, the render area the source rectangle. Both move from their resolve layouts toDEPTH_STENCIL_ATTACHMENT_OPTIMALand back around it; the destination's other plane is not attached and keeps its contents. A rectangle smaller than the subresource has the texels around it copied into a scratch buffer before the scope and back after it, on every GPU: Vulkan resolves only inside the render area, but MoltenVK (1.4.2 and 1.4.3, Apple M3 Max) resolves the whole destination subresource, because it resolves through Metal's store action, which has no render area. Measured with a raw Vulkan program (a 4x D32 attachment, render area (2,1) 5x4 of 8x6,MIN,MAXandSAMPLE_ZERO, storeNONEorSTORE): MoltenVK writes all 48 destination texels, KosmicKrisp only the 20 inside. No device property reports it, so nothing is gated. The format is the depth format or the plane's own (R32_FLOAT,R24_UNORM_X8_TYPELESS,X24_TYPELESS_G8_UINT, and for D32S8R32_FLOAT_X8X24_TYPELESSandX32_TYPELESS_G8X24_UINT; all compared with the PC runtime, TEST-847). A depth-only source above array layer 0 is resolved in aVkRenderPasswith a framebuffer of the same two views instead of the rendering scope, on every GPU (D3D-417, a driver workaround): AMD's Windows driver (32.0.21042.62, Ryzen 7 9700X iGPU) resolves a dynamic-rendering depth attachment from layer 0 of the image when the multisampled view starts at another layer, while it honours the resolve view's first layer. Measured with a raw Vulkan program on a 4x D32 image of four layers: a layer range cleared withvkCmdClearDepthStencilImage, aCLEARload orvkCmdClearAttachmentsreads back right through atexelFetchof every sample, through a resolve of all four layers in one scope and through a copy of the layer into a one-layer image that is then resolved, but a one-layer view resolved in a rendering scope gives layer 0 for every layer (view type2Dor2D_ARRAY, storeNONEorSTORE), and views of layers 1-3 resolved in one scope give layers 0-2. The render pass gives the right layer there; an RTX 3070 (610.74) does in every variant.d3d12_view_slices_testreads a 4x D32 array back slice by slice. A depth-stencil source above layer 0 still uses the rendering scope, because its two planes can be in different layouts, which the render pass's attachment description cannot say without the planes' layouts at recording; a 4x D24S8 or D32S8 array is still read back as its slice 0 on that driver (measured). The format is the depth format or the plane's own (R32_FLOAT,R24_UNORM_X8_TYPELESS,X24_TYPELESS_G8_UINT, and the D32S8 pair, untested). What the PC runtime accepts was measured on an RTX 5070 (driver 621.24) and on WARP:MINandMAXof either plane by either format, andAVERAGEof the depth plane by its own format only (itsClosefails forAVERAGEby the depth format or of stencil); the layer accepts the same. WARP is no reference for two of them: a resolve with the formatD32_FLOATpasses itsClosebut removes the device when run (DXGI_ERROR_DRIVER_INTERNAL_ERROR), and a one-plane D24S8 resolve writes both planes; the RTX 5070 resolves only the plane named. A scope resolves each pixel in place, so a destination offset other than the source rectangle's corner is refused, as is a mode missing from the device'ssupportedDepthResolveModes/supportedStencilResolveModes(queried at device creation; one plane per scope, soindependentResolvenever applies). Refused calls failCloseand record nothing.d3d12_depth_resolve_testcompares D32, D24S8 and D32S8 resolves (typed and typeless resources, whole and rectangle) with the PC runtime and WARP. Its edge cases (TEST-848) draw a triangle over the cleared 4x source first (depth 0.5, stencil 0x44): the pixels on its diagonal edge hold differing samples, and MIN, MAX and AVERAGE over them match the PC runtime on an RTX 5070 (driver 621.01) and WARP byte for byte.DECOMPRESS,ResolveSubresourceof depth (which D3D12 does not offer) and resolves between two formats of one typeless family remain open. A multisampled texture copies only to one with the same sample count and has no footprint. Discards, immediate writes and atomic copies replay as section 4.2 describes. -
UAV clears (
ClearUnorderedAccessViewUint/ClearUnorderedAccessViewFloat). The CPU handle's slot is read while recording as the GFX10 descriptor a shader would load (section 3.4), so the clear works with any view-creation code that writes them and with descriptors the game builds itself; the GPU handle is not needed. A T# gives the view's format (FORMAT plus DST_SEL, which tells BGRA from RGBA), mip and layers. A tagged 3D UAV selectsFirstWSliceandWSize. An untagged 3D T# covers every slice of the bound resource's selected mip. A V# gives a byte range: its address minus the resource'sGetGPUVirtualAddress, and NUM_RECORDS bytes (stride 0, no format: raw), records (a stride: structured) or elements (a format: typed). A view that reaches past the end of the buffer stops there, as the hardware's bounds check would.- Values follow D3D's rules (
runtime/src/uav_clear.h): Uint copies the low bits of each value into its channel with no conversion, whatever the format's type; Float converts (UNORM/SNORM clamp and round to nearest, NaN is 0; 16-bit and the packed 11/10-bit floats round toward zero, a finite value too large becoming the largest finite). A raw or structured view takes value 0 for every 32-bit word (Float: its bits). D3D11 calls Float on an integer view invalid and D3D12 does not say; here the value is converted (toward zero, clamped, NaN 0) so the result is defined. These are checked against hand-computed elements ind3d12_uav_clear_test. - Buffers: elements of up to 4 bytes repeat in every aligned word, so
vkCmdFillBufferwrites the aligned middle andvkCmdCopyBuffercopies the unaligned ends from it (an 8-bit view at an odd offset, say). 8- and 16-byte elements are written withvkCmdUpdateBuffer(up to 64 KiB) and doubled with copies. A rectangle is an element range[left, right)on row 0. If a range contains no complete aligned word, prepare reserves eight transfer-scratch bytes, retained until submission completion. Replay fills that scratch with the repeated element and copies only the requested bytes, preserving neighbouring bytes even at resource boundaries. Rectangles within one clear reuse that pattern with transfer dependencies between them. Ownerless replay callers withoutcopy_scratchstill refuse these short ranges before emitting anything.d3d12_short_uav_clear_testcompares Uint/Float whole-view and clipped/overlapping rectangle clears against WARP (CTest) orLEONIDA_HOST_ADAPTER(manual runs), checking the entire buffer against literal patterns. Portable native comparisons keep rectangles on row 0. Out-of-row controls run separately against WARP: NVIDIA D3D12 was observed to ignore Y where WARP and AMD preserve the buffer, so those controls do not assert that native drivers behave uniformly. This test distinction does not change the replay policy. Portable UNORM Float clears use0.25f(R8:0x40, R16:0x4000), away from a conversion midpoint;0.5fremains covered by separate WARP-only midpoint controls. Native NVIDIA was observed to clear that midpoint to0x7f/0x7fffwhere WARP and AMD give0x80/0x8000. All comparisons remain byte-exact. - Textures: the values become one element of the view's format, and that element is cleared into the image as
the value that decodes it in the image's own format, so a typeless texture viewed as UINT gets exactly the bits
asked for. Exact for every typed-UAV format except the SNORM pattern
0x80..(Vulkan writes -1.0 as0x81..) and NaN payloads on the Vulkan color-clear paths. A whole, matching-format 3D mip usesvkCmdClearColorImage. Direct lists can usevkCmdClearAttachmentsfor rectangles on attachment-capable 1D/2D images. Unpredicated partial 3D W ranges (FirstWSlice/WSize) and 3D XY rectangles use the same transfer path on direct and compute lists. It encodes the clear value in the view format, fills up to 64 KiB of scratch, and copies tiles one Z slice at a time inGENERAL. This requires matching view and backing formats, with the existing exception for emulatedR9G9B9E5onR32_UINT. - The clear is fenced as the UAV state widened to transfers, so a following UAV barrier, transition, or enhanced
barrier from
SYNC_CLEAR_UNORDERED_ACCESS_VIEWsees it. - Under
SetPredication, a direct list clears an attachment-capable 1D/2D UAV through its attachment view. A whole view becomes one rectangle so conditional rendering applies. Buffer clears and the direct-list whole-mip transfer fallback run unconditionally and count towardunpredicated_copies. Direct and compute lists refuse predicated partial-W or rectangular 3D clears before submission.
- Values follow D3D's rules (
-
Layout tracking (
LayoutTracker): the current Vulkan layout of every image subresource, so barriers start from the real layout instead of the application'sbefore. This is how implicit promotion and decay work: a texture inCOMMONsits inGENERAL, which every promotable access can use, so a later barrier naming the promoted state still starts fromGENERAL, and decay changes no layout. Buffers have no layout, and simultaneous-access textures stay inGENERALfor life. WithseparateDepthStencilLayoutsthe depth and stencil planes are tracked apart, so a depth-only clear or a one-plane transition leaves the other plane where it is. -
Execution (
runtime/src/vulkan_backend.h):VulkanContext(registered resources, the tracker, a view cache),VulkanQueue(ExecuteCommandListsprepares every list before writing any, so a bad list submits nothing and leaves the tracker as it was;Signal;Wait, which is attached to the next submission because a Vulkan wait only holds back its own batch) andVulkanFence(a timeline semaphore). -
COM (
runtime/shims/d3d12_com.cpp):ID3D12GraphicsCommandList8(the GCL7 chain plusOMSetFrontAndBackStencilRef),ID3D12CommandQueue,ID3D12CommandAllocatorandID3D12Fence1(withSetEventOnCompletionevents). Every method they do not implement is a stub generated at build time from the SDK'sd3d12.hbytools/gen_d3d12_stubs.py. The stub reports its name once, so the vtables follow the SDK order exactly and nothing derived from the SDK is checked in. Unknown IIDs are logged and refused. Resources are identified by theirID3D12Resourcepointer, and RTV/DSV CPU handles point at aTargetView.OMSetFrontAndBackStencilRefrecords its twoUINTs on the list (andResetclears them); each draw sets them withvkCmdSetStencilReferenceand a face mask. -
Device (
runtime/shims/d3d12_vulkan_device.cpp): anID3D12Device11(PC ABI, 80 slots) that the Xbox-ABI proxy (d3d12_xs_device.cpp) forwards to, so slot 14's heap-handle conversion and slot 76's resource creation work unchanged. It creates the objects above, plus:- descriptor heaps whose slots are 32 bytes (
GetDescriptorHandleIncrementSize). The game asks the device for the increment and derives heap sizes and handle strides from the answer (measured, section 3.4), so the shim returns its own host slot size. RTV/DSV slots hold aTargetView; shader-visible heaps return a GPU handle, but nothing reads it yet; CreateRenderTargetView/CreateDepthStencilViewfor whole resources,TEXTURE1D,TEXTURE1DARRAY(D3D-63),TEXTURE2D,TEXTURE2DMS,TEXTURE2DARRAYandTEXTURE2DMSARRAY(a slice range;ArraySize-1 is every slice from the first on, as on the host,d3d12_view_slices_test);CopyDescriptors/CopyDescriptorsSimple. A descriptor is the bytes of its slot, so a copy is a byte copy: the destination and source range lists are walked together, one descriptor at a time, and null size arrays mean one descriptor per range;- committed buffers (upload and readback heaps mapped persistently and zeroed), 1D textures and 1D arrays (render
targets and depth-stencils too: their attachment views are
VK_IMAGE_VIEW_TYPE_1D_ARRAY), and 2D textures in the common render-target, depth and texture formats (typeless families become mutable-format images;R24G8_TYPELESSandR32G8X24_TYPELESSare depth-stencil images with or withoutALLOW_DEPTH_STENCIL, as Vulkan has no colour format with their layout), plus non-attachment 3D textures with mipmapped upload, image copy and readback, and multisampled 2D textures (single-mip render targets or depth-stencils, in the sample counts the GPU has for the format); - packed
R9G9B9E5_SHAREDEXPtextures map toVK_FORMAT_E5B9G9R9_UFLOAT_PACK32for uploads and sampled views. WhenALLOW_UNORDERED_ACCESSis requested on a GPU whoseVK_FORMAT_E5B9G9R9_UFLOAT_PACK32lacks nativeSTORAGE_IMAGEsupport (for example NVIDIA), the layer backs the texture with a mutableVK_FORMAT_R32_UINTimage (MUTABLE_FORMAT | EXTENDED_USAGE+VkImageFormatListCreateInfo{R32_UINT, E5B9G9R9_UFLOAT_PACK32}), refusingALLOW_RENDER_TARGET,ALLOW_DEPTH_STENCILandDENY_SHADER_RESOURCE:CheckFeatureSupportadvertisesTYPED_UNORDERED_ACCESS_VIEWandUAV_TYPED_STORE(plusUAV_TYPED_LOADwithR32_UINTstorage atomics) while keepingRENDER_TARGEToff; SRV and UAV descriptors emit theE5B9G9R9T# (FORMAT 132, RGB1) and reject incompatible casts, while set 0 creates aVK_IMAGE_USAGE_SAMPLED_BITE5B9G9R9sampled view and aVK_IMAGE_USAGE_STORAGE_BITR32_UINTstorage view (bound inas_uint/r32ui, neveras_float);ClearUnorderedAccessViewFloatpacks RGB9E5 with round-half-up (clamping negative/NaN to 0 and +Inf/overflow to 65408, bumping on 512) andClearUnorderedAccessViewUintwrites 0, matching WARP (d3d12_r9g9b9e5_uav_test,d3d12_uav_clear_test); - the descriptor shader samples
B5G5R5A1_UNORMthrough a 2D SRV. Opaque and transparent red check bit 15, and mixed-channel texels check the five-bit color fields; B5G5R5A1_UNORMwithALLOW_UNORDERED_ACCESSon a GPU whoseVK_FORMAT_A1R5G5B5_UNORM_PACK16lacksSTORAGE_IMAGE(for example NVIDIA) is backed the same way, by a mutableVK_FORMAT_R16_UINTimage with{R16_UINT, A1R5G5B5_UNORM_PACK16}in its format list (Format::uint_backed). UnlikeR9G9B9E5, render targets are kept: RTVs and clears go through anA1R5G5B5attachment view, SRVs through anA1R5G5B5sampled view, and the UAV's storage view isR16_UINTinas_uint. SRV and UAV descriptors name the texture's own T# format (1_5_5_5_UNORM, 134), so a shader store needs the translator to pack the 5-5-5-1 bits for that view; until it does,CheckFeatureSupportdoes not advertise the typed UAV. Multisampled UAV textures are still refused (d3d12_b5g5r5a1_uav_test);R8G8B8A8_UNORM_SRGBandB8G8R8A8_UNORM_SRGBwithALLOW_UNORDERED_ACCESS, which the host runtime sizes and creates (RTX 4090 and WARP) and a retail title sizes as a 2048x2048, 12-mip render target, on a GPU whose sRGB format lacksSTORAGE_IMAGE(most): a mutable image of the UNORM format of the same order, with both formats in its format list (Format::uint_backed). Its storage view is UNORM, as every D3D12 typed UAV of these textures is, so shaders andClearUnorderedAccessViewFloatwrite raw bytes; RTVs and SRVs are sRGB, so clears and rendering encode and sampling decodes. BGRA8 needsB8G8R8A8_UNORMstorage. Both clears match WARP byte for byte; multisampled ones are still refused (d3d12_srgb_uav_test);B8G8R8X8_UNORM,_UNORM_SRGBand_TYPELESS(D3D-87) areB8G8R8A8images: clears, copies and footprints keep all four bytes (WARP writes the clear's alpha into the X byte too), and shader views read alpha as 1. Its typeless family is its own, so views to or fromB8G8R8A8are refused, unless the texture's castable-format list names the view's format (relaxed casting, which WARP and AMD's D3D12 driver accept both ways). The view's format then decides the alpha: aB8G8R8X8view of aB8G8R8A8texture reads 1, aB8G8R8A8view of aB8G8R8X8one the stored byte. It decides the channel order too: anR8G8B8A8texture whose list namesB8G8R8A8orB8G8R8X8reads red and blue swapped through those views, as on the host (both orders share one T# format code, so the T#'s swizzle carries the order). An RTV in a format the list names stores clears and draws in the view's channel order and encoding, as on the host (see the castable-list RTVs under D3D-275 below). As on the host runtime, the family has no typed UAV, and a typedB8G8R8X8texture cannot allow unordered access (the host accepts one whose castable-format list namesB8G8R8A8; the layer doesn't yet). Blending into aB8G8R8X8render target reads destination alpha as 1, as WARP and AMD's D3D12 driver do: the PSO turnsDEST_ALPHAintoONE,INV_DEST_ALPHAintoZEROand the colourSRC_ALPHA_SATintoZERO, where the BGRA8 image would read the X byte. What a draw leaves in the X byte is not defined (WARP writes 0, AMD the blended alpha), and no view reads it;R10G10B10_XR_BIAS_A2_UNORMmaps toVK_FORMAT_A2B10G10R10_UNORM_PACK32, the same packed 10:10:10:2 layout; the bias and scale are the application's shader work. Like the PC runtime, it accepts only a single-mip, single-sample 2D texture: extra mips, multisampling and 3D are refused in creation, allocation and footprints. Format support reportsTEXTURE2DandCAST_WITHIN_BIT_LAYOUT, not the host's display, back-buffer-cast or video-processor bits;CheckFeatureSupportfor feature levels (up to 12_1), architecture, D3D12 options (OPTIONS,OPTIONS1–5,7–9,11–21), GPU virtual-address support, format support, format plane counts, multisample quality levels, shader model, root signature version, predication (VK_EXT_conditional_rendering), command-queue priority support, protected-resource session queries, shader cache, existing heaps, serialization, cross-node sharing, displayable resources, meta-command queries (E_INVALIDARG), application-specific driver state, and bytecode bypass hash support.D3D12_OPTIONS8reports unaligned block textures when the Vulkan logical device enables BC texture compression, andD3D12_OPTIONS12reportsRelaxedFormatCastingSupported = TRUE, so a committed or placed texture accepts a castable-format list. Other queries (includingOPTIONS6andOPTIONS10) are logged and refused until the trace shows what the game asks (question 11);- Single-sampled
A8_UNORM1D, 2D and 3D textures use one byte per texel inVK_FORMAT_R8_UNORM. Their SRVs expose (0, 0, 0, A) before applying the caller's component mapping. Format support includesMIPwhen the Vulkan image supports multiple levels. Where the GPU hasVK_FORMAT_A8_UNORM_KHR(VK_KHR_maintenance5) and can sample, copy and blend it as a colour attachment, a texture created withALLOW_RENDER_TARGETis stored in that format instead: its RTVs, PSORTVFormatsand clears use the alpha channel, its SRVs view it in the same format (the T# names its one channel X, gfx10'schannels_a), and format support addsRENDER_TARGETandBLENDABLE. Vulkan puts A8 in a compatibility class of its own, so the two kinds of A8 texture cannot share an image, andvkCmdCopyImagerefuses a copy between them (VUID-vkCmdCopyImage-srcImage-01548):CopyResourceandCopyTextureRegionbetween the two go image → transfer scratch → image, as depth ↔ colour copies do, one byte per texel (d3d12_a8_copy_test). A castable-format list namingA8_UNORMitself is a no-op; any other format in it is refused withE_INVALIDARGfor such a render target, since no other format can view its image. Without that format, render targets are refused as before; depth-stencil and UAV creation are unsupported for this format. - A
CopyTextureRegionof the depth plane between two depth formats with the same depth encoding but not the sameVkFormat(D32_SFLOAT_S8_UINTandD32_SFLOAT,D16_UNORM_S8_UINTandD16_UNORM,D24_UNORM_S8_UINTandX8_D24_UNORM_PACK32) goes image → transfer scratch → image too, depth aspect on both sides (vulkan_replay.h,depth_format_pair;replay_copy_offset_test).vkCmdCopyImagerequires depth/stencil formats to match exactly (VUID-vkCmdCopyImage-srcImage-01548), and an NVIDIA driver (RTX 4070 Laptop, 621.40) handed theD32_SFLOAT_S8_UINT→D32_SFLOATpair wrote past the end of theD32_SFLOATimage: the world-startWRITE_INVALIDdevice loss, with the fault at the first byte after the image. - reserved resources and
GetResourceTiling(section 4.2); - query heaps for occlusion, timestamps and pipeline statistics, and
GetTimestampFrequencyon the queue (section 4.6); GetCopyableFootprintsfor buffers, 1D and 1D-array textures, 2D textures and volumes, including BC1–7 and the two-plane depth-stencil formats. The test compares every output with the PC runtime's; that comparison found that planar depth-stencil rows are padded to 512 bytes, not 256, and that subresources are aligned to 512 bytes counting fromBaseOffset, not from 0: the PC runtime moves the whole layout by the base, so an unaligned base (513, 2^32 + 1) keeps the same relative offsets and the same total (measured on an AMD Radeon RX 7600, drivers 26.11.1 and 26.11.2, Windows 10 in-box runtime; aligning from 0 gives mismatching offsets and totals at both unaligned bases and none at 0 and 1024, which is why it went unnoticed).- the
1/2/3variants as wrappers over the methods above (D3D-28):CreateCommittedResource1/2/3,CreateCommandQueue1andGetCopyableFootprints1.D3D12_RESOURCE_DESC1drops toD3D12_RESOURCE_DESC, and the initial state orD3D12_BARRIER_LAYOUTis not used, because new textures startUNDEFINEDand move on first use. The newer arguments are answered as the PC runtime answers them.d3d12_method_variants_testcompares each answer below with the host runtime live, measured on an RTX 4090 (driver 621.14): CreateCommandSignatureandExecuteIndirect: a signature consisting of a single DRAW or DRAW_INDEXED operation inherits the graphics state of its command list. The Vulkan replay snapshots the same pipeline, root data, render targets, IA bindings and raster state as a direct draw, then reads the records on the GPU inside that draw's rendering scope. A padded stride is supported; it is not evidence that a signature is simple. A compound graphics signature still emits no draw, but its written VB/IB and root bindings are reset for the next command, even if no record is interpreted. Untouched slots and previously recorded draws retain their state. See the D3D12 state-leakage contract. Fixed- and GPU-counted batches use the device's enabled indirect features and limits. The current graphics path covers triangle lists on direct command lists. A bundle can defer a single operation with no count buffer: its argument-buffer identity and byte offset are recorded once; eachExecuteBundlecaptures the direct parent's state at that call. Count buffers and compound signatures remain invalid in bundles.d3d12_bundle_indirect_warpandd3d12_bundle_indirect_layercompare DRAW and DRAW_INDEXED against direct pixels with two different parent bindings; the layer fixture also checks marker order and captured views.d3d12_bundle_indirect_dispatchchecks DISPATCH the same way against the counters WARP and the default adapter write (bundle section above). Compound graphics signatures, non-unit instance divisors and unsupported capabilities stay guarded. A GPU-counted draw currently requiresmaxDrawIndirectCount == UINT32_MAX: Vulkan also limits the raw counter value, not just the caller's maximum. To omit indirect graphics without changing direct drawing or compute, setLEONIDA_INDIRECT_DRAWS=offbefore starting the process. This applies to the Vulkan-backed D3D12 command list, including ordinary bundle draws when replayed on a parent. Validation and compound root/IA resets still happen. Only exact lowercaseoffdisables drawing; unset, empty, and other values (including the oldrawspelling) retain the normal capability-checked path. There is no bare draw mode. The formerrawsetting logs an obsolescence notice on first policy use. Each skip reason logs once. Progress lines give cumulative recorded commands, Vulkan emissions, recording skips and replay skips. Replaying a command list can emit a recorded command more than once. By default, a GPU pass bounds draw vertex/index and instance counts, dispatch group counts, and total work across each command list (2^27 units). Unfilled all-ones records produce zero work and spend no budget. Cumulative observed clamp and zero counts are reported every 60 presented frames. Counted calls read at most MaxCommandCount records. The stateful draw or dispatch reads private scratch. Exhausting the diagnostic counter slots only disables readback of those counters.LEONIDA_INDIRECT_CLAMP=0disables this pass.LEONIDA_INDIRECT_GROUP_BUDGET=Nfurther bounds each indirect dispatch, preserving X first, then Y and Z (1–65535 groups). It also works with the clamp disabled.- Optional
VK_KHR_acceleration_structure+VK_KHR_deferred_host_operations+VK_KHR_ray_query:ID3D12Device5::GetRaytracingAccelerationStructurePrebuildInfo,ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure(BLAS + TLAS),vkGetBufferDeviceAddressinID3D12Resource::GetGPUVirtualAddress(), and RT-awareUAVbarriers (cleanly disabled/skipped on GPUs without RT).
- descriptor heaps whose slots are 32 bytes (
-
DXGI Swapchain (
runtime/shims/dxgi_swapchain.h,runtime/shims/dxgi_com.{h,cpp}):IDXGIFactory4andIDXGISwapChain3overVK_KHR_win32_surface+VkSwapchainKHR, exposed viart::d3d12::create_dxgi_factory. Swapchain backbuffers are realID3D12ResourceCOM objects (BackBufferResourceinheriting fromID3D12ResourceStubs) registered directly withVulkanContext, supportingCreateSwapChainForHwnd,GetCurrentBackBufferIndex,GetBuffer,CreateRenderTargetView,Present, andResizeBuffers(preserving explicit buffer dimensions even when the HWND client size is unchanged via an offscreen backbuffer + blit path, and exposing exactly the requestedBufferCounteven when Vulkan's native image count differs, in which case the offscreen ring is the app-visible swapchain and each present blits the current slot into the acquired image). The factory answers up toIDXGIFactory7(D3D-2).EnumAdapterByGpuPreferencereturns the one Vulkan adapter at index 0 for every preference. It accepts a preference outside the enum, as the host does, and givesDXGI_ERROR_INVALID_CALLfor a nulloutandDXGI_ERROR_NOT_FOUNDpast the end. The adapter list never changes, soRegisterAdaptersChangedEventnever signals its event. It still gives the host's answers: a null event or cookie, or an event that is already registered, isDXGI_ERROR_INVALID_CALL. Cookies start at 1 and are separate from the occlusion cookies, and an unknown cookie isDXGI_ERROR_NOT_FOUND. All of these were measured on the host'sdxgi.dll(Windows 11, RTX 3070) and are checked indxgi_swapchain_test. explicit buffer dimensions even when the HWND client size is unchanged via an offscreen backbuffer + blit path, and exposing exactly the requestedBufferCounteven when Vulkan's native image count differs, in which case the offscreen ring is the app-visible swapchain and each present blits the current slot into the acquired image).Argument Answer a protected resource session E_INVALIDARG; the layer reports noD3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORTSamplerFeedbackMipRegionon a textureE_INVALIDARGfromCreateCommittedResource2/3;GetCopyableFootprints1returns its failure answer (every output all ones)SamplerFeedbackMipRegionon a bufferignored a buffer's initial layout other than UNDEFINEDE_INVALIDARGa castable-format count with a null list no list ( S_OK)a castable-format list accepted on a texture when the formats map to Vulkan formats: the image is mutable and carries a VkImageFormatListCreateInfo; a buffer or an unmapped format isE_INVALIDARG. A cast whose texel size differs from the resource's is alsoE_INVALIDARG— the host refuses other sizes, and a size-mismatched format list is a Vulkan validation error (VUID-VkImageCreateInfo-pNext-06722). The list is kept on the resource, so an SRV whose format is neither the resource format nor in the list leaves a null descriptor. The resource's own format is always accepted and is added to the Vulkan format list when the D3D12 list omits it. A listed same-size cross-family cast, such asR8G8B8A8_UINTtoR32_UINT, is accepted. An RTV in a listed RGBA8 family format on a typedR8G8B8A8_UNORMtexture clears through the cast, the same reinterpretation a typeless RTV uses; without a list a typed resource still refuses a different-format RTV.D3D12_OPTIONS12reportsRelaxedFormatCastingSupported = TRUE(this layer requires Vulkan 1.3, where the format list is core).CreatePlacedResource2's list reaches its placed image through the same rules (D3D-90)CreateCommandQueue1's creator IDignored CreatePlacedResource1/2wrap the placed path above;2carries the castable-format list.CreateHeap1remains a stub.-
CreateSampler2as a wrapper overCreateSampler(D3D-28, part 2). Without flags it writes the same S#.D3D12_SAMPLER_FLAG_UINT_BORDER_COLORreads the union as integers.(0,0,0,0),(0,0,0,1)and(1,1,1,1)take the S#'s transparent-black, opaque-black and opaque-white types. The S# has no separate integer types, since the hardware reads them by the image's format. Vulkan does not: an integer image sampled with aVK_BORDER_COLOR_FLOAT_*border reads 0. Vonsek found this on an RTX 5080 (#538), andd3d12_descriptor_testreproduces it on an RTX 4090 when the layer uses the float enums. So the layer marks an integer border in the S# withBORDER_COLOR_PTR = 0x800(gfx10::kIntegerBorderPtr). The hardware reads that pointer only for a table colour, and Mesa writes it only forSQ_TEX_BORDER_COLOR_REGISTER. The mark gives the integer border its own key in the descriptor hash table, so it does not share the float border'sVkSampler, andvulkan_samplermakes itVK_BORDER_COLOR_INT_*. Any other colour is a table colour (BorderColor::table). WithVK_EXT_custom_border_color(D3D-73), the layer registers custom float and UINT border colours in a device-wide table of up to 4000 entries; the table index is stored inBORDER_COLOR_PTR [11:0]of the S#, so distinct custom colours produce distinct keys in the descriptor hash table and distinctVkSamplerobjects. On sampler creation,VkSamplerCustomBorderColorCreateInfoEXTpasses the colour components withVK_BORDER_COLOR_FLOAT_CUSTOM_EXTorVK_BORDER_COLOR_INT_CUSTOM_EXTandformat = VK_FORMAT_UNDEFINED(viacustomBorderColorWithoutFormat). Without the extension, custom colours fall back to transparent black with a diagnostic log line, usingVK_BORDER_COLOR_INT_TRANSPARENT_BLACKfor integer borders andVK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACKfor float borders to satisfy Vulkan input validation rules on integer views. An integer border colour with the bits of1.0fis not white and receives a table colour index.D3D12_SAMPLER_FLAG_NON_NORMALIZED_COORDINATESsetsFORCE_UNNORMALIZED(word 0, bit 15) and changes nothing else;vulkan_samplermakes itunnormalizedCoordinates. The layer answersD3D12_OPTIONS17withNonNormalizedCoordinateSamplersSupported(core Vulkan, with the same restrictions) and noManualWriteTrackingResourceSupported. That is what the RTX 4090 and WARP report. The runtime on a Radeon 680M (D3D12 driver 31.0.14084.6002) reports no non-normalized samplers, and leaves every non-normalized description unwritten, including those the table below says are written.A description the PC runtime refuses leaves the slot as it was. The runtime itself does this, without the debug layer, on the RTX 4090 (driver 621.14) and on WARP; the debug layer's message names the rule.
d3d12_sampler2_testcompares each row with the host runtime live:CreateSampler2inputAnswer a null description the slot is left as it was a flag other than the two the slot is left as it was non-normalized, with MIN ≠ MAG, a linear MIP filter, anisotropy or comparison the slot is left as it was; MINIMUM/MAXIMUMfilters are acceptednon-normalized, with AddressUorAddressVnotCLAMP/BORDERthe slot is left as it was; AddressWis free, as in Vulkannon-normalized, with MinLOD,MaxLODorMipLODBiasnot 0the slot is left as it was; -0is 0non-normalized, a point filter with MaxAnisotropyorComparisonFuncsetwritten; both are ignored (the debug layer warns about ComparisonFunc)both flags written
BC1–7 textures need
textureCompressionBC, which the device enables when the GPU has it, as it doesocclusionQueryPreciseandpipelineStatisticsQueryfor the query heaps. -
-
Presentation (
leonida::VulkanPresenterinruntime/src/vulkan_present.h, whichrt::d3d12::create_window_presentermakes for a device and a window). This is the part thePresentXfront end uses; which of DXGI orPresentXthe game uses is still open (question 6). It takes a back buffer, an ordinary texture in the D3D12PRESENTstate, and blits it to an acquiredVkSwapchainKHRimage, scaling when the window size differs. The blit goes on the sameVkQueueafter the application's work, so the frame contains everything submitted before the present. Details:- two frames in flight, and a present semaphore per swapchain image;
- FIFO when vsync is asked for, otherwise MAILBOX or IMMEDIATE; with
VK_KHR/EXT_swapchain_maintenance1the FIFO swapchain can also present one frame in IMMEDIATE or FIFO_RELAXED (present(..., tear), section 4.5); - the swapchain is recreated on resize or when the surface reports it out of date or suboptimal, and a minimised window skips presents;
- a back buffer that was never written is zero-filled like any other texture;
presented()counts the presents the engine took (VK_SUCCESSorVK_SUBOPTIMAL_KHR), not ones it reported out of date;- a recreation is published only when the swapchain, its images and every per-image semaphore exist. On a failure the partial objects are released and the next present tries again, so no image is acquired without its semaphore;
- if the blit's submission fails after an image was acquired, an empty batch takes the acquire semaphore and
signals the frame's fence, and the swapchain is recreated next time to get the image back. The next present
therefore does not wait forever on a fence nothing signals. If even that batch fails, or a fence wait or reset
fails, the presenter stops (
ok()is false) and its owner makes a new one. - for
PresentX(section 4.5): a source rectangle, a blank present, an sRGB swapchain format for an sRGB source, and an optional capture of each presented frame to host memory (whatxbox_present_testreads back).
The device needs
VK_KHR_swapchain(and the instance the surface extensions). The standalone device enables them when present.New textures are not touched at creation. They are tracked as
UNDEFINED, and the first command that uses a part of one zero-fills it (D3D12 committed resources start zeroed;CREATE_NOT_ZEROEDskips this) and moves it to the layout that command expects, so creation needs no submission. Block-compressed textures are not zero-filled, because Vulkan cannot clear them; they start undefined until the application uploads them. Each submission ends with a barrier to the host, so a readback buffer holds the GPU's writes once the fence wait returns. Children hold a reference to the proxy, not the inner device, soGetDevicealways returns the Xbox-ABI object. Each live D3D12 queue leases a distinctVkQueuewhile one is free (its own type's family first, then the graphics family); the standalone device requests up to 16 per family. The queues still share a submit lock for replay state, but Wait-before-Signal between them can make progress (D3D-97), and a batch that waits for a Signal not yet submitted is held on the CPU so layouts follow dependency order (section 4.4). Caller-owned Vulkan devices can supply additional handles throughVulkanDeviceInfo::command_queues; without them they retain legacy single-queue behavior. When every handle is in use, the new D3D12 queue shares theVkQueuethat has the fewest D3D12 queues (section 4.4, "More D3D12 queues than Vulkan queues"); it used to fail withE_OUTOFMEMORY. Dedicated compute/transfer families would also require resource queue-family ownership handling and remain future work.
Descriptors and the bindless set (milestone M2, without the pipelines that will bind the set), from the shader's side inwards:
runtime/src/vulkan_bindless.h: set 0 includes the single-sample bindings the translator declares, optional multisample bindings, andDescriptorTable(runtime/src/descriptor_table.h, section 5.1) behind binding 2. One set for the device. The translator declares every array as a runtime array, so the counts are the runtime's choice. Details:-
The device sizes the arrays once, when it creates the set. It does not recreate the set, because pipeline layouts are built on
bindless_set_layout().bindless::size_bindingsreads the update-after-bind limits (maxPerStageDescriptorUpdateAfterBind*,maxDescriptorSetUpdateAfterBind*,maxPerStageUpdateAfterBindResources,maxUpdateAfterBindDescriptorsInAllPools), or the plain limits for a set without update-after-bind. It starts from the default counts below (4096 sampled 2D images, 1024 samplers, 1024 2D-array, 256 1D, 256 3D and 256 per storage array). Where a limit is lower, it clamps the sampler, storage and 2D arrays, in that order, and the device logs it. Next come the MS pairs that fit. Then it grows the arrays, in the same order, towards the maximums:- samplers: up to 4096, and at most
maxSamplerAllocationCountless 64 for samplers outside the set. That covers a full 2048-sampler D3D12 heap plus room for literal and static S#s. - 2D images: up to 65536.
- storage arrays: up to 4096 each, capped by their dimension's sampled array or by 256 for storage-only 1D arrays.
- 2D-array, 3D and 1D images: up to 65536 each, as many as 2D, grown together (one count for the three while the limits stop them short of it), so no dimension is favoured. A texture keeps an index for each distinct T# of it for as long as it lives, and which dimensions its textures have is the title's choice: a native boot filled the default 1024 2D-array and 256 1D indices during the story load, and world runs filled the 4096 1D indices of the sizes before this with 4092 T#s of 4090 live 1D textures. The bound is memory, not the device's limits (RADV allows 8388606 sampled images): every element of every array is in each generation's descriptor pool, used or not.
Growth leaves 64 descriptors of each limit to the other sets of a pipeline layout. It also stays within
maxPerSetDescriptors, which never shrinks the default counts, because a layout past it may still be supported: past it, the device grows only wherevkGetDescriptorSetLayoutSupportaccepts the grown layout. Intel's UHD 770 (101.7092) reports 6159 and accepts the full sizes, so it gets the same set as an RTX (D3D-219). MoltenVK (1.4.2 and 1.4.3 on an M3 Max) reports 1212 and accepts only layouts with fewer descriptors than that (MVKDevice::getDescriptorSetLayoutSupportcompares the sum with it), although it creates and samples a set of 65536 2D images and 4096 samplers correctly (a native repro, andd3d12_descriptor_testunder Wine with the set grown). So on MoltenVK the D3D12 device doesn't ask: the per-type update-after-bind limits, which MoltenVK takes from Metal's argument-buffer limits (500000 samplers on an M3 Max), decide alone, and the set grows as on other GPUs. Where a set still ends up short of a full 2048-sampler D3D12 heap, the device logs that at startup. Past the last free index,CreateShaderResourceViewandCreateSamplerlog once that the array is full, and a shader reads the fallback.d3d12_descriptor_testthen fills each short array to its last index and checks that the next view and sampler are refused. The MS arrays keep their default counts. On an RTX 5070 (driver 621.24, 1048576 of each type and 4000 samplers) the set has 65536 2D, 2D-array, 3D and 1D images each, 3936 samplers and 4096 storage indices in each dimension: 325729 descriptors with the MS pairs, 10-20 MiB at 32-64 bytes a descriptor. RADV (Mesa 26.3, the Raphael iGPU and the RX 7900 XTX) and llvmpipe get the same image counts and 4096 samplers. The device prints the counts it chose (bindless set:),bindless_sizing_testchecks the rules on synthetic limits, andvk_bindless_dimensions_testreads 5000 live 1D, 2D-array and 3D images each through their indices in a set sized from the device's own limits. - samplers: up to 4096, and at most
-
A T# the title writes into a console descriptor heap that set 0 has no room for is refused, and counted in the heap's
unbound T#s by reasonline, asthe bindless array of the T#'s dimension is full(orthe bindless storage arrays of the T#'s dimension are fullfor a UAV whose dimension has free indices only above the shorter storage arrays), not asno view for the T#'s format or range. The first such refusal of a dimension also logsa bindless image array is full; dimension N (name)with the indices, the T#s and textures that hold them and how many of those textures are still registered at their address (a texture's indices go back when it goes). -
An image view has one index in its dimension (2D, 2D array, 3D, 1D, 2DMS, 2DMS array or 1D array), shared by the bindings for that dimension. The runtime adds sampled-image bindings in pairs for 2DMS and 2DMS array: 20/21 for floating-point and normalized color, 22/23 for unsigned integers, and 24/25 for signed integers. The runtime enables pairs that fit the device's descriptor limits and have a multisampled zero fallback of the matching numeric class. A missed key reads zero at texel (0, 0), layer 0, sample 0. The 1D-array dimension uses storage bindings 26–28 and has no sampled binding.
-
The storage arrays are shorter (
BindlessSet::storage_capacity). Each array holds at most as many images as its dimension, and the 2D r32ui array is the same size as the other 2D storage arrays. So an image with a storage view gets an index the storage arrays hold, and a read-only one goes above where there is room. Index 0 is reserved, so 256 descriptors hold 255 live views in each 1D-array storage binding. -
Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss is index 0. It stands for a null descriptor (a zero T#, an empty heap slot, a view the layer refused) and is of the kind the instruction asks for: the translator picks the binding by the instruction's dimension (a cube reads the 2D-array binding) and the view by the T#'s class, so each dimension and class reads zeros. The storage arrays' fallbacks never share an image with the sampled ones, so a store or atomic through a null UAV cannot show in a later read through a null SRV. Where the device has
VK_EXT_robustness2'snullDescriptor(VulkanDeviceInfo::null_descriptor, enabled alone) they are null descriptors, and the store or atomic is dropped and a load reads zero, as on the console; without it they are 1x1 images of their own. A null V# (all zeros) needs no fallback: every access through it is out of range (NUM_RECORDS0), so loads give 0 and stores and atomics do nothing (tests/semantic/test_null_vsharp.py). Checked on the GPU byvk_null_descriptor_test(every dimension and class, both kinds of storage fallback). -
Changes are queued and written by
flush(), one write a slot, so a view that is removed before the next flush is never written. -
flush()also uploads the table to its buffer: device-local memory, written from a mapped staging copy when the buffers are created (first use or growth) and withvkCmdUpdateBufferfor slot changes. Adding a key only puts a new entry in an empty slot, and the copy of an entry is not atomic; a running lookup that does not know the key cannot resolve to it, which is accepted. Erasing a key empties its slot and moves no other entry (every lookup, CPU and shader, compares all eight probe slots and never stops at an empty one), so it is uploaded like an add. Replacing a live key's index, an insert that relocates a live entry, and a table that has grown (a new buffer behind binding 2) change what running lookups see:flush_replaces_table()says when a flush would do one of those, and the flush then makes a new generation instead of writing in place (D3D-314; see the paragraph on the flush at everyExecuteCommandLists, below). Erasing used to compact the probe cluster, which moved other keys and made every texture release wait for the whole GPU.
-
runtime/src/gfx10_descriptors.h: the T#, S# and V# structures (section 5.3), encoded and decoded, with their mapping to Vulkan formats, view types, component mappings and samplers. Field positions are Mesa's (src/amd/registers/gfx10-rsrc.json) and agree with what the translator and the GPU tests already use. Bits that only the console's driver could give a meaning (tiling, compression metadata, performance hints) are written as zero.- Device:
CreateShaderResourceViewandCreateUnorderedAccessViewof textures write a T# into the slot,CreateSampleran S#; each then makes sure set 0 has the view or sampler and the table has the key. Details:- The key is the descriptor's bytes, so a copied descriptor needs nothing more. An SRV and UAV with identical bytes can share an entry; a partial 3D UAV carries a W-range tag and remains separate from the unsliced SRV.
- A D3D12 comparison sampler with function NEVER and an ordinary sampler both encode zero in the hardware depth comparison field. The layer marks the NEVER comparison in S# word 3, bit 12 (unused with DERIV_ADJUST_EN clear) to give it a separate lookup key and a comparison-enabled Vulkan sampler.
- A view the layer cannot show (below) leaves a null descriptor, all zeros, which finds the fallback.
- A typed multisampled color texture has one mip. Its default SRV covers every layer. An explicit
TEXTURE2DMSview reads layer zero, whileTEXTURE2DMSARRAYselects a range starting atFirstArraySlice(ArraySize = UINT_MAXselects the remaining layers). The format-support query advertisesMULTISAMPLE_LOADwhen the format can be sampled with MSAA and its binding pair is available. - A texture is named in its T#s by an address of its own, above 4 GiB and 256 bytes apart, that nothing dereferences; its entries leave the set and the table when it is destroyed.
VulkanDeviceInfo::bindlesssays the Vulkan device has the features this needs:runtimeDescriptorArray, dynamic indexing of sampled- and storage-image arrays, and update after bind for sampled images, storage images and storage buffers. The standalone device enables them where the GPU has them.- Every
ExecuteCommandListsflushes the set before its commands are written. rt::d3d12::bindless_setandbindless_set_layouthand out the set and its layout: what a pipeline whose shader declares set-0 bindings is created with and binds.
- Layouts. A descriptor in set 0 has one image layout for as long as it lives, but D3D12 lets a texture be
sampled in a shader-resource state and also while promoted from
COMMON, which isGENERALhere (section 4.3). So with the bindless set, a texture's shader-resource states useGENERALtoo (ResourceBinding::sampled_in_general), and every descriptor is written withGENERAL. This follows from the Vulkan rule that a descriptor's layout matches the image's; no test here can see it broken, because the validation layer does not follow which element of a runtime array a shader reads. A depth texture sampled while it is also bound read-only (DEPTH_READwith a shader-resource state) is inDEPTH_STENCIL_READ_ONLY_OPTIMALand is not handled.
A typed single-sampled 3D texture can use a default SRV or an explicit TEXTURE3D SRV of the same format.
An R8G8B8A8_TYPELESS volume supports explicit R8G8B8A8_UNORM and R8G8B8A8_UNORM_SRGB SRVs.
The sRGB view decodes RGB and preserves linear alpha. A typeless volume requires an explicit typed view.
The T# records the base depth, the view's mip range and ResourceMinLODClamp. Binding 6 holds the 3D Vulkan view,
which has one array layer. d3d12_descriptor_test checks samples at four W coordinates through two views of the same
volume, plus minimum-LOD clamped views (inside the mip range via VK_EXT_image_view_min_lod, at or below
MostDetailedMip, and above the last mip).
Buffer shader-resource views and constant-buffer views are written as the 16-byte GFX10 V# a shader loads
(gfx10_descriptors.h) in the first half of the slot: write_buffer_srv for raw, structured and typed buffer
SRVs, CreateConstantBufferView for CBVs in the console's form of 16-byte rows (LEONIDA_CBV_RAW=1 writes a raw
V#), both checked in d3d12_compute_test; buffer UAVs of every kind are written too (section 3.4 "Buffer UAVs",
d3d12_m4_compute_test and d3d12_buffer_uav_test). Known gaps in the descriptor path:
1D-array SRVs, other typeless volume formats, multisampled depth/stencil and typeless
color SRVs, and shader-translator lowering for multisample loads. Single-sampled depth-plane views (R24_UNORM_X8_TYPELESS,
R32_FLOAT_X8X24_TYPELESS) are a T# of the texture's depth format (8_24_UNORM, X24_8_32_FLOAT) through the
depth aspect (the texture's backing format, so X24_8_32_FLOAT for a D24 texture where the layer stores it as
D32_SFLOAT_S8_UINT), each on its own family only (the other family's is a null
descriptor, as D3D12 refuses it), and stencil-plane views (PlaneSlice 1, as
X24_TYPELESS_G8_UINT or X32_TYPELESS_G8X24_UINT) are an 8_UINT T# that set 0 shows through the stencil
aspect, in its float-typed sampled arrays like other single-sampled UINT views. Other gaps include descriptors
the game writes itself, which need
the execute-time scan of section 3.4 (only descriptors made through the device are registered). A retail
descriptor heap census (BL-4, measuring the primary 1,245,184-slot console CBV/SRV/UAV heap across submissions
50, 500, and 5000 on RTX 5070 / Windows 11) confirms the slot distribution: 910,244 empty slots; 327,543 single-dword
free-list links (value = slot_index + 1, ending at 0xFFFFFFFF); 261 T# with layer-assigned addresses above 4 GiB;
5,840 V# (3,024 with a null base, 2,816 with a sub-4-GiB arena base); 1,296 slots containing interleaved constant data
(IEEE-754 floats); and zero bare 32-bit GPU addresses. Console descriptors do not store standalone 32-bit pointer words;
buffer and image base addresses are packed into standard 48-bit V# and T# records conforming to the arena layout
(modeled by model-level reference contract suite tests/test_descriptor_address_translation.py); the literal S#s of shaders (literal_samplers in the index),
which rt::d3d12::register_samplers registers without a heap slot but which nothing passes to it yet (the call at
pipeline creation comes with the shader index, #291);
custom border colours without VK_EXT_custom_border_color, and minimum/maximum filters, anisotropy or mirror-once addressing without the Vulkan
feature, each logged and approximated (note: in Vulkan, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT is
per-format; because bindless set 0 hashes T# and S# independently in the shader, bind_sampler cannot know
which image format a sampler will be paired with — on Radeon iGPUs BC* formats lack MINMAX while uncompressed
formats support it, whereas RTX supports all queried formats); the storage arrays hold 255 images a dimension at the default counts, more
where the device has room (4095 2D and 1023 2D-array on an RTX 5070); nothing writes through a
storage view in a D3D12-level test yet (vk_bindless_test goes through the storage bindings at the Vulkan
level). The set is flushed at every ExecuteCommandLists. A flush that moves the table to a larger buffer, changes
the index of a live key or relocates one (BindlessSet::flush_replaces_table()) does not write in place and does not
wait (D3D-314; D3D-76 first waited for the whole device, which stalled every queue and would have at every texture
release of a game that churns textures). It makes a new generation: new table buffers (the whole table uploaded to
them in that submission's command buffer), a new one-set descriptor pool and set (binding 2 names the new table, and
every descriptor written so far is written again from a CPU shadow of the set, in runs, so unwritten elements stay
unwritten under partially_bound), and replay binds that set at the dispatches and draws of the submission
(ReplayFunctions::bindless_set; the pipelines' own bindless_set only marks that they use one). Submissions made
before keep reading the old set and table, which nothing writes again. The old generation is stamped with the
latest submission ticket and freed at a later ExecuteCommandLists (and at device teardown) once
completed_retire_ticket() has reached it. Those tickets are the layer's per-submission records of (queue timeline
semaphore, value): the stamp is therefore the latest submitted value of every queue that could have bound the
set, and the free waits until each of those timelines has passed its value; nothing is waited for. The completed
prefix is global and in order, so a queue blocked on a fence only delays the free, never another queue. The stamp
is taken under tracker_mutex_, which execute() holds from the flush to the end of its submit, so no submission
that bound the old set is unsubmitted when it is read. LEONIDA_BINDLESS_IDLE_WAIT=1 restores the old wait
(a counted vkDeviceWaitIdle before the flush) to compare frame times; nothing else uses it. The cost of the new
path is a full upload of the table and a rewrite of the set's descriptors per replacing flush, where the old one
uploaded the changed slots after the stall; d3d12_bindless_churn_test prints both.
The pattern is the one vkd3d-proton uses to retire GPU-visible objects without a device idle (approach only, no
code taken): stamp the object with what every queue has submitted and free it at a later submit once those
submissions have completed. Two further rules come with it here. The submission that carries a new generation's
table upload makes every other queue's next submission wait for its timeline value (bindless_upload_semaphore_,
like the storage-image initialisation), because that submission is the first to bind the new set and a queue with no
D3D12 fence on it could otherwise run before the copy; the table's buffers need no ownership transfer because every
D3D12 queue of the device is made in info.queue_family. And at most 8 retired generations are kept: past that, the
next flush waits (logged once, with the descriptor lock released) for the submissions up to the oldest one's ticket,
which is a wait for those queues' timelines and not for the device. The commit of a submit's result runs under
tracker_mutex_, so a later flush never sees an earlier submit's outcome unrecorded. If the new generation cannot be
made, the submission still goes ahead. A table buffer that finds device-local memory full goes to host-visible
memory (slower lookups, logged once). A freed generation is kept as a spare (at most one) and reused, pool and
buffers, by the next replacing flush, so steady texture churn allocates nothing. Failing that, the flush frees the
generations that have completed and retries; when every submission is done it rewrites the current table in place;
and otherwise it degrades: the pending descriptor writes go in place as on a flush that replaces nothing (they name
new or freed indices), the table keeps what it had, so keys added since read the fallback, and the change waits for
a later flush (logged at the first and each power of two, with what could not be made). It used to fail, and
ExecuteCommandLists refused the whole batch, which the title treats as fatal (a native boot died that way in the
story load once device-local memory was full). vk_bindless_grow_test covers the churn, the host fallback, the
in-place rewrite and the degraded flush, with allocations failed on purpose.
Two bindless hazards that vkd3d-proton documents for games and that this change does not remove: descriptors
written for resources allocated after the submit that reads them, and an image and a buffer descriptor aliasing one
heap slot (vkd3d-proton PR #3033, https://github.com/HansKristian-Work/vkd3d-proton/pull/3033). Future path, not
implemented: VK_EXT_descriptor_heap (https://www.khronos.org/blog/vulkan-introduces-roadmap-2026-and-new-descriptor-heap-extension)
would replace descriptor sets with application-sized heaps.
A typed 3D color target supports default and explicit RTVs. The default covers mip 0; FirstWSlice and
WSize select the depth slices in an explicit view's mip. d3d12_clear_test --volume checks full and
rectangular clears of overlapping slice ranges against both Windows WARP and expected RGBA bytes.
The compute path, end to end:
-
runtime/src/shader_library.hfinds the translated SPIR-V for a shader the game hands to D3D12 (section 3.6). It extracts the FSSM program from the DXBC container (DXIL → XDAT entry 0x0D → XBCH → zlib) and looks up its SHA-256 asfssm_sha256inspirv/index.json. Its own inflate, SHA-256 and JSON reader keep it free of dependencies (shader_library_test).- A container with two different 0x0D payloads (195 of 26,503) is read at the last one, as
tools/fssm_unpack.pydoes by default and so asfssm_sha256was computed. - Index entries that share a program are all kept (789 groups of 1,182 entries in the corpus). A PSO takes the first entry that fits (for a VS: whose input signature the input layout feeds) and declares no set-0 bindings (the cheaper pipeline: a binding-free entry has no set 0 in its layout).
- A malformed index (bad numbers or
\uescapes) is refused with an error instead of throwing into the shim, and an integer field outside 0..2^32−1 reads as 0.
- A container with two different 0x0D payloads (195 of 26,503) is read at the last one, as
-
Root signatures use the model already on
main(runtime/src/root_signature.h,rt::rootsig):parse_rts0reads the serialized blob andpack()lays out the 32 user-data dwords by the section 3.5 default mapping, refusing anything that would spill.pack_stage()lays them out in the console layout of one stage (section 3.5, D3D-448); the compute bind point uses it. -
GPU address arena (section 3.3, when the device has
bufferDeviceAddress): one host-visible, device-addressable buffer, 256 MiB by default (LEONIDA_ARENA_MB, at most 4095 MiB, so every VA fits 32-bit table pointers).LEONIDA_ARENA_MBbounds the address range; with sparse binding it is not memory.- Backing blocks (
runtime/src/arena_backing.h). Where the device hassparseBinding,sparseResidencyBuffer,residencyNonResidentStrict, a sparse address space at least as large as the arena and a queue with the sparse binding bit to spare (pick_arena_bind_queue: RADV's sparse-only family), the arena is a sparse buffer and its memory comes in units bound in 2 MiB blocks: a block is bound when the first allocation needs it, before the allocation is handed out, and unbound once its last allocation is released and the GPU has passed the retire ticket of the release (submitted_retire_ticket() + 1, checked at the start of everyExecuteCommandListsagainstcompleted_retire_ticket()), then its memory is freed. Binds go to that queue alone and are waited for there, so a bind never sits behind a submission that waits for a fence the CPU signals later. - Only with signed V# offsets. A driver can place a sparse buffer anywhere relative to ordinary ones: RADV
(Mesa 26.3.1, natively and under Wine) gives sparse buffers a range of their own 64 TiB above them
(0xffffc00100200000 against 0xffff800100010000), so with a sparse arena every buffer outside it (geometry copies,
title windows and shadows outside it, upload buffers) lies below heap_base, at a negative offset. A shader that
sign-extends a V#'s 48-bit base (docs/design.md, "Heap-relative buffer device addresses") reaches it, since RADV
hands out addresses from one 2^47 half of the 48-bit space, so any two lie within 2^47 of each other. One that
zero-extends does not. The device counts each loaded module's
vsharp_base_sign_extendedmarker (VsharpBaseCensus,runtime/src/shader_library.h) and logsV# bases: signed offsets from heap_base (N of N modules sign-extend). The arena is sparse only when every module sign-extends (orLEONIDA_IMPORT_BELOW_ARENA=1says to read bases signed). With older modules it stays one allocation and one line says why.TitleBufferWindows::shader_reachablechecks every block made outside the arena against the same range when it is made, and a block it refuses is logged with both addresses.d3d12_title_va_game_deviceandd3d12_geometry_views_game_devicerun the title-memory tests on the device the game makes (with the bind queue), so on RADV their windows and geometry copies are read through negative offsets. - No allocation crosses a unit: one no larger than a block stays inside one block, a larger one takes whole blocks
of its own. So each allocation is one run of one mapping, and the CPU reaches an arena offset through
DeviceState::arena_host()(one table read; null, with a line, for a range without memory), orArenaBacking::with_host()for an offset the caller does not hold (value writes,read_arena). A D3D12 heap in the arena lends its unit's memory to reserved resources' tiles at the heap's place in that unit. - The block size is measured, not tuned: a world run had about 5,000 live arena allocations averaging 160 KiB (790 MiB live, 990 MiB peak end, 4,095 MiB asked). 2 MiB is a multiple of the 64 KiB sparse page, keeps a 4 GiB arena within the 4,096 memory objects some Windows drivers allow (2,048 at most, about 500 at that peak), and is amdgpu's large page.
- Without those capabilities (llvmpipe: a 2 GiB sparse address space and one queue) one allocation backs the whole
arena, as before, through the same accessors.
arena_backing_test(CPU) andarena_sparse_gpu_test(a real device; skipped without sparse binding) check both. The arena's line at device release (and with a console heap's log) readsGPU address arena: bound N MiB now (peak P, U units of 2 MiB blocks, sparse). - It is also no larger than the device's
maxBufferSize(Vulkan 1.3) and, counting the buffer's memory requirement,maxMemoryAllocationSize(Vulkan 1.1), whichever is smaller (runtime/src/arena_size.h). When a limit cuts the request, one log line names the limit and the size used.arena_size_test(CPU) checks the decision on synthetic limits;d3d12_compute_testchecks the arena against the device's limits and a simulated 32 MiBmaxMemoryAllocationSize. - The RX 6800 (RDNA2, AMD driver 26.11.2, Windows 11, measured 2026-11-22) reports 2 GiB for both, so
LEONIDA_ARENA_MBabove 2048 gets a 2048 MiB arena there. - Before the cap, that driver did create a 3000 MiB arena. Buffers placed past 2 GiB in it (VA 0x89820000) were
written by a compute shader and read back correctly, but the validation layer reports the allocation as over
maxMemoryAllocationSize. Nothing relies on this out-of-spec behaviour. - The device logs the arena's high-water mark when it is destroyed: the peak end offset against the size, the
most bytes live at once (by use: buffers, descriptor heaps, shaders, heaps), allocations and refusals (D3D-55).
LEONIDA_ARENA_LOG=1also logs one line per VA handed out, per refused allocation, and per upload or readback buffer VA outside the arena. - Default-heap buffers are 64 KiB-aligned ranges in it, zeroed through its mapping; their console VA is the offset.
- Every access to its free-block map is under the arena's mutex, and a walk holds no iterator across a call
(
runtime/src/arena_blocks.h): each step reads a block's offset and size, lets its iterator go, looks the next block up from the map again, and re-finds a candidate by offset before it cuts it. A map access outside the lock makes a concurrent walk step into a node an insert rebalanced away or a release freed — measured once: an access violation reading the nil flag of a null map child at 0x19, insidearena_allocatefor a slot-133 shadow buffer (the arena's first block used to be inserted bycreate_arenawith no lock, and an insert rewrites child links). The arena checksfree + live == size - reservedon every allocation and release (O(1)) and walks the whole block map only when that fails orLEONIDA_ARENA_CHECK=1is set; adouble_freeor a release of a range past the arena (outside_arena) is reported instead of being let into the map, and those lines are rate-limited to one per 5 s.arena_blocks_test(CPU) covers first fit, coalescing, a title keep-out, the walk cut under it, the bad releases and one lock with many threads. - Shader-visible descriptor heaps also live in it: the CPU handle is its host mapping and the GPU handle is the VA, so descriptor bytes the application writes itself are what shaders load.
- Upload and readback buffers keep their own memory, and their VA is their device address minus the heap base.
- Shader programs (FSSM blobs) are copied in as the code base.
- Backing blocks (
-
CreateRootSignatureparses the blob withparse_rts0and keeps each parameter's place in two layouts, both the console's (one dword per table; section 3.5, D3D-448):pack_stage(Stage::Pixel)for the graphics bind point (from s8; a signature past s31 there keepspack()'s s0 layout, logged) andpack_stage(Stage::Compute)for the compute one (from s4). It also checkspack_stage(Stage::Mesh): a signature past a mesh shader's 16-dword window is logged, andDispatchMeshwith it invalidates the list. A signature neither bind point can place (past s31: the spill layout is open; the translated shaders have no below-base spill-pointer candidates) is refused with both reasons; one only a single layout places is created with a log line, and binding it at the other bind point invalidates the list. Before that it answers as the host runtime does (compare_invalid_arguments, "root signature:", RTX 5070 / 621.14):S_FALSEfor a null output whatever the blob, thenE_INVALIDARGfor a node other than node 0 or a DXBC container whose size (the dword at +24) is not the size passed.CreateComputePipelineState(PC slot 11, Xbox slot 62 through the proxy) finds the shader by its FSSM hash, builds a pipeline with the 144-byte push-constant range and registers it for replay. Shaders that declare set-0 bindings get the device's bindless set 0 in their layout and bound at every dispatch (M2); on a device without that set they are refused with a log. -
Command list:
Set{Compute,Graphics}RootSignature(a different signature clears the arguments, as D3D12 leaves them undefined; setting the bound one again keeps them, as D3D12 does),SetPipelineState, the 32-bit constant, root view and descriptor-table setters,SetDescriptorHeapsandClearState. A wrong parameter type, out-of-range constants, or an invalidSetDescriptorHeapscall makesClosereturnE_INVALIDARG.SetDescriptorHeapstracks the currently bound shader-visibleCBV_SRV_UAVandSAMPLERheaps and their arena GPU base VAs, holds references to them untilResetor list destruction, unbinds omitted types (clearing both onClearStateandReset), refusesCOPYlists, > 2 heaps, null arrays/elements, non-shader-visible orRTV/DSV/duplicate-type/foreign-device heaps, and enforces bundle matching against the parent list (parent's currently bound heap for each non-null heap the bundle specifies,d3d12_set_descriptor_heaps).- The list holds a reference to every root signature and pipeline state it is given, until
Resetor its own release. D3D12 lets an application release them right after setting them, so the root layout the setters read and the pipelineExecuteCommandListslooks up must outlive that. Keeping them alive while the GPU runs the submission stays the application's job, as in D3D12.Dispatchrecords the block as it is at that moment. Replay binds the pipeline, pushes s0..s31, the heap base and the code base, and dispatches.
-
Graphics pipelines and draws (M1).
CreateGraphicsPipelineState(PC slot 10) finds the VS and PS by FSSM hash.- Vertex input: each input-layout element is matched to the VS input signature by semantic name and index, and its location is the element's register (the translator's vertex-fetch rule). An input the layout leaves unfed is refused, as D3D12 refuses it.
- Fixed-function state: rasterizer, blend and depth-stencil state map one to one. Viewport, scissor,
topology, stencil references and the blend factor are dynamic, and so are vertex strides when the pipeline has
vertex bindings. A pipeline without them (a full-screen pass from
SV_VertexID) does not declare the stride state, since nothing would set it (VUID-vkCmdDraw-pStrides-04913).d3d12_state_sweep_testchecks the mapping against the host on the same adapter: 482 full-screen draws over every blend factor pair, blend operation, write mask, comparison function and stencil operation, with the stencil plane read back, are byte-identical on an RTX 5080 and a Radeon iGPU. Sixteen more build the PSO from a stream withDEPTH_STENCIL2and different masks per face, front- and back-facing, with one reference or two (OMSetFrontAndBackStencilRef): 498 in all, byte-identical on an RTX 5070 Ti (driver 617.42), and 6 of the 16 differ when the back face is given the front face's masks. - A triangle-family PSO can draw Xbox rectangle lists. When the input assembler selects topology 17, replay
selects a geometry-stage variant that emits the fourth corner after vertex shading. It requires
geometryShaderand a vertex pipeline without an application geometry stage. A later triangle draw uses the original PSO. The translated-draw GPU test switches between both primitives on one PSO and checks every pixel. - Logic ops come from
RenderTarget[0], as in D3D12, and apply to every target (Vulkan has one per pipeline; it skips float formats).DepthClipEnable = FALSEis depth clamping: D3D12 clamps output depth to the viewport's range anyway. - Conservative rasterization (Tier 1/2): the standalone device enables
VK_EXT_conservative_rasterizationwhen available; caller-owned devices must setVulkanDeviceInfo::conservative_rasterizationonly if they enabled it. OPTIONS reports at least Tier 1 only with at least eight subpixel precision bits and a finite, nonnegative primitive overestimation no greater than0.5 - 1/512pixels, leaving half a minimum grid step within the Tier 1 uncertainty bound.ConservativeRaster=ONuses overestimate mode with zero extra overestimation, including unbound-attachment variants. OFF keeps the ordinary pipeline. Missing support, unknown modes, wireframe and non-triangle PSOs are refused (a mesh PSO needs no topology type: its module has to output triangles,conservative_raster::mesh_outputs_triangles); conservative TIR (ForcedSampleCount != 0) remainsE_NOTIMPL. Tier 2 additionally requiresdegenerateTrianglesRasterizedand primitive overestimation plus half a device subpixel step no greater than 1/256 pixel. Other eligible devices retain Tier 1. The standalone device does not expose Tier 3: the XboxSV_InnerCoverageinput mapping has not been confirmed. See Microsoft's rules and Vulkan's properties.d3d12_conservative_tier2_testchecks the tighter geometric uncertainty bound, post-snap and exact degenerates with distinct indices, provoking-vertex colour, constant depth, back-facing classification, culling, indexed permutations, triangle strips, scissor and unbound-attachment variants. On RX 5700 XT (Windows driver 32.0.21045.5002), 16 tight-bound scenes and 480 degenerate draws pass across Vulkan and native AMD D3D12. The WARP comparison omits only its pixel-corner fixture: WARP drops that tiny triangle even though Vulkan and native AMD cover it.--warp-cornerretains the strict failing software-reference reproducer; Vulkan always checks the corner. VariableSV_Position.zis not a provoking-vertex oracle: both native references and Vulkan exhibit extrapolation for screen-space degenerates. This test checks constant depth and separately varying colour, and does not claim a depth-buffer readback or variable-depth conformance.d3d12_conservative_raster_testchecks geometric required/forbidden coverage, subpixel/sliver and degenerate triangles, culling, scissor, 1x/4x MSAA, variants, feature reporting and refusals. Uncertain edge pixels are allowed to differ. On RX 5700 XT (Windows 32.0.21045.5002), 48 scenario pairs pass on Vulkan and native AMD; 24 single-sample pairs pass on WARP. WARP's 4x subpixel fixture covers outside the geometric bound; it remains reproducible with--warp-msaa4, separately from CTest's 1x software comparison. Vulkan's 4x oracle remains strict. On RTX 3060 (Windows 11, NVIDIA 610.88), 48 pairs pass on Vulkan and native NVIDIA. The oracle judges the layer alone. A native render that fails it is printed as "host not comparable", with its normal and conservative pixel counts, and that scenario isn't compared with the host. For example, Windows 10's WARP (d3d10warp.dll10.0.19041, the host CTest selects withLEONIDA_HOST_ADAPTER=warp) misses pixel (4,4) of scene 4 with conservative rasterization on: seen on an RTX 5060 Ti and an RTX 2060 machine, both of which pass with their NVIDIA GPU as the host (TEST-907). The GPU test needs the current graphics path's 144-byte push-constant support; CPU capability checks do not need a GPU. No game-pass usage is claimed by these synthetic tests.d3d12_conservative_tier3_referenceis a native D3D12 reference probe, not Tier 3 support in the Vulkan layer. Explicit InnerCoverage library contract (experimental): a caller-owned device can setVulkanDeviceInfo::inner_coverage_abionly for a shader library whose InnerCoverage input is already lowered to the boolean SPIR-VFullyCoveredEXTbuilt-in (false maps to uint 0, true to uint 1). Tier 3 then also requires all Tier 2 properties andfullyCoveredFragmentShaderInputVariable. The default remains false, including for the standalone device; this is not an inferred FSSM/VGPR layout or automatic game-shader support. Graphics PSOs inspect the actual SPIR-V capability, even if index capability metadata is absent, and refuseFragmentFullyCoveredEXTwithE_NOTIMPLbefore shader-module creation unless the contract and device support are present. A module usingPostDepthCoverageadditionally requiresconservativeRasterizationPostDepthCoverage. The tests use explicit synthetic GLSL; no new translator rule or retail shader coverage is claimed.inner_coverage_oraclechecks false positives, missed interior values and missing invocations on the CPU.d3d12_inner_coverage_guardschecks that neither opt-in nor metadata omission can bypass missing support.d3d12_inner_coverage_nativechecks 48 native D3D12 scenarios on the matching adapter: six triangles, 1x/4x MSAA, scissor and unbound-target variants. These pass on RX 5700 XT (Windows 32.0.21045.5002) with Vulkan validation active.d3d12_conservative_tier3runs the same 48 scenario pairs on Vulkan and native D3D12 when Vulkan has the property and native D3D12 has Tier 3; it skips on this RX 5700 XT. The positive Vulkan path still requires independent execution on a capable GPU. InnerCoverage with conservative rasterization off is undefined in D3D12 and is not compared. Edge pixels within the uncertainty region are not required to match byte-for-byte; both backends must independently satisfy the geometric guarantees. To validate the explicit path, configure with Vulkan SDK/glslang available, buildd3d12_conservative_tier3_test, select an adapter withLEONIDA_VK_DEVICEif needed, and runctest --test-dir runtime/build -C RelWithDebInfo -R "^(inner_coverage_oracle|d3d12_inner_coverage_guards|d3d12_inner_coverage_native|d3d12_conservative_tier3)$" -V. Check that the positive test prints 48 Vulkan/native paired scenarios rather thanSkipped.d3d12_conservative_tier3_referenceremains a native D3D12 reference probe; it does not opt in to that Vulkan contract. It reports the selected Vulkan device'sfullyCoveredFragmentShaderInputVariable, matches that device to its native D3D12 adapter by LUID, then checks the adapter's Tier 3SV_InnerCoverageoutput on four synthetic triangles. On Windows with Visual Studio 2022 and Windows SDK 10.0.26100 or newer, run.\scripts\run_conservative_tier3_reference.ps1from the repository root; by default this uses Vulkan's default adapter. Pass-Device <name substring>to select a specific one when multiple GPUs are present. It builds only this test, needs no glslang, and fetches the pinned Vulkan headers only if none are installed. The verbose CTest output reports the capability and result; it skips if the selected device lacks a matching native D3D12 adapter or Tier 3. - Formats: dynamic rendering takes the RTV and DSV formats. A draw that leaves a slot unbound for which the PSO names a format (D3D12 allows it and discards those writes) uses a variant of the pipeline with that format undefined, built on first use and kept with the PSO. Bit i of the variant key is colour slot i, and bit 8 is depth/stencil.
- Instance step rate 0: every instance reads element 0, done with a stride of 0 for that slot at draw time.
- Features: independent blend state, wireframe fill, a depth-bias clamp, SRC1 blend factors, logic ops and
disabled depth clipping need
independentBlend,fillModeNonSolid,depthBiasClamp,dualSrcBlend,logicOpanddepthClamp. The standalone device enables those the GPU has and reports them inVulkanDeviceInfo::features. A PSO that needs a missing one is refused with a log. - Shader features: the standalone device also enables
shaderInt64(declared by 25,803 of 26,503 index entries),shaderFloat64,shaderInt16,shaderClipDistanceandshaderCullDistancewhere the GPU has them. Without one,vkCreateShaderModulereports the capability (VUID-VkShaderModuleCreateInfo-pCode-08740). The index'sfeatureslist is not read yet, so a shader that needs a feature the GPU lacks is not refused up front. - Stores and atomics outside compute: a pixel shader that stores to an image or does an image atomic declares
that storage image without
NonWritable(of the 1,038 translated 1.0.2.1 modules that contain an image atomic, counted as modules with anOpImageTexelPointerand split by the index's stage, 1,018 are pixel shaders and 20 compute), which Vulkan allows only withfragmentStoresAndAtomics(VUID-RuntimeSpirv-NonWritable-06340); a vertex or geometry shader needsvertexPipelineStoresAndAtomics(-06341). The standalone device enables both where the GPU has them. A graphics PSO whose stage declares writable storage (read off the module's declarations,src/spirv_stores.h) on a device without the feature is refused withE_NOTIMPLand a log naming the shader.d3d12_stores_atomics_testchecks both under the validation layer. - Geometry shaders:
desc.GSis the translator's Vulkan geometry stage (docs/design.md, "Geometry shaders": triangles in, a triangle strip out) between the VS and PS. It needsgeometryShader, which the standalone device enables where the GPU has it and reports inVulkanDeviceInfo::features; without it such a PSO isE_NOTIMPL. The PSO's topology type must beTRIANGLE, the GS's input (E_INVALIDARGotherwise). The push-constant range names the geometry stage only on such a device (d3d12_geometry_test). - Refused with a log: hull and domain stages, stream output, MSAA, set-0 bindings, and two stages
that both read their code base (question 14, section 5.2). More than eight render targets is
E_INVALIDARG. - Push constants: both PSO paths declare the 144-byte block as one range. Its stage flags are the whole
stage table the graphics path accepts, and the replay pushes with the same flags. A device whose
maxPushConstantsSizeis below 144 (#224'spush_constants_need_fallback) has every PSO refused, with the limit in the log, until the uniform-buffer tail exists.
The command list keeps the input-assembler, viewport, scissor, render-target (read at
OMSetRenderTargets, as D3D12 does), blend-factor and stencil-reference state, including CommandList8's front/back references. EachDrawInstanced/DrawIndexedInstancedrecords a copy of that state. A draw with no viewport (never set, or unbound withRSSetViewports(0, …)) or an empty one rasterizes nothing in D3D12. Such a draw is not recorded, since Vulkan forbids a 0×0 viewport.At replay:
- Buffers: vertex and index views resolve to buffers by VA (arena or upload). A view that runs past its buffer is cut at the buffer's end. An unbound vertex slot, or an indexed draw with no index buffer, reads the arena's reserved first 64 KiB, which is kept zero (stride 0), so it gets the zeros D3D12 gives.
- Attachments: they move to attachment layouts through the tracker, and the draw runs in a dynamic-rendering scope. Its layer count is the smallest layer count of the bound views.
- Viewport: it is flipped (negative height), because translated vertex shaders write D3D clip coordinates; front-face winding then matches D3D12's.
- Only the first viewport and scissor are used, and primitive restart is not modelled yet.
Resources and heaps:
- A buffer of 0 bytes, or one whose size wraps when aligned, is
E_INVALIDARG. One the arena cannot hold isE_OUTOFMEMORY, and so is a shader-visible descriptor heap the arena cannot hold (in host memory its GPU handle would be 0). - If the arena cannot be created, its buffer is released, so other buffers keep their own memory and get no VA.
- With
VK_EXT_conditional_rendering, the arena is created with the conditional-rendering usage, andSetPredicationon a default-heap buffer reads at the buffer's offset in the arena plus the call's offset. CreateHeapreserves the requested size in the arena at 64 KiB, and a buffer placed in it gets the heap's place plus the placed offset as its console VA. A placed texture has memory of its own (a range of a shared block or its ownVkDeviceMemory, section 3.3) and a null VA, 1D, 2D and 3D alike (arrays and mips included), and a dimension outside the enum isE_INVALIDARG, as on the host (RTX 2080 Ti and WARP,d3d12_placed_dimensions_test); tiled (64KB_UNDEFINED_SWIZZLEand Xbox0x101) 2D/3D placed textures are backed the same way with tile-multipleGetResourceAllocationInfo,GetResourceTiling, and host-matchedE_INVALIDARGchecks (D3D-191).CreatePlacedResource2's castable-format list reaches the placed texture's image as the committed path's does (D3D-90).CreateHeaprefuses withE_INVALIDARG, as the host does (RX 5700 and WARP, D3D-238), an alignment other than 0, 64 KiB and 4 MiB, a heap type outside the enum, a custom heap without a CPU page property and memory pool or a non-custom heap with either, and a heap with all threeDENY_*flags. It also refusesALLOW_DISPLAY(committed resources only), as an RTX 4070 SUPER and a UHD 770 host do. It acceptsHARDWARE_PROTECTED, as those hosts do, though theD3D12_HEAP_FLAGSdocumentation calls it unsupported. (D3D-191). Multisampled 2D placed textures (UNKNOWNand4xtiled) share that backing with host-matched heap and offset alignment checks (4 MiBvs64 KiB,D3D-222).CreatePlacedResource2's castable-format list reaches the placed texture's image as the committed path's does (D3D-90).
Known gaps: set 0 in pipelines (the device keeps the bindless set, but no pipeline declares or binds it yet) and
therefore every translated shader that declares bindings; tessellation, geometry and mesh pipelines,
multisampled pipelines, several viewports, primitive restart; requiredSubgroupSize = 64 for wave64 compute;
the game's present entry point (PresentX; the DXGI factory/swapchain and the presenter above are what it
- Subgroup size (compute and graphics PSOs). A translated shader assumes one subgroup size, and a GPU whose
default differs runs it inexact: a wave64 shader reads lanes 32-63 of a 32-wide subgroup, and a wave32 pixel
shader on a 64-wide default reads the other half's lanes (AnyPS5 #487 on RDNA4).
runtime/src/subgroup_size.hdecides, per stage, from the shader's index entry and what the device offers; the PSO chains the result.-
Index fields:
wave64,subgroup_size(64 for wave64, 32 otherwise,nullwhen emulated) andwave64_exchange(present: translated with--wave64-emulate, exact on any size). -
Device:
subgroupSizeControlandcomputeFullSubgroupsare enabled where supported;minSubgroupSize,maxSubgroupSize,maxComputeWorkgroupSubgroups,requiredSubgroupSizeStages(fromVkPhysicalDeviceSubgroupSizeControlProperties) and the defaultsubgroupSizeare kept inVulkanDeviceInfo::subgroupand printed at device creation. -
Emulated shaders: nothing is required.
-
Native shaders:
VkPipelineShaderStageRequiredSubgroupSizeCreateInfo{subgroup_size}when the feature is enabled, the stage is inrequiredSubgroupSizeStages, the size is a power of two in [min, max] and, for compute and mesh, the workgroup fits in size xmaxComputeWorkgroupSubgroups(VUID-VkPipelineShaderStageCreateInfo-pNext-02755 and -02756, VUID-VkPipelineShaderStageRequiredSubgroupSizeCreateInfo-requiredSubgroupSize-02760..02762). A compute stage also getsVK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BITwhencomputeFullSubgroupsis enabled and local size X is a multiple of the size (-flags-02785 for the feature, -flags-08988 for the stage, -pNext-02757 for X). Wave32 shaders ask for 32 the same way. A device whose only size is the wanted one (NVIDIA, wave32) needs no chain. Where the size cannot be required (stage not listed, feature off) but the device default is the wanted one, the shader works as it is (device_default; nothing guarantees the default, so it is not logged as inexact); any other size isunavailableand logged. -
Which stages can be required: it is the driver's list, not a fixed rule, and AMD's Windows driver gives different lists for different GPUs, on the same 26.11.2 release too:
- Radeon 880M (RDNA3.5, gfx1150), 26.11.2: FRAGMENT | COMPUTE | TASK | MESH, sizes 32..64, so wave64 and wave32 pixel shaders run exact there.
- RX 6800 (RDNA2 like the console; gfx1030), 26.11.2 (Windows driver 32.0.21045.29003), measured 2026-11-22:
COMPUTE only, sizes 32..64, default 64 (
vulkaninfo; the device log saysrequirable in stages 0x20). No size can be requested for pixel or mesh shaders (vk_harnesschains none forVKH_SUBGROUP_SIZE), and at the default they run 64-wide: a GLSL probe pixel shader drawn byvk_harnesscounts 64 live invocations per subgroup (subgroupBallotBitCount) on a full-screen draw (SPIR-V 1.5 and 1.6), andms_w64x_ballot(both halves of a wave64) passes natively. For the translated SPIR-V 1.5 modules, made withoutALLOW_VARYING_SUBGROUP_SIZE, the specification fixesSubgroupSizeat that default ("Varying Subgroup Size"); only the driver's default could change. So wave64 pixel and mesh shaders work at the default (device_default; the layer has no mesh PSO yet), and a wave32 pixel shader isunavailable: two of its waves share a subgroup.ps_bitmask_permshows it: lanes 0-31 exact, while the other 2,048 of 4,096 pixels readv_mbcnt_lo= 32 instead of their lane (the fixture's check judges lanes 0-31 only). Of the 1,127 wave32 pixel shaders in the corpus, 1,010 contain av_readlane/v_writelane/v_readfirstlane, 146 av_mbcnt, 105 ans_bcnt1/s_ff1of a lane mask, and all 1,127 a branch on EXEC or VCC or an SCC vote on a mask, which the translator decides by a subgroup vote (117 have only those). 926 also havev_permlanex16and row DPP and 826 quad ops, which stay inside a 32-lane half as translated (tools/wave32_pixel_scan.py; counts of candidates, not verdicts). - Ryzen 7 9800X3D iGPU (RDNA2, gfx1036), Windows driver 32.0.21045.5002: COMPUTE only, sizes 32..64; RX 9070 XT
(RDNA4, gfx1201), Windows driver 32.0.31041.1004: FRAGMENT | COMPUTE | TASK | MESH, sizes 32..64
(@AC-Storm-YT,
vulkaninfoSDKfrom Vulkan SDK 1.4.363.1, #313). The same two lists on AMD 26.11.2 (Windows drivers 32.0.21045.29003 and 32.0.32029.2010), whereps_bitmask_permalso shows the live fragment width: the gfx1036 iGPU gets the RX 6800's split (2,048 of 4,096 pixels read lane 32), the RX 9070 XT is exact on all 4,096 (@AC-Storm-YT, #3982 and #4225).
Current Mesa RADV on GFX10+ lists COMPUTE | FRAGMENT | task/mesh (Mesa main at 152b9cde,
src/amd/vulkan/radv_physical_device.c,requiredSubgroupSizeStages; older Mesa reported compute only), so pixel shaders run exact there. NVIDIA lists every stage but only size 32, so a native wave64 shader cannot get 64 there. Vertex and geometry stages are in neither list. -
A size the device cannot give is logged once per stage with the first shader's name (and again at 10, 100, 1000 shaders of that stage):
[rt] d3d12: <name> (<stage>) is a 64-wide shader but this device cannot require that subgroup size .... For compute and mesh the fix is the build,--wave64-emulate(make_game.py --wave64-emulate autopicks it for this GPU); a wave64 vertex, geometry or pixel shader has no emulation yet (the ~10,000 wave64 pixel shaders are the open case on NVIDIA, SHADER-10). A wave64 VS/PS/GS whose index entry carrieswave64_graphicstier A or B is not logged as inexact: the line says it runs at the device's size and that the translator's partition-invariance analysis puts it in that tier, since cutting its wave into two 32-lane halves does not change its results (tier C and entries without the analysis keep the conservative line). -
Test:
subgroup_size_test(CPU) checks the decision against AMD-like, NVIDIA-like and old-RADV properties and the resulting create-info chain;d3d12_subgroup_test(GPU) runscs_w64x_readlanenatively and with--wave64-emulate, andcs_wqm_w32, through D3D12 PSOs and compares the read-back words.
-
Known gaps: set 0 in pipelines (the device keeps the bindless set, but no pipeline declares or binds it yet) and
therefore every translated shader that declares bindings; tessellation, geometry and mesh pipelines,
multisampled pipelines, several viewports, primitive restart; subgroup size for mesh pipelines (the decision covers them, no mesh PSO exists to chain it into), and for wave64 vertex, geometry and, on a GPU that cannot require 64 for pixel shaders (NVIDIA), pixel shaders, which have no emulation (SHADER-10); wave32 pixel shaders on a GPU that runs the fragment stage 64-wide and cannot require 32 for it (RDNA2 under AMD's Windows driver, "Subgroup size" above), where two waves share a subgroup;
the game's present entry point (DXGI factory/swapchain or PresentX; the presenter above is what either
calls), HDR and fullscreen; buffer and constant-buffer views (UAV clears read the descriptor bytes, so they do
not wait on view creation), typeless volume RTVs, depth-stencil resolves to a destination offset other than
the source rectangle's;
default-heap buffers are not zero-filled yet; a fence cannot be signalled to a lower value (Vulkan timelines only
increase; such a signal is reported and dropped); a CPU Signal above a queue Signal the GPU has not reached
yet is held until it has (vkSignalSemaphore must stay below every pending signal,
VUID-VkSemaphoreSignalInfo-value-03259), so GetCompletedValue shows it only then, and a fence released
while it holds one drops it; instance step rates above 1 (they need vertex attribute
divisors); read-only DSVs (the depth image always moves to DEPTH_STENCIL_ATTACHMENT_OPTIMAL, which matters once
depth SRVs are sampled next to a read-only DSV, M2); the index buffer is bound without its view's size
(vkCmdBindIndexBuffer2, Vulkan 1.4, takes one).
Known gaps found in review, not fixed here:
- Queues: every D3D12 queue submits to one
VkQueue, which runs batches in order. So a queue that waits on a fence another queue signals later (B->Wait(f, n)recorded beforeA->Signal(f, n)) holds back that signal, and the GPU never progresses (woreksami's probe). Queues on separate Vulkan queues (#306 for copy and compute) or holding back a batch until its wait value is submitted would fix it. - Lookups:
buffer_atsearches every resource for each vertex and index view; an ordered map by VA would do when it shows. - Fences: a CPU
ID3D12Fence::Signalchecks only the semaphore's current value, so it can signal below a GPU signal that is still pending (VUID-VkSemaphoreSignalInfo-value-03258).
Build runtime/ (Vulkan SDK and Python 3 on PATH) and run ctest --test-dir <build> --output-on-failure for the
CPU tests:
command_list_testcovers the recording rules.d3d12_state_map_testcovers both state tables, subresource and barrier-range decoding, layout tracking, the subresource rangesDiscardResourceprepares, Resizable BAR detection, and the memory type order on a no-ReBAR heap layout. On Windows it also checks every D3D12 constant the IR copies against the SDK'sd3d12.h.gfx10_descriptors_testcovers the T#, S# and V#: every field alone at its bit position, round trips, what decoding refuses and ignores, the T#s the image test shaders build, sampler words as radv writes them, and the format table.tests/test_gfx10_descriptors.pycompares that table withtools/gfx10_formats.json.subgroup_size_testcovers the subgroup-size decision of section 3.2 without a GPU: synthetic index entries (native and emulated wave64, wave32; compute, pixel, mesh, vertex) against AMD-like (32..64, FRAGMENT | COMPUTE | TASK | MESH), NVIDIA-like (32 only, every stage) and old-RADV (COMPUTE only) properties, the limits (feature off,maxComputeWorkgroupSubgroups, a size that is not a power of two), and the create-info chain.
The GPU tests read their results back. With LEONIDA_VK_VALIDATION=1 they run under VK_LAYER_KHRONOS_validation,
and any validation error fails them.
-
vk_command_replay_test, part A: only Vulkan 1.0 functions and no tracker. -
vk_command_replay_test, part B: rectangle clears, a depth clear while the stencil plane is read-only, a promoted texture, and enhanced barriers including a discard. -
vk_command_replay_test, part C: a 4x4x4 volume uploaded from a footprint, copied as a 2x2x2 block and whole, and read back; a 4x multisampled target cleared and resolved; and the copies and resolves that must be refused (a z range past the volume or its footprint, a footprint past the buffer, a resolve from a single-sampled texture or into another size, a multisampled texture copied to a footprint or to another sample count). -
vk_command_replay_test, part D: every D3D12 sync bit against every access bit (360 pairs), each as a global, a buffer and a texture barrier. Under the validation layer none may be rejected; beforevulkan_barrier_scopethere were 462 validation errors on Intel(R) Graphics. -
vk_command_replay_test, part F (D3D-26):WriteBufferImmediatein all three modes at console VAs, one of them in a binding that is a range inside another buffer (as arena resources are); UINT and UINT64 atomic copies ordered between the writes so that a missing barrier would copy a stale or a later value; a buffer discard (kept), a texture cleared, discarded and cleared again, and a rectangle discard (kept); and the lists that must be refused (an address past a binding or in none, novkCmdUpdateBuffer, a copy or dependent range past its buffer, an unknown dependent resource, a subresource the resource does not have, and an explicit discard count ofUINT_MAX, which is a range and not the whole resource). -
vk_command_replay_test, part I: a 4x D32MINresolve of a rectangle; the texels around it must keep the destination's clear value (MoltenVK overwrote all 28 of them before the scratch copy). It is skipped where the device has noMINdepth resolve (llvmpipe), and withoutcopy_scratchthe list is refused. -
d3d12_vulkan_device_testalso runs both atomic copies and the discards through COM, checks that aWriteBufferImmediateto an address no buffer holds is refused at execution (unresolved_resource), and writes a word at a placed buffer's VA and reads it back. -
vk_bindless_test(run byruntime/test/shaders/check.pyandscripts/run_gpu_tests.py): the translator's own lookup against the table and the set.ps_tex.asm, a hand-written RDNA2 pixel shader built bybuild.py, loads a T# and an S# from a descriptor table and samples. The test draws the gradient with the T# at the fourth slot probed, the fallback after the key is erased, the gradient again after the table has grown into a new buffer, another view at the same index, and the fallback after removal, with and without the descriptor-indexing flags. Last, it draws through a 2D image past 5000 others and a sampler past 2100 others. -
vk_sampler_test(run the same way): the S# and T# mip fields asgfx10_descriptors.hmaps them.ps_ssharp.asmloads a T# and an S# from the heap and samples a 128x128 two-level texture twice, withimage_sample_lz(LOD 0) andimage_sample(LOD 1 at this size). The sampler isvulkan_sampler(decode(S#))and the view's levels come fromdecode(T#).check.py'sSAMPLER_CASEScover a point mip filter, MAX_LOD 0, MIN_LOD 1, LOD_BIAS ±1, MIP_FILTER_NONE with and without MIN_LOD, and a T# whose BASE_LEVEL is 1. Each pixel is judged against levels worked out from the S# and T# bits in Python, independently of the header. On Vulkan, the sampler's minLod and mipLodBias apply to an explicit LOD as well. The T#'s MIN_LOD (D3D12's ResourceMinLODClamp) is not covered by this test. -
Measured on RDNA2 (SHADER-539):
tools/sampler_lod_probe.py --oracle hwsamples a linear 64x64 R32_SFLOAT texture with seven levels at its top-left texel. The texture memory is a dword ramp, so each result names the level it was read from, and a calibration row per level finds the level starts. It runs 43 rows ofimage_sample_landimage_sample_lzon a gfx1036 (Radeon iGPU, Windows 11, AMD 26.10.1,tools/hw_oracleHIP launcher, rocm-sdk-core 10.0.0 clang). wave32 and wave64 gave the same level in every row, and three runs were identical.-
The S# fields apply to explicit LODs. LOD_BIAS (±), MIN_LOD and MAX_LOD apply to
image_sample_l's explicit LOD and toimage_sample_lz's LOD 0, bias before the clamp, as radv assumes. MIP_FILTER none ignores them and reads the view's base level. -
The T#'s MIN_LOD applies too. It counts from the resource's level 0, not the view's BASE_LEVEL: BASE_LEVEL 1 with MIN_LOD 2 reads level 2.
-
Where the hardware is not Vulkan:
- Rounding. The point mip filter's level is floor(lambda + 0.5), so an exact .5 rounds up: LOD 0.5, 1.5 and 2.5 read levels 1, 2 and 3, and so do S# MIN_LOD 1.5 or MAX_LOD 1.5 and LOD 1 with bias +0.5. Vulkan's nearest is ceil(lambda + 0.5) - 1, which reads 0, 1 and 2.
- The T#'s MIN_LOD clamps the still fractional LOD before that rounding. MIN_LOD 2.25, 2.5 and 2.75 at
LOD 0 read levels 2, 3 and 3.
VK_EXT_image_view_min_lodraises the integer level to floor(minLod), which gives 2, 2 and 2. - MIP_FILTER none with the T#'s MIN_LOD. The level is the base raised to floor(MIN_LOD): 2.5 reads level 2, the same as Vulkan.
So a host whose Vulkan driver follows the spec's nearest rule reads one level lower than the console on 8 of the 43 rows: an exact half-level LOD, or a fractional ResourceMinLODClamp. LOD 1.49 reads level 1 on both. The AMD driver does not follow it. Through the runtime's own path (
vk_sampler_test,vulkan_sampler(decode(S#))), an S# LOD_BIAS of +0.5 onimage_sample_lzreads level 1, like the console, on the same gfx1036 and on an RX 7800 XT (both AMD 26.10.1). So on AMD hosts the S# case matches. On other hosts the result splits: Mesa llvmpipe (Mesa 23.2.1, LLVM 15.0.7) and an Apple M2 (macOS 26.4, MoltenVK 1.4.2) follow the spec's nearest rule — the samevk_sampler_testS# with LOD_BIAS +0.5 reads level 0 (on the M2 the same explicitimage_sample_lzwith bias 0 and -0.5 also reads level 0; llvmpipe switches to level 1 at 129/256, for LOD_BIAS and MIN_LOD alike), while NVIDIA reads level 1, like the console: an RTX 5070 (driver 610.88) switches at exactly 128/256. Intel is not measured here. -
Layout. gfx1036 lays a linear mip chain out smallest level first, each row padded to 256 bytes. Levels 6..0 of the 64-wide R32 chain start at dwords 0, 64, 192, 448, 960, 1984 and 4032.
tests/test_sampler_lod_probe.pychecks the descriptor fields againstcheck.pyandgfx10_descriptors.h, and the model against these levels, without a GPU. -
-
d3d12_com_test: drives the COM objects through their vtables. It also checks that a queueWaiton a fence the CPU has not signalled holds the GPU back. -
dxgi_swapchain_test: creates a Win32 HWND and exercisesrt::d3d12::create_dxgi_factory,IDXGIFactory4::CreateSwapChainForHwnd,IDXGISwapChain3::GetCurrentBackBufferIndex,GetBuffer+GetDesc(), backbufferCreateRenderTargetView+ clear + readback verification +Present, andResizeBufferswith 0 validation errors. -
d3d12_stateful_indirect_pixels,d3d12_stateful_indirect_multi_pixelsandd3d12_stateful_indirect_counted_pixels: positive D3D12-to-Vulkan graphics tests. Compare every readback pixel with both a direct-draw reference and a known pattern for each draw kind; the counted variant fills its argument and count buffers by GPU copy before use. -
d3d12_indirect_rt_test: validatesID3D12Device::CreateCommandSignature+ExecuteIndirectwith a GPUCountBuffer(vkCmdDrawIndirectCount,count = 0skipped andcount = 1rendered), a draw whose record asks for four billion instances (clamped on the GPU, section 4.7), and a native Vulkan counted-draw reference over the same suballocated argument/count offsets (count = 0leaves the clear colour,count = 1renders; it is independent of the D3D12 command replay); optionalVK_KHR_acceleration_structure+VK_KHR_ray_query(GetRaytracingAccelerationStructurePrebuildInfo, BLAS + TLASBuildRaytracingAccelerationStructure, and aRayQueryKHRcompute shader verifying hit vs. miss; clean SKIP on GPUs without RT). -
indirect_clamp_test: theExecuteIndirectargument clamp pass itself (section 4.7), with no game files: every argument kind (draw, draw indexed, dispatch, mesh dispatch) and the counted variants, in-range records bit-identical, garbage records bounded, records and counts pastmax_command_countempty, and the per-batch work budget saturating; dispatch records bounded by the device'smaxComputeWorkGroupCount(70 000 x 1 x 1 kept and run where the device allows it, cut and counted where it does not); clean SKIP without a Vulkan device. -
d3d12_gcl8_test: the publicID3D12GraphicsCommandList8surface:QueryInterfacefor its IID,OMSetFrontAndBackStencilRef(1, 2)with the recorded values, and the reference count around the query. It creates only an allocator and a list, so it needs no GPU or Vulkan loader. -
d3d12_depth_resolve_test: depth and stencilResolveSubresourceRegionof a 4x D32 or D24S8 target cleared with three overlapping values, whole and by rectangle, compared with the PC runtime on the layer's own adapter and WARP; the refused calls must failCloseand leave the destination as cleared. -
d3d12_vulkan_device_test: the Vulkan device behind the Xbox-ABI proxy, called the way the game will call it. It creates heaps through slot 14 and reads their start handles in RAX, creates a render target through slot 76 with the Xbox layout word, then creates views, records clears and barriers, executes and waits on a fence. Results come back through D3D12 itself (CopyTextureRegioninto a readback heap, thenMap): the render target, the depth and stencil planes, and a never-written texture (which must be zero). A second list uploads a pattern and copies it on: whole into a texture created inCOMMON, a boxed part into a smaller texture, a BC1 round trip, a 1D texture and a 1D-array layer, and a buffer region. A 4x multisampled render target is cleared through aTEXTURE2DMSview and resolved into a texture that is read back; the multisampled shapes D3D12 refuses are refused, and so is a resolve from a single-sampled texture.GetCopyableFootprintsis compared with the PC runtime's, and a short run repeats on a standalone device, the pathLEONIDA_D3D12=vulkantakes. That standalone run also covers heaps and placed resources: a castable list on a placed texture is cleared through an RTV in a cast format and read back against the host's answer, and refused lists match the host'sE_INVALIDARG(D3D-90). The comparison tests run against a PC D3D12 device: the layer's own adapter (the default adapter when the Vulkan device has no LUID or that adapter gives no D3D12 device), or the one named byLEONIDA_HOST_ADAPTER(warp, or part of an adapter's name; the adapter used is printed).d3d12_vulkan_devicepicks it throughruntime/test/d3d12_copy_compare.h;d3d12_copy_xfmt,d3d12_depth_resolve,d3d12_fence_events,d3d12_indirect_zero,d3d12_node_mask,d3d12_query_rulesandd3d12_resource_desc, which also compare with WARP, throughruntime/test/host_adapter.h. Some answers are the driver's choice, so pick the host side when two adapters disagree:GetResourceTilingsplits standard and packed mips differently on an NVIDIA, an AMD and a WARP host, and the test accepts any split.-
Copies against the host (D3D-46,
d3d12_copy_compare.h): the same scenario runs on the layer and on the host and the bytes read back are compared; a failing case prints its name, the region (subresource, mip, slice, plane) and the first differing byte. Every case uploads deterministic bytes into a texture and then runsCopyResource,CopyTextureRegiontexture to texture (an inner box to the origin, and the origin box into another array slice at an offset), footprint to texture (an inner box at an offset) and texture to footprint (an inner box at an offset into a readback buffer prefilled with0xcd), and reads every subresource back. Formats: R8, R8G8 SNORM, RGBA8 (UNORM, SRGB, typeless), BGRA8, R16 UNORM, RG16 and RGBA16 float, R32 UINT, RG32 UINT, RGBA32 float, R10G10B10A2, R11G11B10, R9G9B9E5, B5G6R5, B5G5R5A1, D16, D32, D24S8, D32S8 and BC1-BC7 (SRGB and signed variants included), as a 36x20 texture with three slices and six mips (odd mip sizes), 3D textures with boxes in depth, a single-mip single-slice texture and a one-block BC7. Buffers:CopyBufferRegionat odd offsets and sizes, aCopyResourceof a 4093-byte buffer, and an upload buffer straight to a readback buffer. Only the bytes inside a footprint row are compared (row padding is the driver's; a difference there is printed, not failed); every byte a partial copy must leave alone is compared. It found:R8G8_SNORM,R16_UNORM,R32G32_UINT,R9G9B9E5_SHAREDEXP,B5G6R5_UNORMandB5G5R5A1_UNORMtextures were refused (no Vulkan mapping); they map toR8G8_SNORM,R16_UNORM,R32G32_UINT,E5B9G9R9_UFLOAT_PACK32,R5G6B5_UNORM_PACK16andA1R5G5B5_UNORM_PACK16.- A texture-to-texture box on a block-compressed texture that reaches the padded edge of a mip (for example a
box of whole blocks over a 9x5 mip) was refused as
invalid_copy; the PC runtime accepts it.
Copies between different mips of one texture are compared too (mips 24, 12, 6, 3, 1; RGBA8, BC1, BC7): sizes that are no block multiple, boxes to a padded edge, and boxes that do not fit the destination, which both sides must refuse (the host at
ClosewithE_INVALIDARG, the layer at execution withinvalid_copy). It found:- Block-compressed copies into a mip whose size is no block multiple (a 0..8 box into a 6-wide mip, a 6x6
mip into a larger one, a 4x4 box into a 3x3 mip) were refused with
invalid_copy: the host copies whole blocks, and onevkCmdCopyImagecannot (its extent must be a block multiple or reach each image's edge). They are staged through transfer scratch now (above) and match the host byte for byte, as do a box 4..8 of a 6x6 mip into a 3x3 one and a 3x3 mip into a 6x6 one at (4, 4). Measured on an RTX 5070 Ti and an RTX 3060 (driver 621.24) and an integrated AMD Radeon(TM) Graphics (0x1002:0x164e, Vulkan driver 2.0.353), Windows 11, each against its own host.d3d12_state_map_testchecks the staged regions on the CPU.
Known gaps shown by it and by the formats, not fixed:
TEXTURE1Dresources are not supported by the layer (creation, footprints and allocation info refuse them), so 1D copies are not compared.- On a GPU with a native D24, a readback leaves the unspecified
X8byte of the depth plane untouched where the PC runtime writes 0; the comparison ignores it. Where the layer stores D24 as D32 (see section 3.2) it writes 0. A PC driver's copy flushes denormal float depth to zero, so the test keeps its values normal. ALEONIDA_HOST_ADAPTERthat matches no adapter fails the run instead of skipping the comparisons.
-
D24 against the host (
d3d12_depth24_compare.h,depth24_convert_test): the D24S8 row of the copy test above runs with random 24-bit words on every GPU, the Radeon 880M'sD32_SFLOAT_S8_UINTfallback included (72 regions, byte for byte, upload, readback and copies).d3d12_depth24_compare.hclears 5215 depth values (steps, half steps and the floats around them, powers of two, random) as a whole-view clear of a 4x4 texture (the first 160) and as one rectangle clear per value of a wide texture, with a stencil value, and compares both planes read back. The layer is checked against the reference (depth24_quantize), and against the host byte for byte where the host agrees with it; NVIDIA's host rounds some ties the other way (478 of 5215 values) and is logged as a host quirk, not a failure. It also clears anR24G8_TYPELESStexture through a typed D24 DSV (200 values, compared the same way), and reports whether shader-resource views of both planes (R24_UNORM_X8_TYPELESS,X24_TYPELESS_G8_UINT) write the T# of the texture's backing format (D3D-75): X24_8_32_FLOAT for the depth plane where the layer stores the texture asD32_SFLOAT_S8_UINT, 8_24_UNORM where the GPU has D24, and 8_UINT for the stencil plane. An SRV read is not compared with the host (no shader runs in these tests and the host's descriptor is opaque). It also runs an upload and readback under aSetPredicationthat skips copies, which the layer must still convert and which is compared with the host's unpredicated run.depth24_convert_testruns the compute pass on the GPU for all 16777216 words (to float, and back), 16777216 float bit patterns againstdepth24_quantize(with a 1 MiB range so the copy splits into 65 dispatches), and a pitched copy at an offset split by a 1 KiB range. It tests the pass, which needs no D24 absence, on whatever deviceVK_LOADER_DRIVERS_SELECTpicks; the layer's own D24 path (the D3D12 tests above) is used only on a GPU without D24 depth-attachment support, so run those with the AMD driver selected (the Radeon 880M, RADV).
-
-
d3d12_translated_draw_test: milestone M1.5 (D3D-53), the same path with translator output.- Shaders:
test/shaders/vs_m15.asmandps_m15.asmare hand-written RDNA2 (gfx1013). The build assembles them withllvm-mcand translates them withtools/rdna2spirv.pythroughtest/shaders/build.py.build.pyalso writes each one's synthetic FSSM program (; fssm-at/; fssm-datain the header) tofssm/and the translator puts its SHA-256 inspirv/index.json, so the layer's lookup is the one the game uses; the test loads that index as it is. An unknown program is refused. - User data: root parameter 0 is a descriptor table (
s8, the 32-bit VA of its first slot), parameter 1 four root constants (s9..s12: the draw's clip offset, and a bias for the PS), in the console's graphics layout. - Vertex fetch: the VS has no input layout. It
s_loads a V# the application wrote into a shader-visible slot and fetches position and colour withbuffer_load_dwordx4 ... idxen; the V# points at a DEFAULT-heap buffer in the arena. - Code base: the PS starts with
s_getpc_b64ands_loads four floats from offset 0x100 of its own FSSM program, so the layer must have uploaded that program at the push-constant code base (dwords 34-35). - Draws: a quad and a second V# over the same buffer, with different table slots and constants, into a
R32G32B32A32_FLOATtarget. Every value is a short binary fraction, so the comparison is bit for bit: 4064 of 4096 pixels are exact, and the 32 whose centres lie on the triangle's long edge are counted apart. - Zero-based ids: all draws use
StartVertexLocation0 andStartInstanceLocation0, sov0is the same with and without the translator's zero-based VS ids (#436, not in this tree: with its translator change applied the result was identical, checked on both GPUs). Both devices enableshaderDrawParameterswhere supported, which #436's shaders need. A non-zero base would differ (hardware: zero-based, the base in an SGPR), so the test avoids one.
- Shaders:
-
d3d12_method_variants_test: each variant against the method it wraps, on the device directly (the proxy's slot 76 is the Xbox texture method, notCreateCommittedResource3). It runs 12 creation cases (buffers on the three heap types, textures, a volume, a multisampled target, and three shapes the base refuses) through everyCreateCommittedResourcevariant, which must give the same result, description, heap properties andMapanswer. It runs the edge cases in the table above and compares them with the host's PC runtime when there is one; protected sessions are checked on the layer alone, and castable lists have their own success/refusal checks.GetCopyableFootprints1must matchGetCopyableFootprintsfield by field, including the failure answer. A texture fromCreateCommittedResource3is uploaded, copied back and compared on a queue fromCreateCommandQueue1. -
d3d12_sampler2_test:CreateSampler2againstCreateSampler, on the slots' bytes. It checks:- 10 descriptions without flags, which must be byte for byte the same;
- 6 UINT and float-bit border colours against their float equivalents (the three built-in UINT colours with
the integer mark, which must decode to
VK_BORDER_COLOR_INT_*); - custom float and UINT border colours registered in the table on
VK_EXT_custom_border_color(D3D-73), verifying index reuse for identical colours and distinct S# descriptors for distinct colours or integer vs float representations; - 3 non-normalized samplers, which must be
CreateSampler's S# withFORCE_UNNORMALIZEDset; - the
D3D12_OPTIONS17answer; - the 22 written-or-refused cases behind the table in section 3.2, compared with the host's PC runtime when there is one.
-
xbox_present_test:PresentXand the frame events (section 4.5, "what is implemented"), checked on swapchain pixels. there is one. A host that reports no non-normalized samplers is compared only on the 3 cases without the flag. The other 19 are then checked against their recorded answers only. -
d3d12_subgroup_test: subgroup size control through D3D12 PSOs, on the PSOs of the device proxy.- Shaders:
cs_w64x_readlane(av_readlaneacross both halves of a wave64) translated natively and with--wave64-emulate, andcs_wqm_w32, built bytest/shaders/build.py(needsllvm-mc:LLVM_MC). - Check: each is dispatched through a PSO found by FSSM hash and the eight words it stores are compared. The
PSO's request (
pipeline_subgroup_requests) must equal the decision function's. The native wave64 shader must be exact where the device can give 64 (AMD: required size 64 plus full subgroups) and is reported, not judged, where it cannot (NVIDIA); the emulated one must be exact everywhere. - Control: a second run with nothing requested is printed. On the Radeon 880M the default compute subgroup is already 64, so the wave64 controls are exact as well.
- Probes: GLSL shaders (
cs_sg_probe.comp,ps_sg_probe.frag,vs_sg_fullscreen.vert) storegl_SubgroupSize, so the size the driver used is observed for a wave64 entry, a wave32 entry and an emulated one. Where the PSO required a size, the observed size must equal it. For a wave32 compute shader on a device whose default is not 32, the control is asserted to differ (the request matters); a wave32 pixel shader on the 880M goes from 64-wide to 32-wide with the request. - Wave64 pixel shader:
ps_w64x_readlane.asm(v_readlaneof lanes 40, 5, 33 and 63) is drawn over 64x64 pixels through a graphics PSO into a float target, and every pixel must carry the four values derived in the .asm header where the PSO required 64: 4096 of 4096 on the 880M. The control is asserted to differ only where the default pixel subgroup is not 64; the 880M runs pixel shaders 64-wide by default, so its control is exact too. On the RTX 5070 the shader gets no 64 (0 of 4096 exact, not judged). - RX 6800 (RDNA2, AMD Windows driver 26.11.2, 2026-11-22): the compute requests take effect (wave32 compute
goes from 64-wide to 32-wide), but nothing can be requested for the fragment stage: the pixel probe runs at the
64-wide default for the wave64, wave32 and emulated entries (outcomes
device_default,unavailable,emulated), andps_w64x_readlaneis not judged; its control, at the 64-wide default, is 4096 of 4096 exact.
- Shaders:
-
d3d12_descriptor_test: descriptors through the proxy.- Copies, checked on the slots' bytes: one run, range lists of different shapes on each side, null size arrays, and a destination longer than its source.
- What views and samplers write, decoded: a view of an uploaded 8x8 texture and a sampler, mips 1 and 2 of a
BGRA cube with a component mapping, an unordered-access view (the same bytes as the shader-resource view of
that mip), and the null descriptors of a missing resource, a texture without
ALLOW_UNORDERED_ACCESS, a view past the mips and a volume. - UINT border colours (Vonsek's case on #538): an
R8G8B8A8_UINTtexture sampled one tile to the right throughCreateSampler2samplers with a UINT(0,0,0,0)and(1,1,1,1)border reads 0 and 1 in every channel. A float white border on the UNORM texture reads 255; its S# differs from the UINT white one only in the integer mark. - That set 0 holds them: a compute shader (
test/glsl/cs_sample.comp, GLSL, compiled withglslangValidator; skipped without it) is handed a slot's T# and the sampler's S#, looks them up in the hash table as a translated shader does, and samples. The sampler wraps in U and the shader samples one tile to the right, so a missed S# shows too: the fallback sampler clamps. The test creates the pipeline in Vulkan and binds the device's set. It reads the texture through the view's own slot and through a copy of it, and gets the fallback from a slot of bytes no view was made for and, after the texture is destroyed, from the view's own bytes. - Capacity: 5000 distinct SRVs of that texture and one more, and 2100 distinct wrapping samplers in two 2048-slot heaps. The last view through the last sampler reads the texture one tile to the right. With the sizes of before, both were past their arrays ("array is full") and the shader read the fallback.
-
d3d12_texture_uav_test(D3D-78): creates 1D, 1D-array, 3D and 2D control UAVs through the D3D12 device, checks rejected descriptors, copies descriptors between slots, and dispatches a translated hand-written shader from a Vulkan compute pipeline on the actual set 0, not through D3D12Dispatch. It reads back every texel; the UINT read/modify/write cases (not atomics) also run on Windows WARP. The D3D12 command-list path is used separately to flush the set and to test clears. The tests dispatch past the selected array/W range, so writes to an adjacent layer or slice fail the check. -
d3d12_compute_test: the compute path through the proxy. It creates a root signature from the PC serializer's blob, and a PSO through slot 62 from a container shaped like the game's, found in a translator-style index by its FSSM hash (an unknown program is refused). It sets root constants, a root UAV and a descriptor table whose application-written entry points at an upload buffer, then runs two dispatches that change s0 and the UAV in between. The results come back through a readback buffer. The shader,test/glsl/cs_user_data.comp, is GLSL written to the translator's push-constant and address contract, compiled withglslangValidator. It also checks:- the dispatches' root signature and PSO are released right after being set, and the same signature is set again after the arguments, so the list must hold both and keep the arguments (without the hold the test crashes);
- the index has an entry with set-0 bindings for the same program ahead of the binding-free one, and the PSO must take the binding-free one;
- a device that reports 128 bytes of push constants refuses the PSO.
-
d3d12_fspx_compute_test: the FidelityFX DLL's two ways of passing an FSPX program, with synthetic programs (fspx.md, "Build and run-time lookup"). A PSO through slot 62 from aDXBCcontainer whoseACCCpart is an FSPX payload, and one throughCreateComputePipelineStatefrom a bare kind-6 program, as the slot-67 description carries it. Both are found byfspx_code_sha256in<shaders>/fspx/index.jsonand dispatched once withcs_user_data.comp, which adds dword 1 of its code base: each must read its own kind-6 program. Ten inputs are refused withE_INVALIDARG: an untranslated program, bare and in a container; kind-6 entries that end past the payload, start inside the directory, wrap 32 bits, are too large or are empty; a container withoutACCC; bytes without the prologue; and the program with four bytes appended. -
d3d12_bindless_churn_test: the table churn of D3D-314 through D3D12 alone, on a direct and a compute queue with three frames in flight. Each of 96 frames makes 24 textures with SRVs in a ring of shader-visible heap slots and releases those of seven frames earlier (about 190 live keys, so the table grows), the direct queue uploads, the compute queue waits for it on the GPU, and each queue runs thecs_set0_sample.compshader eight times on SRVs of the frame and the three before it. All 98,304 sampled texels per run are compared with what the CPU wrote. The two D3D12 queues get distinctVkQueues where the device's family has two (queue_count_wanted = 2,command_queues; the test prints which it got and says so when the family has only one). Two queues on oneVkQueueare ordered by submission, which hides a missing wait between them. It runs four times: as the layer is (0vkDeviceWaitIdlefor the bindless set required, at least one generation made, a retired generation seen pending right after the submit that made it); with the compute queue never waiting on the direct queue's fence (it samples textures the CPU has seen finished, so only the grown table is new to it); and both again withLEONIDA_BINDLESS_IDLE_WAIT=1(the old wait, counted above 0). Times are printed, not asserted. The async runs are what the layer's wait on the uploading submission keeps correct: with that wait removed, the RTX 5070 run failed at frame 5 (compute read a zeroed table: the grown binding 2 with the upload not yet run), as @duudiis reported on #2740; the old-wait path shares that bug onmain(the idle wait only covers work already submitted, not another queue's later submission that binds the new table). The Radeon 880M did not reproduce it in two runs.d3d12_bindless_churn_validatedruns it under the validation layer. The table's growth is the only replacing flush this scenario produces (3 generations). The other kinds (a live key's index replaced, a relocation) and the failed-submit retry are checked at the Vulkan level byvk_bindless_testcases 3 to 6 (the set changes;release_retiredfrees only what its ticket allows). That test needs the translatedvs_ids,ps_texandps_imgatomic; it was not in ctest before D3D-314 (onlyscripts/run_gpu_tests.pyandcheck.pyran it), and is now, asvk_bindless_ps_texandvk_bindless_ps_imgatomic. without the prologue; and the program with four bytes appended. It also covers the dispatch state:- one program in containers with three kind-0 entries picks its own entry for each, an unknown kind 0 is refused, and the bare program is refused as ambiguous;
- slot 67 with all four pairs picks by kind 0 too (one entry's module is missing on purpose, so the pick shows as
E_FAIL), and four inconsistent pairs are refused before they are read; - slot 67 with the description built the way the DLL builds it (
dll_slot67: the reader's pair order over the container's own directory, kinds 0, 1 and 7 pointing into the payload, kind 6 copied into a 256-rounded buffer padded with0xcc) resolves each program to its own translation with its own state; - console slot 11 on a slot-67 and a slot-62 pipeline returns an object whose slot 3 points at the dword 0 and whose slot 4 gives 4 bytes; it releases to 0, and the pipeline's reference count is unchanged.
-
d3d12_set0_compute_test: set 0 from the compute bind point, through the proxy and D3D12 alone. The index entry of its shader lists set-0 bindings, so the PSO's layout holds the device's bindless set and replay binds it at each dispatch; nothing in the test binds it. Four dispatches oftest/glsl/cs_set0_sample.comp(GLSL written to the translator's contract) load a T# and an S# from two descriptor tables and sample one tile to the right in U:- two SRVs give their textures texel for texel, so the T# decides the image;
- 32 bytes no view was made for give the fallback image, one colour everywhere;
- a clamping sampler gives the texture's right edge, so the S# decides the sampler;
- a device without the bindless set refuses the PSO.
Removing the set-0 bind from the dispatch path makes this test fail (
VUID-vkCmdDispatch-None-08600, measured on llvmpipe);d3d12_m2_textured_testcovers the bind at draws in the same way. -
d3d12_draw_test: milestone M1, through the proxy.- Pipeline: a VS+PS PSO found by FSSM hash. The input layout is POSITION then COLOR, while the VS has them in the opposite register order, so a match by position would fail.
- Buffers: the vertex buffer is copied into the arena, and the index buffer is read from an upload heap.
- Draws: two indexed draws with different root constants and root CBVs, then a back-facing triangle that must
be culled. Each of these also checks a fix:
- the first draw uses a PSO with a second RT format and a DSV format, with neither bound (a variant);
- before the second draw, the same root signature is set again after the arguments, which must keep them;
- two more draws, through a viewport on the top-right quadrant, read COLOR per instance with step rate 0 (two instances that must both read element 0) and from an unbound slot (zeros).
- Second pass on the same target, cleared again: a full-screen triangle from a VS with no inputs
(
test/glsl/vs_fullscreen.vert), first in its submission so no vertex buffer was bound before it, through a viewport on the bottom-right quadrant; then, where the GPU haslogicOp, the red quad XORed over the blue top-left quadrant, which must read(255,0,255,0). - Refusals:
- PSOs that need wireframe fill, independent blend, a depth-bias clamp or depth clamping are refused on this device, which enables none of them;
- nine render targets is refused, at PSO creation and at
OMSetRenderTargets; - 0-byte and wrapping buffer sizes are refused, and a buffer or shader-visible heap larger than the arena runs out of memory;
- a draw with no viewport executes cleanly and draws nothing.
- Check: all 4096 pixels of the read-back target are compared. Where the red and green quadrants land also
checks the viewport flip and the winding. The test fails with any of these fixes undone: the rebind, step
rate and logic op show wrong pixels, the variant breaks
dynamicRenderingUnusedAttachments-08912, and the stride state breakspStrides-04913.
The shaders are GLSL written to the translator's contract (
test/glsl/vs_draw.vert,vs_fullscreen.vert,ps_draw.frag). -
d3d12_present_test: milestone M0. It opens a window and presents 60 frames, each one: reset the list, move the back bufferPRESENT→RENDER_TARGET, clear, move it back, execute, present, signal a fence. It then resizes the window and presents 10 more (70 in all), which recreates the swapchain, scales the blit and switches to unsynchronised presents. The presenter's capture copies every presented image back, and the test checks that the whole image holds the clear colour at the swapchain's size (after the first 60 frames, after the resize and at the end). Last, it reads the colour on screen with GDI when the window is in front, no other window lies over its centre (an always-on-top one can, even over the foreground window) and GDI can read the screen. On a GPU that does not drive the window's monitor (the UHD 770 with the desktop on an RTX 4080 SUPER) the desktop never shows the swapchain, so the test prints the pixel, does not assert it and says why. Under Wine's macOS driver it can't:GetPixelon the screen DC returnsCLR_INVALIDeven for a pixel GDI painted itself, and the window's own DC holds Wine's GDI surface (white), not the image presented through the Metal layer. There the capture checks are what confirms the colour.- The injected failures below make the runtime log
[rt] d3d12: present failedthree times (VkResult -1000001004 twice, then -1,VK_ERROR_OUT_OF_HOST_MEMORY). The test announces them on stderr first; they are expected and are not out-of-date presents from the driver (the closing line counts those). - The device and the presenter get their Vulkan functions through a driver double in the test. It forwards to the real driver, counts the presents the driver reports out of date (the frame counts allow for them), and tracks the binary semaphores alive.
- Through the double, the test reports one successful present as out of date (not counted) and one as suboptimal (counted).
- It fails the second per-image semaphore of a recreation: only the two acquire semaphores may remain, and a retry at the same vsync must make a complete swapchain.
- It fails one blit submission: the next four presents must go through without hanging.
- Run against the presenter before these fixes, the test fails at the frame count after the resize, where the driver reported a real out-of-date present (RTX 5060 Ti, driver 621.24).
- The injected failures below make the runtime log
Open: whether the game uses command-list flags, bundles, or ExecuteCommandLists with many lists at once. All
are supported by the IR; the trace will show which are hot.
3.3 One GPU address space
The shader contract is the constraint that shapes everything else. The translator computes:
host_address = heap_base + console_va
where heap_base is push-constant dwords 32–33 and console_va is an Xbox GPU virtual address the game writes
into a descriptor, a root argument, or a buffer. This applies to buffer, descriptor-table and shader-code
addresses. Image descriptors (T#) are hashed by the translator, not dereferenced, so an image's base can be a
separate key range (below). Most shaders also force the high dword of a descriptor-table pointer to zero (25,865
of the 26,503 in package 1.0.2.1, counted 2026-11-22; see "Descriptor-table high-dword truncation" below), so
shader-visible descriptor heaps must live below 4 GB in this address space.
The layer therefore owns the console VAs. It returns them from ID3D12Resource::GetGPUVirtualAddress and from
GetGPUDescriptorHandleForHeapStart; the game only sees values the layer chose. The design is:
| Piece | Design |
|---|---|
| Address space | Two ranges. A BDA arena holds buffers, descriptor heaps and shader code; its device address is heap_base. A separate image key range supplies unique console VAs for images; those keys are never added to heap_base. The arena's VkBuffer is created with all buffer usages the game can bind (uniform, storage, vertex, index, indirect, transfer) plus SHADER_DEVICE_ADDRESS, and its memory with VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT. |
| Buffers | A buffer resource is a range in the arena's single VkBuffer: offset = its console VA, size = the resource size. Buffer commands bind the arena buffer with that offset, so its device address is exactly arena_bda + offset; no per-resource VkBuffer object is needed. |
| Images | Each image gets a unique console VA key and has device-local memory with optimal tiling: a range of a 64 MiB block that other textures share (runtime/src/image_memory.h, VK-IMAGE-MEMORY-POOL), or its own VkDeviceMemory when it is a render target, a depth buffer, a CPU-visible texture or larger than an eighth of a block, or when device-local memory has no room for another block. A range goes back to its block when the last submission that could use the image has completed. One reused from an earlier texture is zeroed before the next submission that runs shaders, as a committed resource reads as zero. Blocks hold only optimal-tiled images, so bufferImageGranularity does not apply. Shader image access goes through the T#/hash table, so nothing dereferences the key. Keeping images out of the arena avoids forcing optimal-tiled images into the arena's memory type and keeps the arena sized by buffers, not textures. |
| Heaps and placed resources | CreateHeap reserves the requested size in the arena, so a buffer placed at a 64 KiB-aligned offset is that offset into the arena and its console VA is the heap's place plus the offset. A placed texture (1D, 2D or 3D) gets its own memory (a range of a shared block or its own VkDeviceMemory, above); one the title placed at its own address through the console's CreatePlacedResourceX (Xbox device slot 133) reports that title address from GetGPUVirtualAddress, as the console does — a title turns it into the CPU pointer it clears the texture through — while its pixels do not alias the title's pages yet. Any other texture answers a null VA, as on D3D12. Tiled (64KB_UNDEFINED_SWIZZLE and Xbox 0x101) 2D/3D placed textures (D3D-191) and multisampled 2D placed textures (D3D-222) share that backing, answer GetResourceAllocationInfo and GetResourceTiling, and check heap/offset alignments. Reserved buffers can use heap tile mappings (section 4.2). |
| Descriptor heaps | Shader-visible CBV/SRV/UAV and sampler heaps are allocated in the low 4 GB of the arena. RTV/DSV heaps are host-side only. |
| Shader code | Each FSSM blob is uploaded to the arena; its console VA is the code base. |
| Upload/readback | D3D12_HEAP_TYPE_UPLOAD/READBACK resources are separate host-visible buffers outside the arena. Their console VAs are only used by copy APIs; if the game binds one as a vertex/index buffer or reads it in a shader, the layer biases the view/descriptor by -heap_base so the shader's addition lands on the host BDA (ASSUMPTION; measured to fail for a V#, see below). |
Measured (XCL, retail title, PR #168): the console answers a placed texture's GetGPUVirtualAddress with the
address the title placed it at; the title clears a 256×256 R32_FLOAT texture through that value as a CPU pointer.
On the PC, where D3D12 answers 0 for a texture, that write went to address 0. XCL returns the title address when the
PC answers 0 and leaves buffers and resources with a PC address unchanged
(real.rs, PR
#168). Facts only: XCL is GPL-2.0-only and no code is copied. This layer
sets a slot-133 fallback texture's GetGPUVirtualAddress to the title address; the image itself still does not
alias the title's pages.
Non-arena buffers (upload/readback) can still be addressed by the shader without putting them in the arena: pass
console_va = host_bda - heap_base (mod 2^64) in root descriptors and vertex/index/indirect views, so the shader's
heap_base + console_va equals the host BDA. For descriptors, patch the V# base field the same way when the layer
copies or scans them. This relies on the game not using the raw VA for anything except shader addressing
(ASSUMPTION); if it does, the resource must move into the arena instead.
Measured (D3D-53, d3d12_translated_draw_test): the bias works for 64-bit root arguments (d3d12_compute_test: a root
CBV and a table slot that point at an upload buffer) but not for a V#. A V#'s base field is 48 bits
(dword0 and dword1[15:0]), and an upload buffer's console VA, its device address minus heap_base, is negative on both test
GPUs (0xffffffffffce0000 on the AMD Radeon 880M, 0xffffffffffedc000 on the RTX 5070 Laptop; the buffer's device
address lay below the arena's, an allocation-order fact of these runs, so it is not guaranteed either way). The shader
adds heap_base to the truncated 48-bit value, which is a wild address: the draw faults and the whole queue submission is lost
(the clear that came before it is lost as well). Any resource a game can put in a V# (a vertex, constant or structured buffer
behind a descriptor) must therefore be an arena range, whatever the allocator happens to do, upload and readback heaps included. Until the layer does that, the
translated-draw test fetches from a DEFAULT-heap buffer and does not draw from the upload buffer.
Measured (static, XboxBvhBuilder.dll): the BVH builder only takes destination addresses below 2^40. Its
validation function at 0xc8f0 loads DestAccelerationStructureData (the first field of the build description it
reaches through [rcx+0x68]) and checks it twice:
| Check | Instruction | On failure |
|---|---|---|
| 256-byte alignment | test r8b,r8b |
message "…must be 256-byte aligned…" |
| below 2^40 | cmp r8,10000000000h / jae |
message "…can not have more than 40b of address set" |
On a failed check it prints its message through OutputDebugStringW after a "D3D12 XDXR Error: " prefix, and then
throws E_INVALIDARG: a C++ exception out of the DLL, not an HRESULT return.
- The alignment rule is the public
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT. - The 40-bit rule has no PC counterpart.
Arena VAs (at most 4095 MiB, so 32-bit) pass. A VA biased from outside the arena does not: the negative upload-heap VAs above are at or above 2^40 as unsigned values. That is one more reason for the rule above that every buffer a console client can address is an arena range, whichever heap it comes from.
Title-chosen addresses. Two kinds of buffer address are the title's choice, not the layer's:
- device slot 133 (
CreatePlacedResourceX) puts a buffer at the CPU address of the title's own pages; - the title points root views and V#s at its own memory, for instance a per-frame constant ring (#8862, section
3.5 of
docs/retail_boot_chain.md).
On Windows these are user-mode addresses far above 4 GiB, past the arena (at most 4095 MiB, and descriptor
tables must stay below 4 GiB), so heap_base + VA names nothing the layer made (the D3D-53 failure above). The layer
therefore replaces such an address, wherever it sees one, by the console VA of a GPU copy of that memory
(runtime/src/title_va_alias.h):
| Where the address is | When it is replaced |
|---|---|
Root CBV/SRV/UAV (Set*Root*View) |
when the argument is set |
CBV and buffer SRV/UAV V#s the layer writes (Create*View, slot 70, counter V#s included) |
when the descriptor is written |
| Buffer V#s the title writes into a shader-visible CBV/SRV/UAV heap itself | before each ExecuteCommandLists, in place, for the tables the submitted lists bind and only the slots their root signatures declare |
The copies:
- A slot-133 buffer whose pages cannot be imported is the per-submission shadow, and the shadow is an arena
range when it fits. Its console VA is its arena offset, which holds in a root argument, in a V#'s 48 bits and in
a 32-bit table pointer alike. Without room in the arena it keeps its own memory and is biased like an upload buffer
(logged once; raise
LEONIDA_ARENA_MB). An imported slot-133 buffer is reached at its device address minusheap_base(mod 2^64): exact for root arguments, and for a V# only when the driver put the import above the arena (logged once otherwise). - Any other address in the title's memory gets a window: the 64 KiB-aligned pages it covers, clipped to the
title's range, copied into the arena now and before every submission, through the same shadow refresh as slot 133
(so dirty-page tracking for that refresh applies to both). A window never covers bytes an existing range already
serves: it stays inside the free span around the address (and a stream-pool extent inside the free span in both of
the pair's views), because a range entered over a live one replaces it whole, and the copy that range answered from
would be left reached by nothing. Windows stay while an address range still answers from them, up to
LEONIDA_TITLE_WINDOWS_MB(64 MiB by default). A window that no range answers from any more (a slot-133 buffer the title placed over its pages, or a BVH input's exact copy, replaced its ranges) is retired after the next submission's refresh: the alias table's listener records the removed ranges' copies, and a window none of its ranges is left for loses its stream-pool extent and its bytes of the budget at once. Its memory is freed once everyExecuteCommandListsreplay in progress then has recorded its submissions, every command list whose recording began before the retirement is gone (reset, released, or a held batch's or the async worker's copy of it run), and the submissions recorded by then have completed: a list resolves its root views when they are recorded, so one recorded before the retirement and executed, or executed again, after it still names the window (src/command_list_epochs.h). Until then its copy stays a target of its pages' tracker, refreshed like the others, and what the GPU wrote in it goes back to the title's pages: with its submissions' write-back, and once more when it is freed (a range noted when a list was recorded can be copied back before a held batch has run). A retired copy goes back only on the bytes no live copy over them changed, byte by byte (the window and the buffer that replaced it can each have written their own bytes of one 256-byte piece), and every copy is compared with the title's bytes as they were before any copy went back. The bytes a retired copy returns are also written into every other copy over them that still held the title's older bytes, as the next refresh would: a window is freed after its submission's refresh, and the range that replaced it reads its last bytes in that same submission.d3d12_title_window_orphanscovers it, with a writing batch held on a fence while the next submission's refresh retires its window. A window is not retired when its pages are released or remapped: a retail run measured no release at all of the pages windows cover (the title remaps its pool frames instead), and the tracker follows the pages. A tracker the window shared with a copy still live keeps its extent (a retirement never splits one). A window that cannot fit between the title's address reservations can use a separate mapped buffer. The buffer's device address must lie within reach of a V# base from the arena base: a positive offset below 2^47, or, when every loaded shader sign-extends the base, anywhere within 2^47 on either side (TitleBufferWindows::shader_reachable). The same window cap and dirty-page refresh apply.LEONIDA_STREAM_BUFFER_WINDOWS=0requires the window to fit in the arena. - What the GPU wrote goes back. The same return copy serves slot-133 shadows (a buffer the driver would not
import, a compute result the title reads again): the ranges are recorded through the alias of the buffer's pages and
the tracker there carries them back.
d3d12_placed_write_backcovers it. A copy is a read-side mirror, so a UAV or a raw write into a window would land in the copy and the title would never see it (#1537, theWRITE_INVALIDstop at the world start). Every title range a submission's bindings reach is kept, and the next refresh copies those ranges from the copy to the title's pages before it copies the pages forward, so a page the title itself wrote in between keeps the title's newer bytes and its GPU result is dropped. The copy back asks the write watch first (the refresh's own asking comes after it, so a hot page's last answer is a submission old), passes over pages whose mapping changed, that a kernel write may be filling or that xmem maps at another address too, and writes only the bytes where the copy differs from the title's (compared in 256-byte pieces): a read-only view writes nothing and its pages stay guarded. The copy runs under the tracker's lock and can still fault on a page another guard keeps read-only (the geometry watch, another view's shadow): the fault handler asks every tracker over the address, this one included, and on the thread whose copy faulted it does not take that lock again (an SRW lock is not recursive; on 621.40 the title's submitting thread hung there for good, the main loop frozen with no device loss). Up to 8,192 ranges and 64 MiB a submission (a V# has no read/write bit, so every view reached is compared; past the caps the ranges are left behind, logged once).LEONIDA_TITLE_WRITEBACK=0turns it off. A batch is fenced: it is kept with the ticket of the submission that will use it and copied back only when the context reports that ticket retired, so a range another submission is still writing is never read half done. A queue held deep (console ordering) can leave batches waiting: past 64 of them the oldest go back without their ticket, logged once. - A window that is refused (the budget is spent, the arena is full, or the pages are not committed yet) is backed
by a persistent geometry copy of exactly the requested range (
LEONIDA_GEOMETRY_MB) instead; when no copy can be made either, the view is written with no base and no records — loads return 0 and stores are dropped. A raw title address is never left in a V# or a root view:heap_base + a raw VAis not an allocation, and a store there loses the device. The refusal and the count of zero-size views are logged. - A stream pool (the title's CPU view paired with a 16-24 GiB GPU-only
alias) is not windowed per request. The GPU-only pages are translated to the CPU view of the same frames (rule B in
that note), and one mapping serves a page-aligned readable run of the pool (at most 1 MiB, and never past the
next mapping in either view; a geometry copy when the cap allows, a window otherwise). A request whose byte a
mapping already holds in either view is served by it when the mapping holds all of the request's bytes, and the
other view is entered as far as that mapping reaches. A request never gets a mapping shorter than its bytes (a V#'s
size, 64 KiB for a root view): one that runs into the next mapping, or past the end of the one holding its first
byte, gets one mapping over itself and every window it reaches, each whole, in both views (
title_pool_cover,TitleVaAliases::replace_twin), and those windows are retired at the next submission.replace_twinchecks, under the lock it replaces them under, that every range it would erase is one of those windows: a slot-133 buffer is entered without the window lock, so one placed in the span after the plan makes it refuse, the new window is dropped and the request falls back as below. Only with a range in the way that is not a window (a slot-133 buffer, a geometry copy) or that reaches past the pool in its view, or pages that are not readable, does it get a zero-size view: a refusal there would also have the root views a title rings through a pool read zeros where it served them before.vsharp_addressasks again, likeTitleVaAliases::resolve, when the range holding a V#'s base ends before the V# does. Both addresses of the pair are entered in the table, so a V# naming either reaches that one mapping instead of asking for a second one;LEONIDA_GEOMETRY_MBis the preferred backing. Acceleration-structure destinations and scratch also resolve through the table, and a structure no window holds whole gets a copy of its whole range, so the BVH builder's commands are recorded. LEONIDA_GEOMETRY_MBsets the device-local memory cap for streamed buffer views. The default is 0. A positive cap enables persistent copies of placed buffer SRVs and buffer descriptors in title memory. A GPU-only reservation uses its paired CPU mapping. Matching source ranges share one copy. The resource descriptor heap keeps its console indices and original CPU bytes. Its shader-visible copy encodes each resolved buffer's offset from the arena base. CPU writes through either physical mapping, file reads and XMem remaps invalidate the affected copies before their next submission. During an untyped heap scan, an extent above 16 MiB with no format or an unrecognized descriptor encoding reuses only an independently established geometry view. An explicit table or placed SRV can establish that view. The Vulkan memory probe reports populated views, payload and reserved bytes, upload totals, cap refusals and allocation failures.- Where the copies live: device-local memory through the BAR by default.
LEONIDA_GEOMETRY_HOST=1puts them in system memory outside VRAM (write-back where the device offers a cached host type,=2write-combined), as VIctory keeps its copies of title memory (approach only). In a world run on the RX 7900 XTX the copies held 4.4-6 GB of VRAM. The cost moves to the bus: the GPU reads every vertex and index of a copy from system memory, so a geometry-heavy pass can take longer; measure frame time with and without it before making it a default. - When a copy goes: a view is retired when its title range is freed, decommitted or unmapped. A remap of
physical pages retires nothing: the copies follow the new pages through the refresh. A retired
view leaves the lookups at once, its alias ranges and translated heap slots are invalidated, its stream-pool
extent is forgotten, and its memory is freed only after every ExecuteCommandLists replay in progress at the
retirement has recorded its submissions and those have completed (
kAfterExecutes). Before it leaves the refresh it is copied once more from its pages if they are still readable (a heap block freed in memory that stays committed). The next view of the range makes a new copy.geometry_views_testcases 14-16 cover this without a GPU.
- Where the copies live: device-local memory through the BAR by default.
- Which pages changed since the last refresh: where xmem reserved the title's memory with
MEM_WRITE_WATCH(XMemVirtualAlloc's ordinary regions and the title'sVirtualAllocreservations, not placeholders or physical-page windows), the kernel says (GetWriteWatchwith reset, its answers kept for every copy over the page:leonida::title_write_watchinruntime/src/title_page_watch.h); elsewhere a copied page is made read-only and the title's first write faults (ShadowPages).LEONIDA_WRITE_WATCH=0guards everything; under Wine that is the default and=1turns write watching on. A reservation the title releases and reserves again (at the same address too) is new to every copy, all of it taken as written once. The title's ownXMemGetWriteWatchandXMemResetWriteWatchrefuse a reservation write-watched for the copies, as the host refuses one that isn't. The write-fault handler waits for the trackers' locks while the faulting thread may hold the process heap's lock (the title'sXMemAllocblocks are_aligned_malloc's), so the state changed under those locks allocates from a heap of the runtime's own (leonida::host_heap), never the process heap. - What the GPU wrote into a copy stays until the title changes the bytes under it. Some pages are copied at
every refresh without a sign that the title wrote them (mapped at two addresses, left writable, reopened with the
64 KiB around a written page, write-watched or pinned); copied whole, they overwrote a value a compute program had
stored in the copy for the next frame with the title's unchanged bytes, so it read back as the title's old value
every other frame.
ShadowPageskeeps a 64-bit sum per 256-byte piece of the bytes it copied last (runtime/src/shadow_keep.h) and copies a piece only when the title's bytes differ; a piece zeroed because its page went away is copied again in full once it comes back. Limit: a title that writes the same bytes again to reset a value the GPU changed is not seen (that needs the GPU's writes to reach the title's pages).LEONIDA_SHADOW_KEEP=0copies every page as before. - Only the title's memory gets a copy: the blocks and ranges the xmem shims hand the title (
XMemAlloc,XMemAllocDefault,XMemVirtualAlloc, the title'sVirtualAlloc). An address anywhere else, the runtime's or a host DLL's memory included, is left as it was and counted, as is an arena VA or a buffer the layer made.
The title's own VA is still what GetGPUVirtualAddress answers, and vertex, index, copy and immediate-write calls
still resolve it through the buffer VA index, which knows slot-133 buffers by that VA. The copies are one way: what
the GPU writes into a copy does not reach the title's pages. A pointer the title hides elsewhere (a raw VA inside its
constant data that a shader dereferences) is not seen by the layer and keeps the title's VA.
Why not give each buffer its own BDA and set heap_base = 0? Because 25,865 of the 26,503 shaders (97.6%)
truncate descriptor-table pointers to 32 bits, and host BDAs are not guaranteed to be below 4 GB. The arena keeps console VAs low and stable.
Why one arena rather than several? Because the shader gets exactly one heap_base for buffer, descriptor-table and
code accesses. A draw can reference a descriptor table in one heap and a vertex buffer in another; both must
satisfy the same heap_base + va equation. Several non-contiguous VkBuffers cannot provide that equation.
Image keys are 256-byte-aligned byte addresses. The RDNA 2 ISA, §8.2.6, Table 45 defines
the 40-bit T# base field as address bits 47:8. gfx10_descriptors.h encodes bits 39:8 in word 0 and bits 47:40
in word 1[7:0]. The largest representable key is 0xFFFFFFFFFF00 (2^48 − 256 bytes). Bit 48 is not stored,
so keys separated by 2^48 bytes produce the same base field.
The runtime allocates image keys from 0x100000000 (4 GiB) in 256-byte steps, above the 4095 MiB arena cap.
Open: whether any shader in the game uses an image VA as a raw pointer rather than through its T#.
Memory type policy. The first boot needs correctness, not bandwidth:
- M0–M3: allocate the arena as
HOST_VISIBLE | HOST_COHERENT(preferably alsoDEVICE_LOCALwhen large BAR is available). The CPU can then write descriptor heaps, shader blobs and uploaded buffers directly. Images are already device-local, so rendering still uses fast memory for textures. This is slow for dynamic buffers but removes staging and host/console address translation from the bring-up path.- A memory type is only tried when its heap can hold the whole allocation (
memory_type_orderinruntime/src/vulkan_memory.h, beside D3D-96'sresizable_bar). Without Resizable BAR the onlyDEVICE_LOCAL | HOST_VISIBLEtype sits in a heap of 256 MiB or less (214 MiB on an RTX 3090 with driver 616.56), so the 256 MiB default arena lands in system memory there. Asking that heap for it broke VUID-vkAllocateMemory-pAllocateInfo-01713 even though the driver returnedVK_SUCCESS(reported by CharlyRien). - With Resizable BAR a driver can still leave the
DEVICE_LOCAL | HOST_VISIBLEtype out of a large buffer'smemoryTypeBits. On an RTX 5070 Ti (NVIDIA 617.42, Windows 11) an arena-shaped buffer of 4,090 MiB may use it and one of 4,092 MiB may not, soLEONIDA_ARENA_MB=4096(4,095 MiB) put the whole arena in system memory.create_arenatries smaller sizes in 16 MiB steps, by at most an eighth, and keeps the largest whose requirements allow that type and fit its heap. Placing the arena in ReBAR does not guarantee a reduction in host commit. An RTX 4080 comparison confirmed ReBAR placement and measured higher process private bytes. The runtime logs the size cap:GPU address arena: 4080 MiB of the 4095 MiB asked for, capped by the device's Resizable BAR memory types. Without Resizable BAR nothing changes.
- A memory type is only tried when its heap can hold the whole allocation (
- M4+: allocate the arena
DEVICE_LOCALand stage CPU writes (descriptor heaps, shader blobs, buffer uploads) through a host-visible staging buffer, copied before the commands that use them (runtime/src/arena_staging.h,LEONIDA_DEVICE_LOCAL_ARENA=auto|1|0).- In
automode (the default), when the arena does not fit inDEVICE_LOCAL | HOST_VISIBLEmemory (e.g. discrete GPUs without Resizable BAR where BAR1 is 256 MiB or less) and both a pureDEVICE_LOCALVRAM type and aHOST_VISIBLE | HOST_COHERENTsystem-RAM staging type fit,arena.bufferis allocated in pureDEVICE_LOCALVRAM andarena.mappedpoints at theHOST_VISIBLE | HOST_COHERENTstaging mirror (arena.staging_buffer). On GPUs with Resizable BAR or unified memory,autokeeps the zero-copy single buffer;LEONIDA_DEVICE_LOCAL_ARENA=1forces the staged path for testing, andLEONIDA_DEVICE_LOCAL_ARENA=0keeps the single host-visible arena. - Overflow
TitleBufferWindowsslabs outside the main arena are budgeted byLEONIDA_EXTERNAL_WINDOWS_MB(default 4096 MiB total when staged — counting both VRAM and host staging mirror — or 2048 MiB when unstaged). Empty slabs beyond one spare are reclaimed. - CPU writes into
arena.mapped(ShadowPages, console and standard shader-visible descriptor heaps, shader blobs,write_arena_value, geometry leases, placed/committed buffer init andMap/Unmap) are tracked at exact byte granularity (never rounded up to 4 KiB pages, so flushing a 256-byte shadow piece or 32-byte descriptor never overwrites neighboring GPU writes on the same page), coalesced, and uploaded with batchedvkCmdCopyBufferplus cross-queue timeline synchronization before each submission. GPU-to-CPU readbacks (write_back_titles, retired shadow write-back, readable placed-bufferMap(),read_arena) subtract any unflushed dirty spans before copying back viaVulkanContext::copy_buffer_sync().arena_staging_test(CPU) covers the policy and dirty tracker. - The hash table is not in the
arena either: it is a normal storage buffer in
DEVICE_LOCALmemory, uploaded from a mapped staging copy before the commands that read it (D3D-76).
- In
- Upload-heap buffers prefer
DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENTmemory when the GPU has Resizable BAR (D3D-96): the CPU writes them through the BAR and the GPU reads them from VRAM.leonida::resizable_bar(runtime/src/vulkan_memory.h) calls it Resizable BAR when such a type sits in a device-local heap larger than 256 MiB. Without Resizable BAR that type lives in a window of 256 MiB or less (214 MiB on an RTX 3090) that every upload buffer would share, so they stay in system memory. If VRAM is full, the allocation falls back to system memory. The device logs which one it uses ([rt] d3d12: upload heaps in ...), andLEONIDA_UPLOAD_SYSMEM=1keeps them in system memory to compare the two. Readback buffers keep preferringHOST_CACHED. - Textures and default-heap buffers outside the arena prefer
DEVICE_LOCALand need no host access. When VRAM is full they still get memory, from the next typememory_type_orderlists, which is system memory. The first one that does is logged once ([rt] d3d12: a N-byte allocation did not fit in device-local memory ..., D3D-299,leonida::spilled_to_host), so a run on a 4 GB GPU shows that it spilled (#2375).
Capacity. The arena is sized by buffers, descriptor heaps and shader code, not by textures. The allocator
tracks the high-water mark; start with a configurable capacity (for example 4 GiB for the loading/menu path) and
fail with a clear message when a console VA would fall outside it. Growing means creating a new arena, copying,
and updating heap_base for all subsequent commands; do it at a frame boundary, never with work in flight.
Open: the game's real buffer VA range and peak working set are unknown until it runs. maxBufferSize (with
VK_KHR_maintenance4) and maxMemoryAllocationSize bound the arena; a large open-world buffer working set may not
fit on smaller PC GPUs. This is a product requirement, not something the layer can hide.
Reserved resources. CreateReservedResource and the queue tile APIs use Vulkan sparse binding for buffers and
compatible single-mip RGBA8 2D textures (section 4.2). Other descriptions have fully allocated backing. Wider
texture coverage and the game's use of tile streaming remain open.
Diagnostics for descriptors the title builds itself (all off by default, logging only unless said otherwise):
LEONIDA_UNKNOWN_TSHARP=1: one line for each distinct base address a title-written T# names with no texture there (its shape, the tiling bits and whether the address is title memory), up to 300 addresses, and every 8192 such lookups a summary by format, type and tiling.LEONIDA_UNBACKED_VSHARP=1: the buffer V#sfix_vsharpwrites empty because nothing backs their base; one line for each of the first 120 distinct bases and every 8192 a summary by 4 GiB range of the base.LEONIDA_UPLOAD_LOG=1(d3d12_xs_device.cpp): each upload chunk (CPU base, device address, size) and the first 96, then every 8192nd,AllocateUploadMemoryresult as an offset into its chunk.LEONIDA_UPLOAD_ALIAS=1(an experiment, changes behaviour): enters each upload chunk's CPU range in the title VA table, so a V# the title wrote with the CPU pointerAllocateUploadMemoryhanded it is rewritten to the chunk instead of left empty. A chunk below the arena needsLEONIDA_IMPORT_BELOW_ARENA=1as well.
Address guard (LEONIDA_ADDRESS_GUARD=1, rdna2spirv.py --address-guard)
Prototype, off by default.
Why. The layer rewrites the addresses it can see: root views, the V#s it writes, and the V#s the title writes into
shader-visible heaps. It writes an empty V# when nothing backs an address (above). The translator checks a V#'s
record count but not its base. Any other address becomes heap_base plus an arbitrary value:
- a V# a shader builds in SGPRs from data;
- a raw
global_/flat_address (530 of the 26,503 shaders of package 1.0.2.1, 69 of the 2,684 pipeline-library programs); - a stale or offset-like value.
On RADV such an access page-faults. Two RX 7900 XTX runs (Mesa 26.3.1, under Wine) ended with the same sequence:
- a
gfxhubfault from client TCP with PERMISSION_FAULTS 0x3; - a compute-ring timeout and "MES failed to respond";
- a MODE1 reset ("VRAM is lost").
Both faults were 4.8 GiB and 20 GiB above heap_base, past the arena's end.
"Inside the arena" is not the right bound. Several buffers are legitimately outside it, at a positive offset from
heap_base (a negative one with LEONIDA_IMPORT_BELOW_ARENA=1):
- geometry copies;
- upload and readback buffers;
- imported title memory;
- separate window buffers.
The guard checks each access against what the runtime actually backs. An access that fails reads 0 and drops its
store, so a wild address never reaches the GPU. The overall process follows VIctory
(crates/victory-gpu/src/memory.rs, GPL-3.0). Its page table of 64 KiB pages
routes every computed address, and memory no copy holds reads 0 and takes no writes. The structure below is our own:
VIctory's table names descriptor views, this one is a bitmap over device addresses.
Structure: a two-level page table of 4 KiB pages over the 48-bit offset space, behind an arena compare. The
check works on the heap offset, the sign-extended 48-bit value Gen.host_addr adds to heap_base:
- Level 1: 65,536 words indexed by offset bits 47..32. Each word names the level-2 block of one 4 GiB chunk.
- Level 2: blocks of 32,768 words, one bit per 4 KiB page (bits 31..12).
- Two fixed blocks: block 0 is empty and block 1 is full; allocated blocks start at 2.
- Size: the table is a host-visible buffer of its own, 256 KiB plus 128 KiB per block (8.25 MiB for 62 blocks).
Why this structure:
- Pages of 4 KiB are the GPU's own mapping granularity. A page any byte of a backing touches is mapped as a whole, so marking pages outward is exact for faults. A 64 KiB page would mark memory that may not be mapped.
- Level 1 by 4 GiB chunk covers the whole signed 48-bit space (negative offsets index from 0x8000 up). A real run touches a handful of chunks, so the table stays small.
- Other structures cost more per access. A sorted range table needs a binary search: about 10 dependent loads for a thousand backings, against 2 here. A coarse region bitmap plus a fine range table needs a search in the fine part.
- The arena needs no lookup. It is one fully bound
VkBuffer, so any offset below its size passes on a compare. That is the common case: descriptor heaps, default-heap buffers and windows in the arena.
The header. It sits at arena offset 0x70000, after the zero page and the quad indices, and holds:
- a 64-bit magic (
"LGUARD01"); - the arena's size (the compare's limit);
- the table's address minus
heap_base; - a refusal count and the last refused offset, which the shaders write.
Two sinks follow the header: 0x71000 (zero area, what refused loads read) and 0x78000 (dump area, where refused
stores and atomics go). None of [0x70000, 0x80000) is handed out. With LEONIDA_ARENA_NULL_MB the range lies in the
null region, so its offset never moves. runtime/src/address_guard.h and tools/address_guard.py (the Python
reference) hold the format.
Each access. Gen.host_addr takes the access kind (load, store or atomic) and its span. Under --address-guard
it calls one function per module, %guard_fn, which is straight-line at the call site, so no caller's block
structure changes. The function computes end = offset + span - 1 and then decides:
- Passes on a compare: the runtime's guard is off (no magic), or
offsetandendare both below the limit. The result isheap_base + offset. The cost is a 64-bit add, two 64-bit compares and a select. - Otherwise, a lookup: the bits of the pages of
offsetand ofend. That is two independent pairs of dependent 32-bit loads (level 1, then level 2). - Refused: an access whose bits are not both set adds 1 to the header's count, writes its offset, and goes to the zero area (a load) or the dump area (a store or atomic), at its offset within its page. Alignment is kept, and every span fits inside a sink.
- Atomics run on the dump area, and their returned value is replaced by 0 (
Gen.guard_zero). The CAS loops (float min/max, inc/dec) end there too, as on any other memory.
The entry block reads the header's first six dwords once per invocation, from the arena, so that read is always
backed. When the base is uniform, as for s_load, s_buffer_load and a V# from SGPRs plus a uniform offset, the
compiler keeps the whole check scalar: one check per instruction, not per lane. A per-lane address (global_ with a
VGPR address, offen/idxen) is checked per lane, and the slow path runs only for lanes outside the arena.
What is checked. Every heap_base access goes through host_addr:
- buffer loads and stores (dword, sub-dword, typed, format; swizzled spans are computed at run time);
global_loads, stores, sub-dword and atomics;- buffer atomics,
_x2included; s_loadands_buffer_load;- the BVH node reads of
image_bvh*_intersect_ray(span by node type).
These are not checked:
- images (T#s go through the hash table, not an address);
- LDS;
- the
--mesh-computeoutput buffer (a runtime address); s_getpccode reads.
The translator does not translate flat_ instructions (they raise Unsupported), so none reaches memory today. A
translation added later must go through host_addr like global_ does.
Keeping the table current. The spans are the same backings the console heap pass's backed table uses
(update_gpu_backed):
- every
gpu_backingsentry outside the arena (upload and readback buffers, imports, slot-133 buffers, windows outside the arena); - the geometry copies' blocks;
- the separate window buffers' blocks.
update_address_guard runs in the queue's before_execute, after the heap refresh, the windows and the geometry
copies. It differs from that table in four ways:
- It rebuilds whenever
backing_generationor a block layout changed, with no 100 ms limit, because a backing made since the last submission must not read 0. - It writes only the words that changed, level 2 before level 1.
- A chunk keeps its block for good, so a submission still in flight never reads a block that now means another chunk.
- When the 62 blocks run out, a new chunk gets the full block (unchecked, as without the guard), and that is logged.
A release clears its bits at the next submission. D3D12 forbids releasing memory the GPU still uses, so only a wild access in flight at that moment could still pass.
Cost per access:
- Fast path: about 8 scalar or vector ALU operations.
- Outside the arena: about 40 operations and 4 loads, from a table small enough to stay in cache.
- Per invocation: 6 uniform header loads.
- Per submission (runtime): nothing until a backing changes, then a rebuild of the used blocks (128 KiB each) and a diff.
Switches.
--address-guardrecords"address_guard": trueinindex.json.LEONIDA_ADDRESS_GUARD=1makes the runtime reserve the range, create the table and write the header.- Either alone does nothing: a guarded module on a runtime without the guard finds no magic, and every access passes after one compare.
- Without the flag the module is byte for byte what it was.
What a run with the guard shows.
- One line when the device is made:
[rt] d3d12: address guard on .... - At most one line a second:
[rt] d3d12: address guard: N access(es) refused so far (+k), the last at heap offset 0x.... Each refusal is a wild access that would have reached the GPU. The offset says where to look (above the arena's end, as in the two faults). - A run that reset the GPU before should keep going, with wrong pixels where a refused access mattered.
Risks and open points.
- A refused access that mattered (a backing the layer never registered) now reads 0 instead of faulting. That is silent apart from the count.
- An access is checked as a whole. A multi-dword load whose first dwords are inside a V# and a backing, but whose last dword is past both on an unbacked page, reads 0 in full.
- The table is read through the GPU's caches. A page whose bit changes while a submission is in flight can be seen either way by that submission.
- Sparse buffers outside the arena are guarded only if they are registered as backings.
Checked:
tests/semantic/test_address_guard.py: the fixturecs_address_guardwith the guard on, with it off at run time and without the flag, throughspirv_mini_interp; the kind and span of each instruction family; the table model; the constants shared by the translator, the runtime andtools/address_guard.py.runtime/test/address_guard_test.cpp: the page table, incremental writes, negative offsets, wrap, chunks and overflow.scripts/run_address_guard_gpu_test.py: the fixture on a 2 MiB heap whose table backs one page outside the "arena". Every address it touches is inside the buffer, so no run can fault. With the guard on, the refused loads read 0 although memory is there, the store and the atomic land in the dump area and the count is 6. With the guard off, the same module reads that memory. It passed on lavapipe (Mesa 26.3.1).- Corpus (package 1.0.2.1, 2026-11-26):
--shard 0/8of the shaders: 3,313 translated and 3,313spirv-val-valid, with the guard and without.- The pipeline library: 2,683 of 2,684 translated and valid, with the guard and without (the same one fails either way).
- Without the flag, every module is byte for byte the same as before the change.
- With it, the SPIR-V grows by 1.8% (shaders) and 1.6% (library).
3.4 Descriptor heaps and the bindless model
The game can use D3D12 descriptors in three ways, and the layer must handle all of them:
- Root descriptor tables.
SetGraphicsRootDescriptorTablesupplies a GPU handle; the shader receives the table's console VA in its user data and loads T#/S# structures from it. - Direct heap indexing. The root signature has
D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDand/or..._SAMPLER_HEAP_DIRECTLY_INDEXED, and the shader indexesResourceDescriptorHeap/SamplerDescriptorHeapdirectly. The console driver supplies the bound heap base and stride; the shader loads the descriptor atbase + index * stride. Measured (D3D-329): each heap base arrives as a 32-bit pointer in an input SGPR the shader reads directly, inside the user data for compute; no stride arrives at all.tools/heap_index_census.pyover the 1.0.2.1 corpus (26,503 listings; 1,473 with embedded data words skipped) follows every descriptor-widths_load_dwordx4/x8/x16back to the SGPRs it starts from. Of 770,412 such loads, 769,366 (99.86%) start from an entry SGPR used as a 32-bit pointer (high word a constant 0), 0 from a pointer loaded from memory, and 1,041 could not be followed (0.14%, all but 63 in heap-indexing shaders). That holds for the 18,066 shaders whoseSFI0sets either heap-indexing bit as much as for the 6,964 that set neither. The heap-indexing shaders add a base read with a run-time offset (the heap index): for examples10in CS,s23in MS ands15in PS for the resource heap, and a separate base for the sampler heap (s11in CS,s24in MS,s16in PS). For compute this is settled: every base lies below the shader'sCOMPUTE_PGM_RSRC2USER_SGPRcount, so it is user data. For VS, PS, MS and GS no user-SGPR count is measured; every base lies belows32and none is the NGGs3, so they are user data under the translator's 32-SGPR assumption, and the user count of the graphics stages (question 3 in the table below) is what would confirm it. Which SGPR holds which heap varies with the stage and the root signature, so placing the bases belongs to the root-signature mapping, not to a new translator input. No stride is read at run time: static offsets of T# loads are multiples of 32 and of S# loads multiples of 16, so the stride is compiled into the code. In the runtime shim,CreateRootSignaturerecords theCBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDandSAMPLER_HEAP_DIRECTLY_INDEXEDroot-signature flags andSetDescriptorHeapstracks the bound shader-visible heap GPU bases. A matched compute root signature and dispatch settle the resource base for the Prop and Tree BatchCull programs. Their two explicit tables and one constant occupy s4, s5 and s6. Both programs read the resource heap from s7, the next user dword. Supply its arena-relative byte address in push-constant dword 7. The shader zero-extends this dword and adds the 32-bit resource index shifted left by five. A 32-byte slot contains a four-dword buffer descriptor or an eight-dword image descriptor. The host arena BDA remains in dwords 32–33. A matching runtime trace found s7 zero with the resource heap bound. The PreSkin compute programs use s9. Graphics examples with resource-direct indexing include PS_NoStripImmutableTable at s11 and VS_TransformD at s12. Their shader inputs establish the destination dwords. The explicit graphics layouts and ordering for signatures with spills still need independent root-signature evidence. Inline compute layout (integration #984). Runpython -I tools/compute_heap_layout_census.py <carve>/disasmon each compute carve. Of 5,450 indexed compute entries, 2,959 advertise direct indexing and none of those embeds its root signature. Adding--group fspx_compute --dispatch-log <dispatch-log>joined seven resource-indexing entries to independently recorded layouts. In all seven, a dynamically indexed resource descriptor used the first SGPR after the explicit arguments. There were zero mismatches and zero cases without room among those seven. For the remaining 2,952 entries the layout is unknown. These are entries across carves, which can contain the same program. No sampler-indexing entry had a matched layout. Putting the resource heap first when both flags are set, then the sampler in the next dword, remains a hypothesis. D3D-329's adjacent SGPR examples alone do not establish it. The runtime snapshots the bound resource and sampler heap pointers in that order after the explicit arguments for direct and indirect compute dispatches with an inline signature. Bound console descriptor heap base addresses are remapped throughconsole_descriptor_table_vaso that user SGPRs receive the arena copy's shader virtual address (where GPU descriptor reads land, preventingREAD_INVALIDdevice loss during world load), while unshadowed host heaps remain unchanged. An unbound heap contributes zero, and rebinding affects later commands. A heap that cannot fit in the inline user data is reported once, and a signature whose compute arguments spill gets nothing written (logged once). SetLEONIDA_COMPUTE_DIRECT_HEAPS=0to restore the previous compute arguments. Draws do the same in the graphics layout (pack_stage(Stage::Pixel), from s8, one dword per table): the resource heap's 32-bit shader VA goes in the dword after the explicit arguments, then the sampler heap's, each only when the signature has its flag, snapshotted per draw. Vertex, pixel and geometry shaders share one user-data block and that layout, so one write serves all three; a signature whose explicit arguments take s8..s10 gives s11, one whose arguments take s8..s11 gives s12 (the two program reads above). A mesh shader reads push dword d as s(d + 8) through its root window (section 3.5), soDispatchMeshrecords the same dwords and the mesh stage finds the resource heap at s(16 + end − 8), right after its arguments from s16, where DadaCap reports every directly indexed program of the retail library reads it, for compute from s4, VS/PS/GS from s8 and mesh from s16 (issue #14, comment 7143020922, on aboot-prototyperun; not reproduced in this repository). A mesh signature that fills the window leaves no room there: a heap past s31 of the mesh shader (push dword 24 or later) is logged once. A signature that keeps the s0 graphics layout, or whose arguments fill s31, gets none (logged once).d3d12_graphics_direct_heaps_testchecks the recorded draws and reads back what vertex and pixel shaders saw with and without the flags. On a mesh-capable device it also checks the heap pointers read by the mesh and pixel stages after a rebind.d3d12_mesh_testchecks the recorded dwords for a vertex draw, a resource-only rebind, a signature ending at s30 and one on the s0 layout. SetLEONIDA_GRAPHICS_DIRECT_HEAPS=0to restore the previous draw arguments. Missing console V# backing leaves a zero descriptor in the copy. Each V# half of a console resource heap's copy (the buffer V# and the UAV counter) has a record in host RAM of what it resolved to: the title's base and span, the device address its copy names, and whether it resolved or waits (src/console_heap_slot_records.h, written only byfix_console_slot). Two indexes, by base and by target, hold the halves by their exact range: halves naming the same range share one group (with a resolved and a waiting list, each half's place in it kept, so a half moves or goes in O(1)), and the groups are ordered by start per power-of-two class of their length. A change visits exactly the halves whose range overlaps it; an addition visits the waiting halves whose range starts inside it, since a V# resolves only through a backing, alias range, copy or title memory that holds its base (title memory is told as the merged range that holds it); each half once per index in a submission, however many changes name it. The groups compared to find them are those plus, for a removal, per class, the ones that start less than one class length before it and end before it. Releases (a backing, a title-window or geometry block), alias ranges removed or replaced (TitleVaAliasestells its listeners as it happens,forget_copyincluded) and additions (a backing, an alias range, title memory) go on an unbounded per-device list; at the next submission each heap fixes again exactly the slots whose records a change touches: a release or removal every half naming it, an addition the waiting halves whose base it holds. Nothing walks the heap or reads the copy for this. A zeroed range, a slot the title rewrote and a heap destroyed drop their records.console_heap_slot_records_testchecks that a release of a buffer 10 of 60,010 slots name looks at those 10, that a 40-byte release among 300,000 slots packed into 74 blocks of 64 KiB looks at the 3 it overlaps, and compares the copy with a full re-resolution through random writes, releases, additions and alias changes. A title-written T# has a record too, under the exact base address it names (bind_title_imagelooks textures up by that address, or by the other view of texture-pool memory): bound, or waiting for a texture there (no texture, or one whose type, samples, mips, layers, image or views do not fit the T#), or waiting for room in its bindless array. A texture registered, replaced or published at an address (note_image_address, a title texture's placement, a streamed texture's image), or gone from it (forget_image, a placement removed), goes on the same list, and the next submission fixes again exactly the T#s naming that address; freed bindless entries fix the T#s waiting for room. Nothing looks at a waiting T# otherwise: before, a round robin tried the waiting slots again for 500 µs a submission (LEONIDA_CONSOLE_RETRY_US), which in world runs took tens of submissions to come round and counted every look as a T# "naming no texture" again. A texture that goes takes its T#s out of the descriptor hash table at once (forget_image_views_locked), so a shader reading the slot gets the fallback; the slot then waits for the next texture at the address, which a texture streamed out and back in needs. A V# half whose geometry copy was refused for lack of room waits for room the same way: the slots are fixed again when geometry copies are freed (GeometryViews::free_generation), not only when something is added over their base. A T# with no texture at its address is counted by what the address is (unbound T#s by reasonin the heap's log line): title memory, a texture of the layer's own that is gone, an address whose low 32 bits are one of the layer's texture addresses with other high bits (the texture there with the T#'s shape, with another, or gone), or none of these. The heap'sslot recordsline gives the T#s recorded, those waiting, the T# fixes that left one waiting and the refills since the last line.d3d12_tsharp_refill_testsamples, through the last of 60,001 waiting slots, a texture made after the T# was written, at the first submission after it appears. T#s are a third index of the same kind, keyed by their address: a texture change visits exactly the T#s recorded for that address, and the records waiting for room are kept in a list per kind, which a change saying room was made visits whole. The title rebuilds T#s of the layer's textures from 32 bits: the unbound T#s of one world run named 0x7f0000021400 for the layer's 0x100021400, and 0x2ef600 for 0x1002ef600 (bits 32-39 clear, 0x7f or 0 in bits 40-47). Such an address outside the title's memory names the layer's texture with the same low 32 bits (tsharp_texture_key, while fewer than 2^24 texture addresses were handed out):bind_title_imagelooks it up there, and the T# waits under that address, where the texture's creation is announced. Before, such T#s waited under the title's form, which no arrival names, and the run showed no refill at all;d3d12_tsharp_refill_testwrites both forms before the texture exists and expects them bound at the first submission after it appears. A V# the title rewrote whose range another half of the heap waits for is answered as that half was (ConsoleHeapSlotRecords::waiting_answer), without walking the alias table, backings, geometry copies and title memory again: a waiting record is fixed again by every change that could let it resolve, so while it waits its answer stands. The changes noted since the submission's list was taken are applied to the heap first (sync_slot_changes), and the submission's own changes before the rewritten slots, so an answer is never older than a change that concerns it. In one world run 70% of the 2,100 rewritten V# halves a submission resolved to nothing at about 9 µs each. A console resource heap read in place. When the page mirror holds every page of the heap (a reservation xmem placed in the mirror's range), there is no copy of the whole heap and no page tracker of its own. Its pages have two homes. At the title's address (the mirror) the home is the title's bytes exactly, as for any page: the title keeps plain data inline in its heap pages and points V#s at it (run 64w3: four words a compute program reads as its sizes,[512 256 1280 720]), so a V# or a title pointer into those pages must read what the title wrote, and GPU stores there are written back as for any page. At the table address, below 4 GiB of the arena (25,865 of 26,503 shaders keep 32 bits of a descriptor-table pointer), each page has a filtered copy of its own (TitleMirror::alias: a second home per page, bound there in the same batches as the mirror's binds, so the one wait orders a reader of either address), in a range of whole arena blocks with no arena memory behind it; the null slots after the heap are that range's rest, unbound, which reads zero. The filter writes only that copy (filter_heap_page), refilled when a 256-byte piece of the title's page changed (the upload's sums compare the title's bytes with the title's) or write-back changed it. Each slot that changed since it was last filtered, or that a change of the address space touched, is filtered: a V# half whose base lies in the arena, in the mirror (named to it as any reader names title memory) or in a buffer of ours is kept as the title wrote it (reachable_as_written); a half nothing holds is null whole, all four words (a shader reading it as a V# would fault at heap_base + its base: the "resolved to nothing" classes of the heap's log line), never three of four; a T# is kept as written and bound; words that decode as neither are null, as a shader taking them as a V# would fault. The filter runs inside the mirror's fills, under its lock, so it takes no other lock of ours: a V# the mirror does not hold reads null until the heap's refresh resolves it as a copied slot was, and a T# is bound there too, its dword 6 in the copy then taking the bindless index word (tsharp_index_word, docs/design.md "Bindless index in the T#"; 0, the fallback, from the filter until then and while the T# waits; the title's dword 6 stays in its bytes), each result written into the copy unless the title rewrote the slot meanwhile (finish_in_place). Lock order:console_heap_mutex, then the mirror's, then the change list's. Table pointers reach shaders in user SGPRs, which the layer sets to the table address (console_descriptor_table_va) for every module; a table pointer a shader loads from memory is the title's address and reads the title's bytes there: V#s as written (the mirror holds what they name, or the read faults as on any unfiltered memory) and T#s without the index word, which a module of the index-word contract reads as the fallback. A heap the mirror does not hold (a device without the mirror, memory outside its range) is copied as before.d3d12_heap_in_place_testchecks that the GPU reads the filtered slots at the table address while the title's bytes never change, that a rewrite reaches the GPU at the next refresh, that inline data reads exactly through a V# while the table reads it filtered, that a GPU store into the heap goes back, and that the null slots read zero;title_mirror_hooks_testchecks the alias without a GPU andvk_heap_alias_testa second binding on a device. Console resource heap copies and shader-visible CBV/SRV/UAV heaps with at least 65,536 slots request 64 MiB of zeroed padding after their last descriptor.LEONIDA_HEAP_GUARD_MBsets the padding in MiB (0 disables it). When arena space is tight, allocation can fall back to the heap alone. Only indices inside the reserved padding read null slots. Console slots containing data instead of a recognized image or buffer descriptor have their first 16 bytes cleared in the GPU copy. The title keeps its original bytes. - Game-built descriptor memory. The game writes raw T#/S# bytes into a heap itself, without calling
CreateShaderResourceView. The shaders then read those bytes exactly as in case 1.
The layer's descriptor model:
-
A
DescriptorHeaphas a host shadow and, if shader-visible, an arena range. CPU handles point into the shadow; GPU handles are arena VAs.Create*View,CopyDescriptorsandCopyDescriptorsSimplewrite the shadow and mark the range dirty. The execute-time scan below is the correctness path, so a game that writes raw descriptor bytes through a CPU handle still works; dirty tracking is only an optimisation. -
Heap start-handle ABI. Prior art measured
GetCPUDescriptorHandleForHeapStartandGetGPUDescriptorHandleForHeapStart(heap slots 9/10) returning the 8-byte handle in RAX on the Xbox build, while the PC call returns it through a hidden pointer in RDX. A generic sret/IDL thunk must special-case these two slots or the handle is garbage. This is a method-level ABI quirk; the heap object is still the publicID3D12DescriptorHeapinterface. -
The bytes written for an image/sampler descriptor are GFX10 T#/S# structures, the same structures the translator reads. The layer writes them itself in
Create*View; this does not depend on what the console driver wrote. If the game builds descriptors in memory itself, it must use the same format (the shader reads raw T#/S#), which is the assumption to verify. If it uses an opaque format, the layer must translate at bind time. -
At execution, for each bound table (or the whole bound heap when direct indexing is enabled), the layer walks the declared descriptor range with the heap's stride, parses each T#/S#, and ensures a bindless entry exists:
- image T# →
VkImageView(format, view type, mip range, array layers) → bindless image index, which the layer writes into dword 6 of the T# where shaders read it (the console heap copy's slot, or the layer's own heap), with the arrays it is bound in (docs/design.md, "Bindless index in the T#"); the hash table keeps the key as written; - sampler S# →
VkSampler(filter, address modes, LOD, compare, anisotropy) → bindless sampler index; - buffer V# / CBV → no Vulkan view; the descriptor already contains a console VA the shader dereferences.
- image T# →
-
Buffer UAVs.
CreateUnorderedAccessViewon a buffer writes a V# in the first 16 bytes of the slot (the rest of the 32 bytes is zero):BASE_ADDRESS= the resource's GPU VA +FirstElement* the element size, and by view kind- raw (
R32_TYPELESS+RAW): stride 0,NUM_RECORDS= bytes,OOB_SELECT3 (raw); - structured (
UNKNOWN+StructureByteStride): stride,NUM_RECORDS= records,OOB_SELECT0; - typed (any other format the typed-UAV table has:
uav_clear.hlayouts thatgfx10_descriptors.h'sformat_tablenames with a code below 128):FORMAT= theGFX10_FORMAT_*code, stride = the element size in bytes,NUM_RECORDS= elements,DST_SEL= the format's own channel order (format_swizzle: R8 reads as (x, 0, 0, 1), B8G8R8A8 as (z, y, x, w)),OOB_SELECT1 (structured: only the index is checked againstNUM_RECORDS,docs/buffer_bounds.md). This is whatbuffer_load_format_*/buffer_store_format_*/ thebuffer_atomic_*of a translatedRWBuffer<T>read; the translator decodes the element from the V#'sFORMATat run time (rdna2spirv.pyFORMATS) and bounds-checks the whole element againstNUM_RECORDS. A format the layer cannot name (a typeless or 96-bit one, a compressed one, anything whose code is 128 or more,R16G16_SNORMand the other texture formatsvulkan_formathas no row for) leaves a null slot, logged once. Typed clears (ClearUnorderedAccessViewUint/Float) read the same V# back, so they work on these views and on game-built ones. - UAV counters (
pCounterResource+CounterOffsetInBytes, structured views only). D3D12 keeps the counter in an application-visible buffer: there is noCopyStructureCount(that is D3D11); a game copies the counter withCopyBufferRegionfrompCounterResourceatCounterOffsetInBytes(this is "CopyStructureCount" in D3D12 and needs nothing from the layer), and resets it withClearUnorderedAccessViewUinton a raw view of that word or a copy from an upload buffer. The layer refuses (null slot, logged once) a counter on a non-structured view, a counter resource that is not a buffer created withALLOW_UNORDERED_ACCESS, an offset that is not a multiple ofD3D12_UAV_COUNTER_PLACEMENT_ALIGNMENT(4096) or leaves no room for 4 bytes, and a non-zero offset with no counter resource, the combinations D3D12 documents as invalid. Hypothesis for the console contract (not measured): the shader gets the counter as a second V#, raw, 4 bytes (stride 0,NUM_RECORDS4,OOB_SELECT3) at address counter VA + offset, in bytes 16..31 of the same descriptor slot, which is otherwise unused for a buffer (a V# is 16 bytes in a 32-byte slot), andAppendStructuredBuffer/ConsumeStructuredBuffercompile tobuffer_atomic_add/buffer_atomic_subwithglcon it, the returned old value (minus one for consume) being the record index. Why this guess: the translator has nods_append/ds_consume/ GDS path and the corpus scan (open-questions table below, row 10) found no GDS instruction, so a counter in memory is the only form left; where the counter V# sits (a second slot, a user SGPR pair, a spill) is open until a shader that uses one is traced (row 16 of the same table).d3d12_buffer_uav_testrunscs_buf_counter.asm, a hand-written shader of exactly that shape: 256 lanes append, 128 consume, the counter reads 256 and then 128 throughCopyBufferRegion, and the 256 appended records are each present once. If the console puts the counter elsewhere, onlywrite_buffer_uavmoves.
- raw (
-
Unbounded descriptor ranges (
NumDescriptors = UINT_MAX) have no end. Scan from the table handle to the end of the bound heap, and cache parsed descriptors by key so unchanged slots cost nothing. Open: whether the game uses unbounded tables; the trace will show the root-signature ranges. -
The heap stride is the value the layer returns from
GetDescriptorHandleIncrementSize. Prior art forwards device slot 15 (GetDescriptorHandleIncrementSize) unchanged. Measured in the executable: every one of the 943 indirect calls through[device vtable + 0x78]was resolved by tracingrcxfrom its function's start; ten reach the device itself:rcxis loaded rip-relative from the BSS device global0x148759D00or from one of its aliases0x1475DF000-0x1475DF048, the same global the measured device calls in section 7.1 use (the load ismov rcx, qword ptr [rip + displacement], so the literal address does not appear in the instruction). The other 933 call the same slot on another object (queue, factory, wrapper) and are counted but not attributed.site descriptor heap type ( edx)what the return does 0x141C7456B0 ( CBV_SRV_UAV)add rdi, raxin the slot loop: the increment advances the GPU handle stored in each entry0x141F75FDD0 ( CBV_SRV_UAV)the same handle-stride loop 0x142478E420 ( CBV_SRV_UAV)stored for later: mov dword ptr [rip + 0x516E1AE], eax0x142478E5F1 ( SAMPLER)discarded 0x142478E712 ( RTV)discarded 0x142478E833 ( DSV)discarded 0x142478E9A4 ( NUM_DESCRIPTOR_HEAP_TYPES)discarded 0x145C5FF2F0 ( CBV_SRV_UAV)imul rsi, raxandimul rdi, rax: two buffer sizes, each then rounded up to 64 KiB0x145CABB180 ( CBV_SRV_UAV)mov ecx, eax; div rcx: slot count from a byte count, handed to the heap-size path (0x141CF3280) that multiplies it back0x141CF32BEedxargument of its wrapperimul rdi, r12: size = count x increment; the callers pass type 0 (0x145CABB00) or forward their own argument0x145A54700, itself called with types 1, 2 and 3So the game queries the increment and derives sizes, divisions and handles from the answer: it does not hardcode a stride, and it is the getter, not the shader's shift, that decides it here. The layer must therefore return the host heap's own increment per type, never a console constant, or every size and handle walk above is wrong. In the two table builders the CPU-side record stride is
0x40while the handle advances by the returned value, so the increment is a slot stride and a record can be wider than one slot. The bootstrap queried all five enum values but cached only type 0; types 1-4 reach the getter only through0x141CF3280. Open: the numeric console values themselves, and the console slot sizes behind them (32 bytes for CBV/SRV/UAV and for samplers stays this layer's choice); the shader's shift amount still has to match whatever stride the layer hands out. -
CopyDescriptorscopies raw bytes. If the descriptor was produced by ourCreate*View, the copy is a valid T#/S#; if it came from game memory, it is still valid raw data. No re-encoding is needed. -
Handle validation: a GPU descriptor handle is an arena VA; the heap registry maps the containing range to a heap. A table handle outside the bound heaps is a validation error; log it and resolve to fallback index 0 rather than reading arbitrary memory.
-
RTV/DSV creation builds a
VkImageViewand stores it in the host-side heap;OMSetRenderTargetsresolves those handles to views for the rendering scope. RTV/DSV descriptors are never shader-visible. -
View creation maps
D3D12_SRV_DIMENSION/D3D12_UAV_DIMENSIONtoVkImageViewType, the mip and layer ranges, sample count, andD3D12_SHADER_COMPONENT_MAPPINGtoVkComponentMapping. Single-layer 1D textures have default and explicit shader-resource views on sampled binding 5. Single-sampled 1D, 2D, 2D-array, cube and 3D colour SRVs apply the T# minimum LOD in resource mip coordinates. A clamp inside the exposed mip range usesVK_EXT_image_view_min_lod. Vulkan allows the image-view minimum to be rounded down to an integer. With nearest mip filtering, the UHD 770 and Arrow Lake Xe-LPG returned mip 0 for a 2D minimum of 0.75. The Xe-LPG also returned mip 1 for a 2D-array minimum of 1.75. RTX and Radeon returned mips 1 and 2.d3d12_descriptoraccepts either rule for a fractional clamp (all texels of a view following the float or the floored minimum), and prints which one the driver used. See Vulkan image-level selection and the Intel readbacks. If the logical device lacks the feature, the runtime logs the unsupported view and its descriptor resolves to the fallback. A clamp at or below the first mip needs no extension. Above the last mip, the view retains its dimensions and maps sampled channels to zero while preserving constant channels. -
D3D-78: a
Texture1DArrayUAV gets a 1D-array view with the requested array subrange and storage bindings 26–28 (float, UINT, SINT);ArraySize = UINT_MAXselects the remaining layers. A non-arrayTexture1Dview of a 1D array selects layer 0, as checked on native D3D12. ATexture3DUAV gets a 3D view with a single mip and Vulkan array range{0, 1}. A partial W range requiresVK_EXT_image_sliced_view_of_3dandrobustImageAccesson the logical device:VkImageViewSlicedCreateInfoEXTrebases storage-image Z toFirstWSliceand limits it toWSize(UINT_MAXmeans the remaining mip depth). It does not slice the sampled view. The generated T# tags the W range for whole-mip and partial UAVs, distinguishes them from SRVs in the hash table, and rebases typed sampled fetches; see the contract indocs/design.md. Without those features a partial W view is logged and left null, not made writable across the whole mip. Shader-visible 1D, 1D-array and 3D UAVs require both formatless storage read and write support for the actual Vulkan view format.image_load ... glcuses the storage view for 1D and 3D, and 1D-array loads always use it. The emulated RGB9E5 rawR32_UINTstorage view is formatted and is exempt. Vulkan 1.3 permits these SPIR-V capabilities even without the legacyshaderStorageImage{Read,Write}WithoutFormatfeature bits. The caller-owned device test leaves both legacy bits off and masks each per-format bit to verify safe rejection.ClearUnorderedAccessView*reads the W range from these descriptor bytes even after a descriptor copy. General 1D/3D backing-format reinterpretation remains unsupported. Shader access to the new UAVs requiresrobustImageAccess(whole-mip CPU clears do not). A separate native D3D12 probe on the RTX 4090 and UHD 770 clipped typed writes to the view's W range. WARP 10.0.26100.9818 rebased the view but did not clip writes past a finiteWSizein that probe. The regression compares in-range writes with WARP and checks preservation of out-of-range slices independently. -
Set 0 is a fixed bindless layout, sized once when the device creates it. The defaults are 4096 sampled 2D images, 1024 samplers, 1024 2D-array images, 256 1D, 256 3D and 256 per storage dimension/class. The 2D, sampler and storage arrays grow to what the device's limits allow, up to 65536, 4096 and 4096 (1D-array storage stays capped at 256; see
vulkan_bindless.habove). The set is not recreated to grow, because recreating it would invalidate the pipeline layouts built on it. UseUPDATE_AFTER_BINDandPARTIALLY_BOUNDso a new view does not require rewriting every descriptor; without those features, rebuild the set when it changes. -
The command buffer binds set 0 once; descriptor-heap changes only update the arrays and the hash table.
Descriptor lifetime. A bindless index may be referenced by in-flight command buffers after the resource is destroyed. Views/samplers are retired on a fence-value queue; the hash-table entry can stay (a stale key is only a miss for a new descriptor, not a correctness problem) until the slot is reused. Reusing a slot for a new resource updates the index in place; the key match makes the lookup correct.
3.5 Root signature to user SGPRs
This is the least verifiable part of the layer. D3D12 gives the application a root signature; the console driver
turns it into the user SGPRs (s0..s31) that the shader reads. The translator already copies those 32 dwords from
push constants into s0..s31. The layer must produce them.
The first mapping the layer used (rt::rootsig::pack in runtime/src/root_signature.{h,cpp}, kept for the tools and
tests that compare the two models; the runtime now uses the console layout below at both bind points) follows root
parameter order:
| Root parameter | User-data dwords |
|---|---|
D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS |
one dword per constant |
D3D12_ROOT_PARAMETER_TYPE_CBV / _SRV / _UAV |
two dwords: the 64-bit console VA passed to Set*Root*View |
D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE |
two dwords: the table's console VA (a D3D12_GPU_DESCRIPTOR_HANDLE) |
| static sampler | none; registered in the hash table at root-signature creation |
Before the draw/dispatch, the layer copies the current root arguments into a 32-dword block in that order and uploads it as push constants. Missing parameters are zero.
Measured on the corpus (python -I tools/user_sgpr_census.py <spirv/index.json> --base ps=8 vs=8 gs=8 cs=4 ms=16, all 26,503 shaders). These are physical user SGPRs; the tool cannot see logical root-parameter indices.
- The lowest user SGPR read as a pointer is s8 in most PS (9,830 of 12,101) and VS (1,660 of 2,236), s4 in CS (2,364 of 2,689) and s16 in mesh shaders (7,977 of 9,282).
- Pointers are 32-bit (
ptr32_lo) in every PS/VS/CS/MS shader that reads one; only the 195 GS read a 64-bit pointer (ptr64_loat s8). - Consecutive pointer SGPRs in one shader are most often adjacent (distance 1: 22,008 PS, 14,548 MS, 3,059 CS, 1,836 VS), and the SGPR after a 32-bit pointer is never read as a
ptr64_hi. - Below those bases only
const32reads appear, at odd SGPRs in PS/VS/CS (s1, s3, s5, s7), and s2 in GS: a reserved block whose meaning is not established here.
Taken together this disagrees with the packing above (from s0, two dwords per table) and is consistent with a per-stage base (s8 VS/PS, s4 CS, s16 MS) and one dword per table pointer. It is a census of shader reads, not a confirmed mapping: it does not show which root parameter feeds which SGPR, and the GS behave differently. --expect ps=8 vs=8 cs=4 ms=16 turns it into a check; tests/test_user_sgpr_census.py shows that the two packing models give different results.
Console layout, measured for compute (D3D-448). rt::rootsig::pack_stage lays the parameters out for one stage:
in root order from the stage base, each while it fits whole, a constant taking one dword per value, a root
CBV/SRV/UAV two (its 64-bit VA), a descriptor table one (the 32-bit VA of its first descriptor; the heaps live
below 4 GiB). A parameter that does not fit goes, with every later one, to the spill array behind s[0:1]
(section 7), which is not modelled, so such a signature is refused. How each part is known:
- Compute, base s4: measured three ways.
- The console compiler's output (section 7).
- The package's FidelityFX DLL, whose 29 compute containers carry their
RTS0next to the console-compiled program (tools/rootsig_census.py <fspx> --disasm <fspx>/disasm, Xbox Series 1.0.2.1). Base s4 plus the signature's span in this layout equals the program's RSRC2USER_SGPRcount in 29 of 29: 27 signatures (table, table, four root CBVs) span 10 dwords and launch with 14 user SGPRs, 2 (table, table, one root CBV) span 4 and launch with 8. Thepack()layout spans 12 and 6, two short of both. - The reads:
tools/root_sig_contract.py <fspx index.json> --rootsig <that shape> --model consolefinds all 20 translated programs compatible (tables read at s4/s5 as 32-bit pointers, each root CBV's VA copied whole as two dwords from s6). Thepack()layout contradicts 7 of them, which read the second table at s5, the first table's high half in that layout.
- Vertex/pixel/geometry s8 and mesh s16: a hypothesis. It rests on the census above only; no signature confirms these bases, and visibility is not modelled (every parameter takes its place in every stage). Each shader's own root-layout table would make it a per-shader fact; it is parsed but not counted yet ("Per-shader root tables in the FSSM record" below).
The runtime uses the console layout at both bind points. Every stage of a pipeline reads one push-constant block
(ShaderUserData in runtime/src/vulkan_replay.h), so the graphics bind point lays a signature out once with
pack_stage(Stage::Pixel) (the same s8 base as vertex and geometry): root dword k at push dword 8 + k. A vertex,
pixel or geometry shader reads SGPR i from push dword i, so it finds the arguments at s8.. as the console puts them.
A graphics signature past s31 (more than 24 dwords from s8) keeps pack()'s layout (from s0, two dwords per table),
logged as "keeps the s0 graphics layout": the graphics spill array is not modelled. LEONIDA_GRAPHICS_STAGE_LAYOUT=0
keeps pack() for every graphics signature (RootArgumentLayout::graphics_console false).
The graphics root window (D3D-448-GRAPHICS): a mesh shader's root arguments start at s16, so the translator loads
its s16..s31 from push dwords 8..23 instead (user_data_dword in tools/rdna2spirv.py); a mesh and a pixel shader
of one pipeline then find each argument in the same dword. A mesh shader's s8..s15 are below its base and read 0;
s0..s7 stay push dwords 0..7 for every stage. The index records the window as "root_window": {"sgpr": 16, "dword": 8}, and a mesh PSO whose mesh shader lacks it (translated before) is refused with a log line asking for the shaders
stage again. The mesh window holds 16 dwords (s16..s31) where the others hold 24 (s8..s31): a signature that fits the
graphics layout but not the mesh window, or one on pack()'s s0 layout, is created (the first is logged), and
DispatchMesh with it invalidates the list (RootArgumentLayout::mesh_ok, d3d12_mesh_test). Live evidence for s8
and one dword per table: on the retail frame loop the VS of a textured draw reads table slots 0 and 2 through s8 and
its PS slot 1, which hold exactly the buffer, constants and texture the title bound (issue #14, comment 7131556366,
native Windows, RTX 5080). What mesh shaders read below s16 was counted on the 1.0.2.1 corpus
(user_sgpr_census.py --base ms=16, issue #14 comment 7138532347): of 9,282 mesh shaders, 9,279 read nothing below
s16; three read one 32-bit constant there (s13 in one, s15 in two), never a pointer, and they read it as 0 now.
Its meaning is not established. A root signature carries both layouts; one that only one of them can place is
created, and binding it at the other bind point invalidates the command list (Close returns E_INVALIDARG).
s0..s3 of a compute dispatch are the driver's block; the layer leaves them zero (109 CS read s1 as a constant,
42 s3; their meaning is open).
Measured: a real signature beside the count it produced. tools/fspx_unpack.py decodes COMPUTE_PGM_RSRC2 of
each of the 29 compute programs in amd_fidelityfx_upscaler_xbox.dll, and its USER_SGPR field is the count the
console launched the dispatch with. Every one of those 29 containers also carries an RTS0, which makes this the
only place in the package where a serialized root signature sits beside the dword count it produced
(tools/rootsig_census.py). The game's own 26,503 containers carry no RTS0, so their read sets cannot be joined
with a signature and cannot settle it either.
All 29 are version 1.1 with Flags = 0, 168 parameters in total (58 tables and 110 root CBVs, no 32-bit constants,
SRVs or UAVs), every parameter at D3D12_SHADER_VISIBILITY_ALL, and 27 of them carry one static sampler. They come
in two shapes:
| Parameters | Signatures | USER_SGPR |
Layer model (2 dwords per table) | One dword per table |
|---|---|---|---|---|
| 4 CBV + 2 tables | 27 | 14 | 12 | 10 |
| 1 CBV + 2 tables | 2 | 8 | 6 | 4 |
The surplus is 2 dwords under the layer's model and 4 under one-per-table, and it is the same for both shapes: the
driver put a fixed block below the parameters. Arithmetic alone therefore does not separate the two models. The
disassembly does (tools/rootsig_census.py --disasm, over the same 29 programs):
s4is copied into the low half of a pair, the high half zeroed, and passed tos_loadas the base in 29 of 29;s5is in 16. The two declared tables therefore sit at s4 and s5, one dword each, in signature order, and the 13 programs that never reads5are using only the first.- A 64-bit pair is copied whole from
s6:s7in 27 of the 29. Five of those also copy froms8:s9,s10:s11ands12:s13, which matches their four root CBVs at two dwords each. The other two read none ofs6tos13: they declare four CBVs and never touch them. - 27 read none of
s0tos3. In_05the program addss0ands3tos4, and_07multiplies bys0, so the block below the tables is not always dead, but no program here uses one of those dwords as a pointer.
That is USER_SGPR = 4 + 2 per table + 2 per CBV, which gives the measured 14 and 8, and it is the one-dword-per-
table model behind a four-dword prefix. The CS census above agrees: its lowest pointer is s4, where a four-dword
block puts the first table, while two dwords per table would put it at s2.
Still open: which CBV index lands in which pair. The four pairs do appear in declaration order, but nothing in the
package proves that order, and every parameter in these 29 is D3D12_SHADER_VISIBILITY_ALL, so they say nothing
about the visibility question below.
Per-shader root tables in the FSSM record (FSSM-ROOT-LAYOUT-TABLES): parsed, not measured yet. The census
above reads the code. Each native program's record also names two tables that state the layout directly: a
root-layout table (where each root parameter arrives in the program's user data) and a used-resource table (which
descriptors the program reads, by root parameter). This is the record layout as read by VIctory (Marvisak/VIctory,
GPL-3.0, native.rs in its crates/victory-shader/src), which builds its user data from these tables instead of
inferring a base. root_tables() in tools/fssm_root_layout.py is a parser written for this repository from that
layout; it contains no VIctory code. Nothing here has been run on a real shader: the parser and
tools/root_layout_census.py are tested on hand-built records only (tests/test_fssm_root_layout.py). Neither
file is a translation source and tools/fssm_unpack.py is unchanged, so a translated shader library stays valid
with them.
Offsets stored in the blob count from the payload, which starts at blob offset 0x10; the offsets other pages
give for the header (0xC0, 0xE8, ...) are blob offsets.
| Where | What | Basis |
|---|---|---|
payload +0x08 |
u64 record offset per hardware stage: LS, HS, ES, GS, VS, PS at +0x08..+0x30, mesh at +0x48, compute at +0x60; 0xDEADBEEFDEADBEEF when the blob has no program for the stage |
VIctory's reading. fssm_crosscheck.md measured blob 0x18/0x20 (the LS and HS slots here) as that sentinel in 26,503 of 26,503, and the code offset at blob 0xC0, where a first record at payload 0xB0 puts it. Which slot holds which record offset is not checked, and the qwords between those slots (+0x38, +0x40, +0x50, +0x58) are not read. |
record +0x00, +0x08 |
u64 code offset and size |
Measured before as blob 0xC0/0xC8. The first instruction is 0x18 bytes into this range (the u32[0xC0] + 0x28 rule, with the offset counted from the payload). |
record +0x28 |
u64 offset of the root-layout table |
VIctory's reading. It is the field fssm_crosscheck.md calls code_end (blob 0xE8): equal to code offset + size in 26,486 blobs, so the table starts where the code ends, and the unset sentinel in the other 17. |
record +0x30 |
u64 offset of the used-resource table |
VIctory's reading. The meta_ptr of fssm_crosscheck.md (blob 0xF0), the sentinel in 635 blobs. |
record +0x38, +0x3c |
u32 entry count of each table |
VIctory's reading, unconfirmed. |
| root-layout entry, 20 bytes | u32 root type (0 constants, 1 root descriptor, 3 descriptor table, 4 immediate sampler, 5 resource heap, 6 sampler heap), u32 offset of the range in its table in dwords, u32 user-data dwords it takes, u32 shader register of the first descriptor, u8 first user-data dword, u8 root parameter index, u16 0 |
VIctory's reading, unconfirmed. fssm_header.binding_table already found 20-byte records at this place in all 26,503 blobs (5,640,704 of them) without naming their fields. It starts at the same byte, so its "header" word is this table's first root type: it is 4 in 24,572 blobs and 3 in 1,914, an immediate sampler and a table. Its records begin 8 bytes later, so each straddles two entries. That follows from the two descriptions; it is not checked on data. |
| used-resource entry, 20 bytes | u8 resource type (0 SRV, 1 sampler, 2 CBV, 3 UAV), u8 root type, u16 0, u32 offset in the table in dwords, u32 lower-bound register, u32 stride, u8 dwords per descriptor, u8 first user-data dword, u8 root parameter index, u8 0 |
VIctory's reading, unconfirmed. |
| user-data dword n → SGPR | s<n> in the VS, PS and compute stages; s<n+8> in the merged and mesh stages (LS, HS, ES, GS, MS), which have 8 system SGPRs first |
VIctory's reading. With it the bases above are first user-data dwords: 8 for a PS, VS or mesh shader (s8, s8, s16), 4 for compute, 0 for a GS (s8). Section 7 has the mesh user data at s16-s24 from a corpus measurement. |
| spill (compute) | 16 user SGPRs; a parameter whose first user-data dword is 16 or more is in memory behind the 40-bit pointer in user data 0-1, and that memory starts with dword 16 | VIctory's reading. The pointer in s[0:1] is also section 7's (console-compiler output). The 16 is not measured here: the game's compute shaders launch with at most 14 user SGPRs. VIctory reads a spill for compute only. |
What the parser refuses (FssmLayoutError, a ValueError): a header that is not version 0x101 with a matching
payload size, a record or code range outside the payload, records that overlap each other or the slot table, and a
table that runs past the payload or overlaps a record, its program's code or the program's other table. A count of
0 is an empty table whatever its offset is. Unnamed types and non-zero reserved fields are kept, so the census can
count them.
python -I tools/root_layout_census.py <work>/shaders/dxbc --json <report.json>
python -I tools/root_layout_census.py <work>/shaders/dxbc --base ps=8 vs=8 gs=8 cs=4 ms=16 --expect-agree
python -I tools/fssm_root_layout.py <work>/shaders/dxbc --out <root_layout.json>
The census reads your own carved containers (every tag-0x0D payload) or unpacked .fssm blobs and prints counts
only, per hardware stage: the lowest SGPR a parameter arrives in and the lowest that holds an address (the number
the SGPR census above measured from the code), the dwords each root type takes (one or two per table), the root
types and used-resource kinds, the compute programs with a spilled parameter and the first spilled dword, and how
many programs agree with this section's hypothesis: no parameter below the stage base, one dword per table, two per
root descriptor, parameters in root order. It lists the reasons for the ones that disagree. --expect-agree exits
1 on a disagreement, a blob that does not parse or an empty run. It also counts what would show the reading to be
wrong: blobs it cannot read (by reason), record offsets (the first is expected at 0xc0), whether the root-layout
table follows the code, the number of entries in each table, used resources with no layout entry for their
parameter, non-zero reserved fields, unnamed types and parameters past s31. With no path, or a folder that has
no .fssm or .dxbc file, it prints no input. fssm_root_layout.py writes the tables themselves as JSON, one
line per file with an entry per blob (the programs, or why they could not be read); without --out it prints
them, and for a whole library the output is large.
Open:
- Every offset and field marked "VIctory's reading" is unconfirmed on this corpus. A census of a real library
settles it: no unread blob, record offsets as expected, a lowest-pointer SGPR per stage that matches the SGPR
census (
s8in 9,830 PS and 1,660 VS,s4in 2,364 CS,s16in 7,977 MS), and entry totals that can be held against the 5,640,704 recordsbinding_tablecounted in the same region. - Does a table list every parameter of the root signature, or only the ones the program reads? If only those, a lowest parameter above the base is expected; if all of them, it contradicts the base. The census therefore counts "above the base" apart from "at the base" and calls neither a disagreement.
- Root type 2 and the reserved fields have no reading; the census counts them.
- Blobs with two programs. The 195 GS blobs carry a second PAL stage descriptor, the shader's VS copy (design.md, "PAL stage descriptors"), so they should have two records here. Whether each has its own tables is not known: the parser reads each record's tables on their own and lets two records name the same table.
- A graphics-stage spill has no reading at all.
- The runtime does not use the tables. Feeding them to
rt::rootsig::pack_stageandShaderUserDatais the follow-up once the counts are in; until then the hypothesis above stays a hypothesis.
Spill policy: a signature needing more than 32 user SGPRs, or more than the 64-dword D3D12 cost limit, is
refused loudly (pack returns the offending parameter) instead of being truncated. The console spills through
__XB_GetRootSignatureSpillPointer; until that layout is measured, refusing is the only correct behaviour.
Measured (D3D-315): zero below-base spill-pointer candidates in the translated shaders.
python -I tools/root_spill_census.py <spirv/index.json> --carve <dxbc/index.json> --expect-no-spill exits 0 on
the 26,501 translated shaders (all but the 2 compute shaders refused for workgroup memory under wave64 emulation),
Xbox Series 1.0.2.1:
- No root signatures in the containers. 0 of the 26,503 carved containers have an
RTS0part. The game builds its root signatures at run time, so the number that exceed 32 dwords is open until they are dumped from the executable. - No spill-pointer candidates. No user-SGPR read used as an address (
ptr32_lo,ptr64_lo,ptr64_hi) sits below the stage base (ps/vs/gs s8, cs s4, ms s16) in any stage. For compute that block holds the measured spill pointers[0:1](section 7); heres0ands1are never read as an address, onlys1as a constant (109 CS, 551 PS, 12 VS). - Compute stays far below the budget. The largest RSRC2
USER_SGPRcount is 14 (31 of 2,687 shaders), so at most 10 of the 28 root dwords above s4 are used. - The highest reads are not spills. PS reads reach s31 (8 shaders), s29 (7), s27 (1) and s25 (8); MS s29 (2) and s27 (8); VS s25 (2). Each of those top reads is a 32-bit constant after a gap, not an address.
What this does not settle:
- How many runtime-created signatures exceed the budget. The containers carry none, so that count waits for signatures dumped from the executable.
- Why a particular
pack()refusal happens.pack()counts two dwords per table from s0, which the census above disagrees with, so its 32-dword limit and the console's budget need not agree. Whether a given refusal is that model or a real spill is open until the signature and its shaders are compared. - A spill behind a pointer at or above the base. It reads the same as a table pointer, so the census can't tell the two apart.
The spill layout stays unimplemented: no shader in the translated set reads a candidate a spill could sit behind.
Reconciliation: tools/root_sig_contract.py checks a candidate root signature against every shader's
user_sgpr_reads from spirv/index.json (const32 vs constant dwords, 64-bit VAs vs view/table pairs) and fails
the build on the first contradiction. Until the console mapping in §3.5 is confirmed by a PSO, this check — not
a rendered frame — is the acceptance gate for the mapping above.
Blob format: rt::rootsig::parse_rts0 reads the RTS0 chunk of a serialized root signature, versions 1.0, 1.1
and 1.2. root_signature_oracle_test checks it on Windows against blobs the PC d3d12.dll serializes. These
layouts are measured, not assumed:
- a descriptor table's payload is
{num_ranges, ranges_offset}, with the ranges at that offset; - ranges are 20 bytes, or 24 with the 1.1/1.2 flags dword, in
D3D12_DESCRIPTOR_RANGE(1)order:{type, count, base register, space, offset}in 1.0 and{type, count, base register, space, flags, offset}in 1.1/1.2, so the flags come beforeOffsetInDescriptorsFromTableStart(a range withDATA_STATICand offset 7 serializes as… 8 7). The parser keeps all six fields; - root descriptors carry a flags dword from 1.1 on;
- static samplers are 13 dwords (
D3D12_STATIC_SAMPLER_DESCorder). In 1.2 they are 14:D3D12_STATIC_SAMPLER_DESC1appendsFlags, i.e. UINT border colours and non-normalized coordinates.
Static samplers take no user-data dwords, so 1.2 changes nothing in pack.
Root-signature flag quirk. Prior art measured Xbox root-signature descriptors carrying flags 0x03000000; the
PC serializer rejects them with E_INVALIDARG because its flags live in the low 16 bits. Clear the high byte on a
private copy before calling the host serializer/deserializer; never modify the game's descriptor. The meaning of the
bits is unknown. The v1.0 D3D12SerializeRootSignature path keeps flags at offset +32, and a descriptor with
0x3000001 also fails on the PC runtime.
Measured: where the bits come from in the package. Of the two console-compiled clients, only XboxBvhBuilder.dll
sets them, and it does so twice.
- In its shaders: all 52
RTS0parts in its DXBC containers (version 2, i.e. 1.1) carryFlags = 0x03000000. - At run time: the builder's only
D3D12SerializeVersionedRootSignaturecall (0xc32f, import address table0x180024250,d3d12_xs.dll) is in the function at0xc2d0, which ten call sites reach. That function copies the 48-byteD3D12_VERSIONED_ROOT_SIGNATURE_DESCto the stack ([rsp+40h]) and, with no branch before it, ORs the bits into the copy's v1.1Flags(+0x28):or dword ptr [rsp+68h],3000000hat0xc30e.
amd_fidelityfx_upscaler_xbox.dll does neither. Its 29 RTS0 parts carry Flags = 0, and no instruction in it uses
the constant 0x3000000. So the bits are not a property of every console root signature; this builder adds them. The
retail executable's root signatures do not carry them either (old upstream PR 7140): its direct call passes a 1.1
description with Flags = 0x80 (LOCAL_ROOT_SIGNATURE), and its root-signature decoder reads Flags as a
zero-extended 16-bit value.
The mask stays unconditional, because it can't touch a public flag: it clears bits 24-31
(kXboxRootSignatureFlagHighByte, runtime/shims/d3d12_xs_rootsig.h), and every public
D3D12_ROOT_SIGNATURE_FLAGS value is in bits 0-11 (the highest is SAMPLER_HEAP_DIRECTLY_INDEXED, 0x800). So it is
safe on every descriptor and blob, whatever built it. root_sig_public_flags_test pins this:
- the helpers keep every flag value in
[0, 0xFFFF]; - the shims' serializers give the host's blob byte for byte for each public flag the host takes. Where the host
refuses only
CBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDorSAMPLER_HEAP_DIRECTLY_INDEXED(Windows 10's in-boxd3d12.dll), they serialize on purpose: the blob is the host's blob without those bits, with the full flags inRTS0and a valid container hash (kDirectlyIndexedFlags,runtime/shims/d3d12_xs_rootsig.h); - a blob with
0x03000080comes back as0x80.
Version 1.2 on older runtimes. The in-box d3d12.dll of Windows 10 (measured on 22H2, 10.0.19045, without the
Agility SDK) and of Windows 11 23H2 (#361) serializes root signatures only up to 1.1. On Windows 10 it rejects even an
empty 1.2 description with E_INVALIDARG, and D3D12_FEATURE_ROOT_SIGNATURE reports HighestVersion 1.1 (#528).
Version 1.2 differs from 1.1 only in
D3D12_STATIC_SAMPLER_DESC1::Flags. So on such a host, the d3d12_xs serializer rewrites a 1.2 description whose
static samplers all have Flags == 0 as the same root signature in 1.1. It refuses one that uses sampler flags (a
UINT border colour or non-normalized coordinates) with a log line, since 1.1 can't express them. The host is probed
once with an empty 1.2 description. root_sig_test checks the rewrite field by field and through the host
deserializer.
Heap-directly-indexed flags on older runtimes. The same in-box d3d12.dll refuses
D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED and ..._SAMPLER_HEAP_DIRECTLY_INDEXED in the
serializer at every descriptor version, with E_INVALIDARG and "Unsupported bit-flag set (root signature flags c00)"
(measured on 10.0.19041.4355; 1.0 and 1.1 both fail). Its deserializer and its devices take a blob that carries
them: a blob serialized without the bits, patched back in and re-hashed deserializes with Flags = 0xc00 and creates
a WARP root signature. So the d3d12_xs serializer, when the host refuses and the description sets either bit,
serializes again with the bits cleared and puts them back into the produced RTS0 chunk, recomputing the container
hash. A host that takes them (Windows 11) gets one call and its own blob back. d3d12_xs_root_signature_test covers
both descriptor versions and checks the flags through the host deserializer and a device; the test-side
d3d12test::serialize_root_signature helper does the same retry for tests that serialize directly.
Things that can invalidate this simple model, all Open:
-
Shader visibility. The layer starts with one global block in root-parameter order and treats visibility as access control, not as a per-stage reordering. If the console driver instead omits invisible parameters per stage, a VS and a PS would need different values at the same push-constant offsets, which Vulkan cannot express with one block; that would force per-stage blocks or a per-stage indirection. Measured, VS/PS (D3D-318): consistent with one block in root order. The game's shaders carry no
RTS0and the executable that pairs them into pipelines is not in the package, sopython -I tools/user_sgpr_census.py <spirv/index.json> --pairspairs a VS with a PS by technique name instead (names alike apart from theVS_/PS_token) and compares the user SGPRs both read. Over the 1.0.2.1 corpus: 166 techniques have both stages (225 VS, 203 PS, 358 combinations).- The 379 SGPRs both stages read have the same kind (pointer or constant) in every case. Over all 26,196,976 VS × PS combinations, the control, 25.5% of the shared reads differ in kind.
- In 79 combinations one stage reads an SGPR the other skips, below an SGPR both read. If that parameter were omitted from the other stage, the parameters above it would move down one SGPR there; all 111 shared reads above such an SGPR still agree.
It can't tell a hidden parameter from a visible one a stage doesn't read, and it doesn't see the root signature, so the executable's pipeline table would settle it;
tests/test_user_sgpr_census.pyshows that the two models give different counts. Mesh shaders (base s16) and the compute signatures are not covered here. -
Root signature larger than 32 dwords. D3D12 allows up to 64 dwords. The console has 32 user SGPRs, so a driver must spill the rest to memory, probably behind a pointer in the user data. The current shader contract has no representation for that. The likely answer is that this game keeps its root signatures small (bindless descriptors, a few constants), but it must be measured. If a large root signature appears, the spill layout has to be reverse-engineered from the shader's loads. Measured on the shader side (D3D-315, spill policy above): zero below-base spill-pointer candidates in the translated shaders. The root signatures themselves, and how many exceed the budget, are still to be dumped from the executable.
-
Direct heap indexing. The bound heap base and stride are not root parameters. Measured (D3D-329, section 3.4): each heap's base reaches the shader as a 32-bit pointer in an entry SGPR, inside the user data for compute (and below
s32for the graphics stages, whose user count is not measured yet), and the stride is compiled into the shader's offsets. So the translator needs no new runtime value; the layer has to write the bound heap bases into the user-data slots the root-signature mapping assigns them. The root signature flag tells us direct indexing is enabled; the shader's address arithmetic identifies the base. -
Static samplers. D3D12 static samplers do not consume root parameters. The console driver may place their S# values in a fixed table. The layer registers every static sampler's S# in the hash table, so a shader that loads it by value works; a shader that expects a driver table needs that table's location (Open).
CreateRootSignaturedoes the registering, for 1.0, 1.1 and 1.2 blobs: each static sampler is encoded asCreateSampler2encodes the same description (the fiveD3D12_STATIC_BORDER_COLORvalues, two of them UINT, and the 1.2 flags), and gets a sampler in set 0 and a key in the hash table without a heap slot. The entry outlives the root signature.d3d12_descriptor_testchecks the key before and after and samples with it. loads it by value works; a shader that expects a driver table needs that table's location. Measured (SHADER-735): no sampling instruction in the corpus was found reading an S# from a fixed table (0 of 366,628; 0.66% stay undetermined under the conservative reading), so on this evidence the layer has none to emulate; the counts and their limits are under "Where the sampled S# comes from" below. -
Descriptor-table high-dword truncation. If a shader forces the high dword of a table pointer to zero, the table must be below 4 GB; the layer allocates all shader-visible heaps there. If a shader forces a resource VA's high dword to zero, the resource must also be low; that would constrain the arena layout. Measured on 2026-11-22 over package 1.0.2.1 (
python -I tools/ptr_truncation_census.py <work>/shaders/disasm, all 26,503 shaders, thetruncates_high/ptr32_lorule oftools/shader_meta.py): 25,865 shaders truncate at least one pointer (VS 2,038 of 2,236, PS 11,666 of 12,101, CS 2,684 of 2,689, GS 195 of 195, MS 9,282 of 9,282), 86,036 truncated pointers in all, at most 5 per shader. Every one is the base of a 4/8/16-dword descriptor load (s_load_dwordx4/x8/x16, a table pointer) from a user SGPR, and no 1–2 dwords_loadbase is truncated. Noglobal_*in the corpus takes its base from SGPRs: its 10,548global_*instructions (530 shaders) address through VGPR pairs, which the classifier does not follow. 25,669 shaders truncate every user-SGPR pointer they dereference, 196 only some (the 195 GS, whose 64-bit s8 pointer has a high dword the classifier cannot resolve, and one CS), and the other 638 dereference no user-SGPR pointer. Bases not rooted in a user SGPR (462 shader/access combinations) never have a constant-zero high dword. So what is measured to need the low 4 GB is the descriptor heaps; buffer addresses reach the shaders inside V#s (48-bit bases) or in VGPRs forglobal_*, and this count sees neither, so it does not show that buffers may sit above 4 GB.
Where the sampled S# comes from (SHADER-735; counts only). tools/sampler_source_census.py follows the four
SGPRs of the sampler operand of every image_sample*, image_gather4* and image_get_lod back to where their
values are made: through constants, scalar loads, SGPRs spilled to a VGPR and read back, and joins, where it keeps
the sources of every path. Over the 1.0.2.1 corpus (26,503 listings, none skipped; the ones with embedded data
words are re-anchored as the translator does) 14,025 shaders sample, with 366,628 such instructions:
| stage | sampling instructions | loaded through user data | literal | held in user SGPRs | other base | undetermined |
|---|---|---|---|---|---|---|
| CS | 120,816 | 63,141 | 57,674 | 0 | 0 | 1 |
| MS | 21,992 | 10,142 | 9,723 | 0 | 0 | 2,127 |
| PS | 221,157 | 115,109 | 106,048 | 0 | 0 | 0 |
| VS | 2,663 | 1,020 | 1,351 | 0 | 0 | 292 |
| all (the 195 GS do not sample) | 366,628 | 189,412 | 174,796 | 0 | 0 | 2,420 |
- Other base is what a driver table would be: some dword of the S#, on some path, held in or loaded through a
constant address, a system SGPR (at or above
USER_SGPRin CS;s32and up in the graphics stages, and the NGGs3in MS and GS) or a code-relative address. It wins over every other class, the undetermined one included, and it is empty in every stage. - Loaded through user data: an
s_load_dwordx4or wider at an address that starts from a user SGPR, 179,602 at a static offset (0x540 at most) and 9,810 at a run-time one. No constant is added to any of these pointers, soconstant table address + user index, which is the same arithmetic asuser pointer + constantand which the classes could not tell apart, does not occur either. All 189,412 are in shaders whoseSFI0sets the sampler-heap bit: no shader without it loads an S# from memory. Whether one of these loads goes through a descriptor table or through the sampler heap base of section 3.4 the shader cannot say; both are a user SGPR. - Literal: four immediates, 105,235 in shaders with the sampler-heap bit and 69,561 in shaders without it,
which sample with nothing else. 28,659 of them, in 6,824 shaders, build one dword with
s_brev_b32.tools/shader_meta.pydoes not fold that instruction, soliteral_samplersin the index does not list those S#s yet and the layer cannot register them from it. - Undetermined (0.66%, in 300 shaders): with every edge followed, some path brings something else into the S#
registers. 2,355 read the S# back from a VGPR it was spilled to, and one path does not save it there (on the
paths that do, it is a load through user data); in 64 the paths bring a literal and a load through user data;
in 1 a path brings a value the dataflow does not follow. All of them go away with one kind of edge: the S# is
made or saved inside a region the compiler jumps over with
s_cbranch_execzwhen no lane is active, and the sample comes after the region. Without the taken edge of those branches (the region always runs, as it does whenever a lane is active) the same analysis gives all 2,420 a class: 2,419 loaded through user data, 1 literal. The table keeps them apart because that second reading trusts that nothing samples on the skipping path; lane masks are not modelled.
So, as far as the shaders can answer it, this corpus gives no evidence of a driver sampler table: no instruction
lands in the other-base class, and the 2,420 undetermined ones are not shown to be free of it by the conservative
reading, only by the one that assumes nothing samples on an exec-zero skip.
What the census does not show: it reads the shaders, not what the driver writes at the addresses they load from;
the graphics stages' user count is the translator's 32, not a measured one (question 3 in section 8.2); and it
cannot say which S# is a root signature's static sampler. The literals are the candidates, since a static sampler
is known when the shader is compiled and half of the sampling instructions build their S# from immediates, but
that is a hypothesis until the root signatures are matched against them. Reproduce with
python -I tools/sampler_source_census.py <work>/shaders/dxbc/disasm --jobs 4 --expect-none other_base, which
exits 1 if an instruction lands in that class.
What the console's own D3D12 libraries show (names only, read statically from a user's console system-file dump; nothing from those files is in this repository):
- Two root-signature ABIs exist. The driver's validation messages name a flag
D3D12XBOX_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI, and require it for ray tracing (XDXR) and for pipelines with an amplification shader. So the default is the register-based ABI this section describes, and a root signature can opt into a memory-based one. The shader compiler has the matching switch,XBOX_FORCE_MEMORY_BASED_ABI. - The ABI is decided when the shader is compiled, not by the driver at bind time. The shader compiler has the
intrinsics
__XB_GetShaderUserDataand__XB_GetRootSignatureSpillPointer. That answers the "larger than 32 dwords" question above: parameters that don't fit in the user SGPRs spill to memory, and the shader reads a spill pointer from its user data. Because the game ships precompiled shaders, each shader's own user-SGPR reads (and any loads through a spill pointer) are the authoritative map; the metadata below is how to recover it. d3d12_xs.dllis a thin front end (about 50 KB). It loads the user-mode driver,xgs12_10.dll, which implements the device and command lists and exportsUMD*entry points.xg_xs.dllexports the texture layout functions (XGComputeTexture2DLayout,XGComputeOptimalSwizzleMode, ...), the reference for untiling textures.- The driver keeps the standard D3D12 root-signature cost limit: 64 dwords, with descriptor tables costing 1 and root views 2.
Required build metadata. To solve the mapping without guessing, spirv/index.json should gain, per shader:
- the set of user-SGPR dwords read before first write, and whether each is used as a 32-bit constant or a 64-bit pointer;
- the descriptor stride(s) implied by descriptor address arithmetic;
- whether the shader uses the code base (
s_getpc_b64) and, if so, in which stage; - the literal S# values it builds from immediates;
- the input signature (semantic name/index, register, mask, component type), not just the register numbers;
- the FSSM content hash (the PSO lookup key, section 3.6);
- the descriptor-table / heap-direct-indexing mode the shader was compiled for.
The runtime can then reconcile the root signature with the shader's reads and fail loudly on a mismatch instead of rendering silently wrong.
tools/shader_meta.py (invoked by tools/rdna2spirv.py and verified by tests/test_shader_meta.py) now emits these
fields into spirv/index.json: user_sgpr_reads (const32, ptr64_lo/ptr64_hi, ptr32_lo, vsharp, tsharp,
ssharp), descriptor_strides, uses_code_base, literal_samplers, input_signature (ISG1 semantic name/index,
register, masks, system value, component type), fssm_sha256, and descriptor_access (DXBC SFI0 direct-indexing
bits 25/26 plus table-load and high-dword-truncation flags). A missing or malformed ISG1 signature leaves the vertex shader
without recorded inputs. In that case the runtime accepts any input layout when filtering shader candidates.
3.6 Shader identity, PSOs and feature selection
The Xbox native graphics pipeline descriptor identifies stages by the digest in a DXBC HASH part (see
docs/fspx.md, kind 7). The shaders stage writes <work>/shaders/spirv/native_hashes.txt from the user's
carved DXBC containers and translation index. After the version header, each line contains the 16-byte digest
in lowercase hex, the translated stage and a container path relative to the index, separated by tabs.
Containers sharing a digest must agree on stage and FSSM hash. A collision fails the stage and preserves the
previous catalog. Rerunning the shaders stage checks its source fingerprint, including the catalog writer.
To add or refresh just the catalog in an existing translation, run
python -I tools/native_pso_hashes.py "<work>/shaders/dxbc" "<work>/shaders/spirv".
A D3D12 PSO carries DXBC containers, not SPIR-V. The layer identifies a shader by hashing the FSSM payload (the
native RDNA2 program inside the container) and looking it up in a build-time table keyed by (stage, hash). The
build emits that hash for every translation; the runtime extracts the FSSM chunk from the DXBC container the same
way tools/fssm_unpack.py does. The current spirv/index.json is keyed by carve name, which the runtime may not
have; add the content hash to the index.
Pipeline creation:
D3D12_GRAPHICS_PIPELINE_STATE_DESCis supported (CreateGraphicsPipelineState), as are the compute desc and theD3D12_PIPELINE_STATE_STREAM_DESCsubobjects (CreatePipelineState; "Implemented (D3D-29)" below): the stream's subobjects are parsed in order, and an unknown type isE_INVALIDARG.- Build
VkPipelineShaderStageCreateInfofrom the translated module and the index entry. Mesh shaders useVK_EXT_mesh_shader(AS/MSsubobjects → task/mesh stages); geometry uses the geometry stage; compute uses a compute pipeline. - The index's
max_vertices/max_primitivesalready size the SPIR-V mesh output arrays. Vulkan has no per-pipeline mesh output limit: check them againstVkPhysicalDeviceMeshShaderPropertiesEXT::maxMeshOutputVertices/maxMeshOutputPrimitivesand fail at pipeline creation if the device is smaller. - Vertex input comes from the PSO input layout plus the shader's ISG1 signature. The translator's rule is
location = D3D input register, not the semantic's HLSL slot. Match the layout element's semantic name/index
to the ISG1 element to get the register, then create a
VkVertexInputAttributeDescriptionwith that location and the DXGI format. ResolveD3D12_APPEND_ALIGNED_ELEMENTagainst the preceding element and honourInputSlotClass/InstanceDataStepRate. The index entry needs the semantic map (section 3.5). - Enable the features the index entry lists: barycentrics, fragment interlock, mesh, geometry, Float64, Int64, buffer device address, storage image without format, maintenance8.
- Request the subgroup size each shader was translated for (
requiredSubgroupSize64 or 32) where the device lists the stage inrequiredSubgroupSizeStages, and say so in the log where it cannot (section 3.2, "Subgroup size"). - Pipeline caches: graphics and compute PSOs use one
VkPipelineCacheper device. On first use the runtime reads thepipelinesbuild stage'spipeline_cache.binbeside the executable if its Vulkan header matches the device and pipeline-cache UUID. When the file is absent or incompatible, the runtime starts with an empty cache. The offline checker matches the runtime's layout and subgroup request for compute shaders with no descriptor bindings and the standard 144-byte push-constant range. The runtime writes its ownpipeline_cache.session.binon device teardown, and, since a title never releases its device, whengta6rtends with the device alive: at the run's exit, at a console close and from an unhandled-exception filter (a fault in the title or its DLLs, the int3 after a device loss). The title's ownSetUnhandledExceptionFilteris served by the runtime, which keeps its filter first and passes the exception on. That exit write (save_pipeline_caches_at_exit,shims/d3d12_compile_exit.h) waits 1 s for a build still running on a title thread, then writes the pipelines finished so far, with 3 s for the write itself. A compatible session file initializes the live cache directly if there is no offline seed. With both files present the session cache merges into the offline seed.LEONIDA_DIRECT_SESSION_CACHE=0also uses a merge when only the session exists. The files must match the Vulkan vendor, device and pipeline-cache UUID. Vulkan supplies an opaque snapshot. Replacing part of the previous file would corrupt it.LEONIDA_PIPELINE_CACHE_BYTEScaps what a session adds, at a checkpoint or at teardown (an offlinepipeline_cache.binseed, which the driver hands back as part of the union, is not counted; 4 GiB by default, zero disables the session file). The session file can't keep a crashed run's compiles: it is written at teardown and at the optional checkpoints below only. The heavy pipeline cache (RT-HEAVY-PIPELINE-CACHE,runtime/src/heavy_pipeline_cache.h) keeps the graphics ones; compute pipelines go to the per-pipeline journal described below. Every graphics build first asks the corpus cache withVK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT. A pipeline the corpus doesn't have is built against a second cache, seeded frompipeline_cache.heavy.binnext topipeline_cache.bin, so that cache holds only the corpus's misses. A build that takes at leastLEONIDA_HEAVY_PIPELINE_CACHE_MS(500 by default) marks the heavy cache for writing. A thread of its own writes it whole: 3 s after the newest slow build, and no later than 20 s after the first unwritten one, through the same staging file and rename as the session cache. A crash therefore loses at most the last 20 s of slow builds, and the next launch starts with the rest. A write that fails, or whosevkGetPipelineCacheDatareturns anything butVK_SUCCESS(VK_INCOMPLETEmeans the cache grew after the size query, so the blob is truncated), leaves the previous file in place and the cache dirty: it is tried again 5 s later, the delay doubling with each failure in a row up to 2 min, so the cache is not left unsaved until teardown and a write that keeps failing does not spin. At device teardown the thread stops, and the cache is written if any build went into it. Fast builds are kept that way: without an offline seed every build is a miss, so they no longer reachpipeline_cache.session.bin.LEONIDA_HEAVY_PIPELINE_CACHE_MS=0turns the heavy cache off, and with it thepipelineCreationCacheControlfeature unlessLEONIDA_PIPELINE_COMPILE=cache-onlyasks for it. A cache-only create (cache-only) is left as it is. A driver can stop keeping new pipelines once its cache is large, with no error. On NVIDIA 610.88 (RTX 5060 Ti), a 1.23 GB or 1.35 GB cache came back fromvkGetPipelineCacheDatathe same size to the byte after a 2 s compile (with the 1.35 GB one the next process compiled the pipeline again; a hit then comes only from the driver's own disk cache), where an empty cache grew ~210 KiB and served the next process in 0.01 s. In the game, seeded with the 1.23 GB file, 68 of ~110 builds over 200 ms were slow again in the next run; started with no seed, 5 of 164 were. An older cache of other pipelines stopped growing at 4.9 GB, so the point is not a fixed size. The runtime takes the cache's size when it creates it and at each session save, counts the title's builds that took at least 200 ms (a hit takes a few milliseconds), and says once when 16 or more of them compiled while the cache grew by less than 64 KiB. The remedy is a smaller seed: withoutpipeline_cache.bin, the session file holds only what the title builds.LEONIDA_SKIP_COMPUTE=<part of a name>[,<part>...](all: every compute program) never builds the matching compute programs at play and drops their dispatches, direct and indirect; the first dropped dispatch of each is logged. It is a way past a program that hangs the GPU while the program or its input is fixed, not a fix.--precompile-pipelines(below) builds them anyway unless it is given--skip-listed.LEONIDA_STARTUP_CACHE_CHECKPOINTS=1also schedules a snapshot after a successful pipeline build, at most once per 120 seconds. It starts on the compile worker when queued builds have drained and the device has no active builds. The driver fills a mapped staging file directly. A successful snapshot atomically replaces the session. An interrupted write preserves the previous cache; the next launch removes unheld staging files older than ten minutes. While the compute warm-up has builds queued that idle checkpoint never starts, and a boot that ends by a crash, a device loss or a kill never reaches teardown, so neither file used to keep that boot's compute pipelines. Compute pipelines are therefore journaled one file each (src/pipeline_cache_journal.h):pipeline_cache.d/cs-<hash>.binbeside the session file, named by a hash of the SPIR-V words, the stage flags and subgroup request, the push-constant range and the bindless layout. A build creates aVkPipelineCachefrom its file (if the header names this device and pipeline-cache UUID) and creates the pipeline against it; when the driver reports a compile (creation feedback withoutAPPLICATION_PIPELINE_CACHE_HIT, or no file), that cache is written back to the file at once, through a staging file renamed over it. Without a file, and withpipelineCreationCacheControl, the shared cache is first asked withVK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BITwhen it was seeded from a file, so the offline seed still serves a first boot. NVIDIA 630.20 answers that flag with a compiled pipeline (seconds) instead ofVK_PIPELINE_COMPILE_REQUIRED, so the first answer that took 250 ms or more without the cache-hit bit stops the asking, and that pipeline is built again against its journal cache so it gets a file (a fast answer without the bit is the driver's own disk cache, and a valid one;LEONIDA_PIPELINE_JOURNAL_ASK_SHARED=0: never ask). All driver calls of a compute build (shader module, journal cache, pipeline) run in one turn of the compile gate, with no file I/O in it: from the journal a build takes milliseconds, the warm-up worker makes them back to back, and three warm boots whose cache and module calls were outside the gate lost the device in avkQueueSubmit20-25 s in (no GPU fault, no TDR). The files take 2-3 MiB a pipeline on that driver (about 3.6 GiB for the 1700 a boot builds);LEONIDA_PIPELINE_JOURNAL_BYTES(32 GiB by default) caps them. At a device's first pipeline, staging files older than ten minutes are removed and, past the budget, the least recently used files until three quarters of it is left: a file's modification time is its last use (written, or touched, at most hourly, when a build finds its pipeline there), so files no build names any more after a translator regeneration go first. Measured on an RTX 4070 Ti (driver 630.20): 17 compute modules of 0.6-0.7 MB SPIR-V took 222 s to compile and 0.04 s to create from their cache; a boot's ~1000 warm-up builds of 128 KiB or more took 81 s cold and 1.8 s from the journal, and the submissions' compile-gate waits went from 77 s to none. Nsight Aftermath crash dumps (LEONIDA_AFTERMATH=1) appear to make the driver compile again whatever the caches hold: boots loading the same 317 MB session file logged no compute build of 2 s or more without Aftermath and 88-95 with it. The VK_NV_device_diagnostics_config flags alone do not (vk_pipeline_check--nv-diagnostics: 17 of 17 cache hits).LEONIDA_PIPELINE_JOURNAL=0(orLEONIDA_PIPELINE_CACHE_BYTES=0) turns the journal off.LEONIDA_PIPELINE_CACHE_DIR=<folder>moves the journal with the other files, so builds of gta6rt in several folders can share one; the file names and the driver's checks keep a pipeline from one build from being taken for another's.gta6rt --precompile-pipelines [--threads N] [--big-threads N] [--all] [--smallest-first] [--limit N] [--min-bytes N] [--max-bytes N] [--filter PART]... [--skip-listed] [--list]fills the journal ahead of play, with no game: it creates the Vulkan device as--rundoes (so the same environment gives the same journal names and driver keys: LEONIDA_SHADERS, LEONIDA_PIPELINE_CACHE_DIR, and LEONIDA_DEVICE_FAULT/LEONIDA_AFTERMATH, whose diagnostics config makes other pipelines) and builds every compute entry of the library through the dispatch path (build_compute_pipeline), largest first, on below-normal-priority threads. Entries with a usable journal file are skipped (only their header is read), so it can be stopped and started again. Running as gta6rt.exe it also fills NVIDIA's disk cache, which that driver keys by the executable's name. Measured on an RTX 4070 Ti (driver 630.20), 4 threads: modules of 3.6-5.8 MB took 46-145 s each, 12 in 312 s, about 3.5 GB of host memory each while in the driver (14.5 GB peak for four). Graphics pipelines are not covered: they are built at a title's draw from its PSO description and the bound formats, and take milliseconds.LEONIDA_SKIP_COMPUTEdoes not narrow the build: it is a play-time setting, players run the pre-compile with the game's environment, and a program left out here would stay out of the journal after the list is shortened. The run says how many entries the list names and builds them;--skip-listedleaves them out on purpose. The last line counts what was built (compiled, or found in a cache), what was journaled already or being built by another process, what failed, and what was left out and why: by--skip-listed, not buildable on this device (no SPIR-V, set-0 bindings without a bindless set, workgroup memory over the limit), or filtered out (--filter, the size bounds,--limit). The 89-167 s per program behind the skip list of the largelibrary/programs came from wave64-emulated packs. Measured with a native wave64 pack on an RX 7900 XTX (RADV, Mesa 26.3.1, Wine): all 721 programs of 2 MiB or more built, 360 of them in 170 s on 32 threads, 2.5-32 s each, the largest (13 MiB) in 28.5 s alone, at a peak of 14 GiB of RAM for the process. With all of them in the journal and no skip list, two world runs took them all from the journal (none built in the game) and ended as runs with the skip list do, in an idle-queue device loss or a stop with the GPU idle (running.md); whether their output is correct is not measured.LEONIDA_COMPILE_HELPER=1(shims/d3d12_compile_helper.h) keeps first-ever compiles out of the title's process: the driver's locks, which a longvkCreateComputePipelinesholds and avkQueueSubmitof the same process waits for, are per process. A compute build ofLEONIDA_COMPILE_HELPER_MIN_BYTESor more (128 KiB) with no journal file writes a request beside the journal (requests/<name>.req: the entry and a priority, 0 for a use, the module size for a warm-up) and starts the helper at the first one (gta6rt --compile-server --parent <pid>, the same executable and environment, so the same device and journal names). With asynchronous builds (LEONIDA_ASYNC_PIPELINES=1, the intended mode) nothing waits: the build answers deferred, the variant goes back to idle, the dispatch is skipped and counted, and each later use looks at the request (a file check, the module is not read again) until the journal file is there and the pipeline is created from it, a cache hit. A warm-up only asks, in either mode, so the warm-up worker writes its requests ahead and the helper's threads (LEONIDA_COMPILE_HELPER_THREADS, 2) build them in parallel, the most urgent first; a warm-up the helper builds is never held back while the title submits. Without asynchronous builds a dispatch waits for its file, holding nothing of the driver's (LEONIDA_COMPILE_HELPER_WAIT_MS, default 120 s, 0 for no limit). A failure (requests/<name>.failed, the helper gone) builds the pipeline here as before, and so does a request that is no longer listed (<name>.reqgone with no answer) or one still pending afterLEONIDA_COMPILE_HELPER_PENDING_MS(default 120 s): the helper cannot hold a dispatch forever. The helper checks that its journal name is the one asked for before it compiles (the name is a hash of the module and the device, no driver call), ends with the process that started it, runs alone per journal, and with nothing asked fills the rest of the library, smallest module first, onLEONIDA_COMPILE_HELPER_IDLE_THREADS(1, always one fewer than its threads) at idle priority; the journal names it worked out are kept inrequests/names.idx(with each module's size and time and what the names depend on), so a later helper does not read every module again.requests/<name>.buildingis a lock file a process holds for the whole build (no sharing, deleted by the OS when that process ends, killed or not), whose contents name the process: the helper and--precompile-pipelinesleave an entry its holder is building to it, and a file no process holds is stale whatever process id it names. Measured, RTX 4070 Ti, driver 630.20, a boot with an empty journal and the helper waiting (no asynchronous builds): the helper compiled 171 pipelines of 128 KiB or more (148 s in its driver), every one of them was a hit in the title's process (at most 2 ms), and no submission waited at the compile gate. Under Proton, pass a Wine path, for exampleLEONIDA_PIPELINE_CACHE_DIR='Z:\opt\leonida\cache'. Async warm-up workers publish to the same directory. For a disposable session,LEONIDA_PIPELINE_JOURNAL_SEED_DIR=<absolute existing directory>can name a separate, trusted read-only set of per-key compute journal files. The runtime prefers a compatible writable entry, then tries the same key in the seed; both use the existing size and device/driver header checks. A seed hit neither copies an entry nor refreshes its mtime. All writes, LRU touches, staging cleanup, eviction and byte accounting belong to the writable journal only, including replacement of an incompatible local file. The seed must be distinct from the writablepipeline_cache.d, not its ancestor or descendant; an explicitly unusable or overlapping root disables the journal. This setting does not grant access or authenticate cache data. Use only trusted, privately produced files on a read-only mount/ACL with stable, disjoint directories and no linked files between them. Leave unset for the original single-directory behavior. Per-key names are unchanged: externally precompiled files for the same pipeline identity can be read without a persistent writable shared journal. During normal runtime, a compatible local or external entry is used before requesting the helper. The offline precompiler and compile-server instead read and populate only the writable journal, even when a separate seed is configured. An external hit is not a published response to a helper request; its readiness check still requires a compatible file at the requested writable path. Both modes validate the configured directory pair before enabling journaling. To check the two tiers without game files, buildd3d12_compute_journal_test, then runpython scripts/check_compute_journal_overlay.py <path-to-d3d12_compute_journal_test.exe> --require-hit. This uses four fresh processes, two authored compute shaders and a disposable cache. It checks dispatch results, reported application-cache hits (where supported), local publications, and that old seed contents/mtime stay put.LEONIDA_TRACE_PIPELINE_COMPILE=1records each graphics and compute build's trigger, thread, elapsed time, SPIR-V size, shader names and Vulkan application-cache feedback (1 hit, 0 miss, -1 unavailable). It also times cache reads, merges, writes and draw/dispatch pipeline lookups that take at least 1 ms.LEONIDA_ASYNC_PIPELINES=1schedules cold first-use builds on the warm-up worker ahead of speculative work; how long a submission waits for them, and what is skipped, is "Pipelines still being built" below. Strict replay builds synchronously and waits for every build.LEONIDA_COMPUTE_WARMUP=0restricts the worker to pipelines requested by the title.LEONIDA_PIPELINE_ORDER_LOG=1records the order in which the title first asks for pipelines (RT-PIPELINE-PREWARM-ORDER, phase 1;runtime/src/pipeline_order.h). It is off by default: nothing reads the file yet, so a run that does not ask for it writes nothing and its pipelines carry no hook. For each pipeline and variant (the unbound-slot mask for graphics, 0 for compute) that a dispatch or draw names for the first time, one line is appended topipeline_order.logbesidepipeline_cache.session.bin(soLEONIDA_PIPELINE_CACHE_DIRmoves it):P <c|g|m> <key> <variant hex> <created ms> <first use ms> <build ms or -> <ready 0|1> *<checksum>, with the times in milliseconds since the process started. The key is the SHA-256 of the title's own description of the PSO (GetCachedBlob's key; a mesh pipeline's MS is folded in), not of the SPIR-V, so a translator change keeps it. A build that ends after its line was written addsB <key> <variant hex> <build ms> *<checksum>; a session starts withS 1 <vendor hex> <device hex>. A compute pipeline'sPline is followed byE <key> <variant hex> <name hash hex> *<checksum>: the name hash is 16 hex digits of FNV-1a 64 over the name of the library entry the pipeline was made from (the name itself is not written). A reader from beforeElines skips them (counted as lines not read). Each line ends with an FNV-1a checksum: a cut or damaged line is skipped on read, never fatal. The hook sits in replay'sComputePipeline::requested/GraphicsPipeline::requested, called where a submission is prepared, also for a handle that exists already (a warm-up build, a cached one); the recorder decides "first" with one compare-and-swap in a table made at start, never blocks and allocates nothing (a non-blockingtry_lockon the first request of a pipeline and of a variant), and a thread of its own appends every 250 ms, so a killed process loses at most that. The record holds 8192 lines per run (the rest is counted, not kept); a file past 8 MiB is set aside aspipeline_order.log.prev. At exit (the exit cache save, or the device's release) one line gives the counts:[rt] pipeline-order: requested N, already ready M, median lead X ms. "Lead" is first use minus creation. A PSO made from a pipeline state stream on the console path is created when it is first bound, so its lead is the title's, not an upper bound on a head start. A root signature the runtime does not know is hashed by its address, so the key of a pipeline made with one can change from one run to the next. The file is local, like the cache files, and is not meant to be attached to a report: quote the counts. It changes no build, order or cache.LEONIDA_PIPELINE_PREWARM_ORDER=<file>reads such a log at boot and builds, ahead of their first draw, the graphics and mesh pipelines an earlier run asked for first (RT-PIPELINE-PREWARM-ORDER, phase 2;runtime/src/pipeline_prewarm.h).1namespipeline_order.logbeside the session cache; it is read before this run's own record is appended, so both variables can be on together. Of the runs recorded on this GPU (vendor and device id), the one with the most records is read, the newest on a tie. When the title creates a PSO whose key is in it, each recorded variant is queued on the compile workers as a warm-up at its recorded rank: after every demanded build, one warm-up at a time and none while a demanded build runs (PipelineCompiler; the compile-gate finding in "Compile workers" below is why), ahead of the compute warm-up's size order and before the cache checkpoint. A variant 0 built at create is skipped. A console stream kept for its first bind (LEONIDA_PIPELINE_COMPILE=on-demand) is otherwise parsed only there, which would leave the prewarm no lead: when its pipeline is in the plan, the parse is queued as its first prewarm job instead (at the rank of its first recorded variant, on a compile worker), and its variants follow with their ranks. A bind that comes first waits for that parse, which it would otherwise have done itself. Records are taken in order until their recorded build times add up toLEONIDA_PIPELINE_PREWARM_BUDGET_MS(default 300000; a record with no build time counts 1000 ms), and at mostLEONIDA_PIPELINE_PREWARM_MAX_ENTRIES(default 4096). Compute records are left to the compute warm-up and togta6rt --precompile-pipelines. A missing or unreadable file, a file with no readable record and a file from another GPU are ignored with one[rt] pipeline-prewarm:line; a damaged line is skipped, as are line types a v1 reader does not know (E). A queued prewarm holds no reference: a PSO released first drops it. One that is already running when the title submits still holds the compile gate (LEONIDA_COMPILE_GATE), as any warm-up does. A queued build holds no reference to its PSO or device (PipelineCompiler,runtime/shims/d3d12_pipeline_compile.h). A PSO's last release drops its queued builds and returns at once; one already running is left to finish, and the worker deletes the PSO after it (PipelineState::last_release). The PSO's device reference goes at the release, so the release that tears the device down waits for that build, drops the device's cache checkpoint, and the last device stops and joins the worker before any Vulkan object goes; the session cache is written after that. gta6rt, which ends with the device alive, drops the queue and waits up to 2 s for a running build beforeExitProcessand on a console Ctrl+C, Ctrl+Break or close; after that nothing is queued, and a first use builds in place (d3d12_compile_teardown_test).GetCachedBlobrecords the vendor, device, driver version,pipelineCacheUUIDand a SHA-256 of the description withoutFlags, sealed by a checksum (runtime/src/cached_pso.h). The answers are the host's, measured on an RTX 3060 and WARP: the same description is accepted; another shader, root signature content or state, a changed byte, a truncated blob or a pointer with size 0 giveE_INVALIDARG; a null pointer with a size is ignored; another adapter givesD3D12_ERROR_ADAPTER_NOT_FOUNDand another driverD3D12_ERROR_DRIVER_VERSION_MISMATCH.ID3D12PipelineLibraryis an in-memory map plus the Vulkan cache.d3d12_pipeline_library_host_testcompares public argument checks with the host. It runs each host call in a separate process because a fault can leave the device unusable. It reports serialized sizes and the result of flipping a trailing byte for each device's own format.d3d12_pipeline_library_testchecks that the layer rejects a nonzero reserved field in itsLPL1header. On Windows 11 build 26100 (RTX 5070 Ti, driver 610.74), all 72 public-argument comparisons matched. The previous 74-value run (RTX 3060, driver 610.88) included the two results from the trailing-byte case.CreatePipelineLibrary: a foreign, truncated or corrupt blob, the other device's blob, or a null pointer with a size isE_INVALIDARG, and*ppPipelineLibraryis left as it was. One of the layer's own blobs from another format version isD3D12_ERROR_DRIVER_VERSION_MISMATCH, the documented code for a cache from another driver. A pointer with size 0 is an empty library; a longer blob than the header is accepted; a null output isS_FALSE.- The library is a device child, not a pageable object:
QueryInterface(ID3D12Pageable)isE_NOINTERFACE. LoadComputePipeline/LoadGraphicsPipeline/LoadPipelinewith a null output areE_INVALIDARG, as is an unknown or empty name.Serializewith a buffer smaller thanGetSerializedSize()isE_INVALIDARG. The serialized size and bytes are each device's own (the host's empty library is 900 bytes, the layer's 16).- Not compared: the calls the host runtime faults on (
Serialize(nullptr, n),StorePipelinewith a null PSO,Load*with a null name or description); the layer answersE_INVALIDARGfor each.
- Compiles at draw time: the first draw of a graphics pipeline, the first dispatch of a compute pipeline the warm-up
has not built, and each variant are compiled for the submission that needs them.
prepare()leaves each one that is not built yet toPipelineCompiles, once per pipeline and variant;VulkanQueue::execute_nowthen compiles them side by side on the device's workers (runtime/src/pipeline_workers.h), the submitting thread among them, and writes the command buffer when all are built. Every draw and dispatch has its own pipeline: none is left to a later frame. A pipeline the driver refuses has the result it had whenprepare()built it: a draw or an indirect dispatch fails the submission, a dispatch is dropped (strict replay: fails it too). The resource lock is held while they compile, as it is when each is compiled alone, so a PSO released meanwhile waits for the submission. The workers have ended before the session cache is read at device teardown.LEONIDA_PIPELINE_THREADS=<n>sets the workers: unset, half the logical processors and at most 8;0compiles each pipeline on the submitting thread whereprepare()meets it. Large pipelines (below) are compiled within a memory budget, and the variants of one PSO one after another.LEONIDA_ASYNC_PIPELINES=1is not changed: its builds stay on the compile worker. Measured with synthetic programs never compiled before and the warm-up off (RTX 3080, NVIDIA 621.24, Windows 11, 16 logical processors, 8 workers, three runs each): the first submission of 192 graphics pipelines takes 126 to 143 ms instead of 861 to 882, of 192 variants 124 to 130 instead of 856 to 863, of 96 compute pipelines 74 to 81 instead of 486 to 519, and the process holds about 50 MiB more (the driver keeps memory for each thread that compiles). OneVkPipelineCacheis enough: one cache per thread, merged, was about as fast. Tested bypipeline_workers,replay_pipeline_compilesandd3d12_pipeline_workers. - Large pipelines: a compile takes the driver some hundred bytes of memory for each byte of SPIR-V
(pipeline_check.md, "Limiting concurrent compilation of large modules"), so compute modules over
128 KiB and graphics pipelines of 1 MiB or more compile side by side only while their estimates (512 bytes for each
byte of SPIR-V) fit a budget: three quarters of the smaller of the free RAM and the room under the commit limit, read
again whenever a place at the gate (
runtime/src/large_module_gate.h, one for the process) is given or returned. One always gets in when none is, so a pipeline larger than the budget compiles alone. An estimate counts in full until the compile ends, although the driver has taken part of it by then. They get in in the order they came; while the first in line does not fit, the next behind it that does may pass, as long as all that have passed it would fit the budget together with it, so that a stream of small ones does not keep it out. The ones a submission waits for (and those ofLEONIDA_ASYNC_PIPELINES) go before the warm-up's, which take a quarter of the budget at most and none while a submission that has large ones is compiling on its workers. A thread that waits for its place holds no PSO's lock, and one that has a place waits for none.PipelineCompiles::buildgives a submission as many jobs for large ones as its smallest could be in at once, largest first; where the next one does not fit, the job compiles small ones in the meantime.LEONIDA_SERIAL_BIG_COMPILES=1compiles them one after another instead, as before there was a budget,=0has no limit,LEONIDA_BIG_COMPILE_BUDGET_MBfixes the budget. Measured with synthetic integer modules never compiled before and the warm-up off (RTX 3080, NVIDIA 621.24, Ryzen 7 5800X3D, 8 workers and the submitting thread, three alternating runs each): the first submission of 16 modules of 256 KiB takes 0.8 s instead of 4.0 to 4.8 s, 16 of 512 KiB 2.0 to 2.2 s instead of 10.2 to 11.4, 15 of 1 MiB 5.8 to 6.1 s instead of 29.2 to 31.2, 12 of 0.5 to 2 MiB 8.0 to 10.5 s instead of 38.9 to 39.9. While the 15 of 1 MiB compile, private memory peaks 656 to 676 MiB over what it was, instead of 140 to 147 (one compile takes 85 to 131 bytes for each byte of SPIR-V here, and the driver keeps memory for each thread that compiles). With a budget of 1536 MiB, two at once, they take 18.5 s and peak 202 MiB over. Not measured: other drivers, and the title. Tested bybig_compile_gate,replay_pipeline_compilesandd3d12_big_compute.
Pipelines still being built (PipelineState::queue_build in runtime/shims/d3d12_vulkan_device.cpp). Lazy
pipelines are built at first use, and on the 4070 Ti (NVIDIA 630.20) a large compute pipeline takes the driver 3-10 s,
some 37 s. A submission builds the ones it needs through PipelineCompiles and PipelineWorkers (above), with
resource_mutex_ released while they compile and the large ones within the memory budget of LargeModuleGate.
#2098 had a second path here, a pre-pass in VulkanQueue::execute that built them one after another on the
submitting thread; at the maintainers' decision it was replaced by this one when #2098 was merged.
- Asynchronous builds (
LEONIDA_ASYNC_PIPELINES=1). Prepare asksqueue_build, which answers the handle once built and otherwise queues one compile-worker job at replay's priority and answers null: the draw or dispatch is skipped, the list's other commands replay as recorded, and a later submission uses the pipeline. The job also starts at record time already: atSetPipelineStatefor compute and at each draw for graphics, with the variant its bound targets give (request_pipeline_build). A compute build the compile helper is still making (LEONIDA_COMPILE_HELPER) publishes nothing, so its next use asks again. - Compile workers (RT-ASYNC-COMPILE-POOL, after MoonEyes' design in #2077). The jobs above, the compute warm-up
and the cache checkpoint run on
LEONIDA_COMPILE_THREADSworkers (half the logical processors, 2 to 8). With one worker a driver compile of minutes held every pipeline a submission asked for behind it, and their draws and dispatches were skipped meanwhile. A worker now takes the most urgent job it may: demanded builds first, in the order they came, then warm-ups by module size, then the checkpoint, which waits until no worker compiles. Large builds (compute over 128 KiB, graphics of 1 MiB or more) and warm-ups together take at most threads-1 workers, so one is always free for a small demanded build; at mostLEONIDA_COMPILE_HEAVY_MAXlarge builds run at once (default threads-1, 1 withLEONIDA_SERIAL_BIG_COMPILES=1), each still within the memory gate; warm-ups run one at a time, as before, and none starts while a demanded build is queued or running, since each holds the compile gate for its whole create (MoonEyes measured in #1608 that with the gate on, submissions waited 142 s in all behind warm-ups of about 800 KB, and that withLEONIDA_COMPILE_GATE=0the same boot reached game state 3); and a PSO has one build running at a time, soafter_runningand the teardown rules hold as they were.LEONIDA_COMPILE_THREADS=1is the layout before the pool: one general worker and the graphics-only one; there too a PSO has one build running at a time (two variants of one graphics PSO, one on each worker, let its last release delete it under the other build, qhukz13). A submission still waits at the compile gate for every compute create in flight (and graphics creates too withLEONIDA_COMPILE_GATE=adaptiveor1; the classic default gates compute builds only), so more workers do not shorten that wait (SubmitMutex::CompileTurn;LEONIDA_COMPILE_GATE=0turns it off). - Only the large ones asynchronous (
LEONIDA_ASYNC_MIN_BYTES=<n>, withLEONIDA_ASYNC_PIPELINES=1). With every pipeline asynchronous, the small lighting and post programs are skipped with the large ones until the worker gets to them, and on an RTX 4070 Laptop (NVIDIA 621.40) the world phase was reached with the screen black; with none, a submission waits for each ray-tracing compute program of 2-26 MB of SPIR-V, 2-3 minutes each there, and 17 were built in 30 minutes (measured by OreoFR on the wave64-emulated pack). With the variable, a pipeline under n bytes of SPIR-V (compute: its module; graphics: all its stages, the size the large-compile rules use) takes the path it takes with asynchronous builds off: no record-time request, prepare'sPipelineCompilesbuilds it, and a compile-helper build waits for its file. One of n bytes or more is asynchronous as above. The choice is made once per pipeline at create (async_buildinsrc/vulkan_replay.h, decided bysrc/async_pipeline_size.h). Unset,0or text that is not a decimal number of bytes (which is logged): every pipeline is asynchronous, as before the variable. A large build still goes through the compile gate andLargeModuleGateas before, so a smaller one a submission waits for can queue behind it there;async_pipeline_size_testcovers the decision andd3d12_m4_compute_async_small_waitsa submission whose two pipelines are under the threshold with the worker held (both dispatches run).LEONIDA_ASYNC_MIN_BYTES_GRAPHICS=<n>gives graphics and mesh pipelines (all their stages) a threshold of their own; unset, they takeLEONIDA_ASYNC_MIN_BYTES, as before the variable, and compute always does.0makes every graphics pipeline asynchronous, asLEONIDA_ASYNC_PIPELINES=1did on its own. The reason: @MoonEyes's thread dumps (RTX 4060,LEONIDA_ASYNC_MIN_BYTES=1048576) showed the draw thread building lazy graphics variants under 1 MiB in place (PipelineState::variant->build->vkCreateGraphicsPipelines, 2.5-11 s each, back to back), so no present came for about 100 s. A graphics pipeline that is not built yet costs one skipped draw, while the image needs the small lighting and post compute programs, so graphics can stay asynchronous while those are built where they are needed. One startup line states both thresholds.d3d12_pipeline_workers_async_graphics_zeroholds the compile worker with compute over its threshold and graphics at0: every dispatch runs, every draw is skipped, and the draws come once the worker is let go;d3d12_pipeline_workers_async_graphics_unsetchecks that graphics followLEONIDA_ASYNC_MIN_BYTESwithout the variable. - Warm-ups while the title submits. A compute warm-up holds the compile gate for its whole create, and every
submission waits behind it: a native boot's submissions waited 140 s in all at the gate behind compute warm-ups, and
past the story load the worker went through 694 warm-ups of modules over 128 KiB (those over 640 KiB take 4-25 s
each) against 25 such builds a dispatch asked for (measured with a 128 KiB limit). With
LEONIDA_COMPUTE_WARMUP_LIVE_MAX_BYTES=<n>a warm-up of a module over n bytes of SPIR-V is not started while the title submits (a submission in the last second,src/pipeline_wait.h); the pipeline is built at its first use instead. Opt-in: unset or 0, every warm-up runs, as onmain, andLargeModuleGate(#1889) orders them behind a submission's compiles. Smaller warm-ups, and every warm-up before the first submission, run as before. - A bounded, adaptive compile gate, where the driver was measured for it (
SubmitMutex::enter_submit,src/vulkan_device_fault.h;LEONIDA_COMPILE_GATE=adaptiveforces it,classicforces the classic one). The classic gate: compute creates only, each waited for however long it takes, no probes, as before. Unset orauto, the device measures which one this driver gets before the title runs (the next item). The adaptive gate is not on everywhere because of what it costs on a driver that does hold submissions behind a create (630.20, below): no run of it there has been reported yet. The gate keeps avkQueueSubmitout of the driver while a create is in it, since on NVIDIA 630.20 one that entered during a longvkCreateComputePipelineswaited 10 s and lost the device. The waiting submission holds the submit lock, so all queues stop: on an RTX 4070 Laptop (NVIDIA 621.40) one compute create of a 2.3 MB module stayed in the driver for more than 54 s during the story load, the submission waited for all of it and the title's 30 s hang watchdog ended the process; withLEONIDA_COMPILE_GATE=0the same build went past that point. With the adaptive gate a submission waits at mostLEONIDA_COMPILE_GATE_WAIT_MS(15 s by default there) and then goes ahead; the creates in the driver at that moment hold no later submission back, and creates that enter after it are waited for again. On 630.20 that loses only creates over 25 s (15 s here, then the driver's 10 s), which the watchdog ends anyway. On the same laptop the three submissions that went ahead came back from the driver in 11, 1 and 0 ms with the create still there, and no device was lost; but consecutive long creates made submissions wait the full 15 s again and again, and the title's watchdog still ended the run. So the adaptive gate adapts: every submission that enters the driver next to a create it no longer waits for is a probe. Two that come back in under 250 ms, at least 1 s apart, with that create still in the driver turn the gate off for the rest of the run (a driver that holds a submission behind a create holds it as long as the create stays, and 630.20 held one for the full 10 s). Two, and a second apart, because back-to-back creates take and release that driver's lock, so one submission can slip in between; the second costs no extra wait, since after one has gone ahead the next enter at once while the create is still there. One probe that stays 2 s or more keeps the gate on for the rest of the run (presents and idle waits do not probe, below). Both verdicts are logged once.LEONIDA_COMPILE_GATE=1gates always and never probes. In the next run on that laptop the story load passed, but no wait reached 15 s, so no probe came: 80 submissions waited 3-7 s each (90 s in all, the longest 6.7 s), back to back, and the title's watchdog ended the run at 433 s. So until a verdict is in, a submission also goes ahead once the submissions' waits at the gate in the last 10 s, its own included, add up toLEONIDA_COMPILE_GATE_PROBE_MS(2500 ms). A budget over a window rather than a shorter limit per wait, because it also counts many short waits, and one wait reaches it as soon as a 2.5 s limit would. Before the verdict the gate then stops the queues for at most about a quarter of any 10 s, after a quick verdict not at all. On a driver that does hold submissions (630.20) the first probe now enters the driver after 2.5 s of waiting instead of 15 s, and loses the device if the create stays there 10 s more (the classic gate waits that create out). One probe per kind and run: it holds the submit lock while it is in the driver, so no other submission enters until it comes back, and it then gives the held verdict (2 s or more, back within 500 ms of the create leaving), after which no submission goes ahead beside a create of that kind before the held limit. The held threshold stays 2 s, well inside the 10 s such a driver gives before the loss. The limit and the budget apply with the title's watchdog kept kicked too (LEONIDA_TITLE_WATCHDOG=0andLEONIDA_TITLE_WATCHDOG_KICK): nothing ends the run then, but the stops still cost the frames, and an RTX 4060 run that way had 459 waits, 155 s in all and the longest 2.9 s, by t=202 s. OnlyLEONIDA_COMPILE_GATE_WAIT_MS=0(with noLEONIDA_COMPILE_GATE_PROBE_MS) orLEONIDA_COMPILE_GATE=1(with noLEONIDA_COMPILE_GATE_WAIT_MS) waits however long the creates take and never adapts. Tested bysubmit_mutex(no GPU); the probe budget is not yet measured in the title. The verdict is kept per kind of create, compute and graphics (mesh pipelines included), and graphics creates pass this gate andLEONIDA_COMPILE_GATE=1too (the classic gate, as before, only compute builds). On 621.40 every probe beside a compute create came back in 0-12 ms (and on an RTX 4060 with 610.88, 133 of them), but a run whose gate those probes had turned off lost the device 9 s later with a submission held 7.8 s beside a mesh create, and withLEONIDA_COMPILE_GATE=0avkQueueSubmitsat 54 s in the driver beside a 56 s mesh create (541 KB) and the device was lost. A probe counts for each kind that had a create in the driver from before the submission entered until it came back; a held one counts against all of them, since which create held it cannot be told. A kind that is off is still timed: a submission that stays 2 s or more beside one of its creates turns that kind back on for the rest of the run. A held probe (pending or off) counts only if the submission came back within 500 ms after a create of that kind, there when it entered, left the driver: a submission held behind a create comes back when the create does. On the 4070 Laptop (621.40, 8 GB nearly full) a 36 s submission came back 18 s before the 58 s compute create beside it; counted as held, it re-armed the gate, which then kept the next submission 78 s behind compute creates. A synthetic probe on the same machine (one to three threads creating 2 MB graphics pipelines of 8-10 s each, with and withoutVK_NV_device_diagnostics_configand a shared pipeline cache) never held a submission past 80 ms. The recent leaves are kept in a ring, so a create that entered after the submission and left after the one it entered beside does not hide that one. Only submissions (vkQueueSubmit,vkQueueBindSparse) probe: presents and idle or semaphore waits pass the gate the same way but can take seconds on their own, so they judge nothing, and they never go ahead at the probe budget, only at the limit. While a create of a kind that holds submissions is in the driver, no submission goes ahead at the limit or the budget, and such a create is waited for even when one went past it before the verdict, up to the held limit (LEONIDA_COMPILE_GATE_HELD_WAIT_MS, 60 s; 0 waits however long, and a held limit under the plain one applies on its own): then the creates in the driver are gone past and the next submissions no longer wait for them. This is checked on every pass of the wait: once such a create leaves while creates of a kind with no verdict stay, the plain limit and budget apply again. A false "holds" verdict so costs at most that per create, not the rest of the run. On a device loss the log names every create in the driver (kind, program, SPIR-V size, thread, how long it had been there, whether submissions waited for it) and each kind's gate. Long graphics creates would leave the title's process only through the compile helper, which builds compute pipelines alone today. LEONIDA_COMPILE_GATE=auto, the default: a calibration at device creation (src/compile_gate_policy.h,src/compile_gate_calibration.h,decide_auto_compile_gateinshims/d3d12_vulkan_device.cpp). Before theVulkanContext(and itsSubmitMutex) exists, so nothing is gated before the decision, a worker thread creates a compute pipeline written in code (a chain offract(sin(...))steps and branches over a storage buffer, its constants from specialization constant 0 with a new seed each run, so neither a pipeline cache nor the driver's shader cache answers it; no game data) while this thread submits an empty command buffer to the device's queue and waits for its fence, over and over, until the create returns. At least 3 submissions back in 50 ms or less, before the create left and some in its second half, with none slower: adaptive. One of 250 ms or more that came back within 200 ms of the create leaving: the driver holds submissions, classic. A create under 300 ms is tried again larger (up to 4 trials, none started after 6 s); a slow submission the create does not explain, too few samples or any failed call: classic. The verdict is kept per vendor, device, driver version and pipeline cache UUID incompile_gate_calibration.txtbeside the pipeline cache, so it runs once per driver; a failed call or an unclear verdict (a slow submission the create does not explain) is not kept, and the next launch measures again, so one busy moment on the GPU does not hold every later launch on the classic gate. After a wait that times out, the fence and command pool are destroyed only once the submission's fence signals (left alive on a lost device).LEONIDA_COMPILE_GATE_RECALIBRATE=1measures again. It is logged once,[rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.40 in 0.7 s: 115 submissions came back in <= 0.5 ms beside a 722 ms create; cached in ...)(classicand the reason otherwise). Only gta6rt's title process calibrates;--precompile-pipelines,--compile-serverand the tests keep the classic gate, and a forced value never waits for it. Why a calibration can ask what an in-game probe cannot: the adaptive gate learns by letting a submission into the driver beside a create of the title's, which can take 30-60 s, and on a driver that holds submissions such a probe loses the device once it waits 10 s more. The calibration's create takes about a second and its submissions are empty, so on such a driver one is held about a second and comes back with the create; that cannot reach the 10 s the driver allows. What is known for the verdict to agree with,MEASUREDbut small (#2412, comment 7217585003): on an RTX 4070 Laptop with NVIDIA 621.40 a synthetic probe never held a submission past 80 ms beside 8-10 s graphics creates and retail adaptive runs had no gate hang after #2418, and this calibration gives adaptive there (in 6 runs ofvk_compile_gate_calibration_test, 53-125 submissions each, none over 0.9 ms, beside creates of 354-783 ms); an RTX 4060 with 610.88 turned the adaptive gate off with no regression reported; other 621.x users report fewer crashes with it; one freeze at about 231 s on an RTX 5070 (621.x) was at a head without #2418 and is being rechecked. On 630.20 the calibration has not run yet: the expected verdict there is classic, from the 10 s hold measured beside a long compute create.
Open: whether the game uses D3D12_PIPELINE_STATE_STREAM_DESC for mesh/RT and which subobject types appear.
The trace will enumerate them.
Implemented (D3D-29): pipeline state streams, mesh PSOs and DispatchMesh.
- Device:
VK_EXT_mesh_shaderwithmeshShaderis enabled where the GPU has it (VulkanDeviceInfo::mesh_shader).taskShaderis not enabled, since the corpus has no amplification shaders.D3D12_OPTIONS7reportsMeshShaderTier1 only then; without the extension it reportsNOT_SUPPORTEDand mesh PSOs areE_NOTIMPL. - Streams:
CreatePipelineStateparses the stream in the d3dx12.h layout: a subobject type, then its description at that description's alignment, each subobject pointer-aligned.- Every type up to
RASTERIZER2is read. - The Vulkan backend selects console numbering when the PC reading fails or gives AS without MS and the
console reading has a verified DXIL kind-13 mesh stage. Slot 86 keeps that selected layout with canonical
tags and owned shader bytes so slot 55 can derive another PSO.
LEONIDA_XS_STREAM_ENUM=pcselects PC only. - With D3D12 tracing, each unsupported stream has one
PipelineStream::Refusedreason. Accepted mesh PSOs have a separatePipelineStream::Meshcount.LEONIDA_PSO_STREAM_AUDIT=1also prints raw tags, shader stages and FSSM hashes for unsupported or failed streams. The call number joins to the backend result. LEONIDA_PSO_PROFILE=1measures wall time and calling-thread CPU time for each Vulkan pipeline creation. Begin and end records share an ID. Compute records distinguish warmup, dispatch and eager creation. Graphics records name the lazy recipe's stages and unbound attachment mask. Mesh draw totals are reported per command buffer with its submit result.- Missing subobjects take the runtime's defaults: depth test on with
LESS, back-face culling, no blending, sample mask0xFFFFFFFF, one sample. - The stream becomes the same descriptions
CreateGraphicsPipelineStateandCreateComputePipelineStatetake, so a VS stream builds the same PSO as the classic call. E_INVALIDARG, as on the PC runtime: a type given twice, an unknown type, a truncated stream, MS with VS, tessellation or GS, CS with a graphics stage, or no stage at all.E_NOTIMPLwith a log, for what is not built yet: an AS, a depth-bounds test, view instancing.DEPTH_STENCIL2's per-face read and write masks go to each face'sVkStencilOpState(the front face's in the description, the back face's beside it), soOPTIONS14.IndependentFrontAndBackStencilRefMaskSupportedis TRUE: withOMSetFrontAndBackStencilRef's per-face references, both of that cap's parts.RASTERIZER1/2's float depth bias is truncated to the integer the PSO path takes, with a log.
- Every type up to
- Mesh PSO: the MS (
msindex entry by FSSM hash) and PS on the mesh stage. It has no vertex input or input assembly; the input layout, topology type and strip cut are ignored, as D3D12 ignores them for mesh PSOs. Topology and strides are not dynamic state there (VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-07065/07066). Creation is refused when the index'smax_vertices/max_primitivesor the workgroup size exceed the device'sVkPhysicalDeviceMeshShaderPropertiesEXT. DispatchMesh: recorded as aDrawwithmeshset; the thread-group counts go incount/instances/first. It takes the same state snapshot asDrawInstanced: render targets, root arguments, viewport, scissor, blend factor, stencil references. Replay issuesvkCmdDrawMeshTasksEXT.- Recording errors (
ClosereturnsE_INVALIDARG): a grid above 65535 per count or 2^22 groups. - Not recorded: an empty grid.
- Execution error (
ReplayResult::invalid_draw): a mesh draw with a VS pipeline, or the reverse.
- Recording errors (
- Tests:
d3d12_mesh_testchecks the refusals and three draws pixel by pixel on an RX 9060 XT (RADV, under Wine), validation-clean.- The three draws: a 2×2×1 and a 1×1×2 mesh grid, plus a VS PSO from a stream.
- What it doesn't cover: whether the console flattens a 3D
DispatchMeshgrid the same way. That is an open question indocs/design.md, "Mesh shaders"; the test shader reads the workgroup ID directly.
Console rectangle and quad lists
The console has two list topologies Vulkan lacks: rectangle list (IASetPrimitiveTopology(17), with a PSO whose topology type is 19) and quad list (IASetPrimitiveTopology(19)). The facts are from xvalkyrie (GPL-3.0, commit 53af7df77c10; no code taken): a rectangle is three corners and the fourth is v2 + v3 - v1 for the position and every interpolant, after the vertex stage; a quad is four vertices. The layer draws both as triangles (d3d12_rect_list_test, RTX 4090: 4096 of 4096 pixels, the colour plane exact, quad list bit-exact; d3d12_quad_index_test for indexed quads).
- Rectangle list: PSO type 19 builds a triangle-list pipeline plus a generated geometry stage (
src/rect_list_geometry.h, written from the vertex shader's own outputs) that takes the three corners and emits the strip v1 v2 v3 v4 (same winding). It has to be post-vertex-stage: the translated vertex shaders fetch by V# themselves, and the fourth corner is a function of what they write. A corner value with the same bits at all three corners (a flat attribute) is copied. NeedsgeometryShader(elseE_NOTIMPL), no application GS, and a vertex shader with no ClipDistance, CullDistance, Layer or ViewportIndex output. - Quad list: one triangle-list draw whose indices are
i0 i1 i2, i0 i2 i3for each quad. Both triangles start at the quad's first vertex, the one Vulkan takes flat inputs from, and one draw keeps D3D12's instance order (instance by instance, not quad by quad). The PSO type is the ordinary triangle type.- Non-indexed: a shared index buffer in the arena holds the pattern
0 1 2, 0 2 3for 16384 quads (a draw with more is cut off there, with a log line). The draw's first vertex becomes the vertex offset. - Indexed: a compute pass (
src/quad_index_expand.comp, run bysrc/quad_index_expand.h) reads the application's index buffer on the GPU and writes the six 32-bit indices of each quad into copy scratch (src/vulkan_scratch.h); the draw binds that scratch with the application's instance count, base vertex and first instance. The host never reads the indices: a copy or a shader earlier in the same list can have written them. The pass runs before the draw's rendering scope, after a barrier that makes earlier writes visible to it and before one that makes its indices visible to the draw, and between two segments of an active pipeline-statistics query so thatCSInvocationsdoes not count it (as for the other helper dispatches, D3D-162).- Index values are copied as they are, a 16-bit one zero-extended, so
VertexIndex - BaseVertexis still the application's index in a translated vertex shader. - The strip-cut values
0xFFFFand0xFFFFFFFFare ordinary indices, as in every list topology: the replay enables primitive restart for strips only. What the console does with one inside a quad is not measured. - An index past the end of the index buffer view reads 0, as in D3D12. The pass reads a 16-bit index from its aligned 32-bit word, so standalone shader-addressable Vulkan buffers round their backing size up to a word. The D3D buffer size and view bounds are unchanged. A draw's last one to three indices that do not make a quad are dropped.
- Needs
bufferDeviceAddress(the pass uses device addresses, no descriptors). Without it, and inside a statistics query that cannot be split, the list fails as unsupported instead of drawing something else.
- Index values are copied as they are, a 16-bit one zero-extended, so
- Why not a triangle fan per quad (the first version of the indexed path): a fan takes a flat input from
each triangle's own first vertex, the quad's second and third, and a draw per quad runs every instance of one
quad before the next quad.
d3d12_quad_index_testshows both on an RTX 4070 SUPER: a quad with a red first vertex came out black and blue (0 of 4096 pixels red), and of two overlapping instances the first one's second quad ended on top (2048 of 4096 pixels right). With the expansion the seven test frames cover 16-bit and 32-bit indices, a first index at an address of 2 modulo 4, a base vertex, two instances, and a view that ends inside the second quad, plus a 16-bit draw that reaches the end of a standalone upload buffer. - Not covered: quad and rectangle lists through
ExecuteIndirect, whose draws do not record a topology.
- Non-indexed: a shared index buffer in the arena holds the pattern
4. Object model mapping
| D3D12 / Xbox object | Vulkan / layer object | Notes |
|---|---|---|
ID3D12Device … ID3D12Device11 |
one Device object with the public chain plus measured Xbox overrides |
The shipped BVH builder names Device11; slots 1/15/18/19/27/38 matched desktop in prior art, slot 48 is called as (desc, riid, out) with IID_ID3D12CommandQueue (PC slot 48 is OpenExistingHeapFromAddress; the 32-byte desc is a PC D3D12_COMMAND_QUEUE_DESC plus four Xbox words, logged once, and the proxy takes the slot 8 path with the PC prefix and only DISABLE_GPU_TIMEOUT kept), slot 62 is called at 0x14247FE66 as a create with (desc, 0, 0, &riid, &out) — five parameters with an explicit IID/out pair, where the PC method it forwards to, CreateComputePipelineState, takes three — and static Capstone disassembly over the executable's .text (following the device globals 0x148759D00 and 0x1475DF000–0x1475DF048 from renderer init 0x142478440) finds no device call site for slot 76 (+0x260; none of the 57 indirect call [reg+0x260] sites in .text loads a device global); its only measured caller is the shipped FidelityFX upscaler, with the seven CreateCommittedResource arguments (d3d12_command_objects.md §3.5a), and heap slots 9/10 return in RAX. Unknown Xbox IIDs/slots are logged and refused. |
ID3D12CommandQueue |
one leased VkQueue per live queue: direct queues on the graphics family, compute queues on an async-compute family and copy queues on a transfer-only (DMA) family when the GPU has them (src/queue_families.h), else graphics-family leases |
Distinct Vulkan queues allow cross-queue waits and signals to make progress. With more than one family in use, buffers, images, the arena and staging are created VK_SHARING_MODE_CONCURRENT over those families, so no ownership transfers are needed. Barriers on copy and compute queues are narrowed to the stages their family has; render-target and depth clears are refused there (as in D3D12), and the D24/RGB96 copy conversions and bindless flushes stay off a transfer-only queue. Tested by vk_queue_test. PresentX, SuspendX, ResumeX are Xbox queue methods, not in the public vtable; public GDKX samples present only through them (§4.5). Call shapes known, slots Open. |
ID3D12CommandAllocator |
IR arena + VkCommandPool |
Reset only when the previous submission's fence is complete. |
ID3D12GraphicsCommandList … 8 |
CommandList with IR |
Replay at ExecuteCommandLists; bundles inlined. Supports render passes, mesh dispatch, enhanced barriers; records the GCL8 front/back stencil references (applied only once a pipeline path consumes them). Draw views are inlined and moved into the command stream (D3D-289), eliminating per-draw heap allocations. |
ID3D12RootSignature |
RootSignature + VkPipelineLayout |
Deserialize the blob with the host D3D12CreateVersionedRootSignatureDeserializer when possible; clear the measured 0x03000000 flag byte on a copy first; fall back to a local parser. Build the user-SGPR map and static samplers. |
ID3D12PipelineState |
VkPipeline + a PipelineInfo |
Shader hash → SPIR-V + index entry; PSO state → Vulkan state; dynamic state where possible. The BVH builder's compute PSOs arrive at device slot 62 with a plain D3D12_COMPUTE_PIPELINE_STATE_DESC. |
ID3D12DescriptorHeap |
DescriptorHeap (shadow + optional arena range) |
CBV/SRV/UAV and sampler heaps can be shader-visible; RTV/DSV are host-only. Start handles use the measured RAX return at heap slots 9/10. The game derives heap sizes and handle strides from GetDescriptorHandleIncrementSize (measured call sites, section 3.4), so the layer returns its own slot size (32/32) rather than a console value. |
ID3D12Resource |
Resource (a range in the arena buffer; a separate VkImage for textures) |
Committed, placed and reserved. Reserved buffers use sparse memory where supported (section 4.2). Xbox textures may arrive through device slot 76. GetGPUVirtualAddress returns a console VA (a buffer offset or an image key). |
ID3D12Heap |
Heap (a reserved VA range) |
Buffer ranges are backed by the arena; images get ranges of shared blocks or their own VkDeviceMemory (section 3.3). Residency calls are no-ops. True buffer/image aliasing inside a heap is Open. |
ID3D12Fence / ID3D12Fence1 |
Fence over a timeline VkSemaphore |
GetCompletedValue = counter value; SetEventOnCompletion = wait thread + Win32 event; CPU Signal = host signal. |
| Resource barriers (legacy) | vkCmdPipelineBarrier |
Per-subresource state tracking; BEGIN_ONLY/END_ONLY become conservative full barriers at the begin point. |
Enhanced barriers (ID3D12GraphicsCommandList7::Barrier) |
vkCmdPipelineBarrier2 |
Direct mapping of sync/access/layout; prefer it when the game uses it. |
IDXGISwapChain / IDXGIFactory |
Factory/adapter/output: fake objects. Swapchain over VkSwapchainKHR + Win32 surface: only for the PC-style path |
Shim DXGI; do not bind host DXGI. A GDKX title likely creates no swapchain (§4.5); it needs IDXGIDevice1→GetAdapter→EnumOutputs and a PresentX + frame-event presenter instead. |
ID3D12QueryHeap |
VkQueryPool |
Occlusion, binary occlusion, pipeline statistics, timestamps. Binary results clamped to 0/1. |
ID3D12CommandSignature |
IndirectLayout |
Simple draw/dispatch signatures map to indirect calls; root-constant/vertex/index/descriptor changes need expansion. |
ID3D12PipelineLibrary |
map + VkPipelineCache |
D3D12 cached blobs are ignored. |
ID3D12StateObject (ray tracing) |
likely unused | RT work includes compute traversal (image_bvh*) plus XboxBvhBuilder; a DXR state-object path is stubbed until the trace shows it. |
ID3D12ShaderCacheSession |
VkPipelineCache |
Stub with logging. |
| DRED, protected sessions, meta commands, shared handles | stubs | Not needed for single-player boot; return a clean failure and log. |
4.1 Device and feature queries
CheckFeatureSupport is a boot-critical diagnostic. Answer from the Vulkan device, not from a wish list:
-
D3D12_FEATURE_ARCHITECTURE: report the host GPU's UMA property. The console is UMA; a discrete PC GPU is not. Reporting the truth may change the game's upload strategy; reporting a lie can make it map memory it cannot map. Start truthful and log the game's reaction. -
D3D12_FEATURE_LEVELS: report the highest feature level the Vulkan device can satisfy (12_2 when mesh/RT features are present). -
D3D12_FEATURE_SHADER_MODEL: answer the shader model the layer can honour, not the driver's maximum. Nothing in the runtime compiles DXIL: the game's shaders arrive as SPIR-V from the offline translator, and the BVH builder's container also carries a console FSSM program that the same translator handles. A request above 6.0 is clamped down to 6.0, a request for 5.1 is answered with 5.1 (D3D12's own baseline, which a caller asking for the minimum expects), and a value below 5.1 is refused withE_INVALIDARG. Measured against the host PC runtime (616.86) on an RTX 5070: 5.1-6.8 echo the request, 6.9 clamps to 6.8, and0isE_INVALIDARG;0x5fcrashed the host runtime, which the test records in a comment rather than repeating. WARP answers a 5.1 request the same way. -
D3D12_FEATURE_ROOT_SIGNATURE: 1.1, the version the proxy can always produce. A 1.2 blob is rewritten as 1.1 when the host's serializer stops at 1.1 and nothing is lost (d3d12_xs_rootsig.cpp), and Windows 10'sd3d12.dllstops there, so 1.1 is what the game can rely on everywhere. A 1.2 request is clamped down to 1.1, and an undefined value (0, or anything above 1.2) isE_INVALIDARGwith the value left as it was. Measured against the host PC runtime (616.86): 1.0-1.2 echo the request, and a wrongDataSizeisE_INVALIDARG; the host crashed on a null buffer, so the test never gives it one. The refusal above 1.2 was measured on an RTX 4070 Laptop (621.24) and WARP. -
D3D12_FEATURE_D3D12_OPTIONS1: answer from the Vulkan device's subgroups.WaveOpsis true only when every operation group the wave intrinsics map to is present (BASIC,VOTE,BALLOT,SHUFFLE,ARITHMETIC), because D3D12 promises them all behind that one bool.WaveLaneCountMin/Maxare the subgroup size range (VkPhysicalDeviceSubgroupSizeControlProperties, or the singlesubgroupSizewithout those 1.3 properties). The exception is an Intel integrated GPU of the pre-Xe-LPG lines (D3D-121): Vulkan reports 8..32 there, Intel's D3D12 driver a fixed 16..16, and the layer answers 16..16 like the host. Measured on Xe-LP: UHD 770 (32.0.101.6129), Raptor Lake-S Mobile (101.7092) and Tiger Lake 0x9a78 (101.7088). From Xe-LPG on the driver answers the same range Vulkan reports (D3D-280, measured Meteor Lake 0x7d55 on 32.0.101.6127: 8..32 on both sides), so those lines keep the Vulkan range (Meteor/Arrow Lake device IDs 0x7d40-0x7dc5, Lunar Lake 0x64a0-0x64b6). Discrete Arc keeps the Vulkan range until it is measured (TEST-57).TotalLaneCounthas no Vulkan equivalent: D3D12 counts every lane of the device, and the layer answers one full wave, so a game that sizes work from it plans for less parallelism than the GPU has, never more. Measured against the host PC runtime (616.86) on an RTX 5070:S_OKwithWaveOps1, lanes 32..32 and a total of 6144, andE_INVALIDARGfor aDataSizeone field too short or too long. The host crashed the process on a null buffer, so the layer refuses one without asking the host (as with root signatures). -
D3D12_OPTIONSfamilies: report the tier the Vulkan feature set can honour (resource binding tier 3 when descriptor indexing and update-after-bind are available), plus wave ops, 16-bit, barycentrics, render passes, VRS, mesh shader tier, and RT tier 1.1 only if the layer can honour them. The game may branch on these; a false "supported" is worse than a false "unsupported" at boot. ForOPTIONS2–5,7,9,11,13–16, and18–21(D3D-86; leavingOPTIONS1to #745,OPTIONS6/10to #469,OPTIONS8to #715, andOPTIONS12to #693):OPTIONS4reportsMSAA64KBAlignedTextureSupported = TRUE(implemented inGetResourceAllocationInfo);OPTIONS19mapsSupportedSampleCountsWithNoOutputsfromframebufferNoAttachmentsSampleCounts, tiesAnisoFilterWithPointMipSupportedtoVulkanDeviceInfo::sampler_anisotropy, and reports the baseline heap limits (2048samplers,1000000views);OPTIONS21reports baselineD3D12_EXECUTE_INDIRECT_TIER_1_0, and unimplemented features/tiers (DepthBounds,CastingFullyTypedFormat, MSAA UAVs, independent stencil masks, render passes, RT, mesh shaders, sampler feedback, wave MMA, work graphs, GPU upload heaps) stayFALSE/NOT_SUPPORTED/TIER_0. Checked live against the host D3D12 runtime on the same adapter (NVIDIA GeForce RTX 5080, driver616.56, Windows 11): 15/15 feature queries compared with0mismatches (MSAA64KBAlignedTextureSupported = TRUE,SupportedSampleCountsWithNoOutputs = 0x1d,LEONIDA_VK_VALIDATION=1with0validation errors).
-
D3D12_FEATURE_FORMAT_SUPPORT: map tovkGetPhysicalDeviceFormatProperties; multisample render-target and resolve bits also require the format's image-usage/sample-count query to succeed. D3D12's per-format rules then apply, as native D3D12 reports them (RX 9070 XT, AMD 26.11.2, and WARP):MIPwherever the image can have more than one level.SHADER_GATHERwithSHADER_SAMPLE, includingA8_UNORMwhere the 49-footprint WARP regression verified alpha selection.UAV_TYPED_LOADwith every typed UAV. Ordinary typed UAV texture reads use the sampled binding (image_read_typed), while coherentglcloads and storage-only 1D-array loads use storage-image reads. Typed buffer UAVs: the layer writes their V# (section 3.4, "Buffer UAVs");rdna2spirv.pyFORMATSstill limits decoded buffer formats (including gaps in 8/16-bit and 10_11_11 formats).- The UAV atomic bits other than exchange for
R32_UINTwhere Vulkan supports storage image atomics. The translator and set 0 use the formattedr32uiviews for 2D and 3D;R32_SINThas nor32uiview. MULTISAMPLE_RENDERTARGETfor depth formats, from the same usagesMULTISAMPLE_QUALITY_LEVELSqueries.- No integer resolve, no 1D block-compressed. Depth formats are 2D and cube only: no 3D, shader reads, UAVs, buffer or vertex use, and no 1D, which native D3D12 allows but the layer's resource creation refuses.
- TYPELESS formats report texture dimensions and
MIPonly.
d3d12_vulkan_device_testchecks these bits for every format that both the layer and native D3D12 on the same adapter (matched by LUID or PCI ID) support. Some checks compare with the host and some check the layer's own consistency; the comment oncompare_format_supportlists which are which. Formats the layer answers with no uses, such as D24 without Vulkan D24, are listed but not checked. It skips when there is no host on the same adapter (Wine, or no LUID/PCI match). -
D3D12_FEATURE_FORMAT_INFO: report the DXGI plane count independently of Vulkan texture support. Both depth/stencil families (including their view formats), NV12, P010, P016 and NV11 have two planes. The device test compares counts and HRESULTs with native D3D12 on the same adapter. If an older host rejects the sampler-feedback formats orA4B4G4R4_UNORMwithE_INVALIDARG, the test still requires the layer to returnS_OKand one plane for them. -
D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS: queryvkGetPhysicalDeviceImageFormatPropertiesfor the matching colour or depth/stencil attachment usage, plus the transfer and sampled usages used by the resource implementation. Vulkan exposes one standard sample pattern, so a supported sample count reports one quality level (quality index 0); only D3D12's legal sample counts (powers of two up to 32) are exposed. -
D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT(D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT): report the arena's limits, not the console's. -
GetResourceAllocationInfoandGetCopyableFootprints: implement D3D12's rules locally; the game uses them to suballocate and to lay out uploads. They are deterministic and public. Validate against a host D3D12 device in tests if one is available; do not require one at runtime.GetResourceAllocationInfo(and1/2): a buffer takes its width rounded up to 64 KiB, aligned to 64 KiB. A texture's size is the memory itsVkImageneeds (vkGetDeviceImageMemoryRequirements), rounded up to its D3D12 alignment. That alignment is 64 KiB, or 4 MiB with MSAA. The small alignments (4 KiB, or 64 KiB with MSAA) apply only when the application asks for them. 4 KiB also needs the texture to fit in 64 KiB and not be a render target or depth buffer; if it doesn't qualify, the description is invalid (UINT64_MAX), as the PC runtime answers. The MSAA 64 KiB alignment has no size limit on the PC runtime, so none here either. Texture sizes are the driver's on both runtimes, so only buffer sizes, alignments and invalid descriptions are compared with the host. One known difference: a mip count beyond the full chain is invalid here (Vulkan can't create it), while the PC runtime still answers with a size. A total over several resources that passes 2^64 saturates at0xFFFFFFFFFFFF0000here. Hosts disagree on it: WARP and the RTX 5070 host of #1204 saturate too, while on Windows 26300.9974 (D3D12Core 10.0.26100.9818) the Intel Raptor Lake-S (101.7092) and RTX 5060 Laptop (621.24) hosts wrap, two 2^63 buffers to 0, and WARP on that PC still saturates. A wrapped total could make a caller allocate less than one of its resources, so the layer keeps saturating, and the test accepts a host that wraps. Behind the Xbox-ABI proxy (device slots 25 and 56) a 2D render target of a listed colour format with one sample is padded to whole console tiles: the size is the sum over its mips (MipLevels 0 is the full chain, an odd extent rounds up), each mip rounded up to the RDNA2 SW_64KB_D tile shape (runtime/src/gfx10_tiling.h: 256 x 128 pixels for 2-byte elements, 128 x 128 for 4-byte, 128 x 64 for 8-byte, 64 x 64 for 16-byte), with the first mip that fits in half a tile's width and a whole tile's height, and the mips after it, sharing one tail tile, times the array size. A 1920 x 1080 RGBA8 target is 135 tiles, 8,847,360 bytes, where the PC answer is 8,323,072. The proxy lays the descriptions out as the PC device does (each at its own alignment, the total rounded up to the largest alignment, sums saturating) with each render target at the larger of its console size and its PC size; a 4 MiB aligned multisampled neighbour therefore keeps its place (a 1 x 1 four-sample target and a 1080p target need 16 MiB, not 12.5). Slot 56 reports the same offsets. The PC layout stands when no description grows (d3d12_xs_alloc_size.h;xs_proxy_mock_test). Assumption: the retail title's own sizes are not measured (#6982, stop 17), so that its allocation is these shapes and no DCC or CMask memory is open until they are. The descriptions the title passes to slot 25 carry console values (layout word0x101/0x1, flag bits above the PC ones). For console-form calls or descriptors explicitly using layout0x101, the proxy gives the PC device a copy with the PC flags only and ROW_MAJOR (buffer) or UNKNOWN (texture); the title's array is never written. Other PC-form descriptors reach the host unchanged for validation (d3d12_xs_desc_clean.h, the same cleaning as slot 76; #6982 section 3.7). A committed resource made through slots 76 and 127 also allocates that size through the title's__XMemAllocationHooks__, as the console runtime'sXMemAllocfor the resource does, and frees it when the resource is destroyed (a lease kept withSetPrivateDataInterface; the bytes are not used). The retail title budgets its first full-screen render targets with such a hook: it bump-allocates the allocations whose XALLOC page-size field is 2 out of a range it reserved and asserts that less than 2 MiB is left (RT-5 stop 17). The lease's attribute word (allocator ID 0x80, page-size field 2, object type 0) is an assumption; the measured hook reads only the page-size field. -
GetAdapterLuid(implemented):VkPhysicalDeviceIDProperties::deviceLUID, which on Windows is the DXGI adapter's LUID;d3d12_fence_timing_testfinds it withIDXGIFactory4::EnumAdapterByLuid(RTX 4090, driver 621.14). A driver that reportsdeviceLUIDValid = VK_FALSEgets a zero LUID, logged. -
GetCustomHeapProperties(implemented): the D3D12 documentation's table for a NUMA adapter, matching theUMA = FALSEthatD3D12_FEATURE_ARCHITECTUREreports:DEFAULTisNOT_AVAILABLE/L1,UPLOADWRITE_COMBINE/L0,READBACKWRITE_BACK/L0,GPU_UPLOADWRITE_COMBINE/L1, all with typeCUSTOMand node masks 1.CUSTOM, unknown types and node masks above 1 get an all-zero answer, logged. The test comparesDEFAULT,UPLOADandREADBACKbyte for byte with the host runtime's answer (RTX 4090: identical). The retail executable calls it (device slot 26) with the buffer for the returned struct in RCX and the device in RDX, node mask in R8 and heap type in R9: three calls right after device creation, node mask 1 and types 1, 2 and 3 (measured undergta6rt --runwith a register probe in the slot's thunk). A PC C++ method has the device in RCX and the buffer in RDX, so the Xbox-ABI proxy takes the console form when RDX holds the proxy (d3d12_xs_device.cpp;xs_proxy_mock_test,device_proxy_test). Slot 43 returns a struct too and the proxy still forwards it in the PC form: no call of slot 43 has been seen. Slots 25 and 56 take the same form by the same rule (reported later in the boot, #6982; not measured), as #6973 first did for slot 25. -
Residency and power (D3D-33) are no-ops that still check their arguments (
d3d12_vulkan_device.cpp, tested ind3d12_vulkan_device_test). Vulkan has no residency API: memory fromvkAllocateMemorystays usable untilvkFreeMemory, and paging under pressure is the kernel driver's job, so every pageable object is always resident. The residency answers are the host runtime's:d3d12_residency_testruns the same 58 steps on both devices with a committed buffer, a heap, a placed buffer, a descriptor heap, a query heap and a fence, and compares every HRESULT, the device-removed reason after each step, and the valueEnqueueMakeResidentleaves the fence at (110 values; RTX 3060, driver 610.88). Steps that leave the host runtime unusable run there in a child process with a fresh device.MakeResidentandEvictreturnS_OKfor any count of this device's pageable objects, the same one twice, an evicted one or a resident one. D3D12 documentsEvictas a hint the runtime may defer, so dropping it is allowed.SetResidencyPriority(Device1): only objects that own their memory take a priority, committed resources and heaps; anyUINTis a valid priority for them. A placed resource (a reserved one too, by the same rule; not measured), a descriptor heap, a query heap or a fence isE_INVALIDARG, also inside a longer list. The host runtime then removes its device as well (DXGI_ERROR_INVALID_CALL); the layer doesn't, since a console title that sets priorities on its placed resources would lose its device over a hint.EnqueueMakeResident(Device3) signals its fence from the CPU with the given value before returning, since the work is already complete. A queueWaiton that fence must not hang, which is why the signal stays. A null fence is accepted and nothing is signalled.E_INVALIDARGfor flags other thanNONEandDENY_OVERBUDGET; a refused call does not signal. A value below the fence's current one moves the host's fence back; the layer's stays where it was (see the fence note above).- Not compared: a nonzero count with a null array, and a null entry in an array, which the host runtime
dereferences (an access violation). The layer answers
E_INVALIDARGfor the null arrays, skips a null entry inMakeResident,EvictandEnqueueMakeResident, and refuses one inSetResidencyPriority. SetStablePowerStatereturnsS_OK: Vulkan has no clock control, and the result of a frame does not depend on the clocks.SetBackgroundProcessingMode(Device6): no Vulkan API steers driver background work, so nothing runs. The completion event is set at once and*pbFurtherMeasurementsDesiredisFALSE. A mode or action outside the SDK's enum isE_INVALIDARG.
4.2 Resources, heaps, placed and reserved
-
Xbox texture creation is a separate device method at slot 76, not
CreateCommittedResource. Prior art reports its shape as heap properties / heap flags / description / initial state / clear value / iid / output, forwarded on the PC side toCreateCommittedResourceslot 27. The description is 56 bytes plus extension words, and its layout field is0x101(tiled) or0x1(row-major buffer). The PC proxy replaces the layout with a driver-chosen one; our layer must recognise slot 76 and0x101explicitly and must not pass0x101to the public layout enum. The FidelityFX upscaler creates 10 default-heap resources through this slot, so it is not optional for middleware. The console tiled data layout is GFX10SW_64KB_D(Mesa addrlibGFX10_SW_64K_D_RBPLUS_PATINFO), and the detile and tile path is implemented inresource_detile.hand verified byresource_detile_test(D3D-316). -
CreateCommittedResource: allocate an aligned range in the arena for a buffer, or a range of a shared block or a separateVkDeviceMemoryfor an image (section 3.3); record the initial state. MapD3D12_HEAP_TYPE_DEFAULTto device-local memory,UPLOAD/READBACKto separate host-visible buffers. This remains the path for buffers and for any PC-style committed resource. -
ID3D12Resource::GetDescreturns the description with its defaults filled in, as the PC runtime does:MipLevels0 becomes the full chain, andAlignment0 becomes the placement alignment, 64 KiB, or 4 MiB for a multisampled texture (an alignment the description asked for is kept). Implemented and compared field by field with the PC runtime and WARP byd3d12_resource_desc_test: 25 committed and reserved buffers and 2D, array, volume and multisampled textures (measured on an RTX 3060 host and WARP, Windows 10). -
Invalid arguments (D3D-49).
CreateCommittedResource,CreateDescriptorHeap,CreateCommandQueue,CreateFenceandMapreturn the host PC runtime's HRESULTs (no debug layer) for the cases incompare_invalid_arguments(d3d12_vulkan_device_test): invalid ones, their valid neighbours, andALLOW_RENDER_TARGET/ALLOW_DEPTH_STENCILon every format both devices create. Rules the host keeps that are easy to get wrong: a committed resource takes no heap flag exceptSHARED,ALLOW_DISPLAY(textures only),HARDWARE_PROTECTED,CREATE_NOT_RESIDENT,CREATE_NOT_ZEROEDandALLOW_SHADER_ATOMICS(only withALLOW_UNORDERED_ACCESS; measured on an RTX 4070 Laptop and WARP); a buffer refusesALLOW_SIMULTANEOUS_ACCESS; MSAA takes quality 0 or one of the two standard patterns; a buffer may beALLOW_RENDER_TARGETbut notALLOW_DEPTH_STENCIL, and is aligned 0 or 64 KiB only; upload heaps start in any part ofGENERIC_READ(orCOMMON), readback heaps inCOPY_DESTorCOMMON, neither with UAVs; a texture starts in exactlyGENERIC_READ, in one write state alone (RENDER_TARGET,UNORDERED_ACCESSandDEPTH_WRITEonly with the matching resource flag,COPY_DEST,RESOLVE_DEST) or in a mix of read states (DEPTH_READonly withALLOW_DEPTH_STENCIL, the shader-resource states not withDENY_SHADER_RESOURCE), never with a buffer-only or undefined state bit, while a buffer takes any bits exceptRAYTRACING_ACCELERATION_STRUCTUREwithout UAV access (RTX 3060 / 610.88; the same rule applies to placed and reserved resources), or at all where the host reports no ray tracing (an integrated Radeon without DXR, @aguedou-34 on #2462): the layer refuses it on a device with neither KHR acceleration structures nor the XDXR builds;ALLOW_DEPTH_STENCILis accepted for every format of the R32, R16, R24G8 and R32G8X24 families and nothing else; a clear value needs a render target or depth buffer and a format of the resource's family; descriptor heaps may have zero descriptors; non-monitored fences are refused; a null output isS_FALSE(a capability check) except forCreateCommandQueue, which answersE_UNEXPECTED, andCreateDescriptorHeapanswers it before its flag, type and node rules (S_FALSEeven for a shader-visible RTV heap) where committed resources and fences check their arguments first; aGPU_UPLOADheap is refused, sinceCheckFeatureSupportreportsOPTIONS16.GPUUploadHeapSupportedFALSE (a host with GPU upload heaps, which needs Resizable BAR, accepts it, so that case is compared only on a host without them); a global-realtime queue isDXGI_ERROR_ACCESS_DENIEDwithout the privilege;Maprefuses a non-empty read range past the buffer. Not compared, because the host faults or the layer cannot follow it: a null heap-properties or descriptor-heap description (the host faults), more mips than the full chain (the RX 9070 XT runtime keeps up to 16 on a 16×16 texture and dies on 17),D32_FLOATandD16_UNORMas render targets and the R32 and R16 colour formats as depth buffers (accepted by the host; the layer creates the Vulkan format of the same name, and the Vulkan drivers measured can't make that attachment, so the test prints these instead of failing), cross-adapter resources (the host takes a row-major texture on aSHARED | SHARED_CROSS_ADAPTERheap; the layer has no cross-adapter sharing), an unknown descriptor heap type (accepted by the host), and the driver's own answers: R32G32B32 render targets, 2D textures wider than 16384,L1custom heaps, 16x MSAA and video formats and queues differ between the RX 9070 XT, an integrated Radeon and WARP. The rest of the table agrees on all three. -
CreateHeap: reserve a VA range with the requested size/alignment.CreatePlacedResource: assign the resource the range atheap_va + offset; a buffer uses that range in the arena, an image uses the offset as a key and binds its own memory. Vulkan image alignment can exceed D3D12's 64 KiB; because images do not share the arena, this mostly affects true aliasing, which is Open until tested on the target GPU. Its arguments are answered as the host runtime answers them (compare_placed_reservedind3d12_vulkan_device_test, RTX 3060 / 610.88): the description, initial-state and clear-value rules of a committed resource (but any initial state for a buffer in an upload or readback heap, and no UAVs there); a buffer at a 64 KiB-aligned offset; a texture at a multiple of itsGetResourceAllocationInfoalignment (4 KiB for a small texture), in a heap aligned at least as much, and whole inside the heap; the heap'sDENYflags against the resource; then a null output isE_UNEXPECTEDand nothing is made. -
CreateReservedResourceimplemented (d3d12_vulkan_device.cpp,src/resource_tiling.h, checked byd3d12_vulkan_device_testandresource_tiling_test):-
CreateReservedResource,CreateReservedResource1(no protected sessions) andCreateReservedResource2(castable formats ignored) create sparse buffers when the device can bind and alias 64 KiB tiles and guarantees zero reads from unbound pages. Reserved textures and buffers on other devices use a fully backed resource. D3D12's description rules are kept, as measured on the PC runtime: buffers areROW_MAJOR, textures64KB_UNDEFINED_SWIZZLE(anything else, or a format without a tile shape, isE_INVALIDARG;64KB_STANDARD_SWIZZLEtoo, sinceCheckFeatureSupportreportsStandardSwizzle64KBSupportedas FALSE), andGetHeapPropertieson a reserved resource isE_INVALIDARG. The description, initial-state and clear-value rules are a committed resource's on a default heap, and a null output isE_UNEXPECTEDafter them (compare_placed_reserved, RTX 3060 / 610.88).GetHeapPropertiesanswers as the host runtime's (d3d12_heap_properties_test: 561 values for committed resources in every heap type, custom ones and SHARED / ALLOW_DISPLAY / CREATE_NOT_ZEROED / CREATE_NOT_RESIDENT included, placed resources in heaps of each kind, reserved ones, and null arguments; RTX 3060, driver 610.88). A committed resource's flags are the caller's without the two creation-only bits, plus the DENY bits of the resource classes it isn't; a placed resource reports its heap's flags as they are, so one in anALLOW_ALLheap reads back 0.CheckFeatureSupportstill reportsTiledResourcesTieras not supported, so a game that checks it creates committed resources instead. Buffer mappings alone do not implement a full tiled-resources tier. The Xbox tiled layout word0x101is accepted as64KB_UNDEFINED_SWIZZLE(ASSUMPTION: that the console uses it for reserved resources too). -
GetResourceTiling: the standard 64 KiB tile shapes, standard and packed mips (a mip stays standard while it is wider than half the tile or taller than the tile, depth not counting, as AMD's PC runtime does on RDNA2 and RDNA4 and so, most likely, the console (D3D-65); an NVIDIA GPU packs from the first mip smaller than a tile on any axis. D3D11.3 functional spec 5.9.2.8.5 only requires that a mip filling a tile in every dimension stays standard, a smaller one "may or may not be packed, depending on the IHV"), each standard mip's tile counts, and the tile order (each array slice holds its standard mips, then its packed tiles). The test compares the tile shape and the tile counts of the mips both sides keep standard with the PC runtime, and checks that no mip filling a tile is packed, for 18 buffer, 2D, array, block-compressed and volume layouts, and skips a layout the host refuses: which ones a PC driver accepts varies (an RTX 3090 on driver 616.56, at tier 3, refuses texture arrays whose mips reach the packed tail, measured by @CharlyRien in #295; an RTX 5070 on 621.01 accepts them). How many tiles the packed mips take is the driver's choice: here it is one tile per tile-depth slice the tail spans, as AMD reports (below), and never fewer than their tight linear size in whole tiles; the PC runtime on an RTX 5070 reported one tile more than the tight size for 1000x300 and 100x100 RGBA8 and a 128^3 R8 volume, and the same count for the other layouts probed. Two further measured differences: on array slices after the first, the PC runtime writes a tile index into packed subresources instead of the documentedD3D12_PACKED_TILE(ours follows the documentation), and a resource that is not reserved has no tiles (all outputs zero), as on the PC runtime. -
Measured on AMD (RX 9070 XT, RDNA4, driver 32.0.31041.1004, Windows 11,
main91b36cf): the AMD PC runtime splits standard and packed mips differently, whichd3d12_vulkan_device_test's tiling comparison used to report as a failure; the spec leaves the split to the driver, so the comparison now takes any split (a Radeon 880M on 26.11.2 behaves the same, and WARP keeps every mip standard: it packs nothing, down to 1x1). Tile shapes agree in all 17 texture layouts, and 11 of them match exactly; in the other 6, AMD keeps more mips as standard tiles before the packed tail:Layout Tile Standard mips: NVIDIA (the layer before D3D-65) AMD (the layer now) 1000x300 RGBA8 sRGB, 3 slices 128x128 2 4 2048x1024 BC7, 2 slices 256x256 3 4 1000x600 BC3 256x256 2 3 100x100 RGBA8 128x128 0 1 4096x64 BGRA8 128x128 0 6 256x256x64 RGBA8 volume 32x32x16 3 4 An RDNA2 GPU (the Ryzen 7 9800X3D's, driver 32.0.21045.5002) gives the same splits as the RDNA4 one (#374). With 30 more layouts that probe the edges (a mip exactly at or just past half a tile, thin and tall textures, non-square 2D and volume tiles), the rule that fits all 47 on both GPUs is: a mip stays standard while it is wider than half the tile or taller than the tile; depth does not count. An earlier "every axis at most half the tile's largest side" fitted the first 17 but missed four tall or deep edge cases. All 47 layouts and AMD's values are in
runtime/test/resource_tiling_test.cpp. AMD's packed tile count is one tile per tile-depth slice the tail spans,ceil(depth of the first packed mip / tile depth): 1 for every 2D layout, and for 32 further volumes whose tail is deeper than a tile it steps at each tile depth (8x8x32 R8 takes 1 tile, 8x8x33 takes 2, 8x8x256 takes 8), even where the bytes would fit in fewer (16x16x128 RGBA8: 8 tiles for 3 tiles of data). Those 32 are in the test too, 79 layouts in all, identical on both GPUs. The console is RDNA2, so the layer follows this rule (D3D-65; ASSUMPTION: that the console's runtime splits like the PC's AMD driver). -
UpdateTileMappingsandCopyTileMappingsbind pages in reserved buffers to default heaps from D3D-16. Sequential, NULL, SKIP and single-tile reuse ranges are supported. Queue timeline waits order binding between ordinary submissions, and the previous heap allocation is retained until an in-flight unbind completes.CopyTilescopies 64 KiB tiles between sparse buffers and linear buffers in either explicit direction.d3d12_buffer_tiles_testcompares three full readbacks with native D3D12, including a fence-gated queue. -
Drivers that exclude the host-visible arena memory type from sparse buffers (including NVIDIA 621.01 on the RTX 3090) use a dedicated device-local allocation per heap for its tiles. A heap with this dedicated backing cannot mix placed buffers and sparse mappings.
-
D3D-285 extends these mappings to single-sample
R8G8B8A8_UNORMreserved 2D textures with one mip, one layer and no resource flags. The Vulkan image must support sparse aliases and zero reads from unmapped tiles, with 128 × 128 color blocks aligned to 64 KiB. Images requiring an opaque mip tail or separately bound metadata keep the fully allocated fallback. The image is transitioned while still unbound and kept inGENERALso mapping an alias preserves contents. Image tiles use dedicated device-local heap memory and can alias tiles of compatible sparse images. Buffer and placed-resource aliases with texture tiles are outside this path. -
CopyTilestransfers RGBA8 tiles in either direction. Partial edge blocks use the full 512-byte linear row pitch and transfer only in-bounds texels. Byte-unaligned offsets use transfer scratch.d3d12_texture_tiles_testcompares initially unmapped tiles, column mappings, aliases, and a fence-delayed remap with native D3D12, including clipped edges and byte-unaligned offsets.
-
-
D3D12_RESOURCE_DESC::Layout: the publicROW_MAJORand64KB_STANDARD_SWIZZLEvalues plus the Xbox0x101tiled value from slot 76. Row-major textures needVK_IMAGE_TILING_LINEAR(not usable for RT/DS) or a staging copy;64KB_STANDARD_SWIZZLEand0x101have no direct Vulkan equivalent. If the game uploads console-tiled data, the layer uses a detile step.runtime/src/resource_detile.h(detile_surface_64k/tile_surface_64k,resource_detile_test) andruntime/src/gfx10_tiling.hprovide GFX10/RbPlusSW_64KB_Ddetiling. Which mode0x101uses, the mip tail and upload wiring remain Open. -
Formats: a
DXGI_FORMAT→VkFormattable, including sRGB and typeless variants. Typeless resources get a concrete image format plusVK_IMAGE_CREATE_MUTABLE_FORMAT_BITand aVK_KHR_image_format_listwhen views cast within the family; unsupported casts are logged and fall back to the resource format.CreateCommittedResource3's castable-format lists are mapped to aVkImageFormatListCreateInfo; buffers and unmapped formats are refused.CreatePlacedResource2's list is mapped the same way on the placed path (D3D-90). Depth/stencil, BCn and packed formats map directly; any format the device rejects is a hard error with the DXGI value. -
Map/Unmap: upload/readback buffers map their host-visible memory; default-heap resources returnE_INVALIDARGas D3D12 does. A texture in a CPU-visible custom heap maps only with a null pointer (its layout is the driver's), as on D3D12. -
GPU-writable slot-133 images on a default heap bind memory when replay, presentation or creation of a shader view first needs their Vulkan image. D3D12 placement and logical attachment views can precede that bind. A CPU-fillable, typed BC texture (filled by host copies or the staged upload) can initially sample an immutable zero image of the same format, extent, layer count and mip count. A CPU upload or explicit GPU command gives the placement private backing and republishes its existing descriptor keys. The cache holds at most 256 MiB.
LEONIDA_PLACED_IMAGE_DEFER=0restores eager binding. -
A slot-70 sampled texture whose source pages are unreadable reserves its image backing on the first complete CPU read. Copies of descriptors written earlier resolve to the fallback until that upload succeeds.
LEONIDA_TITLE_IMAGE_DEFER=0allocates these textures eagerly. The memory probe reports the live unbound image count and its Vulkan memory requirements in MiB. -
With
LEONIDA_TITLE_PARTIAL_MIPS=1, such a texture can be filled before all its pages are readable. The XG layout of a 2D texture of one slice stores its mips from the smallest to the largest, so the mips frommon are the firstmip_chain_bytes(layout, m)bytes from its base (xg_xs_layout.h; checked inxg_xs_testfor tiled, tail and linear layouts). The probe (texture_memory_readable_bytes) returns how many bytes from the base are readable andfirst_mip_withinthe first mip those hold. When the last slot-70 view starts at that mip or later, the mips from there on are filled and only the descriptor keys of views that start there or later are published. The others stay on the fallback (PendingImage::first_mip) until a later fill has their mips. The image still has memory for every mip:LEONIDA_TITLE_PARTIAL_MIPS_MB(2048) limits the image memory of the textures filled in part. Arrays, cubes and volumes are filled whole or not at all.LEONIDA_TITLE_STREAM_BUDGET_MB(16 by default,0for unlimited) bounds newly streamed unmapped texture uploads and partial-mip upgrades perrefresh_title_texturespass (deferring excess textures viawatch.touchto the next submission while never deferring mapped video planes, already-filled dynamic updates, or the first streamed texture of a pass). -
Small optimal Vulkan images synthesized for slot-70 texture views share memory pages. Each slice meets the image's size, alignment and memory type requirements. The GPU retirement queue destroys the image before its slice can be reused. Large images, dedicated-only images, and failed pool allocations use individual memory allocations.
LEONIDA_TITLE_IMAGE_POOL=0selects individual allocation for every image. WithLEONIDA_MEM_PROBEenabled, the texture census also reports logical Vulkan backing bytes for the registered slot-70 and slot-133 images and the portion on non-device-local types. -
A refresh pass visits a snapshot of the title-image registry, taken under its mutex, instead of walking the registry itself. Filling a texture can submit, a submission destroys a retired image, and that image's destructor erases its registry entry. Windows' mutex is recursive for its owner, so the erase lands inside the pass, and a walk over the map itself would step into a freed node (measured: an access violation reading the nil flag of a null child, 0x19, in
Device::refresh_title_textures). The snapshot also holds a reference to each entry, so an entry retired during the pass is still alive when its turn comes. -
Sampled title images can use device-local memory even when Vulkan host image copies require a host-visible memory type. The runtime queries the same image with and without host-transfer usage. When only the latter permits plain device-local backing, it detiles the complete image into a reusable staging buffer and transfers all its mips and layers together. Linear slot-133 placements use host copies when the image supports them. A CPU-visible, single-sampled colour title image that needs no format conversion uses the staged upload if the device, format or image usage lacks host-transfer support, or if the host-transfer image has no compatible memory type. The runtime logs that last case once per Vulkan format. A GTX 1050 Ti on NVIDIA 582.66 reported it for R8_UNORM, R8G8B8A8_UNORM and BC1_RGBA_UNORM_BLOCK. GTX 1050 Ti test results When both placements are available, an allocation failure on the staged path retries the original host-copyable image.
LEONIDA_TITLE_IMAGE_STAGING=0restores the original placement policy. WithLEONIDA_MEM_PROBE, each title image class logs its Vulkan memory type mask, mask without host transfer, and selected type. -
WriteToSubresource/ReadFromSubresource(implemented ind3d12_vulkan_device.cpp) complete before they return, as D3D12 requires; a read cannot wait for a later submit. Textures in CPU-visible custom heaps are created withVK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXTwhen the device supports that usage with the requested image format and flags, moved toGENERALand zero-filled on the host at creation, and copied withvkCopyMemoryToImageEXT/vkCopyImageToMemoryEXTwhile they stay inGENERAL(D3D12'sCOMMON). Every other case (no extension, a texture a barrier has moved, a default-heap texture, which D3D12 does not allow but the layer copies and logs) is aCopyTextureRegionfrom or to a host-visible staging buffer, replayed on the device's queue and waited for, so the layout tracker and a first use's zero fill behave exactly as for the application's own copies. Their arguments answer as the host runtime's do (d3d12_subresource_copy_testruns the same 117 steps on both devices and compares every HRESULT and the whole destination of every read; RTX 3060, driver 610.88): a subresource past the last, a box whose right, bottom or back edge lies past the mip's, or one that cuts a compressed block isE_INVALIDARG; an empty or inverted box that passes those checks isS_OKand copies nothing; the row and depth pitches are not checked, so rows or slices that overlap (a pitch smaller than a row, or 0) are copied in order. Not compared: null data, which the host faults on (the layer answersE_INVALIDARG); which bytes win when a read's rows overlap, which is the driver's copy order; and a default-heap texture, which the host refuses and the layer copies on purpose.- A driver can report
VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXTfor a format, create the image with host-transfer usage, and then give it no memory type (memoryTypeBits = 0). This was measured on a GTX 1050 Ti with NVIDIA 582.78 and again with 582.66 on Windows 10 (#1364), where the same image without host-transfer usage takes device-local memory; the validation layer of Vulkan SDK 1.4.363 reports nothing. Such a texture is made again without host-transfer usage before it is bound, and takes the staging path.d3d12_vulkan_device_testandd3d12_subresource_copy_testforce this branch on any GPU withVulkanDeviceInfo::force_host_transfer_retry(their third CPU-copy path; the second compares it with the host runtime). LEONIDA_HOST_IMAGE_COPYchooses whether the device enables the extension at all (src/host_image_copy_policy.h, tested byhost_image_copy_policy_test):1wherever the device has it,0never, andauto, the default, as1except on NVIDIA (vendorID0x10DE), where it is off. On an RTX 4070 SUPER (Windows 11) a real boot lost the device withWRITE_INVALIDin 7 of 7 runs that used host image copies and in 0 of 2 that did not; why is still under investigation. Off, the extension is neither enabled nor chained, no texture gets host-transfer usage, and every copy takes the staging path, as on a device without the extension. Device creation logs one line,[rt] d3d12: host image copy: on (available)oroff (...)with the reason. Results withLEONIDA_HOST_IMAGE_COPY=1on other NVIDIA GPUs and drivers are welcome in an issue.
- A driver can report
-
96-bit textures (
R32G32B32_FLOAT/_UINT/_SINT/_TYPELESS, D3D-62) areR32G32B32A32images (ResourceBinding::rgb96), on every GPU. Most GPUs have no optimal-tiling RGB32 image (an RX 9070 XT reports no optimal features forR32G32B32_SFLOAT), and one that has would not avoid the repack: D3D12 places subresources at multiples of 512 bytes and Vulkan requires a copy's buffer offset to be a multiple of the 12-byte texel (VUID-vkCmdCopyBufferToImage-dstImage-07975). What the application sees stays D3D12's:GetCopyableFootprintsgives 12-byte texels (compared with WARP ind3d12_rgb96_test), and a view's T# namesGFX10_FORMAT_32_32_32_*, whose swizzle reads alpha as one, so the image's fourth channel is never read.CopyTextureRegionbetween a texture and a buffer is repacked by the D24 compute pass (src/depth24_convert.compmodes 2 and 3,Depth24Job::rgb96): the same scratch buffers, parts and lifetime, with texels of three words in the footprint and four in the scratch, copied as they are (an upload writes the fourth word as 0). The words are not interpreted, so NaN payloads, denormals and integers pass unchanged. On an RX 9070 XT (AMD 26.11.2) an upload and a readback take about 5 and 2 ms at 1024x1024 and about 20 and 45 ms at 4096x4096 (d3d12_rgb96_testwithLEONIDA_RGB96_LARGEset; single runs that vary by a few ms, each the first submission of a new queue). The converter is created on every device for this, whether or not the GPU has a native D24.- Texture-to-texture copies and
CopyResourceare plain image copies, and only between two 96-bit textures. WriteToSubresource/ReadFromSubresourcealways take the staged copy, as a D24 texture stored as D32 does: a host image copy would not repack.- Not done: render targets. WARP creates 96-bit render targets; this layer refuses
ALLOW_RENDER_TARGETand leavesRENDER_TARGETout ofFORMAT_SUPPORT, since a writable fourth channel changes destination-alpha blending.ALLOW_UNORDERED_ACCESSandALLOW_DEPTH_STENCILare refused, as on WARP (measured in the test).GetResourceAllocationInfogives no size for a description creation refuses. A typed 96-bit texture has views of its own format only; theTYPELESSone hasFLOAT,UINTandSINTviews (sampled ind3d12_descriptor_test).GetResourceTilingreports no tiling for a committed 96-bit texture on both Microsoft WARP and an NVIDIA GTX 1660 SUPER: total tiles, the tile shape and every packed-mip field are zero, and the returned subresource-tiling count is zero (so its output element is untouched). This holds forFLOAT,UINT,SINTandTYPELESS; there is no standard tile shape to implement for a 12-byte texel.
-
Resource flags map to Vulkan usage:
ALLOW_RENDER_TARGET→COLOR_ATTACHMENT,ALLOW_DEPTH_STENCIL→DEPTH_STENCIL_ATTACHMENT,ALLOW_UNORDERED_ACCESS→STORAGE,ALLOW_SIMULTANEOUS_ACCESS→ concurrent sharing,DENY_*→ omit the corresponding usage. Buffers get the union of usages their states and flags imply; images copy dimension, format, mip levels, array layers and sample count. -
Xbox depth textures with
ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESScan use legacy committed creation (slot 76),CreateCommittedResource3(forwarded by Xbox slot 127 in the boot stack), or placement at a guest address (slot 133). Device10 and slot 133 take an initialD3D12_BARRIER_LAYOUT. Both check the layout against the logical texture flags and validate the optimized clear against the native depth format. Xbox allocation queries return the attachment's placement size for XMem accounting; the writable planes are private backend allocations. The supported shapes are single-sample, single-mip 2D textures and 2D arrays. ForR32G8X24_TYPELESS, useR32_FLOATon depth plane 0 andR8_UINTon stencil plane 1. ForR16_TYPELESS, useR16_UINTon plane 0 to access the raw D16 bits. An array UAV selects a contiguous range of layers. The depth/stencil and shader-resource views continue to use the attachment image. Slot 133 keeps the guest address. Identical, live placements share their image and writable planes across distinct COM objects. An incompatible reinterpretation at the same address is refused. A placement's extent is the PC allocation size, which can exceed the title's own block (RADV sizes a large D16 target above it, so the title's next block starts inside the range); a placement that starts inside another one therefore gets its own image when both layouts are opaque, since D3D12 leaves an alias's contents undefined until reinitialized, and is refused only for a non-opaque layout. Before this, the retail boot stopped on the title's assert while it created its D16 depth targets on an RDNA2 iGPU under RADV. A refused depth placement is logged (no trace line covers it). Where the provider (Resource::enable_depth_stencil_uav) has no unordered-access form of a texture it answersE_INVALIDARGorE_NOTIMPL, and slots 76 and 133 then make the texture without unordered access, as before the provider: slot 76 as a committed depth-stencil texture, slot 133 through its stand-in (the title-placed texture, or the committed one). The first such refusal per slot is logged (xs_proxy_mockchecks the refusal against a mock provider). Any other failure (out of memory, the backing itself, a refused placement) is passed on as before. Console D16S8 (format 118) made asD24_UNORM_S8_UINTviapc_format()(the default on GPUs with D24S8 attachments, such as NVIDIA) keeps its UAVs through the widenedR16_TYPELESS+R8_UINTstorage planes: plane-0 barriers convert between 24-bit UNORM words in transfer scratch andR32_SFLOATviaDepth24Converterand blit between the intermediateR32_FLOATimage andR16_UNORM(viewed asR16_UINTorR16_UNORM), while plane 1 copies stencil bytes directly (xbox_d16s8_d24_storagewithLEONIDA_CONSOLE_D16S8=d24). -
Legacy and enhanced texture transitions copy the selected planes and layers to or from their storage images. Fence-ordered graphics and compute queues can share UAV access. A dedicated compute family can perform the plane transfer itself when
VK_KHR_maintenance10and the format's depth/stencil copy flags allow it. Otherwise the graphics queue issues the explicit transitions on either side of the compute work. The two queue-specific COMMON layouts allow implicit UAV access, so replay refuses them for these textures. Generic COMMON remains available for copies, shader reads and queue handoffs.d3d12_depth_stencil_uav_testverifies these paths with a synthetic shader and per-pixel readback. -
Copies:
CopyBufferRegion→vkCmdCopyBufferwith arena offsets;CopyTextureRegion→vkCmdCopyBufferToImage/vkCmdCopyImageToBuffer/vkCmdCopyImage, using theD3D12_PLACED_SUBRESOURCE_FOOTPRINTrow pitch and height;CopyResource→ a whole-subresource copy; colour resolves →vkCmdResolveImage; depth and stencil resolves → avkCmdBeginRenderingscope with a resolve attachment (section 3.2). Partial resolve regions to another offset need a shader or a region copy.- A placed footprint must have an
Offsetthat is a multiple of 512 and aRowPitchthat is a multiple of 256 (D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT,D3D12_TEXTURE_DATA_PITCH_ALIGNMENT). Any other is refused when it is recorded, soClosereturnsE_INVALIDARG(CommandList::valid(const CopyLocation&)inruntime/src/command_list.h;command_list_testhas both cases). That is D3D12's rule for a device that reportsUnrestrictedBufferTextureCopyPitchSupportedasFALSEinD3D12_FEATURE_D3D12_OPTIONS13, which this device does on purpose (d3d12_vulkan_device_testfails on aTRUE). The PC runtime answers differently: on an RTX 4090 (driver 621.14) and on WARP it reports the capability as supported, and a list withOffset16 andRowPitch260 for anR8G8B8A8_UNORMfootprint closes withS_OK(measured with a stand-alone D3D12 program, Windows 11 26200). The layer cannot simply say the same: Vulkan takes a copy's buffer offset as a multiple of the texel block size and its row length in texels (VUID-vkCmdCopyBufferToImage-dstImage-07975), while the capability lifts D3D12's two alignments and is not documented as keeping offsets and pitches texel multiples (not tested here), so a footprint that is not texel-aligned would have to be repacked through scratch memory the way a 96-bit one is (section 4.2). The replay already accepts any pitch that is a texel multiple and any offset that is one, except that a depth, stencil or 96-bit copy needs an offset that is a multiple of 4 (prepare_texture_copyinruntime/src/vulkan_replay.h; anything else isunsupportedthere), so accepting those needs only the record-time check changed; reporting the capability needs the repack as well. What the console's runtime reports is not measured, and no title code that depends on it has been seen.
- A placed footprint must have an
-
WriteBufferImmediate(D3D-26) →vkCmdUpdateBufferof 4 bytes. The address is resolved when the list is executed, throughReplayFunctions::buffer_at: the buffer whoseResourceBinding::varange holds it, atbuffer_offset + (address - va).VulkanContextfinds it by binary search over the buffers' VA ranges (runtime/src/buffer_va_index.h, kept in step with the registered resources); aliasing placed buffers can overlap: the one whose range starts closest below the address and also holds the bytes the view or write needs wins, or, when none holds all of them, the one that starts closest below (buffer_va_index_test). The device fillsvawith the buffer's console VA, the oneGetGPUVirtualAddressanswers (section 3.3); a list with an immediate write whose 4 bytes no buffer holds is refused asunresolved_resource.DEFAULTadds no barrier: it is ordered like any copy, by the application's barriers.MARKER_OUTwaits for every earlier command to finish and sees its writes (ALL_COMMANDS/MEMORY_WRITE→TRANSFER/TRANSFER_WRITE).MARKER_INonly needs earlier commands to have started. Vulkan cannot express that, becauseTOP_OF_PIPEin a first synchronisation scope is no stage at all, so it gets an execution-onlyALL_COMMANDS→TRANSFERdependency: stricter than D3D12 requires, never weaker. Recording refuses a null or unaligned address and an unknown mode (the debug layer'sWRITEBUFFERIMMEDIATE_*messages, IDs 1090-1092 ind3d12sdklayers.h). -
AtomicCopyBufferUINT/AtomicCopyBufferUINT64(D3D-26) → onevkCmdCopyBufferregion of 4 or 8 bytes, after aALL_COMMANDS/MEMORY_WRITE→TRANSFER/TRANSFER_READ|WRITEbarrier. That barrier covers every earlier write, those to the dependent resources among them, so the copy sees them all, as D3D12 requires. The dependent ranges are checked against their buffers (end == UINT64_MAXresolves to the buffer's size) but add nothing a global barrier does not already cover. Recording matches live Windows 11 WARP and hardware D3D12Closevalidation: offsets aligned to and within the buffer for the copy size, zero dependencies allowed (with null arrays), buffer dependency ranges withbegin < endand eitherend == UINT64_MAXorend <= width, and texture dependency ranges{0, UINT64_MAX}on a valid subresource orALL_SUBRESOURCES. ASSUMPTION: Vulkan promises no atomicity for a transfer, and the layer relies on a naturally aligned 4- or 8-byte copy being a single write on the GPU. This matters only to a reader racing the copy on another queue or on the host. -
Clears: a full-subresource clear maps to
vkCmdClearColorImage/vkCmdClearDepthStencilImage(UAV buffers tovkCmdFillBuffer); a rect clear usesvkCmdClearAttachmentsinside the rendering scope. UAV image clears usevkCmdClearColorImageinGENERAL, and rectanglesvkCmdClearAttachments. Buffer patterns of other sizes need no compute clear: 8/16-bit elements are a 32-bit fill with copied ends, 64/128-bit ones an update doubled by copies (section 3.2, UAV clears). -
Typed UINT RTV clears:
ClearRenderTargetViewstill takesFLOAT[4]. For the currently exposedR8G8B8A8_UINT,R32_UINTandR32G32B32A32_UINTresources, convert those values numerically intoVkClearColorValue::uint32for both image and rectangle clears; copying float bits gives incorrect stored integers without a Vulkan validation error. Measured: Windows D3D12 on WARP and AMD RX 5700 XT clamps negatives/NaN to zero, positive overflow/infinity to the component maximum, and truncates fractions.d3d12_clear_test(renamed fromd3d12_uint_clear_testin #525, D3D-45) compares full and rectangular D3D12 readbacks with WARP over eleven integer input sets on every UINT and SINT render-target format it lists, beside the UNORM/SNORM/FLOAT and depth/stencil cases. ctest runs only its--rgb9e5mode (d3d12_rgb9e5_rtv), so the WARP comparison is run by hand until #521's 0.5 tie rounding lands (runtime/CMakeLists.txt).clear_color_testchecks both replay paths without a GPU, including unchanged float values. This does not add typed-view reinterpretation of typeless resources or new integer formats. -
RGBA8 typeless RTV clears: explicit UNORM, SRGB, UINT, SINT and SNORM RTVs on a
R8G8B8A8_TYPELESS2D resource with sample count 1, selecting a mip and a contiguous array-layer range.TargetViewcaptures its format by value; copies and layout tracking keep the resource's base format. Reinterpreted full clears use dynamic rendering becausevkCmdClearColorImagecannot select a view format. Rectangle clears use the same typed attachment view. The view-cache key includes the format, and views request only color-attachment usage so SRGB does not inherit an unrelated storage requirement. Same-format image clears and legacy float-only replay clients retain their existing path. On an RX 5700 XT, 13 synthetic full/rectangle readbacks match Windows WARP (UINT exact, normalized channels within one byte), including descriptor rewrites, format switches and an SRGB RTV on a UAV resource. The same tests fail without this change and when the cache ignores format. CPU replay covers 31 scenarios; 17 unsupported/invalid frontend views failClosewithout submission. Typed-resource casts, MSAA and 3D typeless RTVs remain unsupported. Phase 2 adds 54 mip/array and 12 non-array higher-mip readbacks against WARP, including untouched sentinels. D3D-161 adds SINT and SNORM views when the Vulkan format supports color attachments. SINT uses the existing integer clear conversion, and SNORM passes floating-point values to the attachment. Signed channels matched WARP byte for byte in full and rectangular clears on an RX 9070 XT (driver 32.0.32029.2010) and the integrated Radeon in a Ryzen 5 9600X (32.0.21045.29003), including mip and array selections. The SNORM vectors avoid half-step rounding ties. -
Typed RTVs of the other typeless families (D3D-275): an RTV of any TYPELESS color texture (B8G8R8A8, R16G16B16A16, R32G32B32A32, R32G32, R16G16, R10G10B10A2, R8G8, R32, R16, and R8 once it is mapped) names a typed format of its family;
TargetViewcarries that view's VkFormat (ColorViewFormatholds VkFormat numbers) andcolor_view_formataccepts any format of the resource's family (typeless_view_family), so the clear writes through a view in that format. Typeless images are already mutable without a format list. Before, only RGBA8 was reinterpreted and the others cleared through the resource's own format (anR8_UINTRTV cleared to 7 wrote 0xff).d3d12_typeless_families_testclears every typed RTV format of each family with two value sets and compares the bytes with the host D3D12 on the same adapter: 62 of 62 equal on an RTX 3060 (NVIDIA 32.0.16.1714) withLEONIDA_VK_VALIDATION=1; WARP differs from that host in 8 (rounding of 0.5 to UNORM/SNORM and the R10G10B10A2_UNORM alpha). Formats the layer does not map yet (R16G16B16A16_SNORM, R16G16_UNORM/SNORM, R16_UINT/SNORM/SINT, the R8 family; #1914) are reported and skipped. Draws need no change: the replay builds a draw's attachment view in the PSO'sRTVFormats[slot](GraphicsPipeline::color_formats, applied invulkan_replay.h's draw setup), which D3D12 requires to equal the RTV's format, so pipeline and attachment already agree and the mutable image is written in the typed format. The same test draws a full-screen pass (GLSL stand-ins for translated shaders found by FSSM hash; HLSL through d3dcompiler_47 on the host) writinguint4(7, 300, 1000, 3)orfloat4(0.5, -2, 1.5, 0.25)into R16G16B16A16_UINT/FLOAT/UNORM, R32_UINT/FLOAT, R10G10B10A2_UINT/UNORM and R8G8B8A8_UINT views of the matching TYPELESS textures: 8 of 8 equal the host, with no validation error, before and after the clear fix. -
RTVs through a castable-format list in the other channel order: an
R8G8B8A8orB8G8R8A8texture (UNORM or SRGB,B8G8R8X8included) whose castable-format list names the RTV's format in the other channel order, acrossB8G8R8X8andB8G8R8A8, or a typedB8G8R8A8texture's listed SRGB format, gets an RTV in that format.CreateRenderTargetViewchecks the list as the application gave it (lists_castable_format), andcolor_view_formatlets a castable image's clear cross between the RGBA8 and BGRA8 orders. WARP and AMD's D3D12 driver (RX 9060 XT, 26.11.2) store clears and draws in the view's channel order and encoding: anR8G8B8A8texture cleared to (0.2, 0.4, 0.6, 0.25) through aB8G8R8A8RTV holds the bytes 153, 102, 51, 64. Before, the RTV was refused for anR8G8B8A8texture (its clear failedCloseand its draws were dropped), and a typedB8G8R8A8texture's RTV kept the image's format whatever the view named, so its clears came out in BGRA order and without the sRGB encoding (its draws were right already, as they use the PSO's format). A format the list doesn't name is refused, on a typedB8G8R8A8orB8G8R8X8texture as on anR8G8B8A8one (theB8G8R8A8andB8G8R8X8ones kept the image's format before); a typedB8G8R8A8texture without a list still ignores the RTV's format, as before.d3d12_clear_testcompares 8 such textures with WARP in full and rectangle clears within 1 (the X byte of an X8 view left out: WARP and AMD write different values there) and checks that anR8G8B8A8, aB8G8R8A8and aB8G8R8X8texture each take their own and their listed format and refuse 3 formats their lists don't name,d3d12_draw_testdraws through the same views, andtypeless_rtv_testchecks the replay's crossing and its refusals. -
Typed RTV clears:
ClearRenderTargetViewstill takesFLOAT[4]. For every integer RTV format the device exposes (R8G8,R8G8B8A8,R16G16,R16G16B16A16,R32,R32G32andR32G32B32A32in_UINTand_SINT, plusR10G10B10A2_UINT;R8/R16_UINT/_SINTare handled in replay too) convert those values numerically intoVkClearColorValuefor both image and rectangle clears; copying float bits gives incorrect stored integers without a Vulkan validation error. Measured: Windows D3D12 on WARP clamps negatives/NaN to zero, positive overflow/infinity to the component maximum (and signed below the minimum), and truncates fractions; signed formats useint32with the same NaN/overflow rules.R10G10B10A2_UINTclamps RGB to 1023 and alpha to 3 (inputs 4, 4.5 and 2^32 in alpha match WARP).d3d12_clear_testcompares full and rectangular D3D12 readbacks with WARP across UNORM, SNORM, FLOAT, all 15 exposed UINT/SINT render targets (11 value vectors, including 8-/16-/10-/2-bit range boundaries) and depth/stencil;clear_color_testchecks both replay paths for 19 integer formats without a GPU, including unchanged float values. SRGB clears are omitted from that comparison;d3d12_clear_formats_testcompares them (next item). Open: on NVIDIA RTX 5080 (driver 616.56) clears that land exactly on a.5UNORM/SNORM step round down where WARP rounds up:R8G8B8A8_UNORM/SNORM0.5 store7f/3fvs WARP80/40, and aD16_UNORM0.5 depth clear stores0x7fffvs WARP0x8000(all onmainbefore this change; same 1-ulp class as SRGB, not addressed here).D32_FLOATandD32_FLOAT_S8X24_UINTmatch WARP. This does not add typed-view reinterpretation of typeless resources. -
sRGB RTV clears (D3D-CLEAR-SRGB-ENCODE):
ClearRenderTargetViewthrough anR8G8B8A8_UNORM_SRGBorB8G8R8A8_UNORM_SRGBview encodes the colour channels in the layer and hands Vulkan the linear value of the resulting code (srgb8_from_linearandsrgb8_linearinvulkan_replay.h); alpha is linear and rounds like UNORM. Before, the linear float went tovkCmdClearColorImageorvkCmdClearAttachmentsas it was and the GPU encoded it, so the stored byte depended on the GPU: 0.5 wasbbon an Intel Iris Xe andbcon WARP and an NVIDIA RTX 4060. Measured (Windows 11 build 26100, WARP 10.0.26100.5074, Iris Xe with Intel 32.0.101.7092, RTX 4060 Laptop with NVIDIA 616.92; a scratch program cleared 256-slice sRGB targets through the layer and through WARP, a whole view and a rectangle each, and bisected over float bit patterns):- No driver is wrong. D3D permits FLOAT → SRGB a tolerance of 0.6 of a step (Direct3D 11.3 functional specification, 3.2.3.8), and each implementation puts the 255 steps between two codes somewhere else: measured against the halfway point of the ideal curve, the Iris Xe's sit between 0.18 of a code below and 0.33 above, the RTX 4060's within 0.10 and WARP's between 0.29 below and 0.34 above. On each GPU both Vulkan commands have the same 255 steps. Of 60 000 random values (half uniform in 0..1, half log-uniform from 1e-6) the Iris Xe stored another byte than WARP for 6 649 and the RTX 4060 for 3 648, never more than one code away.
- WARP takes the value to 12 bits first and encodes that:
j = floor(x * 4095 + 0.5)with the product rounded to single precision, then the nearest code of the IEC 61966-2-1 curve atj / 4095. The 255 floats at which WARP's byte changes are the 255 this rule gives (with the product in exact arithmetic only 188 are:0x3f018018times 4095 is 2071.4999986, which a float rounds to 2071.5), and WARP agrees with it on 84 582 further values: every 12-bit value, five floats around each of the 4 095 places between two of them, the 60 000 random ones, 0, 1, values outside 0..1, NaN and both infinities. It is not the nearest code of the ideal curve for 2 852 of the 60 000 (0.0004 is 2, the curve gives 1.32). - WARP and both GPUs store the linear value of a code as that code, for all 256 codes and with both commands. That value is the one farthest from any implementation's steps, so it is what the layer hands over; a GPU whose encoding is more than half a code off at one of these values would still differ.
- Each GPU's own D3D12 driver stores what its Vulkan driver stores (the same byte for 84 582 of 84 582 values, on both GPUs): the encoding is the hardware's. So the layer used to store the bytes of the D3D12 driver of the GPU it ran on, and now stores WARP's on every GPU, which differ from the Intel driver's for those 6 649 of 60 000 values and from the NVIDIA driver's for 3 648. That is the choice made before for the ties of UNORM clears and for D24: the layer converts, WARP is the reference, and a host driver that does otherwise is a host quirk.
clear_color_test(no GPU) pins 38 values to the bytes WARP stored, checks that every code encodes to itself and that the result is the same under each floating-point rounding mode.d3d12_clear_formats_testclears both formats to the UNORM colours, the value of every code and the value halfway between every two codes (176 colours each, as a whole view and as a rectangle): against WARP, 178 of the 352 cases differed on the Iris Xe and 170 on the RTX 4060 before, none after (the five UNORM colours alone differed in 10 of 10 cases on the Iris Xe and in none on the RTX 4060).d3d12_state_sweep_testcompares with the D3D12 driver of the same adapter and cleared its sRGB targets to 0.2, 0.4 and 0.6, of which the first two are codes 124 and 170 on WARP and 123 and 169 on the Iris Xe; it now clears them to the values of codes 124, 170 and 203, so its eight sRGB cases compare the blending whichever way the host encodes. A draw into an sRGB target is still encoded by the GPU. -
Depth clears. Microsoft documents a
[0, 1]clamp. On Windows 11 build 26100, both WARP and native D3D12 on an RTX 5070 Ti (610.74) preserved finite out-of-rangeD32_FLOATvalues and quiet NaN in full and rectangle clears. Replay preserves those values when the Vulkan device has enabledVK_EXT_depth_range_unrestricted. With the extension disabled, replay clamps finite values to[0, 1]and uses zero for NaN. The UNORM depth format conversions still apply. D3D12 reference -
D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY(public release note) and DCC: ignore the flag, let the Vulkan driver choose compression, and fail loudly if the game aliases a buffer over a compressed image or reads raw DCC metadata. -
G-buffer render targets stay 8-bit UNORM. Reported by @Silliana in #603 (not reproduced here): the material shaders pack data into plain bytes (the normal is octahedral-packed across three bytes of one target, and ID bytes sit in another) and the lighting shaders unpack them with a
* 255and a truncate. If the layer or a test gives those targets another format (say f16 for everything), a byte is lost in many pixels: the normals go wrong and the specular sparkles. Create them with the format the game asks for (R8G8B8A8_UNORMand the like) and don't substitute a wider or float format for them.
The title already supports the linear tile path (XG-SWIZZLE-LINEAR-PATH)
Read statically in 1.0.2.1; nothing was executed. Both xg_xs.dll imports are adjacent IAT thunks:
XGCreateTextureComputer at 0x145F3FF40 (JMP [0x146793F60]) and XGSuggestSwizzleMode at
0x145F3FF50 (JMP [0x146793F68]).
XGSuggestSwizzleMode has one shape at both call sites, 0x140C4B3CE (in 0x140C4B030) and
0x144ECCCA2 (in 0x144ECC940). The helper loads the description's tile-class byte [desc+8],
compares it with 0xFF (0x140C4B3B5, 0x144ECCB00/0x144ECCB28) and calls only on equality, so
the class is unknown. The arguments are RCX = the description block being filled, RDX = 0
(XOR EDX,EDX) and R8 = RCX+0x2C (LEA R8,[RCX+0x2C]), the block's 32-bit tile-mode field —
i.e. XGSuggestSwizzleMode(desc, NULL, &desc->tileMode). Both helpers zero the block at +0x28
first, so that field is 0 unless a class is known; a known class writes 0x100 | class (with
0x102 and 0x10A as special cases) and never 0. The result the callee writes is therefore the
mode, and 0 is already the value the title uses for "linear" everywhere.
The consumers test that mode word as tiled with CMP x,0x100 plus BT x,9 (bits 8 and 9) and
run the linear arithmetic on the 0 result:
0x14555E9E0, test at0x14555EA2C: 0 stores 0 at[out+8]and returnspitch*(row+…) + xat0x14555EA45.0x14193DE10, test at0x14193DE73: 0 goes to0x14193DE9E(which builds a layout through0x140C4B030at0x14193E06Band then calls0x1416F7100from0x14193DF4B), not to the tiled branch at0x14193E314.0x1404F4210, test at0x1404F448A: 0 takes0x1404F44E4.0x145121690takes its non-0x980path and calls the computer's+0x40with offset 0 and apitch*heightspan.
What a shim can do with that: XGSuggestSwizzleMode writes 0 and returns S_OK, and
XGCreateTextureComputer can hand back an object whose slots used at these sites (2, 8, 10 and
+0x40) pass the byte offset through and report the full linear row span. The linear paths above
compute pitch*row + x themselves and ask the object only for an offset, so nothing has to model
a tile. FUN_145121980 (0x145121980) is not the mode test but a cache: 0x144DB9180 keys it on
the description bytes, 0xE and (flags&0xFF)<<16 | mode, and it builds a tiled layout only on a
miss, so an identity computer still has to answer whatever that branch asks.
What is not established: 0x102 and 0x10A are written by the two helpers, but the four
consumers above only special-case 0x100 and bit 9, so whether the variants are meant to be tiled
was not measured. The physical layout of a non-zero mode is not new here either
(textures.md, runtime/src/gfx10_tiling.h); 0 is the choice of the linear layout,
not a description of one.
4.3 Barriers and layouts
Plain buffer copies order earlier transfer writes on the same queue before reading or writing the next range.
Set LEONIDA_ORDER_BUFFER_COPIES=0 to omit this dependency when comparing replay behavior.
Track a current state/layout per subresource. D3D12 states are bitmasks; a combined state takes the union of the
mapped stages/accesses, and if no single layout serves all uses, use GENERAL and log it. Legacy
D3D12_RESOURCE_STATE_* maps to a (stage, access, layout) triple:
| D3D12 state | Vulkan layout | Stage / access |
|---|---|---|
COMMON |
GENERAL for images, no layout for buffers |
Promote on first use |
RENDER_TARGET |
COLOR_ATTACHMENT_OPTIMAL |
COLOR_ATTACHMENT_OUTPUT / write |
DEPTH_WRITE / DEPTH_READ |
DEPTH_STENCIL_ATTACHMENT_OPTIMAL / DEPTH_STENCIL_READ_ONLY_OPTIMAL |
early/late tests |
PIXEL_SHADER_RESOURCE |
SHADER_READ_ONLY_OPTIMAL |
fragment shader / read |
NON_PIXEL_SHADER_RESOURCE |
SHADER_READ_ONLY_OPTIMAL |
vertex/compute/etc. / read |
UNORDERED_ACCESS |
GENERAL |
shader / read+write |
COPY_DEST / COPY_SOURCE |
TRANSFER_DST_OPTIMAL / TRANSFER_SRC_OPTIMAL |
transfer |
RESOLVE_DEST / RESOLVE_SOURCE |
TRANSFER_DST_OPTIMAL / TRANSFER_SRC_OPTIMAL |
resolve |
STREAM_OUT |
no layout for buffers | transform feedback write (if used) |
VERTEX_BUFFER / INDEX_BUFFER / INDIRECT_ARGUMENT |
no layout for buffers | vertex input / index / draw indirect |
PRESENT |
PRESENT_SRC_KHR for swapchain images, GENERAL otherwise |
present |
RAYTRACING_ACCELERATION_STRUCTURE |
buffer, no layout | acceleration structure read/write |
-
Split barriers (
BEGIN_ONLY/END_ONLY, and enhancedSYNC_SPLIT) are an optimisation. The resource is unusable between the halves, so one full barrier at either point is correct; the IR records it at the end point (command_list.h). UseVK_KHR_synchronization2events if profiling needs the overlap. -
Implicit promotion and decay need no extra barriers:
COMMONisGENERAL, and the layout tracker makes later barriers start from it (section 3.2). -
Aliasing barriers: if image aliasing is implemented (one
VkDeviceMemoryper D3D12 heap range, withVK_IMAGE_CREATE_ALIAS_BIT), transition the old image toUNDEFINED, issue a global memory barrier, then transition the new image. Until then, log aliasing and allocate distinct memory; do not silently return the wrong contents. -
Enhanced barriers (
D3D12_BARRIER_SYNC_*,D3D12_BARRIER_ACCESS_*,D3D12_BARRIER_LAYOUT_*) map directly toVkPipelineStageFlags2,VkAccessFlags2andVkImageLayout(vulkan_sync,vulkan_barrier_access,vulkan_layout). Queue-specific layouts map like their generic forms; ray tracing, video and split scopes useALL_COMMANDS;LayoutBefore = UNDEFINEDor the discard flag becomesoldLayout = UNDEFINED.SYNC_COPYisCOPY | CLEAR, notCOPYalone:WriteBufferImmediateis recorded asvkCmdUpdateBufferandResolveQueryData's never-written queries asvkCmdFillBuffer, which synchronization2 runs in theCLEARstage (D3D-838;vk_command_replay_testpart K is a read-after-write hazard under synchronization validation without it). -
LayoutAfter = UNDEFINEDfrom a defined layout (D3D-BARRIER-INTO-UNDEFINED) releases the subresources: their contents are no longer needed, as before their memory is aliased. Vulkan has no transition intoUNDEFINED(VUID-VkImageMemoryBarrier2-newLayout-01198), so each piece gets a barrier witholdLayout = newLayout, the layout the tracker has for it: the accesses are ordered and nothing in the image changes. The tracker keeps those layouts. A piece never used yet gets no barrier and is not zero-filled for it. The next barrier on these subresources has to start fromUNDEFINED, which discards from whatever layout they are in, as before. The list closes, as it does on WARP (measured on Windows 11 26340 in #984). #984 also reports that the retail title ends a depth buffer's use this way and takes a failedCloseas fatal; the layer failed such a list'sCloseuntil this change.UNDEFINEDtoUNDEFINEDis a separate case (#600).- Tests:
command_list_testandreplay_texture_barrier_test(CPU: the barriers recorded, the kept layouts, an unused image, the barrier that follows); three rows ofd3d12_close_parity_test;vk_command_replay_testpart L (a colour target, a depth buffer whose planes are in two layouts and an unused image released, the target used again and read back); andd3d12_com_test, where a depth buffer is cleared, released, taken fromUNDEFINEDagain, cleared and read back through the D3D12 list and queue (16 depth and 16 stencil texels exact). Run on an RTX 4070 Ti (NVIDIA 620.70.06, Linux): part L natively with the validation layer 1.4.363 and no error, where the same barriers withnewLayout = UNDEFINEDgive VUID-VkImageMemoryBarrier2-newLayout-01198 four times; the D3D12 tests under Wine.
- Tests:
-
A rejected recording call logs
<method> rejected a call (d3d12_com.cpp:<line>)the first time each call site rejects one (Barrier and CopyTextureRegion also print their arguments), and a batch the queue's replay refuses logsqueue replay refused a batch at vulkan_backend.h:<line>, so a failedCloseorExecuteCommandLists failed: unsupportednames its cause. -
DiscardResource(D3D-26): each discarded image subresource gets a barrier fromoldLayout = UNDEFINEDto the layout the tracker already has for it, so the driver may drop the contents while later commands see no layout change. The other cases are no-ops, which "contents undefined" allows: buffers, discards with rectangles (only part of each subresource), a part never used yet (it is still to be zero-filled on first use), a list replayed without a tracker, and one plane of a combined depth-stencil image withoutseparateDepthStencilLayouts(discarding one plane would also discard the other). A null region is recorded aswhole; a region is always an explicit range, even withNumSubresources = UINT_MAX, so itsFirstSubresourceis checked like any other. -
Access bits and sync scopes are not one-to-one. D3D12 lets an access be named with a sync scope whose Vulkan stages cannot perform it:
SYNC_ALL_SHADINGwithACCESS_VERTEX_BUFFERis valid D3D12, butVK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BITneedsVERTEX_ATTRIBUTE_INPUT, which shading stages are not. Vulkan rejects such a barrier.vulkan_barrier_scopetherefore widens each side's stages by the narrowest stage that can perform each access without one. The table is the synchronization2 chapter's "supported access types". The stages it adds:DRAW_INDIRECTfor indirect arguments;INDEX_INPUTandVERTEX_ATTRIBUTE_INPUTfor index and vertex buffers;- all shading for constant buffers, SRVs and UAVs;
COLOR_ATTACHMENT_OUTPUTfor render targets;- the fragment tests for depth/stencil;
ALL_TRANSFERfor copies and resolves.CLEARalone cannot read, andALL_GRAPHICScontains no transfer stage.
The access itself is never dropped, so the dependency still covers everything the application named, over a slightly larger scope.
-
Render passes:
BeginRenderPass/EndRenderPassmap tovkCmdBeginRendering/vkCmdEndRendering(dynamic rendering). TheD3D12_RENDER_PASS_BEGINNING_ACCESS/ENDING_ACCESStypes give the load/store ops and resolve targets. Suspending/resuming passes have no direct Vulkan equivalent; split them into two rendering scopes with the same attachments andLOAD/STORE. If the game does not use render passes, build a rendering scope per draw from the bound RTVs/DSV and let explicitClear*Viewcalls do the clears.
4.4 Fences, queues and frames in flight
- One timeline semaphore per
ID3D12Fence. QueueSignal=vkQueueSubmitsignal; queueWait= submit wait. - Wait before Signal across queues, with resources handed over (
src/queue_holds.h,VulkanQueue; testd3d12_queue_handover_test). Vulkan accepts a timeline wait whose signal comes later, but the layer replays everyExecuteCommandListsagainst oneLayoutTrackerin the order the calls arrive, so a queue that waits for work submitted afterwards would be recorded against the layouts from before that work (a copy list that reads a texture a compute list has not yet written was replayed againstUNDEFINED: zero-filled, and a validation error). The layer therefore tracks, per fence, the highest value a Signal has been submitted for (or the CPU has set; the creation value counts), which is not the completed value. A queue that is asked to run a batch (or aSignal) while aWaitit carries names a value above that, or while an earlier batch of the queue is held, copies the lists (CommandListis a value; the application mayResetits list at once) and holds the operation. Everything the queue is asked to do after it (batches, Signals, queue markers) goes behind it, so per-queue order is kept. The held operations are recorded and submitted, in order, on their ownVkQueueas soon as the Signals they wait for have been submitted: by the thread that submits that Signal (or makes the CPUSignal), after it has dropped its own queue's state lock. There is no worker thread and no GPU wait is added, but the call that releases is not free: that thread records the held batches (what theExecuteCommandListswould have cost, including whateverexecutedoes for the lists, such as the bindless upload's wait for the device until D3D-314 removes it) while it still holds the mutex of the D3D12 queue whoseSignalorWaitit is in, so other calls on that queue wait meanwhile; andremove_fence, queue destruction and presenter destruction wait for a release in progress. One thread releases at a time (the others leave a note and the running one makes another pass); a release that submits a Signal lets the next queue's front run in the same pass, so chains (C waits B, B waits A, in any submission order) and operations with several waits resolve in dependency order, and the layout tracker follows that order. A wait whose value has been reached by a submitted Signal never blocks again (vkd3d-proton's rule too). The normal case (the Signal submitted first) is unchanged: no copy, no hold, the samevkQueueSubmit. Holding on the CPU also avoids a Wait and its Signal landing in the wrong order on oneVkQueue, which would not make forward progress on the GPU (Vulkan-Docs issue 1262): the test also runs with every D3D12 queue on oneVkQueueand with two. What a held operation keeps alive, as D3D12's queue does: the fences it waits on and signals, until its submission has completed on the GPU (a released fence stays until then, which also removes the destroy-while-pending validation error the unheld path could hit); the pipeline states and root signatures of its lists (copied from the recording before the application mayResetit, so releasing a PSO right afterExecuteCommandListsis fine). Resources are not kept: a resource released while a batch that names it is held fails that batch at release. Order against other work: a heldSignal(F, v)released after an unheldSignal(F, w)withw >= vleaves the Vulkan signal out (timelines only increase; waits forvalready pass), decided under the submit lock so the order of the checks is the order of the submissions, and the value counts as submitted only once thevkQueueSubmitsucceeded (a failed Signal releases nobody and its retry goes through);Presentis queued behind held work too (below). Fence keep-alives are released outside the queue lock, at the nextExecuteCommandLists,Signal,Waitor marker once their submission has completed. Edge cases: a queue destroyed with held operations reports them once (stderr:queue destroyed with N held operation(s) never submitted: waits for a fence value (V) that no Signal reached) and goes on without waiting, and the CPU waits on the fences of its held Signals are completed, as a released fence completes them; queues that wait for those fences stay held and are reported when they go; a fence nobody signals holds back only the queues that wait for it (and for what they would have signaled), never the others; a Signal value that is not above the fence's is still dropped with a note at call time, as before (vkd3d-proton instead maps virtual fence values to physical timeline values; the layer does not yet). A heldExecuteCommandListsthat fails when it is released does not return its result to a call that has returned: it is printed,last_execute_resultandVulkanQueue::take_held_failurereport it, theSignalbehind it still signals (the work did not run; nothing waits forever, as for a failure that is not held), and its waits stay for the queue's next submission, as after a failedvkQueueSubmit. A queue does not holdUpdateTileMappings/CopyTileMappings: they still submit at once, before earlier held work, and take the queue's pending waits (documented limit).VulkanQueue::idlewaits for submitted work only.Present(VulkanPresenter): when any queue holds work, a presented back buffer would be blitted as it was before that work, so the Present is queued instead (QueueHolds::after_held), returns success as a heldExecuteCommandListsdoes, and is submitted, in order with the presents queued before it, by the thread that releases the last operation held when it was called. It is not blocked on the calling thread because the Signal that releases the work may be one that thread makes afterPresentreturns. Held work that is never released holds back the presents after it (device-wide, since the layer cannot tell which batch draws into which back buffer). A blank present reads nothing and is only ordered behind earlier queued presents. At most 8 presents queue up; the next one waits for held work to release (logged once;set_abortends the wait), as a full frame-latency queue does. A queued present reportslast_present_tore()false, which the Xbox PresentX path turns into the default vblank sync for the frame pacer. The presenter's state is guarded by one mutex (the counters are atomics, so reading them never waits for a present blocked on a swapchain image);set_aborthas its own. Facts from vkd3d-proton (LGPL, approach only, nothing copied): it keeps a CPU-side virtual value and pending signals per fence and blocks the queue's submission thread until a signal that satisfies a wait has been submitted, so Vulkan never sees a wait without a submitted signal. Resources areVK_SHARING_MODE_EXCLUSIVEand every D3D12 queue is in the graphics family, so no ownership transfer is needed; with dedicated compute/transfer families they would needCONCURRENT(vkd3d-proton does that, because D3D12 gives no information for transfers). Every mode of the handover test ends with the same cases on the host runtime (the expected data is the CPU's pattern in all of them, so that run shows the cases are valid D3D12 and holds the layer's modes to one bar). The pipeline-state and root-signature pins are covered end to end byd3d12_m4_compute_test: the compute list is executed while held, its two PSOs and root signature are released and the list is Reset, the copy that releases it is submitted, and the output is compared with the CPU (it reads zeros without the pins). Measured:d3d12_queue_handover_test(three modes: the standalone device with aVkQueueper D3D12 queue, then the host runtime;--two-queues, a caller-owned device with twoVkQueues handed over;--shared-queue, one) runs 592 cases on the layer on the Radeon 880M and the RTX 5070 (also with one sharedVkQueue; 8 with two handed over) and 587 on the host runtime: pairs and three-stage chains (produce, relay, consume) over the queue type assignments that fit and all 6 submission orders (consumer first among them), two producers (texture from one queue, buffer from another) with one consumer, a chain released by a CPUSignal, a CPUSignalbefore and after theWait, a never-signaled fence, a fence released while a batch waits, a held Signal of a fence the application released, a held Signal below an unheld one on a shared fence, teardown with a held Signal under a CPU wait, and 200 rounds with two threads signalling and releasing at once; results compared byte for byte, sync validation clean. With holding disabled the test fails 236 cases and validation reportsVUID-vkCmdDraw-None-09600; with the monotonic check disabled it reportsVUID-VkSubmitInfo-pSignalSemaphores-03242;vk_presenter_sync_testandd3d12_m4_compute_test(which submits the compute list first and releases its PSOs and root signature before the copy that feeds it) fail without the Present ordering and the pins. - More D3D12 queues than Vulkan queues (
pick_queue_slotinsrc/queue_families.h,CreateCommandQueue; testd3d12_queue_share_test). A GPU can expose fewerVkQueues than a title creates D3D12 queues: the Intel UHD 770 on Windows and lavapipe have one family withqueueCount1, so the second D3D12 queue of any type was refused withE_OUTOFMEMORY("no independent Vulkan queue available") and a title with a DIRECT and a COMPUTE queue stopped at boot (PingasMech, #4863). A new D3D12 queue takes an unusedVkQueueof its own type's family, then of the graphics family, as before (D3D-97: oneVkQueueper live D3D12 queue while there are enough, so nothing changes on a GPU with enough queues; an RTX 5080 gives 16 graphics, 8 compute and 2 transfer queues); when every one is in use it shares the one with the fewest D3D12 queues (its own family's first on a tie) and logs that once per type. D3D12 queues on oneVkQueuestay separate objects: each keeps its own batches in order, its own progress timeline and its own held operations; theVkQueueruns their batches one after the other, in the order they reach it, so they lose concurrency, not correctness (as on one family, below). What would break is a GPU wait that no submitted signal satisfies landing on the sharedVkQueueahead of the signal it waits for, which never makes progress. The holding above already rules that out: a batch reachesvkQueueSubmitonly once every fence value it waits for has a submitted Signal (earlier on the sameVkQueue, or on another one) or has been set by the CPU. One case let the CPU half slip: a CPUSignalthat has to wait behind a queue Signal the GPU has not reached yet (VUID-VkSemaphoreSignalInfo-value-03259, applied later by the fence wait thread) never told the held queues, so a queue waiting for that value was held for ever, on separateVkQueues too. The wait thread now reports the value once it has set it, and releases what it satisfies; reporting it earlier, when the CPU calledSignal, would send the waiting batch ahead of the queue Signal it depends on, which on a sharedVkQueuenever completes.vkQueueSubmit,vkQueueBindSparse,vkQueuePresentKHR,vkQueueWaitIdleand the queue labels need theVkQueueexternally synchronised; every call the layer makes holds the device's one submit lock (VulkanContext::submit_mutex), which covers sharedVkQueues as it covers the staging queue the first DIRECT queue already shares. A per-VkQueuelock (#3841) must key on theVkQueuehandle, not the D3D12 queue. Costs on a sharedVkQueue:GetClockCalibrationwithout calibrated timestamps and the destruction of a D3D12 queue wait for the other D3D12 queues' submitted work too, and queue debug labels (BeginEvent/EndEvent) of the D3D12 queues interleave on it. Two test settings make the standalone device look like such a GPU, so the sharing path runs anywhere:LEONIDA_VK_MAX_QUEUES_PER_FAMILY=N(at most NVkQueues per family) andLEONIDA_VK_GRAPHICS_FAMILY_ONLY=1(COMPUTE and COPY in the graphics family); both together are one family with one queue (docs/testing.md, "Choosing the GPU"). Only the test executables apply them: the game's device (d3d12_xs,LEONIDA_D3D12=vulkan) ignores them and says so, so a variable left in the environment cannot put every queue of the game on oneVkQueue(run_tiny_frame_queue_test_settings). Measured on an RTX 5080 (Linux, driver 580.65.06, Wine 11) and on lavapipe, under the validation layer with synchronization validation:d3d12_queue_share_testpasses with no setting, with one queue per family, with one queue in all and on lavapipe (36 queues, a buffer copied exactly through all of them consumer first and producer first, 9 deferred CPU Signal cases, 4 threads on 9 queues: 2,000 iterations with all 9 on oneVkQueueof the RTX 5080, 80,000 on lavapipe; a fence released right after the GPU passed the queue Signal its deferred CPU Signal waited behind, 900 times per mode, the held batch running every time), 0 validation messages; on main it fails at the 27th queue on the RTX 5080 and at the 2nd on lavapipe, and the first deferred case hangs. The layer half ofd3d12_queue_handover_testruns its 371 cases exact in all four (on lavapipe main ran 0: one queue). SetEventOnCompletion(value, hEvent): a small wait thread callsvkWaitSemaphoresandSetEvent. Reuse one thread with a condition variable; do not create a thread per fence.GetCompletedValueisvkGetSemaphoreCounterValue; CPUSignalisvkSignalSemaphore.SetEventOnMultipleFenceCompletion(implemented). With a null event it is one blockingvkWaitSemaphoresover every fence's semaphore, withVK_SEMAPHORE_WAIT_ANY_BITforD3D12_MULTIPLE_FENCE_WAIT_FLAG_ANYand no flag forALL. With an event, the device's fence wait thread counts down one shared waiter (1 forANY, the fence count forALL, kept as the API's unsignedUINT) and the hit that reaches zero sets the event, so no thread is added; later hits stay at zero (d3d12_fence_waiter_testchecks counts pastINT_MAX). Values already reached are counted before the call returns. Zero fences, other flags, a null array or a fence from elsewhere areE_INVALIDARG, as on the PC runtime. A fence released while an event waits on it counts as reached for that wait, as on the PC runtime (RTX 5070 and WARP):SetEventOnCompletionandANYset the event,ALLcounts it as one fence (d3d12_fence_events_test).- The swapchain owns acquire/present semaphores and N frames in flight. A present waits for the frame's render-finished semaphore; the next acquire waits for the image's present-complete semaphore.
- Queue types: a direct queue maps to a graphics+compute queue, a compute queue to a compute-only family if one exists, a copy queue to a transfer-only family. If the host exposes only one family, serialize and log; async compute is a performance feature, not a correctness one.
GetTimestampFrequency/GetClockCalibrationuseVK_EXT_calibrated_timestampswhere available.GetClockCalibration(implemented) returns the GPU stamp in device ticks (1e9 / timestampPeriodper second, the units ofGetTimestampFrequency) and the CPU stamp inQueryPerformanceCounterunits. When the device hasVK_KHR_calibrated_timestampsorVK_EXT_calibrated_timestampsenabled (VulkanDeviceInfo::calibrated_timestamps; the standalone device enables whichever the GPU has) and offers theDEVICEandQUERY_PERFORMANCE_COUNTERdomains, it is onevkGetCalibratedTimestampsKHRcall. The fallback waits for an empty completion marker and then submits avkCmdWriteTimestamp. It answers with the midpoint of theQueryPerformanceCounterreads around the timestamp submission. The collecting thread waits on its private timeline, outside the device-wide submission lock, so other application threads can still submit work. A queue family withtimestampValidBits = 0fails withE_FAIL.d3d12_fence_timing_testtakes two calibrations 50 ms apart and compares the GPU and CPU intervals. On an RTX 4090 (driver 621.14) the gap is 2 us with calibrated timestamps, 20 us with the fallback, and 0.4 ms with the fallback under the validation layer. The test fails above 2 ms.
4.5 Swapchain and present
The game package does not include dxgi.dll, so the executable imports it from the system (or from the GDK).
That import must be shimmed. The shim provides:
CreateDXGIFactory/CreateDXGIFactory2→ one fake factory with one adapter describing the host Vulkan device.IDXGIAdapter::GetDescreports host memory/LUID; the game may use these for settings. Open: whether it expects Xbox Series X values (16 GB, fixed clocks) instead.IDXGIFactory::CreateSwapChain/CreateSwapChainForHwnd→VkSurfaceKHRfor the HWND +VkSwapchainKHR.GetBuffer(i)wraps each swapchain image as anID3D12Resourceso the game can create RTVs.Present→vkQueuePresentKHR;ResizeBuffers/ResizeTargetrecreate the swapchain;SetFullscreenStatetoggles borderless/fullscreen;GetFrameStatisticsis a stub.DXGI_PRESENT_TEST/DO_NOT_WAITmap to a no-op/VK_NOT_READYpath.
What exists. The DXGI shim's Present (runtime/shims/dxgi_com.cpp) has its own surface, swapchain and
blit (leonida::VulkanSwapchain, runtime/shims/dxgi_swapchain.h); PresentX (runtime/shims/xbox_present.cpp)
is implemented over leonida::VulkanPresenter (section 3.2) instead. PresentX takes ordinary committed
textures and blits them at present time, which frees the game's buffer count and format from the surface's. The
DXGI shim's GetBuffer(i) returns the swapchain images themselves, and switches to offscreen images blitted at
present only when the requested size or format differs from the surface's (runtime/shims/dxgi_swapchain.h); its
buffer count is the swapchain's image count.
PresentX and frame events (GDKX). Public Microsoft samples present on Xbox without a DXGI swapchain. Facts
below come from MIT/zlib-licensed code and docs, read directly; none is from the game or the SDK. Sources:
SimpleDeviceAndSwapChain
(readme: "Instead of using DXGI for presentation, this uses the new PresentX API"),
FramePacing,
DirectXTK12 wiki, DeviceResources ("The GDKX
platform uses PresentX, so the method WaitForOrigin has to be called each frame loop"),
directxtk12modelviewer DeviceResourcesGXDK.cpp (MIT) and
SDL2 src/render/direct3d12/SDL_render_d3d12_xbox.cpp (zlib).
Fact (call sequence in those samples):
D3D12XboxCreateDevice(nullptr, ¶ms, iid, &device): adapter pointer null, a params struct (ring and scratch sizes,D3D12XBOX_DEFAULT_SIZE_BYTES= use default), IID, out pointer. SDL asks forID3D12Device1.- Back buffers are ordinary
CreateCommittedResourcecalls withD3D12_HEAP_FLAG_ALLOW_DISPLAY, initial stateD3D12_RESOURCE_STATE_PRESENT,ALLOW_RENDER_TARGET, 2D, one mip (SDL:B8G8R8A8_UNORM). They are the game's own resources, not objects owned by a swapchain. - DXGI is used only to find the output: QI the device for
IDXGIDevice1,GetAdapter,EnumOutputs(0). device->SetFrameIntervalX(output, D3D12XBOX_FRAME_INTERVAL_60_HZ, n-1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE): 4 arguments; the third is the allowed frame latency (SimpleDeviceAndSwapChain passes buffer count minus 1, SDL passes 1). Thendevice->ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, nullptr, ..._FLAG_NONE): 4 arguments (event, aUINTpassed as 0, a pointer passed as null, flags).- Per frame:
device->WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, INFINITE, nullptr, ..._FLAG_NONE, &token): 5 arguments, the last an out pointer to aD3D12XBOX_FRAME_PIPELINE_TOKEN(SDL stores it in aUINT64; the null value isD3D12XBOX_FRAME_PIPELINE_TOKEN_NULL). Then render,ExecuteCommandLists, thenqueue->PresentX(planeCount, planes, params): 3 arguments (UINT, pointer to an array ofD3D12XBOX_PRESENT_PLANE_PARAMETERS, optional pointer toD3D12XBOX_PRESENT_PARAMETERS; null in the simple samples). - Plane fields used:
Token(the value from the wait),ResourceCount(1),ppResources(pointer to the resource pointer(s)),pSrcViewRects(pointer to a rect, HDR case only) andColorSpace(aDXGI_COLOR_SPACE_TYPE). The HDR path uses 2 planes sharing the token: plane 0RGB_FULL_G2084_NONE_P2020(HDR10), plane 1RGB_FULL_G22_NONE_P709(the GameDVR/SDR copy, its own back-buffer set). Non-HDR uses 1 plane. This agrees with the UMD limit of 2 planes ind3d12_xs_surface.md§7. D3D12XBOX_PRESENT_PARAMETERShas at leastImmediateThresholdPercent(float). Per the FramePacing text: a late frame is shown immediately only if scanout has not passed that percentage of the screen; 0 disables limited tearing, 100 allows a late flip anywhere in the scan.- Suspend:
queue->SuspendX(0)(one argument, passed 0; no other thread may be rendering). Resume:queue->ResumeX(), then re-run steps 4'sSetFrameIntervalX/ScheduleFrameEventX. The samples say frame events must be registered again after resume. - Shutdown:
PresentX(0, nullptr, nullptr)presents a blank screen before resources are released. - Statistics:
device->GetFrameStatisticsX(token, typeMask, &count, array): 4 arguments. Type bits seen:FRAME_INTERVAL,FRAME_EVENT,RENDER,PRESENT,DISPLAY;countis in/out;S_FALSEor a short count means "not available yet"; no statistics for the first presented frame; render/present/display entries carry aPlaneIndex; display entries carryPercentScanned. - Xbox titles do not handle
DXGI_ERROR_DEVICE_REMOVED/RESET.
Not measured: vtable slots of all *X methods, exact D3D12XBOX_* struct layouts and sizes, enum values, and
whether the token is exactly 64 bits in the ABI. The samples give argument counts and field names only.
Hypothesis (the game is not observed): a GDKX title follows this pattern, so the DXGI swapchain shim (D3D-2)
is probably not on its boot path. What is on it: D3D12XboxCreateDevice, IDXGIDevice1/IDXGIAdapter/
IDXGIOutput enumeration, committed ALLOW_DISPLAY resources, the frame events and PresentX. Without the
frame events and PresentX no frame reaches the screen. To confirm: trace which of CreateSwapChain* or the
queue's PresentX slot the game calls first; check the executable's dxgi/d3d12_xs imports.
Layer plan:
- Keep the DXGI factory, adapter and output enumeration (adapter
GetDesc,EnumOutputs); no host DXGI. - Step 3 of the sequence is on the device proxy: it answers
IDXGIObject,IDXGIDeviceandIDXGIDevice1as one COM object with the device (a PCID3D12Devicehas noIDXGIDevice, so nothing is forwarded), andGetAdapterandGetParentreturn the adapter of the device behind it: the layer's own on the Vulkan device, the host adapter with the device's LUID on the host backend. The 14 slots are the publicdxgi.horder, an assumption like the queue's.SetMaximumFrameLatencyandSetGPUThreadPriorityare kept and read back only.dxgi_device_testwalks it on both backends; the output itself isEnumOutputs(D3D-313). ALLOW_DISPLAYcommitted resources are normalResources that the presenter may blit to a Vulkan swapchain image;PRESENTstate maps per the resource-state table (PRESENT_SRC_KHRonly for swapchain images).- Presentation core:
PresentXwith 0-2 planes presents into theVkSwapchainKHR(one plain plane is a blit; scaling, placement, HDR10 and an overlay plane 1 go through a compose pass, see "Plane composition" below);SetFrameIntervalX/ScheduleFrameEventX/WaitFrameEventXrun on a vblank timer and hand the token through to the present;GetFrameStatisticsXminimal;SuspendX/ResumeX; 0 planes = blank screen. Test the methods directly with a fake clock, before slots are known. - The DXGI
CreateSwapChain*path stays as the fallback and for PC-style tests, not as the first-boot target.
What is implemented (the presentation core). Everything in the plan above that does not need a slot exists as
methods of rt::d3d12::XboxPresentation (runtime/shims/xbox_present.h), on top of the presenter of section 3.2 and
leonida::FramePacer (runtime/src/frame_pacer.h, no Vulkan, no Windows headers). The struct layouts, constant
values, HRESULTs and the 64-bit token are our own provisional definitions: the samples give call shapes and field
names only, so the real slots, layouts and enum values are still unmeasured and the class is the surface the proxy
will forward to. The queue-side calls ignore which queue they came on (one VkQueue behind all of them).
-
Frame pacing (
FramePacer, time from an injectable clock; real time is a steady timer, a host vblank source can replace it).SetFrameIntervalXtakes the interval as a period in microseconds and the latency, and starts the vblank grid.ScheduleFrameEventXarms the origin event, delayed by an offset inside the frame.WaitFrameEventXreturns at the next origin with the next token (1, 2, 3, ...; 0 is the null token) and does not return whilelatencypresented frames are still waiting for their vblank. A frame presented before the origin event is armed is not paced (PresentXdoes not hold it for a vblank), so it is shown at once and never waits for a vblank: blank presents of a loading screen do not delay the first wait. At mostlatencyframes are in flight once the event is armed: a present into a full queue (several presents with no wait between them) replaces the newest queued frame and takes its vblank, like a mailbox, so the replaced frame is never shown (no display statistic) and the older ones keep their vblanks. However many presents come between two waits, the next wait passes when the oldest frame is shown. A wait that comes late returns at once with the newest passed origin; the missed ones are skipped. A finite timeout givesHRESULT_FROM_WIN32(WAIT_TIMEOUT); nothing registered, or suspended, givesHRESULT_FROM_WIN32(ERROR_INVALID_STATE).LEONIDA_PRESENT_UNCAP(any non-empty value other than "0", read when the object is made) takes the frame-rate cap off: a wait hands its token out at once (no vblank grid, no latency throttle) andPresentXpresents unsynced — MAILBOX or IMMEDIATE, not FIFO — so the frame rate is whatever the title renders; registration and suspension errors are unchanged, and the statistics of an uncapped frame report its present time. This covers the frame-event cap only: a cap inside the game's own code would still apply, and the DXGI swapchain fallback keeps the app's sync interval.GetFrameStatisticsXkeeps the last 64 frames and reports the event, present and display times (not render;PercentScannedonly for a frame shown at once byImmediateThresholdPercent, else 0);S_FALSEwith count 0 for what it does not have. Pacing drift reporting (BL-6):FramePacerkeeps fixed-capacity ring buffers (frame_pacing_window = 1024) of present-to-present frame intervals and origin-to-present latencies (clearing the last-present anchor acrossSuspendX/ResumeXso suspended pauses are excluded), computing nearest-rankp50/p95/p99and the mean drift against the active target interval (FramePacer::pacing_summary()). On teardown after at least one present,XboxPresentationlogs a single[rt] present: pacing summary ...line on stderr, whichtools/boot_trace.pysurfaces beside the D3D12 call counts. The intervals are betweenPresentXcalls, not between frames shown: a frame replaced in a full queue (see the latency limit above) still counts as a present with its real interval, so the percentiles describe the title's present cadence, and a burst of presents between two waits shows up as short intervals. Confirmed on a fake clock byframe_pacer_test(known 100-frame distribution, positive and negative drift, ring-buffer wrap-around, suspend/resume exclusion, uncapped mode, replaced frames) and bytests/test_boot_trace.py. -
PresentX: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a single-sample 2D colour texture inPRESENT) to the swapchain image, limited topSrcViewRects[0]when set (bilinear, so the rectangle's outer texels blend with their neighbours). The blit converts between formats; an sRGB source gets an sRGB swapchain format and every other source a UNORM one, so the encoded bytes go through unchanged. A source the GPU cannot blit givesDXGI_ERROR_UNSUPPORTEDand presents nothing: the checks arevkGetPhysicalDeviceFormatProperties(BLIT_SRCon the source,BLIT_DSTon the swapchain format, cached per format; the scaling filter is linear only withSAMPLED_IMAGE_FILTER_LINEAR, else nearest), plus integer formats, which a UNORM swapchain cannot take. Multisampled planes are refused the same way: resolving one into a temporary image is not done. 2 planes must share one token (see "Plane composition" for what happens to plane 1). More than 2 planes, null planes, or an empty/outside rectangle giveE_INVALIDARG. A missingALLOW_DISPLAYheap flag is logged once and presented anyway. -
Plane composition (M7). Fact (public MIT sample, Xbox-GDK-Samples
Samples/Graphics/HDR10/DeviceResources.cppand its readme): the two-plane form there is not an overlay. Plane 0 is the HDR10 back buffer (RGB_FULL_G2084_NONE_P2020), plane 1 is a second back-buffer set holding the SDR rendering of the same frame (RGB_FULL_G22_NONE_P709), both with the same full-outputpSrcViewRects; the readme says the SDR signal "is still required for GameDVR and screenshots" and the SimpleHDR readme says the system can generate it itself (D3D12XBOX_RESOURCE_FLAG_ALLOW_AUTOMATIC_GAMEDVR_TONE_MAP). Fact (field names seen in a public Go binding of the header, hajimehoshi/ebiten, Apache-2.0; no layout or values):D3D12XBOX_PRESENT_PLANE_PARAMETERSisToken,ResourceCount,ppResources,pSrcViewRects,pDestPlacementBase(aD3D12XBOX_VIEW_RECT*, four floats left/top/right/bottom),ColorSpace,ScaleFilter,ExtendedDescCount,pExtendedDescs,Flags;D3D12XBOX_PRESENT_PARAMETERSisImmediateThresholdPercent,ViewCount,ExtendedDescCount,pExtendedDescs,Flags. Fact (GDK reference text forXGameStreamingSetResolution, read through a third-party mirror of the docs, not on Microsoft's site):pDestPlacementBasescale factors of 0.0-1.0 refer to the output size (the streaming resolution, else 1920x1080 or 3840x2160), andpSrcViewRectswithpDestPlacementBaseis how a plane is scaled. Not found in public material (so hypotheses, all labelled ours inxbox_present.h): the values ofScaleFilterandFlags, whether plane 1 can be a blended overlay at all on the console (the plane limit of 2 and the field set suggest a display-plane model, but no public sample uses it that way), premultiplied or straight alpha, what is shown outside a plane's placement, the blending space, the SDR white level, and every colour space but the two of the HDR sample.What the layer does. A plain single plane (SDR colour space, no placement, default filter) is the old blit, unchanged (
composed_presents()does not move; the test compares the bytes of a blit with the compose pass at 1:1 and they are equal). Anything else goes throughVulkanPresenter::present_planes: a compute pass (runtime/src/present_compose.comp, SPIR-V embedded asdepth24_convertis, built withglslc --target-env=vulkan1.1 -O -mfmt=c) writes an RGBA16F image of the swapchain's size, and avkCmdBlitImage(same size, nearest) puts it in the swapchain image, so the layer writes the swapchain only by transfer (no storage usage) and the capture path is unchanged. The swapchain also asks forCOLOR_ATTACHMENT, which the layer never uses: overlays that hook the swapchain (Bandicam'sVK_LAYER_bandicam_helper, measured) draw into its images through a framebuffer, and without it every frame raisedVUID-VkFramebufferCreateInfo-pAttachments-00877andVUID-VkImageViewCreateInfo-image-04441. Surfaces always report it, and the DXGI swapchain (dxgi_swapchain.h) already requested it. The planes are read withtexelFetch(no sampler, so any sampled float/UNORM/sRGB format works and filtering never reads outside the source rectangle); an sRGB-format source is decoded by the texture unit and encoded again, so its bytes are read as stored. Plane 0:pSrcViewRects[0](else the whole texture) scaled topDestPlacementBase(fractions of the output; null is the whole output; outside it is black),ScaleFilterpoint (the texel containing the sample) or linear/default (bilinear, clamped inside the source rectangle). Plane 1 is blended over plane 0 (in linear light after conversion, see "Linear-light filtering and blending"; alpha premultiplied by default or straight withxbox_plane_flag_straight_alpha) only when it carries ourxbox_plane_flag_overlay; without it plane 1 is not composed (logged once), as before, because in the public sample it is the GameDVR copy of the frame and blending a plane of unknown alpha would draw the frame twice (hypothesis: whether the console blends a second plane at all is unmeasured). The extra fields are read defensively, since their types and values are unmeasured: a placement that is not a sub-rectangle of 0..1 (empty, inverted, outside, NaN), an unknownScaleFilterandExtendedDescCountare ignored and logged once, and the plane is shown as if they were absent; a single SDR plane with null/zero extras stays on the plain blit. Planes the pass cannot read (multisampled, depth, integer, block-compressed) giveDXGI_ERROR_UNSUPPORTED. The struct inxbox_present.hfollows the field order of the binding cited above exactly (Token,ResourceCount,ppResources,pSrcViewRects,pDestPlacementBase,ColorSpace,ScaleFilter,ExtendedDescCount,pExtendedDescs,Flags); the types and sizes are ours. The compose target follows the swapchain when it is recreated (resize, out-of-date acquire);xbox_present_testresizes the window between composed presents.Colour. Only
RGB_FULL_G22_NONE_P709(0, SDR, also the default for a zeroed struct) andRGB_FULL_G2084_NONE_P2020(12, HDR10) are composed; any other value is composed as SDR and logged once. The swapchain is UNORM. If a plane is HDR10 and the surface lists an ST.2084 format (VK_COLOR_SPACE_HDR10_ST2084_EXT,A2B10G10R10orA2R10G10B10; needsVK_EXT_swapchain_colorspaceenabled on the instance, the test device does) the swapchain is created in it and an HDR10 plane goes through the working space unchanged; else the swapchain is SDR (the logged fallback). The real runtime's instance (create_vulkan_device_standalone) enablesVK_EXT_swapchain_colorspacewhen the loader has it (it did not before; only the test device did), so the HDR10 surface formats can be listed there;xbox_present_testchecks this on the standalone path. Limited-range and YCbCr colour spaces are not modelled.Linear-light filtering and blending (decision from the sources below; the console's own blending space is unmeasured). Every texel of a plane is decoded to linear light before it is weighted, the filtered plane is converted to the output's working space, plane 1 is blended over plane 0 there, and the sum is encoded once:
- Decode. SDR planes: the SDR EOTF (below) gives linear Rec.709 with 1.0 = SDR white. HDR10 planes: PQ inverse to linear
nits (Rec.2020). For premultiplied UNORM, encoded RGB up to alpha is divided by alpha before decoding and multiplied
again afterwards. Encoded RGB above alpha is decoded as additive light, including all RGB when alpha is zero. Both
contributions are filtered separately so coverage cannot attenuate the additive light. Premultiplied
*_UNORM_SRGBplanes are already hardware-decoded to linear premultiplied light bytexelFetch(no encoded-space division by alpha). Straight-alpha colour is premultiplied after the decode, so a transparent texel adds no colour of its own (found in review by @Flyander). - Convert, still linear. HDR10 output: SDR to Rec.2020 (the Rec.709 to Rec.2020 matrix from the primaries; rows sum to 1) times the SDR white level in nits. SDR output: HDR10 to Rec.709 (the inverse matrix), divided by the SDR white level, then tone mapped (below). Tone mapping unpremultiplies only the covered light and maps the filtered additive light independently. A plane already in the output's space is not converted.
- Blend
over + (1 - alpha) * base(premultiplied; straight alpha was premultiplied in step 1); black outside plane 0. - Encode once: PQ of the nits for an HDR10 output (argument clamped to 0..10000 nits), the inverse SDR EOTF (clipped to 0..1) for an SDR one.
Why. Microsoft's Advanced Color documentation says DWM composes in linear scRGB (FP16, "excellent precision for linear gamma blend operations"), that an app which puts SDR and HDR content into one surface must apply the SDR boost itself, in linear space (multiply by SdrWhiteLevel / 80), and, for a non-linear space such as HDR10, to "consider converting into linear gamma to apply the adjustment"; it describes no blending in PQ, and a weighted sum of PQ values is not a sum of light. (Some compositors blend in a gamma space to avoid banding; KDE's KWin is reported to do so since Plasma 6.2, https://planet.kde.org/xavers-blog-2024-11-01-hdr-and-color-management-in-kwin-part-4-nonlinear-blending, unverified: only a search snippet of that post was seen. Our intermediate image is RGBA16F, so banding is not what limits us here.) Each plane costs a decode and an encode per texel; a single SDR plane still comes out byte for byte (
xbox_present_test: within the 8-bit rounding of the RGBA16F intermediate, and equal to the plain blit at 1:1). What changes against the first version of this section: bilinear filtering and alpha now weight light, not encoded values, so a 50% white overlay on black is byte 188 (piecewise sRGB) or 186 (gamma 2.2), not 128, and a bilinear edge between a dark and a bright texel is brighter than the same edge filtered in the encoded values. Whether the title's art expects the encoded-space result (UI is often authored that way on SDR consoles; inference) is unmeasured and is to be settled by a comparison with the title; the blend space is the one place that would then get a switch.SDR EOTF (selectable). Default: the piecewise sRGB curve (IEC 61966-2-1:
e / 12.92up to 0.04045, else((e + 0.055) / 1.055)^2.4). Option: a pure power of 2.2 (XboxPresentation::set_sdr_eotf, or the environment variableLEONIDA_SDR_EOTF=gamma22(or2.2, any case;srgbor unset is the default, other values are logged once and ignored) read when the object is made;PresentPlanes::sdr_eotfin the presenter). The inverse of the same curve encodes an SDR output, so SDR in an SDR output stays the identity. Why piecewise as the default: community-sourced, not a Microsoft statement. KDE developer Xaver Hugl reports that Windows decodes SDR content with the piecewise sRGB curve when HDR is on (raised darks, "washed out") while SDR displays use gamma 2.2 (https://planet.kde.org/xavers-blog-2025-03-31-on-brightness-and-calibrating-your-displays/), and the ledoge win11hdr-srgb-to-gamma2.2-icm project exists to make Windows use 2.2 instead (https://github.com/ledoge/win11hdr-srgb-to-gamma2.2-icm). What a PC player compares against is Windows, so that is the default; art mastered on a gamma 2.2 display looks closer to its intent with the option. The Xbox's own SDR-in-HDR decode is unmeasured. An sRGB-format source is encoded again with the sRGB curve first (the texture unit had decoded it), so its stored bytes are decoded by the chosen EOTF exactly as UNORM bytes would be.SDR white level (the nits that SDR white 1.0 maps to in an HDR10 output, and what HDR10 is divided by for an SDR one).
XboxPresentation::set_sdr_white_nits(n)with n > 0 overrides everything (n = 0 goes back to automatic). Otherwise, while the swapchain is HDR10, Windows' SDR content brightness for the output the window is on:DisplayConfigGetDeviceInfo(DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL)on the active display path whose GDI source name is the window's monitor,nits = SDRWhiteLevel / 1000 * 80(1000 is 80 nits, the scRGB 1.0; https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-displayconfig_sdr_white_level), read at most once a second by a background thread (the query is not run on the present path, see below);PresentXreads the cached value, and a failed query keeps the last good one. Otherwise (an SDR swapchain, or nothing read yet) 203 nits, the HDR reference white of ITU-R BT.2408 (graphics white, 58% PQ; https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2408-9-2026-TOC-HTM-E.htm; the W3C CSS Color HDR module uses 203 too, https://www.w3.org/TR/css-color-hdr-1; the report's text itself was not parsed here). Windows' setting is a PC desktop's; the console's is unknown, which is why the override exists. Why a thread: the query is aQueryDisplayConfig(with the documented retry onERROR_INSUFFICIENT_BUFFER) plus twoDisplayConfigGetDeviceInfocalls; measured byxbox_present_teston the author's machine (12 us mean, 70 us worst over 50 calls on the AMD run; 47 us mean, 361 us worst on the NVIDIA run; this laptop's display setup, HDR off). That is small here, but the call goes into the display driver stack and its worst case with several displays or during a mode change is not bounded by anything measured (inference), and a stall under the present lock would feedImmediateThresholdPercentlateness; so it is kept off the present path. What is measured about the value: the query returns 80.0 nits on the SDR desktop of both test GPUs' output, which is only the path where the layer ignores it (it uses 203 nits unless HDR10 is active); the HDR value itself has not been read on real HDR hardware here. 1000, 2500 and 6000 convert to 80, 200 and 480 (arithmetic only).HDR10 content on an SDR output: tone mapped, no longer clipped. After step 2, the luminance Y of the Rec.709 value (0.2126 R + 0.7152 G + 0.0722 B, 1.0 = SDR white) goes through a shoulder: identity up to a knee at 0.8 of SDR white (162 nits at 203), and above it extended Reinhard (Reinhard, Stark, Shirley, Ferwerda, "Photographic Tone Reproduction for Digital Images", SIGGRAPH 2002, eq. 4) applied to the excess: with
t = 1 - knee,u = (Y - knee) / t,w = (Lw - knee) / t,Yd = knee + t u (1 + u / w^2) / (1 + u), whereLw = peak / SDR whiteandpeakis the content's peak (default 1000 nits,set_hdr_peak_nits; no metadata is read, so this is an assumption). The colour is scaled by Yd / Y. This is continuous in value and slope at the knee (slope 1 there), monotonic, and mapsY = Lwto exactly 1.0; colours with Y below the knee (SDR-range content, up to 162 nits) are not touched. Above the knee it compresses: 203 nits (SDR white) comes out at 0.90 of white at peak 1000 (byte 243), 300 nits at 250. Per-channel values above 1 after the scaling (saturated highlights) are still clipped; there is no gamut mapping and no dither. Microsoft's Advanced Color document lists tone mapping choices, among them a scaled Reinhard (x / (1 + x)) and the BT.2390 EETF, as simple options (https://learn.microsoft.com/en-us/windows/win32/direct3darticles/high-dynamic-range). The BT.2390 EETF itself is not done (its constants were not checked against the Recommendation here).HDR metadata: not sent. The presenter never calls
vkSetHdrMetadataEXT. Microsoft's page forIDXGISwapChain4::SetHDRMetaData(https://learn.microsoft.com/en-us/windows/win32/api/dxgi1_5/nf-dxgi1_5-idxgiswapchain4-sethdrmetadata, fetched in the research) says calling it is not recommended, that Windows does not guarantee the metadata is sent to the monitor and that monitors handle it inconsistently, and that an app should tone map into the range ofIDXGIOutput6::GetDesc1instead. vkd3d-proton forwardsSetHDRMetaDatatovkSetHdrMetadataEXTonly for an explicitDXGI_HDR_METADATA_TYPE_HDR10block (libs/vkd3d/swapchain.c, https://github.com/HansKristian-Work/vkd3d-proton; partly read: the first ~100k of ~175k characters of the file, which include the HDR10 conversion and the setter), so a title that sets none gets none there either. We invent no mastering values (Vulkan treats unknownVkHdrMetadataEXTfields as 0). Forwarding a title's explicit HDR10 block is possible once aSetHDRMetaDataslot exists.Sources for the PQ chain: the constants are the exact rationals of SMPTE ST 2084 / ITU-R BT.2100 (m1 = 2610/16384, m2 = 2523/4096 x 128, c1 = 3424/4096, c2 = 2413/128, c3 = 2392/128; https://en.wikipedia.org/wiki/Perceptual_quantizer), 1.0 = 10,000 nits; the Rec.709 to Rec.2020 matrix is computed from the primaries (ITU-R BT.2087 specifies the same conversion; its PDF was not parsed). Microsoft's Advanced Color document: https://learn.microsoft.com/en-us/windows/win32/direct3darticles/high-dynamic-range.
Verified by
xbox_present_testagainst a CPU model written from the above (not from the shader; it decodes, converts, blends and encodes in double precision): point filtering between opaque SDR planes is byte exact; bilinear, alpha blending (premultiplied and straight, point and bilinear), the sRGB and gamma 2.2 EOTFs and the linear 50% overlay are within 1 level of 255; the HDR10 to SDR shoulder tone map (peaks 1000 and 600 nits; the expected bytes of an eight-step ramp and of an HDR10 plane 1 over an SDR plane 0 are hand calculations, as are the 50% overlay bytes 188 and 186) and the PQ encoder (an 8-bit swapchain forced to hold PQ values withforce_hdr_encoding, a test hook) are within 2 levels (GPUpow; the PQ codes of the source are 10-bit). The HDR10 swapchain itself (format choice, 10-bit capture, pass-through): verified on an RTX 5080 (driver 616.56, Windows 11) with an HDR10 surface by @JavierBlanco23 in #2069 (native ST.2084 swapchain within 1 code, GameDVR plane drop, tearing); not verified on AMD: the author's Radeon 880M and RTX 5070 Laptop (desktop without HDR enabled) list no ST.2084 surface, where the test logs that case as skipped and checks the 10-bit codes only where the surface has the format. - Decode. SDR planes: the SDR EOTF (below) gives linear Rec.709 with 1.0 = SDR white. HDR10 planes: PQ inverse to linear
nits (Rec.2020). For premultiplied UNORM, encoded RGB up to alpha is divided by alpha before decoding and multiplied
again afterwards. Encoded RGB above alpha is decoded as additive light, including all RGB when alpha is zero. Both
contributions are filtered separately so coverage cannot attenuate the additive light. Premultiplied
-
ImmediateThresholdPercent(hypothesis from the FramePacing text, item 7 above; not measured on the console): a frame is due at the vblank after the origin that handed out its token. One that is presented later than that is late, and when the scan would not be further down the screen than the threshold percentage (late time modulo the interval, as a fraction of the interval) it is flipped at once, mid-scan, instead of waiting a whole interval. 0, negative and NaN never tear; 100 or more tears wherever the scan is; a frame on time never does. The decision is the pureleonida::decide_present_sync(late_us, interval_us, threshold)inframe_pacer.h. A frame behind one that still waits for its vblank is not torn (it would overtake it), and neither is an unpaced present. The tear is shown inGetFrameStatisticsX(the display entry'sPercentScannedis set and its time is the present time) and inXboxPresentation::immediate_presents(). In Vulkan: withVK_KHR_swapchain_maintenance1(else the EXT original; the structures are the same and the tests' GPUs list both; the instance getsVK_KHR_get_surface_capabilities2and the matching*_surface_maintenance1) a vsync swapchain is created withVkSwapchainPresentModesCreateInfoKHRlisting FIFO plus IMMEDIATE (FIFO_RELAXED when the surface does not list IMMEDIATE as compatible with FIFO, checked withVkSurfacePresentModeCompatibilityKHR), and a present that tears chainsVkSwapchainPresentModeInfoKHRwith that mode. The extension and its feature are enabled only where the GPU has them. Without them, or without either mode, the threshold is ignored and logged once, and a late frame waits for its vblank as before.LEONIDA_PRESENT_NO_TEAR=1turns it off. Caveats: FIFO_RELAXED tears only when the queue is empty and a vblank was missed (close to the semantics, but the driver decides), and the lateness is measured on the pacer's clock (a timer, not the display's real scan), so on a real display the tear position is whatever the driver does at that moment. What is checked is that the immediate mode is chosen and presented with 0 VUIDs in our runs withLEONIDA_VK_VALIDATION=1; no scan-out or tearing was observed. -
Tokens: what the console does with a null, repeated or out-of-order token is unmeasured, and a title that presents a loading screen with
Token = 0, presents again with one token, or presents from a render thread out of order must not freeze. So those are presented anyway and logged once per kind; only a token that was never handed out givesE_INVALIDARG(nothing presented). Skipping a token is fine. -
Frame capture (
LEONIDA_CAPTURE=<dir>,LEONIDA_CAPTURE_EVERY=<n>,LEONIDA_CAPTURE_LIMIT=<n>): writes every n-th presented frame (default 30, at most 24) to<dir>/frame_NNNNN.ppm, a binary P6 of the swapchain image converted to 8-bit RGB, and appends one line per frame to<dir>/index.txtwith the extent and the mean RGB. Off unless the variable is set, and the folder is created. Disk-only sampling copies frames 1, 1+n, 1+2n, … to host staging until the file limit is reached; intervening frames still present normally. This avoids a full-image transfer on every present when only occasional samples were requested. An explicit continuous readback request and the temporary splash inspection still copy each frame they need. This lets a check inspect what the layer actually presented: the window is not readable in every setup (under Wine it is not even mapped), and the mean is enough to tell a real frame from a black one.d3d12_present_testturns it on and checks the files against the colour it clears to. -
SuspendX/ResumeX: suspend drops the interval, the origin event and the frames in flight, wakes blocked waits withERROR_INVALID_STATEand refuses presents (aPresentXwaiting for a swapchain image polls the suspended state every 50 ms and gives up, soSuspendXnever waits on it); resume allows presents again, but waits fail untilSetFrameIntervalXandScheduleFrameEventXare called again, as the samples do. Tokens keep counting. CallingSetFrameIntervalXagain outside suspend keeps the origin event armed and re-bases the vblank grid on that moment. -
Not done: the BT.2390 tone map and gamut mapping for HDR10 on an SDR swapchain (a Reinhard shoulder only), scRGB, limited-range and YCbCr colour spaces,
ResourceCountabove 1 (refused withDXGI_ERROR_UNSUPPORTEDbefore either path, logged once, since only resource 0 would be read; found in review by @Flyander), extended descriptors (pExtendedDescs) andViewCount, capturing a second (GameDVR) output, resolving multisampled planes, a mutable-format swapchain (an sRGB/UNORM alternation recreates the swapchain;VK_KHR_swapchain_mutable_formatis not enabled on the device), a host-vblank clock (the timer drifts from the display; with FIFO presents the swapchain holds the queue to the real refresh anyway), render statistics,PercentScannedof frames shown at a vblank (a scan position is never measured), and the vtable wiring. Slots to measure (all unknown): the device'sSetFrameIntervalX,ScheduleFrameEventX,WaitFrameEventX,GetFrameStatisticsXand the queue'sPresentX,SuspendX,ResumeX(the list is in the header). -
Tests:
frame_pacer_test(fake clock: interval, offset, late waits, timeouts, latency blocking, tokens, statistics, suspend/resume, a real 10 ms timer; no GPU) andxbox_present_test(the Vulkan device, reading the swapchain image back: blank, solid, two colours, source rectangles, RGBA/BGRA/sRGB sources, 2 planes, plane composition (placement, point/bilinear, alpha overlay, HDR10 and PQ conversions, refusals; against a CPU model), token errors, statistics, suspend/resume,ImmediateThresholdPercentwith a late frame at several thresholds (immediate mode chosen, or not for 0, below the lateness, on time) and withLEONIDA_PRESENT_NO_TEAR=1, 30 frames at 60 Hz in real time; skipped, exit 77, without a Vulkan device).frame_pacer_testalso sweepsdecide_present_sync, and checks that 1000 presents between two waits leave at mostlatencyframes in flight (latency 1, 2 and 3).
4.6 Queries
Implemented (QueryHeap in runtime/shims/d3d12_vulkan_device.cpp, the query commands in command_list.h and
vulkan_replay.h), checked on one GPU by d3d12_vulkan_device_test under the validation layer:
- Heaps. One
VkQueryPoolperID3D12QueryHeap, registered with theVulkanContextby its pointer, as resources are.OCCLUSIONheaps areVK_QUERY_TYPE_OCCLUSIONpools and hold bothOCCLUSIONandBINARY_OCCLUSIONqueries, as in D3D12.TIMESTAMPandCOPY_QUEUE_TIMESTAMPheaps areVK_QUERY_TYPE_TIMESTAMPpools.OPTIONS3.CopyQueueTimestampQueriesSupportedand copy timestamp heap creation agree: both require timestamp bits and graphics or compute support in every family a copy queue can use (its dedicated family, if configured, and the graphics fallback). Transfer-only families can write timestamps on some devices but cannot reset or resolve their queries. Query commands andGetTimestampFrequencyalso check the queue's actual family.PIPELINE_STATISTICSheaps count all eleven Vulkan statistics (0x7ff), whose result order is the field order ofD3D12_QUERY_DATA_PIPELINE_STATISTICS(IA vertices, IA primitives, VS, GS invocations, GS primitives, clipper invocations and primitives, PS, HS, DS, CS), so one 88-byte result per query is copied as is. They needpipelineStatisticsQuery.VIDEO_DECODE_STATISTICSandPIPELINE_STATISTICS1(mesh and amplification counts) are logged and refused withE_NOTIMPL. Invalid descriptions are answered as the host runtime answers them (compare_invalid_arguments, "query heap:", RTX 5070 / 621.14):E_INVALIDARGfor no queries, a node other than node 0, or a type pastPIPELINE_STATISTICS1(7), checked before the output; a valid description with a null output is thenE_UNEXPECTED, notS_FALSE. - Stream-output statistics (D3D-302). The layer still refuses
StreamOutputPSOs and does not implementSOSetTargets, so no primitive reaches a stream yet. WithVK_EXT_transform_feedbackenabled on the device (D3D-TRANSFORM-FEEDBACK-DEVICE) and itstransformFeedbackQueriesproperty set, anSO_STATISTICSheap is a realVK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXTpool begun and ended indexed on the stream (vkCmdBeginQueryIndexedEXT/vkCmdEndQueryIndexedEXT), andResolveQueryDatacopies the two 64-bit results per query (16 bytes:NumPrimitivesWritten,PrimitivesStorageNeeded), in the same order; with no stream output they are 0. A stream at or above the device'smaxTransformFeedbackStreamsruns nothing and resolves zero, as if the heap had no pool. Without the feature, the property, or a nonzeromaxTransformFeedbackStreams, the heap is made without aVkQueryPool:BeginQuery/EndQueryrun nothing in Vulkan (D3D12's call rules are still kept, and the heap's queries track ended or not as the others do), they overlap no other query, andResolveQueryDatawrites zeros (vkCmdFillBuffer, 16 bytes per query), with no statistics split since nothing is dispatched. Two overlappingSO_STATISTICSqueries on one stream would be two active indexed queries in one pool (VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753), soprepare()refuses such a list (ReplayResult::invalid_query); queries on different streams are fine. - Recording. The list keeps D3D12's rules for the calls: timestamps only have
EndQuery; every other query is begun and ended in the same list with the same type, is not begun again while it runs, and is not resolved while it runs; resolve offsets are multiples of 8. A list closed with a query still running reportsE_INVALIDARGand is refused at execution. Heap types, index ranges and the destination buffer are checked atExecuteCommandLists, when the heap and buffer are known (ReplayResult::invalid_query). - Replay. D3D12 queries need no reset; a Vulkan query does. Each
BeginQueryand each timestampEndQueryis preceded byvkCmdResetQueryPoolof that one query. Nothing in the layer runs inside a render pass yet, so the reset is legal where it stands; a draw path that opens a render pass around queries must reset them before it.OCCLUSIONbegins withVK_QUERY_CONTROL_PRECISE_BITwhenocclusionQueryPreciseis enabled. A timestamp isvkCmdWriteTimestampatBOTTOM_OF_PIPE(every earlier command finished).ResolveQueryDataisvkCmdCopyQueryPoolResultswithVK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT. A query keeps its result across executions until it is begun or written again, as in D3D12. - Binary occlusion. The queue resolves to a scratch buffer in chunks, reduces each 64-bit value to 0 or 1
with a compute dispatch, and copies it into the destination. This works with readback buffers, which need
only transfer-destination usage. The helper runs outside conditional rendering so a predicate cannot suppress
the resolve.
vk_binary_occlusionchecks more than one scratch chunk, gaps, suballocated destinations, consecutive submissions and an ordinary occlusion count on a real Vulkan device. - Queries never ended. D3D12 leaves their result undefined; a Vulkan copy with
WAIT_BITwould wait for them forever. Each heap records on the host which queries were ended, in submission order, and a resolve writes zeros (vkCmdFillBuffer) for the ones that were not. - Overlapping occlusion queries and statistics (D3D-252). On a graphics queue with compute, the replay opens
a new physical query whenever the set of active queries changes. Ordinary and binary occlusion share the one
physical pool (both are
VK_QUERY_TYPE_OCCLUSION, so one physical query is open at a time, and the shared intersection interval is counted by both logical queries); pipeline-statistics queries split the same way into the statistics pool, where every non-timestamp resolve and every helper dispatch while a query runs also closes and reopens the open segment (D3D-162), for every query open at that point. Each logical query keeps a contiguous range in the submission's pool. Resolving it sums the results on the GPU, then copies them to the destination; a binary resolve normalizes the summed counts to 0 or 1 (sum_binary_occlusion, the sum followed by the existing normalize). Both occlusion compute helpers reuse one scratch buffer per queue. Logical results and in-flight submissions retain the pools independently, so later resolves and overwrites can be recorded before the earlier commands complete.vk_overlapping_occlusionchecks crossing and nested scopes, more than one scratch chunk, alternating binary and ordinary resolves under a predicate, gated submissions, crossing statistics queries against three unsplit references word by word, and an ordinary query around a binary one, on a GPU;replay_query_predicationpins the segment layouts, the helper dispatches inside an overlap and the binary sum-and-normalize without a GPU. On a device withoutpipelineStatisticsQuery(MoltenVK) the test leaves the statistics lists out;vk_overlapping_occlusion_no_statisticsruns it that way (--no-statistics) on a device that has the feature, so that path is also run where no such device is at hand. - Helper dispatches during a pipeline-statistics query (D3D-162). The helper dispatches above (binary
normalisation, occlusion sums), statistics sums,
SetPredicationcaptures, predicated buffer copies and D24/RGB96 footprint conversions would count in the application'sCSInvocationsif they ran inside its query. Such a query is split. Its counters go to physicalPIPELINE_STATISTICSsegments in a pool of the submission's own; a segment ends before each helper and a new one begins after it. Non-query helpers and resolves share the segment numbering. Its result is the sum of its segments, added per counter by a compute dispatch (statistics_sum.comp) on the same scratch buffer, which is itself kept out of any statistics query still running. Whether a resolve dispatches is only known once the list is planned against the heaps, so every such resolve splits the query.vk_binary_occlusionchecks that a binary resolve and a statistics sum inside statistics queries leave every counter at 0.vk_overlapping_occlusionputs a native draw in each segment and checks the split sums against unsplit queries with the same draws, word by word.vk_predicated_copychecks captures, rebindings and predicated copies;depth24_convertchecks both conversion directions for D24 and RGB96. Their byte-exact results still match and all 11 statistics counters are zero. Without a statistics pool (single-listreplay()or a queue without the summation helper), these three commands are refused before helper scratch allocation or recording. The resolve fallback is unchanged: only resolves needing dispatches are refused there. - Mesh draws during a pipeline-statistics query (D3D-291). D3D12 allows
DispatchMeshinside a statistics query and reads its input-assembly, vertex, geometry and tessellation fields as 0. Vulkan forbidsvkCmdDrawMeshTasksEXTwhile a query with the input-assembly, vertex, geometry, tessellation or clipping counters is active (VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076), and the heap's pool has all eleven. So a statistics query that holds a mesh draw is split as above, and a split before a draw stays outside its rendering scope. A segment's first draw decides its pool: the submission's full pool, or a second pool with only the fragment and compute invocations, the two the VUID leaves allowed. A later draw of the other kind ends the segment and begins one of its own kind; dispatches and segments without draws use the full pool, andExecuteIndirectdraws count as vertex draws. The sum copies a mesh segment's two counters into fields 7 and 8 of its record, andstatistics_sum.compadds them asPSInvocationsandCSInvocations, so the other fields get nothing from it. D3D12 counts the clipping invocations and primitives of a mesh pipeline, but Vulkan has no counter for them during a mesh draw, soCInvocationsandCPrimitivesread 0 for a mesh segment. A query that holds only mesh draws is one mesh segment, resolved through the same sum. Without the compute helper there is no segment pool and such a list is refused (unsupported) rather than run unsplit; so is one on the single-listreplay()(D3D-399), whosecreate_segment_poolgives no mesh pool. Overlapping statistics queries (D3D-252) split the same way inside their shared segments: a draw of the other kind than the open segment's opens a new one, so every query that segment belongs to sums both kinds.replay_query_predication_test(cases 15 to 17) checks the split points, the segment kinds, the resolve plan and the counters the mesh pool may enable on the CPU.d3d12_mesh_testresolves a query around a vertex, two mesh and a vertex draw, one around a mesh draw and one around the two vertex draws: the vertex fields count only the two triangles, the mixed query has the same clipping count as the vertex-only one and more pixel-shader invocations, and the mesh-only query has no clipping count without the mesh-primitives query below. - The clipping invocations of a mesh segment (D3D-MESH-CLIPPING-COUNTER). D3D-291 leaves
CInvocationsandCPrimitivesof a mesh segment at 0, because Vulkan has no clipping counter during a mesh draw. Where the device has themeshShaderQueriesfeature ofVK_EXT_mesh_shader, the number of primitives the mesh shader emitted comes from aVK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXTquery instead: a third pool of the submission, begun and ended with each mesh segment, next to the two the statistics split needs. Its count is copied to field 5 of the segment's record andstatistics_sum.compadds it asCInvocations;CPrimitivesstays 0, because Vulkan has no clipped-primitive counter and D3D12'sCPrimitivesis the clipper's output (0 when a triangle is dropped, 2 when it is split). The count is not D3D12's number: Vulkan counts a primitive the mesh shader culled withgl_CullPrimitiveEXT, which D3D12 does not count, so a mesh segment'sCInvocationscan be higher than D3D12's. Without the feature the field reads 0, as in D3D-291. - Timestamps.
GetTimestampFrequencyis1e9 / timestampPeriod(1 GHz on the test GPU). Every D3D12 queue shares oneVkQueuefor now (question 12), so they share one frequency. - Timestamp resolves on MoltenVK. On Apple GPUs, MoltenVK delays every
vkCmdWriteTimestampto the end of the current Metal encoder, where it is sampled by a blit pass of its own (encodeTimestampStageCounterSamples, because Apple GPUs sample only at stage boundaries).vkCmdCopyQueryPoolResultsresolves the counters with a blit that nothing orders after that pass. The copy then reads the previous value, or 0 for a timestamp never written before. This happens when the copy is in the timestamp's open blit encoder, in a later encoder, in a later command buffer or in the nextvkQueueSubmit. The spec needs no barrier here:WAIT_BITwaits for the query.vkGetQueryPoolResultson the host is right. A minimal Vulkan program (two timestamps around avkCmdCopyBuffer, resolved with64_BIT | WAIT_BIT, compared withvkGetQueryPoolResults, 200 runs per case on an M3 Max, macOS 27.3) got the right values 0 to 13 times out of 200 for each of these placements with MoltenVK 1.4.3 (main5189f8de). With a pipeline barrier or a fill before the copy it was 9 and 3 out of 200. MoltenVK 1.4.2 got 0 to 43 out of 200, measured while other GPU work ran. Every case was right 200/200 on KosmicKrisp (Mesa 26.3.1) and llvmpipe. Two things order the copy on MoltenVK, right in every run (200 or 500 runs, both versions). One isvkCmdSetEvent+vkCmdWaitEventson a fresh event before the copy, which MoltenVK encodes as a Metal event signal and wait on the command buffer. The other, across submissions, is a timeline semaphore wait for the earlier submission. So wheredriverIDisVK_DRIVER_ID_MOLTENVK(Wine reports the host's driver), the queue sets and waits for an event before each timestamp resolve that copies, and a submission with such a resolve waits on the queue's own timeline for the submission before it. The values are still the GPU's own timestamps, nothing is emulated. MoltenVK picks at submit time, from the event's host state, whether a set or wait does anything. So each resolve gets an event of its own, which goes back to the queue's pool after a hostvkResetEventonce the submission completes.d3d12_vulkan_devicechecks the same list (timestamp, clear, copy, timestamp, resolve) and a resolve in the next execution with no wait between them. Under Wine (CrossOver 26.3, MoltenVK 1.4.3) the first case failed every run before this change (t1read 0).
The single-list replay() helper replays overlapping occlusion kinds and statistics queries too (D3D-399) when
the caller passes a keep vector and sets ReplayFunctions::create_segment_pool with the four sum helpers: it
makes one occlusion and one pipeline-statistics segment pool sized to the list, plans them as the batched path does,
and hands them to keep, which the caller holds until the command buffer has completed. Without them such a list is
still refused with ReplayResult::unsupported. replay_query_predication_test case 14 checks both, on case 13's
statistics list and case 10's occlusion pair (no GPU).
Not implemented yet:
- Mesh-shader statistics (
PIPELINE_STATISTICS1, D3D-132), and stream-output statistics that count real primitives (they wait for stream output itself). (GetClockCalibrationis implemented: see section 4.4, "Fences, queues and frames in flight".) - Xbox-specific query heap types (if any) are Open; unknown types are logged.
4.7 Indirect commands and command signatures
-
D3D12_COMMAND_SIGNATURE_DESCdescribes the argument stride and a list of argument types. Simple draw, draw-indexed, dispatch and mesh-dispatch signatures map tovkCmdDraw*Indirect,vkCmdDispatchIndirectandvkCmdDrawMeshTasksIndirectEXT; use the*Countvariants (VK_KHR_draw_indirect_count, core 1.2) when theExecuteIndirectcall supplies a count buffer. -
Signatures that change root constants, vertex/index buffers or descriptors per argument cannot be expressed by one Vulkan indirect call. Use a compute expansion pass that writes a Vulkan-shaped indirect buffer, or
VK_NV_device_generated_commandson NVIDIA. Start with the simple signatures; the trace will show which signatures the game creates. -
The indirect arguments are clamped on the GPU before the command reads them (D3D-17's replay,
runtime/src/vulkan_indirect_clamp.h, shaderruntime/src/indirect_clamp.comp). The title's own compute writes them, and a pass the replay drops (an async pipeline that is not built yet, a stub pipeline,LEONIDA_SKIP_COMPUTE) or mistranslates leaves whatever the memory held: a dispatch of billions of groups or a draw of four billion vertices runs until the host resets the display driver. One small compute pass perExecuteIndirectcall copies the active records into device-local scratch with their values bounded - 2^24 vertices or indices, 2^26 vertex instances (count times instances), the device'smaxComputeWorkGroupCountgroups per dimension for a dispatch (65 535 for a mesh dispatch), 2^20 groups per dispatch and a 2^27-unit work budget per call that saturates through an atomic compare-and-swap - and writes an empty record pastmin(count, max_command_count)and past the budget, and the clamped count word a*Countdraw then reads (so the count is at mostmaxDrawCount, VUID-vkCmdDrawIndirectCount-countBuffer-02717). A draw record of 2^23 vertices or indices an instance or more is a slot the title has not filled: it runs empty and charges nothing (RT-INDIRECT-DRAW-UNFILLED-COUNT). Before, each was cut to 2^24 and charged that, so eight of them used up the budget and every later draw in the list ran empty; a census in a VIctory fork found 90 such records in one list. A dispatch record's groups per dimension follow the device (#2230): the title's tile passes ask for 67 440 groups in x at 2560x1440 (found in the VIctory-Belobug-AMD fork of VIctory,crates/victory-gpu/src/indirect.rs), RADV runs 2^32 - 1 in x in one dispatch, and the cut at 65 535 dropped the last 1 905 tiles of the pass. A device that allows less (llvmpipe: 65 535) still gets the record cut at its limit: running the rest would take more dispatches with a group-ID base the translated shader does not read. The counters'indirect clamp dispatch:line (every 10 s while dispatch records are clamped) gives the records, those wider than 65 535 in x, the widest x that ran and those cut at the device's limits, so a run shows which case it is. The indirect command reads that scratch. A draw emits the pass before its rendering scope opens:vkCmdCopyBufferand a memory barrier with a transfer access are not allowed inside a dynamic-rendering scope. The records are bit-identical to the application's when they are within the limits, the argument and count buffers are left untouched, and the scratch comes from a per-submission pool (vulkan_scratch.h) that a list with many indirect calls reuses.LEONIDA_INDIRECT_CLAMP=0reads the application's buffer again, as before. The pass's counters (records checked, records clamped, counts clamped, records past the budget) are copied to one host-visible slot per call, read once the submission completes, logged in full at the first use and then rate-limited. Covered byindirect_clamp_test(every kind and the counted variants, in-range and garbage records, the budget), byd3d12_m4_compute_test(a garbage dispatch record beside the in-range one) and byd3d12_indirect_rt_test(a draw whose instance count is garbage). -
Predication (
SetPredication) maps toVK_EXT_conditional_rendering(D3D-18). Done:GraphicsCommandList:: SetPredicationrecords aPredicationcommand (runtime/src/command_list.h; offset 8-byte aligned, opEQUAL_ZEROorNOT_EQUAL_ZERO, a null buffer turns it off). The replay (runtime/src/vulkan_replay.h) begins conditional rendering on the captured condition, plain forEQUAL_ZERO(Vulkan discards when the word is 0) andVK_CONDITIONAL_RENDERING_INVERTED_BIT_EXTforNOT_EQUAL_ZERO, ends it before a new predicate (it cannot nest) and at the end of the list (predication does not carry over to the next list). While a predicate is set, whole-view clears are replayed as one rectangle withvkCmdClearAttachments, becausevkCmdClearColorImageandvkCmdClearDepthStencilImageignore conditional rendering. The standalone device enables the extension and itsconditionalRenderingfeature when the GPU has them, and then creates buffers withVK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT; without it a predicated list is rejected (unsupported).D3D12_RESOURCE_STATE_PREDICATIONis the same bit asINDIRECT_ARGUMENT(andSYNC_PREDICATION/ACCESS_PREDICATIONthe same asEXECUTE_INDIRECT/INDIRECT_ARGUMENT), so with the extension enabled barriers into and out of that state also coverVK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXTatVK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT, where the predicate is read: without it aResolveQueryDatainto the predicate had no dependency on the read (vulkan_access,vulkan_barrier_scope). Checked by part E ofvk_command_replay_teston an NVIDIA GeForce RTX 3070, and end to end byd3d12_vulkan_device_test(an occlusion query resolved into a predicate, through legacy and enhanced barriers) on an NVIDIA GeForce RTX 5070. The 64-bit value is captured on the GPU at eachSetPredication: an internal eight-byte copy and a one-invocation compute pass OR the two dwords into a private 32-bit condition. Later writes to the source do not change that snapshot. A null buffer disables predication; rebinding ends the previous conditional scope before the capture, so the internal dispatch is never predicated. Bounds checks require all eight bytes. Capture arenas and descriptors remain alive until their command buffer's timeline ticket completes. No CPU readback or per-predicate wait is used. This helper requires a compute-capable configured queue family; unsupported queues fail preparation instead of falling back to the low word. The synthetic GLSL source and embedded SPIR-V are shipped together; normal builds do not need a shader compiler. Capturing a new predicate inside an active pipeline-statistics query splits the query around the capture dispatch (D3D-162, section 4.6), keeping its invocation out of the application's result. Without a statistics segment pool, preparation still refuses the capture before allocating its scratch. Integration notes for #291 and D3D-27: the capture helper binds its own compute pipeline, descriptor set 0 and push constants. The compute path must restore those bindings afterward, or bind its application state before each dispatch. Copies and compute dispatches cannot execute inside dynamic rendering, so render-pass integration must place the capture outside the rendering scope while preserving capture atSetPredication. These are requirements for those future integrations, not compute-dispatch or render-pass support added here.CopyBufferRegionunder a predicate instead uses a byte-granular compute dispatch inside the captured conditional scope; both operations, unaligned offsets and lengths, and the full 64-bit predicate are covered. Zero-byte copies are no-ops, as checked against native WARP. Unpredicated copies retainvkCmdCopyBuffer. The compute helper requires enabled Vulkan 1.2storageBuffer8BitAccess(notshaderInt8) and a compute queue; without it, preparation rejects the predicated buffer copy rather than executing it unconditionally. Descriptor windows respect storage-buffer alignment/range and dispatch limits, including arena offsets. Copy descriptors are owned by command-buffer slots until the submission timeline completes. Memory dependencies order prior writes, subsequent reads and successive windows. Direct and compute queues support the helper; copy queues reject active predication. Preparation is serialized under the tracker lock, preserving resource -> tracker -> submit lock order and the copy-then-commit tracker. Readback writes accumulate COMPUTE_SHADER for the helper and COPY for ordinary copies; mixed lists accumulate both before main's queue-specific host-stage filtering. This helper also binds compute pipeline/set 0/push constants, so the application-state restoration requirement above applies. A predicated copy inside an active pipeline-statistics query splits that query around the helper dispatches (D3D-162); without a statistics segment pool it is refused before copy scratch allocation. Synthetic checks:predicated_copy_testcovers preparation and rejection paths without a GPU;d3d12_predicated_copy_testcompares 180 byte-exact cases against WARP and an independent literal oracle, plus 16 query-to-copy cases: real empty ordinary/binary occlusion queries resolve zero into a default-heap predicate at offsets 0/16, both predicate operations govern copies, and executing overwrite copies replace zero with a high-word-only value. Four paired controls verify that recapturing the same address changes exactly one 13-byte destination region; without recapture, later copies keep using the captured zero. Predicate-buffer guards and all untouched destination bytes are checked too. These query cases do not cover nonzero visible-draw counts;vk_predicated_copy_testforces small windows and dispatches, arena prefixes, dependent copies, offset rebinding, reset, 32 gated plus 32 reused submissions, failed-submit cleanup and host stages on all three queue kinds. Binary and overlapping occlusion fixtures also verify that query results resolve under a false predicate while a dedicated copy destination remains unchanged; disabling predication copies into a separate region. The embedded shader is generated frompredicated_copy.compwith glslang 16.6.0 (-V --target-env vulkan1.2 -Os) and validated for Vulkan 1.2.Open:
-
Texture copies,
CopyResourceand resolves. Vulkan's conditional rendering does not cover transfer commands, so these still run unconditionally andPreparedList::unpredicated_copiescounts them. -
Draws, dispatches and
ExecuteIndirectare covered by conditional rendering as soon as they are replayed (D3D-3, D3D-4, D3D-17);ClearUnorderedAccessView*andResolveSubresourceneed the same check when added.
-
4.8 Ray tracing and XDXR
This is the largest Xbox-specific area, and the shipped XboxBvhBuilder.dll gives concrete evidence. The DLL's
own names use the XDXR prefix for Xbox's raytracing path:
- Its constructor takes
ID3D12Device11*; its build/copy/rehydrate methods takeID3D12GraphicsCommandList4/6/8*. - Prior art measured its constructor creating 53 compute pipelines through device slot 62, called with the
compute-PSO shape (a plain
D3D12_COMPUTE_PIPELINE_STATE_DESC, two zero words, iid, out); on the PC interface used there slot 62 isCreateStateObject(a different arity), so the proxy overrides it. The layer must implement slot 62 as compute-PSO creation, not as a state object. - It exposes standard
D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESCbuilds, batched Xbox builds (D3D12XBOX_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_BATCHED_DESC2), XDXR stream descriptions (D3D12XBOX_XDXR_STREAM_DESC), post-build offline statistics, and aDEHYDRATEbuild flag. The Xbox types are not public. Measured from the DLL's own reads (xdxr.md,runtime/src/xdxr_descs.h):BATCHED_DESC2is the public build desc, the postbuild count and pointer, and a 16-byteXDXR_STREAM_DESC(0x50bytes); the stream desc is a size and a pointer to 16-byte typed records. The DLL rejects the offline-statistics postbuild type (0x10) for every build, so that layout is not in the package. - The translator's
image_bvh_intersect_ray/image_bvh64_intersect_rayalready emulate the AMD hardware BVH node format: node id = address >> 3 | type, box16/box32/triangle nodes, 256-byte base units. That is the format the runtime must produce for the game's compute traversal.
The builder's own shaders are console FSSM, not Xbox DXIL. Each of the 52 containers carries an LLVM
bitcode blob and an XDAT/XBCH record; the PC experiment below compiled the bitcode, but the console runtime
executes the XBCH record. Measured from that record: 52/52 unpack to FSSM, and all 52 translate and pass
spirv-val with the same translator the game's 26,503 shaders use; the last one, Box16Rehydration, since
buffer_store_short landed (8f208d09a; embedded_shaders.md). The
raw 64-bit addresses are the corpus's existing raw-address path, not a separate lowering. Open: whether the game
uses the builder at all (RT-5) and whether the translated programs match a reference on a GPU.
The design choice follows from that: build AMD-format BVH data, not a VkAccelerationStructureKHR, unless the
shaders are changed to OpTraceRayKHR. The game's 64 RT compute shaders traverse the nodes themselves; a
Vulkan AS would be invisible to them. Two paths:
- If
XboxBvhBuilderdoes the build with its own compute dispatches (the likely case, given it ships as a DLL with a device and command lists), the layer must translate and run its compute shaders. The console programs areFSSMand all 52 passspirv-val. Buffers, UAVs, descriptors, barriers and indirect dispatch are necessary but not sufficient. The standardBuildRaytracingAccelerationStructurecalls may never reach our command list. - If the game calls
ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure, the layer must implement it. Produce the AMD node layout in the arena, with the same geometry/instance rules the translator assumes, and makeGetRaytracingAccelerationStructurePrebuildInforeturn sizes for that layout. The layout is the XDXR BVH4 runtime form (bvh.md §3.1).tools/xdxr_bvh.pyencodes it on the CPU, with a reference traversal and a validator (bvh.md §7a).runtime/src/xdxr_build.hbuilds it on the GPU and is checked against that reference. The standalone device uses it forBuildRaytracingAccelerationStructureand answersGetRaytracingAccelerationStructurePrebuildInfofrom its layout, exactly. Acceleration-structure buffers then keep their console VAs, the addresses the records name each other by.LEONIDA_RT_AS=khrkeeps #743'sVkAccelerationStructureKHRbuilds (forRayQueryKHR), which the game's shaders can't read. Updates refit the source structure instead of rebuilding it,CopyRaytracingAccelerationStructureclones and compacts, and the postbuild compacted and current sizes are written (bvh.md §7a). A bottom-level build withMINIMIZE_MEMORYgets BOX16 nodes (half boxes, about a fifth smaller; top-level builds stay BOX32), and one withoutALLOW_UPDATEpairs sibling triangles that share an edge into TRI0/TRI1 leaves. Serialization and the Xbox #743'sVkAccelerationStructureKHRbuilds (forRayQueryKHR), which the game's shaders can't read. A top-level build withD3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERSis supported there: the console VAs in the pointer list are translated to Vulkan device addresses in a staged copy, without changing the guest's input. The list must be in CPU-writable memory (an UPLOAD or write-back CUSTOM heap; WRITE_COMBINE CUSTOM is CPU-writable too); GPU-written DEFAULT and READBACK lists are refused asunsupportedbefore submission, since their mapped bytes can still hold an earlier frame's pointers when the CPU prepares the build. Completed staging buffers are reused, so a per-frame rebuild does not allocate memory each frame. Updates refit the source structure instead of rebuilding it,CopyRaytracingAccelerationStructureclones and compacts, and the postbuild compacted and current sizes are written (bvh.md §7a). Serialization and the Xbox batched/streaming builds are not implemented. The reportedRaytracingTieris unchanged (NOT_SUPPORTED). Checked byruntime/test/d3d12_xdxr_rt_test.cppthrough the D3D12 API.
Open: which path the game uses. Resolve by logging the first call to the standard AS methods and by tracing the builder's command-list usage. If XDXR batched/streaming builds are used, their structs and compression formats need to be recovered from call sites (or the NDA GDK headers, if a developer has access); they cannot be guessed.
4.9 Xbox-specific surface
| Feature | Public evidence | Design |
|---|---|---|
| No ESRAM | Xbox Series X|S uses unified GDDR6; ESRAM was Xbox One | Do not implement ESRAM-era APIs. The d3d12_xs.cpp comment about "ESRAM-era extensions" should be read as Xbox One, not Series. |
| Binning | The GDK topic index names Xbox binning modes (NDA content) | Should be a no-op if the game uses it only as an optimisation: it changes how a render pass uses on-chip memory, not the result. Log and ignore for the first boot; revisit for performance. Open whether the game relies on binning for correctness. |
| DCC / texture compatibility | Public release note for D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY |
Let Vulkan choose compression; fail if the game aliases/reads raw compressed data. |
| PresentX / present planes / frame events | Public GDK samples (MIT/zlib), §4.5; the device calls are measured (§7.1) | Likely the only present path of a GDKX title. Presenter + vblank-timed frame events; 1-2 planes composed into the Vulkan swapchain (placement, filter, alpha overlay, HDR10 conversions). Call shapes known; the four frame-call slots are Measured called, on one device pointer; plane/parameter layouts Open. |
| Device slots 48/73/78/79/80 | Public HLE Freminet/ScarlettX (third-party, not Microsoft documentation); 78-80 Measured in the executable at the documented arities (§7.1) |
d3d12_xs_device.cpp routes CreateCommandQueueX (48), CreateCommandListX (73), SetFrameIntervalX (78), ScheduleFrameEventX (79) and WaitFrameEventX (80) before it indexes the PC vtable. Queue and list creation use the existing create paths. The frame-event calls are a per-device token counter: WaitFrameEventX returns at once with a fresh non-zero token, because there is no vblank source before a presenter exists. The five indices can be moved with LEONIDA_XS_QUEUE_X_SLOT, LEONIDA_XS_LIST_X_SLOT, LEONIDA_XS_FRAME_INTERVAL_SLOT, LEONIDA_XS_SCHEDULE_EVENT_SLOT and LEONIDA_XS_WAIT_EVENT_SLOT (3..127; a value that names a slot the proxy already handles keeps that slot's handler); a trace that disagrees wins. |
| Indirect argument type 105 | The retail title's startup creates five one-argument command signatures (device slot 41) with no root signature; one has type 105 and a 12-byte stride. Its two ExecuteIndirect sites, read statically, set the compute state first, as the DISPATCH sites do, and pass one command from the same argument buffer, on a second command list |
d3d12_xs_device.cpp creates it as DISPATCH (D3D12_DISPATCH_ARGUMENTS). What the console does differently for it is Open. |
| Device slot 61 | The retail title's boot under gta6rt --run (stop 20 of the RT-5 measurements in #6910): called as (desc, dest handle) once per sampler |
d3d12_xs_device.cpp routes it to the PC CreateSampler (slot 22) with the description's PC D3D12_SAMPLER_DESC prefix, for a caller in an image the guest loader mapped; the PC slot 61 is CreateMetaCommand, which any other caller (a host test driving the device through the proxy) still gets. The layout of the description beyond the PC fields is Open. |
| Device slot 74 | The retail title's boot under gta6rt --run: called as (pointer, u32, pointer) |
Stand-in. d3d12_xs_device.cpp answers S_OK and does nothing, for a caller in an image the guest loader mapped; the PC slot 74 is ShaderCacheControl, which the call does not fit and which any other caller still gets. What the console method is, and what it should do, is Open. |
| Command-allocator slot 9 | The retail title's boot under gta6rt --run: called past the 9-slot PC allocator, as (function pointer, context, ...); SetAllocatorCallbackX is the name the commit that added it uses |
Stand-in. The allocator proxy records the callback and its context (allocator_proxy_callback, allocator_proxy_callback_context) and answers S_OK. Nothing calls the callback: the Vulkan layer backs command buffers itself. Whether the title depends on being called back is Open. |
Device slot 81, queue PresentX/SuspendX/ResumeX |
XCL (GPL-2.0-only, third-party): GetFrameStatisticsX at device slot 81, PresentX at queue slot 30 (older runtime layout) or 32 (newer); SuspendX/ResumeX slots unmeasured; slot 81 Measured called (§7.1) |
set_presentation_handler forwards 78-81 and the queue routes to a presenter (attach_xbox_presentation). Without one, slot 81 answers S_OK with a zero count (no statistics yet; the answer the retail boot through the story load was measured with, where the public samples' "not available yet" is S_FALSE; a null count, or a count above zero with no array, is E_POINTER); PresentX goes to the presentation the device proxy builds itself on the first call (queue_present_x: in the title's window or one of the runtime's, LEONIDA_PRESENT_WINDOW), which takes its frame tokens from the same source as the device's WaitFrameEventX; every other queue slot past the PC table answers S_OK and does nothing, except slot 31 (next row). PresentX is slot 30 on a queue in the older layout and slot 32 on a queue detected as the newer one (a fence reaching slot 16 or 17, or SignalX at 25), never both: in the newer layout slot 30 is another method. Slot 81 moves with LEONIDA_XS_FRAME_STATISTICS_SLOT (3..127); LEONIDA_XS_PRESENT_X_SLOT pins PresentX to one slot whatever the layout; SuspendX and ResumeX are routed only when LEONIDA_XS_SUSPEND_X_SLOT / LEONIDA_XS_RESUME_X_SLOT are set (queue slots 19..127; two routes on one slot are refused with a log). |
Queue slot 31, CopyPageMappingsBatchX |
Arguments (count, batches, pool, pool pages, flags), a 24-byte batch {UINT64 destination; UINT32 range count; const range* ranges} and a 12-byte range {UINT32 kind, start, count}: read statically from the retail executable's call site and the code that fills the batches (#968), corroborated by the same call shape in a public project's queue (VIctory, copy_page_mappings, where the newer layout puts it at 29), and the pool-size argument equalled the page count of the title's own XMemAllocatePhysicalPages call in a boot |
Every range goes to xmem's copy_page_mappings_fn (d3d12_xs_device.cpp, queue_copy_page_mappings): kind 0 maps pool pages start, start + 1, ... at the destination, 1 maps pool page start at every destination page, 2 unmaps, 3 leaves the destination as it is; each range moves the destination on by count pages. A destination page gets a second view of the physical page mapped at its source page, and the same view at the paired CPU range when the destination is a GPU-only reservation (title_gpu_views), where the layer reads that memory. S_OK when every range was applied, E_INVALIDARG (logged once) for a range past the pool, an unknown kind or one xmem refuses; without xmem linked (tests of the proxy alone) the slot answers S_OK like the other console-only slots. Tested by xmem_test and xs_proxy_mock_test. Known gap: the mappings change when the call is made, not when the queue reaches the batch, as on the console; whether earlier queued work still reads a destination page then is not measured. |
| VRS | Public D3D12_SHADING_RATE / D3D12_AXIS_SHADING_RATE |
VK_KHR_fragment_shading_rate; RSSetShadingRate/image-based rate map to vkCmdSetFragmentShadingRateKHR. |
| Mesh shader tier | Public D3D12_MESH_SHADER_TIER |
VK_EXT_mesh_shader; the 9,282 translated mesh shaders make this a hard requirement for any content that uses them. |
| Wave MMA | Public D3D12_WAVE_MMA_TIER |
Not used: no shader sets WAVE_MMA in SFI0 and none contains v_mfma/v_wmma (all 26,503, tools/feature_scan.py). Answer the tier query truthfully; no cooperative-matrix mapping is needed. |
| Enhanced barriers | Public Xbox Series D3D12_BARRIER_GROUP |
VK_KHR_synchronization2; implement directly. |
| List slot 146: texture barrier with no resource | The retail title records D3D12_BARRIER_TYPE_TEXTURE barriers whose pResource is null in its Barrier(NumBarrierGroups, pBarrierGroups) calls; on the console such a barrier is a global memory and execution barrier |
d3d12_xs_device.cpp turns each into a D3D12_GLOBAL_BARRIER with the same SyncBefore/SyncAfter/AccessBefore/AccessAfter (layouts, subresource range and flags dropped) before it calls GCL7 Barrier (PC slot 80). A texture group with both kinds is split into runs, in order, in storage that lives for the call; a call with nothing to convert goes through with the title's own pointer. Without this the PC list goes into its error state, Close fails and ExecuteCommandLists drops the submission. A group array the proxy cannot read safely (null with a nonzero count, a group type it does not know, more than 1,024 groups or 65,536 barriers in one group) is refused whole, nothing recorded, and logged once per reason. Confirmed by the mock tests only (xs_proxy_mock_test), not by a retail run. |
| List slot 52: clear of an RTV made with no resource | The title creates some render-target views with CreateRenderTargetView(nullptr, ...) and clears them every frame; on the console that clear does nothing |
The device proxy marks the real handle when device slot 20 gets no resource; a view made there with a resource removes the mark, and CopyDescriptors/CopyDescriptorsSimple of RTVs move it with the descriptors. Releasing an RTV heap drops the marks in its real CPU range, so a heap made later at the same address starts unmarked. List slot 52 skips the clear of a marked view (logged the first time) and the list stays valid. The mark is the proxy's own because the real descriptor cannot tell: the Vulkan layer writes the same empty record for a view it could not make, and a PC runtime's handles are opaque. Any other view, valid or not, still reaches ClearRenderTargetView (PC slot 48); RTV records the title copies with its own memcpy are not followed. Confirmed by the mock tests only (xs_proxy_mock_test), not by a retail run. |
| XDXR batched/streaming BVH | XboxBvhBuilder.dll exports |
See 4.8. |
The null-resource barrier and null-view clear behaviour were first reported by luizwidmer/palmetto.
4.10 Debug markers and private data
Games and middleware call these every frame (PIX events), so they must be cheap and never fail. Implemented
(D3D-24) in runtime/shims/d3d12_com.cpp, runtime/shims/d3d12_com_object.h, runtime/src/command_list.h,
runtime/src/vulkan_replay.h and runtime/src/vulkan_backend.h; tested by runtime/test/d3d12_debug_markers_test.cpp.
- Labels, only with
VK_EXT_debug_utils. It is an instance extension, soVulkanDeviceInfo::debug_utilssays whether the instance enabled it;create_vulkan_device_standaloneenables it when the loader lists it. Without it every marker call is a no-op (nothing logged, nothing recorded on the queue). - Command lists.
SetMarker/BeginEvent/EndEventare recorded in the IR (DebugMarker) in order with the other commands and replayed asvkCmdInsertDebugUtilsLabelEXT/vkCmdBeginDebugUtilsLabelEXT/vkCmdEndDebugUtilsLabelEXTinto the submission's command buffer. - Queues. The same three methods on
ID3D12CommandQueuecallvkQueueInsert/Begin/EndDebugUtilsLabelEXTunder the device's submit lock, so they fall between the submissions issued before and after them. - Balancing. D3D12 does not make a list balance its events; Vulkan requires every end to have a begin.
One
ExecuteCommandListsis one command buffer, so a begin in one list may be ended by a later list of the same call. An end with nothing open is dropped, and labels still open when the last list ends are ended before the command buffer is ended. Queue labels are balanced per queue the same way (an unmatched end is dropped; open ones are ended when the queue is destroyed). Command-buffer labels never span twoExecuteCommandListscalls. - Labels. The
Metadataargument says what the data is, following WinPixEventRuntime'spix3_win.h: 0 (PIX_EVENT_UNICODE_VERSION) a UTF-16 string, 1 (PIX_EVENT_ANSI_VERSION) an ANSI string, both cut at the terminator or atSizebytes and converted to UTF-8; 2 (PIX_EVENT_PIX3BLOB_VERSION) PIX's own encoded event, which is not decoded and gets the fixed labelPIX eventso the nesting is still visible (question 21). Other values get the same label and log once. - Private data, on every object.
SetPrivateData,GetPrivateData,SetPrivateDataInterfaceandSetNamelive in the sharedObjectbase, so the device, queues, allocators, lists, fences, descriptor heaps and resources all have them. Every answer is the host runtime's:d3d12_private_data_testruns the same 672 steps on the device, a fence, a buffer, an allocator and a descriptor heap of both devices and compares each HRESULT, returned size, byte and reference count (RTX 3060, driver 610.88, no debug layer):SetPrivateDataInterfaceholds a reference until the entry is replaced (by bytes or another interface), removed or the object is destroyed;GetPrivateDatareturns the pointer with a reference added. A null interface releases the one held and stays as a pointer-sized entry that reads back as null.- A buffer too small for the entry gets
DXGI_ERROR_MORE_DATA, nothing copied and no reference added, and*pDataSizeset to the size needed; a missing entry isDXGI_ERROR_NOT_FOUNDwith*pDataSize0; a nullpDataSizeisE_INVALIDARG. SetPrivateDatawith null data removes the entry whatever the size:S_OKwhen there was one,S_FALSEwhen there wasn't. Zero bytes with data keep an empty entry (S_OK, size 0).SetNameisSetPrivateDatawithWKPDID_D3DDebugObjectNameW({4cca5fd8-921f-42c8-8566-70caf2a9b741}) and the name with its terminator, as D3D12 documents:GetPrivateDatareads it back, an empty name is a 2-byte entry, and the narrowWKPDID_D3DDebugObjectNameis not touched. A null name, which the host runtime faults on, changes nothing (E_INVALIDARG). Before #2533 the layer stored the name under a mistyped GUID. Names are not forwarded tovkSetDebugUtilsObjectNameEXTyet: one D3D12 object may own several Vulkan objects.
4.11 Vulkan device-loss diagnostics
Set LEONIDA_DEVICE_FAULT=1 before creating the runtime's Vulkan device to enable the supported device-fault and
NVIDIA checkpoint extensions. On the first observed device loss, stderr logs driver fault addresses, vendor data
and binary size, plus the checkpoints reached on each queue. Checkpoints identify the replay submission, its
original ExecuteCommandLists call, the zero-based list and command indices, and the most recent shader names
in that list when available. A checkpoint shows progress at a reported pipeline stage and can help narrow down
the faulting work. The loss report also lists the last 64 compute dispatches submitted across queues, including
direct group dimensions or indirect argument-buffer locations, even without driver checkpoints. These entries show
submission order. Set LEONIDA_DEVICE_FAULT_ROOTS=1 to include each dispatch's 32 recorded root words in the local
diagnostic log. While this mode is enabled, a host thread samples the submission timelines once a second. If the
retired ticket stays behind submitted work for 15 seconds, it prints the CPU dispatch history. It also reports
when it cannot sample the submission lock for that long. A progress warning leaves D3D12 fence values and the
device state intact. The driver checkpoint and fault-info queries run after Vulkan reports device loss. This mode
is off by default.
Each fault address is also looked up in this process (RT-FAULT-ADDRESS-OWNER). On Windows, VirtualQuery of the
same number gives the region's base, allocation base, state, protection and type. A GPU address isn't a CPU one,
but a host import, a range of the title's memory and a raw CPU pointer that reached a shader all share the
number. With LEONIDA_ADDRESS_BINDINGS=1 as well, the device enables VK_EXT_device_address_binding_report, and
a debug messenger records the GPU virtual address range of every buffer, image and allocation the driver binds
and unbinds (runtime/src/address_binding.h). The fault report then lists, for each address:
- the live objects that contain the address ("containing"), and those that only share its reported page, whose
size is the fault's
addressPrecision("on the page"); - the live objects that end nearest below it and start nearest above it;
- up to 16 recently unbound objects that held it, with their type, range, handle and the times they were bound and unbound.
"Nothing live or recently unbound there" means that no object of this device had that GPU address. On an RTX 5070 Ti the world-start loss of 1.0.2.1 reported write addresses far above every bound range, at about 50,000 binds. The record keeps the last 16,384 unbinds and costs one map entry per live binding.
There is one record per process. A second Vulkan instance in the same process (a second device) is refused a
messenger, and its device doesn't enable the extension, so the two devices' GPU addresses aren't mixed. If
LEONIDA_ADDRESS_BINDINGS=1 is set but no messenger records the device, the fault report says that the bindings
were not recorded, so this can't be mistaken for "nothing live or recently unbound there".
Each dispatch line carries a seq: a number every recorded dispatch gets, across queues and submissions, in the
order the submissions were recorded. The list keeps the last 64, so its numbers can have gaps where a submission
recorded more than that.
AMD breadcrumbs. NVIDIA's checkpoints say where a queue stopped; RADV has none. With LEONIDA_DEVICE_MARKERS=1
as well, on a device with VK_AMD_buffer_marker, every numbered dispatch and every draw writes its seq into its
queue's slot of one persistent buffer twice (src/vulkan_device_markers.h): at top of pipe before the work
(started) and at bottom of pipe after it (finished), with vkCmdWriteBufferMarker2AMD (or
vkCmdWriteBufferMarkerAMD without synchronization2). Draws and dispatches share the numbering, so the 64-entry
dispatch list has gaps where draws ran. A bottom-of-pipe write waits for all earlier work on the queue, so the
finished value is the last item before which everything had completed, and the queue's items after it up to the
started value are the ones the GPU began and did not finish. The oldest of them is the likely hang. The buffer is
host-visible and coherent, in system memory where the device has such a type, so it can still be read after a device
loss. The loss and stall reports then add lines like these (the shader names are made up):
[rt] device-markers: AMD buffer markers, read after the device loss; best-effort: only what the GPU wrote before it stopped, and a reset may have lost the last writes
[rt] device-markers: queue 0000000012345678 (compute) finished seq=1203 started seq=1205; started, not finished: 1204 1205
[rt] device-markers: finished: seq=1203 execute=88 queue=0000000012345678 (compute) list=0 command=16 shader=cs_example_b
[rt] device-markers: likely hang: seq=1204 execute=88 queue=0000000012345678 (compute) list=0 command=17 shader=cs_example_a
[rt] device-markers: in flight: seq=1205 execute=88 queue=0000000012345678 (compute) list=0 command=18 shader=cs_example_a
[rt] device-markers: queue 00000000123456a0 (direct) finished seq=1199 started seq=1200; started, not finished: 1200
[rt] device-markers: finished: seq=1199 execute=89 queue=00000000123456a0 (direct) list=1 command=1 shader=cs_example_c
[rt] device-markers: likely hang: seq=1200 execute=89 queue=00000000123456a0 (direct) list=1 command=7 draw=indexed count=3480 instances=1 pipeline=vs vs_example ps ps_example pass=draw 4 since command 2 (3 colours + depth, 1920x1080)
[rt] device-fault: submitted dispatch seq=1204 execute=88 queue=0000000012345678 (compute) list=0 command=17 shader=cs_example_a groups=64,1,1 <- likely hang (device-markers)
A draw line gives its kind (indexed, vertices, mesh, with -quads for a quad list and -indirect or
-indirect-count for arguments from a buffer) and counts (vertex or index count and instances, a mesh dispatch's
groups, an indirect draw's max records and stride), its pipeline named as the LEONIDA_GPU_PROFILE lines name
it (gpu_profile::label: each stage's tag and entry name, or pso 0x...), and its place among the draws of the list
to the same targets: pass=draw 4 since command 2 is the fourth draw to these targets since command 2. An idle queue
gets a not started: line for its next submitted item. When VK_EXT_device_fault reports an address, a
device-fault: last started draw (device-markers): line per queue follows the address lines, with (not finished)
or (finished) and <- likely hang when it is the queue's likely hang.
Granularity: a pair per draw, as per dispatch. The replay opens a rendering scope per draw, so the started write goes
before the draw's helper passes (quad index expansion, indirect clamp; a hang there is named as the draw's) and the
finished one after the scope ends, both outside a render pass instance. The extension allows them inside one too
(vk.xml: renderpass="both", and conditional rendering does not apply), which the legacy graphics ExecuteIndirect
path, drawing in the caller's scope, uses; vk_device_markers_test writes a pair inside an open scope under
validation. RADV (radv_CmdWriteMarkerToMemoryAMD) emits the cache flushes already pending, then a top-of-pipe write
as one write-confirmed COPY_DATA (the command processor waits for that write only) and any other stage as one
bottom-of-pipe EOP event (no wait): at most 24 dwords per draw, against the hundreds the draw's own scope and state
take. A pair per run of one pipeline would be cheaper but could not name the draw, so it was not chosen.
A separate history of the last 65,536 dispatches and draws (about 6 MiB) names the likely hang when it has already
left the 64-entry list, and names every draw. An idle queue (finished equals started) is not called hung: if it
still has work submitted, it was waiting on a semaphore or stuck in work that is neither (a copy, a barrier). The
values are what the GPU wrote before it stopped; after a loss and a ring reset they may be stale, so read them as a
pointer, not a proof. The cost with the switch on is two marker writes per dispatch and per draw plus one entry in
the history; with it off nothing is recorded. Without the extension, or without
LEONIDA_DEVICE_FAULT, the runtime logs one device-markers: unavailable line and runs as before.
For a local pre-submit inspection, also set LEONIDA_COMPUTE_INPUTS to comma-separated shader name fragments and
LEONIDA_COMPUTE_INPUT_SLOTS to comma-separated decimal root/slot pairs. For example, 4/86,5/0,5/2,7/0 reads
four 32-byte descriptors. The probe logs the bound heap and root layout, the saved user SGPRs, observed descriptor
writer, buffer address, stride, record count and readable backing. It also follows the per-group scene indices of
the Prop and Tree cullers when both 5/0 and 4/86 are selected. Each sample is taken after CPU-side shadow
refresh and before queue submission. Earlier GPU writes may still be in flight. An imported heap can have a valid
shader offset beyond the arena. Keep probe output local. Unset LEONIDA_COMPUTE_INPUTS to disable it.
5. Producing the shader contract
The table below is the contract from design.md and where the
runtime gets each piece. The shader side is already proven by runtime/test/vk_texture_test.cpp and the compute,
store, load, mesh, geometry and BVH tests; this layer is the other half.
| Contract | Runtime source |
|---|---|
s0..s31 user data |
Root signature state at draw/dispatch: root constants copied, root CBV/SRV/UAV addresses and descriptor-table base addresses as 64-bit console VAs. Mapping per section 3.5; absent parameters zero. |
heap_base (dwords 32–33) |
The arena's vkGetBufferDeviceAddress. One value per command buffer; updated only if the arena is recreated. |
code_base (dwords 34–35) |
The console VA of the current shader's FSSM blob in the arena. Per-stage conflict: see below. |
| Descriptor hash table (set 0, binding 2) | uint mask + entries of key[8], index, pad; FNV-1a over the 8 key dwords; linear probe up to 8; miss = index 0. Implemented in runtime/src/descriptor_table.h (DescriptorTable). The layer inserts every T#/S# it sees and keeps a fallback image/sampler at index 0. |
| Bindless images (bindings 0, 3, 5, 6) | 2D, 2D-array/cube, 1D, 3D sampled-image arrays; typed single-sample shader declarations alias the same binding numbers. Cube textures are 6-layer 2D arrays and cube arrays 6N-layer ones. The runtime also reserves optional MS SRV pairs at 20–25; the translator does not use them yet. |
| Samplers (binding 1) | One VkSampler per distinct S#; literal S# values from shader constants are pre-registered. |
| Storage images (bindings 4, 7, 8–19, 26–28) | Bindings 4 and 7 are formatted r32ui for 2D and 3D atomics. Bindings 8–19 are float/UINT/SINT triples for 2D, 2D-array, 3D and 1D. Bindings 26–28 are the float/UINT/SINT triple for 1D arrays, which have no sampled binding. The translator picks the numeric class from the T# format; the arrays for a dimension share the same index. |
| Buffer/image binding | Descriptors contain console VAs, never host BDAs. Buffers are in the arena at their VA; images are keyed by T# through the hash table. |
| Vertex fetch | PSO input layout + ISG1 signature; location = D3D input register; format from DXGI_FORMAT; instance step rate from the layout. The fetch subroutine is already replaced by Vulkan inputs. |
| PS system inputs | FragCoord (xy/z/w), FrontFacing, barycentrics; enable fragmentShaderBarycentric and fragmentShaderPixelInterlock when the index entry asks. |
| Mesh/geometry stages | VK_EXT_mesh_shader; the index's max vertices/primitives size the SPIR-V output arrays and are checked against the device's mesh properties; geometry stage for the 195 voxelize shaders; DispatchMesh → vkCmdDrawMeshTasksEXT. |
| POPS collision | The translator seeds the POPS collision SGPR itself at entry (0x00010000: no overlap, wave id 1, collision id 0; docs/design.md, "POPS"), so whatever the push constants hold at that SGPR's dword does not matter; ordering comes from fragment-shader interlock. The SGPR is the one the program's wave id extract reads (after the user SGPRs and the primitive mask). |
| Wave size | The PSO asks for the size the shader was translated for (requiredSubgroupSize 64 or 32, section 3.2 "Subgroup size") where the stage is in requiredSubgroupSizeStages; a shader translated with --wave64-emulate asks for nothing. A size the device cannot give is named in the log. |
| Code-embedded data | The whole FSSM blob is in the arena; s_getpc_b64 becomes code_base + next-instruction offset. |
5.1 Descriptor hash table details
Since the T# index word (docs/design.md, "Bindless index in the T#") the table serves only what the word does not
reach: every S#, and the T#s a translated module cannot trace to a heap slot (1,062 of the 439,415 T# operands of
the 1.0.2.1 corpus, in 108 modules). A T# loaded from a heap the layer writes carries its index and kind in dword 6
and is never looked up. Every T# key is still inserted, as the title wrote it: a T# outside the heaps is found by
those words.
The exact layout the shader reads (from tools/rdna2spirv.py, desc_lookup):
uint32 mask; // slot count - 1
struct entry { // 10 uints = 40 bytes
uint32 key[8]; // T#: 8 dwords; S#: 4 dwords then 0xFFFFFFFF x4
uint32 index; // bindless index
uint32 kind; // 0 empty; bit 31 occupied; bits 0..5 the sampled arrays the index is bound in,
// bits 8..11 its storage arrays (one bit per ImageDimension)
} entries[mask + 1];
- Hash: FNV-1a over the eight key dwords as dwords (not bytes):
h = 2166136261; h = (h ^ key[i]) * 16777619. - Optional finalizer (
fnv1a_fmix32): a module whoseindex.jsonmeta says"descriptor_hash": "fnv1a_fmix32"runs MurmurHash3'sfmix32on that word before probing (h ^= h >> 16; h *= 0x85EBCA6B; h ^= h >> 13; h *= 0xC2B2AE35; h ^= h >> 16, logical shifts). An absent key means barefnv1a.DescriptorTablefixes one kind per table before its first insert, taken from the modules' metas: all agree is that kind, mixed is the majority (the minority's lookups miss to index 0), andLEONIDA_DESCRIPTOR_HASH=fnv1a|fnv1a_fmix32overrides. The two kinds' shared vectors are inruntime/test/descriptor_table_test.cpp. - Probe:
slot = (h + k) & maskfork = 0..7; the first entry whose eight key dwords match yields itsindex; no match yields 0. kindsays which arrays that index is good for, because it was given out in the T#'s own dimension's index space (runtime/src/vulkan_bindless.h,ImageDimension): bitdis dimensiond's sampled array, bit8 + dits storage arrays. A module whoseindex.jsonmeta says"descriptor_table": "tagged"reads it and uses the index only in an array the entry names, else index 0 of the array its instruction reads; an absent key is the old plain layout, which reads only the index.DescriptorTable::inserttakes the kind, andBindlessSet::image_kind_atderives it from what was bound at the index (its own arrays, storage views, and the 2D copy of a 2D-array image's first layer, whose slot records that image as its owner so another dimension's image with the same slot number does not inherit it). One layout serves the device: any module whose meta saystaggedmakes the table tagged, because the kind word is additive (a plain module ignores the word and reads the index, which the tagged layout keeps at the same place), so a plain majority never turns it off; no tagged module is the old plain layout.LEONIDA_DESCRIPTOR_TABLE=plain|taggedoverrides, and the runtime says so loudly when an override forces plain while tagged modules exist.- The layer must keep the table sparse enough that no live key needs more than eight probes. When all eight slots are occupied, the runtime tries to move one resident to the next empty slot within that resident's own probe window. A relocation requires an idle flush because it overwrites a live slot. Grow when this fails or when the next insertion would exceed 50% load. Update binding 2 after the rebuild, at a point where no in-flight command buffer reads the old table.
- Insert on
CreateShaderResourceView,CreateUnorderedAccessView,CreateSampler,CopyDescriptorsand heap scans. A duplicate key updates the index in place. - Index 0 is the fallback: a 1×1 texture and a default sampler (and, for the storage arrays, a null descriptor
with
VK_EXT_robustness2nullDescriptoror else a storage image apart from the sampled ones). The translator returns 0 on a miss, so index 0 must always be valid. - The table buffer is a normal storage buffer, not part of the arena. It can be host-visible and updated directly (host-coherent, or flushed before submit); if the game is sensitive to PCIe traffic, stage it like any other upload. The shader only reads it.
- Inserts can come from several threads (view creation is often parallel). Serialise them with a mutex, or stage per-thread and merge at submit. The shader only reads the table, and D3D12 already forbids modifying a descriptor that an in-flight command list is using, so the same rule applies.
Measured (D3D-56, runtime/test/vk_descriptor_bench.cpp). Measured on an NVIDIA GeForce RTX 5080 (discrete, 0x10de:0x2c02, subgroup 32, driver NVIDIA 621.24, Vulkan 1.4.357), Windows 11 Pro 26H2 (build 26300), revision ec8ec4c9, using 64-bit Vulkan GPU timestamps (1.000 ns period) against leonida::DescriptorTable (90% T# / 10% S#) with the exact tools/rdna2spirv.py desc_probe loop. Unless noted, dispatches run 4096 x 64 invocations x 64 iterations (16.78M single / 33.55M T#+S# pair lookups); wave-uniform sweeps use group_stride = iters (64), lane_stride = 0 so all distinct entries are visited (at 100k: 90,000 T#, 10,000 S#, 100,000 T#+S# pairs, 131,072 miss keys; uniform_hot_tsharp repeats 1 key and measures 2.6–4.4 us/1M in device_local). This run includes bc8e604's bounded slot relocation, so its 100k row is at the same 524,288-slot geometry as the AMD RDNA3/RDNA4 tables below and directly comparable to them, and it refreshes an earlier pre-relocation RTX 5080 table. device_local and host_device_local are the median of 4 processes, host_visible one; every row is timing_status=ok with no dispatch auto-scaling:
| Entries (cap / load / bytes / mean probes) | Placement | uniform_tsharp_hit (us/1M, Glk/s) |
uniform_pair_ts (us/1M, Glk/s) |
divergent_tsharp_hit (us/1M, Glk/s) |
divergent_pair_ts (us/1M, Glk/s) |
divergent_miss (us/1M, Glk/s) |
|---|---|---|---|---|---|---|
| 1k (4,096 / 24.4% / 160 KiB / 1.316; 900 T#, 1k pair, 1,024 miss) | device_local |
3.322 (301.06) | 2.917 (342.84) | 24.008 (41.65) | 23.759 (42.09) | 96.175 (10.40) |
| 1k | host_device_local host_visible |
3.317 (301.49) 4.890 (204.48) | 2.918 (342.73) 3.583 (279.10) | 23.973 (41.71) 27.582 (36.26) | 23.732 (42.14) 26.426 (37.84) | 96.148 (10.40) 395.433 (2.53) |
| 10k (65,536 / 15.3% / 2.50 MiB / 1.310; 9k T#, 10k pair, 16,384 miss) | device_local |
12.842 (77.87) | 5.142 (194.49) | 38.202 (26.18) | 39.618 (25.24) | 206.654 (4.84) |
| 10k | host_device_local host_visible |
12.838 (77.89) 211.889 (4.72) | 5.166 (193.59) 16.257 (61.51) | 38.223 (26.16) 10261.465 (0.10) | 39.468 (25.34) 3334.286 (0.30) | 209.528 (4.77) 181717.455 (0.01) |
| 100k (524,288 / 19.1% / 20.00 MiB / 1.416; 90k T#, 100k pair, 131,072 miss) | device_local |
6.007 (166.47) | 7.159 (139.69) | 71.939 (13.90) | 47.306 (21.14) | 483.346 (2.07) |
| 100k | host_device_local host_visible |
6.025 (165.97) 213.404 (4.69) | 7.161 (139.64) 183.383 (5.45) | 71.895 (13.91) 15149.069 (0.07) | 47.277 (21.15) 16289.665 (0.06) | 482.358 (2.07) 205561.481 (0.00) |
Three consequences for the runtime and table layout (additional GPU measurements follow, including AMD RDNA3):
- In
DEVICE_LOCALVRAM, the hash probe itself is cheap at all three sizes: wave-uniform full-table sweeps (uniform_tsharp_hit) run at3.3–12.8 us / 1M, divergent lookups at24.0–71.9 us / 1M, and the 8-probe miss at96–483 us / 1M. BindlessSet::create()currently allocates PCIeHOST_VISIBLE | HOST_COHERENTsystem memory (runtime/src/vulkan_bindless.h): once working sets exceed cache at 10k–100k entries,host_visibleslowsuniform_tsharp_hitby 16.5x–35.5x, divergent T# hits by 210x–269x, and 8-probe misses by 425x–879x (181,717 us / 1Mat 10k,205,561at 100k).host_device_local(ReBARDEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT) matchesdevice_localwithin 1.4% on every row here (largest delta 10kdivergent_miss,+1.4%). Staging binding 2 toDEVICE_LOCAL(or preferringDEVICE_LOCAL | HOST_VISIBLEwhen small) avoids this cliff without touching the shader contract.bc8e604's bounded slot relocation keeps the table dense: 100k settles at524,288slots (19.07%load,20.00 MiB,max_probes=8) instead of doubling to2,097,152on a 9-probe collision, so the large-table cost is bounded by the 8-probe window; the dominant divergent cost is the 8-probe miss (483 us / 1Mat 100k).
Raw CSV rows (297, 9 processes): D3D-56 RTX 5080 report.
Measured (D3D-56, AMD RDNA3). The same benchmark and 64-bit timestamps on an AMD Radeon RX 7900 XTX (discrete, 0x1002:0x744c, subgroup 64, driver AMD proprietary 26.10.1 (LLPC), Vulkan 1.4.359), Windows 11 build 26200, revision 2aed144. Dispatches, iterations and reps match the NVIDIA run above, but the table code does not: this revision includes bc8e604's bounded slot relocation, so at 100k it settles at 524,288 slots (20.00 MiB, 19.07% load, max_probes=8), the same geometry as the refreshed RTX 5080 table above. The two tables now describe the same DescriptorTable code and their 100k rows are comparable; the remaining caveat is subgroup size (AMD 64 vs NVIDIA 32).
| Entries (cap / load / bytes / mean probes) | Placement | uniform_tsharp_hit (us/1M, Glk/s) |
uniform_pair_ts (us/1M, Glk/s) |
divergent_tsharp_hit (us/1M, Glk/s) |
divergent_pair_ts (us/1M, Glk/s) |
divergent_miss (us/1M, Glk/s) |
|---|---|---|---|---|---|---|
| 1k (4,096 / 24.4% / 160 KiB / 1.316) | device_local |
6.220 (160.76) | 5.705 (175.27) | 15.285 (65.42) | 14.051 (71.17) | 50.461 (19.82) |
| 1k | host_device_local host_visible |
8.783 (113.85) 9.508 (105.17) | 5.360 (186.58) 5.783 (172.93) | 15.380 (65.02) 15.869 (63.02) | 13.974 (71.56) 13.465 (74.27) | 49.765 (20.09) 51.978 (19.24) |
| 10k (65,536 / 15.3% / 2.50 MiB / 1.310) | device_local |
5.152 (194.09) | 4.880 (204.90) | 27.998 (35.72) | 20.506 (48.77) | 146.217 (6.84) |
| 10k | host_device_local host_visible |
5.066 (197.38) 7.536 (132.69) | 4.841 (206.57) 6.236 (160.36) | 28.322 (35.31) 72.932 (13.71) | 20.641 (48.45) 54.183 (18.46) | 144.532 (6.92) 334.096 (2.99) |
| 100k (524,288 / 19.1% / 20.00 MiB / 1.416) | device_local |
7.618 (131.28) | 6.005 (166.54) | 53.558 (18.67) | 54.927 (18.21) | 290.279 (3.45) |
| 100k | host_device_local host_visible |
7.660 (130.54) 47.905 (20.87) | 6.040 (165.55) 29.887 (33.46) | 53.983 (18.52) 3492.770 (0.29) | 54.804 (18.25) 2240.356 (0.45) | 292.561 (3.42) 32108.853 (0.03) |
On this GPU:
device_localis stable and cheap at every size. Wave-uniform sweeps run4.9–7.6 us / 1M(the 100kuniform_tsharp_hitis7.618), divergent lookups14.1–54.9 us / 1M, and the 8-probe miss50.5–290.3 us / 1M. Repeating the 10k measurement keepsdivergent_missat141–143 us / 1Mnet, so this column is not noise.host_visiblefalls off a cliff at 100k, and is unreliable below it. At 100k it is5.0x–6.3xslower thandevice_localon wave-uniform sweeps,41x–65xon divergent hits and pairs, and111xon 8-probe misses. At 10k the same rows varied by up to 6x between runs (divergent_missnet147–845 us / 1Mover five runs), so the 10k host row above is one representative run; the uniform rows moved much less (6.1–8.7 us / 1M). The conclusion does not change:device_localis stable,host_visibleis not.host_device_local(ReBAR) is a safe fallback on AMD. It is within 1% ofdevice_localat 100k and within 2% at 10k; at 1k it is within 1.5% on the divergent and miss rows,uniform_pair_tsis 6% faster (5.36vs5.71 us / 1M) anduniform_tsharp_hitis 41% slower (8.78vs6.22 us / 1M). TheDEVICE_LOCAL | HOST_VISIBLEallocation succeeds and runs here; it is not guaranteed on every Windows driver.- At the shared
524,288/8-probe geometry, the 100k rows are comparable across the tables. The RX 7900 XTXdivergent_miss(290 us / 1M) is below the refreshed RTX 5080 (483), with the RX 9070 XT (RDNA4) between at422(#313); the RX 7900 XTX is also faster on 100k divergent T# hits (54vs72) but slower on wave-uniform sweeps (7.6vs6.0 us / 1M). The subgroup size differs (AMD64, NVIDIA32), so this is a device-plus-subgroup comparison, not a pure microarchitecture one.
Raw CSV rows: D3D-56 report, addendum with the repeatability runs: same issue.
Measured (D3D-56, Intel integrated + RTX 5070 Ti Laptop). These synthetic runs use vk_descriptor_bench from revision f85582e, Windows 11 Pro Insider Preview 10.0.29704, MSVC 19.51, Vulkan SDK 1.4.363.0, and the exact 4096 x 64 invocations x 64 iterations (16.78M single / 33.55M T#+S# pair lookups, median of 25 reps). NVIDIA runs used --sizes 1000,1000,10000,100000 --warmup 200; the Intel run additionally duplicated 100k (--sizes 1000,1000,10000,100000,100000 --warmup 200). The first 1k block is excluded because its baseline_uniform timing differed from the duplicate (Intel device-local: 0.771 ms vs 0.594 ms; NVIDIA device-local: 0.0555 ms vs 0.0765 ms). For Intel 100k, the second block is retained after the duplicate confirmed stable timing per allocation. Retained rows were not auto-scaled. Intel's device-local and host-visible placements ran together on the integrated GPU. NVIDIA device-local and ReBAR were measured in separate processes. The RTX 5070 Ti Laptop is 0x10de:0x2f58 (driver 621.01, Vulkan 1.4.357); Intel Graphics is 0x8086:0x7d67 (driver 32.0.101.8132, Vulkan 1.4.325).
| GPU / entries (cap / load / bytes / mean probes) | Placement | uniform_tsharp_hit (us/1M, Glk/s) |
uniform_pair_ts (us/1M, Glk/s) |
divergent_tsharp_hit (us/1M, Glk/s) |
divergent_pair_ts (us/1M, Glk/s) |
divergent_miss (us/1M, Glk/s) |
|---|---|---|---|---|---|---|
| Intel iGPU, 1k (4,096 / 24.4% / 160 KiB / 1.316) | device_local |
85.669 (11.67) | 76.483 (13.07) | 468.524 (2.13) | 431.528 (2.32) | 1,735.402 (0.58) |
| Intel iGPU, 1k | host_visible |
85.356 (11.72) | 76.500 (13.07) | 468.750 (2.13) | 425.419 (2.35) | 1,741.669 (0.57) |
| Intel iGPU, 10k (65,536 / 15.3% / 2.50 MiB / 1.310) | device_local |
86.806 (11.52) | 76.642 (13.05) | 597.170 (1.67) | 507.250 (1.97) | 2,495.724 (0.40) |
| Intel iGPU, 10k | host_visible |
87.665 (11.41) | 76.415 (13.09) | 597.099 (1.67) | 506.874 (1.97) | 2,496.882 (0.40) |
| Intel iGPU, 100k (524,288 / 19.1% / 20.00 MiB / 1.416) | device_local |
101.132 (9.89) | 84.286 (11.86) | 672.021 (1.49) | 964.268 (1.04) | 5,580.289 (0.18) |
| Intel iGPU, 100k | host_visible |
100.269 (9.97) | 84.437 (11.84) | 668.788 (1.50) | 975.549 (1.02) | 5,581.019 (0.18) |
| RTX 5070 Ti Laptop, 1k (4,096 / 24.4% / 160 KiB / 1.316) | device_local |
11.028 (90.68) | 9.652 (103.60) | 48.388 (20.67) | 48.201 (20.75) | 195.543 (5.11) |
| RTX 5070 Ti Laptop, 1k | host_device_local (ReBAR) |
11.072 (90.32) | 9.682 (103.29) | 51.245 (19.51) | 48.427 (20.65) | 194.840 (5.13) |
| RTX 5070 Ti Laptop, 10k (65,536 / 15.3% / 2.50 MiB / 1.310) | device_local |
11.562 (86.49) | 10.164 (98.38) | 63.725 (15.69) | 66.871 (14.95) | 367.062 (2.72) |
| RTX 5070 Ti Laptop, 10k | host_device_local (ReBAR) |
11.494 (87.00) | 10.184 (98.19) | 63.858 (15.66) | 66.909 (14.95) | 297.104 (3.37) |
| RTX 5070 Ti Laptop, 100k (524,288 / 19.1% / 20.00 MiB / 1.416) | device_local |
11.993 (83.38) | 46.172 (21.66) | 116.020 (8.62) | 82.513 (12.12) | 788.086 (1.27) |
| RTX 5070 Ti Laptop, 100k | host_device_local (ReBAR) |
9.186 (108.86) | 46.162 (21.66) | 99.737 (10.03) | 141.439 (7.07) | 632.504 (1.58) |
On these devices:
- The Intel placements are close on the lookup workloads. Gross dispatch times for
device_localandhost_visibletrack within 1.5%; after subtractingbaseline_uniform, differences are within 1.7% through 10k and within 11.2% on 100k uniform hits. At 100k, the baseline itself is repeatable per allocation but differs between them (0.730 msdevice-local vs0.608 mshost-visible), so the net uniform rows carry more uncertainty. Both allocations use the iGPU's shared system memory; this does not predict discrete-GPU PCIe behavior. - NVIDIA ReBAR is close to device-local for uniform sweeps at 1k–10k and at 100k T#+S# pairs. The 100k divergent and miss cases differ by workload (ReBAR is not uniformly faster or slower), so this run does not support a blanket placement ranking.
- The NVIDIA host-visible run is omitted. A separate full run returned
vkWaitForFences -> -4while measuring the 10k host-visible cases; those partial timings are not reported. A safer capped profile is needed before drawing conclusions about PCIe system-memory lookup on this laptop.
The run is synthetic and contains no game data. Raw retained rows and the corrected methodology are recorded in the D3D-56 report on issue #313.
5.2 Per-stage code base
The current 144-byte block has one 64-bit code base at dwords 34–35. A graphics pipeline has at least a vertex and
a pixel shader, and each may use s_getpc_b64 for its own constant table. One block cannot hold two different
code bases at the same offset. The pipeline layout declares the block for every stage that may read it (or for all
graphics stages), and vkCmdPushConstants is called with those stage bits. This is a real gap in the current
contract, not a runtime bug:
- Only 155 shaders use code-embedded data, and a graphics pipeline has at least two stages (typically VS+PS, or MS+PS). If only one stage in a pipeline uses it, the layer can set that stage's code base; the other stage never reads it. This probably covers the first boot. ASSUMPTION.
- If both stages use it, the layer cannot satisfy both with the current contract. The clean fix is a translator change: give each stage its own code-base slot (for example dwords 34–35 VS, 36–37 PS, 38–39 CS, 40–41 GS/MS, extending the block to 168 bytes) and have each compiled shader read its stage's slot. A 168-byte push-constant block is still under the 256-byte limit of common desktop GPUs, but above Vulkan's 128-byte minimum; the device requirement must be checked.
- A second option is a per-stage uniform/storage buffer for the code base, patched in at pipeline creation. That
adds a descriptor binding and a load per
s_getpc, but avoids growing push constants. Not needed for the 1.0.2.1 package: measured over whole PSOs, none has two code-base stages (below).
Measured per stage (all 26,503, tools/feature_scan.py): s_getpc_b64 is kept to read code-embedded data in 54
VS, 93 PS, 266 MS and 263 CS (0 GS); the 147 VS/PS match the translator's own note. Both stages of a VS+PS or
MS+PS pipeline can therefore need a code base.
Measured per PSO (all 25,471 graphics records of the 1.0.2.1 pipeline library, tools/pso_code_base_pairs.py):
no PSO has two code-base stages. The pipeline library names a program per stage slot, and a stage's
resource-layout blob ends with the digest of the container its code came from, which is how a record's stage joins to
that program's uses_code_base in the translation index (shader_library.md §3). 25,027 records
have no code-base stage and 444 have exactly one — 343 in MS, 60 in PS, 41 in VS — in a corpus whose slots are 13,383
VS+PS, 10,726 MS+PS, 1,336 MS, 24 VS and 2 VS+PS+slot 6. The 21 records left unknown (19 VS+PS, 2 with slot 6) have a
stage whose program is not in the carve output, so its code base is unknown rather than absent. The per-stage library
program counts there (38 VS, 46 PS, 260 MS, 263 CS) are lower than the corpus counts above: the library holds a
second compiled form of 6,522 carved shaders, and a program can serve two stage slots.
Measured: across the GPU test fleet (Issue #166), desktop NVIDIA (Turing, Ampere, Ada, Blackwell: 256 bytes), desktop AMD (RDNA2: 256 bytes) and Apple Silicon (MoltenVK: 4096 bytes) all satisfy the 144-byte contract natively (maxPushConstantsSize >= 144). Intel Arc is not uniform: the earlier fleet entries report the 128-byte specification minimum (maxPushConstantsSize == 128) for Arc, but an Arc B580 (Battlemage) on Windows 11, driver 32.0.101.9175, reports 256 bytes (#166, @rtrexmass), so there D3D-14's fallback never engages. The 128 figure may be specific to another OS or driver (Mesa ANV on Linux is the guess; no Arc run on Linux that records the OS is cited here, and an ANV result would settle it). So does an integrated AMD RDNA2 GPU, a Radeon 680M on the Windows driver 22.40.84.06, so the minimum is not Intel-only. That figure follows the driver as well: a Radeon 610M reports 128 on 24.10.16.14 and 256 on 26.11.2 (#166). 128 bytes cannot fit the 16-byte tail (dwords 32–35: heap base and code base) inside push constants. The runtime detects maxPushConstantsSize < 144 at device creation (d3d12_vulkan_device.cpp) and flags push_constants_need_fallback for the uniform-buffer fallback.
Open: the minimum maxPushConstantsSize across target GPUs. The pair count above is measured, and zero, so the
168-byte block is not needed for this package. If a GPU only
supports 128 bytes, the current 144-byte contract already fails; the layer needs a fallback (uniform buffer for the
tail) regardless.
At run time, CreateGraphicsPipelineState refuses a pair where both stages read their code base, with a log, so a
pair the measurement missed still shows up on the first boot. A device whose maxPushConstantsSize is below 144
has every PSO refused,
with the limit in the log, until the uniform-buffer tail exists.
5.3 Descriptor T#/S# parsing
The runtime needs a C++ decoder for the structures the shaders read. The fields it needs:
- T# (image SRV): base console VA, format (GFX10 format code), width/height/depth, mip levels, array layers,
sample count, destination swizzle, dimension. The format table is
tools/gfx10_formats.json(Mesa'sgfx10-rsrc.json), the same one the translator uses. - S# (sampler): filter modes, address modes (U/V/W), border color, min/max LOD, LOD bias, compare function, anisotropy, coordinate normalization.
- V# (buffer): base console VA, stride, record count, format, destination swizzle. Buffer descriptors are dereferenced directly by the shader; the layer only needs to validate the VA and the format for typed loads.
If the game calls CreateShaderResourceView/CreateSampler, the layer can encode these structures itself from
the D3D12 descriptors. If the game writes them, the layer decodes them. Both paths meet in the same parser. The
GPU texture test already proves the shader-side contract on a synthetic T#/S#; the runtime parser is new code.
6. Boot milestones
Each milestone is a capability gate with a synthetic test; the game is the integration test once it is available. M0–M2 do not need the executable.
| # | Scope | What it proves | Done when |
|---|---|---|---|
| M0 | D3D12XboxCreateDevice and the measured device overrides (heap start handles in RAX), one direct queue, allocator/list, fence, fake DXGI factory/adapter/output, ALLOW_DISPLAY back buffers, frame events + PresentX (DXGI swapchain only if the game creates one), clear + present |
COM interception, the known Xbox device entry point and ABI overrides, presentation (PresentX + frame events, or swapchain), frame loop, clean shutdown |
A window shows a stable clear colour for 60 frames, no Vulkan validation errors, every D3D12 call traced. Synthetic part met by d3d12_present_test: 60 frames through the proxy on Vulkan, validation clean, colour checked in the presented images and on screen where GDI can read it. Still open: the game's present front end (frame events + PresentX, or a DXGI swapchain) and the per-call trace |
| M1 | Root signature with root constants (mask the measured 0x03000000 flag byte on a copy), one translated VS+PS, PSO, vertex buffer in the arena, draw, push constants s0..s31 + heap base |
PSO translation, shader hash lookup, vertex input, root-constant packing, heap base, present | The triangle matches a CPU/GPU reference; the existing texture-test style comparison passes with error 0. Met with stand-in shaders by d3d12_draw_test: every pixel of two indexed draws and a culled triangle matches, through the proxy, validation clean. With translated game shaders most of them declare bindings, which M2 (pipelines bind set 0) lets through. M1.5 (D3D-53) met with translator output by d3d12_translated_draw_test: see below |
| M1.5 | The same, with real translator output: hand-written RDNA2 VS+PS, PSO found by FSSM hash, vertex fetch through a V# loaded from the user-data table, a root constant, a table in the arena, the code base | The push-constant, vertex-fetch and code-base contracts on translated code | Met by d3d12_translated_draw_test: three draws, every pixel off the triangle's edge exact in a float target, validation clean on the AMD Radeon 880M and the RTX 5070 Laptop. An upload buffer behind a V# is not supported (section 3.3) |
| M2 | Descriptor heap (heap slots 9/10 return in RAX), CreateShaderResourceView, sampler, root descriptor table, hash-table insert, bindless sampling |
The full D3D12 descriptor path and the shader's T#/S# contract | A textured quad matches the synthetic 8×8 gradient or a known texture with error 0; the hash table has the expected entries. Synthetic part met by d3d12_m2_textured_test: through the proxy, D3D12 API only, a shader-visible CBV/SRV/UAV heap and a sampler heap (start handles from slots 9/10), two 8×8 textures uploaded with Map + CopyTextureRegion, CreateShaderResourceView and a POINT CreateSampler, a root signature of two descriptor tables, SetDescriptorHeaps, SetGraphicsRootDescriptorTable and DrawIndexedInstanced of a quad whose PS is translator output (ps_m2.asm: s_load of the T# and the S# from the tables, image_sample). Every one of the 4096 pixels matches the CPU-computed gradient (left half) and its point reflection (right half, second table) with error 0, and the hash table holds a distinct non-zero index for each of the two T#s and the S# and none for bytes nothing created; validation clean on the AMD Radeon 880M and the RTX 5070 Laptop. The layer change it needed: pipelines whose shader declares set-0 bindings (graphics and compute) were refused; their layout now holds the device's bindless set 0 and replay binds it at every draw and dispatch. Still open: shaders of the game itself (direct heap indexing, unbounded tables, static samplers, descriptors the game writes itself), no host D3D12/WARP byte comparison (the reference is computed on the CPU). Formats, mips and arrays through a PSO: d3d12_m2_formats_test samples an 8×8 BC1 and an 8×8 BC7 texture with 4 mips each and an R8G8B8A8 2D array of 3 slices through the same path (every subresource uploaded at its GetCopyableFootprints layout, POINT samplers with MinLOD = MaxLOD pinning each level, a view from mip 1, two array views read by ps_m2_array.asm); all 12 cases match the CPU with error 0, validation clean on the RTX 4070 Ti SUPER, with no layer change needed |
| M3 | Depth/stencil, multiple render targets, resource barriers, render passes, occlusion queries, fences, 2–3 frames in flight; run the game's first frames | Real frame structure and the first game code | The game reaches its first rendered frame (loading screen/menu or whatever the executable does) or stops on a single unsupported call with a clean report. Synthetic part met by d3d12_m3_frame_test: through the proxy, D3D12 API only, six frames through a ring of three slots (three frames in flight; each slot has its own allocator, list, targets, depth buffer, query and fence, and a frame waits with SetEventOnCompletion + an event for the fence its slot signalled three frames earlier before reading back and recording the slot again). Pass 1 draws three rectangles from root constants with translator-output shaders (vs_m3.asm, ps_m3.asm, hand-written RDNA2) through OMSetRenderTargets into two render targets (R8G8B8A8_UNORM and R32_FLOAT) and a D24_UNORM_S8_UINT depth/stencil buffer (the layer substitutes D32_SFLOAT_S8_UINT on the Radeon; the RTX has it natively): depth LESS with write, stencil REPLACE with references 1 and 2, then a draw with no depth test whose stencil test is EQUAL; before the far rectangle, a single-output probe (ps_m3_query.asm) uses the same depth/stencil tests with color, depth and stencil writes disabled, inside BeginQuery/EndQuery(OCCLUSION), and ResolveQueryData writes its sample count to a readback buffer. The actual far-rectangle draw still writes both render targets with depth/stencil writes enabled. Resource barriers move the first target RENDER_TARGET → PIXEL_SHADER_RESOURCE|COPY_SOURCE and the second to COPY_SOURCE (and back at the next frame, from resources created in those states). Pass 2 samples the first target through an SRV in a descriptor table (the M2 path) with ps_m3_post.asm into a third target. Every pixel of all three targets (the float one bit for bit) matches the CPU reference with error 0 in each of the six frames, and the single-output probe's occlusion count equals the exact visible area of the far rectangle in each frame (3555 samples over the six frames). The original version was validation clean (including synchronization validation) on the AMD Radeon 880M and the RTX 5070 Laptop; current probe/isolation results are recorded below. @whattheflop's run on #1584 (GeForce RTX 3080 and a Ryzen 7 9800X3D Radeon iGPU) sampled the fences with nonblocking reads after each submit and saw 1, 2, 3, 1, 2, 3 slots still incomplete on NVIDIA and 1, 1, 1, 1, 1, 1 on AMD: up to three slots in flight on NVIDIA, one on AMD (sampled fence completion; GPU execution overlap was not measured). Still open for M3: render passes (BeginRenderPass, D3D-27) are not exercised, nor BINARY_OCCLUSION, occlusion during pipeline statistics (D3D-162), MSAA or depth/stencil copies and read-only DSV states in this test; the game's own first frames need the executable |
| M4 | Compute PSOs, UAVs, storage images, indirect dispatch, copy queues, async streaming | Asset loading and GPU compute | The world's streaming path runs without device loss; compute results match a CPU/reference check. Synthetic part met by d3d12_m4_compute_test: through the proxy, D3D12 API only, with translator-output compute shaders (cs_m4_fill.asm and cs_m4_indirect.asm, hand-written RDNA2). A COPY queue streams an input buffer in (CopyBufferRegion from an UPLOAD buffer into a DEFAULT buffer created in COMMON), Signal; a COMPUTE queue Waits on it and runs one list: a compute root signature (four root constants and a descriptor table of five UAVs: a structured buffer, three raw buffers and an R32_UINT RWTexture2D), a compute PSO and Dispatch (256 threads) that fills the structured buffer and the image from the input and writes the arguments of the next dispatch into a raw buffer; barriers (the argument buffer to INDIRECT_ARGUMENT, UAV barriers on the buffer and the image); ExecuteIndirect with a dispatch command signature running a second PSO for the 3 groups the first dispatch asked for, which reads the buffer and the image back (image_load) and writes a raw output; then everything to COMMON and Signal. A COPY queue Waits on that fence, copies the five results (the image through CopyTextureRegion) to a readback buffer, and the CPU waits with SetEventOnCompletion. Each D3D12 queue has its own VkQueue where the family has two (both test GPUs); all 1,924 result words match the CPU reference with error 0; validation (with synchronization validation) clean on the AMD Radeon 880M and the RTX 5070 Laptop. Layer gaps this test found, closed with it: buffer UAVs (structured and raw) were not written (CreateUnorderedAccessView stubbed them, now a V# in the slot); ExecuteIndirect of a dispatch ran whatever pipeline and root arguments the command buffer had bound instead of the list's (now recorded with the command, as Dispatch does); an image created in UNORDERED_ACCESS and first used by a shader was zero-filled by the first barrier or copy that named it, losing the shader's writes (now moved to GENERAL, zeroed, by the first submission after its UAV view is created that is not on a copy queue and dispatches or draws; every other queue's next submission waits for that one); and a queue submitted before the queue whose fence it waits on, when a resource's layout is handed over between them (the layout tracker followed submission order, so a copy list was replayed against the layout from before the compute list ran and the run stopped on a validation error): such a batch is now held on the CPU until a Signal that satisfies its Wait has been submitted, and recorded in dependency order (section 4.4, "Wait before Signal across queues"; d3d12_queue_handover_test, every queue-type and submission order, exact against the host runtime). Still open for M4: the storage-image initialization is tied to the first shader-running submission, not to the list that uses the image, so a list that only reaches an image through a barrier or copy before any dispatch or draw is submitted still zero-fills it first (as before), and an image used by a shader only on a queue that never runs one of its own dispatches or draws first relies on another queue's submission; buffer SRVs and CBVs as V#s (typed buffer UAVs and UAV counters are done: d3d12_buffer_uav_test, section 3.4 "Buffer UAVs"), ExecuteIndirect signatures that change root arguments or use count buffers for dispatches, and async streaming itself and the world's streaming path, which need the game |
| M5 | Mesh shaders, ExecuteIndirect, bindless-table pressure, multi-threaded command lists, pipeline cache |
World rendering | A stable open-world frame at any frame rate; then profile and optimise |
| M6 | Ray tracing/XDXR: standard AS builds or the shipped XboxBvhBuilder compute path; BVH node format; the builder's 52 console FSSM programs (all 52 translate and pass spirv-val: embedded_shaders.md) |
RT shadows and any RT effects | RT output matches a reference; the builder's shaders run through the FSSM translator or a substitute; no unknown XDXR call remains |
| M7 | HDR, VRS, PresentX planes (2-plane HDR + GameDVR compose, ImmediateThresholdPercent), resize, alt-tab, SuspendX/ResumeX, frame pacing and GetFrameStatisticsX |
Presentation polish | HDR and resize work on the target display; no validation errors over a long run. Partly met: ImmediateThresholdPercent (late frame flipped at once through VK_KHR/EXT_swapchain_maintenance1 IMMEDIATE/FIFO_RELAXED, section 4.5; checked on the fake-clock decision and on the Vulkan present mode, 0 VUIDs in our runs with LEONIDA_VK_VALIDATION=1 on two GPUs, no tearing observed on a display; the console's real semantics are unmeasured). Plane compose (section 4.5): 1-2 planes scaled from a source rectangle to a destination placement, point or bilinear, plane 1 alpha-blended (premultiplied or straight), filtered and blended in linear light, SDR (sRGB or gamma 2.2) and HDR10 (PQ) planes converted to the swapchain, SDR white from Windows' setting when HDR10 is active (else 203 nits), checked against a CPU model on two GPUs with 0 VUIDs (exact for point filtering, within 1-2 levels for bilinear, alpha, tone map and PQ conversions); the layouts, flag values and alpha convention are ours, the console's plane semantics are unmeasured, and the public HDR sample's second plane is the GameDVR copy, not an overlay. HDR10 swapchain (ST.2084 surface): verified on an RTX 5080 with an HDR10 display by @JavierBlanco23 in #2069, not on AMD (our test displays list no ST.2084 surface); HDR10 on an SDR swapchain is tone mapped (identity below 0.8 of SDR white, Reinhard shoulder above, then clipped per channel). SuspendX/ResumeX, frame pacing and a minimal GetFrameStatisticsX exist; VRS, alt-tab, an AMD HDR10 display run are open |
M3 occlusion portability (D3D-209). Vulkan's occlusion query specification
permits a count multiplied by the number of written color outputs, even with VK_QUERY_CONTROL_PRECISE_BIT.
The original two-output query returned twice the CPU area on Intel UHD (Windows driver 31.0.101.4146),
while NVIDIA RTX 3050 6GB Laptop (617.14) returned the area itself. Synthetic direct Vulkan and native D3D12
controls also returned 8192 on Intel for a 64×64 quad with two outputs, versus 4096 with one;
NVIDIA and D3D12 WARP returned 4096 in both cases. This does not establish duplicated replay commands.
The test now measures a single-output, write-free probe, keeping its exact CPU oracle and the original
MRT rendering and pixel checks. It does not divide application query results or change the runtime backend.
d3d12_m3_first_pass runs the same executable with --first-pass-only: all six frames, MRT pixels,
depth/stencil, barriers, queries and slot fences are still checked, and the third target must stay clear.
It isolates post-pass pipeline creation and execution: it skips creating the post-process PSO and recording
the sampled draw. All five FSSM files and their shader-library entries, including vs_m2 and ps_m3_post,
are still required at startup. The second-pass root signature and descriptor heaps are still created,
so missing post-pass shaders or failed descriptor setup still fail this mode. d3d12_m3_frame remains
the full test. The first-pass mode passes with validation on both GPUs above (3555 samples). The full test passes on NVIDIA;
on this older Intel driver it still fails validation because ps_m3_post declares Int64 without
shaderInt64 support. The full test continues to report that separate capability issue.
6.1 Minimum API set for the first frame
M0–M3's synthetic tests need only this subset. The game itself may need more as soon as its first frame does; everything else can be absent or a clean failure:
D3D12XboxCreateDeviceandCheckFeatureSupport; the measured device overrides (heap start handles in RAX; slot 76 texture creation if the game uses it; slot 62, compute-PSO creation in the builder's ABI, is not needed for the first frame); one direct queue, one allocator, one command list, one fence;- DXGI factory/adapter/output enumeration; frame events and
PresentX(orGetBuffer/Presentif the game creates a swapchain); - a root signature with root constants and one descriptor table, masking
0x03000000on a copy; one VS+PS PSO and an input layout; - a shader-visible CBV/SRV/UAV heap and a sampler heap;
CreateShaderResourceView,CreateSampler,SetDescriptorHeaps,SetGraphicsRootDescriptorTable; - one committed vertex/index buffer, one texture, upload through
Map/UnmaporWriteToSubresource,CopyBufferToImage; - resource barriers, RTV/DSV,
OMSetRenderTargets,Clear*View,DrawIndexedInstanced,PresentX/Present; - the runtime side: descriptor hash table, bindless set 0, push constants (
s0..s31, heap base, code base), vertex input from the PSO layout.
Not needed for the first frame: compute, mesh, geometry, ray tracing, VRS, PresentX plane compose, reserved/tiled resources,
heap aliasing, indirect draws, multiple queues, pipeline libraries. (PresentX itself is needed; only its plane compose, HDR and statistics are not.)
Why this order. M0–M2 isolate the layer from the game: they exercise every contract piece with known data. M3 is the first point where the game's own root signatures, PSOs and descriptors appear; expect the trace to rewrite parts of section 3.5. M4/M5 are ordered by dependency: assets must stream before the world can draw, and the corpus's 9,282 mesh shaders (and, very likely, indirect draws) are world-rendering features. M6 is last because the game ships its own BVH builder; the layer may only need to run its compute work, not implement a full DXR path.
First-boot minimum. Strictly, the first boot needs M0–M3 plus whatever the game does before its first frame. If the first frame is a loading screen with a simple UI draw, M3 may be enough; if it is the world, M5 is the real minimum. The trace decides, not the milestone labels.
7. Prior art and measured Xbox ABI
A GPL-2.0-only fork of AnyPS5 (americas-recomp, branch xbox-series) recompiles the same GTA VI Xbox Series
shaders and has run the package's DLLs against a PC D3D12 device behind an Xbox-ABI proxy. Its measurements are
prior art for this design. The findings below are paraphrased; no code or long passages are copied. They were
verified there by running the package DLLs (XS_TRACE=1, per-slot hit counters) or by static import analysis, not
independently re-measured here. Basis: static imports means PE import-table analysis; run means the package
DLLs were executed against a PC D3D12 device through the Xbox-ABI proxy.
Other Xbox Series compatibility-layer efforts have since measured overlapping parts of the same surface — running the package's own console DLLs and shader pack, retail titles, or a console-compiler output. Their findings are folded into the table below with the measurement basis noted per row; nothing is re-derived from their code.
| Finding | Basis and link | Consequence for this design |
|---|---|---|
Across the 16 package DLLs there are only 6 Xbox-specific static imports: xmem.dll → XMemAlloc, XMemFree, XMemGetWorkingSetStatistics, XMemVirtualQuery; d3d12_xs.dll → D3D12SerializeVersionedRootSignature, D3D12CreateRootSignatureDeserializer. Both d3d12_xs names exist with the same names in the PC d3d12.dll. The other 492 functions are standard Windows and 113 are shipped in the package. Argument shapes for the less common xmem calls come from caller disassembly; some attribute bits are inferred. |
Static imports — PLATFORM_SURFACE.md | Confirms the middleware surface is tiny. The repo's xmem shim already covers all four; d3d12_xs still forwards only the two root-signature functions. The device/queue/command-list surface belongs to the executable. |
D3D12XboxCreateDevice(adapter, params, riid, out) returns a PC ID3D12Device behind the Xbox-ABI proxy. The params struct is 24 words and is only logged; the signature comes from public documentation, not a header. |
Run — platform README, PLATFORM_SURFACE.md | Corrects "device entry point unknown": the entry point is named. The params/flag layout remains Open. Do not assume D3D12CreateDevice. |
Xbox texture creation is device slot 76 (heap properties / heap flags / description / initial state / clear value / iid / out), not CreateCommittedResource. The description is 56 bytes plus extension words; its layout field is 0x101 (tiled) or 0x1 (row-major buffer), and the PC proxy forwards it to CreateCommittedResource slot 27 with a driver-chosen layout. The FidelityFX upscaler creates 10 default-heap resources this way. |
Run — PLATFORM_SURFACE.md | Adds a required Xbox-specific device method and a non-public layout value. 0x101 must not be passed to the public layout enum; the tiled data layout/detile path remains Open. See section 4.2. |
Device slot 14 is the public CreateDescriptorHeap; the returned heap is wrapped because GetCPUDescriptorHandleForHeapStart / GetGPUDescriptorHandleForHeapStart (heap slots 9/10) return the 8-byte handle in RAX on the Xbox build. The PC call returns it through a hidden pointer in RDX, so the proxy special-cases the return. |
Run — PLATFORM_SURFACE.md | Adds a return-convention quirk to the descriptor-heap ABI. A generic IDL/sret thunk will corrupt the handle. See section 3.4. |
Xbox root-signature descriptors carry flags 0x03000000. The PC serializer rejects them with E_INVALIDARG; the proxy clears the high byte on a copy. The v1.0 D3D12SerializeRootSignature path keeps flags at +32, and 0x3000001 also fails on the PC runtime. |
Run — PLATFORM_SURFACE.md | Narrows the root-signature reflection risk. Mask the high byte on a private copy; the meaning of the bits remains Open. See section 3.5. |
The BVH builder's constructor creates 53 compute pipelines through device slot 62, called with a compute-PSO shape (a plain D3D12_COMPUTE_PIPELINE_STATE_DESC, two zero words, iid, out). On the PC interface the prior art forwards to, slot 62 is CreateStateObject (wrong arity), so the proxy overrides it. |
Run — PLATFORM_SURFACE.md | Corrects the assumption that the whole device vtable is public order. Slot 62 must be compute-PSO creation for the builder, not a state object. Slots 1/15/18/19/27/38 did match the desktop order. |
A reusable xbox_device_proxy.h forwards every slot to a PC object, counts hits per slot and logs first calls with XS_TRACE=1; the observed device slots include 1, 14, 15, 16, 18, 19, 27, 38, 62 and 76. Their xgr stand-in covers 48 of 398 methods; Xodus (LGPL-2.1) covers 152 of 396 via IDL-generated stubs. |
Run — platform README, PLATFORM_SURFACE.md | Confirms the trace-first approach and shows the long tail. We adopt the method (per-slot counters, first-call logging), not the code. |
The BVH builder's 53 compute shaders are Xbox DXIL with @xbox.* intrinsics; 44 of 53 fail the PC D3D12 shader compiler, 22 have been lowered to standard DXIL and accepted as pipelines, and 31 use raw 64-bit GPU addresses. |
Run — PLATFORM_SURFACE.md | A separate translation path from the FSSM RDNA2 corpus when measured on the bitcode. See section 4.8 and the paragraph below. Measured later on the console XBCH record of the same containers: 52 programs, 51 pass spirv-val through the FSSM translator (embedded_shaders.md). 52 programs, 42 pass spirv-val through the FSSM translator (embedded_shaders.md). |
On the console's own shader compiler, compute user parameters go into user SGPRs s4… in root-signature order while each fits whole (root constant = 1 dword, root descriptor = 2, descriptor table = 1 dword holding the 32-bit address of its first descriptor); s0..s3 are the driver's. From the first parameter that does not fit, it and all after it go into a packed array addressed by a 40-bit pointer in s[0:1] (constant 4 B, descriptor 8 B, no alignment). Thread-group ids follow the user SGPRs. |
Console-compiler output, sibling layer | Narrows question 3 for the compute stage: the inline-from-s4 model matches this repo's census (lowest CS pointer SGPR s4), and the spill target is named (the array at s[0:1]), not guessed. VS/PS/MS bases were not measured there; verify against the game's own signatures. |
The command list's inline records: a Dispatch is 0x4002C400 followed by x, y, z (16 B); a 20-byte record 0x4003CC00 stands in for console slot 80; the pipeline record is a 28-byte copy of the PSO object's +0x10..+0x2B; a root parameter starts from the header word at list +0x344+4·i (the high half carries n−1 for a multi-constant write), then a descriptor is 12 B, one constant 8 B and n constants 4+4n B. |
Console-DLL run, sibling layer | Supplies the record opcode for the "five-dword packet" this repo inferred at slot 80 and the header encoding for parameter groups; consistent with our own measurements of +0x18/+0x28/+0x30/+0x140/+0x344/+0x544. |
Mesh (NGG) inputs measured across the corpus: s3[27:24] = wave index in the group, v5 = group·128 + thread, s16–s24 = user data. |
Corpus measurement, sibling layer | Confirms the s16 mesh base of §3.5's census and the v5 group numbering already used for the mesh stage. |
Console unified memory can be mapped GPU-side without copying: a region of at most 4,095 MB at a 4 GiB-aligned address, committed up front, opened through ID3D12Device3::OpenExistingHeapFromAddress (a partial commit and a full 4 GiB are rejected). The low 32 bits of a console address then index the buffer directly. |
Measured on PC D3D12, sibling layer | A concrete recipe for §3.3's single address space: game addresses as offsets into one buffer that shaders reach through PhysicalStorageBuffer64. |
| The title physical-page calls use 64 KiB pages; mapping a run of consecutive pages returns a contiguous range inside the unified region, and scattered or explicitly addressed mappings are refused. | Console-DLL run, sibling layer | Sizes the page granularity the xmem shim should answer before the executable's real calls are known. |
On a retail UE5 title the graphics command list takes console slot 83 for CopyTextureRegion, 84 for CopyResource, 26 for barriers, 127 for direct mesh dispatch, 59 for a second indirect/mesh dispatch path, and 96 for an async-compute budget call that accepts six zero words. |
Retail-title run, sibling layer | Narrows question 2: mesh dispatch is not at the PC position (GCL6 slot 79) on the console, and the copy/barrier/budget slots add to the shifted groups already measured here. |
The console d3d12_xs.dll also exports D3D12XboxCreateSyntheticDevice and D3D12XboxSetProcessDebugFlags; sibling console modules include xg_xs.dll (XGCreateTexture2DComputer, XGComputeOptimalSwizzleMode), AcpHal.dll (ApuAlloc, ApuFree, ApuMapVirtualAddress, ApuIsVirtualAddressValid, AcpHalCreate, AcpHalAllocateShapeContexts, AcpHalReleaseShapeContexts) and dstorage_xs.dll (console DirectStorage); XAudio2_9.dll ordinal 1 is XAudio2Create and GameInput.dll ordinal 1 is GameInputCreate. |
Export inventory, sibling layer | Names the console-only modules the loader's shim registry should expect beyond xgameruntime/d3d12_xs/xmem/gameinput. |
Console xaudio2_9.dll voices accept the console formats: XMA/XMA2 and an Opus voice format 0x704F; a CO_E_NOTINITIALIZED from the system XAudio2 is retried after CoInitializeEx on the calling thread. |
Console-DLL run, sibling layer | Forwarding console XAudio2_9.dll to the system XAudio2 2.9 works; the retry rule and the format remapping are the quirks to reproduce. |
A retail title boots to its menu and lobby through the same shim-layer route (native x64 code, console-library stand-ins); its console-only library set adds chad (XDsp*), xapu (XApu*), xcrdapi and *legacy DLL variants to the list. |
Retail-title run, sibling layer | Confirms the architecture end to end on retail code and extends the console-DLL checklist. |
7.1 What this confirms, corrects and narrows
Confirms.
- The 16 middleware DLLs need only four
xmemfunctions and the twod3d12_xsroot-signature functions. Our earlier statement that the bundled DLLs only import the two root-signature calls was right but incomplete; the fourxmemimports complete the static surface. The repo'sxmemshim already implements all four. - Device slots 1 (AddRef), 15 (
GetDescriptorHandleIncrementSize), 18 (CreateShaderResourceView), 19 (CreateUnorderedAccessView), 27 (CreateCommittedResource) and 38 (GetCopyableFootprints) match the desktop order. Device slot 14 is the publicCreateDescriptorHeap; only the returned heap's start-handle return is wrapped. The public chain is a usable base for those methods, not a guess. - The BVH builder receives the device and command lists from the caller; prior art runs it exactly that way.
Measured: the presentation slots 78, 79, 80 and 81 are called, on the device (D3D12-PRESENT-SLOTS-MEASURED).
All eight device sites load the one device pointer from the BSS global 0x148759D00 into rcx and call through
[[rcx] + offset]; that is the same global the layer's known device calls use (e.g. CreateCommittedResource,
slot 27, at 0x142481bce), and many subsystems load it rip-relative, as they would a device singleton. The
other call [reg+offset] sites at those offsets belong to other interfaces that share the PC slot numbers, so they are
counted but not attributed. Arity and arguments are the register and stack words written before each site:
| slot | offset | raw sites | device sites | receiver | arguments (registers, then stack) | what it is |
|---|---|---|---|---|---|---|
| 78 | 0x270 |
31 | 1 | [0x148759D00] |
0x14247abd8: rdx=0 (output), r8d=edi (latency word from the interval table indexed at 0x14247ab95), r9d=2 or 3 (flags, same table), [rsp+0x20]=0 |
SetFrameIntervalX, 4 arguments (output NULL, latency, flags, 0). Its function (0x14247ab10) has three callers on the frame-interval paths; the slot itself has one site. |
| 79 | 0x278 |
40 | 3 | [0x148759D00] |
0x14247abfc: rdx=0 (event), r8d=edi (offset), r9d=0 (reserved), [rsp+0x20]=0. 0x142478de4: rdx=2, r8=0, r9=0, [rsp+0x20]=0. 0x1424900e3: same as the previous site. |
ScheduleFrameEventX, 4 arguments (event, offset, null, flags 0). Event 0 is ORIGIN; event 2 is unlabelled and only appears on the two later sites. |
| 80 | 0x280 |
42 | 3 | [0x148759D00] |
0x142482405: rdx=2 (event), r8d=0xFFFFFFFF (INFINITE), r9=0 (reserved), [rsp+0x20]=0 (flags), [rsp+0x28]=&[rsp+0x68] (token out). 0x142482448: rdx=0, r8d=INFINITE, r9=0, [rsp+0x20]=2 (flags), [rsp+0x28]=&global token. 0x142484637: rdx=0, r8d=INFINITE, r9=0, [rsp+0x20]=0, [rsp+0x28]=&[rsp+0x30]. |
WaitFrameEventX, 5 arguments (event, INFINITE, null, flags, token out) — the per-frame wait, once at the top of the loop; event 0 with flag 2 on the path that arms the origin, event 2 on the other. |
| 81 | 0x288 |
522 | 1 | [0x148759D00] |
0x142482710: rdx=token ([r9 + r8*8], the previous round's entry of a 4-slot ring), r8d=0x11100 (type mask), r9=&count ([rsp+0x2c], seeded with 6), [rsp+0x20]=&[rsp+0x30] (0x38-byte statistics array) |
GetFrameStatisticsX, 4 arguments. After the call it walks the returned entries and matches type 0x10000 (FRAME_INTERVAL) and 0x1000 (FRAME_EVENT), exactly the documented shape. |
The sites also confirm the order the samples use: interval, schedule, then a wait per frame; the statistics call reads
a token that an earlier wait wrote. Flag 2 on the wait is the one XCL gives the "write the token even on timeout"
meaning. PresentX itself is not in this set (it is a queue slot, §4.5); 78-81 are device slots beyond the public
vtable order, as the prior art said.
Corrects.
- Device creation.
D3D12XboxCreateDeviceis the entry point. The 24-word params struct is only logged, so the flag/layout meaning is still unknown; the name and call shape are no longer unknown. Prior art returns a PC D3D12 device behind the proxy; this design returns the Vulkan-backedDevicebehind the same call shape. - Vtable. The Xbox device is not uniformly the public order. Slot 76 is an extra texture-creation method, slot 62 is called with a compute-PSO signature where the PC interface has a state-object method, and the descriptor-heap start handles use a different return convention. Implement the public chain plus explicit measured overrides; do not trust a single generic thunk for every slot.
- Texture layout. Xbox
0x101tiled is not a publicD3D12_TEXTURE_LAYOUTvalue, and slot 76 is the texture path. Our earlierD3D12_RESOURCE_DESC::Layoutdiscussion covered only the public enum; it now includes the Xbox value and slot 76. - Root signatures. The
0x03000000flags must be masked on a copy before the host serializer/deserializer. Our earlier "forward the blob to the host" was too simple; the PC serializer rejects the Xbox bits. - BVH builder. Its console programs are
FSSM; the bitcode in the same container is the representation the PC compiler consumed. "Run the builder's dispatches" therefore takes the same FSSM → SPIR-V path as the game, with one rule still missing (embedded_shaders.md).
Narrows.
- Presentation slots 78-81 are now measured, with arity and receiver (above); the plane/parameter struct layouts, the queue
PresentX/SuspendX/ResumeXslots (prior art only), command-list extensions, and queue/fence creation slots remain Open. - Descriptor start-handle ABI is known; descriptor bytes and heap increments are still Open. Slot 15 is forwarded unchanged, but the actual increment values were not measured.
- Texture creation ABI and the
0x101value are known; the tiled data layout, detile path and DCC remain Open. - The device params (command-queue ring size, scratch memory, debug flags) are unused and their meanings are still unknown.
- The
xgr48/398 and Xodus 152/396 coverage numbers show how large the long tail is. They do not change the plan: implement what the game calls, in the order it calls it.
7.2 The BVH builder's shader path
The builder's 52 compute shaders are a second corpus, not a second shader front end. Each container carries an
LLVM bitcode blob and an XDAT/XBCH record; the bitcode is what the PC D3D12 compiler experiment consumed
(44 of 53 rejected, 22 lowered), while the console runtime executes the XBCH record. That record decompresses
to FSSM, the same container the game's own compute shaders use: 52/52 unpack, translate and pass
spirv-val with tools/rdna2spirv.py; embedded_shaders.md lists the five rules that
closed the last ten. The raw 64-bit addresses are the translator's existing raw-address path, so no
address-to-resource table is needed on top. A port that runs XboxBvhBuilder therefore needs the FSSM translator,
not a DXIL front end (a substitute builder remains the alternative).
Correctness is still unverified on a GPU and the call sites need the executable (RT-5).
7.3 Licence
americas-recomp / AnyPS5 is GPL-2.0-only. GPL-2.0-only is not compatible with this repository's
GPL-3.0-or-later, so no code, headers, generated stubs or other implementation text from that tree may be copied
into Leonida. This section records ABI/format facts and links only; the designs in this document are independent.
Xodus is LGPL-2.1 and is cited only for its coverage number, not as a code source. The same line holds for the
other compatibility-layer efforts whose measurements are folded in above: facts and numbers only, paraphrased —
nothing is copied from their trees.
8. Known vs unknown
8.1 Known
- The public D3D12 ABI and method order (Windows SDK
d3d12.h10.0.26100.0); the Xbox public reference lists the same base interfaces and method names underd3d12_xs.h, but the measured Xbox device ABI is only mostly the public order: slots 1/15/18/19/27/38 matched, while slots 62 and 76 and the descriptor-heap start-handle return did not (section 7). - The translator/runtime shader contract, and that it works on a real GPU for the tested paths.
- The package evidence in section 2 and Appendix A: the BVH builder's Device11/CommandList4/6/8 signatures and
XDXR types, the FSR IIDs, the other DLLs' lack of
d3d12_xsimports,gameos.xvd's encrypted payload, and the absent executable. - The prior art's measured Xbox ABI (section 7): 6 Xbox-specific static imports across the 16 DLLs,
D3D12XboxCreateDevice, device slots 62/76, descriptor-heap start handles in RAX, root-signature flags0x03000000, and the BVH builder's container format (a DXIL bitcode blob plus the consoleXBCHrecord).
8.2 Unknown / open questions
| # | Question | How to resolve |
|---|---|---|
| 1 | The device entry point is now named D3D12XboxCreateDevice(adapter, params, riid, out). What do its 24-word params and flag bits mean? |
Public documentation and the executable's call sites. Log the words and accept any flag bits; do not treat a wrong params layout as fatal until the fields are understood. |
| 2 | Which Xbox device/heap/queue/command-list slots differ? Prior art measured device slots 62 and 76 and descriptor-heap slots 9/10; slot 14 is the public CreateDescriptorHeap, with only the returned heap's start-handle return wrapped. Partly measured with the FSR DLL (d3d12_command_objects.md §3.5a): device slots 14, 15, 16, 18, 19, 27, 38, 62 and 76 at their expected shapes (24 in the code, not called), slot 67 a console-only pipeline call; command-list slots 14, 15, 25 and 26 at their PC positions, then shifted (+4 from SetDescriptorHeaps at 32, +2 at ExecuteIndirect at 61), with console-only methods at 85 and 141. The BVH builder's call sites add the rest of the +4 root group (37, 39, 43, 45) and console slots 71, 73, 80, 146 (the GCL7 Barrier) and 148 (an upload allocator whose pointer is also the GPU address) (d3d12_command_objects.md §3.3, §3.3a). A second, retail-title measurement adds console slots 83 (CopyTextureRegion), 84 (CopyResource), 26 (barriers), 127 (direct mesh dispatch — not the PC position, GCL6 slot 79), 59 (a second indirect/mesh dispatch path) and 96 (an async-compute budget call) (section 7). Presentation slots 78-81 are measured (§7.1); the rest of presentation, queue and fence slots remain unknown. |
Trace every QueryInterface and every method slot with per-slot hit counters. A wrong slot shows as an immediate crash or wrong argument; compare against the SDK vtable. |
| 3 | How does the console map a root signature to s0..s31 (order, per-stage visibility, spills above 32 dwords, static samplers, direct-heap base)? |
Compute partly measured by a sibling project's console-compiler output (section 7): parameters inline in user SGPRs from s4 in root order while each fits whole; the first that does not fit, and all after it, go into a packed array addressed by a 40-bit pointer at s[0:1]; thread-group ids follow the user SGPRs. That matches this repo's CS census (lowest CS pointer SGPR s4). VS/PS/MS bases remain open. Static samplers: no sampling instruction was found reading one from a driver table (SHADER-735, section 3.5; 0.66% undetermined); which S# is a static sampler remains open. Dump the game's root-signature blobs with the host deserializer; mask the 0x03000000 flag byte on a copy first; match against the per-shader user-SGPR read sets. If a signature exceeds 32 dwords, reverse the spill pointer from the shader. |
| 4 | Are Xbox descriptor bytes GFX10 T#/S#, and what are the heap increments? Does the game use Create*View or build descriptors itself? |
Dump a shader-visible heap after the first CreateShaderResourceView and after the first draw; compare the bytes the shader loads with the T# parser. The start-handle return ABI is known (RAX). The game calls GetDescriptorHandleIncrementSize itself (ten device sites, all five heap types, section 3.4) and sizes heaps and handles from the answer; the numeric console values still need measuring, by hooking slot 15 and logging the answer. |
| 5 | What is the buffer/descriptor/code VA range, and what arena capacity is needed? | Log every GetGPUVirtualAddress and every descriptor base; track the high-water mark. Choose a capacity; grow at a frame boundary if needed. |
| 6 | Which swapchain/present path is used: DXGI, PresentX, or both? |
Answered for the device half (measured, §7.1): the game calls the frame-event device slots 78-81 on its device pointer, the same path the GDKX samples use; those samples present with PresentX and no DXGI swapchain (DXGI only for IDXGIDevice1→adapter→output). Still open: the queue PresentX slot the game calls, SuspendX/ResumeX, the D3D12XBOX_* layouts, and whether it also creates a swapchain. Check imports and the first present call. Implement the PresentX + frame-event presenter first; keep DXGI swapchain as fallback. |
| 7 | Does the game build acceleration structures through the standard D3D12 calls or through XboxBvhBuilder's own compute path? |
Log BuildRaytracingAccelerationStructure, CopyRaytracingAccelerationStructure, Emit...PostbuildInfo, and the builder's command-list method calls on the first RT frame. The builder's container carries a DXIL bitcode blob and a console XBCH record; the record is FSSM and all 52 programs pass spirv-val (embedded_shaders.md). If the builder path is used, translate the XBCH record rather than the bitcode. |
| 8 | What are the layouts of D3D12XBOX_XDXR_STREAM_DESC, the batched build desc, and the offline statistics desc? |
Measured from XboxBvhBuilder.dll's reads (xdxr.md): BATCHED_DESC2 (0x50) and XDXR_STREAM_DESC (0x10) with every field's offset, and the stream records' offsets, types and defaults. Still open: the record names, and the offline statistics layout, which the DLL never writes (it rejects that postbuild type). |
| 9 | Xbox texture creation is device slot 76 with layout 0x101 (tiled) or 0x1 (row-major). What is the tiled data layout, and does the game upload console-tiled or DCC data? |
Trace slot 76, CopyTextureRegion and the resource descs. If the game uploads console-tiled data, add a detile step or a matching layout. |
| 10 | Does the game use binning, DCC, VRS, wave MMA, stream output, tessellation, or amplification shaders? | Shaders: answered by tools/feature_scan.py over all 26,503 (1.0.2.1): no hull, domain or amplification shader (DXIL program kinds: 2,236 VS, 12,101 PS, 195 GS, 2,689 CS, 9,282 MS); no WAVE_MMA or SHADING_RATE in any SFI0, and no v_mfma/v_wmma/v_smfmac in the disassembly; no output-signature element on a stream other than 0 (all 195 GS write stream 0 only) and no GDS / ds_ordered_count / GWS instruction, so no stream-output path. Also from SFI0: 10 PS need ROVs (pixel interlock), 30 shaders TILED_RESOURCES (see #18), 685 ATOMIC_INT64_ON_TYPED_RESOURCE. Binning and DCC are not shader-visible; they stay open for the PSO/stream subobjects. |
| 11 | What should CheckFeatureSupport answer for UMA, resource binding tier, mesh tier, RT tier? |
Implemented (D3D-11). Reports truthful host architecture (discrete desktop GPU: non-UMA), ResourceBindingTier 3 (descriptor indexing / bindless support), 48-bit GPU virtual address support matching the arena, and maps D3D12_FEATURE_FORMAT_SUPPORT to Vulkan format properties plus multisample render-target/resolve support and one quality level per supported sample count. |
| 12 | Does the game rely on async compute or copy queues for correctness? | Trace queue creation and cross-queue fences. If only performance, serialize on one queue for boot. |
| 13 | Is 144 bytes of push constants available on all target GPUs? | Resolved / Measured (D3D-14). Checked at device creation in runtime/shims/d3d12_vulkan_device.cpp. Measured across the test fleet (#166): NVIDIA (256 B), desktop AMD (256 B), and Apple M1/MoltenVK (4096 B) satisfy 144 B natively. A Radeon 680M on the Windows driver 22.40.84.06 and the earlier Intel Arc entries expose only the core minimum 128 B (maxPushConstantsSize == 128), but an Arc B580 on Windows 11 (driver 32.0.101.9175) reports 256 B (#166), so the 128 B figure for Arc depends on the OS or driver; an Arc result on Linux (Mesa ANV) would settle which side it is. d3d12_vulkan_device_test accepts either answer and checks that the fallback flag matches it. Below 144 B, the device logs a warning and marks push_constants_need_fallback, routing the 16-byte tail (dwords 32..35: heap base and code base) to a uniform-buffer fallback. |
| 14 | Are there PSOs with two code-base stages? | No: 0 of 25,471, measured per PSO (tools/pso_code_base_pairs.py, section 5.2). Per stage (tools/feature_scan.py, s_getpc_b64 kept for data rather than a far branch): 54 VS, 93 PS, 266 MS, 263 CS, 0 GS; the translator's uses_code_base gives the same counts (with LLVM 23 that needs #223, without which these 1,471 shaders are rejected). The pairing is in shaders.rpf after all, in the pipeline library (shader_library.md §3): each graphics record names a program per stage slot and a stage's resource-layout blob carries the digest of the container its code came from, which joins to the translation index. So one 144-byte block with one code base at dwords 34–35 is enough for this package; the per-stage slot stays a fallback, and the runtime's refusal of a PSO whose two stages both read the code base (section 3.2) can stand. |
| 15 | Is ExecuteIndirect used with signatures Vulkan cannot express directly? |
Trace CreateCommandSignature and ExecuteIndirect; implement simple signatures first, expand the complex ones with compute. The simple signatures are D3D-17 (#313). |
| 16 | Does the game use append/consume UAV counters or typed buffer formats the translator does not model? | Shaders: answered by tools/feature_scan.py over all 26,503 (1.0.2.1, disassembled with LLVM 21.1.8 for gfx1013; SHADER-65). No append/consume counters: none of the 445,394 PSV0 binding records is a structured UAV with a counter, and there is no ds_append/ds_consume/GDS instruction. Typed buffers are declared in 5,359 shaders as SRVs (17,328 records) and in 2,177 as UAVs (4,005). MTBUF (format in the instruction): 52,890 loads in 10,278 shaders, all in five formats the translator decodes (16_16_SNORM 24,881, 8_8_8_8_UNORM 19,835, 8_8_8_8_UINT 5,099, 2_10_10_10_UNORM 2,648, 16_16_16_16_UINT 427), and no MTBUF store. MUBUF buffer_*_format_* (format from V# word 3): 90,316 accesses (84,908 loads, 5,408 stores) in 11,591 shaders; word 3 comes from a scalar load in 88,924 of them, is computed in 1,390, and is a literal in 2 (FORMAT 0, INVALID, which reads 0 on the hardware and in the translator). So the shaders fix no MUBUF format: the descriptors the executable writes decide it. Still open: which formats those descriptors carry; the runtime can log a V# format outside Gen.FORMATS (those read 0 today) when the descriptor is created or copied. Trace UAV descs and shader buffer_* ops; extend the translator/runtime together. Runtime side done, console side open: the layer writes typed buffer V#s and a counter V# (a hypothesis for where the shader finds it, section 3.4 "Buffer UAVs"); whether the game uses either is for the trace. |
| 17 | Do upload/readback resources ever reach shaders (as vertex/index buffers or descriptors), and does the -heap_base bias work for them? |
Trace CreateCommittedResource heap types and every VB/IB/descriptor that points at an upload resource; test the bias with a synthetic draw. |
| 18 | Does the game alias buffers/images in a heap, or use reserved/tiled resources? | Trace CreatePlacedResource ranges, aliasing barriers, CreateReservedResource and tile mappings. If yes, implement shared memory per heap range or fall back to linear allocations with a clear log. Shaders: 30 declare TILED_RESOURCES in SFI0 (tools/feature_scan.py), so reserved/tiled resources are likely used. Placed resources are D3D-16 and reserved resources D3D-20 (#313). |
| 19 | What do the 0x03000000 root-signature flag bits mean? |
Masking them on a copy works around the PC serializer; the semantics remain unknown. Origin measured (section "Root-signature flag quirk"): in the package only XboxBvhBuilder.dll sets them, in its 52 compiled RTS0 parts and unconditionally at 0xc30e before serialising; the FSR DLL's 29 RTS0 parts carry 0. Compare against the public flag enum and observe the game's behaviour with and without the mask; check whether the executable's root signatures carry them. |
| 20 | Which of the BVH builder's 52 FSSM programs does the game actually use, and do the translated programs match a reference? |
Dump the slot-62 compute PSOs on the first RT frame and map each to its container by the ILDN name; 51/52 pass spirv-val today and the one missing rule is named in embedded_shaders.md; compare against the builder's CPU validation (CpuValidateResultX) or a captured reference. 42/52 pass spirv-val today and the four missing rules are named in embedded_shaders.md; compare against the builder's CPU validation (CpuValidateResultX) or a captured reference. |
| 21 | Which Metadata values and blob format does the console's PIX use for SetMarker/BeginEvent? The layer reads 0 and 1 as strings and labels 2 (the PC PIX3 blob) PIX event (section 4.10). |
Log the Metadata values the game passes; if it is 2, decode the console blob from the executable's PIX calls rather than assuming the PC WinPixEventRuntime layout. |
| 22 | Does the game ask CheckFeatureSupport(D3D12_OPTIONS5) for RaytracingTier and switch ray tracing off when it reads NOT_SUPPORTED? The layer answers NOT_SUPPORTED because full DXR (CreateStateObject, DispatchRays) is not implemented, even though the XDXR acceleration-structure path the game's own traversal shaders use is (bvh.md §7a). On the console, ray tracing is always present, so the game may never ask. |
The first-boot trace (--trace-d3d12) logs every CheckFeatureSupport call and its answer. If the game asks and gates its RT on the tier, decide with the maintainer whether to report TIER_1_0/1_1 for this game while DispatchRays stays unimplemented; until then, keep the conservative answer. |
9. Risks and non-goals
Risks.
- Xbox ABI deviations. The device vtable is mostly public but not uniformly: slot 76 adds texture creation,
slot 62 is compute-PSO creation for the BVH builder, descriptor-heap slots 9/10 return in RAX, and root signatures
carry
0x03000000. Use a per-slot proxy with counters; presentation, command-list, queue and fence slots remain unknown. A wrong return convention or slot mapping corrupts state rather than failing cleanly. - Root-signature mapping. A wrong
s0..s31packing produces silently wrong rendering, not a crash. The per-shader read-set metadata and a strict mismatch check are the mitigation. The0x03000000flag mask is a workaround, not an explanation. - The arena. A single BDA arena is required by the shader contract for buffers, descriptor tables and code; the
game's buffer working set may exceed
maxBufferSizeor PC VRAM. Host-visible arenas are slow; device-local arenas need staging and careful upload/readback handling. This is the main performance risk. - Hash-table cost. Every image/sampler access hashes a T#/S# and probes a storage buffer. Measured (D3D-56, section 5.1) on an RTX 5080 (driver 621.24): in
DEVICE_LOCALVRAM the lookup itself stays fast up to 100k entries (wave-uniform full sweeps3.3–12.8 us/1M, divergent hits24–72 us/1M), whereasHOST_VISIBLE | HOST_COHERENTsystem memory slows uniform full sweeps 16x–36x and divergent lookups 210x–879x at 10k–100k entries;bc8e604's bounded slot relocation keeps the 100k table at20.00 MiB(19.07%load,max_probes=8) instead of doubling. The runtime now keeps that table inDEVICE_LOCALmemory and uploads only the slots that changed, from a mapped staging copy, with the copy and its barrier in the command buffer that will read it (D3D-76; 46.2x on a divergent miss at 100k on an RTX 2060 SUPER). Improving slot placement within the 8-probe window is the open optimisation (SHADER-100); Intel, RTX 5070 Ti Laptop and AMD RDNA3 are measured in section 5.1; Apple numbers remain open viavk_descriptor_bench. - Wave64. A native wave64 shader needs a 64-wide subgroup in its stage: AMD (Windows driver, RADV on GFX10+) can require
it for compute, mesh and pixel shaders, NVIDIA cannot (32 only). There, compute and mesh shaders translated with
--wave64-emulateare exact; wave64 pixel, vertex and geometry shaders have no emulation and keep the translator's 32-wide approximation (cross-half ops are approximate). This is a known fidelity gap, not specific to the layer. - Xbox tiling/DCC. Slot 76 and layout
0x101are known, but the tiled data layout, detile path and DCC remain unknown. If the game assumes console tiling or compression metadata, the layer needs a detile/repack step. - BVH builder shaders. The container's DXIL bitcode is Xbox DXIL that PC drivers reject; its console
XBCHrecord isFSSM, and all 52 programs passspirv-valthrough the same translator as the game (embedded_shaders.md). Translation is not execution: there is no GPU reference for any of the 52 yet. - Ray tracing. The game's RT work includes 64 compute shaders that traverse AMD-format BVH nodes, and it ships a BVH builder; a standard D3D12 AS path may also exist. If it is used, the layer must build AMD-format nodes, not a Vulkan AS.
Non-goals.
- Xbox One ESRAM or
d3d12_x(the Xbox One flavour); this is a Series build. - D3D11, D3D12 video, protected content, cross-process sharing, meta commands, DRED tooling.
- A general D3D12 compatibility layer for arbitrary applications.
- Any use of game data, keys or decryption.
- Copying code, headers or generated stubs from the GPL-2.0-only prior art; its ABI/format facts are cited with links only.
- Replacing the translator's shader contract. The layer adapts to it; changes to it (per-stage code base, extra
metadata) are coordinated with
tools/rdna2spirv.py.
10. References
Prior art (facts and links only; no code copied; GPL-2.0-only, see section 7.3):
- americas-recomp, branch
xbox-series - PLATFORM_SURFACE.md: package import surface and measured device ABI
- platform tools README: proxy,
XS_TRACE, xgr, first-run workflow - GPL-2.0 license text
Public D3D12:
- D3D12 programming guide
- Root signatures
D3D12_ROOT_SIGNATURE_FLAGS- Resource binding in HLSL
- Descriptor heaps
- Recording command lists and bundles
- Using resource barriers
- Enhanced barriers (DirectX spec)
- Executing and synchronizing command lists
- Fence-based resource management
- Queries
- Mesh shader (DirectX spec)
- Direct3D 12 raytracing
ID3D12Device10,ID3D12GraphicsCommandList7(the Win32 reference does not yet have pages forDevice11/CommandList8; the Windows SDK header defines them)
Xbox public documentation:
- Xbox graphics API reference
- Xbox
ID3D12Device::CreateCommittedResource - Xbox-GDK-Samples (MIT): SimpleDeviceAndSwapChain, FramePacing
- DirectXTK12 wiki: DeviceResources; directxtk12modelviewer (MIT); SDL2
SDL_render_d3d12_xbox.cpp(zlib) PresentXmentioned inXGameStreamingSetResolution- GDK release notes mentioning
D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY
Vulkan:
- Descriptor indexing
- Buffer device address
- Synchronization2
- Dynamic rendering
- Timeline semaphores
- Mesh shader
- Fragment shader barycentric
- Fragment shader interlock
- Subgroup size control
- Maintenance4
Appendix A: evidence and reproduction
REA was used for the PE import/export and string inventory. The XVD header and entropy scan used local .NET,
because gameos.xvd is an XVD container rather than a PE. Nothing was decrypted or executed.
A.1 gameos.xvd
- Size 348,069,888 bytes.
msft-xvdmagic at file offset 0x200; the 512 bytes before it are a high-entropy block, consistent with a signature. Using the standard XVD header layout, the first two dwords after the magic arevolume_flags = 1andformat_version = 3. - 64 KiB Shannon entropy sampled at offsets 0, 0x1000, 0x10000, 1 MiB, 16 MiB, 64 MiB, 128 MiB, 256 MiB: 6.40, 6.69, 7.68, 7.68, 7.997, 7.998, 7.997, 7.997 bits/byte.
- A chunked ASCII scan (4 MiB chunks) of the whole file found no
d3d12_xs.dll,d3d12.dll,D3D12CreateDevice,ID3D12Device,gameos, orxboxgipstrings. A token spanning a chunk boundary could be missed, but the entropy result does not depend on the scan. - Conclusion: the payload is encrypted or compressed. It cannot supply the D3D12 API surface without keys, which are out of scope. No key search or decryption was attempted.
Reproduce: read the first 4 KiB, locate msft-xvd; compute per-block entropy; scan for the ASCII tokens above.
The file is an XVD container, not a PE; PE-oriented import tools do not apply.
A.2 XboxBvhBuilder.dll
- Size 884,224 bytes; PE32+ x86-64; export directory RVA 861,536, 12 named exports.
- The exported C++ signatures name:
ID3D12Device11(constructor, rehydration),ID3D12GraphicsCommandList4(standard build, copy, CPU validation),ID3D12GraphicsCommandList6(batched build),ID3D12GraphicsCommandList8(batched rehydration),D3D12XBOX_XDXR_STREAM_DESCandD3D12XBOX_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_BATCHED_DESC2,D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESCand the standard build/copy/prebuild types.
- Imports:
d3d12_xs.dll!D3D12SerializeVersionedRootSignature(ILT RVA 864,368, IAT RVA 148,048) andxmem.dll!XMemVirtualQuery(ILT RVA 864,384, IAT RVA 148,064). No other console graphics imports. - GUID byte scan against the Windows SDK
d3d12.hfoundIID_ID3D12PipelineStateat file offset 0x0c9ed8 andIID_ID3D12RootSignatureat 0x0c9ee8. Presence in a read-only data table is evidence of the interface version the DLL was compiled against, not proof that every method is called.
Reproduce: rea.inspect_native_exports and rea.inspect_pe_imports on the DLL, then a byte scan for the
little-endian GUIDs from d3d12.h.
Constructed by runtime/test/bvh_builder_test.cpp (1.0.2.1: rt::Loader, Loader::initialise() for TLS and
DllMain, .pdata registered by the loader (#176), then XboxBvhBuilder(ID3D12Device11*, bool)
on a PC device behind the Xbox-ABI proxy). Measured:
- 0 unimplemented imports;
D3D12SerializeVersionedRootSignatureandXMemVirtualQuerybind to shims. The constructor writes 24 bytes of the object (sizeof(XboxBvhBuilder)>= 24; the rest of its state is elsewhere). It prints nothing throughOutputDebugStringand never callsTerminateProcess. On failure it throws the failingHRESULTas a C++long. - Device slot 62 is called as
(desc, 0, 0, &IID_ID3D12PipelineState, out), with a plainD3D12_COMPUTE_PIPELINE_STATE_DESC(root signature set, node mask 0, flags 0). The proxy used to read(desc, riid, out), so the first call returnedE_POINTERand the constructor threw it. - With slot 62 read that way, on WARP the constructor returns after 62 ms: 17 root signatures (slot 16) and 53
compute PSOs (slot 62, 53 of 53
S_OK), CS bytecode 4–75 KB each.~XboxBvhBuilderreturns and makes no device call. Created is not the same as correct: the container's DXIL bitcode is Xbox DXIL with@xbox.*intrinsics (section 7.2), its consoleXBCHrecord isFSSM, and nothing has been dispatched yet. - NVIDIA (RT-54). On an RTX 3060 (616.64), an RTX 4090 (621.14) and an RTX 5070 Ti (621.24), all on Windows 11,
the first 48 PSOs return
S_OK, and the 49th (38,248 bytes) never does. Some runs returnE_OUTOFMEMORYfor it, which the constructor throws. Other runs end the process insidenvwgf2umx.dllwith0xC0000409, after the driver's LLVM 7.0.1 bitcode reader printsInvalid recordorNever resolved value found in function. That can't be caught. The D3D12 debug layer prints nothing first.- Cause: the input, not Leonida. The proxy passes the bytecode through unchanged, so nothing is wrong in what
it forwards. The input is the problem:
LEONIDA_BVH_RECORD62=1 LEONIDA_BVH_DXIL=1shows that every one of the 53 PSO calls (52 distinct containers) is signed, has the same 9 parts, and is shader model 6.5 / DXIL 1.5. But dxil.dll (Windows SDK 10.0.26100) rejects all 53 (0x80aa0009): the target triple isdxil-ms-xb2and the module carriesxbox.compiler.optionsmetadata. Most also have Xbox-only externals (44 of 53),extractvalueon non-DXIL types (16) or other disallowed instruction types (5). No PC driver has to accept this, and WARP happens to. - What sets the 49th apart: one error kind. It is the only shader of the 53 that the validator reports for a
resource in a function signature (a non-entry function that takes a resource). Its other counts are 265
extractvalue, 6 Xbox externals and 514i64mentions; the 36th shader has the same 265 and 468 and is created. - Workaround: the test uses WARP on every hardware vendor. AMD doesn't take these shaders either: on an RX 7900
XTX (32.0.32029.2010) the constructor faults with
0xC0000005right after the first slot 62 call (RT-89, #166). Sobvh_builder_testuses WARP whenever there is a hardware adapter, unlessLEONIDA_BVH_HARDWARE=1, and it prints the reason with the adapter's PCI vendor id. WARP creates all 53 PSOs, and the constructor and destructor return. - The runtime itself still shouldn't hand Xbox DXIL to a PC driver. The same container carries the console
XBCHrecord, which decompresses toFSSM; all 52 programs translate and passspirv-valtoday (embedded_shaders.md). Translating that record is the path that avoids a DXIL lowering front end (section 7.2, M6); the bitcode is a second representation.
- Cause: the input, not Leonida. The proxy passes the bytecode through unchanged, so nothing is wrong in what
it forwards. The input is the problem:
- On the Vulkan device (D3D-557). With
LEONIDA_BVH_DEVICE=vulkanthe constructor runs on the Vulkan-backed device, where slot 62 needs the translated module of each container'sFSSMprogram.make_game.pytranslates the DLL's programs into<shaders>/bvh/and the shader library reads that index (embedded_shaders.md section 7). Measured on 1.0.2.1: before that step creation #1 failed (E_FAILwith no library,E_INVALIDARGwith the game's corpus loaded). With it, on an RTX 3070 (NVIDIA 610.74) and on a Ryzen 7 9700X's integrated Radeon (AMD 32.0.21042.62), both with the--wave64-emulatetranslation, 49 of the first 50 creations returnS_OKand the constructor throwsE_INVALIDARGat #50,Box16Rehydration, the one program the translator had no rule for then. Since that rule,buffer_store_short, is onmain(8f208d09a), all 53 are created on the Radeon with the emulated modules and the constructor and destructor return (embedded_shaders.md section 7,main8575d36e; the RTX 3070 was not run again). Nothing has been dispatched.
A.3 amd_fidelityfx_upscaler_xbox.dll
- Size 786,432 bytes; PE32+ x86-64.
- Import:
d3d12_xs.dll!D3D12CreateRootSignatureDeserializer(IAT RVA 164,672). - GUID byte scan found
IID_ID3D12Device(0x0472f0),IID_ID3D12Resource(0x047310),IID_ID3D12RootSignatureDeserializer(0x047320),IID_ID3D12PipelineState(0x047330),IID_ID3D12Heap(0x047340),IID_ID3D12RootSignature(0x047350),IID_ID3D12DescriptorHeap(0x0472e0) andIID_ID3D12CommandSignature(0x047300). Again, presence ≠ use. - Run through the public FidelityFX API by
runtime/test/fsr_dispatch_test.cpp(1.0.2.1:rt::LoaderandLoader::initialise(), with #93's static TLS, which the DLL's thread-safe statics need, and.pdataregistered by the loader (#176); PC D3D12 device on an RTX 4090 behind the Xbox-ABI proxy). Measured:- It maps with 0 unimplemented imports:
D3D12CreateRootSignatureDeserializerandXMemAlloc/XMemFree/XMemGetWorkingSetStatisticsbind to the shims, 82 imports to host DLLs. Its TLS template is 8 bytes with no callbacks.DllMain(DLL_PROCESS_ATTACH)returns TRUE. ffxConfigure(GLOBALDEBUG)and the CPU-only upscale queries accept the PC struct type ids: the Performance ratio is 2.0 and 3840x2160 Quality renders at 2560x1440.GET_VERSIONSfor the upscaler lists one provider,0xf5a5ca1e01001001"4.1.1".ffxCreateContextreports, through the message callback, that only one configuration is built in:maxUpscaleSize1920x1080 ("only the fixed-resolution Quality shader tables are included", so a 1280x720 render size), withHIGH_DYNAMIC_RANGE,DEPTH_INVERTEDandAUTO_EXPOSUREall required. It also requires anffxCreateContextDescUpscaleVersionin the chain; 4.1.2 is rejected as invalid, 4.1.1 and 4.0.0 are accepted.- With all of that,
ffxCreateContextreturnsFFX_API_RETURN_ERRORwith no message, no XMem allocation and no call on the device proxy, for the PC DX12 backend descriptor (0x2), for the same{header, device}layout under0x02000000,0x02000001and0x02000002, and with no backend descriptor at all.
- It maps with 0 unimplemented imports:
- The Xbox backend descriptor, measured from the DLL (Ghidra 12.2 through REA; RVAs, image base
0x180000000):ffxCreateContext(0x11d0) picks its one provider (ffxProvider_FSR4_Int8by RTTI) by finding a device in the chain: type 4 (GET_VERSIONS) at+0x18, types0x10009and0x01000002at+0x10.- The provider's create (
0xc9b0) wantsCreateContextDescUpscale(0x10000) first, checks the version descriptor (0x1000b, 4.0.0 to 4.1.1), then walkspNextfor type0x01000002:{header, device}, the device at+0x10, the same layout as the PC DX12 descriptor. Two of them, or none, isFFX_API_RETURN_ERRORwithout a message: that is what the ids above got. An optional type0x01000003sets function pointers: when the one at+0x20is set (with+0x28), the backend calls it instead ofCreateHeap(device slot 28,0x7390); what its other fields do is open. - The HRESULT checks at the calls seen here (
0x33d4,0x65b3,0x74a8) go through one helper (0x1c60):FormatMessageWof the code, thenthrow 1.
- Run with that descriptor (
fsr_dispatch_test, PC device on an RTX 2000 Ada, driver 597.06, behind the Xbox-ABI proxy): the DLL creates its backend through the proxy. Device slots called: 14CreateDescriptorHeap(5), 15GetDescriptorHandleIncrementSize, 18CreateShaderResourceView, 19CreateUnorderedAccessViewand 76 (4), plus heap slot 9GetCPUDescriptorHandleForHeapStart(Xbox RAX form). No earlier test in this repository reached slot 76 or heap slot 9 with a real client; their measured shapes hold. Slot 76 is called with the 7 arguments ofCreateCommittedResource(heap properties, heap flags, resource desc, state, clear value, IID, out; call at0x33cc), the desc being the 56-byteD3D12_RESOURCE_DESCwith layout0x101and the word 3 at+0x34.- On that GPU it stops at its 4th slot-76 texture: 1920x1080
DXGI_FORMAT_R9G9B9E5_SHAREDEXPwithALLOW_UNORDERED_ACCESS, which the NVIDIA driver refuses (E_INVALIDARG); WARP creates it. The console build creates it, so the console takes that format as a UAV. On the same GPU Vulkan has noSTORAGE_IMAGEsupport forVK_FORMAT_E5B9G9R9_UFLOAT_PACK32either (vulkaninfo, driver 597.06), so the layer needs an emulation (32-bit storage plus a pack/unpack) where a GPU lacks it. @Vonsek measured the same texture on more devices (#864): refused on an RTX 5080 (616.92), created on an AMD Radeon and on WARP, where typed UAV writes round-trip; and on both GPUs one allocation can serve both uses, a mutableR32_UINTVulkan image withE5B9G9R9_UFLOAT_PACK32in its format list, written through anR32_UINTstorage view and sampled through anE5B9G9R9view. Implemented ind3d12_vulkan_device.cppandsrc/uav_clear.h(d3d12_r9g9b9e5_uav_test): on an RTX 3060 Ti (driver 621.01,LEONIDA_FSR_DEVICE=vulkan LEONIDA_FSR_NO_STANDIN=1,LEONIDA_VK_VALIDATION=1),ffxCreateContextandffxDestroyContextboth return OK withoutstandin_slot76and with 0 validation errors. Open: a float store to that format rounds differently on PC devices (@Vonsek, #864: AMD Radeon truncates the mantissas, WARP rounds to nearest even; 609 of 794 test triples differ). Which rule the console FSR needs, and whether its shaders store floats to that texture at all (requiring shader-side packing into theR32_UINTstorage view), waits on decoding itsFSPXshaders. - With that one texture created as
R32_UINTinstead (the test's PC stand-in,standin_slot76), or as is on WARP,ffxCreateContextandffxDestroyContextboth return OK. Device slots called: 14 (5), 15 (26), 18 (10), 19 (16), 27CreateCommittedResource(4), 38GetCopyableFootprints(4), 76 (10); heap slot 9 (26). So the console device also serves the PCCreateCommittedResourceat slot 27, and slots 14, 15, 18, 19, 27 and 38 keep their PC positions for this client. No compute pipeline or root signature is created at context creation. - On that context, one
ffxDispatchrecorded into a logging command list measures the console command list: slots 14, 15, 25 and 26 are at their PC positions, thenSetDescriptorHeapsis at 32 (PC 28), the compute root setters four slots later (33, 35, 41; two of them inferred from their shapes),ExecuteIndirecttwo slots later (61), and there are console-only methods at 85 and 141. The list object also carries a write cursor and limits (+0x18,+0x28,+0x30) the DLL writes commands through while there is room. Table and evidence: d3d12_command_objects.md §3.5a. Device slot 67 is a console-only compute-pipeline call,DeserializeComputePipelineStateXin the DLL's own messages, not the PC method at that index; the proxy routes it toCreateComputePipelineState. The dispatch stops where the PC runtime refuses the DLL's compute code at slot 62: the DLL's shaders carry anACCCpart instead of DXIL, anFSPXpayload with an RDNA2 program (fspx.md). The Vulkan device takes both forms atCreateComputePipelineState: theACCCcontainer slot 62 gets, and theFSPXpayload the proxy builds from the slot-67 description's four pairs. It finds the translated module byfspx_code_sha256andfspx_state_sha256in<shaders>/fspx/index.json, whichmake_game.pywrites (fspx.md, "Build and run-time lookup";d3d12_fspx_compute_test). The pipeline answers the console slot 11 the DLL calls afterwards with 0, so no compute scratch buffer is made (d3d12_command_objects.md §3.5a). Not run here: the DLL's own dispatch on this device (fsr_dispatch_testneeds MSVC structured exception handling). - Its
throw 1reaches the caller. Before #965 the throw carried an image base of 0, because_CxxThrowExceptiondid not know manually mapped images; with #965 it carries the DLL's base, and the DLL still does not catch it on that path (measured withfsr_dispatch_testandLEONIDA_FSR_NO_STANDIN=1). xmem.dll!XMemGetWorkingSetStatisticstakes two arguments,(0x20000001, stats*), at all seven call sites; the one-argument shim wrote through the constant. Fixed inruntime/shims/xmem.cpp.
- On that GPU it stops at its 4th slot-76 texture: 1920x1080
A.4 Other DLLs and the executable
amd_fidelityfx_loader_xbox.dll,Bink2Scarlett.dll,libHttpClient.GDK.dll,XCurl.dll: nod3d12_xsimports.- The package layout XML, chunk 1001, lists
game_scarlett_master.exe; the file is absent from the folder. One claim in this document comes from running the executable from a player's own copy: how it calls device slot 26 (section 4.1; register roles and argument values only). No other claim depends on the executable's contents. - The repository's existing import survey (
docs/design.md, "Baseline already recorded") records that the 16 bundled DLLs need onlyxmemand the twod3d12_xsroot-signature calls; our scan of the six non-CRT DLLs is consistent.
Appendix B: interface versions seen in shipped binaries
| Interface | Evidence | Public methods beyond the previous version |
|---|---|---|
ID3D12Device11 |
XboxBvhBuilder.dll constructor and rehydration signatures |
CreateSampler2 (public SDK) |
ID3D12GraphicsCommandList4 |
standard BVH build/copy/validation signatures | BeginRenderPass/EndRenderPass, BuildRaytracingAccelerationStructure, EmitRaytracingAccelerationStructurePostbuildInfo, CopyRaytracingAccelerationStructure, DispatchRays, SetPipelineState1 |
ID3D12GraphicsCommandList6 |
batched BVH build signature | DispatchMesh |
ID3D12GraphicsCommandList8 |
batched rehydration signatures | OMSetFrontAndBackStencilRef |
The public Xbox graphics index retrieved for this document lists interfaces up to ID3D12Device10 and
ID3D12GraphicsCommandList7; the shipped DLL names Device11 and CommandList8, which the index does not cover.
This is why the layer targets the Windows SDK's newer public chain rather than assuming the Xbox public index is
complete.