The typed array returned by
WebGPURenderer.readRenderTargetPixelsAsync.
Image width in pixels.
Image height in pixels.
4 for RGBA8/Uint8, 8 for RGBA16F/Uint16, 16 for RGBA32F/Float32.
Either raw itself (when no compaction is needed) or a new
typed array of the same concrete type sized for the compact layout.
Drop WebGPU's per-row buffer padding from a readback typed array.
WebGPU's
copyTextureToBuffer(used internally byWebGPURenderer.readRenderTargetPixelsAsync) requiresbytesPerRowto be a multiple of 256 (WebGPU spec § "Texture & buffer copy alignment"). Three.js sizes the returned typed array to match the padded GPU layout, so whenwidth * bytesPerTexelisn't already a multiple of 256 the array contains junk bytes at the end of every row.This helper returns a row-compacted view sized exactly
width * height * bytesPerTexel. When the input already matches the compact size (no padding required), the input is returned unchanged to avoid an allocation. Both WebGL2-returned arrays (always compact) and WebGPU-returned arrays for aligned widths hit the no-op path.Same math as the
PickingSystem.readbackAndVotedeinterlace loop; extracted so the post-processing capture/screenshot paths can share it (previously they assumed compact rows under WebGPU and produced corrupted output for canvas widths whose row stride wasn't a multiple of 256 bytes).