From c288e8d074f303f275ce03bf09c8799b2c8fde6e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 8 Mar 2021 00:14:55 +0200 Subject: [PATCH] Report unsupported shader errors through the diagnostic mechanism --- source/glsl/compatibility.cpp | 28 +++++++++++++++++++++------- source/glsl/compatibility.h | 2 ++ source/glsl/glsl_error.h | 7 ------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index 9ed0d20c..55fa30d9 100644 --- a/source/glsl/compatibility.cpp +++ b/source/glsl/compatibility.cpp @@ -88,9 +88,20 @@ void LegacyConverter::apply(Stage &s, const Features &feat) { stage = &s; features = feat; - if(!supports_stage(s.type)) - throw unsupported_shader(format("Stage %s is not supported", Stage::get_stage_name(s.type))); - s.content.visit(*this); + if(supports_stage(s.type)) + s.content.visit(*this); + else + unsupported(format("Stage %s is not supported", Stage::get_stage_name(s.type))); +} + +void LegacyConverter::unsupported(const string &reason) +{ + Diagnostic diagnostic; + diagnostic.severity = Diagnostic::ERR; + diagnostic.source = GENERATED_SOURCE; + diagnostic.line = 0; + diagnostic.message = reason; + stage->diagnostics.push_back(diagnostic); } void LegacyConverter::visit(Block &block) @@ -274,10 +285,13 @@ void LegacyConverter::visit(VariableDeclaration &var) } else if(stage->type==Stage::FRAGMENT && var.interface=="out") { - if(i->value!=0 && !check_extension(&Features::ext_gpu_shader4)) - throw unsupported_shader("EXT_gpu_shader4 is required"); - stage->locations[var.name] = i->value; - var.layout->qualifiers.erase(i); + if(check_extension(&Features::ext_gpu_shader4)) + { + stage->locations[var.name] = i->value; + var.layout->qualifiers.erase(i); + } + else if(i->value!=0) + unsupported("EXT_gpu_shader4 required for multiple fragment shader outputs"); } if(var.layout->qualifiers.empty()) diff --git a/source/glsl/compatibility.h b/source/glsl/compatibility.h index c30dce8c..21200713 100644 --- a/source/glsl/compatibility.h +++ b/source/glsl/compatibility.h @@ -61,6 +61,8 @@ public: virtual void apply(Stage &, const Features &); private: + void unsupported(const std::string &); + virtual void visit(Block &); bool check_version(const Version &) const; bool check_extension(bool Features::*) const; diff --git a/source/glsl/glsl_error.h b/source/glsl/glsl_error.h index 1fd7169c..46854744 100644 --- a/source/glsl/glsl_error.h +++ b/source/glsl/glsl_error.h @@ -38,13 +38,6 @@ public: virtual ~parse_error() throw() { } }; -class unsupported_shader: public std::runtime_error -{ -public: - unsupported_shader(const std::string &w): runtime_error(w) { } - virtual ~unsupported_shader() throw() { } -}; - struct Diagnostic { enum Severity -- 2.43.0