Skip to content

Commit aead5f9

Browse files
committed
align queue.writeTexture
1 parent ccf76eb commit aead5f9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/GPUQueue.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,21 @@ export class GPUQueueImpl implements GPUQueue {
202202
return;
203203
}
204204

205-
const dataPtr = ptr(arrayBuffer, byteOffsetInData);
206-
const packedDestination = WGPUTexelCopyTextureInfoStruct.pack(destination);
205+
if (!dataLayout.bytesPerRow) {
206+
fatalError("queueWriteTexture: dataLayout.bytesPerRow is required.");
207+
}
208+
207209
const normalizedWriteSize = normalizeGPUExtent3DStrict(writeSize);
208-
209-
// Ensure rowsPerImage is set, defaulting to copy height
210+
const packedDestination = WGPUTexelCopyTextureInfoStruct.pack(destination);
210211
const layoutForPacking: GPUTexelCopyBufferLayout = {
211-
offset: dataLayout.offset ?? 0,
212-
bytesPerRow: dataLayout.bytesPerRow,
213-
rowsPerImage: dataLayout.rowsPerImage ?? normalizedWriteSize.height,
212+
offset: dataLayout.offset ?? 0,
213+
bytesPerRow: dataLayout.bytesPerRow,
214+
rowsPerImage: dataLayout.rowsPerImage ?? normalizedWriteSize.height,
214215
};
215-
if (!layoutForPacking.bytesPerRow) {
216-
fatalError("queueWriteTexture: dataLayout.bytesPerRow is required.");
217-
}
216+
218217
const packedLayout = WGPUTexelCopyBufferLayoutStruct.pack(layoutForPacking);
219218
const packedWriteSize = WGPUExtent3DStruct.pack(normalizedWriteSize);
219+
const dataPtr = ptr(arrayBuffer, byteOffsetInData);
220220

221221
try {
222222
this.lib.wgpuQueueWriteTexture(

0 commit comments

Comments
 (0)