[PR #292] d3d12: ResolveSubresource averages a typeless resource in the format it names (sRGB in linear light) #344

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/10023


📝 Commits (3)

  • 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
  • 9b9679e d3d12: ResolveSubresource averages a typeless resource in the format it names (sRGB in linear light)

📊 Changes

13 files changed (+911 additions, -30 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+17 -3)
📝 runtime/shims/d3d12_com.cpp (+11 -1)
📝 runtime/shims/d3d12_com.h (+5 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+28 -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/command_list.h (+4 -1)
📝 runtime/src/vulkan_backend.h (+20 -0)
➕ runtime/src/vulkan_color_resolve.h (+278 -0)
📝 runtime/src/vulkan_replay.h (+177 -20)
📝 runtime/test/d3d12_msaa_draw_test.cpp (+130 -5)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+5 -0)

📄 Description

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

Stacked on #9971

This PR is based on #9971 (colour MIN/MAX resolves): both change prepare_resolve in runtime/src/vulkan_replay.h and d3d12_msaa_draw_test.cpp. Until #9971 merges, this diff also shows its 3 commits; the only new commit is the last one (d3d12: ResolveSubresource averages a typeless resource in the format it names). Review that commit alone, or wait for #9971 and I will rebase.

What

ResolveSubresource carries its Format to the replay (a Format field in command_list.h, set only when a resource is typeless). The replay views both images in that format and resolves in a rendering scope (colour attachment, AVERAGE), so sRGB is averaged in linear light. Needs ALLOW_RENDER_TARGET on both resources, otherwise refused as before.

Why

The Format was dropped, so a typeless 4x RGBA8 resolved "as R8G8B8A8_UNORM_SRGB" was averaged as UNORM with no error, giving wrong colours; and a typeless source into a typed sRGB destination was refused in prepare_resolve (the Vulkan formats differ) and failed the whole command list, so the frame was dropped. Both are common for swapchain-style typeless render targets.

Rebased cleanly on current main; supersedes #8685's sibling work that lived only on my fork (ship-resolve-format, never opened here). The conflict with #9971 in prepare_resolve was resolved by keeping both paths: the MIN/MAX path now also requires equal source and destination formats (the check the old line had), and the typeless view path runs after it.

Tested

Local clang-cl-19 + xwin build, Wine 10 on lavapipe (llvmpipe). No GPU pod (all off).

  • d3d12_msaa_draw_test exit 0. Pixel of a 4-sample quadrant, with R/G/B/A: typeless to typeless as sRGB 0,137,225,255; typeless to typed sRGB 0,137,225,255; typeless as UNORM 0,64,191,255, all equal to the wanted values; the earlier 4096-pixel MSAA match and the MIN/MAX checks of #9971 still pass.
  • Negative control (the same new test against #9971's code, without this commit): exit 1 at line 401: last_execute_result(queue.p) == ReplayResult::success, i.e. the list is refused.
  • d3d12_vulkan_device_test: same single failure as on main, line 6581 (tiles == 1, llvmpipe tiling), nothing new.

Not verified

  • No real GPU, only llvmpipe. The linear-light average is checked against computed values, not against a Windows driver.
  • At test time main did not compile (console descriptor heap; #9809 / #9815 fix it). A throwaway local patch of those shim lines was used and is not in this PR. I did not rebuild after the last small main updates.

🔄 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/292 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/10023` --- ### 📝 Commits (3) - [`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 - [`9b9679e`](https://github.com/ubiquitarianism/leonida/commit/9b9679eb6446ec06d893814ab91e592eda02cb9f) d3d12: ResolveSubresource averages a typeless resource in the format it names (sRGB in linear light) ### 📊 Changes **13 files changed** (+911 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+17 -3) 📝 `runtime/shims/d3d12_com.cpp` (+11 -1) 📝 `runtime/shims/d3d12_com.h` (+5 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+28 -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/command_list.h` (+4 -1) 📝 `runtime/src/vulkan_backend.h` (+20 -0) ➕ `runtime/src/vulkan_color_resolve.h` (+278 -0) 📝 `runtime/src/vulkan_replay.h` (+177 -20) 📝 `runtime/test/d3d12_msaa_draw_test.cpp` (+130 -5) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+5 -0) </details> ### 📄 Description > Carried over from **old PR 10023** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10023`, 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): ## Stacked on `#9971` This PR is based on `#9971` (colour MIN/MAX resolves): both change `prepare_resolve` in `runtime/src/vulkan_replay.h` and `d3d12_msaa_draw_test.cpp`. Until `#9971` merges, this diff also shows its 3 commits; the only new commit is the last one (`d3d12: ResolveSubresource averages a typeless resource in the format it names`). Review that commit alone, or wait for `#9971` and I will rebase. ## What `ResolveSubresource` carries its `Format` to the replay (a `Format` field in `command_list.h`, set only when a resource is typeless). The replay views both images in that format and resolves in a rendering scope (colour attachment, AVERAGE), so sRGB is averaged in linear light. Needs ALLOW_RENDER_TARGET on both resources, otherwise refused as before. ## Why The Format was dropped, so a typeless 4x RGBA8 resolved "as R8G8B8A8_UNORM_SRGB" was averaged as UNORM with no error, giving wrong colours; and a typeless source into a typed sRGB destination was refused in `prepare_resolve` (the Vulkan formats differ) and failed the whole command list, so the frame was dropped. Both are common for swapchain-style typeless render targets. Rebased cleanly on current main; supersedes `#8685`'s sibling work that lived only on my fork (ship-resolve-format, never opened here). The conflict with `#9971` in `prepare_resolve` was resolved by keeping both paths: the MIN/MAX path now also requires equal source and destination formats (the check the old line had), and the typeless view path runs after it. ## Tested Local clang-cl-19 + xwin build, Wine 10 on lavapipe (llvmpipe). No GPU pod (all off). - `d3d12_msaa_draw_test` exit 0. Pixel of a 4-sample quadrant, with R/G/B/A: typeless to typeless as sRGB 0,137,225,255; typeless to typed sRGB 0,137,225,255; typeless as UNORM 0,64,191,255, all equal to the wanted values; the earlier 4096-pixel MSAA match and the MIN/MAX checks of `#9971` still pass. - Negative control (the same new test against `#9971`'s code, without this commit): exit 1 at `line 401: last_execute_result(queue.p) == ReplayResult::success`, i.e. the list is refused. - `d3d12_vulkan_device_test`: same single failure as on main, line 6581 (`tiles == 1`, llvmpipe tiling), nothing new. ## Not verified - No real GPU, only llvmpipe. The linear-light average is checked against computed values, not against a Windows driver. - At test time main did not compile (console descriptor heap; `#9809` / `#9815` fix it). A throwaway local patch of those shim lines was used and is not in this PR. I did not rebuild after the last small main updates. --- <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#344
No description provided.