Skip to content

Commit cee9ad6

Browse files
authored
Add GPUComandEncoder.fillBuffer() (#2208)
Add GPUComandEncoder.fillBuffer() (#2208) Fixes #1968. In the future, we can add a 4th parameter, `value`, of type `octet` or `byte`. For now, though, the group seems to have just agreed on zeroing, rather than filling with a particular byte. There are two commits in this PR, one that requires `GPUBufferUsage.STORAGE` on the buffer, and a second that relaxes this requirement because of #1968 (comment).
1 parent 09a4f64 commit cee9ad6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

spec/index.bs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5527,6 +5527,11 @@ interface GPUCommandEncoder {
55275527
GPUImageCopyTexture destination,
55285528
GPUExtent3D copySize);
55295529

5530+
undefined fillBuffer(
5531+
GPUBuffer destination,
5532+
GPUSize64 destinationOffset,
5533+
GPUSize64 size);
5534+
55305535
undefined pushDebugGroup(USVString groupLabel);
55315536
undefined popDebugGroup();
55325537
undefined insertDebugMarker(USVString markerLabel);
@@ -5982,6 +5987,38 @@ dictionary GPUImageCopyExternalImage {
59825987
</div>
59835988
</dl>
59845989

5990+
### Buffer Fills ### {#buffer-fills}
5991+
5992+
<dl dfn-type=method dfn-for=GPUCommandEncoder>
5993+
: <dfn>fillBuffer(destination, destinationOffset, size)</dfn>
5994+
::
5995+
Encode a command into the {{GPUCommandEncoder}} that fills a sub-region of a
5996+
{{GPUBuffer}} with zeros.
5997+
5998+
<div algorithm=GPUCommandEncoder.fillBuffer>
5999+
**Called on:** {{GPUCommandEncoder}} |this|.
6000+
6001+
**Arguments:**
6002+
<pre class=argumentdef for="GPUCommandEncoder/fillBuffer(destination, destinationOffset, size)">
6003+
|destination|: The {{GPUBuffer}} to write to.
6004+
|destinationOffset|: Offset in bytes into |destination| to place the data.
6005+
|size|: Bytes to copy.
6006+
</pre>
6007+
6008+
**Returns:** {{undefined}}
6009+
6010+
If any of the following conditions are unsatisfied, generate a validation error and stop.
6011+
<div class=validusage>
6012+
- |this|.{{GPUCommandEncoder/[[state]]}} is {{encoder state/open}}.
6013+
- |destination| is [$valid to use with$] |this|.
6014+
- |destination|.{{GPUBuffer/[[usage]]}} contains {{GPUBufferUsage/COPY_DST}}.
6015+
- |size| is a multiple of 4.
6016+
- |destinationOffset| is a multiple of 4.
6017+
- |destination|.{{GPUBuffer/[[size]]}} is greater than or equal to (|destinationOffset| + |size|).
6018+
</div>
6019+
</div>
6020+
</dl>
6021+
59856022
### Image Copies ### {#image-copies}
59866023

59876024
WebGPU provides {{GPUCommandEncoder/copyBufferToTexture()}} for buffer-to-texture copies and

0 commit comments

Comments
 (0)