From: Mikko Rasa Date: Wed, 31 Mar 2021 20:43:58 +0000 (+0300) Subject: Refactor layout legacy conversion code to be more extensible X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7a41f6dcc1339a4a2dda2207b6b051f20c09a239;p=libs%2Fgl.git Refactor layout legacy conversion code to be more extensible --- diff --git a/source/glsl/finalize.cpp b/source/glsl/finalize.cpp index 532e2ffc..55f7b82e 100644 --- a/source/glsl/finalize.cpp +++ b/source/glsl/finalize.cpp @@ -253,29 +253,30 @@ bool LegacyConverter::supports_sample_sampling() const void LegacyConverter::visit(VariableDeclaration &var) { - if(var.layout && !supports_interface_layouts()) + if(var.layout) { - vector::iterator i; - for(i=var.layout->qualifiers.begin(); (i!=var.layout->qualifiers.end() && i->name!="location"); ++i) ; - if(i!=var.layout->qualifiers.end()) + for(vector::const_iterator i=var.layout->qualifiers.begin(); i!=var.layout->qualifiers.end(); ) { - if(stage->type==Stage::VERTEX && var.interface=="in") + if(i->name=="location" && !supports_interface_layouts()) { - stage->locations[var.name] = i->value; - var.layout->qualifiers.erase(i); - } - else if(stage->type==Stage::FRAGMENT && var.interface=="out") - { - if(check_extension(&Features::ext_gpu_shader4)) + if(stage->type==Stage::VERTEX && var.interface=="in") stage->locations[var.name] = i->value; - else if(i->value!=0) - unsupported("EXT_gpu_shader4 required for multiple fragment shader outputs"); - var.layout->qualifiers.erase(i); - } + else if(stage->type==Stage::FRAGMENT && var.interface=="out") + { + if(check_extension(&Features::ext_gpu_shader4)) + stage->locations[var.name] = i->value; + else if(i->value!=0) + unsupported("EXT_gpu_shader4 required for multiple fragment shader outputs"); + } - if(var.layout->qualifiers.empty()) - var.layout = 0; + i = var.layout->qualifiers.erase(i); + } + else + ++i; } + + if(var.layout->qualifiers.empty()) + var.layout = 0; } if(var.sampling=="centroid")