From 1995280dc9f0bb94a5b2f81ae8724a5e5851c18a Mon Sep 17 00:00:00 2001 From: Layl <2385329-layl@users.noreply.gitlab.com> Date: Fri, 23 Aug 2019 16:11:35 +0200 Subject: [PATCH] Add cubemap hint to 2D multiple of 6 layers textures --- wgpu-native/src/device.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wgpu-native/src/device.rs b/wgpu-native/src/device.rs index 1292a9758..c9264bd5f 100644 --- a/wgpu-native/src/device.rs +++ b/wgpu-native/src/device.rs @@ -23,6 +23,7 @@ use crate::{ SurfaceId, TextureId, TextureViewId, + TextureDimension, }; #[cfg(feature = "local")] use crate::{ @@ -748,6 +749,16 @@ pub fn device_create_texture( assert!((desc.mip_level_count as usize) < MAX_MIP_LEVELS); + let mut view_capabilities = hal::image::ViewCapabilities::empty(); + + // 2D textures with array layer counts that are multiples of 6 could be cubemaps + // Following gpuweb/gpuweb#68 always add the hint in that case + if desc.dimension == TextureDimension::D2 && desc.array_layer_count % 6 == 0 { + view_capabilities |= hal::image::ViewCapabilities::KIND_CUBE; + }; + + // TODO: 2D arrays, cubemap arrays + let mut image = unsafe { device.raw.create_image( kind, @@ -755,7 +766,7 @@ pub fn device_create_texture( format, hal::image::Tiling::Optimal, usage, - hal::image::ViewCapabilities::empty(), // TODO: format, 2d array, cube + view_capabilities, ) } .unwrap();