d3d12: real SO_STATISTICS query pools (D3D-302) #1630

Manually merged
github merged 5 commits from gh-pr/1630/head into gh-pr/1630/base 2026-11-26 09:58:43 +00:00
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 06:21 UTC · original
BubsMcgee:stream-output → main · +231 −34 · 7 files · 5 commits · merged 2026-11-25 22:37 UTC

Claimed in the coordination issue as: D3D-302 (claim: #1608)
Depends on: #1891

Lands only the real SO_STATISTICS query-pool part, on its own (the option aslan2142 offered). StreamOutput PSOs are still refused and SOSetTargets is still not implemented; the capture path is not part of this PR.

The device detect/enable and the vk_pipeline_check parity fix now live in #1891 (which adopts #1236). This PR is stacked on it and contains only the query pools:

  • With VK_EXT_transform_feedback enabled (by #1891), an SO_STATISTICS heap is a real VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT pool, begun and ended indexed on the stream (vkCmdBeginQueryIndexedEXT / vkCmdEndQueryIndexedEXT).
  • ResolveQueryData copies the two 64-bit results (NumPrimitivesWritten, PrimitivesStorageNeeded), 16 bytes per query, in the same order.
  • Without the feature, the heap is made without a VkQueryPool and resolves zeros, as before.

When #1891 merges I will rebase this onto main; the two foundation commits drop and only the query changes remain.

The remaining pipeline_cache_seed failure on AMD is neither this PR nor #1891: adrianmjim rechecked on an RX 7900 XT and it fails identically on the base main without either, from #1723's robustBufferAccess change. That is #1833, where I flagged a checker-vs-runtime bindless input mismatch (the checker's OR of update-after-bind flags vs the runtime's six-feature AND) to correct before relying on it.

Tested on main 71a769d7d (Windows 11 Pro 26300, MSVC RelWithDebInfo, NVIDIA RTX 3080 Ti, driver 616.64, Vulkan SDK 1.4.363.0): d3d12_vulkan_device, d3d12_mesh and pipeline_cache_seed pass, plain and with LEONIDA_VK_VALIDATION=1. AI-assisted.

**@⁠BubsMcgee** on GitHub · 2026-11-25 06:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630) `BubsMcgee:stream-output` → `main` · +231 −34 · 7 files · 5 commits · merged 2026-11-25 22:37 UTC Claimed in the coordination issue as: D3D-302 (claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: #1891 Lands only the real `SO_STATISTICS` query-pool part, on its own (the option aslan2142 offered). StreamOutput PSOs are still refused and `SOSetTargets` is still not implemented; the capture path is not part of this PR. The device detect/enable and the `vk_pipeline_check` parity fix now live in **#1891** (which adopts #1236). This PR is stacked on it and contains only the query pools: - With `VK_EXT_transform_feedback` enabled (by #1891), an `SO_STATISTICS` heap is a real `VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` pool, begun and ended indexed on the stream (`vkCmdBeginQueryIndexedEXT` / `vkCmdEndQueryIndexedEXT`). - `ResolveQueryData` copies the two 64-bit results (`NumPrimitivesWritten`, `PrimitivesStorageNeeded`), 16 bytes per query, in the same order. - Without the feature, the heap is made without a `VkQueryPool` and resolves zeros, as before. When #1891 merges I will rebase this onto `main`; the two foundation commits drop and only the query changes remain. The remaining `pipeline_cache_seed` failure on AMD is neither this PR nor #1891: adrianmjim rechecked on an RX 7900 XT and it fails identically on the base `main` without either, from #1723's `robustBufferAccess` change. That is #1833, where I flagged a checker-vs-runtime `bindless` input mismatch (the checker's OR of update-after-bind flags vs the runtime's six-feature AND) to correct before relying on it. Tested on `main` `71a769d7d` (Windows 11 Pro 26300, MSVC RelWithDebInfo, NVIDIA RTX 3080 Ti, driver 616.64, Vulkan SDK 1.4.363.0): `d3d12_vulkan_device`, `d3d12_mesh` and `pipeline_cache_seed` pass, plain and with `LEONIDA_VK_VALIDATION=1`. AI-assisted.
With VK_EXT_transform_feedback enabled on the device, an SO_STATISTICS heap is a real VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT pool, begun and ended indexed on the stream (vkCmdBeginQueryIndexedEXT / vkCmdEndQueryIndexedEXT). ResolveQueryData copies the two 64-bit results (NumPrimitivesWritten, PrimitivesStorageNeeded) in the same order. The layer still refuses StreamOutput PSOs and still does not implement SOSetTargets, so no primitive reaches a stream yet and the counts stay 0; without the feature the heap is made without a VkQueryPool and resolves zeros, as before.
The three review points on #1630:

- prepare() refuses two overlapping SO_STATISTICS queries on one stream: two
  active indexed queries in one pool break
  VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753. Queries on different streams
  are fine.
- The transform-feedback pool now also needs the transformFeedbackQueries
  property, and a stream at or above maxTransformFeedbackStreams runs nothing
  and resolves zero instead of issuing an invalid indexed begin.
- replay_query_predication case 18 fails without both: the overlapping-stream
  list is invalid_query and a stream past the pool's stream count fills zeros.

Tested: d3d12_vulkan_device, d3d12_state_map and replay_query_predication pass
plain and with LEONIDA_VK_VALIDATION=1 (RTX 3080 Ti, driver 616.64). AI-assisted.
VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753 forbids two active
transform-feedback queries with the same index anywhere in the command
buffer, whatever their pools. prepare() tracked the active ones by heap
and stream, so two heaps beginning stream 0 together still issued two
active indexed queries. It now keeps one bit per stream for the list.

replay_query_predication case 18 adds a second heap: overlapping queries
on one stream in two heaps are refused, and queries that take turns on
that stream are fine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings #1630 up to date with main; no conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in main after #1891, so main's tip is the single merge base;
no conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:41 +00:00
github manually merged commit 844519ab59 into gh-pr/1630/base 2026-11-26 09:58:43 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 07:54 UTC · original

Reviewed cd65952f4 applied onto main 42537e7b6, and ran it on an AMD Radeon RX 7900 XT. The AMD driver exposes the whole extension (transformFeedback, geometryStreams, transformFeedbackQueries, transformFeedbackRasterizationStreamSelect, 4 streams), so the new paths are live there.

A regression on AMD: pipeline_cache_seed fails

With this PR, ctest -R ^pipeline_cache_seed$ fails 3 of 3 on the 7900 XT. It passes 3 of 3 on main with the same build setup:

FAIL: vk_pipeline_check cache does not hit on the runtime's device (AMD Radeon RX 7900 XT), which does hit a cache it wrote itself: vk_pipeline_check's device differs from the runtime's in something the driver makes part of a pipeline's cache key

The runtime's device now enables VK_EXT_transform_feedback, but runtime/test/vk_pipeline_check.cpp does not, and AMD's driver makes that part of a pipeline's cache key. So the cache vk_pipeline_check seeds offline no longer hits in gta6rt, and every pipeline is compiled again at run time. That is the same mismatch the tool already guards against for mesh shaders and maintenance8. I checked it with a two-line local change: linking a VkPhysicalDeviceTransformFeedbackFeaturesEXT with the extension in vk_pipeline_check's feature chain, next to the mesh-shader one. With that, the test passes 3 of 3 again. NVIDIA evidently leaves it out of the key, which is why it didn't show up on the 3080 Ti. The header comment of vk_pipeline_check.cpp and docs/pipeline_check.md ("The cache and the runtime's device") list the always-enabled extensions and would need the new one too.

Problems in the capture path

None of these shows up in the tests, because no test binds a StreamOutput PSO.

1. The rasterization-stream struct has no sType. VkPipelineRasterizationStateStreamCreateInfoEXT rasterization_stream{}; leaves sType at 0, which is VK_STRUCTURE_TYPE_APPLICATION_INFO. That is the case both in the PSO constructor and in the recipe member's default, and build() copies the recipe's value. For a StreamOutput PSO with RasterizedStream != 0 (only accepted when geometryStreams is enabled), build() chains this struct into raster.pNext, so the driver ignores or misreads it and the validation layers report it. It needs {VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT}.

2. Nothing makes the translated shaders capture anything. The README, the docs and the new comment in the PSO constructor say capture is driven by XfbBuffer/XfbStride/XfbOffset decorations in the translated SPIR-V. But nothing emits them: tools/rdna2spirv.py never writes an Xfb* decoration or the Xfb execution mode, and the runtime's SPIR-V patching only touches Location. That is true on main and with this PR. So whenever a StreamOutput pipeline draws with at least one SO target bound, vkCmdBeginTransformFeedbackEXT runs with a last pre-rasterization stage that does not declare Xfb, which violates VUID-vkCmdBeginTransformFeedbackEXT-None-04128. In practice nothing is captured, yet the PSO is accepted as if it could be. The D3D12_SO_DECLARATION_ENTRY list is validated (and hashed into the PSO cache key) but never reaches the shaders or the capture setup.

3. Capture buffers lack the transform-feedback usage bit. No buffer is created with VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT. SO targets are resolved from their VAs like vertex buffers, so they land in the layer's ordinary buffers, and none of their usage lists has that bit (line numbers are in runtime/shims/d3d12_vulkan_device.cpp on main):

  • the GPU-VA arena (create_arena, 10151)
  • committed and placed buffers (4710)
  • host-imported buffers (4844)
  • title-placed shadow buffers (4986)
  • reserved buffers (2318)
  • imported console heaps (2659)

Binding them with vkCmdBindTransformFeedbackBuffersEXT violates VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360.

4. Unbound lower slots are bound as VK_NULL_HANDLE. begin_stream_output sets count to the highest bound slot + 1 and passes d.stream_output.data() for slots 0..count-1 in one vkCmdBindTransformFeedbackBuffersEXT call. With slot 0 unbound and slot 1 bound (SOSetTargets with StartSlot = 1, which D3D12 allows), slot 0 is still the VK_NULL_HANDLE that reset() left there. Transform-feedback binds have no null-buffer allowance: every one of the bindingCount entries must be a valid buffer. So this needs one bind per contiguous run of bound slots. It also contradicts the comment on PreparedDraw::stream_output, which says only slots with a buffer are used.

5. Each draw restarts the capture at byte 0. vkCmdBeginTransformFeedbackEXT(..., nullptr, nullptr), and the matching End, use no counter buffers. D3D12 appends at BufferFilledSize and writes it back after the draw. Here consecutive draws overwrite each other. BufferFilledSizeLocation is copied into filled_size_va but never used afterwards, so the count at that address is never read or written. The PR calls the write-back a follow-up, but the comment in prepare_draw ("written after the draw") doesn't match the code yet. Using the filled-size VA as the counter buffer would be the direct mapping, and it also needs VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT.

6. Smaller points:

  • RasterizedStream > 3 returns E_INVALIDARG. That also refuses D3D12_SO_NO_RASTERIZED_STREAM (0xFFFFFFFF), which is valid and common for stream-out-only passes; it maps to rasterizer discard.
  • An entry with a null SemanticName is refused. In D3D12 that is a gap entry, and its ComponentCount may be more than 4.
  • prepare_draw resolves the SO targets for every draw whenever the device has transform feedback, not only for StreamOutput pipelines. A stale SO target left bound makes every later ordinary draw in the list unresolvable (unresolved_at): by default each of those draws is dropped, and with LEONIDA_STRICT_REPLAY=1 the whole list fails. The new test binds 0x1000 and draws nothing after it, so it does not hit this.
  • SOSetTargets in a bundle is deferred and replayed. D3D12 lists it among the calls not allowed in a bundle ("Recording command lists and bundles": the runtime drops the call). The neighbouring RSSetViewports already does check(false) there.
  • prepare() neither refuses nor splits overlapping SO_STATISTICS queries; it only rejects the same heap slot twice. On main that was harmless, because no Vulkan query ran for them. Now they are real TRANSFORM_FEEDBACK_STREAM_EXT queries, so two overlapping queries on the same stream (different slots or heaps) become two active indexed queries of the same type and index. Vulkan forbids that: VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753.

Points 2 to 4 together mean a real StreamOutput draw is undefined behaviour on any driver, and can lose the device. Until the translator emits Xfb and the buffers carry the usage bit, it may be safer to keep refusing StreamOutput PSOs, and land the query part (SO_STATISTICS as TRANSFORM_FEEDBACK_STREAM_EXT pools) on its own.

RX 7900 XT

  • Targeted tests (d3d12_vulkan_device, d3d12_com, d3d12_query_rules, command_list, d3d12_state_map, replay_query_edges, replay_query_predication, vk_queue_query_sync): 8 of 8 pass, plain and with LEONIDA_VK_VALIDATION=1 (validation on, no messages). The SO block of d3d12_vulkan_device now runs real TRANSFORM_FEEDBACK_STREAM_EXT queries on streams 0 and 3 here, and the resolved counts are 0.
  • The detection works: there is no "the GPU has no VK_EXT_transform_feedback" line.
  • Whole ctest -j 6: 397 of 402 with this PR, against 399 of 402 on main. The difference is pipeline_cache_seed (above) and d3d12_indirect_rt, which failed once under -j 6 and passes 3 of 3 alone, on both trees. The other three failures are the same on main: d3d12_texture_tiles (#964), d3d12_clear, and d3d12_geometry_views (an AMD-without-Resizable-BAR failure on main, unrelated).

AMD driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022, RelWithDebInfo. No game files.

**@⁠adrianmjim** on GitHub · 2026-11-25 07:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7156380152) Reviewed `cd65952f4` applied onto `main` `42537e7b6`, and ran it on an AMD Radeon RX 7900 XT. The AMD driver exposes the whole extension (`transformFeedback`, `geometryStreams`, `transformFeedbackQueries`, `transformFeedbackRasterizationStreamSelect`, 4 streams), so the new paths are live there. ### A regression on AMD: `pipeline_cache_seed` fails With this PR, `ctest -R ^pipeline_cache_seed$` fails 3 of 3 on the 7900 XT. It passes 3 of 3 on `main` with the same build setup: ``` FAIL: vk_pipeline_check cache does not hit on the runtime's device (AMD Radeon RX 7900 XT), which does hit a cache it wrote itself: vk_pipeline_check's device differs from the runtime's in something the driver makes part of a pipeline's cache key ``` The runtime's device now enables `VK_EXT_transform_feedback`, but `runtime/test/vk_pipeline_check.cpp` does not, and AMD's driver makes that part of a pipeline's cache key. So the cache `vk_pipeline_check` seeds offline no longer hits in `gta6rt`, and every pipeline is compiled again at run time. That is the same mismatch the tool already guards against for mesh shaders and maintenance8. I checked it with a two-line local change: linking a `VkPhysicalDeviceTransformFeedbackFeaturesEXT` with the extension in `vk_pipeline_check`'s feature chain, next to the mesh-shader one. With that, the test passes 3 of 3 again. NVIDIA evidently leaves it out of the key, which is why it didn't show up on the 3080 Ti. The header comment of `vk_pipeline_check.cpp` and `docs/pipeline_check.md` ("The cache and the runtime's device") list the always-enabled extensions and would need the new one too. ### Problems in the capture path None of these shows up in the tests, because no test binds a StreamOutput PSO. **1. The rasterization-stream struct has no `sType`.** `VkPipelineRasterizationStateStreamCreateInfoEXT rasterization_stream{};` leaves `sType` at 0, which is `VK_STRUCTURE_TYPE_APPLICATION_INFO`. That is the case both in the PSO constructor and in the recipe member's default, and `build()` copies the recipe's value. For a StreamOutput PSO with `RasterizedStream != 0` (only accepted when geometryStreams is enabled), `build()` chains this struct into `raster.pNext`, so the driver ignores or misreads it and the validation layers report it. It needs `{VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT}`. **2. Nothing makes the translated shaders capture anything.** The README, the docs and the new comment in the PSO constructor say capture is driven by `XfbBuffer`/`XfbStride`/`XfbOffset` decorations in the translated SPIR-V. But nothing emits them: `tools/rdna2spirv.py` never writes an `Xfb*` decoration or the `Xfb` execution mode, and the runtime's SPIR-V patching only touches `Location`. That is true on `main` and with this PR. So whenever a StreamOutput pipeline draws with at least one SO target bound, `vkCmdBeginTransformFeedbackEXT` runs with a last pre-rasterization stage that does not declare `Xfb`, which violates VUID-vkCmdBeginTransformFeedbackEXT-None-04128. In practice nothing is captured, yet the PSO is accepted as if it could be. The `D3D12_SO_DECLARATION_ENTRY` list is validated (and hashed into the PSO cache key) but never reaches the shaders or the capture setup. **3. Capture buffers lack the transform-feedback usage bit.** No buffer is created with `VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT`. SO targets are resolved from their VAs like vertex buffers, so they land in the layer's ordinary buffers, and none of their usage lists has that bit (line numbers are in `runtime/shims/d3d12_vulkan_device.cpp` on `main`): - the GPU-VA arena (`create_arena`, 10151) - committed and placed buffers (4710) - host-imported buffers (4844) - title-placed shadow buffers (4986) - reserved buffers (2318) - imported console heaps (2659) Binding them with `vkCmdBindTransformFeedbackBuffersEXT` violates VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360. **4. Unbound lower slots are bound as `VK_NULL_HANDLE`.** `begin_stream_output` sets `count` to the highest bound slot + 1 and passes `d.stream_output.data()` for slots 0..count-1 in one `vkCmdBindTransformFeedbackBuffersEXT` call. With slot 0 unbound and slot 1 bound (`SOSetTargets` with `StartSlot = 1`, which D3D12 allows), slot 0 is still the `VK_NULL_HANDLE` that `reset()` left there. Transform-feedback binds have no null-buffer allowance: every one of the `bindingCount` entries must be a valid buffer. So this needs one bind per contiguous run of bound slots. It also contradicts the comment on `PreparedDraw::stream_output`, which says only slots with a buffer are used. **5. Each draw restarts the capture at byte 0.** `vkCmdBeginTransformFeedbackEXT(..., nullptr, nullptr)`, and the matching End, use no counter buffers. D3D12 appends at `BufferFilledSize` and writes it back after the draw. Here consecutive draws overwrite each other. `BufferFilledSizeLocation` is copied into `filled_size_va` but never used afterwards, so the count at that address is never read or written. The PR calls the write-back a follow-up, but the comment in `prepare_draw` ("written after the draw") doesn't match the code yet. Using the filled-size VA as the counter buffer would be the direct mapping, and it also needs `VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT`. **6. Smaller points:** - `RasterizedStream > 3` returns `E_INVALIDARG`. That also refuses `D3D12_SO_NO_RASTERIZED_STREAM` (0xFFFFFFFF), which is valid and common for stream-out-only passes; it maps to rasterizer discard. - An entry with a null `SemanticName` is refused. In D3D12 that is a gap entry, and its `ComponentCount` may be more than 4. - `prepare_draw` resolves the SO targets for every draw whenever the device has transform feedback, not only for StreamOutput pipelines. A stale SO target left bound makes every later ordinary draw in the list unresolvable (`unresolved_at`): by default each of those draws is dropped, and with `LEONIDA_STRICT_REPLAY=1` the whole list fails. The new test binds `0x1000` and draws nothing after it, so it does not hit this. - `SOSetTargets` in a bundle is deferred and replayed. D3D12 lists it among the calls not allowed in a bundle (["Recording command lists and bundles"](https://learn.microsoft.com/en-us/windows/win32/direct3d12/recording-command-lists-and-bundles): the runtime drops the call). The neighbouring `RSSetViewports` already does `check(false)` there. - `prepare()` neither refuses nor splits overlapping `SO_STATISTICS` queries; it only rejects the same heap slot twice. On `main` that was harmless, because no Vulkan query ran for them. Now they are real `TRANSFORM_FEEDBACK_STREAM_EXT` queries, so two overlapping queries on the same stream (different slots or heaps) become two active indexed queries of the same type and index. Vulkan forbids that: VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753. Points 2 to 4 together mean a real StreamOutput draw is undefined behaviour on any driver, and can lose the device. Until the translator emits `Xfb` and the buffers carry the usage bit, it may be safer to keep refusing StreamOutput PSOs, and land the query part (`SO_STATISTICS` as `TRANSFORM_FEEDBACK_STREAM_EXT` pools) on its own. ### RX 7900 XT - Targeted tests (`d3d12_vulkan_device`, `d3d12_com`, `d3d12_query_rules`, `command_list`, `d3d12_state_map`, `replay_query_edges`, `replay_query_predication`, `vk_queue_query_sync`): 8 of 8 pass, plain and with `LEONIDA_VK_VALIDATION=1` (validation on, no messages). The SO block of `d3d12_vulkan_device` now runs real `TRANSFORM_FEEDBACK_STREAM_EXT` queries on streams 0 and 3 here, and the resolved counts are 0. - The detection works: there is no "the GPU has no VK_EXT_transform_feedback" line. - Whole `ctest -j 6`: 397 of 402 with this PR, against 399 of 402 on `main`. The difference is `pipeline_cache_seed` (above) and `d3d12_indirect_rt`, which failed once under `-j 6` and passes 3 of 3 alone, on both trees. The other three failures are the same on `main`: `d3d12_texture_tiles` (#964), `d3d12_clear`, and `d3d12_geometry_views` (an AMD-without-Resizable-BAR failure on `main`, unrelated). AMD driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022, RelWithDebInfo. No game files.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 09:11 UTC · original

Thanks for this. It can't be merged yet, for these reasons:

  • D3D-302 has no claiming: line from you in #14 or #1608. Please post the claim there first.
  • It depends on #1236, which is still open. This PR also enables VK_EXT_transform_feedback itself, in the same two files as #1236. Please rebase onto #1236 once it's merged, and drop the duplicated device setup.
  • The points in the earlier review still stand. I checked these against the diff:
    • VkPipelineRasterizationStateStreamCreateInfoEXT has no sType.
    • Nothing in the translator emits Xfb decorations.
    • Unbound lower SO slots are bound as VK_NULL_HANDLE.
    • vkCmdBeginTransformFeedbackEXT runs without counter buffers.
    • vk_pipeline_check doesn't enable the extension, so pipeline_cache_seed fails on AMD.
  • One option is to keep refusing StreamOutput PSOs and land the SO_STATISTICS pool part on its own.
  • The first commit's message describes indirect-signature work, but its diff is the stream-output change.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 09:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7157996178) Thanks for this. It can't be merged yet, for these reasons: - `D3D-302` has no `claiming:` line from you in #14 or #1608. Please post the claim there first. - It depends on #1236, which is still open. This PR also enables `VK_EXT_transform_feedback` itself, in the same two files as #1236. Please rebase onto #1236 once it's merged, and drop the duplicated device setup. - The points in the earlier review still stand. I checked these against the diff: - `VkPipelineRasterizationStateStreamCreateInfoEXT` has no `sType`. - Nothing in the translator emits `Xfb` decorations. - Unbound lower SO slots are bound as `VK_NULL_HANDLE`. - `vkCmdBeginTransformFeedbackEXT` runs without counter buffers. - `vk_pipeline_check` doesn't enable the extension, so `pipeline_cache_seed` fails on AMD. - One option is to keep refusing StreamOutput PSOs and land the `SO_STATISTICS` pool part on its own. - The first commit's message describes indirect-signature work, but its diff is the stream-output change. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 10:37 UTC · original

NVIDIA data point for the pipeline_cache_seed question: tested ac4a992ed merged onto main 57ba40bd6 (clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14 (VK_EXT_transform_feedback with 4 streams), VS 2022 RelWithDebInfo + Ninja.

  • Full ctest -j 6: 408 of 408 passed on both main and this PR (same skips).
  • pipeline_cache_seed: passes 3 of 3 with this PR, so the vk_pipeline_check change in this head keeps the cache hitting on NVIDIA.
  • d3d12_vulkan_device with LEONIDA_VK_VALIDATION=1: exit 0, 0 VUIDs.

Nothing here draws through a StreamOutput PSO, so this doesn't cover the review points above.

AI-assisted testing (non-developer tester).

**@⁠potatoe0100** on GitHub · 2026-11-25 10:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7159950681) NVIDIA data point for the `pipeline_cache_seed` question: tested `ac4a992ed` merged onto `main` `57ba40bd6` (clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14 (`VK_EXT_transform_feedback` with 4 streams), VS 2022 RelWithDebInfo + Ninja. - Full `ctest -j 6`: 408 of 408 passed on both `main` and this PR (same skips). - `pipeline_cache_seed`: passes 3 of 3 with this PR, so the `vk_pipeline_check` change in this head keeps the cache hitting on NVIDIA. - `d3d12_vulkan_device` with `LEONIDA_VK_VALIDATION=1`: exit 0, 0 VUIDs. Nothing here draws through a StreamOutput PSO, so this doesn't cover the review points above. AI-assisted testing (non-developer tester).
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 11:26 UTC · original

Independent verification (native Windows; RTX 4070 SUPER + AMD gfx1036 iGPU, LEONIDA_VK_VALIDATION=1): builds clean; CPU/mock tests 5/5; GPU tests (d3d12_com, d3d12_vulkan_device incl. the new SOSetTargets/SO_STATISTICS block, vk_queue_query_sync, pipeline_cache_seed) pass on both GPUs; full ctest NV 400/401 (sole failure d3d12_pipeline_library_host 0xc0000409 is pre-existing/environmental — identical crash signature on other branches).

Confirming the outstanding reviews independently — every cited defect verified in the diff, plus additional findings the reviews may not have covered:

  • VkPipelineRasterizationStateStreamCreateInfoEXT is value-initialized {} with no sType at both sites (~7590, ~8169) — sType stays APPLICATION_INFO when chained into raster.pNext.
  • Nothing emits Xfb decorations — rdna2spirv.py never writes XfbBuffer/XfbStride/XfbOffset or the Xfb execution mode, so any real StreamOutput draw hits VUID-vkCmdBeginTransformFeedbackEXT-None-04128.
  • No buffer has VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT at any of the 6 creation sites -> VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360.
  • begin_stream_output binds VK_NULL_HANDLE for unbound lower slots (TF binds have no null allowance) — needs per-contiguous-run binds.
  • BufferFilledSizeLocation/filled_size_va is stored but never read or written — consecutive draws overwrite; no counter buffers.
  • Structural: first commit message describes indirect signature arg types (already on main) while its diff is the stream-output bulk; device-detection hunks in cd65952f4 duplicate open #1236 verbatim; merge-base is old (c7e82e26e).
  • pipeline_cache_seed AMD regression mechanism confirmed: vk_pipeline_check.cpp does not enable VK_EXT_transform_feedback while the runtime now does.
  • No test exercises a real StreamOutput draw — the new test records SOSetTargets with a dead VA and draws nothing.

Recommend the same conclusion as the existing reviews: not mergeable as-is; needs the Xfb decoration emission + TF usage bits + counter/fill semantics before it can pass validation on a real SO draw. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 11:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7161048560) Independent verification (native Windows; RTX 4070 SUPER + AMD gfx1036 iGPU, `LEONIDA_VK_VALIDATION=1`): builds clean; CPU/mock tests 5/5; GPU tests (d3d12_com, d3d12_vulkan_device incl. the new SOSetTargets/SO_STATISTICS block, vk_queue_query_sync, pipeline_cache_seed) pass on both GPUs; full ctest NV 400/401 (sole failure d3d12_pipeline_library_host 0xc0000409 is pre-existing/environmental — identical crash signature on other branches). **Confirming the outstanding reviews independently** — every cited defect verified in the diff, plus additional findings the reviews may not have covered: - `VkPipelineRasterizationStateStreamCreateInfoEXT` is value-initialized `{}` with **no sType** at both sites (~7590, ~8169) — sType stays APPLICATION_INFO when chained into raster.pNext. - **Nothing emits Xfb decorations** — rdna2spirv.py never writes XfbBuffer/XfbStride/XfbOffset or the Xfb execution mode, so any real StreamOutput draw hits VUID-vkCmdBeginTransformFeedbackEXT-None-04128. - **No buffer has VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT** at any of the 6 creation sites -> VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360. - `begin_stream_output` binds `VK_NULL_HANDLE` for unbound lower slots (TF binds have no null allowance) — needs per-contiguous-run binds. - `BufferFilledSizeLocation`/`filled_size_va` is stored but never read or written — consecutive draws overwrite; no counter buffers. - Structural: first commit message describes indirect signature arg types (already on main) while its diff is the stream-output bulk; device-detection hunks in cd65952f4 duplicate open #1236 verbatim; merge-base is old (c7e82e26e). - `pipeline_cache_seed` AMD regression mechanism confirmed: vk_pipeline_check.cpp does not enable VK_EXT_transform_feedback while the runtime now does. - No test exercises a real StreamOutput draw — the new test records SOSetTargets with a dead VA and draws nothing. Recommend the same conclusion as the existing reviews: not mergeable as-is; needs the Xfb decoration emission + TF usage bits + counter/fill semantics before it can pass validation on a real SO draw. AI-assisted verification.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 12:48 UTC · original

Rechecked b4e4787d8 on the RX 7900 XT (driver 32.0.32029.2010, Windows 11 26300, VS 2022 RelWithDebInfo). Thanks for splitting it. The query-only scope and the vk_pipeline_check change both look right.

  • The query and replay tests (d3d12_vulkan_device, d3d12_com, d3d12_query_rules, replay_query_edges, replay_query_predication, vk_queue_query_sync, command_list) pass with LEONIDA_VK_VALIDATION=1, with no VUIDs.
  • pipeline_cache_seed still fails, but not because of this PR. It fails the same way, 3 of 3, on this PR's base main ed94fbef9 without it. #1723 (ba626820e) made the runtime's device enable robustBufferAccess, with VK_EXT_robustness2's robustBufferAccess2 and nullDescriptor, for bounded indexed indirect draws. vk_pipeline_check still forces robustBufferAccess off, and AMD keys pipelines on it.
  • I checked it with a local experiment that makes the checker mirror those choices: the seed then passes on top of this PR. Mirroring nullDescriptor alone is not enough; robustBufferAccess is the one that matters.

So your transform-feedback line in the checker is needed and correct; there is now a second mismatch from main. I'll open a separate PR for that one, so it doesn't hold this up.

Whole ctest -j 6 on this head: 435 of 438 pass or skip. The failures are d3d12_texture_tiles, d3d12_clear and pipeline_cache_seed, all three on main too.

**@⁠adrianmjim** on GitHub · 2026-11-25 12:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7162891555) Rechecked `b4e4787d8` on the RX 7900 XT (driver 32.0.32029.2010, Windows 11 26300, VS 2022 RelWithDebInfo). Thanks for splitting it. The query-only scope and the `vk_pipeline_check` change both look right. - The query and replay tests (`d3d12_vulkan_device`, `d3d12_com`, `d3d12_query_rules`, `replay_query_edges`, `replay_query_predication`, `vk_queue_query_sync`, `command_list`) pass with `LEONIDA_VK_VALIDATION=1`, with no VUIDs. - **`pipeline_cache_seed` still fails, but not because of this PR.** It fails the same way, 3 of 3, on this PR's base `main` `ed94fbef9` without it. #1723 (`ba626820e`) made the runtime's device enable `robustBufferAccess`, with `VK_EXT_robustness2`'s `robustBufferAccess2` and `nullDescriptor`, for bounded indexed indirect draws. `vk_pipeline_check` still forces `robustBufferAccess` off, and AMD keys pipelines on it. - I checked it with a local experiment that makes the checker mirror those choices: the seed then passes on top of this PR. Mirroring `nullDescriptor` alone is not enough; `robustBufferAccess` is the one that matters. So your transform-feedback line in the checker is needed and correct; there is now a second mismatch from `main`. I'll open a separate PR for that one, so it doesn't hold this up. Whole `ctest -j 6` on this head: 435 of 438 pass or skip. The failures are `d3d12_texture_tiles`, `d3d12_clear` and `pipeline_cache_seed`, all three on `main` too.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 12:49 UTC · original

The other pipeline_cache_seed mismatch, from #1723's robustness choices, is #1833. With both, the seed passes on the RX 7900 XT.

**@⁠adrianmjim** on GitHub · 2026-11-25 12:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7162908954) The other `pipeline_cache_seed` mismatch, from #1723's robustness choices, is #1833. With both, the seed passes on the RX 7900 XT.
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 13:03 UTC · original

