Treat BGRX overlays as opaque in PresentX composition #2014

Closed
lgr123 wants to merge 1 commit from upstream-pr/2014 into main
lgr123 commented 2026-11-25 18:10:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lgr123 on 2026-11-25T18:10:49Z.


Claimed as RT-PRESENT-BGRX-OPAQUE-PLANE.

On public main, a synthetic green BGRX overlay disappeared when its unused X byte was zero. The sampled result was the base color 51/153/230. With X set to 255, the same input was green 0/255/0. Genuine BGRA controls correctly distinguished alpha 0 and 255. DXGI defines BGRX's X channel as unused, so the overlay should be opaque at either value.

Carry the BGRX format distinction into the compositor and use alpha-one swizzle for the sampled view of the secondary plane. The surrounding image retains the base plane outside the overlay rectangle. Ordinary BGRA/RGBA and direct presentation preserve their existing paths.

Reviewer check

Run the Windows synthetic xbox_present test. The regression uses both BGRX UNORM and sRGB, selects X = 0 and 255, checks straight and premultiplied inputs, and compares pixel placement and genuine BGRA alpha controls.

Tested

  • Windows, NVIDIA RTX 5070, driver 621.24. The before test failed at the first BGRX X=0 pixel in the destination rectangle. After the patch, native xbox_present, d3d12_present, and d3d12_typeless_families all passed.
  • This display does not offer HDR10 ST.2084. The routine HDR10 swapchain case skipped and the SDR tone-map and PQ encoder tests ran.
  • Public base b9320a1. Clean merge-tree with #2001. Source-only check and git diff --check passed.
  • Synthetic fixtures only. No game files.

GPUs tested: NVIDIA RTX 5070, 621.24, Windows.

AI-assisted: yes.

