#13572·slint

Windows: transparent window renders black with the Skia wgpu (DX12) renderer

Author: HOMECODERNEOCreated Sep 22, 2026Updated Sep 28, 2026
Labelsa:renderer-skianeed triaging

Bug Description

A window with background: transparent renders a black background instead of the desktop when using the Skia wgpu renderer (Direct3D 12) on Windows.

Steps: run the code below with SLINT_BACKEND=winit-skia-wgpu (optionally WGPU_DX12_PRESENTATION_SYSTEM=Visual). Expected: desktop visible around the red square. Actual: black background.

Root causes

Found by hooking IDXGIFactory2::CreateSwapChainFor* in a test app:

  1. WGPU_* environment variables are ignored. wgpu-30 is a workspace dependency with default-features = false, and nothing enables its std feature, so wgpu-types is built without std and wgpu_types::env::var() always returns None. WGPU_BACKEND, WGPU_POWER_PREF and WGPU_DX12_PRESENTATION_SYSTEM have no effect. With the default DxgiFromHwnd, wgpu calls CreateSwapChainForHwnd with DXGI_ALPHA_MODE_IGNORE.

  2. The premultiplied alpha mode never reaches DXGI. With DxgiFromVisual, WGPUSurface::init_with_parts first configures the surface with the alpha mode from get_default_config (Auto → DXGI_ALPHA_MODE_UNSPECIFIED). set_transparent() then reconfigures with PreMultiplied, but on DX12 wgpu-hal only calls ResizeBuffers on an existing swapchain, which cannot change the alpha mode, so it stays UNSPECIFIED.

Workaround that works for us

diff
-wgpu-30 = { package = "wgpu", version = "30", default-features = false }
+wgpu-30 = { package = "wgpu", version = "30", default-features = false, features = ["std"] }

and in internal/renderers/skia/wgpu_30_surface.rs, init_with_parts(), before the first configure:

rust
if swapchain_capabilities.alpha_modes.contains(&wgpu::CompositeAlphaMode::PreMultiplied) {
    surface_config.alpha_mode = wgpu::CompositeAlphaMode::PreMultiplied;
}

With both changes and WGPU_DX12_PRESENTATION_SYSTEM=Visual, the swapchain is created by CreateSwapChainForComposition with DXGI_ALPHA_MODE_PREMULTIPLIED, and the window is transparent on both monitors (checked by reading back screen pixels). A proper fix probably passes the window's transparency to the surface before its first configure, or recreates the swapchain when the alpha mode changes.

Why not OpenGL

With winit-skia-opengl, the AMD driver presents OpenGL through its own DXGI swapchain on a FreeSync monitor (it loads amdxc64.dll, D3D12Core.dll, dcomp.dll from atio6axx.dll), and window alpha is lost there too. That makes DX12 with DirectComposition the only reliable option for transparency on such setups.

Side note

With the wgpu surface, Window::set_rendering_notifier callbacks never fire, because WGPUSurface::with_graphics_api is gated behind unstable-wgpu-30.


This was investigated with the help of an AI assistant (Claude): test programs and DXGI hooks. I verified the results on my own hardware.

Reproducible Code (if applicable)

slint
export component TestCase inherits Window {
    no-frame: true;
    background: transparent;
    Rectangle { width: 50px; height: 50px; background: red; }
}

Environment Details

  • Slint Version: 1.18.1
  • Platform/OS: Windows 11 23H2 (22631); AMD Radeon 660M iGPU (driver 26.8.1) + NVIDIA RTX 3050 Ti Laptop
  • Programming Language: C++ (CMake FetchContent)
  • Backend/Renderer: winit + Skia (wgpu / Direct3D 12); OpenGL for comparison

Product Impact

A screenshot tool with a semi-transparent full-screen overlay across multiple monitors. Transparency is essential; we currently ship a local patch of Slint as a workaround.