diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index 2eeda35bb9..062e038f00 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -312,7 +312,9 @@ pub struct Writer<'a, W> { /// (generated by a [`Namer`](crate::proc::Namer)) names: crate::FastHashMap, /// A map with all the names needed for reflections - reflection_names: crate::FastHashMap, String>, + reflection_names_uniforms: crate::FastHashMap, String>, + /// A map with the names of global variables needed for reflections + reflection_names_globals: crate::FastHashMap, String>, /// The selected entry point entry_point: &'a crate::EntryPoint, /// The index of the selected entry point @@ -366,7 +368,8 @@ impl<'a, W: Write> Writer<'a, W> { namer, features: FeaturesManager::new(), names, - reflection_names: crate::FastHashMap::default(), + reflection_names_uniforms: crate::FastHashMap::default(), + reflection_names_globals: crate::FastHashMap::default(), entry_point: &module.entry_points[ep_idx], entry_point_idx: ep_idx as u16, @@ -549,7 +552,7 @@ impl<'a, W: Write> Writer<'a, W> { writeln!(self.out, " {};", global_name)?; writeln!(self.out)?; - self.reflection_names.insert(global.ty, global_name); + self.reflection_names_globals.insert(handle, global_name); } // glsl has no concept of samplers so we just ignore it TypeInner::Sampler { .. } => continue, @@ -1236,7 +1239,7 @@ impl<'a, W: Write> Writer<'a, W> { ); writeln!(self.out, "{} {{", block_name)?; - self.reflection_names.insert(handle, block_name); + self.reflection_names_uniforms.insert(handle, block_name); } else { writeln!(self.out, "struct {} {{", name)?; } @@ -2445,8 +2448,7 @@ impl<'a, W: Write> Writer<'a, W> { let mut uniforms = crate::FastHashMap::default(); for sampling in info.sampling_set.iter() { - let global = self.module.global_variables[sampling.image].clone(); - let tex_name = self.reflection_names[&global.ty].clone(); + let tex_name = self.reflection_names_globals[&sampling.image].clone(); match mappings.entry(tex_name) { Entry::Vacant(v) => { @@ -2471,7 +2473,7 @@ impl<'a, W: Write> Writer<'a, W> { match self.module.types[var.ty].inner { crate::TypeInner::Struct { .. } => match var.class { crate::StorageClass::Uniform | crate::StorageClass::Storage { .. } => { - let name = self.reflection_names[&var.ty].clone(); + let name = self.reflection_names_uniforms[&var.ty].clone(); uniforms.insert(handle, name); } _ => (),