]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/module.cpp
Move backend information into Device
[libs/gl.git] / source / core / module.cpp
index 6d0122c055583d0bafa40f70d6bae08128322514..15bd750cf0b299bd7ea8440ed6d0be5adc3788d1 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/core/algorithm.h>
 #include <msp/io/print.h>
+#include "device.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(create_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(create_features());
        compiler.load_source(io, res, name);
        compile(compiler);
 }
@@ -66,6 +67,20 @@ void Module::load_source(IO::Base &io, const string &name)
        load_source(io, 0, name);
 }
 
+SL::Features Module::create_features() const
+{
+       const DeviceInfo &dev_info = Device::get_current().get_info();
+       const SL::Features &device_features = dev_info.glsl_features;
+       SL::Features latest_features = SL::Features::latest(dev_info.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)
 {