]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programcompiler.cpp
Add feature check for array texture samplers
[libs/gl.git] / source / programcompiler.cpp
index bb77e0ea911e205c192c68cd88462f6affdf1ff6..989098d7d0cf6410b4d26faed46f9c400bc06a3c 100644 (file)
@@ -4,6 +4,7 @@
 #include <msp/gl/extensions/arb_gpu_shader5.h>
 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
 #include <msp/gl/extensions/ext_gpu_shader4.h>
+#include <msp/gl/extensions/ext_texture_array.h>
 #include <msp/strings/format.h>
 #include <msp/strings/regex.h>
 #include <msp/strings/utils.h>
@@ -989,7 +990,7 @@ bool ProgramCompiler::InterfaceGenerator::generate_interface(VariableDeclaration
        return true;
 }
 
-void ProgramCompiler::InterfaceGenerator::insert_assignment(const string &left, ProgramSyntax::Expression *right)
+ExpressionStatement &ProgramCompiler::InterfaceGenerator::insert_assignment(const string &left, ProgramSyntax::Expression *right)
 {
        Assignment *assign = new Assignment;
        VariableReference *ref = new VariableReference;
@@ -1002,6 +1003,8 @@ void ProgramCompiler::InterfaceGenerator::insert_assignment(const string &left,
        stmt->expression = assign;
        stmt->visit(*this);
        insert_nodes.push_back(stmt);
+
+       return *stmt;
 }
 
 void ProgramCompiler::InterfaceGenerator::visit(VariableReference &var)
@@ -1033,7 +1036,9 @@ void ProgramCompiler::InterfaceGenerator::visit(VariableDeclaration &var)
                        remove_node = true;
                        if(var.init_expression)
                        {
-                               insert_assignment(var.name, var.init_expression->clone());
+                               ExpressionStatement &stmt = insert_assignment(var.name, var.init_expression->clone());
+                               stmt.source = var.source;
+                               stmt.line = var.line;
                                return;
                        }
                }
@@ -1944,10 +1949,32 @@ void ProgramCompiler::LegacyConverter::visit(FunctionCall &call)
                                call.name = "texture2D";
                        else if(type=="sampler3D")
                                call.name = "texture3D";
+                       else if(type=="samplerCube")
+                               call.name = "textureCube";
                        else if(type=="sampler1DShadow")
                                call.name = "shadow1D";
                        else if(type=="sampler2DShadow")
                                call.name = "shadow2D";
+                       else if(type=="sampler1DArray")
+                       {
+                               check_extension(EXT_texture_array);
+                               call.name = "texture1DArray";
+                       }
+                       else if(type=="sampler2DArray")
+                       {
+                               check_extension(EXT_texture_array);
+                               call.name = "texture2DArray";
+                       }
+                       else if(type=="sampler1DArrayShadow")
+                       {
+                               check_extension(EXT_texture_array);
+                               call.name = "shadow1DArray";
+                       }
+                       else if(type=="sampler2DArrayShadow")
+                       {
+                               check_extension(EXT_texture_array);
+                               call.name = "shadow2DArray";
+                       }
 
                        for(; i!=call.arguments.end(); ++i)
                                (*i)->visit(*this);