mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Loosen Viewport validation requirements to match the new specs (#7564)
This commit is contained in:
@@ -59,6 +59,8 @@ Naga now infers the correct binding layout when a resource appears only in an as
|
||||
|
||||
### Changes
|
||||
|
||||
- Loosen Viewport validation requirements to match the [new specs](https://github.com/gpuweb/gpuweb/pull/5025). By @ebbdrop in [#7564](https://github.com/gfx-rs/wgpu/pull/7564)
|
||||
|
||||
#### General
|
||||
|
||||
- Removed `MaintainBase` in favor of using `PollType`. By @waywardmonkeys in [#7508](https://github.com/gfx-rs/wgpu/pull/7508).
|
||||
|
||||
@@ -68,7 +68,7 @@ static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::ne
|
||||
renderpass.set_viewport(0.0, 0.0, -1.0, -1.0, 0.0, 1.0);
|
||||
drop(renderpass);
|
||||
},
|
||||
Some("viewport has invalid rect"),
|
||||
Some("less than zero"),
|
||||
);
|
||||
|
||||
// This is the actual interesting error condition. We've created
|
||||
|
||||
@@ -81,8 +81,10 @@ pub enum RenderCommandError {
|
||||
MissingTextureUsage(#[from] MissingTextureUsageError),
|
||||
#[error(transparent)]
|
||||
PushConstants(#[from] PushConstantUploadError),
|
||||
#[error("Viewport has invalid rect {0:?}; origin and/or size is less than or equal to 0, and/or is not contained in the render target {1:?}")]
|
||||
InvalidViewportRect(Rect<f32>, wgt::Extent3d),
|
||||
#[error("Viewport size {{ w: {w}, h: {h} }} greater than device's requested `max_texture_dimension_2d` limit {max}, or less than zero")]
|
||||
InvalidViewportRectSize { w: f32, h: f32, max: u32 },
|
||||
#[error("Viewport has invalid rect {rect:?} for device's requested `max_texture_dimension_2d` limit; Origin less than -2 * `max_texture_dimension_2d` ({min}), or rect extends past 2 * `max_texture_dimension_2d` - 1 ({max})")]
|
||||
InvalidViewportRectPosition { rect: Rect<f32>, min: f32, max: f32 },
|
||||
#[error("Viewport minDepth {0} and/or maxDepth {1} are not in [0, 1]")]
|
||||
InvalidViewportDepth(f32, f32),
|
||||
#[error("Scissor {0:?} is not contained in the render target {1:?}")]
|
||||
|
||||
@@ -2347,14 +2347,33 @@ fn set_viewport(
|
||||
depth_max: f32,
|
||||
) -> Result<(), RenderPassErrorInner> {
|
||||
api_log!("RenderPass::set_viewport {rect:?}");
|
||||
if rect.x < 0.0
|
||||
|| rect.y < 0.0
|
||||
|| rect.w <= 0.0
|
||||
|| rect.h <= 0.0
|
||||
|| rect.x + rect.w > state.info.extent.width as f32
|
||||
|| rect.y + rect.h > state.info.extent.height as f32
|
||||
|
||||
if rect.w < 0.0
|
||||
|| rect.h < 0.0
|
||||
|| rect.w > state.device.limits.max_texture_dimension_2d as f32
|
||||
|| rect.h > state.device.limits.max_texture_dimension_2d as f32
|
||||
{
|
||||
return Err(RenderCommandError::InvalidViewportRect(rect, state.info.extent).into());
|
||||
return Err(RenderCommandError::InvalidViewportRectSize {
|
||||
w: rect.w,
|
||||
h: rect.h,
|
||||
max: state.device.limits.max_texture_dimension_2d,
|
||||
}
|
||||
.into());
|
||||
}
|
||||
|
||||
let max_viewport_range = state.device.limits.max_texture_dimension_2d as f32 * 2.0;
|
||||
|
||||
if rect.x < -max_viewport_range
|
||||
|| rect.y < -max_viewport_range
|
||||
|| rect.x + rect.w > max_viewport_range - 1.0
|
||||
|| rect.y + rect.h > max_viewport_range - 1.0
|
||||
{
|
||||
return Err(RenderCommandError::InvalidViewportRectPosition {
|
||||
rect,
|
||||
min: -max_viewport_range,
|
||||
max: max_viewport_range - 1.0,
|
||||
}
|
||||
.into());
|
||||
}
|
||||
if !(0.0..=1.0).contains(&depth_min) || !(0.0..=1.0).contains(&depth_max) {
|
||||
return Err(RenderCommandError::InvalidViewportDepth(depth_min, depth_max).into());
|
||||
|
||||
Reference in New Issue
Block a user