diff options
author | 2024-02-19 08:35:21 +0100 | |
---|---|---|
committer | 2024-02-19 08:35:21 +0100 | |
commit | 121d220532c14e6fa85e333ccf4271477298445b (patch) | |
tree | b107276f229ec3c9b1a05124591fdc6aed0bbdec /wgpu/src/image | |
parent | c76a9eb2ff08ac242ed27d7fb11f536c1cc4411a (diff) | |
parent | 5d09632790fb4c0a756262c667a993e6da856e0c (diff) | |
download | iced-121d220532c14e6fa85e333ccf4271477298445b.tar.gz iced-121d220532c14e6fa85e333ccf4271477298445b.tar.bz2 iced-121d220532c14e6fa85e333ccf4271477298445b.zip |
Merge pull request #2259 from PolyMeilex/wgpu-image-workaround-wgpu-gl-heuristics
[wgpu.image] Workaround WGPU OpenGL heuristics
Diffstat (limited to 'wgpu/src/image')
-rw-r--r-- | wgpu/src/image/atlas.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index 789e35b4..ea36e06d 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -23,11 +23,19 @@ pub struct Atlas { } impl Atlas { - pub fn new(device: &wgpu::Device) -> Self { + pub fn new(device: &wgpu::Device, backend: wgpu::Backend) -> Self { + let layers = match backend { + // On the GL backend we start with 2 layers, to help wgpu figure + // out that this texture is `GL_TEXTURE_2D_ARRAY` rather than `GL_TEXTURE_2D` + // https://github.com/gfx-rs/wgpu/blob/004e3efe84a320d9331371ed31fa50baa2414911/wgpu-hal/src/gles/mod.rs#L371 + wgpu::Backend::Gl => vec![Layer::Empty, Layer::Empty], + _ => vec![Layer::Empty], + }; + let extent = wgpu::Extent3d { width: SIZE, height: SIZE, - depth_or_array_layers: 1, + depth_or_array_layers: layers.len() as u32, }; let texture = device.create_texture(&wgpu::TextureDescriptor { @@ -55,7 +63,7 @@ impl Atlas { Atlas { texture, texture_view, - layers: vec![Layer::Empty], + layers, } } |