[PR #2001] Preserve sRGB midtones on the SDR UNORM swapchain fallback #2008

Open
opened 2026-11-26 21:19:43 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2001
Author: @lgr123
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: lgr123/present-srgb-unorm-fallback


📝 Commits (1)

  • cec9d96 Preserve sRGB colours on SDR UNORM swapchains

📊 Changes

2 files changed (+202 additions, -15 deletions)

View changed files

📝 runtime/src/vulkan_present.h (+127 -14)
📝 runtime/test/xbox_present_test.cpp (+75 -1)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2001 **Author:** [@lgr123](https://github.com/lgr123) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `lgr123/present-srgb-unorm-fallback` --- ### 📝 Commits (1) - [`cec9d96`](https://github.com/ubiquitarianism/leonida/commit/cec9d96dcc38cd0318aca0a0054fcdf4243b3c69) Preserve sRGB colours on SDR UNORM swapchains ### 📊 Changes **2 files changed** (+202 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/vulkan_present.h` (+127 -14) 📝 `runtime/test/xbox_present_test.cpp` (+75 -1) </details> ### 📄 Description Claimed as [RT-PRESENT-SRGB-UNORM-FALLBACK](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7169658698). 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 - [x] Based on public main. - [x] One topic. - [x] No game data, keys or protection workarounds. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2008
No description provided.