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 GPUSamplerDescriptor valid… #3353

Merged
merged 3 commits into from
Jan 6, 2023

Conversation

James2022-rgb
Copy link
Contributor

@James2022-rgb James2022-rgb commented Jan 5, 2023

… usage for lodMinClamp and lodMaxClamp.

lodMinClamp must not be negative, and lodMaxClamp must be >= lodMinClamp

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis 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::SamplerDescriptor, it was possible to use values for lod_min_clamp and lod_max_clamp such that:

  • lod_min_clamp is negative
  • lod_max_clamp < lod_min_clamp

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

descriptor.lodMinClamp ≥ 0.
descriptor.lodMaxClamp ≥ descriptor.lodMinClamp.

This PR adds InvalidLodClamp to CreateSamplerError, inspired by the already-existing InvalidClamp, and uses that if the validation fails.

Testing
Tested locally.

… usage for `lodMinClamp` and `lodMaxClamp`.

`lodMinClamp` must not be negative, and `lodMaxClamp` must be >= `lodMinClamp`
@nical
Copy link
Contributor

nical commented Jan 6, 2023

Thanks! Almost good to go, but the CI is complaining about formatting so it looks like you need to cargo fmt the PR.

@James2022-rgb
Copy link
Contributor Author

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants