mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-10-30 14:01:39 +00:00
Improve InvalidViewport error message (#2723)
This commit is contained in:
parent
75db572bf7
commit
9e3cd08e59
@ -87,8 +87,10 @@ pub enum RenderCommandError {
|
||||
MissingTextureUsage(#[from] MissingTextureUsageError),
|
||||
#[error(transparent)]
|
||||
PushConstants(#[from] PushConstantUploadError),
|
||||
#[error("Invalid Viewport parameters")]
|
||||
InvalidViewport,
|
||||
#[error("Viewport width {0} and/or height {1} are less than or equal to 0")]
|
||||
InvalidViewportDimension(f32, 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:?}")]
|
||||
InvalidScissorRect(Rect<u32>, wgt::Extent3d),
|
||||
#[error("Support for {0} is not implemented yet")]
|
||||
|
@ -1451,14 +1451,17 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
depth_max,
|
||||
} => {
|
||||
let scope = PassErrorScope::SetViewport;
|
||||
if rect.w <= 0.0
|
||||
|| rect.h <= 0.0
|
||||
|| depth_min < 0.0
|
||||
|| depth_min > 1.0
|
||||
|| depth_max < 0.0
|
||||
|| depth_max > 1.0
|
||||
{
|
||||
return Err(RenderCommandError::InvalidViewport).map_pass_err(scope);
|
||||
if rect.w <= 0.0 || rect.h <= 0.0 {
|
||||
return Err(RenderCommandError::InvalidViewportDimension(
|
||||
rect.w, rect.h,
|
||||
))
|
||||
.map_pass_err(scope);
|
||||
}
|
||||
if !(0.0..=1.0).contains(&depth_min) || !(0.0..=1.0).contains(&depth_max) {
|
||||
return Err(RenderCommandError::InvalidViewportDepth(
|
||||
depth_min, depth_max,
|
||||
))
|
||||
.map_pass_err(scope);
|
||||
}
|
||||
let r = hal::Rect {
|
||||
x: rect.x,
|
||||
|
Loading…
Reference in New Issue
Block a user