]> git.tdb.fi Git - libs/gl.git/commitdiff
Throw an exception if a feature required by a shader is missing
authorMikko Rasa <tdb@tdb.fi>
Sun, 21 Feb 2021 23:39:30 +0000 (01:39 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Feb 2021 23:53:20 +0000 (01:53 +0200)
Workarounds are not always available.

source/glsl/compatibility.cpp
source/glsl/glsl_error.h

index 2e13a5f678eaa7592809fa292071b89cecf28beb..3407386248210035c8a6dee75fee815a9987696f 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/core/raii.h>
 #include <msp/strings/lexicalcast.h>
 #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);
                        }
index 1ae521cae8b05a9085a5195ab2182104e28ffe3f..46ca49be35daf98062a9cff156426fde9882eb6b 100644 (file)
@@ -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