[glsl-out] split reflection_names into a map for types and another for globals (#1144)

* split reflection_names into a map for types and another for globals

* reflection_names_structs -> reflection_names_uniforms
This commit is contained in:
Jakob Hellermann
2021-07-29 06:17:01 +02:00
committed by GitHub
parent 2f516c0932
commit fa05f0d0d9

View File

@@ -312,7 +312,9 @@ pub struct Writer<'a, W> {
/// (generated by a [`Namer`](crate::proc::Namer))
names: crate::FastHashMap<NameKey, String>,
/// A map with all the names needed for reflections
reflection_names: crate::FastHashMap<Handle<crate::Type>, String>,
reflection_names_uniforms: crate::FastHashMap<Handle<crate::Type>, String>,
/// A map with the names of global variables needed for reflections
reflection_names_globals: crate::FastHashMap<Handle<crate::GlobalVariable>, 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);
}
_ => (),