Skip to content

Commit

Permalink
Deploying to gh-pages from @ 68ea652 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jun 7, 2024
1 parent cae7142 commit 2cc23db
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 14 deletions.
4 changes: 2 additions & 2 deletions dist/1.x/webgpu-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/1.x/webgpu-utils.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/1.x/webgpu-utils.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/1.x/webgpu-utils.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/1.x/webgpu-utils.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/1.x/webgpu-utils.module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!-- this file is auto-generated from README.md. Do not edited directly -->
<!--
@license webgpu-utils 1.8.0 Copyright (c) 2023, Gregg Tavares All Rights Reserved.
@license webgpu-utils 1.8.1 Copyright (c) 2023, Gregg Tavares All Rights Reserved.
Available via the MIT license.
see: http://github.com/greggman/webgpu-utils for details
-->
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webgpu-utils",
"version": "1.8.0",
"version": "1.8.1",
"description": "webgpu utilities",
"main": "dist/1.x/webgpu-utils.module.js",
"module": "dist/1.x/webgpu-utils.module.js",
Expand Down
2 changes: 1 addition & 1 deletion src/texture-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function copySourcesToTexture(
if (texture.dimension === '3d') {
tempTexture = tempTexture ?? device.createTexture({
format: texture.format,
usage: texture.usage,
usage: texture.usage | GPUTextureUsage.COPY_SRC,
size: [texture.width, texture.height, 1],
});
dstTexture = tempTexture;
Expand Down
29 changes: 28 additions & 1 deletion test/tests/texture-utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createTextureFromSources,
createTextureFromImage,
} from '../../dist/1.x/webgpu-utils.module.js';
import { assertArrayEqual, assertArrayEqualApproximately, assertEqual } from '../assert.js';
import { assertArrayEqual, assertArrayEqualApproximately, assertEqual, assertFalsy } from '../assert.js';
import { readTextureUnpadded, testWithDevice, testWithDeviceAndDocument } from '../webgpu.js';

// prevent global document
Expand Down Expand Up @@ -142,6 +142,33 @@ describe('texture-utils tests', () => {
assertArrayEqualApproximately(result, [255, 0, 0, 255, 0, 0, 255, 255], 0);
}));

it('canc create 3D texture from canvases without COPY_SRC', testWithDeviceAndDocument(async (device, document) => {
const createCanvas = color => {
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
const ctx = canvas.getContext('2d');
ctx.fillStyle = color;
ctx.fillRect(0, 0, 1, 1);
return canvas;
};
const canvases = [
createCanvas('#f00'),
createCanvas('#00f'),
];

createTextureFromSources(
device,
canvases,
{
usage: GPUTextureUsage.TEXTURE_BINDING |
GPUTextureUsage.RENDER_ATTACHMENT |
GPUTextureUsage.COPY_DST,
dimension: '3d',
}
);
}));

it('creates texture from image url with mips', testWithDevice(async device => {
const dataUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAAXNSR0IArs4c6QAAACJJREFUGFddibENAAAMgvD/o2l07AIJBBRAUpUv2LkzkR8OvcEL/bJgfmEAAAAASUVORK5CYII=';
const texture = await createTextureFromImage(
Expand Down

0 comments on commit 2cc23db

Please sign in to comment.