From: Mikko Rasa Date: Fri, 9 Apr 2021 14:05:47 +0000 (+0300) Subject: Disallow specializing when compiling a module X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cdc2c7176202b4f8d1f3fd21db9c571511b32fa2;p=libs%2Fgl.git Disallow specializing when compiling a module The specialization constants would be ignored anyway, so better be explicit about it. --- diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 7021c62d..b2c4f9ba 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -78,6 +78,9 @@ void Compiler::specialize(const map &sv) void Compiler::compile(Mode mode) { + if(specialized && mode!=PROGRAM) + throw invalid_operation("Compiler::compile"); + for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) generate(*i); ConstantIdAssigner().apply(*module, features); @@ -93,7 +96,7 @@ void Compiler::compile(Mode mode) if(!valid) throw invalid_shader_source(get_diagnostics()); - if(mode==PROGRAM && specialized) + if(specialized) { for(list::iterator i=module->stages.begin(); i!=module->stages.end(); ++i) ConstantSpecializer().apply(*i, spec_values); diff --git a/tools/glslcompiler.cpp b/tools/glslcompiler.cpp index 7af8c80b..a1eb1a1f 100644 --- a/tools/glslcompiler.cpp +++ b/tools/glslcompiler.cpp @@ -74,6 +74,8 @@ GlslCompiler::GlslCompiler(int argc, char **argv): else if(!dump_ast) combined = true; + if(!spec_values_in.empty() && as_module) + throw usage_error("Modules can't be specialized"); for(vector::const_iterator i=spec_values_in.begin(); i!=spec_values_in.end(); ++i) { unsigned colon = i->find(':');