Skip to content

Allow transparent clear color if specified#69

Open
d3x0r wants to merge 1 commit into
google:mainfrom
d3x0r:v20260423.175430-d3x0r-support-transparent-clear
Open

Allow transparent clear color if specified#69
d3x0r wants to merge 1 commit into
google:mainfrom
d3x0r:v20260423.175430-d3x0r-support-transparent-clear

Conversation

@d3x0r

@d3x0r d3x0r commented Jun 8, 2026

Copy link
Copy Markdown

Honor wgpu::CompositeAlphaMode in Vulkan swap chain creation
SwapChainVk::ChooseConfig previously 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?)

@google-cla

google-cla Bot commented Jun 8, 2026

Copy link
Copy Markdown

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.

@d3x0r d3x0r force-pushed the v20260423.175430-d3x0r-support-transparent-clear branch from f9aa24c to 787a066 Compare June 8, 2026 16:22
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

👋 Thanks for your contribution! Your PR has been imported to Gerrit.
Please visit https://dawn-review.googlesource.com/c/dawn/+/314855 to see it and CC yourself on the change.
After iterating on feedback, please comment on the Gerrit review to notify reviewers.
All reviews are handled within Gerrit, any comments on the GitHub PR may be missed.
You can continue to upload commits to this PR, and they will be automatically imported
into Gerrit.

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.

1 participant