[Mesa-dev] [PATCH 03/10] mesa: Add ChooseTexFormat fallbacks for floating point textures.

Eric Anholt eric at anholt.net
Mon Apr 18 13:37:55 PDT 2011


This covers X_FLOAT16 -> X_FLOAT32, and X -> RGBA_FLOAT32.
---
 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 */
-- 
1.7.4.4



More information about the mesa-dev mailing list