Function validate_texture_buffer_copy

Source
pub(crate) fn validate_texture_buffer_copy<T>(
    texture_copy_view: &TexelCopyTextureInfo<T>,
    aspect: FormatAspects,
    desc: &TextureDescriptor<(), Vec<TextureFormat>>,
    offset: BufferAddress,
    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.

The following steps in the algorithm 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 if wgt::TextureFormat::block_copy_size returns None due to a non-copyable format.