Black screen with HDR at 2560x1440 output (sound plays); fix attached #37

Open
opened 2026-12-05 22:44:36 +00:00 by github-bot · 0 comments
Owner

@⁠Blaimno on GitHub · 2026-12-05 22:41 UTC · original

What happens

With LARP_HDR=1 and LARP_RESOLUTION=2560x1440, the screen stays black and only the sound plays. 4K output with HDR works, and 2560x1440 without HDR works.

Cause

At an output size other than the title's own, the title hands frame_end two planes. Under an HDR output mode it gives the interface first (as the note at the top of planes.rs says):

  • plane 0: the 8-bit 3840x2160 interface (legacy 4K UI layout)
  • plane 1: the 10-bit PQ picture

Host::present takes the swap chain format from the first plane, so the back buffer becomes R8G8B8A8 and hdr::apply_swap_chain never turns HDR10 on. The picture is then blended over the interface by its alpha, which leaves the screen black. The log shows it:

  • 4K + HDR: swap chain: HDR10 (...) active / presenting to a window width=3840 height=2160 format=24
  • 1440p + HDR: no HDR10 line / presenting to a window width=3840 height=2160 format=28

Fix

With LARP_HDR=1, when the first plane is not 10-bit but a later one is, draw the 10-bit picture first and lay the planes before it over it. The interface is converted to PQ by the existing flags & 2 path in planes.rs. Nothing changes without HDR, with one plane, or when the picture already comes first. There is no shader translation change, so no pipeline cache rebuild.

  • crates/larp-gpu/src/hdr.rs: new ten_bit() and picture_first() at the end of the file
  • crates/larp-gpu/src/queue.rs: one call in the present path, right before host.present(&texture, &over, frame)
diff --git a/crates/larp-gpu/src/hdr.rs b/crates/larp-gpu/src/hdr.rs
index eee742c..f9b4055 100644
--- a/crates/larp-gpu/src/hdr.rs
+++ b/crates/larp-gpu/src/hdr.rs
@@ -129,3 +129,44 @@ pub(crate) fn apply_swap_chain(swap_chain: &IDXGISwapChain3, format: DXGI_FORMAT
         }
     }
 }
+
+/// Whether `t` is a 10-bit plane (`R10G10B10A2`, typeless or not): the
+/// title's HDR10 PQ picture.
+fn ten_bit(t: &crate::resource::HostTexture) -> bool {
+    // SAFETY: a live resource.
+    let desc = unsafe { t.texture.GetDesc() };
+    matches!(desc.Format.0, 23..=25)
+}
+
+/// The planes of a present in the order they are drawn, with `LARP_HDR=1`:
+/// the 10-bit picture first, the planes before it laid over it after it.
+///
+/// Under an HDR output mode the title hands the display its interface
+/// plane first and the picture after it (`crate::planes`). At its own
+/// output size (3840x2160) it hands one plane; at another (2560x1440, with
+/// the legacy 4K interface) it hands two, the 8-bit 4K interface first:
+/// the window's back buffer was made 8-bit (no HDR10) and the picture was
+/// blended over the interface by its alpha, which left the screen black.
+pub(crate) fn picture_first(
+    first: std::sync::Arc<crate::resource::HostTexture>,
+    mut over: Vec<std::sync::Arc<crate::resource::HostTexture>>,
+) -> (std::sync::Arc<crate::resource::HostTexture>, Vec<std::sync::Arc<crate::resource::HostTexture>>) {
+    if !hdr_enabled() || over.is_empty() || ten_bit(&first) {
+        return (first, over);
+    }
+    let Some(i) = over.iter().position(|p| ten_bit(p)) else {
+        return (first, over);
+    };
+    static ONCE: AtomicBool = AtomicBool::new(false);
+    if !ONCE.swap(true, Ordering::Relaxed) {
+        tracing::info!(
+            plane = i + 1,
+            "HDR: the title's 10-bit picture is drawn first, its interface plane(s) over it (said once)"
+        );
+    }
+    let picture = over.remove(i);
+    let mut laid = Vec::with_capacity(over.len() + 1);
+    laid.push(first);
+    laid.extend(over);
+    (picture, laid)
+}
diff --git a/crates/larp-gpu/src/queue.rs b/crates/larp-gpu/src/queue.rs
index b5642b5..d6a08f3 100644
--- a/crates/larp-gpu/src/queue.rs
+++ b/crates/larp-gpu/src/queue.rs
@@ -1003,6 +1003,8 @@ extern "system" fn present(
                     .flatten()
             })
             .collect();
+        // LARP_HDR=1: the 10-bit picture first, the interface over it.
+        let (texture, over) = crate::hdr::picture_first(texture, over);
         let reflex = crate::reflex::present_begin();
         let shown = host.present(&texture, &over, frame);
         crate::reflex::present_end(reflex);

Tested

RX 9070 XT, Adrenalin 26.11.2, Ryzen 9 5900X, HDR monitor at 2560x1440, on 2026.12.05-amd-4.2 (the diff also applies cleanly on current main). LARP_RESOLUTION=2560x1440 LARP_HDR=1, FSR 0.667: black before, correct HDR picture with HUD and menus after. 4K + HDR and 1440p without HDR look the same as before.

