X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fvalidate.cpp;h=e11f181e0b42d1140b67b313cfe449ff8bad52d7;hp=2da8345de4a7002e0020d98fe536443c72b8cba6;hb=25629675e83449d986ef8896e830db562a8ae64e;hpb=401a3a7ab3c3e4b23edb4c3b5c9c1e74f4313ee4 diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index 2da8345d..e11f181e 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -34,6 +34,13 @@ void Validator::add_info(Node &node, const string &message) } +void DeclarationValidator::apply(Stage &s, const Features &f) +{ + stage = &s; + features = f; + s.content.visit(*this); +} + const char *DeclarationValidator::describe_variable(ScopeType scope) { switch(scope) @@ -62,7 +69,7 @@ void DeclarationValidator::visit(Layout &layout) { binding = true; - if(q.name=="set") + if(q.name=="set" && features.target_api!=VULKAN) { error(layout, "Layout qualifier 'set' not allowed when targeting OpenGL"); continue; @@ -249,6 +256,14 @@ void DeclarationValidator::visit(VariableDeclaration &var) error(var, format("Mismatched interface qualifier '%s' inside '%s' block", var.interface, iface_block->interface)); else if(scope==STRUCT || scope==FUNCTION) error(var, format("Interface qualifier not allowed on %s", descr)); + else if(scope==GLOBAL && variable->interface=="uniform" && features.target_api==VULKAN) + { + TypeDeclaration *type = variable->type_declaration; + while(BasicTypeDeclaration *basic = dynamic_cast(type)) + type = basic->base_type; + if(!dynamic_cast(type)) + error(var, "Interface qualifier 'uniform' not allowed on non-opaque variable in global scope"); + } } TypeDeclaration *type = var.type_declaration;