Skip to content

Honor the surface's alphaMode on the Vulkan and D3D swapchains - #69

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

Honor the surface's alphaMode on the Vulkan and D3D swapchains#69
d3x0r wants to merge 2 commits into
google:mainfrom
d3x0r:v20260423.175430-d3x0r-support-transparent-clear

Conversation

@d3x0r

@d3x0r d3x0r commented Jun 8, 2026

Copy link
Copy Markdown

Dawn hardcoded an opaque composite alpha in both swapchain backends, so a surface configured with a transparent alphaMode was composited as opaque even though the adapter advertised the mode as supported.

Vulkan: SwapChainVk::ChooseConfig converts the WebGPU enum directly. Auto and unsupported modes are already resolved and validated in Surface.cpp, so the Android-only fallback loop is gone.

D3D: SwapChainD3D asked for DXGI_ALPHA_MODE_IGNORE. DXGI rejects a non-opaque alpha mode on CreateSwapChainForHwnd, so a premultiplied HWND surface is created with CreateSwapChainForComposition and bound to the window through a DirectComposition visual. Recycling an existing swapchain now also requires the alpha mode to be unchanged, since AlphaMode is fixed at creation and a composition swapchain is not interchangeable with an HWND one.

Tested with ManualSurfaceTest: T opens a window with a transparent framebuffer, R switches to the clear-cycle render mode (its clear is premultiplied and cycles its alpha) and A cycles alpha modes. On Windows that covers the backends presenting directly to the HWND; the D3D composition path additionally needs a window created with WS_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.js WebGPURenderer over such a window, on D3D12 and Vulkan, Windows 11 + NVIDIA.

@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.

@kainino0x

kainino0x commented Aug 11, 2026

Copy link
Copy Markdown
Member

Latest revision failed to import to Gerrit (our code review tool), due to the merge conflict. Could you update the PR?

@d3x0r
d3x0r force-pushed the v20260423.175430-d3x0r-support-transparent-clear branch from ae99542 to ba69bf7 Compare August 11, 2026 23:35
@kainino0x

Copy link
Copy Markdown
Member

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.
@d3x0r d3x0r changed the title Allow transparent clear color if specified Honor the surface's alphaMode on the Vulkan and D3D swapchains Aug 12, 2026
@d3x0r
d3x0r force-pushed the v20260423.175430-d3x0r-support-transparent-clear branch from ba69bf7 to 68512de Compare August 12, 2026 14:28
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.
@d3x0r
d3x0r force-pushed the v20260423.175430-d3x0r-support-transparent-clear branch from 68512de to 2ee4c4e Compare August 12, 2026 14:46
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