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

Closed
Miici0 wants to merge 3 commits from upstream-pr/1986 into main
Miici0 commented 2026-11-25 17:27:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Miici0 on 2026-11-25T17:27:31Z.


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

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5496014921 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1986). Originally posted by [Miici0](https://github.com/Miici0) on 2026-11-25T17:27:31Z. --- Claimed in the coordination issue as: D3D-STREAMOUTPUT-RASTERIZED-STREAM (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7165139723) 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.
MoonEyes commented 2026-11-28 17:58:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:58:07Z.


Hi @Miici0, thanks for this pull request. It currently conflicts with main (conflicting file(s): 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), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243426254 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1986#issuecomment-7243426254). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:58:07Z. --- Hi @Miici0, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `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`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
enlight3d commented 2026-11-29 12:03:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T12:03:16Z.


Run of this pull request on a second machine (head only: this branch does not merge cleanly into current main).

Heads: PR head e045ccce3 (3 commits, built on main fce586c6d), current main 8fb974878.
Merge into main: conflicts in 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. I therefore built and tested the PR head itself (detached), not a merge.

Commands (RelWithDebInfo, Ninja, -DLEONIDA_REQUIRE_VULKAN=ON):

git checkout --detach pr-1986
cmake --build runtime/build --target d3d12_stream_output_test d3d12_pso_validation_test d3d12_draw_test gta6rt -j 8
ctest -R "^(d3d12_stream_output|d3d12_pso_validation|d3d12_draw)$" --output-on-failure -j1

Green: d3d12_stream_output, d3d12_pso_validation and d3d12_draw pass (3/3). Verbose output of d3d12_stream_output: "RasterizedStream=0: 3 vertices captured, 0 mismatches" and "NO_RASTERIZED_STREAM: 3 vertices captured, 0 mismatches".

Red (behavioural: the test still builds and runs; only the PR's logic is reverted): same head with runtime/shims/d3d12_vulkan_device.cpp and runtime/src/vulkan_replay.h restored to the parent of the last commit, test files kept. d3d12_stream_output then fails: CreateGraphicsPipelineState is refused ("StreamOutput with a RasterizedStream other than 0 is not supported yet") at the NO_RASTERIZED_STREAM case, after the RasterizedStream=0 case passed. As the PR says, an explicit non-zero stream index is not exercised by this test, so that path is not covered here either.

Link: gta6rt.exe built from the PR head vs gta6rt.exe built from main 8fb974878 (dumpbin /imports, DLL!symbol, sorted): the only import present in the head and not in main is api-ms-win-crt-stdio-l1-1-0.dll!__stdio_common_vswscanf. It comes from the older base (main since replaced that swscanf call), not from this diff, which adds no scanf call. The PR adds no other import. (The reverse direction is large because the head is older than main.)

Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1.

The branch is behind main and conflicts in the files above; it would be easier to merge once main is merged into it. Thank you.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7255532495 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1986#issuecomment-7255532495). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T12:03:16Z. --- Run of this pull request on a second machine (head only: this branch does not merge cleanly into current main). Heads: PR head e045ccce3 (3 commits, built on main fce586c6d), current main 8fb974878. Merge into main: conflicts in 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. I therefore built and tested the PR head itself (detached), not a merge. Commands (RelWithDebInfo, Ninja, -DLEONIDA_REQUIRE_VULKAN=ON): ``` git checkout --detach pr-1986 cmake --build runtime/build --target d3d12_stream_output_test d3d12_pso_validation_test d3d12_draw_test gta6rt -j 8 ctest -R "^(d3d12_stream_output|d3d12_pso_validation|d3d12_draw)$" --output-on-failure -j1 ``` Green: d3d12_stream_output, d3d12_pso_validation and d3d12_draw pass (3/3). Verbose output of d3d12_stream_output: "RasterizedStream=0: 3 vertices captured, 0 mismatches" and "NO_RASTERIZED_STREAM: 3 vertices captured, 0 mismatches". Red (behavioural: the test still builds and runs; only the PR's logic is reverted): same head with runtime/shims/d3d12_vulkan_device.cpp and runtime/src/vulkan_replay.h restored to the parent of the last commit, test files kept. d3d12_stream_output then fails: CreateGraphicsPipelineState is refused ("StreamOutput with a RasterizedStream other than 0 is not supported yet") at the NO_RASTERIZED_STREAM case, after the RasterizedStream=0 case passed. As the PR says, an explicit non-zero stream index is not exercised by this test, so that path is not covered here either. Link: gta6rt.exe built from the PR head vs gta6rt.exe built from main 8fb974878 (dumpbin /imports, DLL!symbol, sorted): the only import present in the head and not in main is api-ms-win-crt-stdio-l1-1-0.dll!__stdio_common_vswscanf. It comes from the older base (main since replaced that swscanf call), not from this diff, which adds no scanf call. The PR adds no other import. (The reverse direction is large because the head is older than main.) Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1. The branch is behind main and conflicts in the files above; it would be easier to merge once main is merged into it. Thank you.
aslan2142 commented 2026-12-01 16:40:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:40:33Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318012930 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1986#issuecomment-7318012930). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:40:33Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1986
No description provided.