A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer below:

GPUCommandEncoder: copyBufferToBuffer() method - Web APIs

GPUCommandEncoder: copyBufferToBuffer() method

Limited availability

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The copyBufferToBuffer() method of the GPUCommandEncoder interface encodes a command that copies data from one GPUBuffer to another.

Syntax
copyBufferToBuffer(source, destination)
copyBufferToBuffer(source, destination, size)
copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)
Parameters
source

The GPUBuffer to copy from.

sourceOffset Optional

The offset, in bytes, into the source to begin copying from.

destination

The GPUBuffer to copy to.

destinationOffset Optional

The offset, in bytes, into the destination to begin copying to.

size Optional

The number of bytes to copy.

Note: The sourceOffset and destinationOffset can be omitted if you are copying part of the source buffer at a 0 offset in both the source and destination buffers. The sourceOffset, destinationOffset, and size can be omitted if you are copying the entire source buffer to the destination buffer.

Return value

None (Undefined).

Validation

The following criteria must be met when calling copyBufferToBuffer(), otherwise a GPUValidationError is generated and the GPUCommandEncoder becomes invalid:

Examples

In our basic compute demo, we use copyBufferToBuffer() to copy the contents of our outputBuffer to the stagingBuffer.

// …

// Create an output buffer to read GPU calculations to, and a staging buffer to be mapped for JavaScript access

const outputBuffer = device.createBuffer({
  size: BUFFER_SIZE,
  usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
});

const stagingBuffer = device.createBuffer({
  size: BUFFER_SIZE,
  usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST,
});

// …

// Create GPUCommandEncoder to encode commands to issue to the GPU
const commandEncoder = device.createCommandEncoder();

// …

// Copy output buffer to staging buffer
commandEncoder.copyBufferToBuffer(
  outputBuffer,
  0, // Source offset
  stagingBuffer,
  0, // Destination offset
  BUFFER_SIZE,
);

// Since we are copying the entire buffer, this can be shortened to
// commandEncoder.copyBufferToBuffer(outputBuffer, stagingBuffer);

// …
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4