if(iface.interface=="uniform")
{
- int bind_point = (iface.layout ? get_layout_value(*iface.layout, "binding") : -1);
+ bool push_constant = false;
+ if(iface.layout)
+ {
+ auto i = find_member(iface.layout->qualifiers, string("push_constant"), &Layout::Qualifier::name);
+ push_constant = (i!=iface.layout->qualifiers.end());
+ }
- if(bind_point>=0)
+ if(!push_constant)
{
- used_bindings[0].insert(bind_point);
- uniforms[iface.block_name].bind_point = bind_point;
+ 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);
}
- else
- unbound_blocks.push_back(&iface);
}
}
void LegacyConverter::visit(InterfaceBlock &iface)
{
+ bool push_constant = false;
if(iface.layout)
{
for(auto i=iface.layout->qualifiers.begin(); i!=iface.layout->qualifiers.end(); )
i = iface.layout->qualifiers.erase(i);
}
else
+ {
+ if(i->name=="push_constant")
+ push_constant = true;
++i;
+ }
}
if(iface.layout->qualifiers.empty())
iface.layout = 0;
}
- if(!supports_interface_blocks(iface.interface) && iface.type_declaration)
+ if((!supports_interface_blocks(iface.interface) || push_constant) && iface.type_declaration)
{
if(!iface.instance_name.empty())
unsupported("ARB_uniform_buffer_object required for interface block instances");
void DeclarationValidator::visit(Layout &layout)
{
+ bool push_constant = false;
+ bool binding = false;
for(const Layout::Qualifier &q: layout.qualifiers)
{
bool allowed = false;
allowed = (variable && scope==GLOBAL);
else if(q.name=="binding" || q.name=="set")
{
+ binding = true;
+
if(q.name=="set")
{
error(layout, "Layout qualifier 'set' not allowed when targeting OpenGL");
err_descr = "non-matrix variable";
}
}
+ else if(q.name=="push_constant")
+ {
+ push_constant = true;
+ allowed = (iface_block && !variable && iface_block->interface=="uniform");
+ value = false;
+ }
if(!allowed)
{
else if(!value && q.has_value)
error(layout, format("Layout qualifier '%s' does not allow a value", q.name));
}
+
+ if(push_constant && binding)
+ error(layout, "Layout qualifier 'push_constant' not allowed together with 'binding' or 'set'");
}
void DeclarationValidator::visit(InterfaceLayout &layout)