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

Closed
Andretuta wants to merge 3 commits from upstream-pr/292 into main
Andretuta commented 2026-11-24 03:01:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T03:01:37Z.


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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465270385 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/292). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T03:01:37Z. --- > 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.
OreoFR commented 2026-11-29 17:03:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T17:03:09Z.


@tedin7 this carried-over PR (your old PR 10023, stacked on #240) now conflicts with main (runtime/src/vulkan_backend.h, runtime/src/vulkan_replay.h, runtime/test/d3d12_msaa_draw_test.cpp). Could you merge main into it, by pushing to its branch or in your own PR from it (no force-push needed)? If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259382314 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/292#issuecomment-7259382314). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T17:03:09Z. --- @tedin7 this carried-over PR (your old PR 10023, stacked on #240) now conflicts with `main` (`runtime/src/vulkan_backend.h`, `runtime/src/vulkan_replay.h`, `runtime/test/d3d12_msaa_draw_test.cpp`). Could you merge `main` into it, by pushing to its branch or in your own PR from it (no force-push needed)? If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)
MoonEyes commented 2026-11-30 13:59:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T13:59:09Z.


Closing this draft as superseded by #1830 (open, by potatoe0100): compared line by line, 2 of the 792 lines this head (9b9679eb6) adds are missing there, in the same files. Nothing here is judged wrong, and a conflict is not the reason. Please reopen it if #1830 does not land or leaves something out.

AI-assisted (Claude Code). Closed at the owner's request (MoonEyes), superseded pull requests being fine to close (aslan2142).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7280659863 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/292#issuecomment-7280659863). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T13:59:09Z. --- Closing this draft as superseded by #1830 (open, by potatoe0100): compared line by line, 2 of the 792 lines this head (`9b9679eb6`) adds are missing there, in the same files. Nothing here is judged wrong, and a conflict is not the reason. Please reopen it if #1830 does not land or leaves something out. AI-assisted (Claude Code). Closed at the owner's request (MoonEyes), superseded pull requests being fine to close (aslan2142).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!292
No description provided.