mesa: fix tex format selection for GL_R32F and other R/G float formats
authorBrian Paul <brianp@vmware.com>
Mon, 16 Jan 2012 16:05:05 +0000 (09:05 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 18 Jan 2012 17:44:05 +0000 (10:44 -0700)
The i965 driver advertises GL_ARB_texture_float and GL_ARB_texture_rg
support but the ctx->TextureFormatSupported[] table entries for
MESA_FORMAT_R_FLOAT32 and MESA_FORMAT_RGBA_FLOAT32 are false on gen 4
hardware.  So the case for GL_R32F would fail and we'd print an
implementation error.

This patch adds more Mesa tex format options for GL_R32F and other R/G
formats so we fall back to 16-bit formats when 32-bit formats aren't
available.

Eric made the same fix in commit 6216a5b4 for the non R/G formats.

v2: try 16-bit formats before 32-bit formats and try RG formats before
RGBA where possible.

This should fix https://bugs.freedesktop.org/show_bug.cgi?id=44039

NOTE: This is a candidate for the 8.0 and 7.11 branches.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/mesa/main/texformat.c

index 7e60541c38927b74f200b9fc2dc332ac037776d8..d393873f2a14a77a65215e5a53d5ad8416cf0aa6 100644 (file)
@@ -786,21 +786,31 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
       switch (internalFormat) {
       case GL_R16F:
         RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT16);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
         RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT32);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
         break;
       case GL_R32F:
         RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT32);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT16);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
         break;
       case GL_RG16F:
         RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
         RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
         break;
       case GL_RG32F:
         RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
         RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
+        RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
         break;
 
       default: