Allow transparent clear color if specified#69
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. |
Honor
wgpu::CompositeAlphaModein Vulkan swap chain creationSwapChainVk::ChooseConfigpreviously hardcoded VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR on non-Android platforms, silently dropping any CompositeAlphaMode the application requested on its WGPUSurfaceConfiguration. This made per-pixel transparency unreachable through Dawn on Windows/(Linux?) even when the underlying VkSurfaceKHR reported PRE_MULTIPLIED support.This change maps each wgpu::CompositeAlphaMode to its corresponding Vulkan composite alpha flag, with a fallback that prefers any alpha-honoring mode over OPAQUE when the requested mode isn't supported.
Testing
Verified on Windows 11 + NVIDIA + WS_EX_NOREDIRECTIONBITMAP HWND: requesting "premultiplied" from a GPUCanvasContext.configure(...) call now produces a swap chain that DWM composites with per-pixel alpha. Confirmed via Three.js WebGPURenderer({alpha:true}) rendering with setClearAlpha(0) over the desktop.
My project : https://github.com/d3x0r/sack.vfs/tree/sack-gui is a Node addon (npm @d3x0r/sack-gui) pulls Dawn as an external project, and then provides webgpu bindings for node, which then using three.js webgpu, with a vulkan backend, and with this patch can generate alpha-transparent desktop windows. (Other projects like Mystral would also inherit this).
A dawn::native::end2end::SwapChainTests case for Premultiplied would be a good follow-up; happy to add if reviewers want it in this PR. (There may be a test for android already?)