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