Mesa (master): mesa: refactor floating point texture fbo completeness check on gles

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Sep 8 05:20:55 UTC 2020


Module: Mesa
Branch: master
Commit: 331e5f105eb42862e10f39ea5d702dd55139b887
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=331e5f105eb42862e10f39ea5d702dd55139b887

Author: Tapani Pälli <tapani.palli at intel.com>
Date:   Fri Aug 28 13:04:21 2020 +0300

mesa: refactor floating point texture fbo completeness check on gles

Patch introduces a helper function for checking the completeness and
fixes some of the existing checking in is_format_color_renderable. This
is done as preparation for EXT_color_buffer_half_float support.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6491>

---

 src/mesa/main/fbobject.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index c8735d0459a..23fca13d5cb 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -744,6 +744,23 @@ _mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat)
    }
 }
 
+static GLboolean
+is_float_format(GLenum internalFormat)
+{
+   switch (internalFormat) {
+   case GL_R16F:
+   case GL_RG16F:
+   case GL_RGB16F:
+   case GL_RGBA16F:
+   case GL_R32F:
+   case GL_RG32F:
+   case GL_RGB32F:
+   case GL_RGBA32F:
+      return true;
+   default:
+      return false;
+   }
+}
 
 /**
  * Is the given base format a legal format for a color renderbuffer?
@@ -772,6 +789,15 @@ is_format_color_renderable(const struct gl_context *ctx, mesa_format format,
    case GL_RGBA16_SNORM:
       return _mesa_has_EXT_texture_norm16(ctx) &&
              _mesa_has_EXT_render_snorm(ctx);
+   case GL_R:
+   case GL_RG:
+      return _mesa_has_EXT_texture_rg(ctx);
+   case GL_R16F:
+   case GL_RG16F:
+      return _mesa_is_gles3(ctx);
+   case GL_RGBA16F:
+   case GL_RGBA32F:
+      return _mesa_has_EXT_color_buffer_float(ctx);
    case GL_RGB32F:
    case GL_RGB32I:
    case GL_RGB32UI:
@@ -801,6 +827,42 @@ is_format_color_renderable(const struct gl_context *ctx, mesa_format format,
    return GL_TRUE;
 }
 
+/**
+ * Check that implements various limitations of floating point
+ * rendering extensions on OpenGL ES.
+ *
+ * Check passes if texture format is not floating point or
+ * is floating point and is color renderable.
+ *
+ * Check fails if texture format is floating point and cannot
+ * be rendered to with current context and set of supported
+ * extensions.
+ */
+static GLboolean
+gles_check_float_renderable(const struct gl_context *ctx,
+                            struct gl_renderbuffer_attachment *att)
+{
+   /* Only check floating point texture cases. */
+   if (!att->Texture || !is_float_format(att->Renderbuffer->InternalFormat))
+      return true;
+
+   /* GL_RGBA with unsized GL_FLOAT type, no extension can make this
+    * color renderable.
+    */
+   if (att->Texture->_IsFloat && att->Renderbuffer->_BaseFormat == GL_RGBA)
+      return false;
+
+   /* Unsized GL_HALF_FLOAT supported only with EXT_color_buffer_half_float. */
+   if (att->Texture->_IsHalfFloat)
+      return false;
+
+   const struct gl_texture_object *texObj = att->Texture;
+   const struct gl_texture_image *texImage =
+      texObj->Image[att->CubeMapFace][att->TextureLevel];
+
+   return is_format_color_renderable(ctx, texImage->TexFormat,
+                                     att->Renderbuffer->InternalFormat);
+}
 
 /**
  * Is the given base format a legal format for a depth/stencil renderbuffer?
@@ -907,7 +969,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
           * these textures to be used as a render target, this is done via
           * GL_EXT_color_buffer(_half)_float with set of new sized types.
           */
-         if (_mesa_is_gles(ctx) && (texObj->_IsFloat || texObj->_IsHalfFloat)) {
+         if (_mesa_is_gles(ctx) && !gles_check_float_renderable(ctx, att)) {
             att_incomplete("bad internal format");
             att->Complete = GL_FALSE;
             return;



More information about the mesa-commit mailing list