d3d12: ResolveSubresource averages a typeless resource in the format it names, and colour MIN/MAX resolves (OLD-10023, carries #292) #1830

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

@⁠potatoe0100 on GitHub · 2026-11-25 12:45 UTC · original
potatoe0100:carry/old-10023 → main · +911 −29 · 13 files · 3 commits · open

Claimed in the coordination issue as: OLD-10023 (#1608)

What and why

Carries forward old-pr/10023 (draft #292) by @⁠tedin7, rebased on main 0d80bc5df with the author's three commits:

  • colour MIN and MAX resolves implemented with a small fragment pass (vulkan_color_resolve.h, hand-written GLSL in color_resolve.vert/.frag);
  • d3d12_vulkan_device_test expects a colour MAX resolve to be accepted and still refuses a non-resolve mode;
  • ResolveSubresource averages a typeless resource in the format it names, so a typeless RGBA8 resolved as R8G8B8A8_UNORM_SRGB averages in linear light.

Rebase notes (runtime/src/vulkan_backend.h, runtime/src/vulkan_replay.h):

  • Kept main's quad-index helper next to the new colour-resolve helper, and indirect_clamp next to color_resolves in the submission slot.
  • main now asks has_helper_dispatch() where the branch listed the helper kinds inline; p.color_extremum is added there, so a colour MIN/MAX resolve still splits the statistics segments as the author's version did.
  • The new early returns use main's unsupported_at(__LINE__).

Supersedes draft #292 (its branch can be deleted once this lands).

Tested

VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8.

  • With LEONIDA_VK_VALIDATION=1: d3d12_vulkan_device, d3d12_msaa_draw and vk_sync_validation pass, 0 VUIDs.
  • Full ctest -j 6: 439 tests, all pass (xmem failed once while other builds ran at the same time and passes 3 of 3 on its own).

GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro 26H2 (build 26300)

AI-assisted: yes (Claude Code), by a non-developer tester.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠potatoe0100** on GitHub · 2026-11-25 12:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1830) `potatoe0100:carry/old-10023` → `main` · +911 −29 · 13 files · 3 commits · open Claimed in the coordination issue as: OLD-10023 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why Carries forward `old-pr/10023` (draft #292) by @⁠tedin7, rebased on `main` `0d80bc5df` with the author's three commits: - colour `MIN` and `MAX` resolves implemented with a small fragment pass (`vulkan_color_resolve.h`, hand-written GLSL in `color_resolve.vert/.frag`); - `d3d12_vulkan_device_test` expects a colour `MAX` resolve to be accepted and still refuses a non-resolve mode; - `ResolveSubresource` averages a typeless resource in the format it names, so a typeless RGBA8 resolved as `R8G8B8A8_UNORM_SRGB` averages in linear light. Rebase notes (`runtime/src/vulkan_backend.h`, `runtime/src/vulkan_replay.h`): - Kept `main`'s quad-index helper next to the new colour-resolve helper, and `indirect_clamp` next to `color_resolves` in the submission slot. - `main` now asks `has_helper_dispatch()` where the branch listed the helper kinds inline; `p.color_extremum` is added there, so a colour MIN/MAX resolve still splits the statistics segments as the author's version did. - The new early returns use `main`'s `unsupported_at(__LINE__)`. Supersedes draft #292 (its branch can be deleted once this lands). ### Tested VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8. - With `LEONIDA_VK_VALIDATION=1`: `d3d12_vulkan_device`, `d3d12_msaa_draw` and `vk_sync_validation` pass, 0 VUIDs. - Full `ctest -j 6`: 439 tests, all pass (`xmem` failed once while other builds ran at the same time and passes 3 of 3 on its own). GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro 26H2 (build 26300) AI-assisted: yes (Claude Code), by a non-developer tester. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 10:07:30 +00:00
Author
Owner

@⁠madvillain91 on GitHub · 2026-11-25 14:49 UTC · original · reviewed

Reviewed diff and independently verified commit 158ed8c8a on Windows 11 with an NVIDIA Ampere GPU (against main 71a769d7d):

Environment

  • OS: Windows 11 26H2 (build 26300.9711)
  • Compiler: VS 2022 Build Tools (MSVC 19.44.35230.0, Ninja, RelWithDebInfo)
  • Vulkan SDK: 1.4.363.0
  • GPU: NVIDIA GeForce RTX 3070 Ti (Ampere, 8192 MiB), driver 617.14, Vulkan 1.4.351

Checks run

  • git diff --check across all 3 commits (2ca426248, 6a208ad7a, 158ed8c8a): clean
  • Built d3d12_msaa_draw_test, d3d12_vulkan_device_test, vk_sync_validation_selftest in an isolated clean build: 0 errors
  • d3d12_msaa_draw_test (plain & LEONIDA_VK_VALIDATION=1): PASS, 0 VUIDs (4x draws resolved, 4096 pixels matched; 64 of 189 edge pixels are partial; SampleMask 0x1 wrote one sample of four; 3 samples and a mismatched target refused, incl. typeless sRGB/UNORM and shifted MIN/MAX/AVERAGE region checks)
  • d3d12_vulkan_device_test (LEONIDA_VK_VALIDATION=1): PASS, 0 VUIDs (Resolve comparison: 60 compared, 60 matched, 10 unsupported or host-unavailable cases skipped, 0 mismatches; copy comparison: 0 of 75 cases differ from the host)
  • vk_sync_validation_selftest (LEONIDA_VK_VALIDATION=1): PASS (synchronization validation confirmed active)

Diff notes

  • ColorResolvePass lifetime/cleanup looks clean (Allocation RAII retained in slot->color_resolves and cleared on slot reuse; pipelines/layouts destroyed in ~ColorResolvePass).
  • has_helper_dispatch() and plan_occlusion_segments() properly split statistics and active occlusion queries around p.color_extremum, and vulkan_sync widens resolve with FRAGMENT_SHADER_BIT | COPY_BIT.
  • prepare_view_resolve() enforces color_attachment on both sides and checks averages_colour + color_view_format before falling back to a whole-subresource dynamic-rendering AVERAGE resolve.

Not checked

  • Full ctest suite and non-NVIDIA (AMD/Intel) hardware.

LGTM from this Windows 11 + NVIDIA RTX 3070 Ti verification (AI-assisted verification; synthetic test fixtures only, no game data).

**@⁠madvillain91** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1830#pullrequestreview-6059867663) · **reviewed** Reviewed diff and independently verified commit `158ed8c8a` on Windows 11 with an NVIDIA Ampere GPU (against `main` `71a769d7d`): ### Environment - OS: Windows 11 26H2 (build 26300.9711) - Compiler: VS 2022 Build Tools (MSVC `19.44.35230.0`, Ninja, `RelWithDebInfo`) - Vulkan SDK: `1.4.363.0` - GPU: NVIDIA GeForce RTX 3070 Ti (Ampere, 8192 MiB), driver `617.14`, Vulkan `1.4.351` ### Checks run - `git diff --check` across all 3 commits (`2ca426248`, `6a208ad7a`, `158ed8c8a`): clean - Built `d3d12_msaa_draw_test`, `d3d12_vulkan_device_test`, `vk_sync_validation_selftest` in an isolated clean build: 0 errors - `d3d12_msaa_draw_test` (plain & `LEONIDA_VK_VALIDATION=1`): **PASS, 0 VUIDs** (`4x draws resolved, 4096 pixels matched; 64 of 189 edge pixels are partial; SampleMask 0x1 wrote one sample of four; 3 samples and a mismatched target refused`, incl. typeless sRGB/UNORM and shifted MIN/MAX/AVERAGE region checks) - `d3d12_vulkan_device_test` (`LEONIDA_VK_VALIDATION=1`): **PASS, 0 VUIDs** (`Resolve comparison: 60 compared, 60 matched, 10 unsupported or host-unavailable cases skipped, 0 mismatches`; `copy comparison: 0 of 75 cases differ from the host`) - `vk_sync_validation_selftest` (`LEONIDA_VK_VALIDATION=1`): **PASS** (synchronization validation confirmed active) ### Diff notes - `ColorResolvePass` lifetime/cleanup looks clean (`Allocation` RAII retained in `slot->color_resolves` and cleared on slot reuse; pipelines/layouts destroyed in `~ColorResolvePass`). - `has_helper_dispatch()` and `plan_occlusion_segments()` properly split statistics and active occlusion queries around `p.color_extremum`, and `vulkan_sync` widens `resolve` with `FRAGMENT_SHADER_BIT | COPY_BIT`. - `prepare_view_resolve()` enforces `color_attachment` on both sides and checks `averages_colour` + `color_view_format` before falling back to a whole-subresource dynamic-rendering `AVERAGE` resolve. ### Not checked - Full `ctest` suite and non-NVIDIA (AMD/Intel) hardware. LGTM from this Windows 11 + NVIDIA RTX 3070 Ti verification (AI-assisted verification; synthetic test fixtures only, no game data).
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 17:15 UTC · original

For reference, this PR includes all of #1184 (same two commits, identical patches) plus 158ed8c8a, so reviewing this one covers both.

AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).

**@⁠MoonEyes** on GitHub · 2026-11-25 17:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1830#issuecomment-7169227451) For reference, this PR includes all of #1184 (same two commits, identical patches) plus 158ed8c8a, so reviewing this one covers both. AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).
This pull request has changes conflicting with the target branch.
  • runtime/src/vulkan_backend.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/1830/head:github-bot/gh-1830'
git switch 'github-bot/gh-1830'

Merge

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