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

Closed
potatoe0100 wants to merge 3 commits from upstream-pr/1830 into main
potatoe0100 commented 2026-11-25 12:45:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T12:45:41Z.


Claimed in the coordination issue as: OLD-10023 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162810126)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5491587001 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1830). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-25T12:45:41Z. --- Claimed in the coordination issue as: OLD-10023 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162810126) ### 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)
madvillain91 commented 2026-11-25 14:49:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-25T14:49:47Z.

Review: COMMENTED


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6059867663 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1830#pullrequestreview-6059867663). Originally posted by [madvillain91](https://github.com/madvillain91) on 2026-11-25T14:49:47Z. **Review:** COMMENTED --- 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).
MoonEyes commented 2026-11-25 17:15:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-25T17:15:03Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169227451 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1830#issuecomment-7169227451). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-25T17:15:03Z. --- 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 commented 2026-11-28 18:02:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:02:35Z.


Hi @potatoe0100, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/src/vulkan_backend.h), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243483675 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1830#issuecomment-7243483675). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:02:35Z. --- Hi @potatoe0100, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/src/vulkan_backend.h`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 16:38:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:38:08Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317934858 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1830#issuecomment-7317934858). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:38:08Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

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!1830
No description provided.