Skip to content

Optimize rendering performance by reduce Premultiplied AlphaMode#20757

Open
lindexi wants to merge 14 commits intoAvaloniaUI:masterfrom
dotnet-campus:t/lindexi/Render
Open

Optimize rendering performance by reduce Premultiplied AlphaMode#20757
lindexi wants to merge 14 commits intoAvaloniaUI:masterfrom
dotnet-campus:t/lindexi/Render

Conversation

@lindexi
Copy link
Contributor

@lindexi lindexi commented Feb 26, 2026

What does the pull request do?

See #20643

Testing the RenderDemo in my device:

  • Screen: 3840x2160 (4K) + 100% DPI
  • CPU: i5-12450H
  • GPU: - (Integrated graphics card)

Test step:

  1. Open the TaskManager to find the GPU usage
  2. Switching the TransparencyLevelHint by the menu item in RenderDemo:
    image

GPU usage of DWM:

Win32CompositionMode Before After
WinUIComposition 45% 15%
DirectComposition 35% 15%

What is the current behavior?

Currently, regardless of whether a window requires transparency, the rendering backend on Windows is configured to use the Premultiplied AlphaMode. This forces the Desktop Window Manager (DWM) to handle alpha compositing even for opaque windows, resulting in unnecessary GPU resource overhead for the DWM. See #20643

What is the updated/expected behavior with this PR?

With the proposed modification, render backend will first determine if a window is opaque by WindowTransparencyLevel as @maxkatz6 recommended (see #20643 (comment) ). If so, it will set the AlphaMode in the rendering backend to "Ignore". This adjustment enables the GPU to conserve substantial resources when processing opaque windows.

Notably, this change will lead to a significant reduction in GPU resource usage on 4K-resolution devices without discrete graphics cards, especially when full-screen opaque windows are active.

How can I apply this optimization? Just settings the window.TransparencyLevelHint = [WindowTransparencyLevel.None];

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #20643

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0062571-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0062637-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0062651-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0062981-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@lindexi lindexi marked this pull request as ready for review March 5, 2026 03:38
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0062985-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0063050-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Premultiplied AlphaMode causes high DWM cost for opaque windows (4K)

3 participants