[PR #1884] d3d12: accept StreamOutput PSOs, implement SOSetTargets, capture draws via VK_EXT_transform_feedback (D3D-STREAMOUTPUT-RUNTIME) #1897

Open
opened 2026-11-26 21:19:20 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1884
Author: @Miici0
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/d3d-stream-output-runtime


📝 Commits (2)

  • c99f265 d3d12_vulkan_device: detect and enable VK_EXT_transform_feedback
  • 9fc0789 d3d12: accept StreamOutput PSOs, implement SOSetTargets, capture draws via VK_EXT_transform_feedback

📊 Changes

11 files changed (+477 additions, -7 deletions)

View changed files

📝 runtime/CMakeLists.txt (+27 -0)
📝 runtime/shims/d3d12_com.cpp (+27 -0)
📝 runtime/shims/d3d12_com.h (+12 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+60 -6)
📝 runtime/src/command_list.h (+9 -0)
📝 runtime/src/vulkan_backend.h (+6 -1)
📝 runtime/src/vulkan_replay.h (+76 -0)
➕ runtime/test/d3d12_stream_output_test.cpp (+207 -0)
➕ runtime/test/glsl/ps_stream_output.frag (+9 -0)
➕ runtime/test/glsl/vs_stream_output.vert (+11 -0)
📝 runtime/test/vk_test_device.h (+33 -0)

📄 Description

Claimed in the coordination issue as: D3D-STREAMOUTPUT-RUNTIME (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164990951)

Depends on: #1236

What and why

The capture path #1630 (D3D-302) explicitly left unclaimed: "StreamOutput PSOs are still refused and SOSetTargets is still not implemented; the capture path is not part of this PR." This PR is that capture path.

A graphics PSO that declares StreamOutput is now accepted instead of refused (the common case: RasterizedStream 0, NumStrides within the device's maxTransformFeedbackBuffers). SOSetTargets stores the bound buffers on the command list the same way IASetVertexBuffers already does. A draw whose pipeline has StreamOutput and every declared buffer slot currently bound wraps itself in vkCmdBindTransformFeedbackBuffersEXT + vkCmdBeginTransformFeedbackEXT/vkCmdEndTransformFeedbackEXT, writing real captured data to the bound buffers.

Stacked on #1236, same as #1630: the first commit is #1236's device detect/enable, unchanged. When #1236 merges I will rebase and drop that copy.

Touches the same few files as #1630 (d3d12_com.h, d3d12_vulkan_device.cpp, vulkan_backend.h, vulkan_replay.h) but a different part of each - the query-heap code I touched is only a comment update (the SO_STATISTICS pools themselves stay #1630's). A rebase against each other may be needed depending on merge order.

Not done, left as follow-up (noted in the code and in docs/d3d12_vulkan.md):

  • RasterizedStream other than 0 (needs VkPipelineRasterizationStateStreamCreateInfoEXT / rasterizerDiscardEnable at pipeline creation)
  • SO_STATISTICS queries (#1630's follow-up)
  • Matching a real translated game shader's output semantics to StreamOutput buffer slots, which needs patching Xfb decorations into its SPIR-V at PSO-creation time (the translator runs before any PSO exists, so it cannot know this ahead of time)

Tested

New test d3d12_stream_output_test.cpp: a StreamOutput PSO with a hand-written vertex shader (runtime/test/glsl/vs_stream_output.vert, Xfb-decorated, writes the fixed vec4 (1,2,3,4)) draws 3 vertices; the buffer SOSetTargets bound is read back and every vertex's 16 bytes are checked against that constant. 0 mismatches on real hardware.

Full ctest (runtime/build, RelWithDebInfo): 307/308 pass (one more test than main, the new one); the only failure is the pre-existing d3d12_execute_indirect_validation (#504, fixed by the separate PR #1066, unrelated to this change). No regressions.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974, Vulkan SDK 1.4.363.1.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main (stacked on #1236) and merges cleanly.
  • One topic; follow-up work (RasterizedStream != 0, SO_STATISTICS, real-shader SPIR-V patching) goes in new pull requests.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • N/A: no new translator rule.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1884 **Author:** [@Miici0](https://github.com/Miici0) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/d3d-stream-output-runtime` --- ### 📝 Commits (2) - [`c99f265`](https://github.com/ubiquitarianism/leonida/commit/c99f26559a4cca1866da4891a3cfb27cd5236c3e) d3d12_vulkan_device: detect and enable VK_EXT_transform_feedback - [`9fc0789`](https://github.com/ubiquitarianism/leonida/commit/9fc0789e2e6ec165eae3cff1ab0be7da633e9890) d3d12: accept StreamOutput PSOs, implement SOSetTargets, capture draws via VK_EXT_transform_feedback ### 📊 Changes **11 files changed** (+477 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+27 -0) 📝 `runtime/shims/d3d12_com.cpp` (+27 -0) 📝 `runtime/shims/d3d12_com.h` (+12 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+60 -6) 📝 `runtime/src/command_list.h` (+9 -0) 📝 `runtime/src/vulkan_backend.h` (+6 -1) 📝 `runtime/src/vulkan_replay.h` (+76 -0) ➕ `runtime/test/d3d12_stream_output_test.cpp` (+207 -0) ➕ `runtime/test/glsl/ps_stream_output.frag` (+9 -0) ➕ `runtime/test/glsl/vs_stream_output.vert` (+11 -0) 📝 `runtime/test/vk_test_device.h` (+33 -0) </details> ### 📄 Description Claimed in the coordination issue as: D3D-STREAMOUTPUT-RUNTIME (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164990951) Depends on: #1236 ### What and why The capture path #1630 (D3D-302) explicitly left unclaimed: "StreamOutput PSOs are still refused and SOSetTargets is still not implemented; the capture path is not part of this PR." This PR is that capture path. A graphics PSO that declares `StreamOutput` is now accepted instead of refused (the common case: `RasterizedStream` 0, `NumStrides` within the device's `maxTransformFeedbackBuffers`). `SOSetTargets` stores the bound buffers on the command list the same way `IASetVertexBuffers` already does. A draw whose pipeline has `StreamOutput` and every declared buffer slot currently bound wraps itself in `vkCmdBindTransformFeedbackBuffersEXT` + `vkCmdBeginTransformFeedbackEXT`/`vkCmdEndTransformFeedbackEXT`, writing real captured data to the bound buffers. **Stacked on #1236**, same as #1630: the first commit is #1236's device detect/enable, unchanged. When #1236 merges I will rebase and drop that copy. **Touches the same few files as #1630** (`d3d12_com.h`, `d3d12_vulkan_device.cpp`, `vulkan_backend.h`, `vulkan_replay.h`) but a different part of each - the query-heap code I touched is only a comment update (the `SO_STATISTICS` pools themselves stay #1630's). A rebase against each other may be needed depending on merge order. **Not done, left as follow-up** (noted in the code and in `docs/d3d12_vulkan.md`): - `RasterizedStream` other than 0 (needs `VkPipelineRasterizationStateStreamCreateInfoEXT` / `rasterizerDiscardEnable` at pipeline creation) - `SO_STATISTICS` queries (#1630's follow-up) - Matching a real translated game shader's output semantics to StreamOutput buffer slots, which needs patching `Xfb` decorations into its SPIR-V at PSO-creation time (the translator runs before any PSO exists, so it cannot know this ahead of time) ### Tested New test `d3d12_stream_output_test.cpp`: a StreamOutput PSO with a hand-written vertex shader (`runtime/test/glsl/vs_stream_output.vert`, `Xfb`-decorated, writes the fixed vec4 `(1,2,3,4)`) draws 3 vertices; the buffer `SOSetTargets` bound is read back and every vertex's 16 bytes are checked against that constant. 0 mismatches on real hardware. Full `ctest` (`runtime/build`, RelWithDebInfo): 307/308 pass (one more test than `main`, the new one); the only failure is the pre-existing `d3d12_execute_indirect_validation` (#504, fixed by the separate PR #1066, unrelated to this change). No regressions. GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974, Vulkan SDK 1.4.363.1. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` (stacked on #1236) and merges cleanly. - [x] One topic; follow-up work (RasterizedStream != 0, SO_STATISTICS, real-shader SPIR-V patching) goes in new pull requests. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [ ] N/A: no new translator rule. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1897
No description provided.