[PR #290] d3d12: honour RASTERIZER_DESC2 LineRasterizationMode with VK_EXT_line_rasterization #342

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/290
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/10021


📝 Commits (4)

  • ebef045 fix: preserve rasterizer2 line modes
  • 90e1a46 fix: ALPHA_ANTIALIASED line mode uses the Vulkan RECTANGULAR_SMOOTH enum
  • ce54149 fix: no Bresenham or smooth line state when alpha-to-coverage is on (VUID 02766)
  • b9918c1 test: draw LINE_LIST per D3D12_LINE_RASTERIZATION_MODE and check the pixels; note that wide and narrow are one Vulkan mode

📊 Changes

5 files changed (+364 additions, -3 deletions)

View changed files

📝 runtime/shims/d3d12_com.h (+4 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+56 -3)
📝 runtime/test/d3d12_draw_test.cpp (+237 -0)
📝 runtime/test/d3d12_pso_validation_test.cpp (+45 -0)
📝 runtime/test/vk_test_device.h (+22 -0)

📄 Description

Carried over from old PR 10021 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10021, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
tedin7: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

What

A graphics PSO created from the pipeline-state stream now honours D3D12_RASTERIZER_DESC2::LineRasterizationMode (it was dropped, every LINE_LIST drew with Vulkan's default line state).

  • ALIASED -> VK_LINE_RASTERIZATION_MODE_BRESENHAM, ALPHA_ANTIALIASED -> RECTANGULAR_SMOOTH, QUADRILATERAL_WIDE and NARROW -> RECTANGULAR. Vulkan has no narrow quadrilateral mode, so WIDE and NARROW are one mode here (noted in a comment and in the test).
  • The line state is not chained when the device lacks the matching VK_EXT_line_rasterization feature, and for Bresenham/smooth it is left out when alpha-to-coverage is on (VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766).
  • The mode is part of the PSO cache key, so two streams that differ only in line mode do not share a pipeline.
  • Test device (vk_test_device.h) can request the extension; d3d12_draw_test draws a LINE_LIST per mode and counts pixels; d3d12_pso_validation_test checks the refusals.

Why

Lines are drawn by the game's debug/overlay and some world passes; with the mode ignored, ALPHA_ANTIALIASED lines came out aliased and the VUID above could fire as a validation error on a device with alpha-to-coverage PSOs. It is part of getting 3D rendering state right once a PSO is built.

Tested

Local: clang-cl 19 + xwin SDK cross build, run under Wine on lavapipe (llvmpipe, LLVM 19.1.7). No real GPU. Built on current main plus #9809 applied only in a scratch tree (main does not build right now, issue #9812); that patch is not in this PR.

  • d3d12_pso_validation_test: PASS, 60 layer checks.
  • d3d12_draw_test: exit 0. Line modes, features on (bresenham 1 smooth 1 rectangular 1): aliased=52 pixels (partial 0), alpha_antialiased=160 (partial 112), quadrilateral_wide=52, quadrilateral_narrow=52. Features off: all four 52 (partial 0), so no line state is chained.
  • Negative control: same test, shim fix reverted (main's d3d12_vulkan_device.cpp, new test kept): d3d12_draw_test exits 1 at the line-mode check. With the fix it exits 0.

Not run: the whole runtime suite, real NVIDIA/AMD hardware, Windows host comparisons (Wine's D3D12 is not Microsoft's, those are skipped).

Rebased cleanly on current main; supersedes #8716 closed during org migration.


🔄 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/290 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/10021` --- ### 📝 Commits (4) - [`ebef045`](https://github.com/ubiquitarianism/leonida/commit/ebef045e6d27d3ae24a94d9d94463deb2ecc804b) fix: preserve rasterizer2 line modes - [`90e1a46`](https://github.com/ubiquitarianism/leonida/commit/90e1a46ca5c98dbd5f7b5a71ce6ec6b69b502b72) fix: ALPHA_ANTIALIASED line mode uses the Vulkan RECTANGULAR_SMOOTH enum - [`ce54149`](https://github.com/ubiquitarianism/leonida/commit/ce541490f91c8eaa055dafcec60946e22231f921) fix: no Bresenham or smooth line state when alpha-to-coverage is on (VUID 02766) - [`b9918c1`](https://github.com/ubiquitarianism/leonida/commit/b9918c13d359992d8dec500a51bf72773f09e186) test: draw LINE_LIST per D3D12_LINE_RASTERIZATION_MODE and check the pixels; note that wide and narrow are one Vulkan mode ### 📊 Changes **5 files changed** (+364 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_com.h` (+4 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+56 -3) 📝 `runtime/test/d3d12_draw_test.cpp` (+237 -0) 📝 `runtime/test/d3d12_pso_validation_test.cpp` (+45 -0) 📝 `runtime/test/vk_test_device.h` (+22 -0) </details> ### 📄 Description > Carried over from **old PR 10021** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10021`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `tedin7`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): ## What A graphics PSO created from the pipeline-state stream now honours `D3D12_RASTERIZER_DESC2::LineRasterizationMode` (it was dropped, every LINE_LIST drew with Vulkan's default line state). - ALIASED -> `VK_LINE_RASTERIZATION_MODE_BRESENHAM`, ALPHA_ANTIALIASED -> `RECTANGULAR_SMOOTH`, QUADRILATERAL_WIDE and NARROW -> `RECTANGULAR`. Vulkan has no narrow quadrilateral mode, so WIDE and NARROW are one mode here (noted in a comment and in the test). - The line state is not chained when the device lacks the matching `VK_EXT_line_rasterization` feature, and for Bresenham/smooth it is left out when alpha-to-coverage is on (VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766). - The mode is part of the PSO cache key, so two streams that differ only in line mode do not share a pipeline. - Test device (`vk_test_device.h`) can request the extension; `d3d12_draw_test` draws a LINE_LIST per mode and counts pixels; `d3d12_pso_validation_test` checks the refusals. ## Why Lines are drawn by the game's debug/overlay and some world passes; with the mode ignored, ALPHA_ANTIALIASED lines came out aliased and the VUID above could fire as a validation error on a device with alpha-to-coverage PSOs. It is part of getting 3D rendering state right once a PSO is built. ## Tested Local: clang-cl 19 + xwin SDK cross build, run under Wine on lavapipe (llvmpipe, LLVM 19.1.7). No real GPU. Built on current main plus `#9809` applied only in a scratch tree (main does not build right now, issue `#9812`); that patch is not in this PR. - `d3d12_pso_validation_test`: PASS, 60 layer checks. - `d3d12_draw_test`: exit 0. Line modes, features on (bresenham 1 smooth 1 rectangular 1): aliased=52 pixels (partial 0), alpha_antialiased=160 (partial 112), quadrilateral_wide=52, quadrilateral_narrow=52. Features off: all four 52 (partial 0), so no line state is chained. - Negative control: same test, shim fix reverted (main's d3d12_vulkan_device.cpp, new test kept): `d3d12_draw_test` exits 1 at the line-mode check. With the fix it exits 0. Not run: the whole runtime suite, real NVIDIA/AMD hardware, Windows host comparisons (Wine's D3D12 is not Microsoft's, those are skipped). Rebased cleanly on current main; supersedes `#8716` closed during org migration. --- <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#342
No description provided.