Skip to content

Preserve sRGB midtones on the SDR UNORM swapchain fallback - #2001

Open
lgr123 wants to merge 1 commit into
ProjectLeonida:mainfrom
lgr123:lgr123/present-srgb-unorm-fallback
Open

lgr123 wants to merge 1 commit into
ProjectLeonida:mainfrom
lgr123:lgr123/present-srgb-unorm-fallback

Conversation

@lgr123

@lgr123 lgr123 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Claimed as RT-PRESENT-SRGB-UNORM-FALLBACK.

On the RTX 5070, restricting surface formats to the driver's advertised SDR UNORM formats made the native presenter turn synthetic grey bytes 128/188 into 55/128. The swapchain still used nonlinear sRGB, so these linearized bytes darkened midtones. The default sRGB swapchain and composed controls preserved 128/188.

Copy encoded bytes for matching format layouts at 1:1. For scaling or channel reordering, keep the existing filtered blit through a reusable matching sRGB image before copying the encoded bytes to the UNORM swapchain. This also works for transfer-only source images. If the intermediate cannot be created, keep presenting through the previous blit and emit a warning.

Reviewer check

Run ctest -R ^xbox_present$ --output-on-failure from the configured Windows runtime build. The synthetic surface-format test forces SDR UNORM and checks RGBA/BGRA at 1:1 and with crop/scale. No game files required.

Tested

  • Windows, NVIDIA RTX 5070, driver 621.24. The aligned public main build at b9320a1 passed xbox_present (1 of 1).
  • A separate production-presenter matrix confirmed the default native sRGB path, forced UNORM, direct and intermediary transfer-only paths, filtered midpoints, compositor, repeated scaled frames and the injected allocation-failure warning.
  • The display did not offer ST.2084. The routine HDR10 swapchain case skipped, and SDR tone-map and PQ encoder tests ran.
  • Source-only check and git diff --check passed.

GPUs tested: NVIDIA RTX 5070, driver 621.24, Windows.

AI-assisted: yes.

Checklist

  • Based on public main.
  • One topic.
  • No game data, keys or protection workarounds.

Copy encoded bytes at one-to-one size when channel order matches. For scaled or differently ordered sources, blit into a compatible sRGB image before copying the encoded result to the swapchain. Keep presentation with a warning if the staging image is unavailable.

Cover forced SDR UNORM through the Xbox presentation test on Windows with an NVIDIA RTX 5070. No game data was used. AI-assisted with OpenAI Codex.
@djrolfes

Copy link
Copy Markdown
Contributor

Independent Linux/Wine + NVIDIA GPU verification at head cec9d96dc (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:
    • The new SDR UNORM fallback check passed: 1 plane, sRGB source on an SDR UNORM swapchain: 1:1, crop/scale, RGBA and BGRA ok.
    • 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 1300: 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).

The SDR UNORM swapchain fallback path cleanly preserves sRGB midtones without altering existing presentation paths.

Tests run

  • xbox_present_test.exe (with LEONIDA_PRESENT_PLANE1=0): the new sRGB-on-SDR-UNORM fallback case passed on real Vulkan hardware (1 plane, sRGB source on an SDR UNORM swapchain: 1:1, crop/scale, RGBA and BGRA ok).
  • 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).

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.

3 participants