Skip to content

Commit

Permalink
Fix tex_sub_image_* calls not always adjusting to target texture
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Apr 3, 2023
1 parent ea396e2 commit c6b6e14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610).
- Reset all queue state between command buffers in a submit. By @jleibs [#3589](https://github.com/gfx-rs/wgpu/pull/3589)
- Reset the state of `SAMPLE_ALPHA_TO_COVERAGE` on queue reset. By @jleibs [#3589](https://github.com/gfx-rs/wgpu/pull/3589)
- Fix `Vertex buffer is not big enough for the draw call.` for ANGLE/Web when rendering with instance attributes on a single instance. By @wumpf in [#3597](https://github.com/gfx-rs/wgpu/pull/3597)
- Fix `copy_external_image_to_texture` and `copy_texture_to_texture` not taking 2D texture arrays and cube maps into account. By @daxpedda [#3641](https://github.com/gfx-rs/wgpu/pull/3641)

#### General

Expand Down
24 changes: 20 additions & 4 deletions wgpu-hal/src/gles/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,20 @@ impl super::Queue {
unsafe { gl.bind_texture(dst_target, Some(dst)) };
let format_desc = self.shared.describe_texture_format(dst_format);
if is_layered_target(dst_target) {
let z_offset = if let glow::TEXTURE_2D_ARRAY = dst_target {
copy.dst_base.array_layer as i32
} else {
copy.dst_base.origin.z as i32
};

match src.source {
wgt::ExternalImageSource::ImageBitmap(ref b) => unsafe {
gl.tex_sub_image_3d_with_image_bitmap(
dst_target,
copy.dst_base.mip_level as i32,
copy.dst_base.origin.x as i32,
copy.dst_base.origin.y as i32,
copy.dst_base.origin.z as i32,
z_offset,
copy.size.width as i32,
copy.size.height as i32,
copy.size.depth as i32,
Expand All @@ -415,7 +421,7 @@ impl super::Queue {
copy.dst_base.mip_level as i32,
copy.dst_base.origin.x as i32,
copy.dst_base.origin.y as i32,
copy.dst_base.origin.z as i32,
z_offset,
copy.size.width as i32,
copy.size.height as i32,
copy.size.depth as i32,
Expand All @@ -430,7 +436,7 @@ impl super::Queue {
copy.dst_base.mip_level as i32,
copy.dst_base.origin.x as i32,
copy.dst_base.origin.y as i32,
copy.dst_base.origin.z as i32,
z_offset,
copy.size.width as i32,
copy.size.height as i32,
copy.size.depth as i32,
Expand All @@ -442,6 +448,12 @@ impl super::Queue {
wgt::ExternalImageSource::OffscreenCanvas(_) => unreachable!(),
}
} else {
let dst_target = if let glow::TEXTURE_CUBE_MAP = dst_target {
CUBEMAP_FACES[copy.dst_base.array_layer as usize]
} else {
dst_target
};

match src.source {
wgt::ExternalImageSource::ImageBitmap(ref b) => unsafe {
gl.tex_sub_image_2d_with_image_bitmap_and_width_and_height(
Expand Down Expand Up @@ -549,7 +561,11 @@ impl super::Queue {
copy.dst_base.mip_level as i32,
copy.dst_base.origin.x as i32,
copy.dst_base.origin.y as i32,
copy.dst_base.origin.z as i32,
if let glow::TEXTURE_2D_ARRAY = dst_target {
copy.dst_base.array_layer as i32
} else {
copy.dst_base.origin.z as i32
},
copy.src_base.origin.x as i32,
copy.src_base.origin.y as i32,
copy.size.width as i32,
Expand Down

0 comments on commit c6b6e14

Please sign in to comment.