i965: Add support for half-float formats.
authorEric Anholt <eric@anholt.net>
Wed, 16 Nov 2011 00:26:29 +0000 (16:26 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 22 Nov 2011 21:58:38 +0000 (13:58 -0800)
Now that all the rest of the driver is driven off of the surface
formats table, all we really need to do is add the mapping from
MESA_FORMAT to BRW_SURFACEFORMAT.  However, we also add format
override for I16/L16 render targets at the same time, so that existing
users of I16 that were getting promoted to I32 and then getting the
I32->R32 override still get FBO support.

Fixes failures in piglit gl-3.0-required-sized-texture-formats, and
will prevent regressions in ARB_texture_float on gen4 when moving to
fully table-driven texture format setup.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c

index 7f32d54a96ed308af967a8e09cbaad957ad3be5c..bc2617833956a9c3a9589508245265b3111878e7 100644 (file)
@@ -347,21 +347,21 @@ brw_format_for_mesa_format(gl_format mesa_format)
       [MESA_FORMAT_RGBA_DXT5] = BRW_SURFACEFORMAT_BC3_UNORM,
 
       [MESA_FORMAT_RGBA_FLOAT32] = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT,
-      [MESA_FORMAT_RGBA_FLOAT16] = 0,
+      [MESA_FORMAT_RGBA_FLOAT16] = BRW_SURFACEFORMAT_R16G16B16A16_FLOAT,
       [MESA_FORMAT_RGB_FLOAT32] = 0,
       [MESA_FORMAT_RGB_FLOAT16] = 0,
       [MESA_FORMAT_ALPHA_FLOAT32] = BRW_SURFACEFORMAT_A32_FLOAT,
-      [MESA_FORMAT_ALPHA_FLOAT16] = 0,
+      [MESA_FORMAT_ALPHA_FLOAT16] = BRW_SURFACEFORMAT_A16_FLOAT,
       [MESA_FORMAT_LUMINANCE_FLOAT32] = BRW_SURFACEFORMAT_L32_FLOAT,
-      [MESA_FORMAT_LUMINANCE_FLOAT16] = 0,
+      [MESA_FORMAT_LUMINANCE_FLOAT16] = BRW_SURFACEFORMAT_L16_FLOAT,
       [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32] = BRW_SURFACEFORMAT_L32A32_FLOAT,
-      [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = 0,
+      [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = BRW_SURFACEFORMAT_L16A16_FLOAT,
       [MESA_FORMAT_INTENSITY_FLOAT32] = BRW_SURFACEFORMAT_I32_FLOAT,
-      [MESA_FORMAT_INTENSITY_FLOAT16] = 0,
+      [MESA_FORMAT_INTENSITY_FLOAT16] = BRW_SURFACEFORMAT_I16_FLOAT,
       [MESA_FORMAT_R_FLOAT32] = BRW_SURFACEFORMAT_R32_FLOAT,
-      [MESA_FORMAT_R_FLOAT16] = 0,
+      [MESA_FORMAT_R_FLOAT16] = BRW_SURFACEFORMAT_R16_FLOAT,
       [MESA_FORMAT_RG_FLOAT32] = BRW_SURFACEFORMAT_R32G32_FLOAT,
-      [MESA_FORMAT_RG_FLOAT16] = 0,
+      [MESA_FORMAT_RG_FLOAT16] = BRW_SURFACEFORMAT_R16G16_FLOAT,
 
       [MESA_FORMAT_ALPHA_UINT8] = 0,
       [MESA_FORMAT_ALPHA_UINT16] = 0,
@@ -499,6 +499,10 @@ brw_init_surface_formats(struct brw_context *brw)
       case BRW_SURFACEFORMAT_L32_FLOAT:
         render = BRW_SURFACEFORMAT_R32_FLOAT;
         break;
+      case BRW_SURFACEFORMAT_I16_FLOAT:
+      case BRW_SURFACEFORMAT_L16_FLOAT:
+        render = BRW_SURFACEFORMAT_R16_FLOAT;
+        break;
       case BRW_SURFACEFORMAT_B8G8R8X8_UNORM:
         /* XRGB is handled as ARGB because the chips in this family
          * cannot render to XRGB targets.  This means that we have to