]> git.tdb.fi Git - libs/gl.git/commitdiff
Store GLSL features in DeviceInfo
authorMikko Rasa <tdb@tdb.fi>
Thu, 30 Sep 2021 20:57:16 +0000 (23:57 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 30 Sep 2021 21:07:07 +0000 (00:07 +0300)
This makes the GLSL compiler independent of any OpenGL-specific code.

source/core/deviceinfo.cpp
source/core/deviceinfo.h
source/glsl/compiler.cpp
source/glsl/features.cpp
source/glsl/features.h

index f91e44a9cdd32bbbba061f9478e38274b92e3eca..1526af36744d195690511737b7dc4fdfed1e02eb 100644 (file)
@@ -1,6 +1,13 @@
+#include <msp/gl/extensions/arb_enhanced_layouts.h>
+#include <msp/gl/extensions/arb_explicit_attrib_location.h>
+#include <msp/gl/extensions/arb_explicit_uniform_location.h>
+#include <msp/gl/extensions/arb_gpu_shader5.h>
+#include <msp/gl/extensions/arb_separate_shader_objects.h>
 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <msp/gl/extensions/ext_framebuffer_multisample.h>
+#include <msp/gl/extensions/ext_gpu_shader4.h>
+#include <msp/gl/extensions/ext_texture_array.h>
 #include <msp/gl/extensions/msp_clipping.h>
 #include <msp/gl/extensions/nv_fbo_color_attachments.h>
 #include "deviceinfo.h"
@@ -21,6 +28,22 @@ Limits::Limits()
 }
 
 
+DeviceInfo::DeviceInfo()
+{
+       glsl_features.gl_api = get_gl_api();
+       glsl_features.glsl_version = get_glsl_version();
+       glsl_features.arb_enhanced_layouts = ARB_enhanced_layouts;
+       glsl_features.arb_explicit_attrib_location = ARB_explicit_attrib_location;
+       glsl_features.arb_explicit_uniform_location = ARB_explicit_uniform_location;
+       glsl_features.arb_gpu_shader5 = ARB_gpu_shader5;
+       glsl_features.arb_separate_shader_objects = ARB_separate_shader_objects;
+       glsl_features.arb_uniform_buffer_object = ARB_uniform_buffer_object;
+       glsl_features.ext_gpu_shader4 = EXT_gpu_shader4;
+       glsl_features.ext_texture_array = EXT_texture_array;
+       glsl_features.uniform_binding_range = limits.max_uniform_bindings;
+       glsl_features.texture_binding_range = limits.max_texture_bindings;
+}
+
 const DeviceInfo &DeviceInfo::get_global()
 {
        static DeviceInfo info;
index 6f20854409a52439031546993ba14b1ae3b58ec3..8550d85ff75f35061e5c5c8c7f7dbe371d2c24b2 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef MSP_GL_DEVICEINFO_H_
 #define MSP_GL_DEVICEINFO_H_
 
+#include "glsl/features.h"
+
 namespace Msp {
 namespace GL {
 
@@ -20,6 +22,7 @@ struct Limits
 struct DeviceInfo
 {
        Limits limits;
+       SL::Features glsl_features;
 
        DeviceInfo();
 
index 8d96cc4270b5b1566f75e37f26e1e35fa04c0352..233e37ea33727814042069dd7df2b068abed7670 100644 (file)
@@ -4,6 +4,7 @@
 #include "builtin.h"
 #include "compiler.h"
 #include "debug.h"
+#include "deviceinfo.h"
 #include "error.h"
 #include "finalize.h"
 #include "generate.h"
@@ -24,7 +25,7 @@ namespace GL {
 namespace SL {
 
 Compiler::Compiler():
-       features(Features::from_context()),
+       features(DeviceInfo::get_global().glsl_features),
        module(0),
        compiled(false),
        specialized(false)
index 3c44c11bba94b47c389c99cdeb5b5546ae8e6417..78233bfcf48a3ff884bac0344b464c3e7ca17a33 100644 (file)
@@ -1,12 +1,3 @@
-#include <msp/gl/deviceinfo.h>
-#include <msp/gl/extensions/arb_enhanced_layouts.h>
-#include <msp/gl/extensions/arb_explicit_attrib_location.h>
-#include <msp/gl/extensions/arb_explicit_uniform_location.h>
-#include <msp/gl/extensions/arb_gpu_shader5.h>
-#include <msp/gl/extensions/arb_separate_shader_objects.h>
-#include <msp/gl/extensions/arb_uniform_buffer_object.h>
-#include <msp/gl/extensions/ext_gpu_shader4.h>
-#include <msp/gl/extensions/ext_texture_array.h>
 #include "features.h"
 
 namespace Msp {
@@ -28,25 +19,6 @@ Features::Features():
        texture_binding_range(96)
 { }
 
-Features Features::from_context()
-{
-       Features features;
-       features.gl_api = get_gl_api();
-       features.glsl_version = get_glsl_version();
-       features.arb_enhanced_layouts = ARB_enhanced_layouts;
-       features.arb_explicit_attrib_location = ARB_explicit_attrib_location;
-       features.arb_explicit_uniform_location = ARB_explicit_uniform_location;
-       features.arb_gpu_shader5 = ARB_gpu_shader5;
-       features.arb_separate_shader_objects = ARB_separate_shader_objects;
-       features.arb_uniform_buffer_object = ARB_uniform_buffer_object;
-       features.ext_gpu_shader4 = EXT_gpu_shader4;
-       features.ext_texture_array = EXT_texture_array;
-       const Limits &limits = DeviceInfo::get_global().limits;
-       features.uniform_binding_range = limits.max_uniform_bindings;
-       features.texture_binding_range = limits.max_texture_bindings;
-       return features;
-}
-
 Features Features::from_version(const Version &ver)
 {
        Features features;
index f8be0131462d1aded0bc16dc29b857e9a6131d92..8aee02caa64daf63bef8aa926bcb74c33fb50569 100644 (file)
@@ -25,7 +25,6 @@ struct Features
 
        Features();
 
-       static Features from_context();
        static Features from_version(const Version &);
        static Features latest();
 };