mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Remove surface extent validation (and thus fix the annoying Requested size ... is outside of the supported range warning) (#4796)
* Remove surface extent validation * silence pnext vulkan validation warning which can happen on surface resize * remove old VUID-VkSwapchainCreateInfoKHR-imageExtent-01689 validation warning ignore * Validate surface against max texture size
This commit is contained in:
parent
418493239a
commit
8da4925948
@ -52,6 +52,7 @@ Previously, `DeviceExt::create_texture_with_data` only allowed data to be provid
|
|||||||
|
|
||||||
#### General
|
#### General
|
||||||
- Added `DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW` to know if `@builtin(vertex_index)` and `@builtin(instance_index)` will respect the `first_vertex` / `first_instance` in indirect calls. If this is not present, both will always start counting from 0. Currently enabled on all backends except DX12. By @cwfitzgerald in [#4722](https://github.com/gfx-rs/wgpu/pull/4722)
|
- Added `DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW` to know if `@builtin(vertex_index)` and `@builtin(instance_index)` will respect the `first_vertex` / `first_instance` in indirect calls. If this is not present, both will always start counting from 0. Currently enabled on all backends except DX12. By @cwfitzgerald in [#4722](https://github.com/gfx-rs/wgpu/pull/4722)
|
||||||
|
- No longer validate surfaces against their allowed extent range on configure. This caused warnings that were almost impossible to avoid. As before, the resulting behavior depends on the compositor. By @wumpf in [#????](https://github.com/gfx-rs/wgpu/pull/????)
|
||||||
|
|
||||||
#### OpenGL
|
#### OpenGL
|
||||||
- `@builtin(instance_index)` now properly reflects the range provided in the draw call instead of always counting from 0. By @cwfitzgerald in [#4722](https://github.com/gfx-rs/wgpu/pull/4722).
|
- `@builtin(instance_index)` now properly reflects the range provided in the draw call instead of always counting from 0. By @cwfitzgerald in [#4722](https://github.com/gfx-rs/wgpu/pull/4722).
|
||||||
|
|||||||
@ -1809,21 +1809,19 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
fn validate_surface_configuration(
|
fn validate_surface_configuration(
|
||||||
config: &mut hal::SurfaceConfiguration,
|
config: &mut hal::SurfaceConfiguration,
|
||||||
caps: &hal::SurfaceCapabilities,
|
caps: &hal::SurfaceCapabilities,
|
||||||
|
max_texture_dimension_2d: u32,
|
||||||
) -> Result<(), E> {
|
) -> Result<(), E> {
|
||||||
let width = config.extent.width;
|
let width = config.extent.width;
|
||||||
let height = config.extent.height;
|
let height = config.extent.height;
|
||||||
if width < caps.extents.start().width
|
|
||||||
|| width > caps.extents.end().width
|
if width > max_texture_dimension_2d || height > max_texture_dimension_2d {
|
||||||
|| height < caps.extents.start().height
|
return Err(E::TooLarge {
|
||||||
|| height > caps.extents.end().height
|
|
||||||
{
|
|
||||||
log::warn!(
|
|
||||||
"Requested size {}x{} is outside of the supported range: {:?}",
|
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
caps.extents
|
max_texture_dimension_2d,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if !caps.present_modes.contains(&config.present_mode) {
|
if !caps.present_modes.contains(&config.present_mode) {
|
||||||
let new_mode = 'b: loop {
|
let new_mode = 'b: loop {
|
||||||
// Automatic present mode checks.
|
// Automatic present mode checks.
|
||||||
@ -1997,7 +1995,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
view_formats: hal_view_formats,
|
view_formats: hal_view_formats,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(error) = validate_surface_configuration(&mut hal_config, &caps) {
|
if let Err(error) = validate_surface_configuration(
|
||||||
|
&mut hal_config,
|
||||||
|
&caps,
|
||||||
|
device.limits.max_texture_dimension_2d,
|
||||||
|
) {
|
||||||
break error;
|
break error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,12 @@ pub enum ConfigureSurfaceError {
|
|||||||
PreviousOutputExists,
|
PreviousOutputExists,
|
||||||
#[error("Both `Surface` width and height must be non-zero. Wait to recreate the `Surface` until the window has non-zero area.")]
|
#[error("Both `Surface` width and height must be non-zero. Wait to recreate the `Surface` until the window has non-zero area.")]
|
||||||
ZeroArea,
|
ZeroArea,
|
||||||
|
#[error("`Surface` width and height must be within the maximum supported texture size. Requested was ({width}, height), maximum extent is {max_texture_dimension_2d}.")]
|
||||||
|
TooLarge {
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
max_texture_dimension_2d: u32,
|
||||||
|
},
|
||||||
#[error("Surface does not support the adapter's queue family")]
|
#[error("Surface does not support the adapter's queue family")]
|
||||||
UnsupportedQueueFamily,
|
UnsupportedQueueFamily,
|
||||||
#[error("Requested format {requested:?} is not in list of supported formats: {available:?}")]
|
#[error("Requested format {requested:?} is not in list of supported formats: {available:?}")]
|
||||||
|
|||||||
@ -626,16 +626,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
|||||||
// we currently use a flip effect which supports 2..=16 buffers
|
// we currently use a flip effect which supports 2..=16 buffers
|
||||||
swap_chain_sizes: 2..=16,
|
swap_chain_sizes: 2..=16,
|
||||||
current_extent,
|
current_extent,
|
||||||
// TODO: figure out the exact bounds
|
|
||||||
extents: wgt::Extent3d {
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
}..=wgt::Extent3d {
|
|
||||||
width: 4096,
|
|
||||||
height: 4096,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
},
|
|
||||||
usage: crate::TextureUses::COLOR_TARGET
|
usage: crate::TextureUses::COLOR_TARGET
|
||||||
| crate::TextureUses::COPY_SRC
|
| crate::TextureUses::COPY_SRC
|
||||||
| crate::TextureUses::COPY_DST,
|
| crate::TextureUses::COPY_DST,
|
||||||
|
|||||||
@ -798,7 +798,6 @@ impl super::Adapter {
|
|||||||
workarounds,
|
workarounds,
|
||||||
features,
|
features,
|
||||||
shading_language_version,
|
shading_language_version,
|
||||||
max_texture_size,
|
|
||||||
next_shader_id: Default::default(),
|
next_shader_id: Default::default(),
|
||||||
program_cache: Default::default(),
|
program_cache: Default::default(),
|
||||||
es: es_ver.is_some(),
|
es: es_ver.is_some(),
|
||||||
@ -1145,15 +1144,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
|||||||
composite_alpha_modes: vec![wgt::CompositeAlphaMode::Opaque], //TODO
|
composite_alpha_modes: vec![wgt::CompositeAlphaMode::Opaque], //TODO
|
||||||
swap_chain_sizes: 2..=2,
|
swap_chain_sizes: 2..=2,
|
||||||
current_extent: None,
|
current_extent: None,
|
||||||
extents: wgt::Extent3d {
|
|
||||||
width: 4,
|
|
||||||
height: 4,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
}..=wgt::Extent3d {
|
|
||||||
width: self.shared.max_texture_size,
|
|
||||||
height: self.shared.max_texture_size,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
},
|
|
||||||
usage: crate::TextureUses::COLOR_TARGET,
|
usage: crate::TextureUses::COLOR_TARGET,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -249,7 +249,6 @@ struct AdapterShared {
|
|||||||
features: wgt::Features,
|
features: wgt::Features,
|
||||||
workarounds: Workarounds,
|
workarounds: Workarounds,
|
||||||
shading_language_version: naga::back::glsl::Version,
|
shading_language_version: naga::back::glsl::Version,
|
||||||
max_texture_size: u32,
|
|
||||||
next_shader_id: AtomicU32,
|
next_shader_id: AtomicU32,
|
||||||
program_cache: Mutex<ProgramCache>,
|
program_cache: Mutex<ProgramCache>,
|
||||||
es: bool,
|
es: bool,
|
||||||
|
|||||||
@ -882,11 +882,6 @@ pub struct SurfaceCapabilities {
|
|||||||
/// Current extent of the surface, if known.
|
/// Current extent of the surface, if known.
|
||||||
pub current_extent: Option<wgt::Extent3d>,
|
pub current_extent: Option<wgt::Extent3d>,
|
||||||
|
|
||||||
/// Range of supported extents.
|
|
||||||
///
|
|
||||||
/// `current_extent` must be inside this range.
|
|
||||||
pub extents: RangeInclusive<wgt::Extent3d>,
|
|
||||||
|
|
||||||
/// Supported texture usage flags.
|
/// Supported texture usage flags.
|
||||||
///
|
///
|
||||||
/// Must have at least `TextureUses::COLOR_TARGET`
|
/// Must have at least `TextureUses::COLOR_TARGET`
|
||||||
|
|||||||
@ -339,15 +339,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
|||||||
],
|
],
|
||||||
|
|
||||||
current_extent,
|
current_extent,
|
||||||
extents: wgt::Extent3d {
|
|
||||||
width: 4,
|
|
||||||
height: 4,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
}..=wgt::Extent3d {
|
|
||||||
width: pc.max_texture_size as u32,
|
|
||||||
height: pc.max_texture_size as u32,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
},
|
|
||||||
usage: crate::TextureUses::COLOR_TARGET | crate::TextureUses::COPY_DST, //TODO: expose more
|
usage: crate::TextureUses::COLOR_TARGET | crate::TextureUses::COPY_DST, //TODO: expose more
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1659,18 +1659,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let min_extent = wgt::Extent3d {
|
|
||||||
width: caps.min_image_extent.width,
|
|
||||||
height: caps.min_image_extent.height,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
let max_extent = wgt::Extent3d {
|
|
||||||
width: caps.max_image_extent.width,
|
|
||||||
height: caps.max_image_extent.height,
|
|
||||||
depth_or_array_layers: caps.max_image_array_layers,
|
|
||||||
};
|
|
||||||
|
|
||||||
let raw_present_modes = {
|
let raw_present_modes = {
|
||||||
profiling::scope!("vkGetPhysicalDeviceSurfacePresentModesKHR");
|
profiling::scope!("vkGetPhysicalDeviceSurfacePresentModesKHR");
|
||||||
match unsafe {
|
match unsafe {
|
||||||
@ -1709,7 +1697,6 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
|||||||
formats,
|
formats,
|
||||||
swap_chain_sizes: caps.min_image_count..=max_image_count,
|
swap_chain_sizes: caps.min_image_count..=max_image_count,
|
||||||
current_extent,
|
current_extent,
|
||||||
extents: min_extent..=max_extent,
|
|
||||||
usage: conv::map_vk_image_usage(caps.supported_usage_flags),
|
usage: conv::map_vk_image_usage(caps.supported_usage_flags),
|
||||||
present_modes: raw_present_modes
|
present_modes: raw_present_modes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
@ -41,10 +41,11 @@ unsafe extern "system" fn debug_utils_messenger_callback(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Silence Vulkan Validation error "VUID-VkSwapchainCreateInfoKHR-imageExtent-01274"
|
// Silence Vulkan Validation error "VUID-VkSwapchainCreateInfoKHR-pNext-07781"
|
||||||
// - it's a false positive due to the inherent racy-ness of surface resizing
|
// This happens when a surface is configured with a size outside the allowed extent.
|
||||||
const VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274: i32 = 0x7cd0911d;
|
// It's s false positive due to the inherent racy-ness of surface resizing.
|
||||||
if cd.message_id_number == VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274 {
|
const VUID_VKSWAPCHAINCREATEINFOKHR_PNEXT_07781: i32 = 0x4c8929c1;
|
||||||
|
if cd.message_id_number == VUID_VKSWAPCHAINCREATEINFOKHR_PNEXT_07781 {
|
||||||
return vk::FALSE;
|
return vk::FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user