Skip to content

Treat BGRX overlays as opaque in PresentX composition - #2014

Open
lgr123 wants to merge 1 commit into
ProjectLeonida:mainfrom
lgr123:lgr123/present-bgrx-opaque-plane
Open

lgr123 wants to merge 1 commit into
ProjectLeonida:mainfrom
lgr123:lgr123/present-bgrx-opaque-plane

Conversation

@lgr123

@lgr123 lgr123 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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 Preserve sRGB midtones on the SDR UNORM swapchain fallback #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.

Preserve the DXGI alpha semantics when the Vulkan composer samples plane 1. Use the existing BGRX format classification to swizzle sampled alpha to one while retaining the overlay placement and the behavior of real alpha formats.
@djrolfes

Copy link
Copy Markdown
Contributor

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 lixonik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#2014 | head 71d41e4 (merged cleanly with main ba8b77b — 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants