]> git.tdb.fi Git - libs/gl.git/commitdiff
Report incorrect shader stages by name
authorMikko Rasa <tdb@tdb.fi>
Tue, 16 Feb 2021 08:47:14 +0000 (10:47 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 16 Feb 2021 08:47:14 +0000 (10:47 +0200)
source/glsl/parser.cpp
source/glsl/syntax.cpp
source/glsl/syntax.h

index 7f0f8e138629f37ee03c67e2b60a1481e5e5b458..3047e136e288303a5725fcdd2ec1d103b3290c2a 100644 (file)
@@ -78,7 +78,7 @@ void Parser::stage_change(Stage::Type stage)
        if(!allow_stage_change)
                throw invalid_shader_source(tokenizer.get_location(), "Changing stage not allowed here");
        else if(stage<=cur_stage->type)
-               throw invalid_shader_source(tokenizer.get_location(), "Stage '%s' not allowed here", stage);
+               throw invalid_shader_source(tokenizer.get_location(), "Stage '%s' not allowed here", Stage::get_stage_name(stage));
 
        module->stages.push_back(stage);
 
index b0d462a816acc854f881f0cafd7e599953ea64af..affc09adfad7badff8ca65d7e39a4730fc9629be 100644 (file)
@@ -267,6 +267,12 @@ Stage::Stage(Stage::Type t):
        previous(0)
 { }
 
+const char *Stage::get_stage_name(Type type)
+{
+       static const char *names[] = { "shared", "vertex", "geometry", "fragment" };
+       return names[type];
+}
+
 
 Module::Module():
        shared(Stage::SHARED)
index 25b7e4a0450d8d89e940579a87af356a74ee5ac1..ac67a3fb9474dcd202682dd9795f939299750b31 100644 (file)
@@ -380,6 +380,8 @@ struct Stage
        std::vector<const Extension *> required_extensions;
 
        Stage(Type);
+
+       static const char *get_stage_name(Type);
 };
 
 struct Module