diff --git a/CHANGELOG.md b/CHANGELOG.md index 72bdf40338..d90dec07e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,18 @@ Bottom level categories: ## Unreleased +## wgpu-0.13.1 (2022-07-02) + +### Bug Fixes + +#### General +- Fix out of bounds access when surface texture is written to by multiple command buffers by @cwfitzgerald in [#2843](https://github.com/gfx-rs/wgpu/pull/2843) + +#### GLES + +- AutoNoVSync now correctly falls back to Fifo by @simbleau in [#2842](https://github.com/gfx-rs/wgpu/pull/2842) +- Fix GL_EXT_color_buffer_float detection on native by @cwfitzgerald in [#2843](https://github.com/gfx-rs/wgpu/pull/2843) + ## wgpu-0.13 (2022-06-30) ### Major Changes @@ -237,7 +249,7 @@ DeviceDescriptor { #### DX11 -- Dx11 Backend by @cwfitzgerald in [#2443](https://github.com/gfx-rs/wgpu/pull/2443) +- Skeleton of a DX11 backend - not working yet by @cwfitzgerald in [#2443](https://github.com/gfx-rs/wgpu/pull/2443) #### Hal @@ -289,7 +301,6 @@ DeviceDescriptor { #### General -- AutoNoVSync now correctly falls back to Fifo @simbleau in [#2842](https://github.com/gfx-rs/wgpu/pull/2842) - Fix trac(y/ing) compile issue by @cwfitzgerald in [#2333](https://github.com/gfx-rs/wgpu/pull/2333) - Improve detection and validation of cubemap views by @kvark in [#2331](https://github.com/gfx-rs/wgpu/pull/2331) - Don't create array layer trackers for 3D textures. by @ElectronicRU in [#2348](https://github.com/gfx-rs/wgpu/pull/2348) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 59a7460d76..cf95f61b8b 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -4975,36 +4975,35 @@ impl Global { ); } if !caps.present_modes.contains(&config.present_mode) { - let new_mode = loop { + let new_mode = 'b: loop { // Automatic present mode checks. // // The "Automatic" modes are never supported by the backends. - match config.present_mode { + let fallbacks = match config.present_mode { wgt::PresentMode::AutoVsync => { - if caps.present_modes.contains(&wgt::PresentMode::FifoRelaxed) { - break wgt::PresentMode::FifoRelaxed; - } - if caps.present_modes.contains(&wgt::PresentMode::Fifo) { - break wgt::PresentMode::Fifo; - } + &[wgt::PresentMode::FifoRelaxed, wgt::PresentMode::Fifo][..] } - wgt::PresentMode::AutoNoVsync => { - if caps.present_modes.contains(&wgt::PresentMode::Immediate) { - break wgt::PresentMode::Immediate; - } - if caps.present_modes.contains(&wgt::PresentMode::Mailbox) { - break wgt::PresentMode::Mailbox; - } - if caps.present_modes.contains(&wgt::PresentMode::Fifo) { - break wgt::PresentMode::Fifo; - } + // Always end in FIFO to make sure it's always supported + wgt::PresentMode::AutoNoVsync => &[ + wgt::PresentMode::Immediate, + wgt::PresentMode::Mailbox, + wgt::PresentMode::Fifo, + ][..], + _ => { + return Err(E::UnsupportedPresentMode { + requested: config.present_mode, + available: caps.present_modes.clone(), + }); + } + }; + + for &fallback in fallbacks { + if caps.present_modes.contains(&fallback) { + break 'b fallback; } - _ => {} } - return Err(E::UnsupportedPresentMode { - requested: config.present_mode, - available: caps.present_modes.clone(), - }); + + unreachable!("Fallback system failed to choose present mode. This is a bug. Mode: {:?}, Options: {:?}", config.present_mode, &caps.present_modes); }; log::info!( diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 3be62ef2d3..4bfcd3fa28 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -773,14 +773,15 @@ impl Global { //Note: locking the trackers has to be done after the storages let mut trackers = device.trackers.lock(); - used_surface_textures.set_size(texture_guard.len()); - //TODO: if multiple command buffers are submitted, we can re-use the last // native command buffer of the previous chain instead of always creating // a temporary one, since the chains are not finished. // finish all the command buffers first for &cmb_id in command_buffer_ids { + // we reset the used surface textures every time we use it, so make sure to set_size on it. + used_surface_textures.set_size(texture_guard.len()); + #[allow(unused_mut)] let mut cmdbuf = match hub .command_buffers diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 19e8c2b5b7..14beea6dac 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -300,8 +300,6 @@ impl super::Adapter { !(cfg!(target_arch = "wasm32") || is_angle), ); - 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 @@ -380,6 +378,17 @@ impl super::Adapter { super::PrivateCapabilities::GET_BUFFER_SUB_DATA, cfg!(target_arch = "wasm32"), ); + let color_buffer_float = extensions.contains("GL_EXT_color_buffer_float") + || extensions.contains("EXT_color_buffer_float"); + let color_buffer_half_float = extensions.contains("GL_EXT_color_buffer_half_float"); + private_caps.set( + super::PrivateCapabilities::COLOR_BUFFER_HALF_FLOAT, + color_buffer_half_float || color_buffer_float, + ); + private_caps.set( + super::PrivateCapabilities::COLOR_BUFFER_FLOAT, + color_buffer_float, + ); let max_texture_size = gl.get_parameter_i32(glow::MAX_TEXTURE_SIZE) as u32; let max_texture_3d_size = gl.get_parameter_i32(glow::MAX_3D_TEXTURE_SIZE) as u32; @@ -513,7 +522,6 @@ impl super::Adapter { workarounds, shading_language_version, max_texture_size, - is_ext_color_buffer_float_supported, }), }, info: Self::make_info(vendor, renderer), @@ -634,7 +642,21 @@ impl crate::Adapter for super::Adapter { 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 { + let half_float_renderable = if self + .shared + .private_caps + .contains(super::PrivateCapabilities::COLOR_BUFFER_HALF_FLOAT) + { + Tfc::COLOR_ATTACHMENT | Tfc::COLOR_ATTACHMENT_BLEND + } else { + Tfc::empty() + }; + + let float_renderable = if self + .shared + .private_caps + .contains(super::PrivateCapabilities::COLOR_BUFFER_FLOAT) + { Tfc::COLOR_ATTACHMENT | Tfc::COLOR_ATTACHMENT_BLEND } else { Tfc::empty() @@ -649,7 +671,7 @@ impl crate::Adapter for super::Adapter { Tf::R16Sint => renderable, Tf::R16Unorm => empty, Tf::R16Snorm => empty, - Tf::R16Float => filterable | float_renderable, + Tf::R16Float => filterable | half_float_renderable, Tf::Rg8Unorm => filterable_renderable, Tf::Rg8Snorm => filterable, Tf::Rg8Uint => renderable, @@ -661,7 +683,7 @@ impl crate::Adapter for super::Adapter { Tf::Rg16Sint => renderable, Tf::Rg16Unorm => empty, Tf::Rg16Snorm => empty, - Tf::Rg16Float => filterable | float_renderable, + Tf::Rg16Float => filterable | half_float_renderable, Tf::Rgba8Unorm | Tf::Rgba8UnormSrgb => filterable_renderable | storage, Tf::Bgra8Unorm | Tf::Bgra8UnormSrgb => filterable_renderable, Tf::Rgba8Snorm => filterable, @@ -676,7 +698,7 @@ impl crate::Adapter for super::Adapter { Tf::Rgba16Sint => renderable | storage, Tf::Rgba16Unorm => empty, Tf::Rgba16Snorm => empty, - Tf::Rgba16Float => filterable | storage | float_renderable, + Tf::Rgba16Float => filterable | storage | half_float_renderable, Tf::Rgba32Uint => renderable | storage, Tf::Rgba32Sint => renderable | storage, Tf::Rgba32Float => unfilterable | storage | float_renderable, diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index ec0d39fc19..69c6168c48 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -138,6 +138,10 @@ bitflags::bitflags! { const CAN_DISABLE_DRAW_BUFFER = 1 << 6; /// Supports `glGetBufferSubData` const GET_BUFFER_SUB_DATA = 1 << 7; + /// Supports `f16` color buffers + const COLOR_BUFFER_HALF_FLOAT = 1 << 8; + /// Supports `f11/f10` and `f32` color buffers + const COLOR_BUFFER_FLOAT = 1 << 9; } } @@ -184,7 +188,6 @@ 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 {