MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / writeUniformBuffer

Function writeUniformBuffer

src/renderers/rendererUtils.ts:226–245  ·  view source on GitHub ↗
(device: GPUDevice, buffer: GPUBuffer, data: BufferSource)

Source from the content-addressed store, hash-verified

224 * - `queue.writeBuffer()` requires write size (and offsets) to be multiples of 4 bytes.
225 */
226export function writeUniformBuffer(device: GPUDevice, buffer: GPUBuffer, data: BufferSource): void {
227 const src =
228 data instanceof ArrayBuffer
229 ? { arrayBuffer: data, offset: 0, size: data.byteLength }
230 : { arrayBuffer: data.buffer, offset: data.byteOffset, size: data.byteLength };
231
232 if (src.size === 0) return;
233
234 if ((src.offset & 3) !== 0 || (src.size & 3) !== 0) {
235 throw new Error(
236 `writeUniformBuffer(data): data byteOffset (${src.offset}) and byteLength (${src.size}) must be multiples of 4 for queue.writeBuffer().`
237 );
238 }
239
240 if (src.size > buffer.size) {
241 throw new Error(`writeUniformBuffer(data): data byteLength (${src.size}) exceeds buffer.size (${buffer.size}).`);
242 }
243
244 device.queue.writeBuffer(buffer, 0, src.arrayBuffer, src.offset, src.size);
245}

Callers 15

writeVsUniformsFunction · 0.90
writeVsUniformsFunction · 0.90
prepareFunction · 0.90
prepareFunction · 0.90
prepareFunction · 0.90
writeVsUniformsFunction · 0.90
prepareFunction · 0.90
prepareFunction · 0.90
prepareFunction · 0.90
prepareFunction · 0.90
prepareFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected