Skip to content

[wsi] For SDL3 use GetWindowSizeInPixels - #4826

Merged
misyltoad merged 1 commit into
doitsujin:masterfrom
flibitijibibo:sdl3-dpi
Apr 3, 2025
Merged

misyltoad merged 1 commit into
doitsujin:masterfrom
flibitijibibo:sdl3-dpi

Conversation

@flibitijibibo

@flibitijibibo flibitijibibo commented Apr 3, 2025 •

Copy link
Copy Markdown
Contributor

Another subtle thing in SDL3 is that "points" vs "pixels" became very separated; you could calculate this manually by using Points and getting the pixel density of the display, but this is a lot easier. (Interestingly this feature is not available for the Set function, so some people are still doing some scaling manually...)

Fixes Wayland windows getting a partial view of the swapchain instead of the full surface; X was not affected.

@misyltoad
misyltoad merged commit 76dd344 into doitsujin:master Apr 3, 2025
@flibitijibibo
flibitijibibo deleted the sdl3-dpi branch April 3, 2025 22:13
@doitsujin

Copy link
Copy Markdown
Owner

Is this actually the correct thing to do for windowed mode swapchains? DXGI has no real notion of desktop vs display coordinates, and Windows seems to do scaling at a compositor level rather than giving the app a larger swapchain, but I'm not 100% sure what the exact behaviour is there.

For full-screen i guess the issue is that the window's desktop coordinates are smaller than the display mode.

@doitsujin

Copy link
Copy Markdown
Owner

There's also the question of what to do with DXGI ResizeTarget. Not sure if that's supposed to be display or desktop coordinates if the app is high dpi aware (which, again, we don't really have a notion of, but Windows does).

@flibitijibibo

Copy link
Copy Markdown
Contributor Author

At least from SDL's point of view this should be more correct; the calls line up with dxvk's win32 WSI:

https://github.com/doitsujin/dxvk/blob/master/src/wsi/win32/wsi_window_win32.cpp#L109

https://github.com/libsdl-org/SDL/blob/main/src/video/windows/SDL_windowswindow.c#L1044

SDL should probably do the left/top subtraction too... A bonus: Here's where SDL3 does the scaling for Set, which results in GetWindowSize being different on Windows too: https://github.com/libsdl-org/SDL/blob/main/src/video/windows/SDL_windowswindow.c#L264

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