Skip to content

Commit 1e1e0c4

Browse files
Editorial review: Update docs for Chrome 137 WebGPU additions (#39732)
* Update docs for Chrome 137 WebGPU additions * Fix nit * Fixes for hamishwillee review
1 parent e89cf8c commit 1e1e0c4

File tree

2 files changed

+15
-7
lines changed
  • files/en-us/web/api

2 files changed

+15
-7
lines changed

files/en-us/web/api/gpucommandencoder/copybuffertobuffer/index.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,27 @@ The **`copyBufferToBuffer()`** method of the
1616
## Syntax
1717

1818
```js-nolint
19+
copyBufferToBuffer(source, destination)
20+
copyBufferToBuffer(source, destination, size)
1921
copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)
2022
```
2123

2224
### Parameters
2325

2426
- `source`
2527
- : The {{domxref("GPUBuffer")}} to copy from.
26-
- `sourceOffset`
28+
- `sourceOffset` {{optional_inline}}
2729
- : The offset, in bytes, into the `source` to begin copying from.
2830
- `destination`
2931
- : The {{domxref("GPUBuffer")}} to copy to.
30-
- `destinationOffset`
32+
- `destinationOffset` {{optional_inline}}
3133
- : The offset, in bytes, into the `destination` to begin copying to.
32-
- `size`
34+
- `size` {{optional_inline}}
3335
- : The number of bytes to copy.
3436

37+
> [!NOTE]
38+
> 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.
39+
3540
### Return value
3641

3742
None ({{jsxref("Undefined")}}).
@@ -49,14 +54,14 @@ The following criteria must be met when calling **`copyBufferToBuffer()`**, othe
4954

5055
## Examples
5156

52-
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`.
57+
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`.
5358

5459
```js
5560
//
5661

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

59-
const output = device.createBuffer({
64+
const outputBuffer = device.createBuffer({
6065
size: BUFFER_SIZE,
6166
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
6267
});
@@ -75,13 +80,16 @@ const commandEncoder = device.createCommandEncoder();
7580

7681
// Copy output buffer to staging buffer
7782
commandEncoder.copyBufferToBuffer(
78-
output,
83+
outputBuffer,
7984
0, // Source offset
8085
stagingBuffer,
8186
0, // Destination offset
8287
BUFFER_SIZE,
8388
);
8489

90+
// Since we are copying the entire buffer, this can be shortened to
91+
// commandEncoder.copyBufferToBuffer(outputBuffer, stagingBuffer);
92+
8593
//
8694
```
8795

files/en-us/web/api/gpudevice/createbindgroup/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ createBindGroup(descriptor)
3232
- `GPUBufferBinding` (which wraps a {{domxref("GPUBuffer")}}; see [GPUBufferBinding objects](#gpubufferbinding_objects) for a definition)
3333
- {{domxref("GPUExternalTexture")}}
3434
- {{domxref("GPUSampler")}}
35-
- {{domxref("GPUTextureView")}}
35+
- {{domxref("GPUTextureView")}}; can be used in place of a `GPUExternalTexture` provided it is compatible (a 2D format with a single subresource, that is, [`dimension: "2d"`](/en-US/docs/Web/API/GPUTexture/createView#dimension)).
3636
- `label` {{optional_inline}}
3737
- : A string providing a label that can be used to identify the object, for example in {{domxref("GPUError")}} messages or console warnings.
3838
- `layout`

0 commit comments

Comments
 (0)