X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fglsl%2Fcompatibility.cpp;h=3700a9c9a3379653e661ad0f56799eb454c03c20;hb=041ba4b1acd55337239c5ce24cc310118c621206;hp=128902f3b9f473bb9df87559d40a231c139ac55e;hpb=5c33b56c3b97ca0381ac216a603c7553f4bea499;p=libs%2Fgl.git diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index 128902f3..3700a9c9 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) @@ -150,12 +161,12 @@ void LegacyConverter::visit(VariableReference &var) { var.name = "gl_FragColor"; var.declaration = 0; - type = "vec4"; + r_type = "vec4"; } else if(var.declaration) - type = var.declaration->type; + r_type = var.declaration->type; else - type = string(); + r_type.clear(); } void LegacyConverter::visit(Assignment &assign) @@ -178,12 +189,12 @@ void LegacyConverter::visit(FunctionCall &call) if(call.name=="texture") { string sampler_type; - type = string(); + r_type.clear(); NodeArray::iterator i = call.arguments.begin(); if(i!=call.arguments.end()) { (*i)->visit(*this); - sampler_type = type; + sampler_type = r_type; for(; i!=call.arguments.end(); ++i) (*i)->visit(*this); @@ -274,10 +285,13 @@ 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; - var.layout->qualifiers.erase(i); + if(check_extension(&Features::ext_gpu_shader4)) + { + stage->locations[var.name] = i->value; + var.layout->qualifiers.erase(i); + } + else if(i->value!=0) + unsupported("EXT_gpu_shader4 required for multiple fragment shader outputs"); } if(var.layout->qualifiers.empty()) @@ -327,10 +341,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"); } }