Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions render/wgpu/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,22 +975,18 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
self.resolve_sync_handle(
sync_handle,
Box::new(|raw_pixels, buffer_width| {
let width = *width as usize;

if buffer_width as usize
!= *width as usize * output_channels * std::mem::size_of::<f32>()
!= width * output_channels * std::mem::size_of::<f32>()
{
let channels_in_raw_pixels = if has_padding { 4usize } else { 3usize };

let mut new_pixels = Vec::new();
for row in raw_pixels.chunks(buffer_width as usize) {
// Ignore any wgpu-added padding (this is distinct from the alpha-channel padding
// that we add for pixelbender)
let actual_row = &row[0..(*width as usize
* channels_in_raw_pixels
* std::mem::size_of::<f32>())];

for pixel in actual_row.chunks_exact(
channels_in_raw_pixels * std::mem::size_of::<f32>(),
) {
let actual_row = &row[0..(width * std::mem::size_of::<[f32; 4]>())];

for pixel in
actual_row.chunks_exact(std::mem::size_of::<[f32; 4]>())
{
if has_padding {
// Take the first three channels
new_pixels.extend_from_slice(
Expand Down
Loading