Addressed the review points on this update:

  • Claim: claiming: D3D-302 is now posted — #1608.
  • Rebased onto #1236: the first commit (392053470) is #1236's device detect/enable, unchanged; the duplicated device setup is gone. When #1236 merges I will rebase onto main and drop that copy.
  • Capture points no longer apply: this PR is query-only. It does not accept StreamOutput PSOs, does not implement SOSetTargets, and has no capture code, so the sType / Xfb / null-slot / counter-buffer points are not in this diff. That work stays on a separate local branch for a future capture PR.
  • AMD cache key: vk_pipeline_check now enables the extension. The remaining pipeline_cache_seed failure on AMD is #1723's robustBufferAccess, tracked as #1833, and is not caused by this PR (adrianmjim rechecked b4e4787d8 on an RX 7900 XT).
  • Commit history: the stray indirect-signature commit is gone; the history is now #1236's commit, then the vk_pipeline_check fix, then the query pools.
  • Tested: d3d12_vulkan_device, d3d12_mesh and pipeline_cache_seed pass on main 98c2f7777 + #1236, plain and with LEONIDA_VK_VALIDATION=1, on an RTX 3080 Ti (driver 616.64).

AI-assisted.

**@⁠BubsMcgee** on GitHub · 2026-11-25 13:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7163227052) Addressed the review points on this update: - **Claim:** `claiming: D3D-302` is now posted — https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608. - **Rebased onto #1236:** the first commit (`392053470`) is #1236's device detect/enable, unchanged; the duplicated device setup is gone. When #1236 merges I will rebase onto `main` and drop that copy. - **Capture points no longer apply:** this PR is query-only. It does not accept StreamOutput PSOs, does not implement `SOSetTargets`, and has no capture code, so the `sType` / Xfb / null-slot / counter-buffer points are not in this diff. That work stays on a separate local branch for a future capture PR. - **AMD cache key:** `vk_pipeline_check` now enables the extension. The remaining `pipeline_cache_seed` failure on AMD is #1723's `robustBufferAccess`, tracked as #1833, and is not caused by this PR (adrianmjim rechecked `b4e4787d8` on an RX 7900 XT). - **Commit history:** the stray indirect-signature commit is gone; the history is now #1236's commit, then the `vk_pipeline_check` fix, then the query pools. - **Tested:** `d3d12_vulkan_device`, `d3d12_mesh` and `pipeline_cache_seed` pass on `main` `98c2f7777` + #1236, plain and with `LEONIDA_VK_VALIDATION=1`, on an RTX 3080 Ti (driver 616.64). AI-assisted.
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 14:40 UTC · original

