d3d12: support StreamOutput RasterizedStream other than 0 (D3D-STREAMOUTPUT-RASTERIZED-STREAM) #1986

Open
github-bot wants to merge 3 commits from github-bot/gh-1986 into main AGit
Owner

@⁠Miici0 on GitHub · 2026-11-25 17:27 UTC · original
Miici0:feat/d3d-stream-output-rasterized-stream → main · +527 −7 · 11 files · 3 commits · open

Claimed in the coordination issue as: D3D-STREAMOUTPUT-RASTERIZED-STREAM (#1608)

Depends on: #1884

What and why

#1884 (D3D-STREAMOUTPUT-RUNTIME) refused any RasterizedStream other than 0. This PR handles the two remaining cases:

  • D3D12_SO_NO_RASTERIZED_STREAM (no stream reaches the rasterizer): rasterizerDiscardEnable on the pipeline's rasterization state. Needs no extra Vulkan feature; still captures everything via transform feedback.
  • An explicit non-default stream index: VkPipelineRasterizationStateStreamCreateInfoEXT chained into the rasterization state, gated on the geometryStreams feature (detected/enabled by #1236) and the index being below the device's maxTransformFeedbackStreams.

The pipeline-creation refusal and the Recipe/build() rasterization-state wiring are both updated; the draw-replay capture path is unaffected (capture is per XFB buffer slot, not per rasterized stream).

Tested

d3d12_stream_output_test.cpp now runs its capture check twice: once at RasterizedStream 0 (as before) and once at D3D12_SO_NO_RASTERIZED_STREAM. Both capture all 3 vertices correctly, 0 mismatches, on real hardware.

An explicit non-zero stream index needs a multi-stream geometry shader to exercise meaningfully, which this PR does not add; that code path is implemented per the Vulkan spec but not independently tested here.

Full ctest (runtime/build, RelWithDebInfo): same pattern as #1884, only the pre-existing d3d12_execute_indirect_validation failure (#1066, unrelated). 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 #1884, which is stacked on #1236) and merges cleanly.
  • One topic; follow-up work (testing a real non-zero stream with a multi-stream geometry shader) goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • N/A: no new translator rule.
**@⁠Miici0** on GitHub · 2026-11-25 17:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1986) `Miici0:feat/d3d-stream-output-rasterized-stream` → `main` · +527 −7 · 11 files · 3 commits · open Claimed in the coordination issue as: D3D-STREAMOUTPUT-RASTERIZED-STREAM (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: #1884 ### What and why #1884 (D3D-STREAMOUTPUT-RUNTIME) refused any `RasterizedStream` other than 0. This PR handles the two remaining cases: - `D3D12_SO_NO_RASTERIZED_STREAM` (no stream reaches the rasterizer): `rasterizerDiscardEnable` on the pipeline's rasterization state. Needs no extra Vulkan feature; still captures everything via transform feedback. - An explicit non-default stream index: `VkPipelineRasterizationStateStreamCreateInfoEXT` chained into the rasterization state, gated on the `geometryStreams` feature (detected/enabled by #1236) and the index being below the device's `maxTransformFeedbackStreams`. The pipeline-creation refusal and the `Recipe`/`build()` rasterization-state wiring are both updated; the draw-replay capture path is unaffected (capture is per XFB buffer slot, not per rasterized stream). ### Tested `d3d12_stream_output_test.cpp` now runs its capture check twice: once at `RasterizedStream` 0 (as before) and once at `D3D12_SO_NO_RASTERIZED_STREAM`. Both capture all 3 vertices correctly, 0 mismatches, on real hardware. An explicit non-zero stream index needs a multi-stream geometry shader to exercise meaningfully, which this PR does not add; that code path is implemented per the Vulkan spec but not independently tested here. Full `ctest` (`runtime/build`, RelWithDebInfo): same pattern as #1884, only the pre-existing `d3d12_execute_indirect_validation` failure (#1066, unrelated). 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 #1884, which is stacked on #1236) and merges cleanly. - [x] One topic; follow-up work (testing a real non-zero stream with a multi-stream geometry shader) goes in a new pull request. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [ ] N/A: no new translator rule.
Foundation for D3D-302 (stream output): read the physical device's
transformFeedback/geometryStreams features where the extension is
present, record them on VulkanDeviceInfo, and enable them on the
logical device when supported, exactly the same pattern the existing
VK_EXT_mesh_shader detection/enable code already follows.

Device-capability plumbing only: no behaviour changes yet. A graphics
PSO declaring StreamOutput is still refused and SOSetTargets is still
not implemented, same as before this commit. Confirmed
VK_EXT_transform_feedback is available (4 streams, 4 buffers) on an
NVIDIA GeForce RTX 4070 SUPER, driver 621.24.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Builds on D3D-TRANSFORM-FEEDBACK-DEVICE (the device-capability plumbing): a
graphics PSO that declares StreamOutput is now accepted instead of refused
(the common case only: RasterizedStream 0, NumStrides within the device's
maxTransformFeedbackBuffers), SOSetTargets stores the bound buffers on the
command list the same way IASetVertexBuffers does, and a draw with a pipeline
that has StreamOutput and every declared buffer slot bound wraps itself in
vkCmdBindTransformFeedbackBuffersEXT + vkCmdBeginTransformFeedbackEXT /
vkCmdEndTransformFeedbackEXT, writing real captured data.

Not done, left as follow-up:
- RasterizedStream other than 0 (needs VkPipelineRasterizationStateStreamCreateInfoEXT
  / rasterizerDiscardEnable at pipeline creation)
- SO_STATISTICS queries (still stubbed to 0; the real wiring is
  VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT with the indexed
  vkCmdBeginQueryIndexedEXT/EndQueryIndexedEXT commands)
- 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) - this PR's own test uses a hand-written GLSL shader
  with the decorations already in place, not a translated one

### 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 run (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.

GPU: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Builds on D3D-STREAMOUTPUT-RUNTIME (#1884), which refused any
RasterizedStream other than 0. Two more cases now work:

- D3D12_SO_NO_RASTERIZED_STREAM (no stream reaches the rasterizer):
  rasterizerDiscardEnable on the pipeline's rasterization state. Needs no
  extra Vulkan feature; still captures everything via transform feedback.
- An explicit non-default stream index: VkPipelineRasterizationStateStream-
  CreateInfoEXT chained into the rasterization state, gated on the
  geometryStreams feature (detected/enabled by #1236) and the index being
  below the device's maxTransformFeedbackStreams.

The pipeline-creation refusal and the Recipe/build() rasterization-state
wiring are both updated; replay is unaffected (capture is per XFB buffer
slot, not per rasterized stream).

### Tested

d3d12_stream_output_test.cpp now runs its capture check twice: once at
RasterizedStream 0 (as before) and once at D3D12_SO_NO_RASTERIZED_STREAM.
Both capture all 3 vertices correctly, 0 mismatches, on real hardware.
(An explicit non-zero stream index needs a multi-stream geometry shader to
exercise meaningfully, which this PR does not add; the code path is
implemented per the Vulkan spec but not independently tested here.)

Full ctest (runtime/build, RelWithDebInfo): same pattern as #1884, only
the pre-existing d3d12_execute_indirect_validation failure (#1066,
unrelated). No regressions.

GPU: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 26300.9974.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:13:55 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_com.h
  • runtime/shims/d3d12_vulkan_device.cpp
  • runtime/src/vulkan_backend.h
  • runtime/src/vulkan_replay.h
  • runtime/test/vk_test_device.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1986/head:github-bot/gh-1986'
git switch 'github-bot/gh-1986'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1986'
git switch 'github-bot/gh-1986'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1986'
git switch 'github-bot/gh-1986'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1986'
git switch 'main'
git merge --squash 'github-bot/gh-1986'
git switch 'main'
git merge --ff-only 'github-bot/gh-1986'
git switch 'main'
git merge 'github-bot/gh-1986'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.