wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

DX12 doesn't respect alpha for the window

Open wez opened this issue 4 years ago • 4 comments

If you take the triangle example and set the alpha to be 0.5, when using Vulkan on both linux and Windows, the window is partially transparent (as expected).

When running on Windows with DX12 the alpha value has no effect.

Example demonstrating what I set for the color/alpha: https://github.com/wez/wezterm/blob/altwin/window/examples/wgpu.rs#L156-L160 https://github.com/wez/wezterm/blob/altwin/window/examples/shader.wgsl#L12

This is with wgpu=0.8

wez avatar May 06 '21 16:05 wez

Highly related to https://github.com/gfx-rs/wgpu/issues/687 It's unexpected that the current behavior is different.

kvark avatar May 06 '21 17:05 kvark

In the same vein, Metal on macOS doesn't respect alpha unless you call this each time you recreate the swap chain:

let layer: id = msg_send![h.ns_view as id, layer];
let () = msg_send![layer, setOpaque: NO];

wez avatar May 07 '21 02:05 wez

We do call this every time the swapchain is configured in gfx-backend-metal.

kvark avatar May 07 '21 02:05 kvark

I see; it seems like having more of https://wgpu.rs/doc/gfx_hal/window/struct.SwapchainConfig.html exposed via https://wgpu.rs/doc/wgpu/struct.SwapChainDescriptor.html might help to manage this "more better", but not necessarily "correctly" on its own :)

wez avatar May 07 '21 02:05 wez

You need use DComp to get any transparency working with windows I believe. Take a look at https://docs.rs/wgpu/latest/x86_64-pc-windows-msvc/wgpu/struct.Instance.html#method.create_surface_from_visual

cwfitzgerald avatar Oct 14 '23 03:10 cwfitzgerald