Restructured on top of #1891, which adopts #1236 and carries the vk_pipeline_check parity fix. The device detect/enable and the vk_pipeline_check change are no longer duplicated here; this PR is now only the SO_STATISTICS query pools, stacked on #1891. Once #1891 merges I rebase onto main and the two foundation commits drop.

Also: the remaining AMD pipeline_cache_seed mismatch is #1833 (robustBufferAccess), where I flagged that the checker passes an OR of update-after-bind flags while the runtime passes the six-feature info.bindless AND, so it can still choose a different robustness setting on some devices.

AI-assisted.

**@⁠BubsMcgee** on GitHub · 2026-11-25 14:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7165627376) Restructured on top of **#1891**, which adopts #1236 and carries the `vk_pipeline_check` parity fix. The device detect/enable and the `vk_pipeline_check` change are no longer duplicated here; this PR is now only the `SO_STATISTICS` query pools, stacked on #1891. Once #1891 merges I rebase onto `main` and the two foundation commits drop. Also: the remaining AMD `pipeline_cache_seed` mismatch is #1833 (`robustBufferAccess`), where I flagged that the checker passes an OR of update-after-bind flags while the runtime passes the six-feature `info.bindless` AND, so it can still choose a different robustness setting on some devices. AI-assisted.
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 16:05 UTC · original

