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

Add validation in accordance with WebGPU setViewport valid usage fo… #4058

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

James2022-rgb
Copy link
Contributor

@James2022-rgb James2022-rgb commented Aug 15, 2023

…r x, y and this.[[attachment_size]].

x and y must not be negative, and the rect must be contained in the render target.

Checklist

  • Run cargo clippy.
  • Run cargo clippy --target wasm32-unknown-unknown if applicable.
    Done just in case, with --feature gles.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Description
For wgpu::RenderPass::set_viewport, it was possible to use values such that:

  • x and/or y is negative
  • the rect is not contained in the render target.

both of which are in violation of the valid usage defined for setViewport in the WebGPU spec:

x ≥ 0
y ≥ 0
x + width ≤ this.[[[attachment_size]]].width
y + height ≤ this.[[[attachment_size]]].height

This PR renames RenderCommandError::InvalidViewportDimension to InvalidViewportRect and adds render target extent to it, in the same spirit as InvalidScissorRect (which has similar valid usage regarding render target extent).

Testing
Tested locally.

…r `x`, `y` and `this.[[attachment_size]]`.

`x` and `y` must not be negative, and the rect must be contained in the render target.
@Wumpf Wumpf added the area: validation Issues related to validation, diagnostics, and error handling label Aug 15, 2023
@Wumpf Wumpf added this to the WebGPU Specification V1 milestone Aug 15, 2023
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice and clean, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants