Improve InvalidViewport error message (#2723)

This commit is contained in:
Jinlei Li 2022-06-03 13:54:09 +08:00 committed by GitHub
parent 75db572bf7
commit 9e3cd08e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -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")]

View File

@ -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,