i965g: Fixup texture formats
authorJakob Bornecrantz <wallbraker@gmail.com>
Sat, 7 Nov 2009 17:47:00 +0000 (17:47 +0000)
committerJakob Bornecrantz <wallbraker@gmail.com>
Sat, 7 Nov 2009 17:47:00 +0000 (17:47 +0000)
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/i965/brw_screen_texture.c

index af885320a7f413b6458e48d369861c89190e7f7a..05da72ebb2b425a5fc331db91ca68b10f98a2bb2 100644 (file)
@@ -201,31 +201,62 @@ brw_is_format_supported(struct pipe_screen *screen,
                          unsigned geom_flags)
 {
    static const enum pipe_format tex_supported[] = {
-      PIPE_FORMAT_R8G8B8A8_UNORM,
-      PIPE_FORMAT_A8R8G8B8_UNORM,
-      PIPE_FORMAT_R5G6B5_UNORM,
       PIPE_FORMAT_L8_UNORM,
-      PIPE_FORMAT_A8_UNORM,
       PIPE_FORMAT_I8_UNORM,
+      PIPE_FORMAT_A8_UNORM,
+      PIPE_FORMAT_L16_UNORM,
+      /*PIPE_FORMAT_I16_UNORM,*/
+      /*PIPE_FORMAT_A16_UNORM,*/
       PIPE_FORMAT_A8L8_UNORM,
+      PIPE_FORMAT_R5G6B5_UNORM,
+      PIPE_FORMAT_A1R5G5B5_UNORM,
+      PIPE_FORMAT_A4R4G4B4_UNORM,
+      PIPE_FORMAT_X8R8G8B8_UNORM,
+      PIPE_FORMAT_A8R8G8B8_UNORM,
+      /* video */
       PIPE_FORMAT_YCBCR,
       PIPE_FORMAT_YCBCR_REV,
+      /* compressed */
+      /*PIPE_FORMAT_FXT1_RGBA,*/
+      PIPE_FORMAT_DXT1_RGB,
+      PIPE_FORMAT_DXT1_RGBA,
+      PIPE_FORMAT_DXT3_RGBA,
+      PIPE_FORMAT_DXT5_RGBA,
+      /* sRGB */
+      PIPE_FORMAT_R8G8B8A8_SRGB,
+      PIPE_FORMAT_A8L8_SRGB,
+      PIPE_FORMAT_L8_SRGB,
+      PIPE_FORMAT_DXT1_SRGB,
+      /* depth */
+      PIPE_FORMAT_Z32_FLOAT,
       PIPE_FORMAT_X8Z24_UNORM,
       PIPE_FORMAT_S8Z24_UNORM,
+      PIPE_FORMAT_Z16_UNORM,
+      /* signed */
+      PIPE_FORMAT_R8G8_SNORM,
+      PIPE_FORMAT_R8G8B8A8_SNORM,
       PIPE_FORMAT_NONE  /* list terminator */
    };
-   static const enum pipe_format surface_supported[] = {
+   static const enum pipe_format render_supported[] = {
+      PIPE_FORMAT_X8R8G8B8_UNORM,
       PIPE_FORMAT_A8R8G8B8_UNORM,
       PIPE_FORMAT_R5G6B5_UNORM,
+      PIPE_FORMAT_NONE  /* list terminator */
+   };
+   static const enum pipe_format depth_supported[] = {
+      PIPE_FORMAT_Z32_FLOAT,
       PIPE_FORMAT_X8Z24_UNORM,
       PIPE_FORMAT_S8Z24_UNORM,
+      PIPE_FORMAT_Z16_UNORM,
       PIPE_FORMAT_NONE  /* list terminator */
    };
    const enum pipe_format *list;
    uint i;
 
-   if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
-      list = surface_supported;
+   if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
+      list = depth_supported;
+   else if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+      list = render_supported;
    else
       list = tex_supported;
 
index 9ca60b46d3dcf04c574eda212af395b7a530225c..666ec70d4240a37d96c42a4a422f6a8f2d967d71 100644 (file)
@@ -73,16 +73,19 @@ static GLuint translate_tex_format( enum pipe_format pf )
    case PIPE_FORMAT_A8_UNORM:
       return BRW_SURFACEFORMAT_A8_UNORM; 
 
-   case PIPE_FORMAT_A8L8_UNORM:
-      return BRW_SURFACEFORMAT_L8A8_UNORM;
+   case PIPE_FORMAT_L16_UNORM:
+      return BRW_SURFACEFORMAT_L16_UNORM;
 
-   case PIPE_FORMAT_A8R8G8B8_UNORM: /* XXX */
-   case PIPE_FORMAT_B8G8R8A8_UNORM: /* XXX */
-   case PIPE_FORMAT_R8G8B8A8_UNORM: /* XXX */
-      return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+      /* XXX: Add these to gallium
+   case PIPE_FORMAT_I16_UNORM:
+      return BRW_SURFACEFORMAT_I16_UNORM;
 
-   case PIPE_FORMAT_R8G8B8X8_UNORM:
-      return BRW_SURFACEFORMAT_R8G8B8X8_UNORM;
+   case PIPE_FORMAT_A16_UNORM:
+      return BRW_SURFACEFORMAT_A16_UNORM; 
+      */
+
+   case PIPE_FORMAT_A8L8_UNORM:
+      return BRW_SURFACEFORMAT_L8A8_UNORM;
 
    case PIPE_FORMAT_R5G6B5_UNORM:
       return BRW_SURFACEFORMAT_B5G6R5_UNORM;
@@ -93,19 +96,15 @@ static GLuint translate_tex_format( enum pipe_format pf )
    case PIPE_FORMAT_A4R4G4B4_UNORM:
       return BRW_SURFACEFORMAT_B4G4R4A4_UNORM;
 
+   case PIPE_FORMAT_X8R8G8B8_UNORM:
+      return BRW_SURFACEFORMAT_R8G8B8X8_UNORM;
 
-   case PIPE_FORMAT_L16_UNORM:
-      return BRW_SURFACEFORMAT_L16_UNORM;
-
-      /* XXX: Z texturing: 
-   case PIPE_FORMAT_I16_UNORM:
-      return BRW_SURFACEFORMAT_I16_UNORM;
-       */
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
+      return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
 
-      /* XXX: Z texturing:
-   case PIPE_FORMAT_A16_UNORM:
-      return BRW_SURFACEFORMAT_A16_UNORM; 
-      */
+   /*
+    * Video formats
+    */
 
    case PIPE_FORMAT_YCBCR_REV:
       return BRW_SURFACEFORMAT_YCRCB_NORMAL;
@@ -113,6 +112,9 @@ static GLuint translate_tex_format( enum pipe_format pf )
    case PIPE_FORMAT_YCBCR:
       return BRW_SURFACEFORMAT_YCRCB_SWAPUVY;
 
+   /*
+    * Compressed formats.
+    */
       /* XXX: Add FXT to gallium?
    case PIPE_FORMAT_FXT1_RGBA:
       return BRW_SURFACEFORMAT_FXT1;
@@ -130,6 +132,10 @@ static GLuint translate_tex_format( enum pipe_format pf )
    case PIPE_FORMAT_DXT5_RGBA:
        return BRW_SURFACEFORMAT_BC3_UNORM;
 
+   /*
+    * sRGB formats
+    */
+
    case PIPE_FORMAT_R8G8B8A8_SRGB:
       return BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB;
 
@@ -142,24 +148,24 @@ static GLuint translate_tex_format( enum pipe_format pf )
    case PIPE_FORMAT_DXT1_SRGB:
       return BRW_SURFACEFORMAT_BC1_UNORM_SRGB;
 
+   /*
+    * Depth formats
+    */
+
+   case PIPE_FORMAT_Z16_UNORM:
+         return BRW_SURFACEFORMAT_I16_UNORM;
+
    case PIPE_FORMAT_S8Z24_UNORM:
    case PIPE_FORMAT_X8Z24_UNORM:
          return BRW_SURFACEFORMAT_I24X8_UNORM;
 
-#if 0
-      /* XXX: these different surface formats don't seem to
-       * make any difference for shadow sampler/compares.
-       */
-      if (depth_mode == GL_INTENSITY) 
-         return BRW_SURFACEFORMAT_I24X8_UNORM;
-      else if (depth_mode == GL_ALPHA)
-         return BRW_SURFACEFORMAT_A24X8_UNORM;
-      else
-         return BRW_SURFACEFORMAT_L24X8_UNORM;
-#endif
+   case PIPE_FORMAT_Z32_FLOAT:
+         return BRW_SURFACEFORMAT_I32_FLOAT;
 
       /* XXX: presumably for bump mapping.  Add this to mesa state
        * tracker?
+       *
+       * XXX: Add flipped versions of these formats to Gallium.
        */
    case PIPE_FORMAT_R8G8_SNORM:
       return BRW_SURFACEFORMAT_R8G8_SNORM;