layout->qualifiers.push_back(Layout::Qualifier(name, value));
}
+bool LocationAllocator::visit_uniform(const string &name, RefPtr<Layout> &layout)
+{
+ int bind_point = (layout ? get_layout_value(*layout, "binding") : -1);
+ if(bind_point>=0)
+ {
+ used_bindings[0].insert(bind_point);
+ uniforms[name].bind_point = bind_point;
+ }
+ return bind_point>=0;
+}
+
void LocationAllocator::visit(VariableDeclaration &var)
{
if(!var.name.compare(0, 3, "gl_"))
const TypeDeclaration *type = var.type_declaration;
while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
type = basic->base_type;
- if(dynamic_cast<const ImageTypeDeclaration *>(type))
- {
- int bind_point = (var.layout ? get_layout_value(*var.layout, "binding") : -1);
- if(bind_point>=0)
- {
- used_bindings[0].insert(bind_point);
- uniforms[var.name].bind_point = bind_point;
- }
- else
- unbound_textures.push_back(&var);
- }
+ if(dynamic_cast<const ImageTypeDeclaration *>(type) && !visit_uniform(var.name, var.layout))
+ unbound_textures.push_back(&var);
}
}
push_constant = (i!=iface.layout->qualifiers.end());
}
- if(!push_constant)
- {
- int bind_point = (iface.layout ? get_layout_value(*iface.layout, "binding") : -1);
-
- if(bind_point>=0)
- {
- used_bindings[0].insert(bind_point);
- uniforms[iface.block_name].bind_point = bind_point;
- }
- else
- unbound_blocks.push_back(&iface);
- }
+ if(!push_constant && !visit_uniform(iface.block_name, iface.layout))
+ unbound_blocks.push_back(&iface);
}
}
void bind_uniform(RefPtr<Layout> &, const std::string &, unsigned);
void add_layout_value(RefPtr<Layout> &, const std::string &, unsigned);
+ bool visit_uniform(const std::string &, RefPtr<Layout> &);
virtual void visit(VariableDeclaration &);
virtual void visit(InterfaceBlock &);
virtual void visit(FunctionDeclaration &) { }