Checklist

  • Based on public main.
  • One topic.
  • No game data, keys or protection workarounds.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5496649340 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014). Originally posted by [lgr123](https://github.com/lgr123) on 2026-11-25T18:10:49Z. --- Claimed as [RT-PRESENT-BGRX-OPAQUE-PLANE](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170365624). On public main, a synthetic green BGRX overlay disappeared when its unused X byte was zero. The sampled result was the base color **51/153/230**. With X set to 255, the same input was green **0/255/0**. Genuine BGRA controls correctly distinguished alpha 0 and 255. DXGI defines BGRX's X channel as unused, so the overlay should be opaque at either value. Carry the BGRX format distinction into the compositor and use alpha-one swizzle for the sampled view of the secondary plane. The surrounding image retains the base plane outside the overlay rectangle. Ordinary BGRA/RGBA and direct presentation preserve their existing paths. ### Reviewer check Run the Windows synthetic `xbox_present` test. The regression uses both BGRX UNORM and sRGB, selects X = 0 and 255, checks straight and premultiplied inputs, and compares pixel placement and genuine BGRA alpha controls. ### Tested - Windows, NVIDIA RTX 5070, driver 621.24. The before test failed at the first BGRX X=0 pixel in the destination rectangle. After the patch, native `xbox_present`, `d3d12_present`, and `d3d12_typeless_families` all passed. - This display does not offer HDR10 ST.2084. The routine HDR10 swapchain case skipped and the SDR tone-map and PQ encoder tests ran. - Public base `b9320a1`. Clean merge-tree with #2001. Source-only check and `git diff --check` passed. - Synthetic fixtures only. No game files. GPUs tested: NVIDIA RTX 5070, 621.24, Windows. AI-assisted: yes. ### Checklist - [x] Based on public main. - [x] One topic. - [x] No game data, keys or protection workarounds.
djrolfes commented 2026-11-27 19:38:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by djrolfes on 2026-11-27T19:38:01Z.


Independent Linux/Wine + NVIDIA GPU verification at head 71d41e418 (applied cleanly onto main 43a9d562d, Profile M, no game files).

  • Environment: NVIDIA GeForce RTX 3070 Ti 8 GB (desktop), driver 620.73.04, Arch Linux 7.2.15, wine-11.22 (XWayland), clang-cl 23.1.5 + xwin SDK 10.0.26100 cross-build, Ryzen 7 5800X, 31 GiB RAM.
  • Build & test: xbox_present_test.exe cross-compiled cleanly and ran under Wine with LEONIDA_PRESENT_PLANE1=0 alongside a clean main (43a9d562d) control build.
  • Measured result:
    • Both new BGRX/BGRA overlay checks passed:
      • compose: BGRA overlay still uses its alpha
      • compose: BGRX UNORM and sRGB overlays are opaque inside their placement for both alpha modes
    • All other single-plane, 2-plane compose, alpha, SDR EOTF, and HDR10 tone-map checks passed identically to main.
    • One unrelated pre-existing resize check (line 1253: present_planes(&one, 1), matching main line 1226) failed under our unfocused Hyprland workspace environment; HDR10 swapchain skipped (no ST.2084 surface format).
  • Not tested: native Windows or an HDR10-capable ST.2084 output.

AI-assisted: Antigravity (Gemini 4 Neon); no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7226719032 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014#issuecomment-7226719032). Originally posted by [djrolfes](https://github.com/djrolfes) on 2026-11-27T19:38:01Z. --- Independent Linux/Wine + NVIDIA GPU verification at head `71d41e418` (applied cleanly onto `main` `43a9d562d`, Profile M, no game files). - **Environment:** NVIDIA GeForce RTX 3070 Ti 8 GB (desktop), driver `620.73.04`, Arch Linux `7.2.15`, `wine-11.22` (XWayland), `clang-cl 23.1.5` + `xwin` SDK `10.0.26100` cross-build, Ryzen 7 5800X, 31 GiB RAM. - **Build & test:** `xbox_present_test.exe` cross-compiled cleanly and ran under Wine with `LEONIDA_PRESENT_PLANE1=0` alongside a clean `main` (`43a9d562d`) control build. - **Measured result:** - Both new BGRX/BGRA overlay checks **passed**: - `compose: BGRA overlay still uses its alpha` - `compose: BGRX UNORM and sRGB overlays are opaque inside their placement for both alpha modes` - All other single-plane, 2-plane compose, alpha, SDR EOTF, and HDR10 tone-map checks passed identically to `main`. - One unrelated pre-existing resize check (`line 1253: present_planes(&one, 1)`, matching `main` `line 1226`) failed under our unfocused Hyprland workspace environment; `HDR10 swapchain` skipped (no ST.2084 surface format). - **Not tested:** native Windows or an HDR10-capable ST.2084 output. AI-assisted: Antigravity (Gemini 4 Neon); no game data.
lixonik commented 2026-11-28 08:48:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T08:48:51Z.

Review: APPROVED


Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).

Treating DXGI_FORMAT_B8G8R8X8_UNORM / B8G8R8X8_UNORM_SRGB overlay planes as opaque via opaque_alpha + VK_COMPONENT_SWIZZLE_ONE on the view is clean, minimal, and keeps BGRA overlays blending normally.

Tests run

  • xbox_present_test.exe (with LEONIDA_PRESENT_PLANE1=0): both new compose checks passed on real Vulkan hardware:
    • compose: BGRA overlay still uses its alpha
    • compose: BGRX UNORM and sRGB overlays are opaque inside their placement for both alpha modes
  • Note: later in the same binary, case F hits the pre-existing main resize readback failure (present_planes(&one, 1)), unrelated to this PR (tracked in #2507).

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341; VK_LAYER_KHRONOS_validation not installed locally).

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6096827080 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014#pullrequestreview-6096827080). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T08:48:51Z. **Review:** APPROVED --- Reviewed the diff and tested merged onto `main` (`493867366`) with Ninja Release (MSVC). Treating `DXGI_FORMAT_B8G8R8X8_UNORM` / `B8G8R8X8_UNORM_SRGB` overlay planes as opaque via `opaque_alpha` + `VK_COMPONENT_SWIZZLE_ONE` on the view is clean, minimal, and keeps BGRA overlays blending normally. ### Tests run - `xbox_present_test.exe` (with `LEONIDA_PRESENT_PLANE1=0`): both new compose checks passed on real Vulkan hardware: - `compose: BGRA overlay still uses its alpha` - `compose: BGRX UNORM and sRGB overlays are opaque inside their placement for both alpha modes` - Note: later in the same binary, case F hits the pre-existing `main` resize readback failure (`present_planes(&one, 1)`), unrelated to this PR (tracked in #2507). GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341; VK_LAYER_KHRONOS_validation not installed locally). AI-assisted (Antigravity, Gemini).
zmasi commented 2026-11-28 23:57:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:57:16Z.


