]> git.tdb.fi Git - libs/gl.git/commitdiff
Check supported attachment formats in Framebuffer::set_format
authorMikko Rasa <tdb@tdb.fi>
Sun, 19 Sep 2021 10:37:13 +0000 (13:37 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 19 Sep 2021 10:37:13 +0000 (13:37 +0300)
extensions/arb_internalformat_query.glext [new file with mode: 0644]
extensions/arb_internalformat_query2.glext [new file with mode: 0644]
source/core/framebuffer.cpp

diff --git a/extensions/arb_internalformat_query.glext b/extensions/arb_internalformat_query.glext
new file mode 100644 (file)
index 0000000..6e8d5fc
--- /dev/null
@@ -0,0 +1 @@
+extension ARB_internalformat_query
diff --git a/extensions/arb_internalformat_query2.glext b/extensions/arb_internalformat_query2.glext
new file mode 100644 (file)
index 0000000..d02bc6a
--- /dev/null
@@ -0,0 +1,22 @@
+extension ARB_internalformat_query2
+# Some of the constants are only defined in conjunction of other extensions
+ignore GL_SRGB_DECODE_ARB
+ignore GL_VIEW_CLASS_EAC_R11
+ignore GL_VIEW_CLASS_EAC_RG11
+ignore GL_VIEW_CLASS_ETC2_RGB
+ignore GL_VIEW_CLASS_ETC2_RGBA
+ignore GL_VIEW_CLASS_ETC2_EAC_RGBA
+ignore GL_VIEW_CLASS_ASTC_4x4_RGBA
+ignore GL_VIEW_CLASS_ASTC_5x4_RGBA
+ignore GL_VIEW_CLASS_ASTC_5x5_RGBA
+ignore GL_VIEW_CLASS_ASTC_6x5_RGBA
+ignore GL_VIEW_CLASS_ASTC_6x6_RGBA
+ignore GL_VIEW_CLASS_ASTC_8x5_RGBA
+ignore GL_VIEW_CLASS_ASTC_8x6_RGBA
+ignore GL_VIEW_CLASS_ASTC_8x8_RGBA
+ignore GL_VIEW_CLASS_ASTC_10x5_RGBA
+ignore GL_VIEW_CLASS_ASTC_10x6_RGBA
+ignore GL_VIEW_CLASS_ASTC_10x8_RGBA
+ignore GL_VIEW_CLASS_ASTC_10x10_RGBA
+ignore GL_VIEW_CLASS_ASTC_12x10_RGBA
+ignore GL_VIEW_CLASS_ASTC_12x12_RGBA
index ffd92a22f8329e05b2c604802d05467a3065f555..1dd2f61f9bab10139772b8619075370df41b2849 100644 (file)
@@ -1,5 +1,7 @@
 #include <msp/gl/extensions/arb_draw_buffers.h>
 #include <msp/gl/extensions/arb_direct_state_access.h>
+#include <msp/gl/extensions/arb_internalformat_query.h>
+#include <msp/gl/extensions/arb_internalformat_query2.h>
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/ext_texture_array.h>
 #include <msp/gl/extensions/ext_texture3d.h>
@@ -83,6 +85,19 @@ void Framebuffer::set_format(const FrameFormat &fmt)
        if(fmt.empty())
                throw invalid_argument("Framebuffer::set_format");
 
+       if(ARB_internalformat_query && ARB_internalformat_query2)
+       {
+               unsigned target = (fmt.get_samples()>1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D);
+               for(FrameAttachment a: fmt)
+               {
+                       unsigned pf = get_gl_pixelformat(get_attachment_pixelformat(a));
+                       int supported = 0;
+                       glGetInternalformativ(target, pf, GL_FRAMEBUFFER_RENDERABLE, 1, &supported);
+                       if(supported!=GL_FULL_SUPPORT)
+                               throw invalid_argument("Framebuffer::set_format");
+               }
+       }
+
        format = fmt;
        attachments.resize(format.size());
 }