From: Mikko Rasa Date: Sun, 21 Feb 2021 23:39:30 +0000 (+0200) Subject: Throw an exception if a feature required by a shader is missing X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=836eeb313874d4f0c406f154ecb0dff366f362c4 Throw an exception if a feature required by a shader is missing Workarounds are not always available. --- diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index 2e13a5f6..34073862 100644 --- a/source/glsl/compatibility.cpp +++ b/source/glsl/compatibility.cpp @@ -2,6 +2,7 @@ #include #include #include "compatibility.h" +#include "glsl_error.h" using namespace std; @@ -259,8 +260,8 @@ void LegacyConverter::visit(VariableDeclaration &var) } else if(stage->type==Stage::FRAGMENT && var.interface=="out") { - if(location!=0) - check_extension(&Features::ext_gpu_shader4); + if(location!=0 && !check_extension(&Features::ext_gpu_shader4)) + throw unsupported_shader("EXT_gpu_shader4 is required"); stage->locations[var.name] = location; var.layout->qualifiers.erase(i); } diff --git a/source/glsl/glsl_error.h b/source/glsl/glsl_error.h index 1ae521ca..46ca49be 100644 --- a/source/glsl/glsl_error.h +++ b/source/glsl/glsl_error.h @@ -37,6 +37,13 @@ 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() { } +}; + } // namespace SL } // namespace GL } // namespace Msp