[PR #240] d3d12: color MIN and MAX resolves for typed 2D resources #291

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/9971


📝 Commits (2)

  • ab27482 Implement Vulkan color MIN and MAX resolves
  • 95c52ee test: d3d12_vulkan_device expects a colour MAX resolve to be accepted and keeps a non-resolve mode refused

📊 Changes

12 files changed (+730 additions, -12 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+6 -0)
📝 runtime/shims/d3d12_com.cpp (+9 -0)
📝 runtime/shims/d3d12_com.h (+1 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+18 -0)
➕ runtime/src/color_resolve.frag (+31 -0)
➕ runtime/src/color_resolve.vert (+6 -0)
➕ runtime/src/color_resolve_spv.h (+199 -0)
📝 runtime/src/vulkan_backend.h (+20 -0)
➕ runtime/src/vulkan_color_resolve.h (+278 -0)
📝 runtime/src/vulkan_replay.h (+119 -9)
📝 runtime/test/d3d12_msaa_draw_test.cpp (+38 -3)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+5 -0)

📄 Description

Carried over from old PR 9971 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9971, 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

Vulkan color D3D12_RESOLVE_MODE_MIN / MAX resolves for typed 2D resources (ResolveSubresourceRegion). The replay now runs a small fullscreen pass (runtime/src/color_resolve.vert/.frag, SPIR-V checked in as color_resolve_spv.h, driver vulkan_color_resolve.h) that takes the per-channel min or max over the samples of the source. AVERAGE and the existing depth/stencil path are unchanged. A mode that is not a colour resolve at all (for example ENCODE_SAMPLER_FEEDBACK, value 4) is still refused at Close with E_INVALIDARG.

Why

Before this, a command list with a colour MIN or MAX resolve failed at ExecuteCommandLists ("invalid copy or resolve; nothing was submitted"), so any frame that records one is dropped whole. That is a first-frame blocker for titles that use these modes.

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

Tested

Built locally with clang-cl-19 + xwin and run under Wine 10 on lavapipe (llvmpipe, LLVM 19.1.7). No GPU pod: all pods are off.

  • d3d12_msaa_draw_test: exit 0 with the fix. Output: "MSAA: 4x draws resolved, 4096 pixels matched; 64 of 189 edge pixels are partial". New checks: a 4x target with only sample 0 written resolves to {0,0,0,255} under MIN and {0,255,255,255} under MAX inside the 8x8 rect, and to the 1:3 mix under AVERAGE, all 64 pixels x 3 modes compared byte for byte with a read-back.
  • Negative control (same two test files on origin/main code): d3d12_msaa_draw_test exits 1 at line 296: list->Close() == S_OK; d3d12_vulkan_device_test exits 1 at its new line 6280 list->Close() == S_OK (colour MAX resolve).
  • d3d12_vulkan_device_test: passes the new MAX-accepted and mode-4-refused checks, then stops at line 6581 (tiles == 1, GetResourceTiling on llvmpipe). The same line 6581 failure occurs on main without my change.
  • d3d12_depth_resolve_test and d3d12_view_slices_test exit 1 on llvmpipe both with and without this change; their full output is line for line identical (47 lines; view_slices "6 failures" on both). No regression, but not a clean pass either.

Not verified

  • No real GPU run (pods off); only llvmpipe.
  • At test time main did not compile (console descriptor heap, known; #9809 / #9815 fix it). For the runs I applied a throwaway local patch to those two shim files in a scratch tree; it is not in this PR. I rebased onto the latest main afterwards without rebuilding.

🔄 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/240 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9971` --- ### 📝 Commits (2) - [`ab27482`](https://github.com/ubiquitarianism/leonida/commit/ab27482471aa617eee24337071387c5cf35f0451) Implement Vulkan color MIN and MAX resolves - [`95c52ee`](https://github.com/ubiquitarianism/leonida/commit/95c52eed87e3918295d29a04ed7811c6ed1f6508) test: d3d12_vulkan_device expects a colour MAX resolve to be accepted and keeps a non-resolve mode refused ### 📊 Changes **12 files changed** (+730 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+6 -0) 📝 `runtime/shims/d3d12_com.cpp` (+9 -0) 📝 `runtime/shims/d3d12_com.h` (+1 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+18 -0) ➕ `runtime/src/color_resolve.frag` (+31 -0) ➕ `runtime/src/color_resolve.vert` (+6 -0) ➕ `runtime/src/color_resolve_spv.h` (+199 -0) 📝 `runtime/src/vulkan_backend.h` (+20 -0) ➕ `runtime/src/vulkan_color_resolve.h` (+278 -0) 📝 `runtime/src/vulkan_replay.h` (+119 -9) 📝 `runtime/test/d3d12_msaa_draw_test.cpp` (+38 -3) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+5 -0) </details> ### 📄 Description > Carried over from **old PR 9971** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9971`, 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 Vulkan color `D3D12_RESOLVE_MODE_MIN` / `MAX` resolves for typed 2D resources (`ResolveSubresourceRegion`). The replay now runs a small fullscreen pass (`runtime/src/color_resolve.vert/.frag`, SPIR-V checked in as `color_resolve_spv.h`, driver `vulkan_color_resolve.h`) that takes the per-channel min or max over the samples of the source. AVERAGE and the existing depth/stencil path are unchanged. A mode that is not a colour resolve at all (for example ENCODE_SAMPLER_FEEDBACK, value 4) is still refused at Close with E_INVALIDARG. ## Why Before this, a command list with a colour MIN or MAX resolve failed at `ExecuteCommandLists` ("invalid copy or resolve; nothing was submitted"), so any frame that records one is dropped whole. That is a first-frame blocker for titles that use these modes. Rebased cleanly on current main; supersedes `#8685` closed during org migration. ## Tested Built locally with clang-cl-19 + xwin and run under Wine 10 on lavapipe (llvmpipe, LLVM 19.1.7). No GPU pod: all pods are off. - `d3d12_msaa_draw_test`: exit 0 with the fix. Output: "MSAA: 4x draws resolved, 4096 pixels matched; 64 of 189 edge pixels are partial". New checks: a 4x target with only sample 0 written resolves to {0,0,0,255} under MIN and {0,255,255,255} under MAX inside the 8x8 rect, and to the 1:3 mix under AVERAGE, all 64 pixels x 3 modes compared byte for byte with a read-back. - Negative control (same two test files on origin/main code): `d3d12_msaa_draw_test` exits 1 at `line 296: list->Close() == S_OK`; `d3d12_vulkan_device_test` exits 1 at its new line 6280 `list->Close() == S_OK` (colour MAX resolve). - `d3d12_vulkan_device_test`: passes the new MAX-accepted and mode-4-refused checks, then stops at line 6581 (`tiles == 1`, GetResourceTiling on llvmpipe). The same line 6581 failure occurs on main without my change. - `d3d12_depth_resolve_test` and `d3d12_view_slices_test` exit 1 on llvmpipe both with and without this change; their full output is line for line identical (47 lines; view_slices "6 failures" on both). No regression, but not a clean pass either. ## Not verified - No real GPU run (pods off); only llvmpipe. - At test time main did not compile (console descriptor heap, known; `#9809` / `#9815` fix it). For the runs I applied a throwaway local patch to those two shim files in a scratch tree; it is not in this PR. I rebased onto the latest main afterwards without rebuilding. --- <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#291
No description provided.