Mesa (master): mesa: Add ChooseTexFormat fallbacks for floating point textures.

Eric Anholt anholt at kemper.freedesktop.org
Wed Apr 20 10:51:23 PDT 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Apr 15 14:18:43 2011 -0700

mesa: Add ChooseTexFormat fallbacks for floating point textures.

This covers X_FLOAT16 -> X_FLOAT32, and X -> RGBA_FLOAT32.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/texformat.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 97b905f..c85a7c0 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -327,36 +327,52 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
       switch (internalFormat) {
          case GL_ALPHA16F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_ALPHA32F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_LUMINANCE16F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_LUMINANCE32F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_LUMINANCE_ALPHA16F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_LUMINANCE_ALPHA32F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_INTENSITY16F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_INTENSITY32F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_RGB16F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FLOAT16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_RGB32F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FLOAT32);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_RGBA16F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
+	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
 	    break;
          case GL_RGBA32F_ARB:
 	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
@@ -631,13 +647,23 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
    if (ctx->Extensions.ARB_texture_rg && ctx->Extensions.ARB_texture_float) {
       switch (internalFormat) {
       case GL_R16F:
-	 return MESA_FORMAT_R_FLOAT16;
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT16);
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT32);
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+	 break;
       case GL_R32F:
-         return MESA_FORMAT_R_FLOAT32;
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT32);
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+	 break;
       case GL_RG16F:
-	 return MESA_FORMAT_RG_FLOAT16;
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+	 break;
       case GL_RG32F:
-         return MESA_FORMAT_RG_FLOAT32;
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
+	 RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+	 break;
 
       default:
          ; /* fallthrough */



More information about the mesa-commit mailing list