Skip to content

fix(windows): transparent windows and overlays stay clear on every GPU - #31

Merged
Hona merged 1 commit into
devfrom
translucent-gpu
Oct 28, 2026
Merged

Hona merged 1 commit into
devfrom
translucent-gpu

Conversation

@Hona

@Hona Hona commented Oct 28, 2026

Copy link
Copy Markdown
Member

On Windows, a transparent overlay (Hex's HUD) draws a black box around its content on PCs whose low-power GPU can't composite alpha. Rune falls back to Opaque with no warning.

Before After

overlay-lab on a PC with an RTX 5070 Ti and an AMD Radeon integrated GPU.

Why

vulkaninfo on that PC:

GPU id : 0 (NVIDIA GeForce RTX 5070 Ti) [VK_KHR_win32_surface]: OPAQUE, PRE_MULTIPLIED
GPU id : 1 (AMD Radeon(TM) Graphics)    [VK_KHR_win32_surface]: OPAQUE
  • request_adapter(LowPower) picks the AMD integrated GPU through Vulkan. Its window surface is opaque only.
  • wgpu's default DX12 presentation (DxgiFromHwnd) is opaque only on every GPU (wgpu-hal dx12/adapter.rs: WndHandle(_) => vec![Opaque]).
  • Overlays reuse the pooled device after checking only its features, so a transparent overlay inherits whichever adapter the first window got.

Fix

flowchart LR
    A[translucent surface] --> B{pooled device composites alpha here?}
    B -- yes --> R[reuse it]
    B -- no --> C["request_adapter(LowPower)"]
    C --> D{composites alpha?}
    D -- yes --> U[use it]
    D -- no --> E["enumerate_adapters: supported + translucent,<br/>lowest power first"]
    E --> U
Loading
  • Gpu::instance sets dx12.presentation_system = DxgiFromVisual. DirectComposition composites alpha on every GPU, so DX12 always offers a transparent option on Windows.
  • New translucency module:
    • mode(surface, adapter) returns the translucent alpha mode, if any. window::surface_config now uses it.
    • prefer(instance, surface, adapter) keeps the adapter if it can do transparency; otherwise it takes the lowest-power adapter that can.
    • serves(gpu, surface, wanted, translucent) is the reuse check for a pooled or prewarmed device.
  • Gpu::for_surface(wanted, translucent, …). Overlays always pass true; windows pass options.transparent. try_with_features is unchanged.
  • An overlay that still can't be transparent logs transparency unavailable for overlay <name>, as windows already do.
  • Opaque windows keep request_adapter(LowPower) as before.

A surface whose adapter can't composite alpha (a Win32 Vulkan surface on AMD integrated GPUs, any HWND DXGI swapchain) fell back to opaque, so overlays drew a black box. DX12 now presents through DirectComposition; a translucent surface prefers the lowest-power adapter that composites it and reuses a shared device only if it can; overlays log when transparency is unavailable.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 01:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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