if(var.interface=="uniform")
{
- const TypeDeclaration *type = var.type_declaration;
- while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
- type = basic->base_type;
- if(dynamic_cast<const ImageTypeDeclaration *>(type) && !visit_uniform(var.name, var.layout))
+ const TypeDeclaration *base_type = get_ultimate_base_type(var.type_declaration);
+ if(dynamic_cast<const ImageTypeDeclaration *>(base_type) && !visit_uniform(var.name, var.layout))
unbound_textures.push_back(&var);
}
}
}
else if(i->name=="binding" && !supports_binding())
{
- const TypeDeclaration *type = var.type_declaration;
- while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
- type = basic->base_type;
- if(dynamic_cast<const ImageTypeDeclaration *>(type))
+ if(dynamic_cast<const ImageTypeDeclaration *>(get_ultimate_base_type(var.type_declaration)))
stage->texture_bindings[var.name] = i->value;
i = var.layout->qualifiers.erase(i);
}
}
+const TypeDeclaration *get_ultimate_base_type(const TypeDeclaration *type)
+{
+ if(!type)
+ return 0;
+ while(const BasicTypeDeclaration *basic = dynamic_cast<const BasicTypeDeclaration *>(type))
+ {
+ if(!basic->base_type)
+ break;
+ type = basic->base_type;
+ }
+ return type;
+}
+
int get_layout_value(const Layout &layout, const string &name, int def_value)
{
auto i = find_member(layout.qualifiers, name, &Layout::Qualifier::name);
};
std::string get_unused_variable_name(const Block &, const std::string &);
-
+const TypeDeclaration *get_ultimate_base_type(const TypeDeclaration *);
int get_layout_value(const Layout &, const std::string &, int = -1);
void add_to_chain(Assignment::Target &, Assignment::Target::ChainType, unsigned);
bool targets_overlap(const Assignment::Target &, const Assignment::Target &);
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)
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");
}
}