]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programcompiler.cpp
Properly handle the legacy replacement of fragment shader output
[libs/gl.git] / source / programcompiler.cpp
index f9a14f2f00a119ffbd7ba7604fd36a84e5a96585..fd27839da25e1f7cb377a7fdf46079bfb1e862f3 100644 (file)
@@ -1494,11 +1494,13 @@ void ProgramCompiler::NodeRemover::visit(VariableDeclaration &var)
 
 
 ProgramCompiler::LegacyConverter::LegacyConverter():
-       target_version(get_glsl_version())
+       target_version(get_glsl_version()),
+       frag_out(0)
 { }
 
 ProgramCompiler::LegacyConverter::LegacyConverter(const Version &v):
-       target_version(v)
+       target_version(v),
+       frag_out(0)
 { }
 
 bool ProgramCompiler::LegacyConverter::check_version(const Version &feature_version)
@@ -1513,7 +1515,7 @@ bool ProgramCompiler::LegacyConverter::check_version(const Version &feature_vers
 
 void ProgramCompiler::LegacyConverter::visit(VariableReference &var)
 {
-       if(var.name==frag_out_name && !check_version(Version(1, 30)))
+       if(var.declaration==frag_out && !check_version(Version(1, 30)))
        {
                var.name = "gl_FragColor";
                var.declaration = 0;
@@ -1525,6 +1527,13 @@ void ProgramCompiler::LegacyConverter::visit(VariableReference &var)
                type = string();
 }
 
+void ProgramCompiler::LegacyConverter::visit(Assignment &assign)
+{
+       TraversingVisitor::visit(assign);
+       if(assign.target_declaration==frag_out && !check_version(Version(1, 30)))
+               assign.target_declaration = 0;
+}
+
 void ProgramCompiler::LegacyConverter::visit(FunctionCall &call)
 {
        if(call.name=="texture" && !call.declaration && !check_version(Version(1, 30)))
@@ -1581,7 +1590,7 @@ void ProgramCompiler::LegacyConverter::visit(VariableDeclaration &var)
        {
                if(stage->type==FRAGMENT && var.interface=="out")
                {
-                       frag_out_name = var.name;
+                       frag_out = &var;
                        remove_node = true;
                }
        }