MCPcopy Create free account
hub / github.com/denoland/std / getRowPadding

Function getRowPadding

webgpu/row_padding.ts:35–51  ·  view source on GitHub ↗
(width: number)

Source from the content-addressed store, hash-verified

33 * @returns The padded and unpadded values
34 */
35export function getRowPadding(width: number): Padding {
36 // It is a WebGPU requirement that
37 // GPUImageCopyBuffer.layout.bytesPerRow % COPY_BYTES_PER_ROW_ALIGNMENT == 0
38 // So we calculate paddedBytesPerRow by rounding unpaddedBytesPerRow
39 // up to the next multiple of COPY_BYTES_PER_ROW_ALIGNMENT.
40
41 const unpaddedBytesPerRow = width * BYTES_PER_PIXEL;
42 const paddedBytesPerRowPadding = (COPY_BYTES_PER_ROW_ALIGNMENT -
43 (unpaddedBytesPerRow % COPY_BYTES_PER_ROW_ALIGNMENT)) %
44 COPY_BYTES_PER_ROW_ALIGNMENT;
45 const paddedBytesPerRow = unpaddedBytesPerRow + paddedBytesPerRowPadding;
46
47 return {
48 unpadded: unpaddedBytesPerRow,
49 padded: paddedBytesPerRow,
50 };
51}
52
53/**
54 * Creates a new buffer while removing any unnecessary empty bytes.

Callers 3

createCaptureFunction · 0.90
resliceBufferWithPaddingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected