Mesa (master): mesa: Add fall-back formats for unsupported snorm formats

Ian Romanick idr at kemper.freedesktop.org
Mon Apr 4 15:20:57 PDT 2011


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sat Apr  2 18:56:33 2011 -0700

mesa: Add fall-back formats for unsupported snorm formats

This is always the way with real hardware and desktop OpenGL.  Some
hardware can't do some formats natively.  The alpha-only, luminance,
and intensity formats are usually the most problematic.  Some sized
formats can also be problematic.  This patch provides fall-back
formats for those that are not natively supported.

At some point it would be interesting to try providing
device-independent conversions using EXT_texture_swizzle.  The drivers
that support EXT_texture_swizzle could, for example, see
GL_LUMINANCE16_SNORM as MESA_FORMAT_SIGNED_R16 with a { r, r, r, 1 }
swizzle.  Care would need to be taken to prevent issues with using
those textures for FBO rendering.

This is the rest of the fix for glean's pixelFormats test on i965.

Reviewed-by: Marek Olšák <maraeo at gmail.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/main/texformat.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 8b7b4ff..da90745 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -402,7 +402,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
          case GL_RGB_SNORM:
          case GL_RGB8_SNORM:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBX8888);
-	    break;
+	    /* FALLTHROUGH */
          case GL_RGBA_SNORM:
          case GL_RGBA8_SNORM:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
@@ -411,18 +411,27 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
          case GL_ALPHA_SNORM:
          case GL_ALPHA8_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_A8);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          case GL_LUMINANCE_SNORM:
          case GL_LUMINANCE8_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_L8);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBX8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          case GL_LUMINANCE_ALPHA_SNORM:
          case GL_LUMINANCE8_ALPHA8_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_AL88);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          case GL_INTENSITY_SNORM:
          case GL_INTENSITY8_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_I8);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          case GL_R16_SNORM:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_R16);
@@ -432,21 +441,32 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
 	    break;
          case GL_RGB16_SNORM:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGB_16);
-	    break;
+	    /* FALLTHROUGH */
          case GL_RGBA16_SNORM:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA_16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
 	    break;
          case GL_ALPHA16_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_A16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA_16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          case GL_LUMINANCE16_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_L16);
-            break;
+	    /* FALLTHROUGH */
          case GL_LUMINANCE16_ALPHA16_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_AL1616);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA_16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          case GL_INTENSITY16_SNORM:
             RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_I16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA_16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV);
             break;
          default:
             ; /* fall-through */



More information about the mesa-commit mailing list