[Mesa-dev] [RFC 59/63] mesa/formatquery: Add READ_PIXELS_TYPE pname

Eduardo Lima Mitev elima at igalia.com
Tue Jan 19 08:42:39 PST 2016


We call the driver to provide its preferred type, but also provide a
default implementation that selects a generic type based on the passed
internal format.
---
 src/mesa/main/formatquery.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index fc8c10f..0f63259 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -588,6 +588,17 @@ _legal_target_for_framebuffer_texture_layer(struct gl_context *ctx,
    }
 }
 
+static GLenum
+_mesa_generic_type_for_internal_format(GLenum internalFormat)
+{
+   if (_mesa_is_enum_format_unsigned_int(internalFormat))
+      return GL_UNSIGNED_BYTE;
+   else if (_mesa_is_enum_format_signed_int(internalFormat))
+      return GL_BYTE;
+   else
+      return GL_FLOAT;
+}
+
 /* default implementation of QueryInternalFormat driverfunc, for
  * drivers not implementing ARB_internalformat_query2.
  */
@@ -632,6 +643,15 @@ _mesa_query_internal_format_default(struct gl_context *ctx, GLenum target,
       break;
    }
 
+   case GL_READ_PIXELS_TYPE: {
+      GLenum base_format = _mesa_base_tex_format(ctx, internalFormat);
+      if (base_format > 0)
+         params[0] = _mesa_generic_type_for_internal_format(internalFormat);
+      else
+         params[0] = GL_NONE;
+      break;
+   }
+
    case GL_MANUAL_GENERATE_MIPMAP:
    case GL_AUTO_GENERATE_MIPMAP:
    case GL_SRGB_READ:
@@ -1105,14 +1125,11 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
 
    case GL_READ_PIXELS:
    case GL_READ_PIXELS_FORMAT:
+   case GL_READ_PIXELS_TYPE:
       ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname,
                                       buffer);
       break;
 
-   case GL_READ_PIXELS_TYPE:
-      /* @TODO */
-      break;
-
    case GL_TEXTURE_IMAGE_FORMAT:
       /* @TODO */
       break;
-- 
2.5.3



More information about the mesa-dev mailing list