#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>
target = &*i;
}
+ if(stage.required_version>target->required_version)
+ target->required_version = stage.required_version;
for(NodeList<Statement>::iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i)
target->content.body.push_back(*i);
apply<DeclarationCombiner>(*target);
void ProgramCompiler::generate(Stage &stage)
{
+ if(module->shared.required_version>stage.required_version)
+ stage.required_version = module->shared.required_version;
inject_block(stage.content, module->shared.content);
apply<DeclarationReorderer>(stage);
ProgramCompiler::Formatter::Formatter():
+ source_index(0),
source_line(1),
indent(0),
parameter_list(false)
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;
stmt->expression = assign;
stmt->visit(*this);
insert_nodes.push_back(stmt);
+
+ return *stmt;
}
void ProgramCompiler::InterfaceGenerator::visit(VariableReference &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;
}
}
{
if(!i->second.referenced)
unused_nodes.insert(i->first);
- clear_assignments(i->second, true);
+ clear_assignments(i->second, i->first->interface!="out");
continue;
}
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);