From 8e553af57b712051f47293c971671f4f6a939be2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 30 Sep 2021 23:57:16 +0300 Subject: [PATCH] Store GLSL features in DeviceInfo This makes the GLSL compiler independent of any OpenGL-specific code. --- source/core/deviceinfo.cpp | 23 +++++++++++++++++++++++ source/core/deviceinfo.h | 3 +++ source/glsl/compiler.cpp | 3 ++- source/glsl/features.cpp | 28 ---------------------------- source/glsl/features.h | 1 - 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/source/core/deviceinfo.cpp b/source/core/deviceinfo.cpp index f91e44a9..1526af36 100644 --- a/source/core/deviceinfo.cpp +++ b/source/core/deviceinfo.cpp @@ -1,6 +1,13 @@ +#include +#include +#include +#include +#include #include #include #include +#include +#include #include #include #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; diff --git a/source/core/deviceinfo.h b/source/core/deviceinfo.h index 6f208544..8550d85f 100644 --- a/source/core/deviceinfo.h +++ b/source/core/deviceinfo.h @@ -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(); diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 8d96cc42..233e37ea 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -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) diff --git a/source/glsl/features.cpp b/source/glsl/features.cpp index 3c44c11b..78233bfc 100644 --- a/source/glsl/features.cpp +++ b/source/glsl/features.cpp @@ -1,12 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include #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; diff --git a/source/glsl/features.h b/source/glsl/features.h index f8be0131..8aee02ca 100644 --- a/source/glsl/features.h +++ b/source/glsl/features.h @@ -25,7 +25,6 @@ struct Features Features(); - static Features from_context(); static Features from_version(const Version &); static Features latest(); }; -- 2.43.0