]> git.tdb.fi Git - libs/gl.git/commitdiff
Refactor layout legacy conversion code to be more extensible
authorMikko Rasa <tdb@tdb.fi>
Wed, 31 Mar 2021 20:43:58 +0000 (23:43 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 1 Apr 2021 19:29:06 +0000 (22:29 +0300)
source/glsl/finalize.cpp

index 532e2ffcbb3914fd2d7e81dafab0f784e0b52daf..55f7b82e5ed107aae78042d4bacc2204accc5945 100644 (file)
@@ -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<Layout::Qualifier>::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<Layout::Qualifier>::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")