Hack to fix GL-specific backend issue where if image atlas grows to a layer depth of 6, GL interprets the texture as a cube map vs a 2d texture array
This commit is contained in:
parent
aa2a50110d
commit
16703ccdef
5 changed files with 32 additions and 9 deletions
|
|
@ -98,6 +98,7 @@ impl Atlas {
|
|||
pub fn upload(
|
||||
&mut self,
|
||||
device: &wgpu::Device,
|
||||
backend: wgpu::Backend,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
width: u32,
|
||||
height: u32,
|
||||
|
|
@ -109,7 +110,7 @@ impl Atlas {
|
|||
|
||||
// We grow the internal texture after allocating if necessary
|
||||
let new_layers = self.layers.len() - current_size;
|
||||
self.grow(new_layers, device, encoder);
|
||||
self.grow(new_layers, device, backend, encoder);
|
||||
|
||||
entry
|
||||
};
|
||||
|
|
@ -370,18 +371,29 @@ impl Atlas {
|
|||
&mut self,
|
||||
amount: usize,
|
||||
device: &wgpu::Device,
|
||||
backend: wgpu::Backend,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
) {
|
||||
if amount == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
// On the GL backend if layers.len() == 6 we need to help wgpu figure out that this texture
|
||||
// is still a `GL_TEXTURE_2D_ARRAY` rather than `GL_TEXTURE_CUBE_MAP`. This will over-allocate
|
||||
// some unused memory on GL, but it's better than not being able to grow the atlas past a depth
|
||||
// of 6!
|
||||
// https://github.com/gfx-rs/wgpu/blob/004e3efe84a320d9331371ed31fa50baa2414911/wgpu-hal/src/gles/mod.rs#L371
|
||||
let depth_or_array_layers = match backend {
|
||||
wgpu::Backend::Gl if self.layers.len() == 6 => 7,
|
||||
_ => self.layers.len() as u32,
|
||||
};
|
||||
|
||||
let new_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("iced_wgpu::image texture atlas"),
|
||||
size: wgpu::Extent3d {
|
||||
width: SIZE,
|
||||
height: SIZE,
|
||||
depth_or_array_layers: self.layers.len() as u32,
|
||||
depth_or_array_layers,
|
||||
},
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue