demo · v137
Copy graph
Pick a frame budget and a copy strategy; the lab runs the same upload graph through the two overloads of copyBufferToBuffer. The new 3-arg form (whole buffer, no offsets) avoids the manual size = src.size - srcOffset arithmetic and the offhand bugs that come with it.
Heads upRequires Chrome 137+ with WebGPU enabled. Falls back to a CPU-side
Uint8Array.set harness so the comparison runs in any browser.probing…
legacy: 5-arg form
copyBufferToBuffer(src, srcOffset, dst, dstOffset, size)
// boilerplate to copy whole buffer encoder.copyBufferToBuffer( src, /* srcOffset */ 0, dst, /* dstOffset */ 0, src.size // easy to mistype );
median frame time—
API-misuse risk5 args, easy to swap
v137: 3-arg overload
copyBufferToBuffer(src, dst, size?)
// no offsets — clearer intent encoder.copyBufferToBuffer(src, dst); // or with explicit length: encoder.copyBufferToBuffer(src, dst, n);
median frame time—
API-misuse risk2 positional args
which overload do I want?
/* whole src -> whole dst */ encoder.copyBufferToBuffer(src, dst); /* whole src -> whole dst, explicit size */ encoder.copyBufferToBuffer(src, dst, src.size); /* sub-region */ encoder.copyBufferToBuffer(src, 16, dst, 32, 256); /* truncate src -> whole dst */ encoder.copyBufferToBuffer(src, 0, dst, 0, dst.size);