diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 20:26:00 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 20:26:00 -0500 |
| commit | 154e4ec034902deffa4b89b2cbca9a949f38baec (patch) | |
| tree | 1b2ef5656de42c172291bc6009efa4c510650815 /docs/d3d12_vulkan.md | |
| parent | eb6a08cd359d98b5777e70d54d0ae8a75879495a (diff) | |
| parent | 8a242efebf823aeb23c72d17c3d666daf0bbd3e2 (diff) | |
Merge the #984 result (main + RT-PROTON-STORY-LOAD) into #939
The base is 8a242efeb, the merge of main and #984. 68 files conflicted; they were resolved in seven groups by
one rule: the same change in two forms keeps the base's form, everything only #939 has is kept, and where the
two solve one problem in two ways the base's is the frame and #939's plugs into it.
A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with #939's additions
ported in. Device slot 57 asks #939's NativeGraphicsFactory first and falls back to the base's
proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from #939: the providers (texture lease,
raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages),
the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: #939's
duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in.
A2 (xs_proxy_mock_test.cpp): the base's test with #939's slot 70 raw-buffer case; presentation cases follow
#939's rule that a device which ever had a handler has no queue fallback.
B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h,
pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; #939's pending_base_compile
and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps
the base's signature; #939's deferred backing is folded into the base's placed-memory binder. #939's quad
lists as triangle indices.
B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list,
shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where
both carry the same case, #939's cases added (rebound tables, linear texture map, large vertex batch,
executable shaders, default A8 views).
C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h,
rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp,
replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its #1055 release rule and its
rectangle generator; #939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the
label fence on the base's submit.
D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test,
main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with
#939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's
answering first; --first-run-ui kept without host speech in its profile.
E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py,
scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's
v_dot4 decode, #281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the
base's executable-shader step with #939's cache fix; 366 registered tests.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'docs/d3d12_vulkan.md')
| -rw-r--r-- | docs/d3d12_vulkan.md | 311 |
1 files changed, 260 insertions, 51 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 14f6cbc6e..2fcf569f6 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -91,7 +91,21 @@ enough for the bundled middleware's `d3d12_xs` calls, not for the game. The laye | |||
| 91 | slot 62 where the PC interface it forwarded to presents `CreateStateObject` (different arity), and descriptor-heap | 91 | slot 62 where the PC interface it forwarded to presents `CreateStateObject` (different arity), and descriptor-heap |
| 92 | start handles returned in RAX at heap slots 9/10. Implement the public chain plus those measured overrides | 92 | start handles returned in RAX at heap slots 9/10. Implement the public chain plus those measured overrides |
| 93 | explicitly; do not assume every slot. On the retail executable's higher device slots (`runtime/shims/d3d12_xs_device.cpp`), | 93 | explicitly; do not assume every slot. On the retail executable's higher device slots (`runtime/shims/d3d12_xs_device.cpp`), |
| 94 | slot 86 routes `CreatePipelineState(desc, riid, out)` to PC slot 47 (`ID3D12Device2::CreatePipelineState`), | 94 | slot 86 routes `CreatePipelineState(desc, riid, out)` to PC slot 47 (`ID3D12Device2::CreatePipelineState`) and keeps |
| 95 | a deep copy of the stream on the PSO it returns; slot 55 (`CreateDerivedPipelineState(pBasePSO, n, pRecords, riid, | ||
| 96 | out)`, `n` = 1..4 records of 0x14c bytes: a u32 tag, then the payload at +4) patches a copy of that stream and creates | ||
| 97 | the PSO through the same path. Tags 0 (`D3D12_DEPTH_STENCIL_DESC`, on DEPTH_STENCIL or DEPTH_STENCIL1), 1 | ||
| 98 | (`D3D12_RASTERIZER_DESC`), 2 (`D3D12_BLEND_DESC`) and 3 (sample mask) are the TomBox layout (GPL-3.0, | ||
| 99 | `create_derived_pso_x`), checked against the title's record writes in the retail build (RVA 0x2479f40): tag 1 is the | ||
| 100 | 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) | ||
| 101 | is served although that function does not write it. Tag 5 (0x16 bytes: 16 zero bytes, then the StencilReadMask and | ||
| 102 | StencilWriteMask bytes at the DEPTH_STENCIL offsets 0x10/0x11, then zeros) overlays only those two bytes of the base's | ||
| 103 | DEPTH_STENCIL or DEPTH_STENCIL1, in record order; this is inferred from the title's writes, not measured at run time. | ||
| 104 | Any other tag, or a base that | ||
| 105 | was not created through slot 86/55, is refused (`E_INVALIDARG`/`E_FAIL`, null output). The stream | ||
| 106 | copy lives in `runtime/shims/d3d12_xs_pso_stream.cpp` and goes with the PSO (private data, released with it), | ||
| 107 | `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE` values that the module does not walk (VIEW_INSTANCING) are not kept, | ||
| 108 | so a PSO built from them is refused as a base, | ||
| 95 | slot 101 routes `CreateStateObject(desc, riid, out)` to PC slot 62 (`ID3D12Device5::CreateStateObject`), and | 109 | slot 101 routes `CreateStateObject(desc, riid, out)` to PC slot 62 (`ID3D12Device5::CreateStateObject`), and |
| 96 | slot 108 routes `GetResourceAllocationInfo2` (accepting the console C-ABI struct return with the return buffer in | 110 | slot 108 routes `GetResourceAllocationInfo2` (accepting the console C-ABI struct return with the return buffer in |
| 97 | `RCX` and the device in `RDX`, expanding 56-byte `D3D12_RESOURCE_DESC` entries to `D3D12_RESOURCE_DESC1` and | 111 | `RCX` and the device in `RDX`, expanding 56-byte `D3D12_RESOURCE_DESC` entries to `D3D12_RESOURCE_DESC1` and |
| @@ -152,7 +166,8 @@ The design is therefore an **IR per command list**: | |||
| 152 | - `Close` freezes the IR. `ExecuteBundle` is 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. | 166 | - `Close` freezes the IR. `ExecuteBundle` is 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. |
| 153 | - Bundle restrictions are checked while recording for the IR operations currently implemented here (barriers, clears, copies, resolves, `SetPredication`, `DiscardResource`, the atomic copies, `RSSetViewports`, `RSSetScissorRects`, `OMSetRenderTargets` and `ClearState`; `WriteBufferImmediate` is allowed in a bundle); those calls are not legal inside a D3D12 bundle and make `Close` return `E_INVALIDARG`. `d3d12_bundle_forbidden_test` measured the last four on the PC runtime without the debug layer: the bundle's `Close` fails (`E_FAIL`, where this layer gives `E_INVALIDARG`) on the default adapter and on WARP, and executing a bundle whose `Close` failed crashes the runtime, so the layer refuses it in `ExecuteBundle` instead. 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, and `ExecuteBundle` plays 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_test` measured 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. After `ExecuteBundle` the 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's `Close` fail, not the bundle's. A per-list state setter must go through the deferred path (`defer()` in `d3d12_com.cpp`, replaying through a private member that does not trace) to work in a bundle. Not deferred yet: `ExecuteIndirect` in a bundle, and bundle `Dispatch` has no GPU test. | 167 | - Bundle restrictions are checked while recording for the IR operations currently implemented here (barriers, clears, copies, resolves, `SetPredication`, `DiscardResource`, the atomic copies, `RSSetViewports`, `RSSetScissorRects`, `OMSetRenderTargets` and `ClearState`; `WriteBufferImmediate` is allowed in a bundle); those calls are not legal inside a D3D12 bundle and make `Close` return `E_INVALIDARG`. `d3d12_bundle_forbidden_test` measured the last four on the PC runtime without the debug layer: the bundle's `Close` fails (`E_FAIL`, where this layer gives `E_INVALIDARG`) on the default adapter and on WARP, and executing a bundle whose `Close` failed crashes the runtime, so the layer refuses it in `ExecuteBundle` instead. 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, and `ExecuteBundle` plays 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_test` measured 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. After `ExecuteBundle` the 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's `Close` fail, not the bundle's. A per-list state setter must go through the deferred path (`defer()` in `d3d12_com.cpp`, replaying through a private member that does not trace) to work in a bundle. Not deferred yet: `ExecuteIndirect` in a bundle, and bundle `Dispatch` has no GPU test. |
| 154 | - What `Close` returns after one recorded call is compared with the PC runtime over WARP (no debug layer) by | 168 | - What `Close` returns after one recorded call is compared with the PC runtime over WARP (no debug layer) by |
| 155 | `d3d12_close_parity_test`, 113 cases on fresh lists, nothing executed. 82 agree; the other 31 are listed in the | 169 | `d3d12_close_parity_test`, 116 cases on fresh lists, nothing executed. 85 agree (three of them enhanced texture |
| 170 | barriers, two into `LAYOUT_UNDEFINED`: section 4.3); the other 31 are listed in the | ||
| 156 | test as known differences. In 16 the layer fails a list WARP closes: draws and dispatches with no pipeline, | 171 | test as known differences. In 16 the layer fails a list WARP closes: draws and dispatches with no pipeline, |
| 157 | root arguments before a root signature, a `CopyTextureRegion` box that is empty or inverted, footprint to | 172 | root arguments before a root signature, a `CopyTextureRegion` box that is empty or inverted, footprint to |
| 158 | footprint or at an unaligned footprint offset or pitch, `CopyResource` of a resource onto itself, | 173 | footprint or at an unaligned footprint offset or pitch, `CopyResource` of a resource onto itself, |
| @@ -377,9 +392,8 @@ What is implemented (all of it testable without the game): | |||
| 377 | SDK's `d3d12.h` by `tools/gen_d3d12_stubs.py`. The stub reports its name once, so the vtables follow the SDK | 392 | SDK's `d3d12.h` by `tools/gen_d3d12_stubs.py`. The stub reports its name once, so the vtables follow the SDK |
| 378 | order exactly and nothing derived from the SDK is checked in. Unknown IIDs are logged and refused. Resources | 393 | order exactly and nothing derived from the SDK is checked in. Unknown IIDs are logged and refused. Resources |
| 379 | are identified by their `ID3D12Resource` pointer, and RTV/DSV CPU handles point at a `TargetView`. | 394 | are identified by their `ID3D12Resource` pointer, and RTV/DSV CPU handles point at a `TargetView`. |
| 380 | `OMSetFrontAndBackStencilRef` records its two `UINT`s on the list (and `Reset` clears them), but nothing applies | 395 | `OMSetFrontAndBackStencilRef` records its two `UINT`s on the list (and `Reset` clears them); each draw sets them |
| 381 | them yet: Vulkan can set the faces with `vkCmdSetStencilReference` and a face mask, but only a pipeline that | 396 | with `vkCmdSetStencilReference` and a face mask. |
| 382 | consumes the dynamic state can, and this layer has no pipeline or draw path. | ||
| 383 | - **Device** (`runtime/shims/d3d12_vulkan_device.cpp`): an `ID3D12Device11` (PC ABI, 80 slots) that the Xbox-ABI | 397 | - **Device** (`runtime/shims/d3d12_vulkan_device.cpp`): an `ID3D12Device11` (PC ABI, 80 slots) that the Xbox-ABI |
| 384 | proxy (`d3d12_xs_device.cpp`) forwards to, so slot 14's heap-handle conversion and slot 76's resource creation | 398 | proxy (`d3d12_xs_device.cpp`) forwards to, so slot 14's heap-handle conversion and slot 76's resource creation |
| 385 | work unchanged. It creates the objects above, plus: | 399 | work unchanged. It creates the objects above, plus: |
| @@ -464,7 +478,9 @@ What is implemented (all of it testable without the game): | |||
| 464 | format instead: its RTVs, PSO `RTVFormats` and clears use the alpha channel, its SRVs view it in the same format | 478 | format instead: its RTVs, PSO `RTVFormats` and clears use the alpha channel, its SRVs view it in the same format |
| 465 | (the T# names its one channel X, gfx10's `channels_a`), and format support adds `RENDER_TARGET` and | 479 | (the T# names its one channel X, gfx10's `channels_a`), and format support adds `RENDER_TARGET` and |
| 466 | `BLENDABLE`. Vulkan puts A8 in a compatibility class of its own, so the two kinds of A8 texture cannot share | 480 | `BLENDABLE`. Vulkan puts A8 in a compatibility class of its own, so the two kinds of A8 texture cannot share |
| 467 | an image. A castable-format list naming `A8_UNORM` itself is a no-op; any other format in it is refused with | 481 | an image, and `vkCmdCopyImage` refuses a copy between them (`VUID-vkCmdCopyImage-srcImage-01548`): |
| 482 | `CopyResource` and `CopyTextureRegion` between the two go image → transfer scratch → image, as depth ↔ colour | ||
| 483 | copies do, one byte per texel (`d3d12_a8_copy_test`). A castable-format list naming `A8_UNORM` itself is a no-op; any other format in it is refused with | ||
| 468 | `E_INVALIDARG` for such a render target, since no other format can view its image. Without that format, | 484 | `E_INVALIDARG` for such a render target, since no other format can view its image. Without that format, |
| 469 | render targets are refused as before; depth-stencil and UAV creation are | 485 | render targets are refused as before; depth-stencil and UAV creation are |
| 470 | unsupported for this format. | 486 | unsupported for this format. |
| @@ -626,6 +642,9 @@ side inwards: | |||
| 626 | covers a full 2048-sampler D3D12 heap plus room for literal and static S#s. | 642 | covers a full 2048-sampler D3D12 heap plus room for literal and static S#s. |
| 627 | - 2D images: up to 65536. | 643 | - 2D images: up to 65536. |
| 628 | - storage arrays: up to 4096 each, capped by their dimension's sampled array or by 256 for storage-only 1D arrays. | 644 | - storage arrays: up to 4096 each, capped by their dimension's sampled array or by 256 for storage-only 1D arrays. |
| 645 | - 2D-array images up to 16384, 3D and 1D images up to 4096 each (the title streams more cube maps, texture | ||
| 646 | arrays and 1D lookups than the defaults hold: each distinct T# of one takes its own index, and a native boot | ||
| 647 | filled the 1024 2D-array and 256 1D indices during the story load). | ||
| 629 | 648 | ||
| 630 | Growth leaves 64 descriptors of each limit to the other sets of a pipeline layout. It also stays within | 649 | Growth leaves 64 descriptors of each limit to the other sets of a pipeline layout. It also stays within |
| 631 | `maxPerSetDescriptors`, which never shrinks the default counts, because a layout past it may still be | 650 | `maxPerSetDescriptors`, which never shrinks the default counts, because a layout past it may still be |
| @@ -640,10 +659,10 @@ side inwards: | |||
| 640 | the last free index, `CreateShaderResourceView` and `CreateSampler` log once that the array is full, and a | 659 | the last free index, `CreateShaderResourceView` and `CreateSampler` log once that the array is full, and a |
| 641 | shader reads the fallback. `d3d12_descriptor_test` then fills each short array to its last index and checks that | 660 | shader reads the fallback. `d3d12_descriptor_test` then fills each short array to its last index and checks that |
| 642 | the next view and sampler are refused. | 661 | the next view and sampler are refused. |
| 643 | The other arrays keep their default counts. On an RTX 5070 (driver 621.24, 1048576 of each type | 662 | The MS arrays keep their default counts. On an RTX 5070 (driver 621.24, 1048576 of each type |
| 644 | and 4000 samplers) the sizing rules give 65536 2D images, 3936 samplers and 4096 storage indices in 2D: | 663 | and 4000 samplers) the set has 65536 2D images, 3936 samplers, 16384 2D-array, 4096 3D and 4096 1D images and |
| 645 | 94561 descriptors with all MS classes, 3-6 MiB at 32-64 bytes a descriptor. The device prints the counts | 664 | 4096 storage indices in each dimension: 152929 descriptors, 5-10 MiB at 32-64 bytes a descriptor. The device prints the counts it chose, and |
| 646 | it chose, and `bindless_sizing_test` checks the rules on synthetic limits. | 665 | `bindless_sizing_test` checks the rules on synthetic limits. |
| 647 | - An image view has one index in its dimension (2D, 2D array, 3D, 1D, 2DMS, 2DMS array or 1D array), shared by the | 666 | - An image view has one index in its dimension (2D, 2D array, 3D, 1D, 2DMS, 2DMS array or 1D array), shared by the |
| 648 | bindings for that dimension. The runtime adds sampled-image bindings in pairs for 2DMS and 2DMS array: | 667 | bindings for that dimension. The runtime adds sampled-image bindings in pairs for 2DMS and 2DMS array: |
| 649 | 20/21 for floating-point and normalized color, 22/23 for unsigned integers, and 24/25 for signed integers. | 668 | 20/21 for floating-point and normalized color, 22/23 for unsigned integers, and 24/25 for signed integers. |
| @@ -762,7 +781,16 @@ D3D12 queue of the device is made in `info.queue_family`. And at most 8 retired | |||
| 762 | next flush waits (logged once, with the descriptor lock released) for the submissions up to the oldest one's ticket, | 781 | next flush waits (logged once, with the descriptor lock released) for the submissions up to the oldest one's ticket, |
| 763 | which is a wait for those queues' timelines and not for the device. The commit of a submit's result runs under | 782 | which is a wait for those queues' timelines and not for the device. The commit of a submit's result runs under |
| 764 | `tracker_mutex_`, so a later flush never sees an earlier submit's outcome unrecorded. If the new generation cannot be | 783 | `tracker_mutex_`, so a later flush never sees an earlier submit's outcome unrecorded. If the new generation cannot be |
| 765 | made (out of memory) the flush leaves the in-use set and the pending writes alone and fails. | 784 | made, the submission still goes ahead. A table buffer that finds device-local memory full goes to host-visible |
| 785 | memory (slower lookups, logged once). A freed generation is kept as a spare (at most one) and reused, pool and | ||
| 786 | buffers, by the next replacing flush, so steady texture churn allocates nothing. Failing that, the flush frees the | ||
| 787 | generations that have completed and retries; when every submission is done it rewrites the current table in place; | ||
| 788 | and otherwise it degrades: the pending descriptor writes go in place as on a flush that replaces nothing (they name | ||
| 789 | new or freed indices), the table keeps what it had, so keys added since read the fallback, and the change waits for | ||
| 790 | a later flush (logged at the first and each power of two, with what could not be made). It used to fail, and | ||
| 791 | `ExecuteCommandLists` refused the whole batch, which the title treats as fatal (a native boot died that way in the | ||
| 792 | story load once device-local memory was full). `vk_bindless_grow_test` covers the churn, the host fallback, the | ||
| 793 | in-place rewrite and the degraded flush, with allocations failed on purpose. | ||
| 766 | Two bindless hazards that vkd3d-proton documents for games and that this change does not remove: descriptors | 794 | Two bindless hazards that vkd3d-proton documents for games and that this change does not remove: descriptors |
| 767 | written for resources allocated after the submit that reads them, and an image and a buffer descriptor aliasing one | 795 | written for resources allocated after the submit that reads them, and an image and a buffer descriptor aliasing one |
| 768 | heap slot (vkd3d-proton PR #3033, https://github.com/HansKristian-Work/vkd3d-proton/pull/3033). Future path, not | 796 | heap slot (vkd3d-proton PR #3033, https://github.com/HansKristian-Work/vkd3d-proton/pull/3033). Future path, not |
| @@ -848,7 +876,10 @@ The compute path, end to end: | |||
| 848 | state, since nothing would set it (`VUID-vkCmdDraw-pStrides-04913`). | 876 | state, since nothing would set it (`VUID-vkCmdDraw-pStrides-04913`). |
| 849 | `d3d12_state_sweep_test` checks the mapping against the host on the same adapter: 482 full-screen draws over | 877 | `d3d12_state_sweep_test` checks the mapping against the host on the same adapter: 482 full-screen draws over |
| 850 | every blend factor pair, blend operation, write mask, comparison function and stencil operation, with the stencil | 878 | every blend factor pair, blend operation, write mask, comparison function and stencil operation, with the stencil |
| 851 | plane read back, are byte-identical on an RTX 5080 and a Radeon iGPU. | 879 | plane read back, are byte-identical on an RTX 5080 and a Radeon iGPU. Sixteen more build the PSO from a stream |
| 880 | with `DEPTH_STENCIL2` and different masks per face, front- and back-facing, with one reference or two | ||
| 881 | (`OMSetFrontAndBackStencilRef`): 498 in all, byte-identical on an RTX 5070 Ti (driver 617.42), and 6 of the 16 | ||
| 882 | differ when the back face is given the front face's masks. | ||
| 852 | - A triangle-family PSO can draw Xbox rectangle lists. When the input assembler selects topology 17, replay | 883 | - A triangle-family PSO can draw Xbox rectangle lists. When the input assembler selects topology 17, replay |
| 853 | selects a geometry-stage variant that emits the fourth corner after vertex shading. It requires | 884 | selects a geometry-stage variant that emits the fourth corner after vertex shading. It requires |
| 854 | `geometryShader` and a vertex pipeline without an application geometry stage. A later triangle draw uses the | 885 | `geometryShader` and a vertex pipeline without an application geometry stage. A later triangle draw uses the |
| @@ -981,7 +1012,8 @@ The compute path, end to end: | |||
| 981 | - With `VK_EXT_conditional_rendering`, the arena is created with the conditional-rendering usage, and | 1012 | - With `VK_EXT_conditional_rendering`, the arena is created with the conditional-rendering usage, and |
| 982 | `SetPredication` on a default-heap buffer reads at the buffer's offset in the arena plus the call's offset. | 1013 | `SetPredication` on a default-heap buffer reads at the buffer's offset in the arena plus the call's offset. |
| 983 | - `CreateHeap` reserves the requested size in the arena at 64 KiB, and a buffer placed in it gets the heap's | 1014 | - `CreateHeap` reserves the requested size in the arena at 64 KiB, and a buffer placed in it gets the heap's |
| 984 | place plus the placed offset as its console VA. A placed texture keeps its own `VkDeviceMemory` and a null VA, | 1015 | place plus the placed offset as its console VA. A placed texture has memory of its own (a range of a |
| 1016 | shared block or its own `VkDeviceMemory`, section 3.3) and a null VA, | ||
| 985 | 1D, 2D and 3D alike (arrays and mips included), and a dimension outside the enum is `E_INVALIDARG`, as on the | 1017 | 1D, 2D and 3D alike (arrays and mips included), and a dimension outside the enum is `E_INVALIDARG`, as on the |
| 986 | host (RTX 2080 Ti and WARP, `d3d12_placed_dimensions_test`); | 1018 | host (RTX 2080 Ti and WARP, `d3d12_placed_dimensions_test`); |
| 987 | tiled (`64KB_UNDEFINED_SWIZZLE` and Xbox `0x101`) 2D/3D placed textures are backed the same way with | 1019 | tiled (`64KB_UNDEFINED_SWIZZLE` and Xbox `0x101`) 2D/3D placed textures are backed the same way with |
| @@ -1058,7 +1090,10 @@ the game's present entry point (`PresentX`; the DXGI factory/swapchain and the p | |||
| 1058 | 1000 shaders of that stage): `[rt] d3d12: <name> (<stage>) is a 64-wide shader but this device cannot require that | 1090 | 1000 shaders of that stage): `[rt] d3d12: <name> (<stage>) is a 64-wide shader but this device cannot require that |
| 1059 | subgroup size ...`. For compute and mesh the fix is the build, `--wave64-emulate` (`make_game.py | 1091 | subgroup size ...`. For compute and mesh the fix is the build, `--wave64-emulate` (`make_game.py |
| 1060 | --wave64-emulate auto` picks it for this GPU); a wave64 vertex, geometry or pixel shader has no emulation yet | 1092 | --wave64-emulate auto` picks it for this GPU); a wave64 vertex, geometry or pixel shader has no emulation yet |
| 1061 | (the ~10,000 wave64 pixel shaders are the open case on NVIDIA, SHADER-10). | 1093 | (the ~10,000 wave64 pixel shaders are the open case on NVIDIA, SHADER-10). A wave64 VS/PS/GS whose index entry |
| 1094 | carries `wave64_graphics` tier A or B is not logged as inexact: the line says it runs at the device's size and | ||
| 1095 | that the translator's partition-invariance analysis puts it in that tier, since cutting its wave into two 32-lane | ||
| 1096 | halves does not change its results (tier C and entries without the analysis keep the conservative line). | ||
| 1062 | - **Test:** `subgroup_size_test` (CPU) checks the decision against AMD-like, NVIDIA-like and old-RADV | 1097 | - **Test:** `subgroup_size_test` (CPU) checks the decision against AMD-like, NVIDIA-like and old-RADV |
| 1063 | properties and the resulting create-info chain; `d3d12_subgroup_test` (GPU) runs `cs_w64x_readlane` natively | 1098 | properties and the resulting create-info chain; `d3d12_subgroup_test` (GPU) runs `cs_w64x_readlane` natively |
| 1064 | and with `--wave64-emulate`, and `cs_wqm_w32`, through D3D12 PSOs and compares the read-back words. | 1099 | and with `--wave64-emulate`, and `cs_wqm_w32`, through D3D12 PSOs and compares the read-back words. |
| @@ -1275,8 +1310,8 @@ and any validation error fails them. | |||
| 1275 | each one's synthetic FSSM program (`; fssm-at` / `; fssm-data` in the header) to `fssm/` and the translator puts its | 1310 | each one's synthetic FSSM program (`; fssm-at` / `; fssm-data` in the header) to `fssm/` and the translator puts its |
| 1276 | SHA-256 in `spirv/index.json`, so the layer's lookup is the one the game uses; the test loads that index as it is. | 1311 | SHA-256 in `spirv/index.json`, so the layer's lookup is the one the game uses; the test loads that index as it is. |
| 1277 | An unknown program is refused. | 1312 | An unknown program is refused. |
| 1278 | - **User data:** root parameter 0 is a descriptor table (`s0:s1`, the VA of its first slot), parameter 1 four root | 1313 | - **User data:** root parameter 0 is a descriptor table (`s8`, the 32-bit VA of its first slot), parameter 1 four |
| 1279 | constants (`s2..s5`: the draw's clip offset, and a bias for the PS). | 1314 | root constants (`s9..s12`: the draw's clip offset, and a bias for the PS), in the console's graphics layout. |
| 1280 | - **Vertex fetch:** the VS has no input layout. It `s_load`s a V# the application wrote into a shader-visible slot and | 1315 | - **Vertex fetch:** the VS has no input layout. It `s_load`s a V# the application wrote into a shader-visible slot and |
| 1281 | fetches position and colour with `buffer_load_dwordx4 ... idxen`; the V# points at a DEFAULT-heap buffer in the arena. | 1316 | fetches position and colour with `buffer_load_dwordx4 ... idxen`; the V# points at a DEFAULT-heap buffer in the arena. |
| 1282 | - **Code base:** the PS starts with `s_getpc_b64` and `s_load`s four floats from offset 0x100 of its own FSSM program, | 1317 | - **Code base:** the PS starts with `s_getpc_b64` and `s_load`s four floats from offset 0x100 of its own FSSM program, |
| @@ -1504,8 +1539,8 @@ The layer therefore owns the console VAs. It returns them from `ID3D12Resource:: | |||
| 1504 | |---|---| | 1539 | |---|---| |
| 1505 | | 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`. | | 1540 | | 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`. | |
| 1506 | | 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. | | 1541 | | 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. | |
| 1507 | | Images | Each image gets a unique console VA key and lives in its own `VkDeviceMemory` (or a suballocated device-local image heap) with optimal tiling. 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. | | 1542 | | 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. | |
| 1508 | | 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 `VkDeviceMemory`; 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). | | 1543 | | 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). | |
| 1509 | | 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. | | 1544 | | 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. | |
| 1510 | | Shader code | Each FSSM blob is uploaded to the arena; its console VA is the code base. | | 1545 | | Shader code | Each FSSM blob is uploaded to the arena; its console VA is the code base. | |
| 1511 | | 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). | | 1546 | | 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). | |
| @@ -1579,7 +1614,31 @@ The copies: | |||
| 1579 | - Any **other address in the title's memory** gets a window: the 64 KiB-aligned pages it covers, clipped to the | 1614 | - Any **other address in the title's memory** gets a window: the 64 KiB-aligned pages it covers, clipped to the |
| 1580 | title's range, copied into the arena now and before every submission, through the same shadow refresh as slot 133 | 1615 | title's range, copied into the arena now and before every submission, through the same shadow refresh as slot 133 |
| 1581 | (so dirty-page tracking for that refresh applies to both). Windows stay until the device goes, up to | 1616 | (so dirty-page tracking for that refresh applies to both). Windows stay until the device goes, up to |
| 1582 | `LEONIDA_TITLE_WINDOWS_MB` (64 MiB by default). | 1617 | `LEONIDA_TITLE_WINDOWS_MB` (64 MiB by default). A window that |
| 1618 | cannot fit between the title's address reservations can use a separate mapped buffer. The buffer's device address | ||
| 1619 | must fit as a positive 47-bit offset from the arena base. The same window cap and dirty-page refresh apply. | ||
| 1620 | `LEONIDA_STREAM_BUFFER_WINDOWS=0` requires the window to fit in the arena. | ||
| 1621 | - `LEONIDA_GEOMETRY_MB` sets the device-local memory cap for streamed buffer views. The default is 0. | ||
| 1622 | A positive cap enables persistent copies of placed buffer SRVs and buffer descriptors in title memory. | ||
| 1623 | A GPU-only reservation uses its paired CPU mapping. Matching source ranges share one copy. | ||
| 1624 | The resource descriptor heap keeps its console indices and original CPU bytes. Its shader-visible copy | ||
| 1625 | encodes each resolved buffer's offset from the arena base. CPU writes through either physical mapping, | ||
| 1626 | file reads and XMem remaps invalidate the affected copies before their next submission. | ||
| 1627 | During an untyped heap scan, an extent above 16 MiB with no format or an unrecognized descriptor | ||
| 1628 | encoding reuses only an independently established geometry view. An explicit table or placed SRV can | ||
| 1629 | establish that view. The Vulkan memory probe reports populated views, payload and reserved bytes, | ||
| 1630 | upload totals, cap refusals and allocation failures. | ||
| 1631 | - **Which pages changed** since the last refresh: where xmem reserved the title's memory with `MEM_WRITE_WATCH` | ||
| 1632 | (`XMemVirtualAlloc`'s ordinary regions and the title's `VirtualAlloc` reservations, not placeholders or | ||
| 1633 | physical-page windows), the kernel says (`GetWriteWatch` with reset, its answers kept for every copy over the page: | ||
| 1634 | `leonida::title_write_watch` in `runtime/src/title_page_watch.h`); elsewhere a copied page is made read-only and the | ||
| 1635 | title's first write faults (`ShadowPages`). `LEONIDA_WRITE_WATCH=0` guards everything; under Wine that is the | ||
| 1636 | default and `=1` turns write watching on. A reservation the title releases and reserves again (at the same address | ||
| 1637 | too) is new to every copy, all of it taken as written once. The title's own `XMemGetWriteWatch` and | ||
| 1638 | `XMemResetWriteWatch` refuse a reservation write-watched for the copies, as the host refuses one that isn't. The | ||
| 1639 | write-fault handler waits for the trackers' locks while the faulting thread may hold the process heap's lock (the | ||
| 1640 | title's `XMemAlloc` blocks are `_aligned_malloc`'s), so the state changed under those locks allocates from a heap of | ||
| 1641 | the runtime's own (`leonida::host_heap`), never the process heap. | ||
| 1583 | - **Only the title's memory** gets a copy: the blocks and ranges the xmem shims hand the title (`XMemAlloc`, | 1642 | - **Only the title's memory** gets a copy: the blocks and ranges the xmem shims hand the title (`XMemAlloc`, |
| 1584 | `XMemAllocDefault`, `XMemVirtualAlloc`, the title's `VirtualAlloc`). An address anywhere else, the runtime's or a | 1643 | `XMemAllocDefault`, `XMemVirtualAlloc`, the title's `VirtualAlloc`). An address anywhere else, the runtime's or a |
| 1585 | host DLL's memory included, is left as it was and counted, as is an arena VA or a buffer the layer made. | 1644 | host DLL's memory included, is left as it was and counted, as is an arena VA or a buffer the layer made. |
| @@ -1672,8 +1731,28 @@ The game can use D3D12 descriptors in three ways, and the layer must handle all | |||
| 1672 | translator input. No stride is read at run time: static offsets of T# loads are multiples of 32 and of S# loads | 1731 | translator input. No stride is read at run time: static offsets of T# loads are multiples of 32 and of S# loads |
| 1673 | multiples of 16, so the stride is compiled into the code. In the runtime shim, `CreateRootSignature` records the | 1732 | multiples of 16, so the stride is compiled into the code. In the runtime shim, `CreateRootSignature` records the |
| 1674 | `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` and `SAMPLER_HEAP_DIRECTLY_INDEXED` root-signature flags and `SetDescriptorHeaps` | 1733 | `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` and `SAMPLER_HEAP_DIRECTLY_INDEXED` root-signature flags and `SetDescriptorHeaps` |
| 1675 | tracks the bound shader-visible heap GPU bases (`d3d12_set_descriptor_heaps`), while placing those bases into | 1734 | tracks the bound shader-visible heap GPU bases. A matched compute root signature and dispatch settle the |
| 1676 | per-stage user SGPRs remains open on question 3. | 1735 | resource base for the Prop and Tree BatchCull programs. Their two explicit tables and one constant occupy |
| 1736 | s4, s5 and s6. Both programs read the resource heap from s7, the next user dword. Supply its arena-relative | ||
| 1737 | byte address in push-constant dword 7. The shader zero-extends this dword and adds the 32-bit resource | ||
| 1738 | index shifted left by five. A 32-byte slot contains a four-dword buffer descriptor or an eight-dword image | ||
| 1739 | descriptor. The host arena BDA remains in dwords 32–33. A matching runtime trace found s7 zero with the | ||
| 1740 | resource heap bound. The PreSkin compute programs use s9. Graphics examples with resource-direct indexing | ||
| 1741 | include PS_NoStripImmutableTable at s11 and VS_TransformD at s12. Their shader inputs establish the | ||
| 1742 | destination dwords. The explicit graphics layouts and ordering for signatures with spills still need | ||
| 1743 | independent root-signature evidence. | ||
| 1744 | The runtime snapshots the bound resource and sampler heap pointers in that order after the explicit | ||
| 1745 | arguments for direct and indirect compute dispatches with an inline signature. Set | ||
| 1746 | `LEONIDA_COMPUTE_DIRECT_HEAPS=0` to restore the previous compute arguments. | ||
| 1747 | Draws do the same in the graphics layout (`pack_stage(Stage::Pixel)`, from s8, one dword per table): the | ||
| 1748 | resource heap's 32-bit shader VA goes in the dword after the explicit arguments, then the sampler heap's, each | ||
| 1749 | only when the signature has its flag, snapshotted per draw. Vertex, pixel and geometry shaders share one | ||
| 1750 | user-data block and that layout, so one write serves all three; a signature whose explicit arguments take | ||
| 1751 | s8..s10 gives s11, one whose arguments take s8..s11 gives s12 (the two program reads above). A mesh shader reads | ||
| 1752 | its arguments from s16, which is not modelled, so in a mesh pipeline only the pixel shader gets the heaps. A | ||
| 1753 | signature that keeps the s0 graphics layout, or whose arguments fill s31, gets none (logged once). | ||
| 1754 | `d3d12_graphics_direct_heaps_test` checks the recorded draws and what a vertex and a pixel shader read, with | ||
| 1755 | and without the flags. Set `LEONIDA_GRAPHICS_DIRECT_HEAPS=0` to restore the previous draw arguments. | ||
| 1677 | 3. **Game-built descriptor memory.** The game writes raw T#/S# bytes into a heap itself, without calling | 1756 | 3. **Game-built descriptor memory.** The game writes raw T#/S# bytes into a heap itself, without calling |
| 1678 | `CreateShaderResourceView`. The shaders then read those bytes exactly as in case 1. | 1757 | `CreateShaderResourceView`. The shaders then read those bytes exactly as in case 1. |
| 1679 | 1758 | ||
| @@ -2154,26 +2233,39 @@ Pipeline creation: | |||
| 2154 | and pipeline-cache UUID. When the file is absent or incompatible, the runtime starts with an empty cache. | 2233 | and pipeline-cache UUID. When the file is absent or incompatible, the runtime starts with an empty cache. |
| 2155 | The offline checker matches the runtime's layout and subgroup request for compute shaders with no descriptor | 2234 | The offline checker matches the runtime's layout and subgroup request for compute shaders with no descriptor |
| 2156 | bindings and the standard 144-byte push-constant range. | 2235 | bindings and the standard 144-byte push-constant range. |
| 2157 | The runtime also keeps what it compiled itself: `pipeline_cache.session.bin`, written from | 2236 | The runtime writes its own `pipeline_cache.session.bin` on device teardown. A compatible session file |
| 2158 | `vkGetPipelineCacheData` on device teardown and merged into the cache at the next launch with | 2237 | initializes the live cache directly if there is no offline seed. With both files present the session cache |
| 2159 | `vkMergePipelineCaches` (the offline seed and the session file cannot be passed together as one | 2238 | merges into the offline seed. `LEONIDA_DIRECT_SESSION_CACHE=0` also uses a merge when only the session exists. |
| 2160 | `VkPipelineCacheCreateInfo`). The two files are separate so a run never replaces the multi-GB corpus cache with | 2239 | The files must match the Vulkan vendor, device and pipeline-cache UUID. Vulkan supplies an opaque snapshot. |
| 2161 | the handful of pipelines it happened to compile. The session write is capped at 256 MiB | 2240 | Replacing part of the previous file would corrupt it. |
| 2162 | (`LEONIDA_PIPELINE_CACHE_BYTES=<bytes>`, `0` turns it off): a cache seeded with the corpus file returns the whole | 2241 | `LEONIDA_PIPELINE_CACHE_BYTES` caps session writes (256 MiB by default, zero disables the session file). |
| 2163 | union, which is not worth rewriting at every exit. A session file from another device, driver or pipeline-cache | 2242 | `LEONIDA_SKIP_COMPUTE=<part of a name>[,<part>...]` (`all`: every compute program) never builds the matching |
| 2164 | UUID is ignored with one line, and a write that fails (a read-only install directory) leaves the previous file. | 2243 | compute programs and drops their dispatches, direct and indirect; the first dropped dispatch of each is logged. |
| 2165 | Set `LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` to write the session file after a successful compute pipeline | 2244 | It is a way past a program that hangs the GPU while the program or its input is fixed, not a fix. |
| 2166 | compile that took at least 500 ms. A later launch can reuse the completed work if the process exits before device | 2245 | `LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` also schedules a snapshot after a successful pipeline build, |
| 2167 | teardown. The session file keeps the same size cap and atomic replacement. | 2246 | at most once per 120 seconds. It starts on the compile worker when queued builds have drained and the device |
| 2247 | has no active builds. These snapshots have an additional 512 MiB ceiling. The driver fills a mapped staging | ||
| 2248 | file directly. A successful snapshot atomically replaces the session. An interrupted write preserves the | ||
| 2249 | previous cache; the next launch removes unheld staging files older than ten minutes. | ||
| 2250 | `LEONIDA_TRACE_PIPELINE_COMPILE=1` records each graphics and compute build's trigger, thread, elapsed time, | ||
| 2251 | SPIR-V size, shader names and Vulkan application-cache feedback (1 hit, 0 miss, -1 unavailable). It also | ||
| 2252 | times cache reads, merges, writes and draw/dispatch pipeline lookups that take at least 1 ms. | ||
| 2253 | `LEONIDA_ASYNC_PIPELINES=1` schedules cold first-use builds on the warm-up worker ahead of speculative work. | ||
| 2254 | Replay skips a draw or dispatch while its pipeline is pending. Later uses find the completed handle. | ||
| 2255 | A skipped dispatch can lose a one-time resource update. Synchronous first use is the default and strict | ||
| 2256 | replay always uses it. `LEONIDA_COMPUTE_WARMUP=0` restricts the worker to pipelines requested by the title. | ||
| 2168 | `GetCachedBlob` records the vendor, device, driver version, `pipelineCacheUUID` and a SHA-256 of the description | 2257 | `GetCachedBlob` records the vendor, device, driver version, `pipelineCacheUUID` and a SHA-256 of the description |
| 2169 | without `Flags`, sealed by a checksum (`runtime/src/cached_pso.h`). The answers are the host's, measured on an | 2258 | without `Flags`, sealed by a checksum (`runtime/src/cached_pso.h`). The answers are the host's, measured on an |
| 2170 | RTX 3060 and WARP: the same description is accepted; another | 2259 | RTX 3060 and WARP: the same description is accepted; another |
| 2171 | shader, root signature content or state, a changed byte, a truncated blob or a pointer with size 0 give | 2260 | shader, root signature content or state, a changed byte, a truncated blob or a pointer with size 0 give |
| 2172 | `E_INVALIDARG`; a null pointer with a size is ignored; another adapter gives `D3D12_ERROR_ADAPTER_NOT_FOUND` and | 2261 | `E_INVALIDARG`; a null pointer with a size is ignored; another adapter gives `D3D12_ERROR_ADAPTER_NOT_FOUND` and |
| 2173 | another driver `D3D12_ERROR_DRIVER_VERSION_MISMATCH`. `ID3D12PipelineLibrary` is an in-memory map plus the Vulkan | 2262 | another driver `D3D12_ERROR_DRIVER_VERSION_MISMATCH`. `ID3D12PipelineLibrary` is an in-memory map plus the Vulkan |
| 2174 | cache. Its arguments answer as the host's (`d3d12_pipeline_library_host_test`, 74 values from 46 calls that need no | 2263 | cache. `d3d12_pipeline_library_host_test` compares public argument checks with the host. It runs each host |
| 2175 | PSO, each run on the host in a process of its own, since a call it faults on leaves its runtime broken and the next | 2264 | call in a separate process because a fault can leave the device unusable. It reports serialized sizes and the |
| 2176 | one failing fast; RTX 3060, driver 610.88): | 2265 | result of flipping a trailing byte for each device's own format. `d3d12_pipeline_library_test` checks that the |
| 2266 | layer rejects a nonzero reserved field in its `LPL1` header. On Windows 11 build 26100 (RTX 5070 Ti, | ||
| 2267 | driver 610.74), all 72 public-argument comparisons matched. The previous 74-value run (RTX 3060, driver | ||
| 2268 | 610.88) included the two results from the trailing-byte case. | ||
| 2177 | - `CreatePipelineLibrary`: a foreign, truncated or corrupt blob, the other device's blob, or a null pointer with a | 2269 | - `CreatePipelineLibrary`: a foreign, truncated or corrupt blob, the other device's blob, or a null pointer with a |
| 2178 | size is `E_INVALIDARG`, and `*ppPipelineLibrary` is left as it was. One of the layer's own blobs from another | 2270 | size is `E_INVALIDARG`, and `*ppPipelineLibrary` is left as it was. One of the layer's own blobs from another |
| 2179 | format version is `D3D12_ERROR_DRIVER_VERSION_MISMATCH`, the documented code for a cache from another driver. | 2271 | format version is `D3D12_ERROR_DRIVER_VERSION_MISMATCH`, the documented code for a cache from another driver. |
| @@ -2196,14 +2288,26 @@ The trace will enumerate them. | |||
| 2196 | - **Streams:** `CreatePipelineState` parses the stream in the d3dx12.h layout: a subobject type, then its | 2288 | - **Streams:** `CreatePipelineState` parses the stream in the d3dx12.h layout: a subobject type, then its |
| 2197 | description at that description's alignment, each subobject pointer-aligned. | 2289 | description at that description's alignment, each subobject pointer-aligned. |
| 2198 | - Every type up to `RASTERIZER2` is read. | 2290 | - Every type up to `RASTERIZER2` is read. |
| 2291 | - The Vulkan backend selects console numbering when the PC reading fails or gives AS without MS and the | ||
| 2292 | console reading has a verified DXIL kind-13 mesh stage. Slot 86 keeps that selected layout with canonical | ||
| 2293 | tags and owned shader bytes so slot 55 can derive another PSO. `LEONIDA_XS_STREAM_ENUM=pc` selects PC only. | ||
| 2294 | - With D3D12 tracing, each unsupported stream has one `PipelineStream::Refused` reason. Accepted mesh PSOs | ||
| 2295 | have a separate `PipelineStream::Mesh` count. `LEONIDA_PSO_STREAM_AUDIT=1` also prints raw tags, | ||
| 2296 | shader stages and FSSM hashes for unsupported or failed streams. The call number joins to the backend result. | ||
| 2297 | - `LEONIDA_PSO_PROFILE=1` measures wall time and calling-thread CPU time for each Vulkan pipeline creation. | ||
| 2298 | Begin and end records share an ID. | ||
| 2299 | Compute records distinguish warmup, dispatch and eager creation. Graphics records name the lazy recipe's | ||
| 2300 | stages and unbound attachment mask. Mesh draw totals are reported per command buffer with its submit result. | ||
| 2199 | - Missing subobjects take the runtime's defaults: depth test on with `LESS`, back-face culling, no blending, sample | 2301 | - Missing subobjects take the runtime's defaults: depth test on with `LESS`, back-face culling, no blending, sample |
| 2200 | mask `0xFFFFFFFF`, one sample. | 2302 | mask `0xFFFFFFFF`, one sample. |
| 2201 | - The stream becomes the same descriptions `CreateGraphicsPipelineState` and `CreateComputePipelineState` take, so | 2303 | - The stream becomes the same descriptions `CreateGraphicsPipelineState` and `CreateComputePipelineState` take, so |
| 2202 | a VS stream builds the same PSO as the classic call. | 2304 | a VS stream builds the same PSO as the classic call. |
| 2203 | - `E_INVALIDARG`, as on the PC runtime: a type given twice, an unknown type, a truncated stream, MS with VS, | 2305 | - `E_INVALIDARG`, as on the PC runtime: a type given twice, an unknown type, a truncated stream, MS with VS, |
| 2204 | tessellation or GS, CS with a graphics stage, or no stage at all. | 2306 | tessellation or GS, CS with a graphics stage, or no stage at all. |
| 2205 | - `E_NOTIMPL` with a log, for what is not built yet: an AS, a depth-bounds test, separate front and back stencil | 2307 | - `E_NOTIMPL` with a log, for what is not built yet: an AS, a depth-bounds test, view instancing. |
| 2206 | masks, view instancing. | 2308 | - `DEPTH_STENCIL2`'s per-face read and write masks go to each face's `VkStencilOpState` (the front face's in the |
| 2309 | description, the back face's beside it), so `OPTIONS14.IndependentFrontAndBackStencilRefMaskSupported` is TRUE: | ||
| 2310 | with `OMSetFrontAndBackStencilRef`'s per-face references, both of that cap's parts. | ||
| 2207 | - `RASTERIZER1`/`2`'s float depth bias is truncated to the integer the PSO path takes, with a log. | 2311 | - `RASTERIZER1`/`2`'s float depth bias is truncated to the integer the PSO path takes, with a log. |
| 2208 | - **Mesh PSO:** the MS (`ms` index entry by FSSM hash) and PS on the mesh stage. It has no vertex input or input | 2312 | - **Mesh PSO:** the MS (`ms` index entry by FSSM hash) and PS on the mesh stage. It has no vertex input or input |
| 2209 | assembly; the input layout, topology type and strip cut are ignored, as D3D12 ignores them for mesh PSOs. Topology | 2313 | assembly; the input layout, topology type and strip cut are ignored, as D3D12 ignores them for mesh PSOs. Topology |
| @@ -2270,7 +2374,7 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2270 | | `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`. | | 2374 | | `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`. | |
| 2271 | | `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. Increments are layer-chosen (32/32) pending the console value. | | 2375 | | `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. Increments are layer-chosen (32/32) pending the console value. | |
| 2272 | | `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). | | 2376 | | `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). | |
| 2273 | | `ID3D12Heap` | `Heap` (a reserved VA range) | Buffer ranges are backed by the arena; images get their own `VkDeviceMemory`. Residency calls are no-ops. True buffer/image aliasing inside a heap is **Open**. | | 2377 | | `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**. | |
| 2274 | | `ID3D12Fence` / `ID3D12Fence1` | `Fence` over a timeline `VkSemaphore` | `GetCompletedValue` = counter value; `SetEventOnCompletion` = wait thread + Win32 event; CPU `Signal` = host signal. | | 2378 | | `ID3D12Fence` / `ID3D12Fence1` | `Fence` over a timeline `VkSemaphore` | `GetCompletedValue` = counter value; `SetEventOnCompletion` = wait thread + Win32 event; CPU `Signal` = host signal. | |
| 2275 | | Resource barriers (legacy) | `vkCmdPipelineBarrier` | Per-subresource state tracking; `BEGIN_ONLY`/`END_ONLY` become conservative full barriers at the begin point. | | 2379 | | Resource barriers (legacy) | `vkCmdPipelineBarrier` | Per-subresource state tracking; `BEGIN_ONLY`/`END_ONLY` become conservative full barriers at the begin point. | |
| 2276 | | Enhanced barriers (`ID3D12GraphicsCommandList7::Barrier`) | `vkCmdPipelineBarrier2` | Direct mapping of sync/access/layout; prefer it when the game uses it. | | 2380 | | Enhanced barriers (`ID3D12GraphicsCommandList7::Barrier`) | `vkCmdPipelineBarrier2` | Direct mapping of sync/access/layout; prefer it when the game uses it. | |
| @@ -2398,16 +2502,15 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2398 | retail title's own sizes are not measured (#6982, stop 17), so that its allocation is these shapes and no DCC or | 2502 | retail title's own sizes are not measured (#6982, stop 17), so that its allocation is these shapes and no DCC or |
| 2399 | CMask memory is open until they are. | 2503 | CMask memory is open until they are. |
| 2400 | The descriptions the title passes to slot 25 carry console values (layout word `0x101`/`0x1`, flag bits above the PC | 2504 | The descriptions the title passes to slot 25 carry console values (layout word `0x101`/`0x1`, flag bits above the PC |
| 2401 | ones). For console-form calls or descriptors explicitly using layout `0x101`, the proxy strips Xbox-only flags and | 2505 | ones). For console-form calls or descriptors explicitly using layout `0x101`, the proxy gives the PC device a copy |
| 2402 | translates layout `0x101` to ROW_MAJOR for buffers or UNKNOWN for textures. Other PC-form descriptors reach the host | 2506 | with the PC flags only and ROW_MAJOR (buffer) or UNKNOWN (texture); the title's array is never written. Other |
| 2403 | unchanged for validation (`d3d12_xs_desc_clean.h`; #6982 section 3.7). | 2507 | PC-form descriptors reach the host unchanged for validation (`d3d12_xs_desc_clean.h`, the same cleaning as slot 76; |
| 2404 | A committed resource made through slots 76 and 127 also allocates its console size (the whole tiles above for a | 2508 | #6982 section 3.7). |
| 2405 | listed render-target shape, never a larger PC answer; otherwise the PC size) through the title's | 2509 | A committed resource made through slots 76 and 127 also allocates that size through the title's |
| 2406 | `__XMemAllocationHooks__`, as the console runtime's `XMemAlloc` for the resource does, and frees it when the | 2510 | `__XMemAllocationHooks__`, as the console runtime's `XMemAlloc` for the resource does, and frees it when the |
| 2407 | resource is destroyed (a lease kept with `SetPrivateDataInterface`; the bytes are not used). The retail title | 2511 | resource is destroyed (a lease kept with `SetPrivateDataInterface`; the bytes are not used). The retail title |
| 2408 | budgets its first full-screen render targets with such a hook: it bump-allocates the allocations whose XALLOC | 2512 | budgets its first full-screen render targets with such a hook: it bump-allocates the allocations whose XALLOC |
| 2409 | page-size field is 2 out of a range it reserved and asserts that less than 2 MiB is left (RT-5 stop 17); two | 2513 | 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 |
| 2410 | 3840 x 2160 RGBA8 targets are 2 x 510 tiles of a 64 MiB range, and AMD's 513 x 64 KiB answer would overrun it. The | ||
| 2411 | lease's attribute word (allocator ID 0x80, page-size field 2, object type 0) is an **assumption**; the measured | 2514 | lease's attribute word (allocator ID 0x80, page-size field 2, object type 0) is an **assumption**; the measured |
| 2412 | hook reads only the page-size field. | 2515 | hook reads only the page-size field. |
| 2413 | - `GetAdapterLuid` (implemented): `VkPhysicalDeviceIDProperties::deviceLUID`, which on Windows is the DXGI | 2516 | - `GetAdapterLuid` (implemented): `VkPhysicalDeviceIDProperties::deviceLUID`, which on Windows is the DXGI |
| @@ -2465,8 +2568,8 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2465 | layout enum. The FidelityFX upscaler creates 10 default-heap resources through this slot, so it is not optional | 2568 | layout enum. The FidelityFX upscaler creates 10 default-heap resources through this slot, so it is not optional |
| 2466 | for middleware. The console tiled data layout is GFX10 `SW_64KB_D` (Mesa addrlib `GFX10_SW_64K_D_RBPLUS_PATINFO`), | 2569 | for middleware. The console tiled data layout is GFX10 `SW_64KB_D` (Mesa addrlib `GFX10_SW_64K_D_RBPLUS_PATINFO`), |
| 2467 | and the detile and tile path is implemented in `resource_detile.h` and verified by `resource_detile_test` (D3D-316). | 2570 | and the detile and tile path is implemented in `resource_detile.h` and verified by `resource_detile_test` (D3D-316). |
| 2468 | - `CreateCommittedResource`: allocate an aligned range in the arena for a buffer, or a separate `VkDeviceMemory` | 2571 | - `CreateCommittedResource`: allocate an aligned range in the arena for a buffer, or a range of a shared block |
| 2469 | for an image; record the initial state. Map `D3D12_HEAP_TYPE_DEFAULT` to device-local memory, `UPLOAD`/`READBACK` | 2572 | or a separate `VkDeviceMemory` for an image (section 3.3); record the initial state. Map `D3D12_HEAP_TYPE_DEFAULT` to device-local memory, `UPLOAD`/`READBACK` |
| 2470 | to separate host-visible buffers. This remains the path for buffers and for any PC-style committed resource. | 2573 | to separate host-visible buffers. This remains the path for buffers and for any PC-style committed resource. |
| 2471 | - `ID3D12Resource::GetDesc` returns the description with its defaults filled in, as the PC runtime does: `MipLevels` | 2574 | - `ID3D12Resource::GetDesc` returns the description with its defaults filled in, as the PC runtime does: `MipLevels` |
| 2472 | 0 becomes the full chain, and `Alignment` 0 becomes the placement alignment, 64 KiB, or 4 MiB for a multisampled | 2575 | 0 becomes the full chain, and `Alignment` 0 becomes the placement alignment, 64 KiB, or 4 MiB for a multisampled |
| @@ -2616,6 +2719,29 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2616 | - `Map`/`Unmap`: upload/readback buffers map their host-visible memory; default-heap resources return | 2719 | - `Map`/`Unmap`: upload/readback buffers map their host-visible memory; default-heap resources return |
| 2617 | `E_INVALIDARG` as D3D12 does. A texture in a CPU-visible custom heap maps only with a null pointer (its layout is | 2720 | `E_INVALIDARG` as D3D12 does. A texture in a CPU-visible custom heap maps only with a null pointer (its layout is |
| 2618 | the driver's), as on D3D12. | 2721 | the driver's), as on D3D12. |
| 2722 | - GPU-writable slot-133 images on a default heap bind memory when replay, presentation or creation of a shader | ||
| 2723 | view first needs their Vulkan image. D3D12 placement and logical attachment views can precede that bind. | ||
| 2724 | A CPU-fillable, typed BC texture can initially sample an immutable zero image of the same format, extent, | ||
| 2725 | layer count and mip count. A CPU upload or explicit GPU command gives the placement private backing and | ||
| 2726 | republishes its existing descriptor keys. The cache holds at most 256 MiB. `LEONIDA_PLACED_IMAGE_DEFER=0` | ||
| 2727 | restores eager binding. | ||
| 2728 | - A slot-70 sampled texture whose source pages are unreadable reserves its image backing on the first | ||
| 2729 | complete CPU read. Copies of descriptors written earlier resolve to the fallback until that upload succeeds. | ||
| 2730 | `LEONIDA_TITLE_IMAGE_DEFER=0` allocates these textures eagerly. The memory probe reports the live unbound | ||
| 2731 | image count and its Vulkan memory requirements in MiB. | ||
| 2732 | - Small optimal Vulkan images synthesized for slot-70 texture views share memory pages. Each slice meets the | ||
| 2733 | image's size, alignment and memory type requirements. The GPU retirement queue destroys the image before its | ||
| 2734 | slice can be reused. Large images, dedicated-only images, and failed pool allocations use individual memory | ||
| 2735 | allocations. `LEONIDA_TITLE_IMAGE_POOL=0` selects individual allocation for every image. With | ||
| 2736 | `LEONIDA_MEM_PROBE` enabled, the texture census also reports logical Vulkan backing bytes for the registered | ||
| 2737 | slot-70 and slot-133 images and the portion on non-device-local types. | ||
| 2738 | - Sampled title images can use device-local memory even when Vulkan host image copies require a | ||
| 2739 | host-visible memory type. The runtime queries the same image with and without host-transfer usage. | ||
| 2740 | When only the latter permits plain device-local backing, it detiles the complete image into a reusable | ||
| 2741 | staging buffer and transfers all its mips and layers together. Linear slot-133 placements retain host | ||
| 2742 | copies. An allocation failure retries the original host-copyable image. `LEONIDA_TITLE_IMAGE_STAGING=0` | ||
| 2743 | restores the original placement policy. With `LEONIDA_MEM_PROBE`, each title image class logs its | ||
| 2744 | Vulkan memory type mask, mask without host transfer, and selected type. | ||
| 2619 | - `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they | 2745 | - `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they |
| 2620 | return, as D3D12 requires; a read cannot wait for a later submit. Textures in CPU-visible custom heaps are | 2746 | return, as D3D12 requires; a read cannot wait for a later submit. Textures in CPU-visible custom heaps are |
| 2621 | created with `VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT` when the device supports that usage with the requested | 2747 | created with `VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT` when the device supports that usage with the requested |
| @@ -2633,6 +2759,12 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2633 | or 0) are copied in order. Not compared: null data, which the host faults on (the layer answers `E_INVALIDARG`); | 2759 | or 0) are copied in order. Not compared: null data, which the host faults on (the layer answers `E_INVALIDARG`); |
| 2634 | which bytes win when a read's rows overlap, which is the driver's copy order; and a default-heap texture, which | 2760 | which bytes win when a read's rows overlap, which is the driver's copy order; and a default-heap texture, which |
| 2635 | the host refuses and the layer copies on purpose. | 2761 | the host refuses and the layer copies on purpose. |
| 2762 | - A driver can report `VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT` for a format, create the image with | ||
| 2763 | host-transfer usage, and then give it no memory type (`memoryTypeBits = 0`). This was measured on a GTX 1050 Ti | ||
| 2764 | with NVIDIA 582.78, and the validation layer of Vulkan SDK 1.4.363 reports nothing. Such a texture is made again | ||
| 2765 | without host-transfer usage before it is bound, and takes the staging path. `d3d12_vulkan_device_test` and | ||
| 2766 | `d3d12_subresource_copy_test` force this branch on any GPU with `VulkanDeviceInfo::force_host_transfer_retry` | ||
| 2767 | (their third CPU-copy path; the second compares it with the host runtime). | ||
| 2636 | - 96-bit textures (`R32G32B32_FLOAT`/`_UINT`/`_SINT`/`_TYPELESS`, D3D-62) are `R32G32B32A32` images | 2768 | - 96-bit textures (`R32G32B32_FLOAT`/`_UINT`/`_SINT`/`_TYPELESS`, D3D-62) are `R32G32B32A32` images |
| 2637 | (`ResourceBinding::rgb96`), on every GPU. Most GPUs have no optimal-tiling RGB32 image (an RX 9070 XT reports | 2769 | (`ResourceBinding::rgb96`), on every GPU. Most GPUs have no optimal-tiling RGB32 image (an RX 9070 XT reports |
| 2638 | no optimal features for `R32G32B32_SFLOAT`), and one that has would not avoid the repack: D3D12 places | 2770 | no optimal features for `R32G32B32_SFLOAT`), and one that has would not avoid the repack: D3D12 places |
| @@ -2814,6 +2946,11 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2814 | stores `0x7fff` vs WARP `0x8000` (all on `main` before this change; same 1-ulp class as SRGB, not addressed here). | 2946 | stores `0x7fff` vs WARP `0x8000` (all on `main` before this change; same 1-ulp class as SRGB, not addressed here). |
| 2815 | `D32_FLOAT` and `D32_FLOAT_S8X24_UINT` match WARP. | 2947 | `D32_FLOAT` and `D32_FLOAT_S8X24_UINT` match WARP. |
| 2816 | This does not add typed-view reinterpretation of typeless resources. | 2948 | This does not add typed-view reinterpretation of typeless resources. |
| 2949 | - **Depth clears.** Microsoft documents a `[0, 1]` clamp. On Windows 11 build 26100, both WARP and native D3D12 on | ||
| 2950 | an RTX 5070 Ti (610.74) preserved finite out-of-range `D32_FLOAT` values and quiet NaN in full and rectangle | ||
| 2951 | clears. Replay preserves those values when the Vulkan device has enabled `VK_EXT_depth_range_unrestricted`. | ||
| 2952 | With the extension disabled, replay clamps finite values to `[0, 1]` and uses zero for NaN. The UNORM depth | ||
| 2953 | format conversions still apply. [D3D12 reference](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-cleardepthstencilview) | ||
| 2817 | - `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` (public release note) and DCC: ignore the flag, let the | 2954 | - `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` (public release note) and DCC: ignore the flag, let the |
| 2818 | Vulkan driver choose compression, and fail loudly if the game aliases a buffer over a compressed image or reads | 2955 | Vulkan driver choose compression, and fail loudly if the game aliases a buffer over a compressed image or reads |
| 2819 | raw DCC metadata. | 2956 | raw DCC metadata. |
| @@ -2826,6 +2963,9 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv | |||
| 2826 | 2963 | ||
| 2827 | ### 4.3 Barriers and layouts | 2964 | ### 4.3 Barriers and layouts |
| 2828 | 2965 | ||
| 2966 | Plain buffer copies order earlier transfer writes on the same queue before reading or writing the next range. | ||
| 2967 | Set `LEONIDA_ORDER_BUFFER_COPIES=0` to omit this dependency when comparing replay behavior. | ||
| 2968 | |||
| 2829 | Track a current state/layout per subresource. D3D12 states are bitmasks; a combined state takes the union of the | 2969 | Track a current state/layout per subresource. D3D12 states are bitmasks; a combined state takes the union of the |
| 2830 | mapped stages/accesses, and if no single layout serves all uses, use `GENERAL` and log it. Legacy | 2970 | mapped stages/accesses, and if no single layout serves all uses, use `GENERAL` and log it. Legacy |
| 2831 | `D3D12_RESOURCE_STATE_*` maps to a (stage, access, layout) triple: | 2971 | `D3D12_RESOURCE_STATE_*` maps to a (stage, access, layout) triple: |
| @@ -2857,7 +2997,32 @@ mapped stages/accesses, and if no single layout serves all uses, use `GENERAL` a | |||
| 2857 | - Enhanced barriers (`D3D12_BARRIER_SYNC_*`, `D3D12_BARRIER_ACCESS_*`, `D3D12_BARRIER_LAYOUT_*`) map directly to | 2997 | - Enhanced barriers (`D3D12_BARRIER_SYNC_*`, `D3D12_BARRIER_ACCESS_*`, `D3D12_BARRIER_LAYOUT_*`) map directly to |
| 2858 | `VkPipelineStageFlags2`, `VkAccessFlags2` and `VkImageLayout` (`vulkan_sync`, `vulkan_barrier_access`, | 2998 | `VkPipelineStageFlags2`, `VkAccessFlags2` and `VkImageLayout` (`vulkan_sync`, `vulkan_barrier_access`, |
| 2859 | `vulkan_layout`). Queue-specific layouts map like their generic forms; ray tracing, video and split scopes use | 2999 | `vulkan_layout`). Queue-specific layouts map like their generic forms; ray tracing, video and split scopes use |
| 2860 | `ALL_COMMANDS`; `LayoutBefore = UNDEFINED` or the discard flag becomes `oldLayout = UNDEFINED`. | 3000 | `ALL_COMMANDS`; `LayoutBefore = UNDEFINED` or the discard flag becomes `oldLayout = UNDEFINED`. `SYNC_COPY` is |
| 3001 | `COPY | CLEAR`, not `COPY` alone: `WriteBufferImmediate` is recorded as `vkCmdUpdateBuffer` and | ||
| 3002 | `ResolveQueryData`'s never-written queries as `vkCmdFillBuffer`, which synchronization2 runs in the `CLEAR` stage | ||
| 3003 | (D3D-838; `vk_command_replay_test` part K is a read-after-write hazard under synchronization validation without | ||
| 3004 | it). | ||
| 3005 | - `LayoutAfter = UNDEFINED` from a defined layout (D3D-BARRIER-INTO-UNDEFINED) releases the subresources: their | ||
| 3006 | contents are no longer needed, as before their memory is aliased. Vulkan has no transition into `UNDEFINED` | ||
| 3007 | (VUID-VkImageMemoryBarrier2-newLayout-01198), so each piece gets a barrier with `oldLayout = newLayout`, the | ||
| 3008 | layout the tracker has for it: the accesses are ordered and nothing in the image changes. The tracker keeps those | ||
| 3009 | layouts. A piece never used yet gets no barrier and is not zero-filled for it. The next barrier on these | ||
| 3010 | subresources has to start from `UNDEFINED`, which discards from whatever layout they are in, as before. The list | ||
| 3011 | closes, as it does on WARP (measured on Windows 11 26340 in #984). #984 also reports that the retail title ends a | ||
| 3012 | depth buffer's use this way and takes a failed `Close` as fatal; the layer failed such a list's `Close` until | ||
| 3013 | this change. `UNDEFINED` to `UNDEFINED` is a separate case (#600). | ||
| 3014 | - **Tests:** `command_list_test` and `replay_texture_barrier_test` (CPU: the barriers recorded, the kept layouts, | ||
| 3015 | an unused image, the barrier that follows); three rows of `d3d12_close_parity_test`; `vk_command_replay_test` | ||
| 3016 | part L (a colour target, a depth buffer whose planes are in two layouts and an unused image released, the target | ||
| 3017 | used again and read back); and `d3d12_com_test`, where a depth buffer is cleared, released, taken from | ||
| 3018 | `UNDEFINED` again, cleared and read back through the D3D12 list and queue (16 depth and 16 stencil texels | ||
| 3019 | exact). Run on an RTX 4070 Ti (NVIDIA 620.70.06, Linux): part L natively with the validation layer 1.4.363 and | ||
| 3020 | no error, where the same barriers with `newLayout = UNDEFINED` give VUID-VkImageMemoryBarrier2-newLayout-01198 | ||
| 3021 | four times; the D3D12 tests under Wine. | ||
| 3022 | - A rejected recording call logs `<method> rejected a call (d3d12_com.cpp:<line>)` the first time each call site | ||
| 3023 | rejects one (Barrier and CopyTextureRegion also print their arguments), and a batch the queue's replay refuses | ||
| 3024 | logs `queue replay refused a batch at vulkan_backend.h:<line>`, so a failed `Close` or | ||
| 3025 | `ExecuteCommandLists failed: unsupported` names its cause. | ||
| 2861 | - `DiscardResource` (D3D-26): each discarded image subresource gets a barrier from `oldLayout = UNDEFINED` to the | 3026 | - `DiscardResource` (D3D-26): each discarded image subresource gets a barrier from `oldLayout = UNDEFINED` to the |
| 2862 | layout the tracker already has for it, so the driver may drop the contents while later commands see no layout | 3027 | layout the tracker already has for it, so the driver may drop the contents while later commands see no layout |
| 2863 | change. The other cases are no-ops, which "contents undefined" allows: buffers, discards with rectangles (only | 3028 | change. The other cases are no-ops, which "contents undefined" allows: buffers, discards with rectangles (only |
| @@ -3157,6 +3322,14 @@ will forward to. The queue-side calls ignore which queue they came on (one `VkQu | |||
| 3157 | keeps the app's sync interval. | 3322 | keeps the app's sync interval. |
| 3158 | `GetFrameStatisticsX` keeps the last 64 frames and reports the event, present and display times (not render; | 3323 | `GetFrameStatisticsX` keeps the last 64 frames and reports the event, present and display times (not render; |
| 3159 | `PercentScanned` only for a frame shown at once by `ImmediateThresholdPercent`, else 0); `S_FALSE` with count 0 for what it does not have. | 3324 | `PercentScanned` only for a frame shown at once by `ImmediateThresholdPercent`, else 0); `S_FALSE` with count 0 for what it does not have. |
| 3325 | *Pacing drift reporting (BL-6):* `FramePacer` keeps fixed-capacity ring buffers (`frame_pacing_window = 1024`) of | ||
| 3326 | present-to-present frame intervals and origin-to-present latencies (clearing the last-present anchor across | ||
| 3327 | `SuspendX`/`ResumeX` so suspended pauses are excluded), computing nearest-rank `p50`/`p95`/`p99` and the mean drift | ||
| 3328 | against the active target interval (`FramePacer::pacing_summary()`). On teardown after at least one present, | ||
| 3329 | `XboxPresentation` logs a single `[rt] present: pacing summary ...` line on stderr, which `tools/boot_trace.py` | ||
| 3330 | surfaces beside the D3D12 call counts. Confirmed on a fake clock by `frame_pacer_test` (known 100-frame distribution, | ||
| 3331 | positive and negative drift, ring-buffer wrap-around, suspend/resume exclusion, uncapped mode) and by | ||
| 3332 | `tests/test_boot_trace.py`. | ||
| 3160 | - *`PresentX`*: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a | 3333 | - *`PresentX`*: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a |
| 3161 | single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set | 3334 | single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set |
| 3162 | (bilinear, so the rectangle's outer texels blend with their neighbours). The blit converts between formats; an sRGB | 3335 | (bilinear, so the rectangle's outer texels blend with their neighbours). The blit converts between formats; an sRGB |
| @@ -3384,7 +3557,11 @@ Implemented (`QueryHeap` in `runtime/shims/d3d12_vulkan_device.cpp`, the query c | |||
| 3384 | - **Heaps.** One `VkQueryPool` per `ID3D12QueryHeap`, registered with the `VulkanContext` by its pointer, as | 3557 | - **Heaps.** One `VkQueryPool` per `ID3D12QueryHeap`, registered with the `VulkanContext` by its pointer, as |
| 3385 | resources are. `OCCLUSION` heaps are `VK_QUERY_TYPE_OCCLUSION` pools and hold both `OCCLUSION` and | 3558 | resources are. `OCCLUSION` heaps are `VK_QUERY_TYPE_OCCLUSION` pools and hold both `OCCLUSION` and |
| 3386 | `BINARY_OCCLUSION` queries, as in D3D12. `TIMESTAMP` and `COPY_QUEUE_TIMESTAMP` heaps are | 3559 | `BINARY_OCCLUSION` queries, as in D3D12. `TIMESTAMP` and `COPY_QUEUE_TIMESTAMP` heaps are |
| 3387 | `VK_QUERY_TYPE_TIMESTAMP` pools; they are refused when the queue family's `timestampValidBits` is 0. | 3560 | `VK_QUERY_TYPE_TIMESTAMP` pools. `OPTIONS3.CopyQueueTimestampQueriesSupported` and copy timestamp heap creation |
| 3561 | agree: both require timestamp bits and graphics or compute support in every family a copy queue can use (its | ||
| 3562 | dedicated family, if configured, and the graphics fallback). Transfer-only families can write timestamps on some | ||
| 3563 | devices but cannot reset or resolve their queries. Query commands and `GetTimestampFrequency` also check the | ||
| 3564 | queue's actual family. | ||
| 3388 | `PIPELINE_STATISTICS` heaps count all eleven Vulkan statistics (`0x7ff`), whose result order is the field order | 3565 | `PIPELINE_STATISTICS` heaps count all eleven Vulkan statistics (`0x7ff`), whose result order is the field order |
| 3389 | of `D3D12_QUERY_DATA_PIPELINE_STATISTICS` (IA vertices, IA primitives, VS, GS invocations, GS primitives, | 3566 | of `D3D12_QUERY_DATA_PIPELINE_STATISTICS` (IA vertices, IA primitives, VS, GS invocations, GS primitives, |
| 3390 | clipper invocations and primitives, PS, HS, DS, CS), so one 88-byte result per query is copied as is. They need | 3567 | clipper invocations and primitives, PS, HS, DS, CS), so one 88-byte result per query is copied as is. They need |
| @@ -3686,8 +3863,10 @@ to be recovered from call sites (or the NDA GDK headers, if a developer has acce | |||
| 3686 | | PresentX / present planes / frame events | Public GDK samples (MIT/zlib), §4.5 | 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; slots/layouts **Open**. | | 3863 | | PresentX / present planes / frame events | Public GDK samples (MIT/zlib), §4.5 | 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; slots/layouts **Open**. | |
| 3687 | | Device slots 48/73/78/79/80 | Public HLE `Freminet`/`ScarlettX` (third-party, not Microsoft documentation) | `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. | | 3864 | | Device slots 48/73/78/79/80 | Public HLE `Freminet`/`ScarlettX` (third-party, not Microsoft documentation) | `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. | |
| 3688 | | 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**. | | 3865 | | 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**. | |
| 3689 | | 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; the PC slot 61 is `CreateMetaCommand`. The layout of the description beyond the PC fields is **Open**. | | 3866 | | 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**. | |
| 3690 | | 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 | `set_presentation_handler` forwards 78-81 and the queue routes to a presenter (`attach_xbox_presentation`). The Windows integration also creates its own presenter on first use. Without one, slot 81 answers `S_FALSE` with a zero count (no statistics yet) and the queue slots stay refused. Moved with `LEONIDA_XS_FRAME_STATISTICS_SLOT` (3..127) and `LEONIDA_XS_PRESENT_X_SLOT` (default 30); `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). | | 3867 | | 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**. | |
| 3868 | | 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**. | | ||
| 3869 | | 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 | `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. `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). | | ||
| 3691 | | VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. | | 3870 | | VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. | |
| 3692 | | 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. | | 3871 | | 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. | |
| 3693 | | 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. | | 3872 | | 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. | |
| @@ -3738,6 +3917,30 @@ Games and middleware call these every frame (PIX events), so they must be cheap | |||
| 3738 | changes nothing (`E_INVALIDARG`). Before #2533 the layer stored the name under a mistyped GUID. | 3917 | changes nothing (`E_INVALIDARG`). Before #2533 the layer stored the name under a mistyped GUID. |
| 3739 | Names are not forwarded to `vkSetDebugUtilsObjectNameEXT` yet: one D3D12 object may own several Vulkan objects. | 3918 | Names are not forwarded to `vkSetDebugUtilsObjectNameEXT` yet: one D3D12 object may own several Vulkan objects. |
| 3740 | 3919 | ||
| 3920 | ### 4.11 Vulkan device-loss diagnostics | ||
| 3921 | |||
| 3922 | Set `LEONIDA_DEVICE_FAULT=1` before creating the runtime's Vulkan device to enable the supported device-fault and | ||
| 3923 | NVIDIA checkpoint extensions. On the first observed device loss, stderr logs driver fault addresses, vendor data | ||
| 3924 | and binary size, plus the checkpoints reached on each queue. Checkpoints identify the replay submission, its | ||
| 3925 | original `ExecuteCommandLists` call, the zero-based list and command indices, and the most recent shader names | ||
| 3926 | in that list when available. A checkpoint shows progress at a reported pipeline stage and can help narrow down | ||
| 3927 | the faulting work. The loss report also lists the last 64 compute dispatches submitted across queues, including | ||
| 3928 | direct group dimensions or indirect argument-buffer locations, even without driver checkpoints. These entries show | ||
| 3929 | submission order. Set `LEONIDA_DEVICE_FAULT_ROOTS=1` to include each dispatch's 32 recorded root words in the local | ||
| 3930 | diagnostic log. While this mode is enabled, a host thread samples the submission timelines once a second. If the | ||
| 3931 | retired ticket stays behind submitted work for 15 seconds, it prints the CPU dispatch history. It also reports | ||
| 3932 | when it cannot sample the submission lock for that long. A progress warning leaves D3D12 fence values and the | ||
| 3933 | device state intact. The driver checkpoint and fault-info queries run after Vulkan reports device loss. This mode | ||
| 3934 | is off by default. | ||
| 3935 | |||
| 3936 | For a local pre-submit inspection, also set `LEONIDA_COMPUTE_INPUTS` to comma-separated shader name fragments and | ||
| 3937 | `LEONIDA_COMPUTE_INPUT_SLOTS` to comma-separated decimal `root/slot` pairs. For example, `4/86,5/0,5/2,7/0` reads | ||
| 3938 | four 32-byte descriptors. The probe logs the bound heap and root layout, the saved user SGPRs, observed descriptor | ||
| 3939 | writer, buffer address, stride, record count and readable backing. It also follows the per-group scene indices of | ||
| 3940 | the Prop and Tree cullers when both `5/0` and `4/86` are selected. Each sample is taken after CPU-side shadow | ||
| 3941 | refresh and before queue submission. Earlier GPU writes may still be in flight. An imported heap can have a valid | ||
| 3942 | shader offset beyond the arena. Keep probe output local. Unset `LEONIDA_COMPUTE_INPUTS` to disable it. | ||
| 3943 | |||
| 3741 | ## 5. Producing the shader contract | 3944 | ## 5. Producing the shader contract |
| 3742 | 3945 | ||
| 3743 | The table below is the contract from [design.md](design.md#translator-status-and-runtime-contract) and where the | 3946 | The table below is the contract from [design.md](design.md#translator-status-and-runtime-contract) and where the |
| @@ -3775,6 +3978,12 @@ struct entry { // 10 uints = 40 bytes | |||
| 3775 | ``` | 3978 | ``` |
| 3776 | 3979 | ||
| 3777 | - Hash: FNV-1a over the eight key dwords as dwords (not bytes): `h = 2166136261; h = (h ^ key[i]) * 16777619`. | 3980 | - Hash: FNV-1a over the eight key dwords as dwords (not bytes): `h = 2166136261; h = (h ^ key[i]) * 16777619`. |
| 3981 | - Optional finalizer (`fnv1a_fmix32`): a module whose `index.json` meta says `"descriptor_hash": "fnv1a_fmix32"` runs | ||
| 3982 | MurmurHash3's `fmix32` on that word before probing (`h ^= h >> 16; h *= 0x85EBCA6B; h ^= h >> 13; h *= 0xC2B2AE35; | ||
| 3983 | h ^= h >> 16`, logical shifts). An absent key means bare `fnv1a`. `DescriptorTable` fixes one kind per table before its | ||
| 3984 | first insert, taken from the modules' metas: all agree is that kind, mixed is the majority (the minority's lookups miss | ||
| 3985 | to index 0), and `LEONIDA_DESCRIPTOR_HASH=fnv1a|fnv1a_fmix32` overrides. The two kinds' shared vectors are in | ||
| 3986 | `runtime/test/descriptor_table_test.cpp`. | ||
| 3778 | - Probe: `slot = (h + k) & mask` for `k = 0..7`; the first entry whose eight key dwords match yields its | 3987 | - Probe: `slot = (h + k) & mask` for `k = 0..7`; the first entry whose eight key dwords match yields its |
| 3779 | `index`; no match yields 0. | 3988 | `index`; no match yields 0. |
| 3780 | - The layer must keep the table sparse enough that no live key needs more than eight probes. When all eight slots are occupied, | 3989 | - The layer must keep the table sparse enough that no live key needs more than eight probes. When all eight slots are occupied, |