d3d12: color MIN and MAX resolves for typed 2D resources #240

Open
github-bot wants to merge 2 commits from github-bot/gh-240 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:51 UTC · original
ubiquitarianism:old-pr/9971 → main · +730 −12 · 12 files · 2 commits · draft

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.
**@⁠Andretuta** on GitHub · 2026-11-24 02:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/240) `ubiquitarianism:old-pr/9971` → `main` · +730 −12 · 12 files · 2 commits · draft > 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:50:05 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/src/vulkan_backend.h
  • runtime/src/vulkan_replay.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/240/head:github-bot/gh-240'
git switch 'github-bot/gh-240'

Merge

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