-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Additional validation of texture copies #7935
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
base: trunk
Are you sure you want to change the base?
Conversation
* Copies must not overlap. * Copies of multisampled or depth/stencil formats must span the entire texture. * Move no-op for zero-size copies after parameter validation. Closes gfx-rs#2951 Fixes gfx-rs#7844
0b8f788
to
fa7961b
Compare
Sounds like we need to add more CTS tests. |
wgpu-core/src/command/transfer.rs
Outdated
src_texture.desc.format, | ||
destination, | ||
dst_texture.desc.format, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The format of the textures is the same since src = dst.
/// `validate_texture_copy_range`. | ||
/// | ||
/// [srtc]: https://gpuweb.github.io/gpuweb/#abstract-opdef-set-of-subresources-for-texture-copy | ||
pub(crate) fn validate_copy_within_same_texture<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fn is not allowing disjoint mip levels but should, per spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed. I'll also open a PR to add this to the CTS (it was noted as a TODO, but not implemented).
wgpu-core/src/command/transfer.rs
Outdated
buffer_layout: source.layout, | ||
size: hal_copy_size, | ||
}, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case shouldn't be allowed by validation (same for copyTextureToBuffer
and writeTexture
).
If texture.format is a depth-or-stencil format format:
texelCopyTextureInfo.aspect must refer to a single aspect of texture.format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we only need this case for copyTextureToTexture
.
fa7961b
to
04cd49f
Compare
In studying whether #2951 is still an issue, I identified some other texture validation that is missing. This adds it, and also fixes the issue where we skip parameter validation for zero-size copies.
I suspect that this may fix #7844 by rejecting an illegal operation before dx12 panics.I've also included a fix for #7844 that splits depth+stencil copies into two operations, although I'm not sure if this is the right fix -- it appears that metal does support a combined copy in copyTextureToTexture (but not in copyBufferToTexture), so maybe this should be pushed to the backends.Testing
Enables all the
copyTextureToTexture
CTS tests. However, the CTS isn't complete coverage of the validation logic I added. In particular, it doesn't cover the logic that allows copies among different aspects of the same texture. I'm not sure if that even makes sense (copying between depth and stencil?), or if it's just the spec being thorough, but I would welcome a suggestion of an interesting test to add here.Squash or Rebase? Squash
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry. Maybe it's worth one overall changelog entry mentioning this, the vertex/index buffer offset change, and any other added validation that gets added.