mesa: Add ChooseTexFormat fallbacks for floating point textures.
authorEric Anholt <eric@anholt.net>
Fri, 15 Apr 2011 21:18:43 +0000 (14:18 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 20 Apr 2011 17:35:41 +0000 (10:35 -0700)
This covers X_FLOAT16 -> X_FLOAT32, and X -> RGBA_FLOAT32.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/texformat.c

index 97b905fd36c7093c23b5ce1c9b03e63eceb1c2da..c85a7c0503024e2bfa37b53849206c54840dfcb5 100644 (file)
@@ -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 */