]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/validate.cpp
Allow a push constant block to be specified, but flatten it for now
[libs/gl.git] / source / glsl / validate.cpp
index f12177db4a4236109f4060ffc72c13098f66093f..2da8345de4a7002e0020d98fe536443c72b8cba6 100644 (file)
@@ -49,6 +49,8 @@ const char *DeclarationValidator::describe_variable(ScopeType scope)
 
 void DeclarationValidator::visit(Layout &layout)
 {
+       bool push_constant = false;
+       bool binding = false;
        for(const Layout::Qualifier &q: layout.qualifiers)
        {
                bool allowed = false;
@@ -58,6 +60,8 @@ void DeclarationValidator::visit(Layout &layout)
                        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");
@@ -141,6 +145,12 @@ void DeclarationValidator::visit(Layout &layout)
                                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)
                {
@@ -162,6 +172,9 @@ void DeclarationValidator::visit(Layout &layout)
                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)