This release is 13 versions behind 0.224.9 — the latest version of @std/webgpu. Jump to latest
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Works with
•JSR Score94%•This package works with Deno, BrowsersIt is unknown whether this package works with Bun


Downloads8/wk
•Published2 years ago (0.221.0)
UNSTABLE: Utilities for working with the Web GPU API
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { getRowPadding, resliceBufferWithPadding } from "./row_padding.ts"; import { assertEquals } from "jsr:/@std/assert@^0.221.0/assert-equals"; Deno.test("getRowPadding()", () => { const { unpadded, padded } = getRowPadding(64); assertEquals(unpadded, 256); assertEquals(padded, 256); }); Deno.test("getRowPadding() works for odd number smaller than COPY_BYTES_PER_ROW_ALIGNMENT", () => { const { unpadded, padded } = getRowPadding(5); assertEquals(unpadded, 20); assertEquals(padded, 256); }); Deno.test("getRowPadding() works for odd number larger than COPY_BYTES_PER_ROW_ALIGNMENT", () => { const { unpadded, padded } = getRowPadding(329); assertEquals(unpadded, 1316); assertEquals(padded, 1536); }); Deno.test("getRowPadding() works for even number smaller than COPY_BYTES_PER_ROW_ALIGNMENT", () => { const { unpadded, padded } = getRowPadding(4); assertEquals(unpadded, 16); assertEquals(padded, 256); }); Deno.test("getRowPadding() works for even number larger than COPY_BYTES_PER_ROW_ALIGNMENT", () => { const { unpadded, padded } = getRowPadding(4024); assertEquals(unpadded, 16096); assertEquals(padded, 16128); }); Deno.test("resliceBufferWithPadding()", () => { // deno-fmt-ignore const input = new Uint8Array([ 0, 255, 0, 255, 255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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