X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fvalidate.cpp;h=6a4b8eb0dc0e34ced99b82fcc08d41c22c569bf0;hp=df3312e1fa9f6b46f3fdc52f7e305ded14059bab;hb=efbce87192ce73ba577684369f759693dccec67c;hpb=ea844415db7fb7705ecbfea9cf27df2a8f00b802 diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index df3312e1..6a4b8eb0 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -526,8 +526,7 @@ void ExpressionValidator::visit(VariableReference &var) error(var, format("Reference to non-constant variable '%s' in a constant expression", var.name)); else if(var.declaration->layout && constant_expression==FIXED_CONSTANT) { - auto i = find_member(var.declaration->layout->qualifiers, string("constant_id"), &Layout::Qualifier::name); - if(i!=var.declaration->layout->qualifiers.end()) + if(has_layout_qualifier(var.declaration->layout.get(), "constant_id")) error(var, format("Reference to specialization constant '%s' in a fixed constant expression", var.name)); } } @@ -662,13 +661,8 @@ void ExpressionValidator::visit(VariableDeclaration &var) var.layout->visit(*this); if(var.init_expression) { - ConstantKind const_kind = (var.constant ? SPEC_CONSTANT : NOT_CONSTANT); - if(var.layout) - { - auto i = find_member(var.layout->qualifiers, string("constant_id"), &Layout::Qualifier::name); - if(i!=var.layout->qualifiers.end()) - const_kind = FIXED_CONSTANT; - } + ConstantKind const_kind = (!var.constant ? NOT_CONSTANT : + has_layout_qualifier(var.layout.get(), "constant_id") ? FIXED_CONSTANT : SPEC_CONSTANT); SetForScope set_const(constant_expression, const_kind); TraversingVisitor::visit(var.init_expression); @@ -770,18 +764,13 @@ void FlowControlValidator::visit(Iteration &iter) } -int StageInterfaceValidator::get_location(const Layout &layout) -{ - return get_layout_value(layout, "location", -1); -} - void StageInterfaceValidator::visit(VariableDeclaration &var) { - int location = (var.layout ? get_location(*var.layout) : -1); + int location = get_layout_value(var.layout.get(), "location"); if(var.interface=="in" && var.linked_declaration) { const Layout *linked_layout = var.linked_declaration->layout.get(); - int linked_location = (linked_layout ? get_location(*linked_layout) : -1); + int linked_location = get_layout_value(linked_layout, "location"); if(linked_location!=location) { error(var, format("Mismatched location %d for 'in %s'", location, var.name)); @@ -910,10 +899,10 @@ void GlobalInterfaceValidator::visit(VariableDeclaration &var) uni.name = var.name; if(var.layout) { - uni.location = get_layout_value(*var.layout, "location"); + uni.location = get_layout_value(var.layout.get(), "location"); uni.loc_count = LocationCounter().apply(var); - uni.desc_set = get_layout_value(*var.layout, "set", 0); - uni.bind_point = get_layout_value(*var.layout, "binding"); + uni.desc_set = get_layout_value(var.layout.get(), "set", 0); + uni.bind_point = get_layout_value(var.layout.get(), "binding"); } uniforms.push_back(uni); @@ -931,8 +920,8 @@ void GlobalInterfaceValidator::visit(InterfaceBlock &iface) uni.name = iface.block_name; if(iface.layout) { - uni.desc_set = get_layout_value(*iface.layout, "set", 0); - uni.bind_point = get_layout_value(*iface.layout, "binding"); + uni.desc_set = get_layout_value(iface.layout.get(), "set", 0); + uni.bind_point = get_layout_value(iface.layout.get(), "binding"); } uniforms.push_back(uni);