Merge order for the TF cluster is now on #1891 (the #1608 thread is rejecting writes at 640 comments): #1891 . This PR is step 2: rebase onto main the moment #1891 lands, dropping the three foundation commits. Ready otherwise.

**@⁠BubsMcgee** on GitHub · 2026-11-25 16:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7167579660) Merge order for the TF cluster is now on #1891 (the #1608 thread is rejecting writes at 640 comments): https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1891 . This PR is step 2: rebase onto main the moment #1891 lands, dropping the three foundation commits. Ready otherwise.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 17:30 UTC · original

Thanks for narrowing it, @⁠BubsMcgee. The claim is accepted. Still open:

  • Two overlapping SO_STATISTICS queries on the same stream become two active indexed queries (VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753). prepare() should refuse or split them, with a test.
  • Gate the pool on transformFeedbackQueries, and on maxTransformFeedbackStreams for streams above 0.
  • Add a test that fails without the change.
  • It waits on #1891 (or #1236).

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 17:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7169595963) Thanks for narrowing it, @⁠BubsMcgee. The claim is accepted. Still open: - Two overlapping `SO_STATISTICS` queries on the same stream become two active indexed queries (`VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753`). `prepare()` should refuse or split them, with a test. - Gate the pool on `transformFeedbackQueries`, and on `maxTransformFeedbackStreams` for streams above 0. - Add a test that fails without the change. - It waits on #1891 (or #1236). AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 19:12 UTC · original

