Skip to content

Commit

Permalink
CITEST
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Feb 25, 2022
1 parent 799f030 commit 8b712c2
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions wgpu-hal/src/gles/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,17 @@ impl super::Queue {
.map_or(copy.size.width * format_info.block_size as u32, |bpr| {
bpr.get()
});
let rows_per_image = copy.buffer_layout.rows_per_image.map_or(
copy.size.height / format_info.block_dimensions.1 as u32,
|rpi| rpi.get(),
);
let minimum_rows_per_image =
u32::max(1, copy.size.height / format_info.block_dimensions.1 as u32);
let rows_per_image = copy
.buffer_layout
.rows_per_image
.map_or(minimum_rows_per_image, |rpi| rpi.get());

let bytes_per_image = bytes_per_row * rows_per_image;
let minimum_bytes_per_image = bytes_per_row * minimum_rows_per_image;
let bytes_in_upload =
(bytes_per_image * (copy.size.depth - 1)) + minimum_bytes_per_image;
let offset = copy.buffer_layout.offset as u32;

let buffer_data;
Expand All @@ -477,18 +482,35 @@ impl super::Queue {
gl.bind_buffer(glow::PIXEL_UNPACK_BUFFER, Some(buffer));
unbind_unpack_buffer = true;
glow::CompressedPixelUnpackData::BufferRange(
offset..offset + bytes_per_image,
offset..offset + bytes_in_upload,
)
}
None => {
buffer_data = src.data.as_ref().unwrap().lock().unwrap();
let src_data = &buffer_data.as_slice()
[(offset as usize)..(offset + bytes_per_image) as usize];
[(offset as usize)..(offset + bytes_in_upload) as usize];
glow::CompressedPixelUnpackData::Slice(src_data)
}
};
log::error!(
"bytes_per_row: {}, \
minimum_rows_per_image: {}, \
rows_per_image: {}, \
bytes_per_image: {}, \
minimum_bytes_per_image: {}, \
bytes_in_upload: {}\
",
bytes_per_row,
minimum_rows_per_image,
rows_per_image,
bytes_per_image,
minimum_bytes_per_image,
bytes_in_upload
);
match dst_target {
glow::TEXTURE_3D | glow::TEXTURE_2D_ARRAY => {
glow::TEXTURE_3D
| glow::TEXTURE_CUBE_MAP_ARRAY
| glow::TEXTURE_2D_ARRAY => {
gl.compressed_tex_sub_image_3d(
dst_target,
copy.texture_base.mip_level as i32,
Expand Down Expand Up @@ -526,21 +548,6 @@ impl super::Queue {
unpack_data,
);
}
glow::TEXTURE_CUBE_MAP_ARRAY => {
//Note: not sure if this is correct!
gl.compressed_tex_sub_image_3d(
dst_target,
copy.texture_base.mip_level as i32,
copy.texture_base.origin.x as i32,
copy.texture_base.origin.y as i32,
copy.texture_base.origin.z as i32,
copy.size.width as i32,
copy.size.height as i32,
copy.size.depth as i32,
format_desc.internal,
unpack_data,
);
}
_ => unreachable!(),
}
}
Expand Down

0 comments on commit 8b712c2

Please sign in to comment.