From: Mikko Rasa Date: Mon, 8 Nov 2021 19:50:00 +0000 (+0200) Subject: Require passing features to SL::Compiler constructor X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4b05add0a40cc7503b9dc7ff3b15844b02f51e16;p=libs%2Fgl.git Require passing features to SL::Compiler constructor Using the current context's features by default seems like it could lead to some surprises down the road. --- diff --git a/source/backends/opengl/program_backend.cpp b/source/backends/opengl/program_backend.cpp index 1fc8c442..32c6d6e1 100644 --- a/source/backends/opengl/program_backend.cpp +++ b/source/backends/opengl/program_backend.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "deviceinfo.h" #include "error.h" #include "program.h" #include "program_backend.h" @@ -89,7 +90,7 @@ unsigned OpenGLProgram::add_stage(Stage type) void OpenGLProgram::add_glsl_stages(const GlslModule &mod, const map &spec_values, TransientData &transient) { - SL::Compiler compiler; + SL::Compiler compiler(DeviceInfo::get_global().glsl_features); compiler.set_source(mod.get_prepared_source(), ""); compiler.specialize(spec_values); compiler.compile(SL::Compiler::PROGRAM); diff --git a/source/core/module.cpp b/source/core/module.cpp index 6d0122c0..099e8b7f 100644 --- a/source/core/module.cpp +++ b/source/core/module.cpp @@ -1,5 +1,6 @@ #include #include +#include "deviceinfo.h" #include "module.h" #include "resources.h" @@ -49,14 +50,14 @@ namespace GL { void Module::set_source(const string &src) { - SL::Compiler compiler; + SL::Compiler compiler(DeviceInfo::get_global().glsl_features); compiler.set_source(src); compile(compiler); } void Module::load_source(IO::Base &io, Resources *res, const string &name) { - SL::Compiler compiler; + SL::Compiler compiler(DeviceInfo::get_global().glsl_features); compiler.load_source(io, res, name); compile(compiler); } diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 9ddafcff..3f259350 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -4,7 +4,6 @@ #include "builtin.h" #include "compiler.h" #include "debug.h" -#include "deviceinfo.h" #include "error.h" #include "finalize.h" #include "generate.h" @@ -24,10 +23,6 @@ namespace Msp { namespace GL { namespace SL { -Compiler::Compiler(): - features(DeviceInfo::get_global().glsl_features) -{ } - Compiler::Compiler(const Features &f): features(f) { } diff --git a/source/glsl/compiler.h b/source/glsl/compiler.h index 9d839745..52076e69 100644 --- a/source/glsl/compiler.h +++ b/source/glsl/compiler.h @@ -47,9 +47,6 @@ private: std::map spec_values; public: - /** Creates a compiler using features from the current OpenGL context. */ - Compiler(); - /** Creates a compiler targeting a specific set of features. */ Compiler(const Features &);