pub(crate) fn validate_texture_buffer_copy<T>(
texture_copy_view: &TexelCopyTextureInfo<T>,
aspect: FormatAspects,
desc: &TextureDescriptor<(), Vec<TextureFormat>>,
layout: &TexelCopyBufferLayout,
aligned: bool,
) -> Result<(), TransferError>
Expand description
Validation for texture/buffer copies.
This implements the following checks from WebGPU’s validating texture buffer copy algorithm:
- The texture must not be multisampled.
- The copy must be from/to a single aspect of the texture.
- If
aligned
is true, the buffer offset must be aligned appropriately.
And implements the following check from WebGPU’s validating GPUTexelCopyBufferInfo algorithm:
- If
aligned
is true,bytesPerRow
must be a multiple of 256.
Note that the bytesPerRow
alignment check is enforced whenever
bytesPerRow
is specified, even if the transfer is not multiple rows and
bytesPerRow
could have been omitted.
The following steps in validating texture buffer copy are implemented elsewhere:
- Invocation of other validation algorithms.
- The texture usage (COPY_DST / COPY_SRC) check.
- The check for non-copyable depth/stencil formats. The caller must perform
this check using
validate_texture_copy_src_format
/validate_texture_copy_dst_format
before calling this function. This function will panic ifwgt::TextureFormat::block_copy_size
returnsNone
due to a non-copyable format.