]> git.tdb.fi Git - libs/gl.git/commitdiff
Disallow specializing when compiling a module
authorMikko Rasa <tdb@tdb.fi>
Fri, 9 Apr 2021 14:05:47 +0000 (17:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 9 Apr 2021 14:45:42 +0000 (17:45 +0300)
The specialization constants would be ignored anyway, so better be
explicit about it.

source/glsl/compiler.cpp
tools/glslcompiler.cpp

index 7021c62d9a2949c9459e6fa183955829bf04f469..b2c4f9ba2cbed88dee8b4e70f00d8a6c4afb5739 100644 (file)
@@ -78,6 +78,9 @@ void Compiler::specialize(const map<string, int> &sv)
 
 void Compiler::compile(Mode mode)
 {
+       if(specialized && mode!=PROGRAM)
+               throw invalid_operation("Compiler::compile");
+
        for(list<Stage>::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<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
                        ConstantSpecializer().apply(*i, spec_values);
index 7af8c80bcf78cc5852b38a3f9d573cd4a976144d..a1eb1a1fa4d87ddd77c71c47acb0fca563c5b309 100644 (file)
@@ -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<string>::const_iterator i=spec_values_in.begin(); i!=spec_values_in.end(); ++i)
        {
                unsigned colon = i->find(':');