]> git.tdb.fi Git - libs/gl.git/commitdiff
Make the Limits struct more robust
authorMikko Rasa <tdb@tdb.fi>
Sat, 30 Oct 2021 20:29:48 +0000 (23:29 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 30 Oct 2021 22:28:13 +0000 (01:28 +0300)
source/backends/opengl/deviceinfo_backend.cpp
source/core/deviceinfo.h

index 7e1f3f48390d2f603d3896d3733ddbee12a93acc..30eeb0327e9cb1c8b61f210a742f9ac376886d42 100644 (file)
@@ -6,6 +6,7 @@
 #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_framebuffer_object.h>
 #include <msp/gl/extensions/ext_gpu_shader4.h>
 #include <msp/gl/extensions/ext_texture_array.h>
 #include <msp/gl/extensions/msp_clipping.h>
@@ -18,13 +19,21 @@ namespace GL {
 
 Limits::Limits()
 {
-       glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast<int *>(&max_vertex_attributes));
-       glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast<int *>(&max_texture_bindings));
-       glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast<int *>(&max_uniform_bindings));
        glGetIntegerv(GL_MAX_CLIP_PLANES, reinterpret_cast<int *>(&max_clip_planes));
-       glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast<int *>(&max_samples));
-       glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast<int *>(&uniform_buffer_alignment));
-       glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast<int *>(&max_color_attachments));
+       if(ARB_vertex_shader)
+       {
+               glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast<int *>(&max_vertex_attributes));
+               glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast<int *>(&max_texture_bindings));
+       }
+       if(EXT_framebuffer_object)
+               glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast<int *>(&max_color_attachments));
+       if(EXT_framebuffer_multisample)
+               glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast<int *>(&max_samples));
+       if(ARB_uniform_buffer_object)
+       {
+               glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast<int *>(&max_uniform_bindings));
+               glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast<int *>(&uniform_buffer_alignment));
+       }
 }
 
 
index e121a8cac2c7b65d74af87d085f262ce4a42791e..6ac75ca18c758caaa3b2038a8348f7ded74993e4 100644 (file)
@@ -11,13 +11,13 @@ Contains information about various limits imposed by the graphics device.
 */
 struct Limits
 {
-       unsigned max_vertex_attributes;
-       unsigned max_texture_bindings;
-       unsigned max_uniform_bindings;
-       unsigned max_clip_planes;
-       unsigned max_samples;
-       unsigned uniform_buffer_alignment;
-       unsigned max_color_attachments;
+       unsigned max_clip_planes = 6;
+       unsigned max_vertex_attributes = 16;
+       unsigned max_texture_bindings = 16;
+       unsigned max_color_attachments = 8;
+       unsigned max_samples = 4;
+       unsigned max_uniform_bindings = 24;
+       unsigned uniform_buffer_alignment = 256;
 
        Limits();
 };