Honor the surface's alphaMode on the Vulkan and D3D swapchains - #69
Honor the surface's alphaMode on the Vulkan and D3D swapchains#69d3x0r wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
f9aa24c to
787a066
Compare
|
👋 Thanks for your contribution! Your PR has been imported to Gerrit. |
|
Latest revision failed to import to Gerrit (our code review tool), due to the merge conflict. Could you update the PR? |
ae99542 to
ba69bf7
Compare
|
Import worked! I think some of the comments on Gerrit still need to be addressed though. |
ChooseConfig hardcoded VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR outside of Android, so a surface configured with a transparent alphaMode was composited as opaque. Convert the WebGPU enum directly: Surface.cpp has already resolved Auto and validated the mode against the capabilities PhysicalDeviceVk reports. Add a transparent-window mode (T) to ManualSurfaceTest so the alpha modes can be checked against the desktop.
ba69bf7 to
68512de
Compare
SwapChainD3D hardcoded DXGI_ALPHA_MODE_IGNORE even though PhysicalDeviceD3D advertises Premultiplied as supported. DXGI rejects a non-opaque alpha mode on CreateSwapChainForHwnd, so a premultiplied HWND surface is now created with CreateSwapChainForComposition and bound to the window through a DirectComposition visual, whose lifetime follows the swapchain across recycling.
68512de to
2ee4c4e
Compare
Dawn hardcoded an opaque composite alpha in both swapchain backends, so a surface configured with a transparent
alphaModewas composited as opaque even though the adapter advertised the mode as supported.Vulkan:
SwapChainVk::ChooseConfigconverts the WebGPU enum directly. Auto and unsupported modes are already resolved and validated inSurface.cpp, so the Android-only fallback loop is gone.D3D:
SwapChainD3Dasked forDXGI_ALPHA_MODE_IGNORE. DXGI rejects a non-opaque alpha mode onCreateSwapChainForHwnd, so a premultiplied HWND surface is created withCreateSwapChainForCompositionand bound to the window through a DirectComposition visual. Recycling an existing swapchain now also requires the alpha mode to be unchanged, sinceAlphaModeis fixed at creation and a composition swapchain is not interchangeable with an HWND one.Tested with
ManualSurfaceTest:Topens a window with a transparent framebuffer,Rswitches to the clear-cycle render mode (its clear is premultiplied and cycles its alpha) andAcycles alpha modes. On Windows that covers the backends presenting directly to the HWND; the D3D composition path additionally needs a window created withWS_EX_NOREDIRECTIONBITMAP, which GLFW does not do and which cannot be set afterwards, so it was verified against a Node addon embedding Dawn (@d3x0r/sack-gui) driving three.jsWebGPURendererover such a window, on D3D12 and Vulkan, Windows 11 + NVIDIA.