Acknowledged the three remaining items: (1) refuse or split two overlapping SO_STATISTICS queries on the same stream (VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753) with a test, (2) gate the pool on ransformFeedbackQueries and on maxTransformFeedbackStreams for streams above 0, (3) a test that fails without the change. I will take them in that order, rerun d3d12_vulkan_device/d3d12_state_map plain and with LEONIDA_VK_VALIDATION=1, then rebase onto main after #1891 lands.

**@⁠BubsMcgee** on GitHub · 2026-11-25 19:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7171973877) Acknowledged the three remaining items: (1) refuse or split two overlapping SO_STATISTICS queries on the same stream (VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753) with a test, (2) gate the pool on ransformFeedbackQueries and on maxTransformFeedbackStreams for streams above 0, (3) a test that fails without the change. I will take them in that order, rerun d3d12_vulkan_device/d3d12_state_map plain and with LEONIDA_VK_VALIDATION=1, then rebase onto main after #1891 lands.
Author
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 19:25 UTC · original

Took the three review points in 369bb1c75:

  • Overlapping SO_STATISTICS on one stream — prepare() now keeps the active SO queries by heap and stream and returns ReplayResult::invalid_query for a second Begin on a stream already active in that pool (VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753). Different streams still run together. A test that fails without this is case 18 in replay_query_predication_test.
  • Pool gating — an SO_STATISTICS heap only creates VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT when VK_EXT_transform_feedback is on and its transformFeedbackQueries property is set and maxTransformFeedbackStreams is nonzero. A stream at or above maxTransformFeedbackStreams runs nothing and resolves zero (the indexed begin is not issued, so no invalid index), same path as a heap with no pool.
  • Docs/comments — docs/d3d12_vulkan.md §4.6 and the GPU test's comment now say what is gated.

