diff --git a/wgpu-hal/src/dx11/adapter.rs b/wgpu-hal/src/dx11/adapter.rs index 576eb810f6..3bc531eaee 100644 --- a/wgpu-hal/src/dx11/adapter.rs +++ b/wgpu-hal/src/dx11/adapter.rs @@ -130,6 +130,7 @@ impl super::Adapter { if feature_level >= FL11_0 { downlevel |= wgt::DownlevelFlags::INDIRECT_EXECUTION; + downlevel |= wgt::DownlevelFlags::WEBGPU_TEXTURE_FORMAT_SUPPORT; features |= wgt::Features::TEXTURE_COMPRESSION_BC; } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 90f845813b..7a7b1b09a5 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -290,6 +290,8 @@ impl super::Adapter { extensions.contains("EXT_texture_filter_anisotropic"), ); + let is_ext_color_buffer_float_supported = extensions.contains("EXT_color_buffer_float"); + let mut features = wgt::Features::empty() | wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES | wgt::Features::CLEAR_TEXTURE @@ -500,6 +502,7 @@ impl super::Adapter { workarounds, shading_language_version, max_texture_size, + is_ext_color_buffer_float_supported, }), }, info: Self::make_info(vendor, renderer), @@ -619,6 +622,13 @@ impl crate::Adapter for super::Adapter { unfilterable | Tfc::COLOR_ATTACHMENT | Tfc::MULTISAMPLE | Tfc::MULTISAMPLE_RESOLVE; let filterable_renderable = filterable | renderable | Tfc::COLOR_ATTACHMENT_BLEND; let storage = Tfc::STORAGE | Tfc::STORAGE_READ_WRITE; + + let float_renderable = if self.shared.is_ext_color_buffer_float_supported { + Tfc::COLOR_ATTACHMENT | Tfc::COLOR_ATTACHMENT_BLEND + } else { + Tfc::empty() + }; + match format { Tf::R8Unorm => filterable_renderable, Tf::R8Snorm => filterable, @@ -628,37 +638,37 @@ impl crate::Adapter for super::Adapter { Tf::R16Sint => renderable, Tf::R16Unorm => empty, Tf::R16Snorm => empty, - Tf::R16Float => filterable, + Tf::R16Float => filterable | float_renderable, Tf::Rg8Unorm => filterable_renderable, Tf::Rg8Snorm => filterable, Tf::Rg8Uint => renderable, Tf::Rg8Sint => renderable, Tf::R32Uint => renderable | storage, Tf::R32Sint => renderable | storage, - Tf::R32Float => unfilterable | storage, + Tf::R32Float => unfilterable | storage | float_renderable, Tf::Rg16Uint => renderable, Tf::Rg16Sint => renderable, Tf::Rg16Unorm => empty, Tf::Rg16Snorm => empty, - Tf::Rg16Float => filterable, + Tf::Rg16Float => filterable | float_renderable, Tf::Rgba8Unorm | Tf::Rgba8UnormSrgb => filterable_renderable | storage, Tf::Bgra8Unorm | Tf::Bgra8UnormSrgb => filterable_renderable, Tf::Rgba8Snorm => filterable, Tf::Rgba8Uint => renderable | storage, Tf::Rgba8Sint => renderable | storage, Tf::Rgb10a2Unorm => filterable_renderable, - Tf::Rg11b10Float => filterable, + Tf::Rg11b10Float => filterable | float_renderable, Tf::Rg32Uint => renderable, Tf::Rg32Sint => renderable, - Tf::Rg32Float => unfilterable, + Tf::Rg32Float => unfilterable | float_renderable, Tf::Rgba16Uint => renderable | storage, Tf::Rgba16Sint => renderable | storage, Tf::Rgba16Unorm => empty, Tf::Rgba16Snorm => empty, - Tf::Rgba16Float => filterable | storage, + Tf::Rgba16Float => filterable | storage | float_renderable, Tf::Rgba32Uint => renderable | storage, Tf::Rgba32Sint => renderable | storage, - Tf::Rgba32Float => unfilterable | storage, + Tf::Rgba32Float => unfilterable | storage | float_renderable, Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 11f7aee704..469213752d 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -184,6 +184,7 @@ struct AdapterShared { workarounds: Workarounds, shading_language_version: naga::back::glsl::Version, max_texture_size: u32, + is_ext_color_buffer_float_supported: bool, } pub struct Adapter { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 3b09ce0cf9..f664a45437 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1027,6 +1027,10 @@ bitflags::bitflags! { /// /// GLES/WebGL don't support this. const DEPTH_TEXTURE_AND_BUFFER_COPIES = 1 << 13; + + /// Supports all the texture usages described in WebGPU. If this isn't supported, you + /// should call `get_texture_format_features` to get how you can use textures of a given format + const WEBGPU_TEXTURE_FORMAT_SUPPORT = 1 << 15; } }