From 836eeb313874d4f0c406f154ecb0dff366f362c4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 22 Feb 2021 01:39:30 +0200 Subject: [PATCH] Throw an exception if a feature required by a shader is missing Workarounds are not always available. --- source/glsl/compatibility.cpp | 5 +++-- source/glsl/glsl_error.h | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) 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 -- 2.45.2