From: Mikko Rasa Date: Tue, 16 Feb 2021 08:47:14 +0000 (+0200) Subject: Report incorrect shader stages by name X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2b87464682733c875966c1aa3b3369efbd60b310;p=libs%2Fgl.git Report incorrect shader stages by name --- diff --git a/source/glsl/parser.cpp b/source/glsl/parser.cpp index 7f0f8e13..3047e136 100644 --- a/source/glsl/parser.cpp +++ b/source/glsl/parser.cpp @@ -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); diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index b0d462a8..affc09ad 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -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) diff --git a/source/glsl/syntax.h b/source/glsl/syntax.h index 25b7e4a0..ac67a3fb 100644 --- a/source/glsl/syntax.h +++ b/source/glsl/syntax.h @@ -380,6 +380,8 @@ struct Stage std::vector required_extensions; Stage(Type); + + static const char *get_stage_name(Type); }; struct Module