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

Fix calculation/validation of layer/mip ranges in create_texture_view #2955

Merged
merged 3 commits into from
Aug 14, 2022

Conversation

nical
Copy link
Contributor

@nical nical commented Aug 11, 2022

Back with some more validation fixes.

Checklist

  • Run cargo clippy.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections

https://bugzilla.mozilla.org/show_bug.cgi?id=1780057

Description

The previous code was doing "selector.layers = base_layer .. count" instead of "base_layer .. base_layer + count" which looked dubious. Same thing for the mip range. It was also not taking the base layer count when in requested_layer_count when the texture was not a texture array which led to invalid ranges and underflow when asking for a non-zero base layer with a (non-array) 2d texture.

The fix consists in:

  • writing the ranges as base .. base + count
  • always taking the provided base layer into account in the requested layer count even where it doesn't make sense (since it will ensure validation catches the error).

Testing

None

@nical
Copy link
Contributor Author

nical commented Aug 11, 2022

Added a commit that checks for integer overflow because the fuzzer told me I had to.

@nical nical force-pushed the createtexview-ranges branch 3 times, most recently from 10f3ced to 8f9c059 Compare August 12, 2022 10:17
…texture_view.

The previous code was doing "selector.layers = base_layer .. count" instead of "base_layer .. base_layer + count" which looked dubious. Same thing for the mip range. It was also not taking the base layer count when in requested_layer_count when the texture was not a texture array which led to invalid ranges and underflow when asking for a non-zero base layer with a (non-array) 2d texture.
@cwfitzgerald cwfitzgerald enabled auto-merge (squash) August 13, 2022 23:50
@cwfitzgerald cwfitzgerald merged commit 6e99cd3 into gfx-rs:master Aug 14, 2022
@nical nical deleted the createtexview-ranges branch August 14, 2022 16:36
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.

2 participants