#2014 | head 71d41e418a (merged cleanly with main ba8b77b390 — no conflicts on current main, and merges cleanly with #2001) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xbox_present|d3d12_present|d3d12_typeless_families)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: building xbox_present_test against main's d3d12_com.h, d3d12_vulkan_device.cpp, xbox_present.cpp, and vulkan_present.h fails xbox_present at line 961: check_overlay(bgrx, 0.0f, straight, opaque_green) (pixel 80,60 is 51,153,230, expected 0,255,0) | green on PR+main: d3d12_present and d3d12_typeless_families pass (rc=0), and xbox_present passes compose: BGRA overlay still uses its alpha, compose: BGRX UNORM and sRGB overlays are opaque inside their placement for both alpha modes, and compose: HDR10 plane to an HDR10 (ST.2084) swapchain: R, G and B codes within 1 of the source: ok on an HDR10 ST.2084 RTX 3090 output with 0 Khronos validation errors (the trailing present_planes(&one, 1) window-resize VkResult -11 at line 1253 matches plain main line 1226 identically); test_docs_encoding.py & test_docs_repo_paths.py (6/6 OK) and check_no_game_data.py (0 violations) pass | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247772835 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014#issuecomment-7247772835). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T23:57:16Z. --- #2014 | head 71d41e418a3fd62003a34ee7373fe98d0444136b (merged cleanly with main ba8b77b390b278cfb05510a4fc2922fb0fb9a11c — no conflicts on current `main`, and merges cleanly with `#2001`) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xbox_present|d3d12_present|d3d12_typeless_families)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`) | red on main: building `xbox_present_test` against `main`'s `d3d12_com.h`, `d3d12_vulkan_device.cpp`, `xbox_present.cpp`, and `vulkan_present.h` fails `xbox_present` at `line 961: check_overlay(bgrx, 0.0f, straight, opaque_green)` (`pixel 80,60 is 51,153,230, expected 0,255,0`) | green on PR+main: `d3d12_present` and `d3d12_typeless_families` pass (`rc=0`), and `xbox_present` passes `compose: BGRA overlay still uses its alpha`, `compose: BGRX UNORM and sRGB overlays are opaque inside their placement for both alpha modes`, and `compose: HDR10 plane to an HDR10 (ST.2084) swapchain: R, G and B codes within 1 of the source: ok` on an HDR10 ST.2084 RTX 3090 output with `0` Khronos validation errors (the trailing `present_planes(&one, 1)` window-resize `VkResult -11` at `line 1253` matches plain `main` `line 1226` identically); `test_docs_encoding.py` & `test_docs_repo_paths.py` (`6/6 OK`) and `check_no_game_data.py` (`0` violations) pass | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes
OreoFR commented 2026-11-29 14:59:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T14:59:44Z.


TAKEN by OreoFR (Windows, RTX 4070 8 GB)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257736254 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014#issuecomment-7257736254). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T14:59:44Z. --- TAKEN by OreoFR (Windows, RTX 4070 8 GB)
OreoFR commented 2026-11-29 21:33:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T21:33:16Z.


Verified by OreoFR — FAILS (the new test contradicts main's additive overlays)

  • Base: main c22a0a732 + this PR (head 71d41e418) merged with --no-ff
  • Red (main + only this PR's test): xbox_present fails on main at line 955 (check_overlay(bgra, 0.0f, false, underlay) && check_overlay(bgra, 1.0f, false, opaque_green)): pixel 80,60 is 51,255,230, expected 51,153,230.
  • Green (merge): the same check fails the same way on the merge, so the BGRX cases after it never run. It is the BGRA control case, which this PR does not change: a premultiplied overlay with alpha 0 is additive on main since ef5620bf6 ("present_compose: fix premultiplied sRGB and additive alpha plane 1 decoding", 2026-11-28, not in this PR's base), and main's own check compose: additive premultiplied (a == 0) sRGB and UNORM plane 1 overlays: ok passes. The test expects the underlay, so green underlay + green comes out. ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p5 = main + #2014 alone: 505 tests, new failures vs main: none besides xbox_present failing earlier than on main (line 955 instead of main's present_planes(&one, 1) failure); xmem and xmem_write_watch failed in the parallel run and pass when re-run alone (main alone: 505 tests, 6 failures: big_compile_gate and api_ref_state and d3d12_queue_wait_timeout timeouts, xs_proxy_mock, vk_compile_gate_calibration, xbox_present)
  • gta6rt.exe links without the XMA decoder (LEONIDA_CARGO=OFF, LEONIDA_XMA2_DECODER_LIB empty), main + this PR alone; imports unchanged vs main (25 DLLs, 755 functions, no WS2_32)
  • Diff read: the runtime change looks right: plane 1 of a B8G8R8X8 source gets an image view with alpha swizzled to ONE, and alpha_unused moves to d3d12_com.h as constexpr. Fix: rebase on main and make the BGRA control case use straight alpha (or expect additive green for premultiplied alpha 0) so the BGRX cases run.
  • Other runs: djrolfes's and zmasi's runs and lixonik's approval were on bases before ef5620bf6.
  • Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7262967014 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014#issuecomment-7262967014). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T21:33:16Z. --- **Verified by OreoFR** — FAILS (the new test contradicts main's additive overlays) - Base: main c22a0a732 + this PR (head 71d41e418) merged with --no-ff - Red (main + only this PR's test): `xbox_present` fails on main at line 955 (`check_overlay(bgra, 0.0f, false, underlay) && check_overlay(bgra, 1.0f, false, opaque_green)`): `pixel 80,60 is 51,255,230, expected 51,153,230`. - Green (merge): the same check fails the same way on the merge, so the BGRX cases after it never run. It is the BGRA control case, which this PR does not change: a premultiplied overlay with alpha 0 is additive on main since ef5620bf6 ("present_compose: fix premultiplied sRGB and additive alpha plane 1 decoding", 2026-11-28, not in this PR's base), and main's own check `compose: additive premultiplied (a == 0) sRGB and UNORM plane 1 overlays: ok` passes. The test expects the underlay, so green underlay + green comes out. ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p5 = main + #2014 alone: 505 tests, new failures vs main: none besides `xbox_present` failing earlier than on main (line 955 instead of main's `present_planes(&one, 1)` failure); `xmem` and `xmem_write_watch` failed in the parallel run and pass when re-run alone (main alone: 505 tests, 6 failures: big_compile_gate and api_ref_state and d3d12_queue_wait_timeout timeouts, xs_proxy_mock, vk_compile_gate_calibration, xbox_present) - gta6rt.exe links without the XMA decoder (`LEONIDA_CARGO=OFF`, `LEONIDA_XMA2_DECODER_LIB` empty), main + this PR alone; imports unchanged vs main (25 DLLs, 755 functions, no WS2_32) - Diff read: the runtime change looks right: plane 1 of a B8G8R8X8 source gets an image view with alpha swizzled to ONE, and `alpha_unused` moves to `d3d12_com.h` as `constexpr`. Fix: rebase on main and make the BGRA control case use straight alpha (or expect additive green for premultiplied alpha 0) so the BGRX cases run. - Other runs: djrolfes's and zmasi's runs and lixonik's approval were on bases before ef5620bf6. - Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44 AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
aslan2142 commented 2026-12-01 16:41:05 +00:00 (Migrated from github.com)

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


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:7318030675 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2014#issuecomment-7318030675). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:41:05Z. --- 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!2014
No description provided.