From c69f67660973a3bffa3b27c295f698dc4aa01524 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 4 Dec 2021 12:13:53 -0500 Subject: [PATCH] glsl: reflect textures without samplers --- src/back/glsl/mod.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index c29bd174b4..53f376a660 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -2718,13 +2718,13 @@ impl<'a, W: Write> Writer<'a, W> { fn collect_reflection_info(&self) -> Result { use std::collections::hash_map::Entry; let info = self.info.get_entry_point(self.entry_point_idx as usize); - let mut mappings = crate::FastHashMap::default(); + let mut texture_mapping = crate::FastHashMap::default(); let mut uniforms = crate::FastHashMap::default(); for sampling in info.sampling_set.iter() { let tex_name = self.reflection_names_globals[&sampling.image].clone(); - match mappings.entry(tex_name) { + match texture_mapping.entry(tex_name) { Entry::Vacant(v) => { v.insert(TextureMapping { texture: sampling.image, @@ -2752,12 +2752,26 @@ impl<'a, W: Write> Writer<'a, W> { } _ => (), }, - _ => continue, + crate::TypeInner::Image { .. } => { + let tex_name = self.reflection_names_globals[&handle].clone(); + match texture_mapping.entry(tex_name) { + Entry::Vacant(v) => { + v.insert(TextureMapping { + texture: handle, + sampler: None, + }); + } + Entry::Occupied(_) => { + // already used with a sampler, do nothing + } + } + } + _ => {} } } Ok(ReflectionInfo { - texture_mapping: mappings, + texture_mapping, uniforms, }) }