(width: number)
| 33 | * @returns The padded and unpadded values |
| 34 | */ |
| 35 | export 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. |
no outgoing calls
no test coverage detected