Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small Bug Fixes #2843

Merged
merged 5 commits into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
45 changes: 22 additions & 23 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4975,36 +4975,35 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
);
}
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!(
Expand Down
5 changes: 3 additions & 2 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,14 +773,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
//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
Expand Down
36 changes: 29 additions & 7 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -634,7 +642,21 @@ impl crate::Adapter<super::Api> 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()
Expand All @@ -649,7 +671,7 @@ impl crate::Adapter<super::Api> 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,
Expand All @@ -661,7 +683,7 @@ impl crate::Adapter<super::Api> 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,
Expand All @@ -676,7 +698,7 @@ impl crate::Adapter<super::Api> 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,
Expand Down
5 changes: 4 additions & 1 deletion wgpu-hal/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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 {
Expand Down