Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework swapchain management #4609

Merged
merged 29 commits into from
Jan 16, 2025
Merged

Rework swapchain management #4609

merged 29 commits into from
Jan 16, 2025

Conversation

doitsujin
Copy link
Owner

@doitsujin doitsujin commented Jan 13, 2025

Big refactor that moves a lot of responsibility to the backend, where it should have been in the first place.

Key changes:

  • Vulkan surface and swapchain creation now happens entirely in the backend. Instead of this clusterfuck where the front-end needs to manually synchronize everything through four different threads and then pray that it actually works, we now just set swapchain properties via a bunch of functions that can then get applied during the next acquireNextImage call.
  • Enabled automatic conversion between HDR10 and scRGB color spaces if the system only supports one of those and the game uses the other. This is definitely not well tested with actual HDR content though.
  • Fixed broken blending with the HUD and software cursor in non-linear color spaces (sRGB if the image format is non-sRGB; HDR10)

Needs lots of testing, especially in D3D9 apps since there are so many weird edge cases wrt swapchain usage.

@doitsujin doitsujin force-pushed the swapchain-rework branch 5 times, most recently from cb57e40 to 22ccf41 Compare January 13, 2025 14:15
@doitsujin doitsujin marked this pull request as ready for review January 13, 2025 16:08
@doitsujin doitsujin force-pushed the swapchain-rework branch 6 times, most recently from e566e65 to 15bbeda Compare January 15, 2025 17:14
Massive cleanup reduce code duplication between D3D11 and D3D9,
and introduce a sane path to pass data around. Implicit swap
chain recreation is now entirely transparent to the frontends.
@doitsujin doitsujin force-pushed the swapchain-rework branch 3 times, most recently from c8bb83d to 83409a2 Compare January 15, 2025 18:31
@WinterSnowfall
Copy link
Contributor

WinterSnowfall commented Jan 15, 2025

It appears this PR fixes #4222 , for not entirely known reasons. Nevermind, it does not.

The swap chain blitter can deal with the conversion.
Needed for D3D8 due to implicit swapchain shenanigans.
This will be necessary for non-linear color spaces to get proper blending.
Also adds a separate set of shaders for the software cursor, provided it
can be drawn directly with alpha blending.
For sRGB, using a native sRGB format allows the swapchain blitter
to use a more efficient code path for drawing the HUD.

Also allow RGB9E5 for sRGB and HDR10.
May fix some issues in case the WSI implementation can return SUBOPTIMAL
from present but not acquire. Also ensure to keep state consistent.
Meaningless, this needs to be done elsewhere anyway.
And add method to explicitly destroy relevant Vulkan objects.
There's basically no reason to ever recreate a presenter for an already
managed window with the new code.
@doitsujin doitsujin merged commit 3dbe8ad into master Jan 16, 2025
8 checks passed
@doitsujin doitsujin deleted the swapchain-rework branch January 16, 2025 10:38
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.

2 participants