]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/validate.cpp
Add a utility function for following a chain of base types
[libs/gl.git] / source / glsl / validate.cpp
index e11f181e0b42d1140b67b313cfe449ff8bad52d7..df3312e1fa9f6b46f3fdc52f7e305ded14059bab 100644 (file)
@@ -77,11 +77,9 @@ void DeclarationValidator::visit(Layout &layout)
 
                        if(variable)
                        {
-                               TypeDeclaration *type = variable->type_declaration;
-                               while(BasicTypeDeclaration *basic = dynamic_cast<BasicTypeDeclaration *>(type))
-                                       type = basic->base_type;
+                               const TypeDeclaration *base_type = get_ultimate_base_type(variable->type_declaration);
                                bool uniform = (variable->interface=="uniform");
-                               allowed = (scope==GLOBAL && uniform && dynamic_cast<ImageTypeDeclaration *>(type));
+                               allowed = (scope==GLOBAL && uniform && dynamic_cast<const ImageTypeDeclaration *>(base_type));
                                err_descr = (uniform ? "variable of non-opaque type" : "non-uniform variable");
                        }
                        else if(iface_block)
@@ -258,10 +256,7 @@ void DeclarationValidator::visit(VariableDeclaration &var)
                        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<BasicTypeDeclaration *>(type))
-                               type = basic->base_type;
-                       if(!dynamic_cast<ImageTypeDeclaration *>(type))
+                       if(!dynamic_cast<const ImageTypeDeclaration *>(get_ultimate_base_type(variable->type_declaration)))
                                error(var, "Interface qualifier 'uniform' not allowed on non-opaque variable in global scope");
                }
        }