Merge pull request #2919 from bungoboingo/hack/fix-gl-cubemap-detection
[Fix] GL backend interpreting atlas texture as cube map vs 2d tex array when atlas layer depth == 6
This commit is contained in:
commit
e6da449c92
1 changed files with 13 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ use std::sync::Arc;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Atlas {
|
||||
backend: wgpu::Backend,
|
||||
texture: wgpu::Texture,
|
||||
texture_view: wgpu::TextureView,
|
||||
texture_bind_group: wgpu::BindGroup,
|
||||
|
|
@ -79,6 +80,7 @@ impl Atlas {
|
|||
});
|
||||
|
||||
Atlas {
|
||||
backend,
|
||||
texture,
|
||||
texture_view,
|
||||
texture_bind_group,
|
||||
|
|
@ -376,12 +378,22 @@ impl Atlas {
|
|||
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 self.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