From 6b8964acf71c4673ac65e99739aef167c9daf8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 18 May 2015 14:35:05 -0700 Subject: [PATCH] GL: Added image format test. --- src/renderer_gl.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index cf7a888f..7d0a0608 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -970,7 +970,7 @@ namespace bgfx { namespace gl } } - bool isTextureFormatValid(TextureFormat::Enum _format, bool srgb = false) + static bool isTextureFormatValid(TextureFormat::Enum _format, bool srgb = false) { const TextureFormatInfo& tfi = s_textureFormat[_format]; GLenum internalFmt = srgb @@ -985,7 +985,6 @@ namespace bgfx { namespace gl GLuint id; GL_CHECK(glGenTextures(1, &id) ); GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) ); - initTestTexture(_format); GLenum err = glGetError(); @@ -996,7 +995,34 @@ namespace bgfx { namespace gl return 0 == err; } - bool isFramebufferFormatValid(TextureFormat::Enum _format, bool srgb = false) + static bool isImageFormatValid(TextureFormat::Enum _format) + { + if (GL_ZERO == s_imageFormat[_format]) + { + return false; + } + + GLuint id; + GL_CHECK(glGenTextures(1, &id) ); + GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) ); + initTestTexture(_format); + + glBindImageTexture(0 + , id + , 0 + , GL_FALSE + , 0 + , GL_READ_WRITE + , s_imageFormat[_format] + ); + GLenum err = glGetError(); + + GL_CHECK(glDeleteTextures(1, &id) ); + + return 0 == err; + } + + static bool isFramebufferFormatValid(TextureFormat::Enum _format, bool srgb = false) { const TextureFormatInfo& tfi = s_textureFormat[_format]; GLenum internalFmt = srgb @@ -1468,7 +1494,7 @@ namespace bgfx { namespace gl ; supported |= computeSupport - && GL_ZERO != s_imageFormat[ii] + && isImageFormatValid(TextureFormat::Enum(ii) ) ? BGFX_CAPS_FORMAT_TEXTURE_IMAGE : BGFX_CAPS_FORMAT_TEXTURE_NONE ;