Skip to content

Allow ArrayBuffer in StorageBuffer.write data type#8911

Merged
mvaligursky merged 1 commit into
mainfrom
mv-storage-buffer-write-doc
Jun 16, 2026
Merged

Allow ArrayBuffer in StorageBuffer.write data type#8911
mvaligursky merged 1 commit into
mainfrom
mv-storage-buffer-write-doc

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

Fixes #8910.

The data parameter of StorageBuffer.write was documented as ArrayBufferView, but the underlying GPUQueue.writeBuffer accepts a GPUAllowSharedBufferSource, so a plain ArrayBuffer is also valid input. The previous annotation caused confusion and spurious type errors for callers passing an ArrayBuffer. WebGPU types are not part of the engine's public API surface, so the standard lib types are used rather than referencing GPUAllowSharedBufferSource directly.

Changes:

  • Widen the JSDoc data type from ArrayBufferView to ArrayBufferView|ArrayBuffer on StorageBuffer.write and its internal WebGPU delegates.

API Changes:

  • StorageBuffer.write(bufferOffset, data, dataOffset, size)data type widened from ArrayBufferView to ArrayBufferView | ArrayBuffer. Non-breaking (a strict widening of accepted input).

…8910)

The `data` parameter of StorageBuffer.write (and the WebGPU impl it delegates
to) was documented as `ArrayBufferView`, but the underlying
GPUQueue.writeBuffer accepts a GPUAllowSharedBufferSource, so a plain
ArrayBuffer is also valid. Widen the JSDoc type to `ArrayBufferView|ArrayBuffer`
to match actual behavior. WebGPU types are not part of the public API, so the
standard lib types are used rather than GPUAllowSharedBufferSource directly.
@github-actions

Copy link
Copy Markdown

Public API report

This PR changes the public API surface (+1 / −1), per the docs' rules (@ignore / @Private / undocumented are excluded).

Show API diff
-StorageBuffer.write(bufferOffset: number, data: ArrayBufferView<ArrayBufferLike>, dataOffset: number, size: number): void
+StorageBuffer.write(bufferOffset: number, data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>, dataOffset: number, size: number): void

Informational only — this never fails the build.

@mvaligursky mvaligursky merged commit 3cd5c08 into main Jun 16, 2026
9 checks passed
@mvaligursky mvaligursky deleted the mv-storage-buffer-write-doc branch June 16, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There is an issue when passing typed arrays to the writeBuffer function of pc.StorageBuffer.

1 participant