-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
GPU: Support swapchain buffer transparency in Vulkan #10654
base: main
Are you sure you want to change the base?
Conversation
If the window is flagged with SDL_WINDOW_TRANSPARENT, create the associated swapchain with a composite alpha value that supports blending, if available. Fixes transparent windows on the Vulkan backend, and prevents possible validation errors by ensuring that the composite alpha value is always a valid bit in VkSurfaceCapabilitiesKHR::supportedCompositeAlpha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to merge features that only work on one backend, that's how we make a hacky mess for clients.
We actually optionally use features up to DXGI 1.6 on DX11, you can see this in the QueryInterface calls. If you can get this feature working on all backends I will reconsider merging this. DXGI 1.4 is required to be supported on Windows 10+ so that's an incredibly wide range of systems. You would also have to look into whether Metal supports this.
Also: if this feature is only conditionally available I would be in favor of adding a SupportsSwapchainTransparency function that the client can check before using this feature. |
At least for Vulkan this should be okay - Metal has a similar flag from what I recall, but if we need to do these one at a time this is fine |
I just want to make sure this is at least possible on every backend first. |
I think the DirectComposition stuff should work on D3D11/D3D12 using You could quickly test if it works by replacing the current window transparency code SDL/src/video/windows/SDL_windowswindow.c Lines 741 to 762 in d1739ce
with setting the flag in GetWindowStyleEx() instead.
However, doing it this way almost certainly regress OpenGL and generally anything that doesn't use DXGI flip presentation. The linked article even suggests that using the composition API is required:
But I've actually found this to be false, HWND flip swapchains generally do work without redirection surfaces (but the fancy transparency stuff is still composition-only). |
If the window is flagged with SDL_WINDOW_TRANSPARENT, create the associated swapchain with a composite alpha value that supports blending, if available.
Fixes transparent windows on the Vulkan backend, and prevents possible validation errors by ensuring that the composite alpha value is always a valid bit in VkSurfaceCapabilitiesKHR::supportedCompositeAlpha.
To note, the DX 11 and 12 backends don't currently support transparent windows either. I tried implementing this for DX12, but all I was able to get was a black or empty window when using
IDXGIFactory4_CreateSwapChainForComposition
, even with all of theDXGI_SWAP_CHAIN_DESC1
struct parameters seemingly set correctly and the function succeeding. Looking at the old DX12 renderer, it looks like transparent windows just don't work with DX12?SDL/src/render/direct3d12/SDL_render_d3d12.c
Lines 3202 to 3204 in f827c13
DX11 currently uses DXGI 1.0, but would need 1.2 to enable window transparency, which would require a bit of refactoring.