X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Freflect.cpp;h=6027acde36862363a6597bebe60db488fa666351;hp=83af09a6f8b092bfb9cf3a76d949644ae5638793;hb=c1bf0909af97772da5b26d82272f337a14c1fae9;hpb=3f245515062d10e4d527827e5126fe412de06ce0 diff --git a/source/glsl/reflect.cpp b/source/glsl/reflect.cpp index 83af09a6..6027acde 100644 --- a/source/glsl/reflect.cpp +++ b/source/glsl/reflect.cpp @@ -49,13 +49,6 @@ bool can_convert(const BasicTypeDeclaration &from, const BasicTypeDeclaration &t unsigned TypeComparer::next_tag = 1; -TypeComparer::TypeComparer(): - first(0), - second(0), - first_tag(0), - r_result(false) -{ } - void TypeComparer::compare(Node &node1, Node &node2) { if(&node1==&node2) @@ -234,10 +227,6 @@ void TypeComparer::visit(VariableDeclaration &var) } -LocationCounter::LocationCounter(): - r_count(0) -{ } - void LocationCounter::visit(BasicTypeDeclaration &basic) { r_count = basic.kind==BasicTypeDeclaration::MATRIX ? basic.size>>16 : 1; @@ -315,6 +304,8 @@ void MemoryRequirementsCalculator::visit(StructDeclaration &strct) } r_size = total; r_alignment = max_align; + r_size += r_alignment-1; + r_size -= r_size%r_alignment; } void MemoryRequirementsCalculator::visit(VariableDeclaration &var) @@ -331,7 +322,11 @@ void MemoryRequirementsCalculator::visit(VariableDeclaration &var) if(var.array) if(const Literal *literal = dynamic_cast(var.array_size.get())) if(literal->value.check_type()) - r_size += r_alignment*(literal->value.value()-1); + { + unsigned aligned_size = r_size+r_alignment-1; + aligned_size -= aligned_size%r_alignment; + r_size = aligned_size*literal->value.value(); + } } @@ -391,6 +386,19 @@ void DependencyCollector::visit(FunctionDeclaration &func) } } + +set AssignmentCollector::apply(Node &node) +{ + node.visit(*this); + return assigned_variables; +} + +void AssignmentCollector::visit(Assignment &assign) +{ + if(VariableDeclaration *var = dynamic_cast(assign.target.declaration)) + assigned_variables.insert(var); +} + } // namespace SL } // namespace GL } // namespace Msp