Allow ArrayBuffer in StorageBuffer.write data type#8911
Merged
Conversation
…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.
Public API reportThis 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): voidInformational only — this never fails the build. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8910.
The
dataparameter ofStorageBuffer.writewas documented asArrayBufferView, but the underlyingGPUQueue.writeBufferaccepts aGPUAllowSharedBufferSource, so a plainArrayBufferis also valid input. The previous annotation caused confusion and spurious type errors for callers passing anArrayBuffer. WebGPU types are not part of the engine's public API surface, so the standard lib types are used rather than referencingGPUAllowSharedBufferSourcedirectly.Changes:
datatype fromArrayBufferViewtoArrayBufferView|ArrayBufferonStorageBuffer.writeand its internal WebGPU delegates.API Changes:
StorageBuffer.write(bufferOffset, data, dataOffset, size)—datatype widened fromArrayBufferViewtoArrayBufferView | ArrayBuffer. Non-breaking (a strict widening of accepted input).