**@⁠Blaimno** on GitHub · 2026-12-05 22:41 UTC · [original](https://github.com/iceboerg00/larp-amd/issues/37) ### What happens With `LARP_HDR=1` and `LARP_RESOLUTION=2560x1440`, the screen stays black and only the sound plays. 4K output with HDR works, and 2560x1440 without HDR works. ### Cause At an output size other than the title's own, the title hands `frame_end` **two planes**. Under an HDR output mode it gives the interface first (as the note at the top of `planes.rs` says): - plane 0: the 8-bit 3840x2160 interface (legacy 4K UI layout) - plane 1: the 10-bit PQ picture `Host::present` takes the swap chain format from the first plane, so the back buffer becomes `R8G8B8A8` and `hdr::apply_swap_chain` never turns HDR10 on. The picture is then blended over the interface by its alpha, which leaves the screen black. The log shows it: - 4K + HDR: `swap chain: HDR10 (...) active` / `presenting to a window width=3840 height=2160 format=24` - 1440p + HDR: no HDR10 line / `presenting to a window width=3840 height=2160 format=28` ### Fix With `LARP_HDR=1`, when the first plane is not 10-bit but a later one is, draw the 10-bit picture first and lay the planes before it over it. The interface is converted to PQ by the existing `flags & 2` path in `planes.rs`. Nothing changes without HDR, with one plane, or when the picture already comes first. There is no shader translation change, so no pipeline cache rebuild. - `crates/larp-gpu/src/hdr.rs`: new `ten_bit()` and `picture_first()` at the end of the file - `crates/larp-gpu/src/queue.rs`: one call in the present path, right before `host.present(&texture, &over, frame)` ```diff diff --git a/crates/larp-gpu/src/hdr.rs b/crates/larp-gpu/src/hdr.rs index eee742c..f9b4055 100644 --- a/crates/larp-gpu/src/hdr.rs +++ b/crates/larp-gpu/src/hdr.rs @@ -129,3 +129,44 @@ pub(crate) fn apply_swap_chain(swap_chain: &IDXGISwapChain3, format: DXGI_FORMAT } } } + +/// Whether `t` is a 10-bit plane (`R10G10B10A2`, typeless or not): the +/// title's HDR10 PQ picture. +fn ten_bit(t: &crate::resource::HostTexture) -> bool { + // SAFETY: a live resource. + let desc = unsafe { t.texture.GetDesc() }; + matches!(desc.Format.0, 23..=25) +} + +/// The planes of a present in the order they are drawn, with `LARP_HDR=1`: +/// the 10-bit picture first, the planes before it laid over it after it. +/// +/// Under an HDR output mode the title hands the display its interface +/// plane first and the picture after it (`crate::planes`). At its own +/// output size (3840x2160) it hands one plane; at another (2560x1440, with +/// the legacy 4K interface) it hands two, the 8-bit 4K interface first: +/// the window's back buffer was made 8-bit (no HDR10) and the picture was +/// blended over the interface by its alpha, which left the screen black. +pub(crate) fn picture_first( + first: std::sync::Arc<crate::resource::HostTexture>, + mut over: Vec<std::sync::Arc<crate::resource::HostTexture>>, +) -> (std::sync::Arc<crate::resource::HostTexture>, Vec<std::sync::Arc<crate::resource::HostTexture>>) { + if !hdr_enabled() || over.is_empty() || ten_bit(&first) { + return (first, over); + } + let Some(i) = over.iter().position(|p| ten_bit(p)) else { + return (first, over); + }; + static ONCE: AtomicBool = AtomicBool::new(false); + if !ONCE.swap(true, Ordering::Relaxed) { + tracing::info!( + plane = i + 1, + "HDR: the title's 10-bit picture is drawn first, its interface plane(s) over it (said once)" + ); + } + let picture = over.remove(i); + let mut laid = Vec::with_capacity(over.len() + 1); + laid.push(first); + laid.extend(over); + (picture, laid) +} diff --git a/crates/larp-gpu/src/queue.rs b/crates/larp-gpu/src/queue.rs index b5642b5..d6a08f3 100644 --- a/crates/larp-gpu/src/queue.rs +++ b/crates/larp-gpu/src/queue.rs @@ -1003,6 +1003,8 @@ extern "system" fn present( .flatten() }) .collect(); + // LARP_HDR=1: the 10-bit picture first, the interface over it. + let (texture, over) = crate::hdr::picture_first(texture, over); let reflex = crate::reflex::present_begin(); let shown = host.present(&texture, &over, frame); crate::reflex::present_end(reflex); ``` ### Tested RX 9070 XT, Adrenalin 26.11.2, Ryzen 9 5900X, HDR monitor at 2560x1440, on 2026.12.05-amd-4.2 (the diff also applies cleanly on current `main`). `LARP_RESOLUTION=2560x1440 LARP_HDR=1`, FSR 0.667: black before, correct HDR picture with HUD and menus after. 4K + HDR and 1440p without HDR look the same as before.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 22:44:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/iceboerg00--larp-amd#37
No description provided.