Vulkan Popup Transparency Issue.#21802
Conversation
…d mode if supported. This change ensures proper transparency support for popups when in Vulkan rendering mode. Upon updating to Nvidia driver 610.74, Popups, when in Vulkan rendering, were showing the classic black square around them if margin is applied. This fixes that issue while still falling back if pre-multiplied is unavailable.
|
You can test this PR using the following package version. |
|
Please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following: Contributor License AgreementContribution License AgreementThis Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ), 1. Definitions. “Code” means the computer software code, whether in human-readable or machine-executable form, “Project” means any of the projects owned or managed by AvaloniaUI OÜ and offered under a license “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any “Submission” means the Code and any other copyrightable material Submitted by You, including any 2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any 3. Originality of Work. You represent that each of Your Submissions is entirely Your 4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else 5. Licenses. a. Copyright License. You grant AvaloniaUI OÜ, and those who receive the Submission directly b. Patent License. You grant AvaloniaUI OÜ, and those who receive the Submission directly or c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement. 6. Representations and Warranties. You represent that You are legally entitled to grant the above 7. Notice to AvaloniaUI OÜ. You agree to notify AvaloniaUI OÜ in writing of any facts or 8. Information about Submissions. You agree that contributions to Projects and information about 9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the Republic of Estonia, and 10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and AvaloniaUI OÜ dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1. |
|
@cla-avalonia agree
…On Saturday, July 18th, 2026 at 5:47 PM, cla-avalonia ***@***.***> wrote:
cla-avalonia left a comment [(AvaloniaUI/Avalonia#21802)](#21802 (comment))
***@***.***(https://github.com/the-bla),
Please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following:
@cla-avalonia agree
Contributor License Agreement
Contribution License Agreement
This Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ),
and conveys certain license rights to the AvaloniaUI OÜ ( “AvaloniaUI OÜ” ) for Your contributions to
AvaloniaUI OÜ open source projects. This Agreement is effective as of the latest signature date below.
1. Definitions.
“Code” means the computer software code, whether in human-readable or machine-executable form,
that is delivered by You to AvaloniaUI OÜ under this Agreement.
“Project” means any of the projects owned or managed by AvaloniaUI OÜ and offered under a license
approved by the Open Source Initiative (www.opensource.org).
“Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
Project, including but not limited to communication on electronic mailing lists, source code control
systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
discussing and improving that Project, but excluding communication that is conspicuously marked or
otherwise designated in writing by You as “Not a Submission.”
“Submission” means the Code and any other copyrightable material Submitted by You, including any
associated comments and documentation.
2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
Project. This Agreement covers any and all Submissions that You, now or in the future (except as
described in Section 4 below), Submit to any Project.
3. Originality of Work. You represent that each of Your Submissions is entirely Your
original work. Should You wish to Submit materials that are not Your original work,
You may Submit them separately to the Project if You (a) retain all copyright and
license information that was in the materials as you received them, (b) in the
description accompanying your Submission, include the phrase "Submission
containing materials of a third party:" followed by the names of the third party and any
licenses or other restrictions of which You are aware, and (c) follow any other
instructions in the Project's written guidelines concerning Submissions.
4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
Submission is made in the course of Your work for an employer or Your employer has intellectual
property rights in Your Submission by contract or applicable law, You must secure permission from Your
employer to make the Submission before signing this Agreement. In that case, the term “You” in this
Agreement will refer to You and the employer collectively. If You change employers in the future and
desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
and secure permission from the new employer before Submitting those Submissions.
5. Licenses.
a. Copyright License. You grant AvaloniaUI OÜ, and those who receive the Submission directly
or indirectly from AvaloniaUI OÜ, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable
license in the Submission to reproduce, prepare derivative works of, publicly display, publicly perform,
and distribute the Submission and such derivative works, and to sublicense any or all of the foregoing
rights to third parties.
b. Patent License. You grant AvaloniaUI OÜ, and those who receive the Submission directly or
indirectly from AvaloniaUI OÜ, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license
under Your patent claims that are necessarily infringed by the Submission or the combination of the
Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
import or otherwise dispose of the Submission alone or with the Project.
c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
granted by implication, exhaustion, estoppel or otherwise.
6. Representations and Warranties. You represent that You are legally entitled to grant the above
licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
have disclosed under Section 3 ). You represent that You have secured permission from Your employer to
make the Submission in cases where Your Submission is made in the course of Your work for Your
employer or Your employer has intellectual property rights in Your Submission by contract or applicable
law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
EXPRESSLY STATED IN SECTIONS 3, 4, AND 6 , THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
7. Notice to AvaloniaUI OÜ. You agree to notify AvaloniaUI OÜ in writing of any facts or
circumstances of which You later become aware that would make Your representations in this
Agreement inaccurate in any respect.
8. Information about Submissions. You agree that contributions to Projects and information about
contributions may be maintained indefinitely and disclosed publicly, including Your name and other
information that You submit with Your Submission.
9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the Republic of Estonia, and
the parties consent to exclusive jurisdiction and venue in the courts sitting in Talinn,
Estonia. The parties waive all defenses of lack of personal jurisdiction and forum non-conveniens.
10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
supersedes any and all prior agreements, understandings or communications, written or oral, between
the parties relating to the subject matter hereof. This Agreement may be assigned by AvaloniaUI OÜ.
AvaloniaUI OÜ dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1.
—
Reply to this email directly, [view it on GitHub](#21802?email_source=notifications&email_token=BNQPXZZZTP6WARI2T7GUTM35FQSCDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMBRGM3TEMRRGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5013722139), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/BNQPXZ2IVWODOZPWDP7ACTT5FQSCDAVCNFSNUABEKJSXA33TNF2G64TZHMYTIOJWGQ2DONJ3JFZXG5LFHM2DSMRQG4ZDQOBTGGQXMAQ).
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for [iOS](https://github.com/notifications/mobile/ios/BNQPXZ4IQU2FKHV3LAIOLKL5FQSCDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMBRGM3TEMRRGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y) and [Android](https://github.com/notifications/mobile/android/BNQPXZ3NDVRKMUAP4MNATXL5FQSCDA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMBRGM3TEMRRGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI). Download it today!
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
What does the pull request do?
Makes the Vulkan backend request a supported swapchain composite-alpha mode instead of
unconditionally hardcoding
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, so transparent windows and popups(e.g.
ComboBox/ light-dismiss popups and their drop shadows) render with per-pixel alpha underthe Vulkan rendering mode.
VulkanDisplay.CreateSwapchainnow prefersVK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHRwhen thesurface advertises it in
VkSurfaceCapabilitiesKHR.supportedCompositeAlpha, and falls back toVK_COMPOSITE_ALPHA_OPAQUE_BIT_KHRotherwise.Maybe related: #19378
What is the current behavior?
With
RenderingMode = [Vulkan], aTopLevelwithTransparencyLevelHint="Transparent"and atransparent background renders opaque — most visibly,
ComboBoxpopups show a hard black boxwhere the drop shadow / rounded-corner margin should be transparent.
ActualTransparencyLevelalsoreports
Transparentwhile nothing is actually transparent (#19378).Root cause:
VulkanDisplay.CreateSwapchainalways passedVK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR. Perthe Vulkan spec,
OPAQUEmeans "the alpha channel, if it exists, is ignored… the image is treatedas if it has a constant alpha of 1.0." So the presented surface is opaque by definition, regardless
of the alpha Skia produced.
How this was observed
I noticed this after an NVIDIA driver update on Windows (Vulkan rendering mode):
ComboBoxpopupsthat had previously looked transparent started showing an opaque black box around the popup margin.
The change correlated with a driver-branch update on this machine (
591.86→610.74/32.0.16.1074, R610 branch), though I have not isolated the driver as the definitive cause.On the current driver,
vulkaninforeports the Win32 surface supports both composite-alpha modes:With the hardcoded
OPAQUEmode the window is opaque (as the spec defines); switching to thePRE_MULTIPLIEDmode the surface advertises restores transparent windows and popups. Regardless ofwhat changed in my environment, requesting a supported non-opaque mode is the spec-correct behavior
for transparent windows — which is why this fix queries
supportedCompositeAlpharather thanassuming a fixed mode, and falls back to
OPAQUEwhere premultiplied isn't offered.What is the updated/expected behavior with this PR?
The swapchain is created with a composite-alpha mode the surface actually supports, so the OS
compositor blends the window's alpha channel and transparent windows/popups render correctly. Where
PRE_MULTIPLIEDis not offered by the surface, the code falls back toOPAQUEexactly as before —so there is no change on platforms/drivers that only expose opaque.
To test:
RenderingMode = [Win32RenderingMode.Vulkan](or[X11RenderingMode.Vulkan]).TransparencyLevelHint="Transparent"/ transparent background and open aComboBoxdropdown.correctly alpha-blended popup shadow.
How was the solution implemented (if it's not obvious)?
In
VulkanDisplay.CreateSwapchain, the already-queriedVkSurfaceCapabilitiesKHRis inspected andthe composite-alpha value is chosen:
PRE_MULTIPLIEDis chosen (rather thanPOST_MULTIPLIED) because Avalonia's Skia surfaces arerendered with premultiplied alpha, which matches that mode's contract. The choice is guarded by
supportedCompositeAlpha, so it is a no-op wherever premultiplied alpha isn't available.Note on scope: this prefers premultiplied whenever the surface supports it. An opaque top-level
clears its surface to alpha = 1.0, for which premultiplied compositing is visually identical to
opaque, so no regression is expected for opaque windows. If the core team would prefer to be more
conservative, an alternative is to thread the window's requested
TransparencyLeveldown toswapchain creation and only request premultiplied when transparency is actually desired — happy to
adjust in that direction.
A unit/render test isn't really feasible here: composite-alpha selection depends on a live Vulkan
surface and OS-compositor behavior, which the existing test harnesses don't exercise. The change is
a single guarded branch with an opaque fallback.
Checklist
Breaking changes
None expected. Behavioral note: on drivers/surfaces that support
PRE_MULTIPLIED, windows nowcomposite their alpha channel instead of being forced opaque. This is the intended fix and matches
the Vulkan spec; opaque content (alpha = 1.0) is unaffected, and surfaces that only expose
OPAQUEkeep the previous behavior.
Obsoletions / Deprecations
None.
Related issues
#19378