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

Open
github-bot wants to merge 3 commits from github-bot/gh-292 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 03:01 UTC · original
ubiquitarianism:old-pr/10023 → main · +911 −30 · 13 files · 3 commits · draft

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.
**@⁠Andretuta** on GitHub · 2026-11-24 03:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/292) `ubiquitarianism:old-pr/10023` → `main` · +911 −30 · 13 files · 3 commits · draft > 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.
ResolveSubresource dropped its Format, so a typeless 4x RGBA8 resolved as R8G8B8A8_UNORM_SRGB averaged as UNORM with no error, and a typeless source into a typed sRGB destination was refused in prepare_resolve (the Vulkan formats differ) and failed the list. The command now carries the VkFormat when a resource is typeless; replay views both images in it and resolves in a rendering scope (colour attachment, AVERAGE). Needs ALLOW_RENDER_TARGET on both; otherwise refused.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:52:10 +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/292/head:github-bot/gh-292'
git switch 'github-bot/gh-292'

Merge

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