Repository navigation
dxgi: keep DXGI_SCALING_NONE on HWND swapchains and present it unscaled (D3D-444) - #4231
Exopus-0x65f7ad0 wants to merge 2 commits into
Conversation
|
Tested 7464bef on Windows 11, MSVC BuildTools 2022 (Ninja, RelWithDebInfo, -j 4), PR head on top of main aa2988c: fail, does not build. The new What did run: AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Build failure at 7464bef2 on Windows 11, MSVC /W4, LEONIDA_BUILD_WINDOWS_RUNTIME=ON:
present_scaling.h(20): error C2011: 'leonida::PresentRect': 'struct' type redefinition
vulkan_present.h(50): note: see declaration of 'leonida::PresentRect'
d3d12_vulkan_device.cpp(7391): error C2664: 'VulkanPresenter::present(..., const leonida::PresentRect *, ...)'
runtime/src/present_scaling.h adds struct PresentRect { src_width, src_height, dst_x, dst_y, dst_width, dst_height, scaled, covers }, but runtime/src/vulkan_present.h already declares struct PresentRect { left, top, right, bottom } in the same leonida namespace, and d3d12_vulkan_device.cpp includes both (transitively). The standalone present_scaling_test compiles, but the runtime target that includes the presenter does not, so the windows build cannot link this branch.
Suggested fix: rename the new struct (e.g. ScalingRect/PresentBlitRect) and its uses in present_scaling.h/present_scaling_test.cpp, or reuse the existing PresentRect with an explicit conversion at the call site. Nothing else in the diff looked wrong; I could not run the swapchain/scaling tests until this compiles.
|
Independent check of the host behavior mentioned under Limitations. Stock Windows DXGI/D3D11 on Windows 11 build 28000.3501, RTX 4070 Ti SUPER (617.14), with a 64x48 solid red back buffer in a 128x128 HWND. I sampled ten pixels per case, including both sides of the expected boundaries, using
This matches Microsoft's DXGI_SCALING documentation. At |
jeremygold02
left a comment
There was a problem hiding this comment.
The stock Vulkan target fails to build at 7464bef2 with the type collision already reported here. After renaming only the new PresentRect type and its uses in present_scaling.h, dxgi_swapchain.h and present_scaling_test.cpp locally, I measured the displayed image. The proposed HWND blit restored native placement and cropping in the D3D-444 fixture on both Windows adapters.
| Runtime | GetDesc1 for NONE | NONE exact RGB pairs | STRETCH exact RGB pairs |
|---|---|---|---|
Parent aa2988cc |
STRETCH | 16/48 | 48/48 |
7464bef2 with local type rename |
NONE | 48/48 | 48/48 |
With NONE, the 32×16 source occupied the upper-left of the 64×32 client. The 128×64 source showed its upper-left crop. I sampled six points after DWM composition, switched the source colors between Present and Present1, and checked each result against native D3D12 on the same adapter LUID. The 96 native reference samples were identical across the two runs. Fixture, sample coordinates and parent readings
On this Windows 11 Home 26200.9974 desktop, native D3D12 and the diagnostic build both returned opaque blue from GetBackgroundColor before the first present. All 16 uncovered samples were RGB 0/0/0 on both paths. This was an ordinary left-to-right Win32 popup with B8G8R8A8_UNORM, two buffers, FLIP_DISCARD and ALPHA_MODE_IGNORE. The D3D11 run on build 28000.3501 observed colored borders under its conditions. D3D11 measurements
Intel Core Ultra 7 265K, MSVC 19.44 x64 Release. The NVIDIA GeForce RTX 5070 (621.01 / 32.0.16.2101) and Intel(R) Graphics (32.0.101.9150) each ran both native D3D12 and Leonida Vulkan. Synthetic frames, Vulkan validation off.
AI-assisted by GPT-6.2 Astra.
|
Thanks for checking native D3D12, @jeremygold02. I ran a matched native D3D11/D3D12 comparison on the same adapter LUID on Windows 11 28000.3501, RTX 4070 Ti SUPER 617.14. Both used a 64x48 back buffer in a 128x128 HWND, For To check timing separately, I created fresh native D3D12 BGRA8 LTR swapchains. Setting blue before the first Present1 produced blue in 7/7 uncovered samples on the first presented frame. On another fresh swapchain the default was black in 7/7, then setting blue after the first present made all seven samples blue on the second. This confirms colored D3D12 borders on this Windows/driver combination. The difference from the black border observed on your system remains open. This follow-up measured the native Windows reference only. Synthetic frames. AI-assisted. |
|
Pushed 117ddbb: |
Kam471
left a comment
There was a problem hiding this comment.
Re-checked the pushed head \117ddbb3\ on Windows 11, RTX 5070 Ti with \LEONIDA_BUILD_WINDOWS_RUNTIME=ON:
- The runtime now builds: \present_scaling.h\ uses \SwapchainBlit, so \d3d12_vulkan_device.cpp\ no longer sees two \leonida::PresentRect\ definitions (the earlier C2011/C2664 are gone).
- \present_scaling_test.exe\ -> OK, exit 0.
- \dxgi_swapchain_test.exe\ -> PASS (all swapchain cases, 0 validation errors).
- \ctest -R 'present_scaling|dxgi_swapchain'\ -> 2/2 passed (0.01 s / 0.53 s).
No blocking issue.
|
I measured the displayed pixels on the current
This checks the presentation backend and real window output. The probe does not exercise the Leonida COM shim or |
…ght-aligns in RTL windows Measured against native D3D11/D3D12 on ItsNotRexed#4231 (@akimfomin, @jeremygold02): with DXGI_SCALING_NONE the part of the window outside the back buffer takes the colour SetBackgroundColor set (black by default), and in a WS_EX_LAYOUTRTL window the back buffer sits at the top-right corner. The layer cleared to opaque black and always used the top-left corner. - swapchain_blit takes the window's reading direction; NONE starts at dst_width - copy width in a right-to-left window (the other modes don't depend on it). The style is read on every present. - The clear uses the background colour, passed on by SetBackgroundColor (opaque: the alpha isn't composed), black until then. present_scaling_test: RTL cases for NONE, STRETCH and ASPECT_RATIO_STRETCH. dxgi_swapchain_test: a NONE swapchain sets a background colour before presenting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @akimfomin and @jeremygold02 for measuring the displayed pixels. Pushed
Checks: |
|
Thanks for the fixes. I repeated the screen samples at Confirmed for the 64×48 source in a 128×128 client, with BGRA8/RGBA8 and black, blue and green backgrounds. The current head matches all 60/60 common native pixels in LTR (previously 32/60) and all 60/60 in RTL (previously 8/60). One more RTL case with a source larger than the window. I put red in the top-left 128×128 of a 192×160 back buffer and blue elsewhere. Stock D3D12 I tested a narrow follow-up locally. Add a zero-initialized Real composed window samples, synthetic frames only. AI-assisted (Codex). |
|
Tested
This is the RDNA4 data point the item was missing. As the PR notes, the presented pixels are not read back by the test; placement is covered by No game data. |
…shows its right part Measured against native D3D12 by @akimfomin on ItsNotRexed#4231: with DXGI_SCALING_NONE in a WS_EX_LAYOUTRTL window, a back buffer wider than the window is cropped to its right part (source columns 64..191 of 192 in a 128-wide window); the layer took the left part. SwapchainBlit gains a source x, set to src_width - copy width in that case, and the blit reads from it. present_scaling_test: wider-than-window RTL cases check the source offset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @akimfomin, and @theantipopau for the RDNA4 run. Pushed |
|
Confirmed
Same MinGW harness scope as the previous report. Synthetic frames only. Thanks for taking the follow-up. AI-assisted (Codex). |
…ed (D3D-444) GetDesc1 reported DXGI_SCALING_STRETCH whatever the app asked for, and Present always stretched the back buffer over the window. The swapchain now stores the scaling mode and returns it, and a DXGI_SCALING_NONE present copies the back buffer 1:1 to the top-left corner (top-right in a WS_EX_LAYOUTRTL window, showing the buffer's right part when it is wider), filling the rest with the SetBackgroundColor colour, with a nearest filter. DXGI_SCALING_ASPECT_RATIO_STRETCH and values past it are refused on HWND swapchains with DXGI_ERROR_INVALID_CALL, as on the host. The blit rectangle is computed in present_scaling.h (SwapchainBlit) and checked by present_scaling_test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The swapchain now loads vkCmdClearColorImage to fill what an unscaled back buffer leaves uncovered, and create() fails when a function is missing, so the mock driver this test (from ItsNotRexed#3280, D3D-389) builds its table from needs the entry too. A no-op, like its other vkCmd mocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ac579d9 to
e67b5ec
Compare
|
Rebased onto
Clean build with |
|
Full suite on the pushed head |
|
Tested
No game files. AI-assisted. |
|
Tested e67b5ec on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Tested
No game files. AI-assisted. |
Claim: #4084 (D3D-444, found by @jeremygold02)
Problem
An HWND swapchain created with
DXGI_SCALING_NONEreportedDXGI_SCALING_STRETCHfromGetDesc1(dxgi_com.cpphard-coded it), and Present stretched its back buffer to the window (dxgi_swapchain.hblitted to the full surface extent). A title asking for unscaled output got a stretched image.Measured on host DXGI for a flip-model HWND swapchain (Windows 11, RTX 5060 Ti, driver 621.14), creating each
DXGI_SCALINGand readingGetDesc1back:ScalingCreateSwapChainForHwndGetDesc1().ScalingmainSTRETCH(0)NONE(1)ASPECT_RATIO_STRETCH(2)Change
GetDesc1reports theScalingthe swapchain was created with.runtime/src/present_scaling.h(present_rect, pure arithmetic) gives Present's copy from the back buffer to the window's image: STRETCH fills the window (as before, linear filter); NONE copies texel for texel to the top-left corner, cropped where the back buffer is larger, nearest filter; ASPECT_RATIO_STRETCH (reachable only fromCreateSwapChainForCoreWindow) scales to the largest aspect-keeping size, centred. Whatever the copy doesn't cover is cleared to opaque black first (vkCmdClearColorImage, then a transfer→transfer barrier), so it's never the undefined contents of a freshly acquired image.CreateSwapChainForHwndrefusesASPECT_RATIO_STRETCHand values past it withDXGI_ERROR_INVALID_CALL, as the host does;CreateSwapChainForCoreWindow(which shared the HWND path) still acceptsASPECT_RATIO_STRETCH.Tests
present_scaling_test(ctestpresent_scaling, CPU only): the rectangles for each mode, smaller/larger/same-size back buffers, letterboxing, rounding, an empty source and sizes near 2^16 (64-bit products). 14 cases, OK.dxgi_swapchain_test:ASPECT_RATIO_STRETCH, 3 and 4 areDXGI_ERROR_INVALID_CALLon an HWND swapchain; a 64x48NONEswapchain in a 128x128 window keepsNONEinGetDesc1and presents (the clear-then-unscaled-copy path). Onmainit fails at the first check (the layer creates anASPECT_RATIO_STRETCHHWND swapchain). With the change: PASS, also withLEONIDA_VK_VALIDATION=1(0VUIDmessages).cmake --build+ctest -C RelWithDebInfo -j6: 137/137 passed, 8 skipped/disabled for missing game files, Bink or SDL, as onmain.tests/test_ctest_registration.py: OK.Limitations
present_rect's unit test and the Vulkan commands by the validation run.IDXGIFactory::CreateSwapChainstill maps toSTRETCH, as before.AI-assisted (Claude Code). Tested on Windows 11 with an RTX 5060 Ti, driver 621.14.