From 2b87464682733c875966c1aa3b3369efbd60b310 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 16 Feb 2021 10:47:14 +0200 Subject: [PATCH] Report incorrect shader stages by name --- source/glsl/parser.cpp | 2 +- source/glsl/syntax.cpp | 6 ++++++ source/glsl/syntax.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) 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 -- 2.45.2