fix(dx12): map composite alpha mode (#7117)

* fix(dx12): map composite alpha mode

closes #7108

* changelog entry

* add composite modes based on surface target

* fix missing `in` in change log entry
This commit is contained in:
Amr Bashir
2025-02-13 01:02:50 +02:00
committed by GitHub
parent 97704099de
commit 2f607d3e64
3 changed files with 22 additions and 3 deletions

View File

@@ -106,6 +106,7 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).
- Fix HLSL storage format generation. By @Vecvec in [#6993](https://github.com/gfx-rs/wgpu/pull/6993) and [#7104](https://github.com/gfx-rs/wgpu/pull/7104)
- Fix 3D storage texture bindings. By @SparkyPotato in [#7071](https://github.com/gfx-rs/wgpu/pull/7071)
- Fix DX12 composite alpha modes. By @amrbashir in [#7117](https://github.com/gfx-rs/wgpu/pull/7117)
#### WebGPU

View File

@@ -281,6 +281,13 @@ pub fn map_vertex_format(format: wgt::VertexFormat) -> Dxgi::Common::DXGI_FORMAT
}
}
pub fn map_acomposite_alpha_mode(_mode: wgt::CompositeAlphaMode) -> Dxgi::Common::DXGI_ALPHA_MODE {
Dxgi::Common::DXGI_ALPHA_MODE_IGNORE
pub fn map_acomposite_alpha_mode(mode: wgt::CompositeAlphaMode) -> Dxgi::Common::DXGI_ALPHA_MODE {
match mode {
wgt::CompositeAlphaMode::PreMultiplied => Dxgi::Common::DXGI_ALPHA_MODE_PREMULTIPLIED,
wgt::CompositeAlphaMode::PostMultiplied => Dxgi::Common::DXGI_ALPHA_MODE_STRAIGHT,
wgt::CompositeAlphaMode::Opaque => Dxgi::Common::DXGI_ALPHA_MODE_IGNORE,
wgt::CompositeAlphaMode::Auto | wgt::CompositeAlphaMode::Inherit => {
Dxgi::Common::DXGI_ALPHA_MODE_UNSPECIFIED
}
}
}

View File

@@ -863,7 +863,18 @@ impl crate::Adapter for super::Adapter {
| wgt::TextureUses::COPY_SRC
| wgt::TextureUses::COPY_DST,
present_modes,
composite_alpha_modes: vec![wgt::CompositeAlphaMode::Opaque],
composite_alpha_modes: match surface.target {
SurfaceTarget::WndHandle(_) => vec![wgt::CompositeAlphaMode::Opaque],
SurfaceTarget::Visual(_)
| SurfaceTarget::SurfaceHandle(_)
| SurfaceTarget::SwapChainPanel(_) => vec![
wgt::CompositeAlphaMode::Auto,
wgt::CompositeAlphaMode::Inherit,
wgt::CompositeAlphaMode::Opaque,
wgt::CompositeAlphaMode::PostMultiplied,
wgt::CompositeAlphaMode::PreMultiplied,
],
},
})
}