Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix nit
  • Loading branch information
chrisdavidmills committed Jun 2, 2025
commit df2c2209ff3ef67fdacf76b63e149943f04cacdf
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ The following criteria must be met when calling **`copyBufferToBuffer()`**, othe

## Examples

In our [basic compute demo](https://mdn.github.io/dom-examples/webgpu-compute-demo/), we use `copyBufferToBuffer()` to copy the contents of our `output` buffer to the `stagingBuffer`.
In our [basic compute demo](https://mdn.github.io/dom-examples/webgpu-compute-demo/), we use `copyBufferToBuffer()` to copy the contents of our `outputBuffer` to the `stagingBuffer`.

```js
// …

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

const output = device.createBuffer({
const outputBuffer = device.createBuffer({
size: BUFFER_SIZE,
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
});
Expand All @@ -79,15 +79,15 @@ const commandEncoder = device.createCommandEncoder();

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

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

// …
```
Expand Down