X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fspirv.cpp;h=44c1eb87a4c382a4c4735df44361c4188a5a633b;hp=be226b3c556ff67650146cb8de9fbcaa2bb188cf;hb=523491787b2b0321748a53f139c1a4355d2f9e85;hpb=03b21dc33ad615efa26849323a2018dd989218c3 diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index be226b3c..44c1eb87 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -455,16 +455,6 @@ SpirVGenerator::Id SpirVGenerator::write_construct(Id type_id, const Id *elem_id return result_id; } -BasicTypeDeclaration &SpirVGenerator::get_element_type(BasicTypeDeclaration &basic) -{ - if(basic.kind==BasicTypeDeclaration::BOOL || basic.kind==BasicTypeDeclaration::INT || basic.kind==BasicTypeDeclaration::FLOAT) - return basic; - else if((basic.kind==BasicTypeDeclaration::VECTOR || basic.kind==BasicTypeDeclaration::MATRIX) && basic.base_type) - return get_element_type(dynamic_cast(*basic.base_type)); - else - throw invalid_argument("SpirVGenerator::get_element_type"); -} - void SpirVGenerator::visit(Block &block) { for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ++i) @@ -665,7 +655,7 @@ void SpirVGenerator::visit(UnaryExpression &unary) return; BasicTypeDeclaration &basic = dynamic_cast(*unary.expression->type); - BasicTypeDeclaration &elem = get_element_type(basic); + BasicTypeDeclaration &elem = *get_element_type(basic); if(constant_expression && elem.kind!=BasicTypeDeclaration::BOOL && elem.kind!=BasicTypeDeclaration::INT) /* SPIR-V allows constant operations on floating-point values only for @@ -747,7 +737,7 @@ void SpirVGenerator::visit(BinaryExpression &binary) BasicTypeDeclaration &basic_left = dynamic_cast(*binary.left->type); BasicTypeDeclaration &basic_right = dynamic_cast(*binary.right->type); // Expression resolver ensures that element types are the same - BasicTypeDeclaration &elem = get_element_type(basic_left); + BasicTypeDeclaration &elem = *get_element_type(basic_left); if(constant_expression && elem.kind!=BasicTypeDeclaration::BOOL && elem.kind!=BasicTypeDeclaration::INT) /* SPIR-V allows constant operations on floating-point values only for @@ -1024,7 +1014,7 @@ void SpirVGenerator::visit(FunctionCall &call) for(NodeArray::const_iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i) if(BasicTypeDeclaration *basic_arg = dynamic_cast((*i)->type)) { - BasicTypeDeclaration &elem_arg = get_element_type(*basic_arg); + BasicTypeDeclaration &elem_arg = *get_element_type(*basic_arg); switch(elem_arg.kind) { case BasicTypeDeclaration::BOOL: arg_types += 'b'; break; @@ -1101,9 +1091,9 @@ void SpirVGenerator::visit_constructor(FunctionCall &call, const vector &arg return; } - BasicTypeDeclaration &elem = get_element_type(*basic); + BasicTypeDeclaration &elem = *get_element_type(*basic); BasicTypeDeclaration &basic_arg0 = dynamic_cast(*call.arguments[0]->type); - BasicTypeDeclaration &elem_arg0 = get_element_type(basic_arg0); + BasicTypeDeclaration &elem_arg0 = *get_element_type(basic_arg0); if(basic->kind==BasicTypeDeclaration::MATRIX) {