-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpu: Don’t allocate an atlas texture that is bigger than the device l…
…imits. We still don’t check if the actual memory allocation failed, though. Also check against the maximum buffer size, because Chrome seems to care even though the spec doesn’t say it should. I tried to reproduce this failure independently with plain JavaScript WebGPU, but could not. The test program I used (based on the console errors I was seeing, which complained of a buffer size limit exceeded *inside writeTexture*) was: const adapter = await navigator.gpu.requestAdapter(); if (!adapter) { console.error("no adapter"); } const device = await adapter.requestDevice(); if (!device) { console.error("no device"); } const queue = device.queue; console.log("got device"); const chunkSize = 16; const totalSize = 512; const chunks = totalSize / chunkSize; console.log("chunks =", chunkSize); const texture = device.createTexture({ size: { width: totalSize, height: totalSize, depthOrArrayLayers: totalSize }, dimension: "3d", format: "rgba8unorm", usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT }); for (let rep = 0; rep < 2; rep++) { console.log("repetition", rep); for (let x = 0; x < chunks; x++) for (let y = 0; y < chunks; y++) for (let z = 0; z < chunks; z++) { queue.writeTexture( { texture, origin: [x * chunkSize, y * chunkSize, z * chunkSize] }, new Uint8Array(chunkSize * chunkSize * chunkSize * 4), { offset: 0, bytesPerRow: chunkSize * 4, rowsPerImage: chunkSize }, [chunkSize, chunkSize, chunkSize], ); } queue.submit([]); await null; } console.log("done");
- Loading branch information
Showing
5 changed files
with
55 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters