From b482f6d59aca2b4f1d9e2cbcc0f596d62c057509 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 22 Feb 2021 01:50:19 +0200 Subject: [PATCH] Check that requested shader stages are supported --- source/glsl/compatibility.cpp | 15 +++++++++++++++ source/glsl/compatibility.h | 1 + 2 files changed, 16 insertions(+) diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index 34073862..07698394 100644 --- a/source/glsl/compatibility.cpp +++ b/source/glsl/compatibility.cpp @@ -88,6 +88,8 @@ 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))); visit(s.content); } @@ -121,6 +123,19 @@ bool LegacyConverter::check_extension(bool Features::*extension) const return true; } +bool LegacyConverter::supports_stage(Stage::Type st) const +{ + if(st==Stage::GEOMETRY) + { + if(features.gl_api==OPENGL_ES2) + return check_version(Version(3, 20)); + else + return check_version(Version(1, 50)); + } + else + return true; +} + bool LegacyConverter::supports_unified_interface_syntax() const { if(features.gl_api==OPENGL_ES2) diff --git a/source/glsl/compatibility.h b/source/glsl/compatibility.h index d3a3a74c..f91f1882 100644 --- a/source/glsl/compatibility.h +++ b/source/glsl/compatibility.h @@ -60,6 +60,7 @@ private: virtual void visit(Block &); bool check_version(const Version &) const; bool check_extension(bool Features::*) const; + bool supports_stage(Stage::Type) const; bool supports_unified_interface_syntax() const; virtual void visit(VariableReference &); virtual void visit(Assignment &); -- 2.43.0