The copyTextureToBuffer() method of the GPUCommandEncoder interface encodes a command that copies data from a GPUTexture to a GPUBuffer.
copyTextureToBuffer(source, destination, copySize)
The following criteria must be met when calling copyTextureToBuffer(), otherwise a GPUValidationError is generated and the GPUCommandEncoder becomes invalid.
For the source:
For the destination:
-
destination.bytesPerRow is a multiple of 256. - The
destination.buffer's GPUBuffer.usage includes the GPUBufferUsage.COPY_DST flag.
commandEncoder.copyTextureToBuffer(
{
texture: sourceTexture,
},
{
buffer: destinationBuffer,
},
{
width: 16,
height: 16,
depthOrArrayLayers: 2,
},
);