From aa5833dbabad9095ef334c7b1febda8639f4b4e5 Mon Sep 17 00:00:00 2001 From: Foniass <107039406+Foniass@users.noreply.github.com> Date: Sun, 29 Nov 2026 06:38:42 +0100 Subject: [PATCH] D3D12.X: a single-plane PresentX with a source sub-rectangle is scaled from it PresentX took the composing path, which scales each plane's source rectangle to the window, only for several planes. A single plane was copied 1:1 from its top-left corner, clipped to the window (CopyTextureRegion), whatever its source rectangle: with dynamic resolution (a 1600x900 region of a 3840x2160 target) in a 1280x720 window, only the region's top-left 1280x720 pixels showed, unscaled. A single plane whose source is a strict sub-rectangle now goes the composing path too; a whole-plane source keeps the copy. Ported from amd-dev 48cf7139 (its present.rs part), raylitebull. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/hle/d3d12x/present.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/xcl/src/hle/d3d12x/present.rs b/crates/xcl/src/hle/d3d12x/present.rs index d0941c4ea6..093babd09c 100644 --- a/crates/xcl/src/hle/d3d12x/present.rs +++ b/crates/xcl/src/hle/d3d12x/present.rs @@ -1389,6 +1389,11 @@ unsafe fn ensure_swapchain(p: &mut Presenter, hwnd: HWND, w: u32, h: u32, fmt: D } } +/// True when `uv` covers a strict sub-rectangle of the source plane (e.g. dynamic resolution). +fn uv_is_subrect(uv: [f32; 4]) -> bool { + uv != [0.0, 0.0, 1.0, 1.0] +} + unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize, Option<[i32; 4]>)>)>) { if IN_PRESENT.with(|c| c.replace(true)) { return; @@ -1516,7 +1521,7 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize, } } let mut composited = false; - if resolved.len() > 1 { + if resolved.len() > 1 || uv_is_subrect(resolved[0].2) { if p.compositor.is_none() { p.compositor = Compositor::new(&p.dev); } @@ -2231,7 +2236,9 @@ mod tests { let got = unsafe { extract_planes(2, buf.as_ptr()) }; assert_eq!(got, vec![(res0, Some(rect0)), (res1, None)]); assert_eq!(source_uv_rect(got[0].1, 1600, 900), [0.1, 0.1, 0.5, 0.5]); + assert!(uv_is_subrect(source_uv_rect(got[0].1, 1600, 900))); assert_eq!(source_uv_rect(got[1].1, 3840, 2160), [0.0, 0.0, 1.0, 1.0]); + assert!(!uv_is_subrect(source_uv_rect(got[1].1, 3840, 2160))); assert_eq!(source_uv_rect(Some([0, 0, 4000, 900]), 1920, 1080), [0.0, 0.0, 1.0, 1.0]); } }