Skip to content

Commit

Permalink
[wgpu-core] fix length of copy in queue_write_texture (#5973)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
teoxoy authored Jul 17, 2024
1 parent 241b52f commit 7e112ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,14 @@ impl Global {
if stage_bytes_per_row == bytes_per_row {
profiling::scope!("copy aligned");
// Fast path if the data is already being aligned optimally.
staging_buffer.write(&data[data_layout.offset as usize..]);
unsafe {
staging_buffer.write_with_offset(
data,
data_layout.offset as isize,
0,
(data.len() as u64 - data_layout.offset) as usize,
);
}
} else {
profiling::scope!("copy chunked");
// Copy row by row into the optimal alignment.
Expand Down

0 comments on commit 7e112ca

Please sign in to comment.