upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/d3d12_vulkan.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/d3d12_vulkan.md')
-rw-r--r--docs/d3d12_vulkan.md81
1 files changed, 61 insertions, 20 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md
index 3ae29163e..3cd9d6d5e 100644
--- a/docs/d3d12_vulkan.md
+++ b/docs/d3d12_vulkan.md
@@ -2029,6 +2029,15 @@ without recorded inputs. In that case the runtime accepts any input layout when
2029 2029
2030### 3.6 Shader identity, PSOs and feature selection 2030### 3.6 Shader identity, PSOs and feature selection
2031 2031
2032The Xbox native graphics pipeline descriptor identifies stages by the digest in a DXBC HASH part (see
2033`docs/fspx.md`, kind 7). The shaders stage writes `<work>/shaders/spirv/native_hashes.txt` from the user's
2034carved DXBC containers and translation index. After the version header, each line contains the 16-byte digest
2035in lowercase hex, the translated stage and a container path relative to the index, separated by tabs.
2036Containers sharing a digest must agree on stage and FSSM hash. A collision fails the stage and preserves the
2037previous catalog. Rerunning the shaders stage checks its source fingerprint, including the catalog writer.
2038To add or refresh just the catalog in an existing translation, run
2039`python -I tools/native_pso_hashes.py "<work>/shaders/dxbc" "<work>/shaders/spirv"`.
2040
2032A D3D12 PSO carries DXBC containers, not SPIR-V. The layer identifies a shader by hashing the **FSSM payload** (the 2041A D3D12 PSO carries DXBC containers, not SPIR-V. The layer identifies a shader by hashing the **FSSM payload** (the
2033native RDNA2 program inside the container) and looking it up in a build-time table keyed by `(stage, hash)`. The 2042native RDNA2 program inside the container) and looking it up in a build-time table keyed by `(stage, hash)`. The
2034build emits that hash for every translation; the runtime extracts the FSSM chunk from the DXBC container the same 2043build emits that hash for every translation; the runtime extracts the FSSM chunk from the DXBC container the same
@@ -2067,9 +2076,12 @@ Pipeline creation:
2067 shader, root signature content or state, a changed byte, a truncated blob or a pointer with size 0 give 2076 shader, root signature content or state, a changed byte, a truncated blob or a pointer with size 0 give
2068 `E_INVALIDARG`; a null pointer with a size is ignored; another adapter gives `D3D12_ERROR_ADAPTER_NOT_FOUND` and 2077 `E_INVALIDARG`; a null pointer with a size is ignored; another adapter gives `D3D12_ERROR_ADAPTER_NOT_FOUND` and
2069 another driver `D3D12_ERROR_DRIVER_VERSION_MISMATCH`. `ID3D12PipelineLibrary` is an in-memory map plus the Vulkan 2078 another driver `D3D12_ERROR_DRIVER_VERSION_MISMATCH`. `ID3D12PipelineLibrary` is an in-memory map plus the Vulkan
2070 cache. Its arguments answer as the host's (`d3d12_pipeline_library_host_test`, 74 values from 46 calls that need no 2079 cache. `d3d12_pipeline_library_host_test` compares public argument checks with the host. It runs each host
2071 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 2080 call in a separate process because a fault can leave the device unusable. It reports serialized sizes and the
2072 one failing fast; RTX 3060, driver 610.88): 2081 result of flipping a trailing byte for each device's own format. `d3d12_pipeline_library_test` checks that the
2082 layer rejects a nonzero reserved field in its `LPL1` header. On Windows 11 build 26100 (RTX 5070 Ti,
2083 driver 610.74), all 72 public-argument comparisons matched. The previous 74-value run (RTX 3060, driver
2084 610.88) included the two results from the trailing-byte case.
2073 - `CreatePipelineLibrary`: a foreign, truncated or corrupt blob, the other device's blob, or a null pointer with a 2085 - `CreatePipelineLibrary`: a foreign, truncated or corrupt blob, the other device's blob, or a null pointer with a
2074 size is `E_INVALIDARG`, and `*ppPipelineLibrary` is left as it was. One of the layer's own blobs from another 2086 size is `E_INVALIDARG`, and `*ppPipelineLibrary` is left as it was. One of the layer's own blobs from another
2075 format version is `D3D12_ERROR_DRIVER_VERSION_MISMATCH`, the documented code for a cache from another driver. 2087 format version is `D3D12_ERROR_DRIVER_VERSION_MISMATCH`, the documented code for a cache from another driver.
@@ -2636,6 +2648,11 @@ The trace will enumerate them.
2636 stores `0x7fff` vs WARP `0x8000` (all on `main` before this change; same 1-ulp class as SRGB, not addressed here). 2648 stores `0x7fff` vs WARP `0x8000` (all on `main` before this change; same 1-ulp class as SRGB, not addressed here).
2637 `D32_FLOAT` and `D32_FLOAT_S8X24_UINT` match WARP. 2649 `D32_FLOAT` and `D32_FLOAT_S8X24_UINT` match WARP.
2638 This does not add typed-view reinterpretation of typeless resources. 2650 This does not add typed-view reinterpretation of typeless resources.
2651- **Depth clears.** Microsoft documents a `[0, 1]` clamp. On Windows 11 build 26100, both WARP and native D3D12 on
2652 an RTX 5070 Ti (610.74) preserved finite out-of-range `D32_FLOAT` values and quiet NaN in full and rectangle
2653 clears. Replay preserves those values when the Vulkan device has enabled `VK_EXT_depth_range_unrestricted`.
2654 With the extension disabled, replay clamps finite values to `[0, 1]` and uses zero for NaN. The UNORM depth
2655 format conversions still apply. [D3D12 reference](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-cleardepthstencilview)
2639- `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` (public release note) and DCC: ignore the flag, let the 2656- `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` (public release note) and DCC: ignore the flag, let the
2640 Vulkan driver choose compression, and fail loudly if the game aliases a buffer over a compressed image or reads 2657 Vulkan driver choose compression, and fail loudly if the game aliases a buffer over a compressed image or reads
2641 raw DCC metadata. 2658 raw DCC metadata.
@@ -2679,7 +2696,11 @@ mapped stages/accesses, and if no single layout serves all uses, use `GENERAL` a
2679- Enhanced barriers (`D3D12_BARRIER_SYNC_*`, `D3D12_BARRIER_ACCESS_*`, `D3D12_BARRIER_LAYOUT_*`) map directly to 2696- Enhanced barriers (`D3D12_BARRIER_SYNC_*`, `D3D12_BARRIER_ACCESS_*`, `D3D12_BARRIER_LAYOUT_*`) map directly to
2680 `VkPipelineStageFlags2`, `VkAccessFlags2` and `VkImageLayout` (`vulkan_sync`, `vulkan_barrier_access`, 2697 `VkPipelineStageFlags2`, `VkAccessFlags2` and `VkImageLayout` (`vulkan_sync`, `vulkan_barrier_access`,
2681 `vulkan_layout`). Queue-specific layouts map like their generic forms; ray tracing, video and split scopes use 2698 `vulkan_layout`). Queue-specific layouts map like their generic forms; ray tracing, video and split scopes use
2682 `ALL_COMMANDS`; `LayoutBefore = UNDEFINED` or the discard flag becomes `oldLayout = UNDEFINED`. 2699 `ALL_COMMANDS`; `LayoutBefore = UNDEFINED` or the discard flag becomes `oldLayout = UNDEFINED`. `SYNC_COPY` is
2700 `COPY | CLEAR`, not `COPY` alone: `WriteBufferImmediate` is recorded as `vkCmdUpdateBuffer` and
2701 `ResolveQueryData`'s never-written queries as `vkCmdFillBuffer`, which synchronization2 runs in the `CLEAR` stage
2702 (D3D-838; `vk_command_replay_test` part K is a read-after-write hazard under synchronization validation without
2703 it).
2683- `DiscardResource` (D3D-26): each discarded image subresource gets a barrier from `oldLayout = UNDEFINED` to the 2704- `DiscardResource` (D3D-26): each discarded image subresource gets a barrier from `oldLayout = UNDEFINED` to the
2684 layout the tracker already has for it, so the driver may drop the contents while later commands see no layout 2705 layout the tracker already has for it, so the driver may drop the contents while later commands see no layout
2685 change. The other cases are no-ops, which "contents undefined" allows: buffers, discards with rectangles (only 2706 change. The other cases are no-ops, which "contents undefined" allows: buffers, discards with rectangles (only
@@ -2988,6 +3009,14 @@ queue they came on (one `VkQueue` behind all of them).
2988 keeps the app's sync interval. 3009 keeps the app's sync interval.
2989 `GetFrameStatisticsX` keeps the last 64 frames and reports the event, present and display times (not render; 3010 `GetFrameStatisticsX` keeps the last 64 frames and reports the event, present and display times (not render;
2990 `PercentScanned` only for a frame shown at once by `ImmediateThresholdPercent`, else 0); `S_FALSE` with count 0 for what it does not have. 3011 `PercentScanned` only for a frame shown at once by `ImmediateThresholdPercent`, else 0); `S_FALSE` with count 0 for what it does not have.
3012 *Pacing drift reporting (BL-6):* `FramePacer` keeps fixed-capacity ring buffers (`frame_pacing_window = 1024`) of
3013 present-to-present frame intervals and origin-to-present latencies (clearing the last-present anchor across
3014 `SuspendX`/`ResumeX` so suspended pauses are excluded), computing nearest-rank `p50`/`p95`/`p99` and the mean drift
3015 against the active target interval (`FramePacer::pacing_summary()`). On teardown after at least one present,
3016 `XboxPresentation` logs a single `[rt] present: pacing summary ...` line on stderr, which `tools/boot_trace.py`
3017 surfaces beside the D3D12 call counts. Confirmed on a fake clock by `frame_pacer_test` (known 100-frame distribution,
3018 positive and negative drift, ring-buffer wrap-around, suspend/resume exclusion, uncapped mode) and by
3019 `tests/test_boot_trace.py`.
2991- *`PresentX`*: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a 3020- *`PresentX`*: 0 planes presents a black frame (no token needed). 1 plane blits plane 0's first resource (a
2992 single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set 3021 single-sample 2D colour texture in `PRESENT`) to the swapchain image, limited to `pSrcViewRects[0]` when set
2993 (bilinear, so the rectangle's outer texels blend with their neighbours). The blit converts between formats; an sRGB 3022 (bilinear, so the rectangle's outer texels blend with their neighbours). The blit converts between formats; an sRGB
@@ -3288,23 +3317,34 @@ Implemented (`QueryHeap` in `runtime/shims/d3d12_vulkan_device.cpp`, the query c
3288 recording. The resolve fallback is unchanged: only resolves needing dispatches are refused there. 3317 recording. The resolve fallback is unchanged: only resolves needing dispatches are refused there.
3289- **Mesh draws during a pipeline-statistics query** (D3D-291). D3D12 allows `DispatchMesh` inside a statistics query 3318- **Mesh draws during a pipeline-statistics query** (D3D-291). D3D12 allows `DispatchMesh` inside a statistics query
3290 and reads its input-assembly, vertex, geometry and tessellation fields as 0. Vulkan forbids `vkCmdDrawMeshTasksEXT` 3319 and reads its input-assembly, vertex, geometry and tessellation fields as 0. Vulkan forbids `vkCmdDrawMeshTasksEXT`
3291 while a query with those counters is active (`VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076`), and the heap's 3320 while a query with the input-assembly, vertex, geometry, tessellation or clipping counters is active
3292 pool has all eleven. So a statistics query that holds a mesh draw is split as above, and a split before a draw stays 3321 (`VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076`), and the heap's pool has all eleven. So a statistics query
3293 outside its rendering scope. A segment's first draw decides its pool: the submission's full pool, or a second pool 3322 that holds a mesh draw is split as above, and a split before a draw stays outside its rendering scope. A segment's first draw decides its pool: the submission's full pool, or a second pool
3294 with only clipping invocations and primitives, fragment and compute invocations. A later draw of the other kind ends 3323 with only the fragment and compute invocations, the two the VUID leaves allowed. A later draw of the other kind ends
3295 the segment and begins one of its own kind; dispatches and segments without draws use the full pool, and 3324 the segment and begins one of its own kind; dispatches and segments without draws use the full pool, and
3296 `ExecuteIndirect` draws count as vertex draws. The sum copies a mesh segment's four counters into fields 5 to 8 of 3325 `ExecuteIndirect` draws count as vertex draws. The sum copies a mesh segment's two counters into fields 7 and 8 of
3297 its record, and `statistics_sum.comp` adds them as `CInvocations`, `CPrimitives`, `PSInvocations` and 3326 its record, and `statistics_sum.comp` adds them as `PSInvocations` and `CSInvocations`, so the other fields get
3298 `CSInvocations`, so the other fields get nothing from it. A query that holds only mesh draws is one mesh segment, 3327 nothing from it. D3D12 counts the clipping invocations and primitives of a mesh pipeline, but Vulkan has no counter
3299 resolved through the same sum. Without the compute helper there is no segment pool and such a list is refused 3328 for them during a mesh draw, so `CInvocations` and `CPrimitives` read 0 for a mesh segment. A query that holds only
3300 (`unsupported`) rather than run unsplit; so is one on the single-list `replay()` (D3D-399), whose 3329 mesh draws is one mesh segment, resolved through the same sum. Without the compute helper there is no segment pool
3301 `create_segment_pool` gives no mesh pool. Overlapping statistics queries (D3D-252) split the same way inside their 3330 and such a list is refused (`unsupported`) rather than run unsplit; so is one on the single-list `replay()` (D3D-399),
3302 shared segments: a draw of the other kind than the open segment's opens a new one, so every query that segment 3331 whose `create_segment_pool` gives no mesh pool. Overlapping statistics queries (D3D-252) split the same way inside
3303 belongs to sums both kinds. `replay_query_predication_test` (cases 15 and 16) checks the split points, the segment 3332 their shared segments: a draw of the other kind than the open segment's opens a new one, so every query that segment
3304 kinds and the resolve plan on the CPU. `d3d12_mesh_test` resolves a query around a vertex, two mesh and a vertex 3333 belongs to sums both kinds. `replay_query_predication_test` (cases 15 to 17) checks the split points, the segment
3305 draw, one around a mesh draw and one around the two vertex draws: the vertex fields count only the two triangles, 3334 kinds, the resolve plan and the counters the mesh pool may enable on the CPU. `d3d12_mesh_test` resolves a query
3306 and the mixed query has more clipping and pixel-shader invocations than the vertex-only one. On the RX 9060 XT 3335 around a vertex, two mesh and a vertex draw, one around a mesh draw and one around the two vertex draws: the vertex
3307 (RADV), the clipping counts add up exactly (2 + 10 = 12). 3336 fields count only the two triangles, the mixed query has the same clipping count as the vertex-only one and more
3337 pixel-shader invocations, and the mesh-only query has no clipping count without the mesh-primitives query below.
3338- **The clipping invocations of a mesh segment** (D3D-MESH-CLIPPING-COUNTER). D3D-291 leaves `CInvocations` and
3339 `CPrimitives` of a mesh segment at 0, because Vulkan has no clipping counter during a mesh draw. Where the device
3340 has the `meshShaderQueries` feature of `VK_EXT_mesh_shader`, the number of primitives the mesh shader emitted
3341 comes from a `VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT` query instead: a third pool of the submission, begun
3342 and ended with each mesh segment, next to the two the statistics split needs. Its count is copied to field 5 of the
3343 segment's record and `statistics_sum.comp` adds it as `CInvocations`; `CPrimitives` stays 0, because Vulkan has
3344 no clipped-primitive counter and D3D12's `CPrimitives` is the clipper's output (0 when a triangle is dropped, 2
3345 when it is split). The count is not D3D12's number: Vulkan counts a primitive the mesh shader culled with
3346 `gl_CullPrimitiveEXT`, which D3D12 does not count, so a mesh segment's `CInvocations` can be higher than D3D12's.
3347 Without the feature the field reads 0, as in D3D-291.
3308- **Timestamps.** `GetTimestampFrequency` is `1e9 / timestampPeriod` (1 GHz on the test GPU). Every D3D12 queue 3348- **Timestamps.** `GetTimestampFrequency` is `1e9 / timestampPeriod` (1 GHz on the test GPU). Every D3D12 queue
3309 shares one `VkQueue` for now (question 12), so they share one frequency. 3349 shares one `VkQueue` for now (question 12), so they share one frequency.
3310- **Timestamp resolves on MoltenVK.** On Apple GPUs, MoltenVK delays every `vkCmdWriteTimestamp` to the end of 3350- **Timestamp resolves on MoltenVK.** On Apple GPUs, MoltenVK delays every `vkCmdWriteTimestamp` to the end of
@@ -3506,6 +3546,7 @@ to be recovered from call sites (or the NDA GDK headers, if a developer has acce
3506| DCC / texture compatibility | Public release note for `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` | Let Vulkan choose compression; fail if the game aliases/reads raw compressed data. | 3546| DCC / texture compatibility | Public release note for `D3D12XBOX_RESOURCE_FLAG_FORCE_TEXTURE_COMPATIBILITY` | Let Vulkan choose compression; fail if the game aliases/reads raw compressed data. |
3507| 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**. | 3547| 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**. |
3508| 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. | 3548| 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. |
3549| 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`; `gta6rt` creates no `XboxPresentation` yet). 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). |
3509| VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. | 3550| VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. |
3510| 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. | 3551| 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. |
3511| 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. | 3552| 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. |