void LayoutDefaulter::apply(Stage &stage)
{
+ stage.content.visit(*this);
if(stage.type==Stage::TESS_EVAL)
{
- stage.content.visit(*this);
if((need_winding || need_spacing) && in_iface)
{
if(need_winding)
}
}
+void LayoutDefaulter::visit(VariableDeclaration &var)
+{
+ if(var.block_declaration && (var.interface=="uniform" || var.interface=="buffer"))
+ {
+ bool has_packing = false;
+ if(var.layout)
+ {
+ for(auto i = var.layout->qualifiers.begin(); (!has_packing && i!=var.layout->qualifiers.end()); ++i)
+ has_packing = (i->name=="std140" || i->name=="std430" || i->name=="shared" || i->name=="packed");
+ }
+
+ if(!has_packing)
+ add_layout_qualifier(var.layout, Layout::Qualifier(var.interface=="buffer" ? "std430" : "std140"));
+ }
+}
+
void ArraySizer::apply(Stage &stage)
{
};
/**
-Adds default global input and output layout qualifiers for stages which need
-them (currently tessellation evaluation).
+Adds default layout qualifiers when they haven't been specified already. This
+includes packing qualifiers for uniform and buffer blocks and global input and
+output qualifiers for certain stages (currently tessellation evaluation).
*/
class LayoutDefaulter: private TraversingVisitor
{
private:
void visit(InterfaceLayout &) override;
+ void visit(VariableDeclaration &) override;
};
/**