X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fcompatibility.cpp;h=280a38c9f2c829443991da07f5d6d6713db190a9;hb=a721984a85925a17ae0e43a2198fbc4762d76798;hp=9ed0d20c82c8b2a0ecc109c9db4adb55fff5040b;hpb=8173340a7737e32cb25b21b67049102bd1526beb;p=libs%2Fgl.git diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index 9ed0d20c..280a38c9 100644 --- a/source/glsl/compatibility.cpp +++ b/source/glsl/compatibility.cpp @@ -88,9 +88,20 @@ void LegacyConverter::apply(Stage &s, const Features &feat) { stage = &s; features = feat; - if(!supports_stage(s.type)) - throw unsupported_shader(format("Stage %s is not supported", Stage::get_stage_name(s.type))); - s.content.visit(*this); + if(supports_stage(s.type)) + s.content.visit(*this); + else + unsupported(format("Stage %s is not supported", Stage::get_stage_name(s.type))); +} + +void LegacyConverter::unsupported(const string &reason) +{ + Diagnostic diagnostic; + diagnostic.severity = Diagnostic::ERR; + diagnostic.source = GENERATED_SOURCE; + diagnostic.line = 0; + diagnostic.message = reason; + stage->diagnostics.push_back(diagnostic); } void LegacyConverter::visit(Block &block) @@ -161,8 +172,8 @@ void LegacyConverter::visit(VariableReference &var) void LegacyConverter::visit(Assignment &assign) { TraversingVisitor::visit(assign); - if(assign.target_declaration==frag_out && !supports_unified_interface_syntax()) - assign.target_declaration = 0; + if(assign.target.declaration==frag_out && !supports_unified_interface_syntax()) + assign.target.declaration = 0; } bool LegacyConverter::supports_unified_sampling_functions() const @@ -274,9 +285,10 @@ void LegacyConverter::visit(VariableDeclaration &var) } else if(stage->type==Stage::FRAGMENT && var.interface=="out") { - if(i->value!=0 && !check_extension(&Features::ext_gpu_shader4)) - throw unsupported_shader("EXT_gpu_shader4 is required"); - stage->locations[var.name] = i->value; + 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"); var.layout->qualifiers.erase(i); } @@ -327,10 +339,20 @@ bool LegacyConverter::supports_interface_blocks(const string &iface) const void LegacyConverter::visit(InterfaceBlock &iface) { - if(!supports_interface_blocks(iface.interface)) + if(!supports_interface_blocks(iface.interface) && iface.type_declaration) { - stage->content.body.splice(uniform_insert_point, iface.members.body); - nodes_to_remove.insert(&iface); + if(!iface.instance_name.empty()) + unsupported("ARB_uniform_buffer_object required for interface block instances"); + else if(iface.struct_declaration) + { + stage->content.body.splice(uniform_insert_point, iface.struct_declaration->members.body); + nodes_to_remove.insert(&iface); + nodes_to_remove.insert(iface.struct_declaration); + } + else + /* If the interface block is an array, it should have an instance + name too, so this should never be reached */ + throw logic_error("Unexpected interface block configuration"); } }