]> git.tdb.fi Git - libs/gl.git/commitdiff
Use specially created features when compiling modules from GLSL
authorMikko Rasa <tdb@tdb.fi>
Mon, 8 Nov 2021 20:18:38 +0000 (22:18 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 8 Nov 2021 20:18:38 +0000 (22:18 +0200)
Set the latest version so all language features are retained, but limit
bindings to what the implementation actually supports.

source/core/module.cpp
source/core/module.h

index 099e8b7fa988c427def61bddaf77ae08f5916978..89d418947f92b1685c9ddd0689d9811612114abd 100644 (file)
@@ -50,14 +50,14 @@ namespace GL {
 
 void Module::set_source(const string &src)
 {
-       SL::Compiler compiler(DeviceInfo::get_global().glsl_features);
+       SL::Compiler compiler(create_features());
        compiler.set_source(src);
        compile(compiler);
 }
 
 void Module::load_source(IO::Base &io, Resources *res, const string &name)
 {
-       SL::Compiler compiler(DeviceInfo::get_global().glsl_features);
+       SL::Compiler compiler(create_features());
        compiler.load_source(io, res, name);
        compile(compiler);
 }
@@ -67,6 +67,19 @@ void Module::load_source(IO::Base &io, const string &name)
        load_source(io, 0, name);
 }
 
+SL::Features Module::create_features() const
+{
+       const SL::Features &device_features = DeviceInfo::get_global().glsl_features;
+       SL::Features latest_features = SL::Features::latest(get_backend_api());
+       SL::Features features;
+       features.target_api = latest_features.target_api;
+       features.glsl_version = latest_features.glsl_version;
+       features.constant_id_range = device_features.constant_id_range;
+       features.uniform_binding_range = device_features.uniform_binding_range;
+       features.texture_binding_range = device_features.texture_binding_range;
+       return features;
+}
+
 
 void GlslModule::compile(SL::Compiler &compiler)
 {
index a480b6139426efaeeb7287566d8bbdc1f2891690..16e07053ea4abd427fac950b0b09da2bb89c6ac9 100644 (file)
@@ -58,6 +58,8 @@ public:
 
 private:
        virtual void compile(SL::Compiler &) = 0;
+
+       SL::Features create_features() const;
 };
 
 /**