[Mesa-dev] [PATCH 2/5] mesa/texformat: add integer fallbacks to other formats

Dave Airlie airlied at gmail.com
Fri Oct 7 12:54:44 PDT 2011


From: Dave Airlie <airlied at redhat.com>

This fixes up the integer format choosing to pick the closest mesa format
then the most likely fallback.

(the formatting in this file needs cleaning in another patch).

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/mesa/main/texformat.c |  204 +++++++++++++++++++++++++++++----------------
 1 files changed, 131 insertions(+), 73 deletions(-)

diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index ccc3c49..7f262d6 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -591,86 +591,144 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
 
    if (ctx->Extensions.EXT_texture_integer) {
       switch (internalFormat) {
-      case GL_RGBA32UI_EXT:
-      case GL_RGB32UI_EXT:
-      case GL_ALPHA32UI_EXT:
-      case GL_INTENSITY32UI_EXT:
-      case GL_LUMINANCE32UI_EXT:
-      case GL_LUMINANCE_ALPHA32UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
-	 break;
-      case GL_RGBA16UI_EXT:
-      case GL_RGB16UI_EXT:
+      case GL_ALPHA8UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+         break;
       case GL_ALPHA16UI_EXT:
-      case GL_INTENSITY16UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+         break;
+      case GL_ALPHA32UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+         break;
+      case GL_ALPHA8I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+         break;
+      case GL_ALPHA16I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+         break;
+      case GL_ALPHA32I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+         break;
+      case GL_LUMINANCE8UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+         break;
       case GL_LUMINANCE16UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+         break;
+      case GL_LUMINANCE32UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+         break;
+      case GL_LUMINANCE8I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+         break;
+      case GL_LUMINANCE16I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+         break;
+      case GL_LUMINANCE32I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+         break;
+      case GL_LUMINANCE_ALPHA8UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+         break;
       case GL_LUMINANCE_ALPHA16UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
-	 break;
-      case GL_RGBA8UI_EXT:
-      case GL_RGB8UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
-	 break;
-      case GL_ALPHA8UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_UINT8);
-	 break;
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+         break;
+      case GL_LUMINANCE_ALPHA32UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+         break;
+      case GL_LUMINANCE_ALPHA8I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+         break;
+      case GL_LUMINANCE_ALPHA16I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+         break;
+      case GL_LUMINANCE_ALPHA32I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+         break;
       case GL_INTENSITY8UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT8);
-	 break;
-      case GL_LUMINANCE8UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_UINT8);
-	 break;
-      case GL_LUMINANCE_ALPHA8UI_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_UINT8);
-	 break;
-      case GL_RGBA32I_EXT:
-      case GL_RGB32I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
-	 break;
-      case GL_ALPHA32I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT32);
-	 break;
+         RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+         break;
+      case GL_INTENSITY16UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+         break;
+      case GL_INTENSITY32UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_UINT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+         break;
+      case GL_INTENSITY8I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+         break;
+      case GL_INTENSITY16I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+         break;
       case GL_INTENSITY32I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT32);
-	 break;
-      case GL_LUMINANCE32I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT32);
-	 break;
-      case GL_LUMINANCE_ALPHA32I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT32);
-	 break;
-      case GL_RGBA16I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+         break;
+      case GL_RGB8UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+         break;
+      case GL_RGB16UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+         break;
+      case GL_RGB32UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UINT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+         break;
+      case GL_RGB8I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT8);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+         break;
       case GL_RGB16I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
-	 break;
-      case GL_ALPHA16I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT16);
-	 break;
-      case GL_INTENSITY16I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT16);
-	 break;
-      case GL_LUMINANCE16I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT16);
-	 break;
-      case GL_LUMINANCE_ALPHA16I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT16);
-	 break;
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT16);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+         break;
+      case GL_RGB32I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_INT32);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+         break;
+      case GL_RGBA8UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8);
+         break;
+      case GL_RGBA16UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16);
+         break;
+      case GL_RGBA32UI_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32);
+         break;
       case GL_RGBA8I_EXT:
-      case GL_RGB8I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
-	 break;
-      case GL_ALPHA8I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_INT8);
-	 break;
-      case GL_INTENSITY8I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_INT8);
-	 break;
-      case GL_LUMINANCE8I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_INT8);
-	 break;
-      case GL_LUMINANCE_ALPHA8I_EXT:
-	 RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_INT8);
-	 break;
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8);
+         break;
+      case GL_RGBA16I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16);
+         break;
+      case GL_RGBA32I_EXT:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32);
+         break;
       }
    }
 
-- 
1.7.6.2



More information about the mesa-dev mailing list