]> git.tdb.fi Git - libs/gl.git/commitdiff
Wrap Limits into a DeviceInfo struct
authorMikko Rasa <tdb@tdb.fi>
Thu, 30 Sep 2021 18:24:32 +0000 (21:24 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 30 Sep 2021 21:07:07 +0000 (00:07 +0300)
This allows adding more types of information.

source/builders/sequencebuilder.cpp
source/core/clipping.cpp
source/core/deviceinfo.cpp
source/core/deviceinfo.h
source/core/pipelinestate.cpp
source/core/texture2dmultisample.cpp
source/core/uniformblock.cpp
source/core/vertexsetup.cpp
source/glsl/features.cpp

index a614a836a5c4d15ee52770f4861e7063ed7fe1e1..45d4f873b1e03a486bca93e4264028fb09cf66ec 100644 (file)
@@ -125,7 +125,7 @@ Sequence *SequenceBuilder::build(const Framebuffer &fbo) const
 
 FrameFormat SequenceBuilder::create_frame_format() const
 {
-       unsigned samples = min(tmpl.get_maximum_multisample(), Limits::get_global().max_samples);
+       unsigned samples = min(tmpl.get_maximum_multisample(), DeviceInfo::get_global().limits.max_samples);
        if(samples<tmpl.get_required_multisample())
                throw invalid_operation("SequenceBuilder::create_frame_format");
 
index c278942361865657a2dfd663f93c3ce0a04c2371..30d1f7c2db7dfeff09701f422baf9af2cc02526e 100644 (file)
@@ -13,7 +13,7 @@ void Clipping::attach(const ClipPlane &p)
 {
        if(find_member(planes, &p, &AttachedPlane::plane)!=planes.end())
                return;
-       if(planes.size()>=Limits::get_global().max_clip_planes)
+       if(planes.size()>=DeviceInfo::get_global().limits.max_clip_planes)
                throw invalid_operation("Clipping::attach");
 
        planes.push_back(&p);
index acbd0a73e7eeb1e44831860729af262fca065987..f91e44a9cdd32bbbba061f9478e38274b92e3eca 100644 (file)
@@ -20,10 +20,11 @@ Limits::Limits()
        glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast<int *>(&max_color_attachments));
 }
 
-const Limits &Limits::get_global()
+
+const DeviceInfo &DeviceInfo::get_global()
 {
-       static Limits limits;
-       return limits;
+       static DeviceInfo info;
+       return info;
 }
 
 } // namespace GL
index 1eb120ff2ec509921ed2dfa84fbcbce92393953d..6f20854409a52439031546993ba14b1ae3b58ec3 100644 (file)
@@ -15,8 +15,15 @@ struct Limits
        unsigned max_color_attachments;
 
        Limits();
+};
+
+struct DeviceInfo
+{
+       Limits limits;
+
+       DeviceInfo();
 
-       static const Limits &get_global();
+       static const DeviceInfo &get_global();
 };
 
 } // namespace GL
index d99a387857ae9c9a2efd63221a2ab6f4374c7f62..97f353dcee8b572c835e1ac5569ca9769489b246 100644 (file)
@@ -46,9 +46,9 @@ PipelineState::PipelineState():
        changes(0)
 {
        if(bound_tex_targets.empty())
-               bound_tex_targets.resize(Limits::get_global().max_texture_bindings);
+               bound_tex_targets.resize(DeviceInfo::get_global().limits.max_texture_bindings);
        if(bound_uniform_blocks.empty())
-               bound_uniform_blocks.resize(Limits::get_global().max_uniform_bindings);
+               bound_uniform_blocks.resize(DeviceInfo::get_global().limits.max_uniform_bindings);
 }
 
 PipelineState::~PipelineState()
@@ -228,7 +228,7 @@ void PipelineState::apply(unsigned mask) const
 
        if(mask&CLIP_PLANES)
        {
-               unsigned max_clip_planes = Limits::get_global().max_clip_planes;
+               unsigned max_clip_planes = DeviceInfo::get_global().limits.max_clip_planes;
                for(unsigned i=0; i<max_clip_planes; ++i)
                {
                        if((enabled_clip_planes>>i)&1)
@@ -338,7 +338,7 @@ void PipelineState::clear()
                glUseProgram(0);
                glBindVertexArray(0);
 
-               unsigned max_clip_planes = Limits::get_global().max_clip_planes;
+               unsigned max_clip_planes = DeviceInfo::get_global().limits.max_clip_planes;
                for(unsigned i=0; i<max_clip_planes; ++i)
                        if((last_applied->enabled_clip_planes>>i)&1)
                                glDisable(GL_CLIP_PLANE0+i);
index 85fa19504ed65638d76204242d2dea102020c8b3..782a55694961e55a979ba772c5f28c5e766f5a51 100644 (file)
@@ -28,7 +28,7 @@ void Texture2DMultisample::storage(PixelFormat fmt, unsigned wd, unsigned ht, un
        }
        if(wd==0 || ht==0)
                throw invalid_argument("Texture2DMultisample::storage");
-       if(!sm || sm>Limits::get_global().max_samples)
+       if(!sm || sm>DeviceInfo::get_global().limits.max_samples)
                throw invalid_argument("Texture2DMultisample::storage");
 
        set_format(fmt);
index 76d657a10456a895539ddeef2246aa09a91d702a..b06ddf926a0f3a34159ed9a2b7921a1ad708d018 100644 (file)
@@ -19,7 +19,7 @@ UniformBlock::UniformBlock(const ReflectData::UniformBlockInfo &info):
 
 unsigned UniformBlock::get_alignment() const
 {
-       return Limits::get_global().uniform_buffer_alignment;
+       return DeviceInfo::get_global().limits.uniform_buffer_alignment;
 }
 
 void UniformBlock::store(const ReflectData::UniformInfo &info, unsigned array_size, const void *value)
index f73e288984fa815fd440cff68a3187ecb02e44d0..55424d6caf41eb9979f2de294547cf7f13fd210a 100644 (file)
@@ -102,7 +102,7 @@ bool VertexSetup::verify_format(const VertexFormat &fmt)
        if(fmt.empty())
                return false;
 
-       unsigned max_attribs = Limits::get_global().max_vertex_attributes;
+       unsigned max_attribs = DeviceInfo::get_global().limits.max_vertex_attributes;
 
        for(VertexAttribute a: fmt)
                if(get_attribute_semantic(a)>=max_attribs)
index db213e833deea22b250768e5cb81791fddd2be39..3c44c11bba94b47c389c99cdeb5b5546ae8e6417 100644 (file)
@@ -41,7 +41,7 @@ Features Features::from_context()
        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 = Limits::get_global();
+       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;