]> git.tdb.fi Git - libs/gl.git/commitdiff
Refactor handling of texture sampling functions in LegacyConverter
authorMikko Rasa <tdb@tdb.fi>
Mon, 15 Feb 2021 11:25:37 +0000 (13:25 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 15 Feb 2021 11:25:37 +0000 (13:25 +0200)
This structure allows to check support for sampler types which don't
have legacy variants for the texture function.

source/glsl/compatibility.cpp

index 4e43ae9dcdd3b4241afe1d7c5c945db368834a49..a3b2882dc538b0db82d603c12f792c3846ca36b5 100644 (file)
@@ -145,47 +145,54 @@ bool LegacyConverter::supports_unified_sampling_functions() const
 
 void LegacyConverter::visit(FunctionCall &call)
 {
-       if(call.name=="texture" && !call.declaration && !supports_unified_sampling_functions())
+       if(call.name=="texture")
        {
+               string sampler_type;
+               type = string();
                NodeArray<Expression>::iterator i = call.arguments.begin();
                if(i!=call.arguments.end())
                {
                        (*i)->visit(*this);
-                       if(type=="sampler1D")
+                       sampler_type = type;
+
+                       for(; i!=call.arguments.end(); ++i)
+                               (*i)->visit(*this);
+               }
+
+               if(!supports_unified_sampling_functions())
+               {
+                       if(sampler_type=="sampler1D")
                                call.name = "texture1D";
-                       else if(type=="sampler2D")
+                       else if(sampler_type=="sampler2D")
                                call.name = "texture2D";
-                       else if(type=="sampler3D")
+                       else if(sampler_type=="sampler3D")
                                call.name = "texture3D";
-                       else if(type=="samplerCube")
+                       else if(sampler_type=="samplerCube")
                                call.name = "textureCube";
-                       else if(type=="sampler1DShadow")
+                       else if(sampler_type=="sampler1DShadow")
                                call.name = "shadow1D";
-                       else if(type=="sampler2DShadow")
+                       else if(sampler_type=="sampler2DShadow")
                                call.name = "shadow2D";
-                       else if(type=="sampler1DArray")
+                       else if(sampler_type=="sampler1DArray")
                        {
                                check_extension(EXT_texture_array);
                                call.name = "texture1DArray";
                        }
-                       else if(type=="sampler2DArray")
+                       else if(sampler_type=="sampler2DArray")
                        {
                                check_extension(EXT_texture_array);
                                call.name = "texture2DArray";
                        }
-                       else if(type=="sampler1DArrayShadow")
+                       else if(sampler_type=="sampler1DArrayShadow")
                        {
                                check_extension(EXT_texture_array);
                                call.name = "shadow1DArray";
                        }
-                       else if(type=="sampler2DArrayShadow")
+                       else if(sampler_type=="sampler2DArrayShadow")
                        {
                                check_extension(EXT_texture_array);
                                call.name = "shadow2DArray";
                        }
-
-                       for(; i!=call.arguments.end(); ++i)
-                               (*i)->visit(*this);
                }
        }
        else