Skip to content

Commit 896c8d3

Browse files
Prevent image flash when switching between texture formats (#513)
1 parent 881229e commit 896c8d3

File tree

1 file changed

+9
-9
lines changed
  • sample/volumeRenderingTexture3D

1 file changed

+9
-9
lines changed

sample/volumeRenderingTexture3D/main.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ async function createVolumeTexture(format: GPUTextureFormat) {
150150
status.textContent = '';
151151
}
152152

153-
volumeTexture = device.createTexture({
154-
dimension: '3d',
155-
size: [width, height, depth],
156-
format: format,
157-
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
158-
});
159-
160153
const response = await fetch(dataPath);
161154

162155
// Decompress the data using DecompressionStream for gzip format
@@ -165,10 +158,17 @@ async function createVolumeTexture(format: GPUTextureFormat) {
165158
const decompressedArrayBuffer = await new Response(
166159
decompressedStream
167160
).arrayBuffer();
168-
const byteArray = new Uint8Array(decompressedArrayBuffer);
161+
162+
volumeTexture = device.createTexture({
163+
dimension: '3d',
164+
size: [width, height, depth],
165+
format: format,
166+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
167+
});
168+
169169
device.queue.writeTexture(
170170
{ texture: volumeTexture },
171-
byteArray,
171+
decompressedArrayBuffer,
172172
{ bytesPerRow: bytesPerRow, rowsPerImage: blocksHigh },
173173
[width, height, depth]
174174
);

0 commit comments

Comments
 (0)