Skip to content

Commit 7e112ca

Browse files
authored
[wgpu-core] fix length of copy in queue_write_texture (#5973)
The size of the given `data` might be less than the size of the staging buffer. This issue became apparent with the refactor in 6f16ea4 (#5946) since there is now an assert in `StagingBuffer.write()`. Ruffle ran into this in #3193 (comment).
1 parent 241b52f commit 7e112ca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

wgpu-core/src/device/queue.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,14 @@ impl Global {
781781
if stage_bytes_per_row == bytes_per_row {
782782
profiling::scope!("copy aligned");
783783
// Fast path if the data is already being aligned optimally.
784-
staging_buffer.write(&data[data_layout.offset as usize..]);
784+
unsafe {
785+
staging_buffer.write_with_offset(
786+
data,
787+
data_layout.offset as isize,
788+
0,
789+
(data.len() as u64 - data_layout.offset) as usize,
790+
);
791+
}
785792
} else {
786793
profiling::scope!("copy chunked");
787794
// Copy row by row into the optimal alignment.

0 commit comments

Comments
 (0)