Tested d3d12_vulkan_device, d3d12_state_map and replay_query_predication on an RTX 3080 Ti (driver 616.64), plain and with LEONIDA_VK_VALIDATION=1; all pass. Still stacked on #1891, to be rebased onto main when it lands.

AI-assisted (Claude, opencode).

**@⁠BubsMcgee** on GitHub · 2026-11-25 19:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7172266700) Took the three review points in `369bb1c75`: - **Overlapping SO_STATISTICS on one stream** — `prepare()` now keeps the active SO queries by heap and stream and returns `ReplayResult::invalid_query` for a second Begin on a stream already active in that pool (`VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753`). Different streams still run together. A test that fails without this is case 18 in `replay_query_predication_test`. - **Pool gating** — an `SO_STATISTICS` heap only creates `VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` when `VK_EXT_transform_feedback` is on **and** its `transformFeedbackQueries` property is set **and** `maxTransformFeedbackStreams` is nonzero. A stream at or above `maxTransformFeedbackStreams` runs nothing and resolves zero (the indexed begin is not issued, so no invalid `index`), same path as a heap with no pool. - **Docs/comments** — `docs/d3d12_vulkan.md` §4.6 and the GPU test's comment now say what is gated. Tested `d3d12_vulkan_device`, `d3d12_state_map` and `replay_query_predication` on an RTX 3080 Ti (driver 616.64), plain and with `LEONIDA_VK_VALIDATION=1`; all pass. Still stacked on #1891, to be rebased onto `main` when it lands. AI-assisted (Claude, opencode).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:37 UTC · original

