From b13bb468cb20b54d348b35fc3d11d7ee50786626 Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Thu, 6 Oct 2022 05:31:22 +0800 Subject: [PATCH] gl: add `Rgba16Float` format support for color attachments (#3045) Co-authored-by: Connor Fitzgerald --- CHANGELOG.md | 3 ++- wgpu-hal/src/gles/adapter.rs | 34 +++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a15b564b..c73299d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,7 +104,7 @@ SurfaceConfiguration { - Fix bug where the Vulkan backend would panic when using a supported window and display handle but the dependent extensions are not available by @i509VCB in [#3054](https://github.com/gfx-rs/wgpu/pull/3054). -#### Gles +#### GLES - Report vendor id for Mesa and Apple GPUs. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036) - Report Apple M2 gpu as integrated. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036) @@ -131,6 +131,7 @@ SurfaceConfiguration { is the actual version of the device. By @i509VCB in [#3011](https://github.com/gfx-rs/wgpu/pull/3011) #### GLES +- Add `Rgba16Float` format support for color attachments. By @jinleili in [#3045](https://github.com/gfx-rs/wgpu/pull/3045) - `TEXTURE_COMPRESSION_ASTC_HDR` feature detection by @jinleili in [#3042](https://github.com/gfx-rs/wgpu/pull/3042) ### Performance diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 0a513e96e..a7a0465f8 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -785,21 +785,29 @@ impl crate::Adapter for super::Adapter { &self, surface: &super::Surface, ) -> Option { + let mut formats = if surface.supports_srgb() { + vec![ + wgt::TextureFormat::Rgba8UnormSrgb, + #[cfg(not(target_arch = "wasm32"))] + wgt::TextureFormat::Bgra8UnormSrgb, + ] + } else { + vec![ + wgt::TextureFormat::Rgba8Unorm, + #[cfg(not(target_arch = "wasm32"))] + wgt::TextureFormat::Bgra8Unorm, + ] + }; + if self + .shared + .private_caps + .contains(super::PrivateCapabilities::COLOR_BUFFER_HALF_FLOAT) + { + formats.push(wgt::TextureFormat::Rgba16Float) + } if surface.presentable { Some(crate::SurfaceCapabilities { - formats: if surface.supports_srgb() { - vec![ - wgt::TextureFormat::Rgba8UnormSrgb, - #[cfg(not(target_arch = "wasm32"))] - wgt::TextureFormat::Bgra8UnormSrgb, - ] - } else { - vec![ - wgt::TextureFormat::Rgba8Unorm, - #[cfg(not(target_arch = "wasm32"))] - wgt::TextureFormat::Bgra8Unorm, - ] - }, + formats, present_modes: vec![wgt::PresentMode::Fifo], //TODO composite_alpha_modes: vec![wgt::CompositeAlphaMode::Opaque], //TODO swap_chain_sizes: 2..=2,