Merged, thanks! Your three points are in, plus one maintainer commit on top (6af9c80a9):

  • Overlap across heaps: VUID-04753 holds for the whole command buffer, not one pool, so two heaps beginning stream 0 together were still invalid. The check now keeps one bit per stream, and case 18 covers two heaps on one stream: refused when they overlap, fine when they take turns.
  • Updated: main merged into the branch (dd6d3fd8a), with no conflicts.
  • Tested: the full Windows suite under Wine on lavapipe and RADV (gfx1036 iGPU), on exactly this tree: no test went from pass to fail. With the old per-heap key, the new case fails on both devices.
  • Checked on main 1bf5eeafd + 844519ab5: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 7 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 22:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1630#issuecomment-7176591888) Merged, thanks! Your three points are in, plus one maintainer commit on top (`6af9c80a9`): - **Overlap across heaps:** VUID-04753 holds for the whole command buffer, not one pool, so two heaps beginning stream 0 together were still invalid. The check now keeps one bit per stream, and case 18 covers two heaps on one stream: refused when they overlap, fine when they take turns. - **Updated:** `main` merged into the branch (`dd6d3fd8a`), with no conflicts. - **Tested:** the full Windows suite under Wine on lavapipe and RADV (gfx1036 iGPU), on exactly this tree: no test went from pass to fail. With the old per-heap key, the new case fails on both devices. - **Checked on `main` `1bf5eeafd` + `844519ab5`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 7 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.