[965] Replace 965 texture format code with common code.
authorEric Anholt <eric@anholt.net>
Mon, 5 Nov 2007 22:55:52 +0000 (14:55 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 20 Nov 2007 19:30:12 +0000 (11:30 -0800)
The only functional difference should be that 965 now gets the optimization
where textures default to 16bpp when the screen is 16bpp.

src/mesa/drivers/dri/i965/Makefile
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_tex.c
src/mesa/drivers/dri/i965/intel_tex.c
src/mesa/drivers/dri/i965/intel_tex.h
src/mesa/drivers/dri/i965/intel_tex_format.c [new symlink]
src/mesa/drivers/dri/i965/intel_tex_validate.c

index d7a2b46e1cf60667fab4d7ae24ea2241cc2b3594..48ecadfd89029688695482589c9e3de40891ba07 100644 (file)
@@ -21,6 +21,7 @@ DRIVER_SOURCES = \
        intel_pixel_bitmap.c \
        intel_state.c \
        intel_tex.c \
+       intel_tex_format.c \
        intel_tex_layout.c \
        intel_tex_validate.c \
        brw_cc.c \
index 6231cba3f93b0363ba2eafc3c67a052a41d67151..bdfdfd17043cbfb3298f5f9227d276350775d5d5 100644 (file)
@@ -89,7 +89,6 @@ static void brwInitProgFuncs( struct dd_function_table *functions )
 static void brwInitDriverFunctions( struct dd_function_table *functions )
 {
    intelInitDriverFunctions( functions );
-   brwInitTextureFuncs( functions );
    brwInitFragProgFuncs( functions );
    brwInitProgFuncs( functions );
 }
index aa797b72ce624fa810c58b402a1fb04285bd692a..3c227faba65584200e1ea240b3cec3e69154b8c8 100644 (file)
@@ -664,7 +664,6 @@ void brw_destroy_state( struct brw_context *brw );
  * brw_tex.c
  */
 void brwUpdateTextureState( struct intel_context *intel );
-void brwInitTextureFuncs( struct dd_function_table *functions );
 void brw_FrameBufferTexInit( struct brw_context *brw );
 void brw_FrameBufferTexDestroy( struct brw_context *brw );
 
index ad29316a42a453b62bd97987767de30396cf34c2..b344dd7d27168f1a7fd7d6ceb7b03015b67fa543 100644 (file)
 #include "brw_defines.h"
 
 
-
-
-static const struct gl_texture_format *
-brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
-                        GLenum srcFormat, GLenum srcType )
-{
-   switch ( internalFormat ) {
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-      if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV)
-        return &_mesa_texformat_argb4444;
-      else if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV)
-        return &_mesa_texformat_argb1555;
-      else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-              (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) ||
-              (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8)) 
-        return &_mesa_texformat_rgba8888_rev;
-      else
-        return &_mesa_texformat_argb8888;
-
-   case GL_RGBA8:
-   case GL_RGB10_A2:
-   case GL_RGBA12:
-   case GL_RGBA16:
-      return &_mesa_texformat_argb8888; 
-
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      /* Broadwater doesn't support RGB888 textures, so these must be
-       * stored as ARGB.
-       */
-      return &_mesa_texformat_argb8888;
-
-   case 3:
-   case GL_COMPRESSED_RGB:
-   case GL_RGB:
-      if (srcFormat == GL_RGB &&
-         srcType == GL_UNSIGNED_SHORT_5_6_5)
-        return &_mesa_texformat_rgb565;
-      else
-        return &_mesa_texformat_argb8888;
-
-
-   case GL_RGB5:
-   case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
-
-   case GL_R3_G3_B2:
-   case GL_RGBA2:
-   case GL_RGBA4:
-   case GL_RGB4:
-      return &_mesa_texformat_argb4444;
-
-   case GL_ALPHA:
-   case GL_ALPHA4:
-   case GL_ALPHA8:
-   case GL_ALPHA12:
-   case GL_ALPHA16:
-   case GL_COMPRESSED_ALPHA:
-      return &_mesa_texformat_a8;
-
-   case 1:
-   case GL_LUMINANCE:
-   case GL_LUMINANCE4:
-   case GL_LUMINANCE8:
-   case GL_LUMINANCE12:
-   case GL_LUMINANCE16:
-   case GL_COMPRESSED_LUMINANCE:
-      return &_mesa_texformat_l8;
-
-   case 2:
-   case GL_LUMINANCE_ALPHA:
-   case GL_LUMINANCE4_ALPHA4:
-   case GL_LUMINANCE6_ALPHA2:
-   case GL_LUMINANCE8_ALPHA8:
-   case GL_LUMINANCE12_ALPHA4:
-   case GL_LUMINANCE12_ALPHA12:
-   case GL_LUMINANCE16_ALPHA16:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return &_mesa_texformat_al88;
-
-   case GL_INTENSITY:
-   case GL_INTENSITY4:
-   case GL_INTENSITY8:
-   case GL_INTENSITY12:
-   case GL_INTENSITY16:
-   case GL_COMPRESSED_INTENSITY:
-      return &_mesa_texformat_i8;
-
-   case GL_YCBCR_MESA:
-      if (srcType == GL_UNSIGNED_SHORT_8_8_MESA ||
-         srcType == GL_UNSIGNED_BYTE)
-         return &_mesa_texformat_ycbcr;
-      else
-         return &_mesa_texformat_ycbcr_rev;
-
-   case GL_COMPRESSED_RGB_FXT1_3DFX:
-       return &_mesa_texformat_rgb_fxt1;
-   case GL_COMPRESSED_RGBA_FXT1_3DFX:
-       return &_mesa_texformat_rgba_fxt1;
-
-   case GL_RGB_S3TC:
-   case GL_RGB4_S3TC:
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-       return &_mesa_texformat_rgb_dxt1;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-       return &_mesa_texformat_rgba_dxt1;
-
-   case GL_RGBA_S3TC:
-   case GL_RGBA4_S3TC:
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-       return &_mesa_texformat_rgba_dxt3;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-       return &_mesa_texformat_rgba_dxt5;
-
-   case GL_DEPTH_COMPONENT:
-   case GL_DEPTH_COMPONENT16:
-   case GL_DEPTH_COMPONENT24:
-   case GL_DEPTH_COMPONENT32:
-      return &_mesa_texformat_z16;
-
-   case GL_SRGB_EXT:
-   case GL_SRGB8_EXT:
-   case GL_SRGB_ALPHA_EXT:
-   case GL_SRGB8_ALPHA8_EXT:
-   case GL_SLUMINANCE_EXT:
-   case GL_SLUMINANCE8_EXT:
-   case GL_SLUMINANCE_ALPHA_EXT:
-   case GL_SLUMINANCE8_ALPHA8_EXT:
-   case GL_COMPRESSED_SRGB_EXT:
-   case GL_COMPRESSED_SRGB_ALPHA_EXT:
-   case GL_COMPRESSED_SLUMINANCE_EXT:
-   case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
-       return &_mesa_texformat_srgba8;
-   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
-   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
-     return &_mesa_texformat_srgb_dxt1;
-
-   default:
-      fprintf(stderr, "unexpected texture format %s in %s\n", 
-             _mesa_lookup_enum_by_nr(internalFormat),
-             __FUNCTION__);
-      return NULL;
-   }
-
-   return NULL; /* never get here */
-}
-
-
-void brwInitTextureFuncs( struct dd_function_table *functions )
-{
-   functions->ChooseTextureFormat = brwChooseTextureFormat;
-}
-
 void brw_FrameBufferTexInit( struct brw_context *brw )
 {
    struct intel_context *intel = &brw->intel;
index 4523969bfa5e4fd378ae063c00fffd3aace88afa..e98e9bbfc4678eadbf66709f9305d0a6a937f340 100644 (file)
@@ -289,6 +289,7 @@ intel_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
 void intelInitTextureFuncs( struct dd_function_table *functions )
 {
    functions->NewTextureObject          = intelNewTextureObject;
+   functions->ChooseTextureFormat = intelChooseTextureFormat;
    functions->TexImage1D                = intelTexImage1D;
    functions->TexImage2D                = intelTexImage2D;
    functions->TexImage3D                = intelTexImage3D;
index e389d521461b9d9cb7e1aa8bae2cddf12119b256..d38325d53845e528a49c10a9b22a81982720aa96 100644 (file)
 
 void intelInitTextureFuncs( struct dd_function_table *functions );
 
+const struct gl_texture_format *intelChooseTextureFormat(GLcontext * ctx,
+                                                         GLint internalFormat,
+                                                         GLenum format,
+                                                         GLenum type);
 
 GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
                                   struct gl_texture_object *tObj );
 
+int intel_compressed_num_bytes(GLuint mesaFormat);
 
 #endif
diff --git a/src/mesa/drivers/dri/i965/intel_tex_format.c b/src/mesa/drivers/dri/i965/intel_tex_format.c
new file mode 120000 (symlink)
index 0000000..3415f75
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_format.c
\ No newline at end of file
index 8c05e7cdabccf7177ef5461c0feefaab5878c506..bd59c84dbdd98632789219b0b4a6374424afc7a5 100644 (file)
@@ -122,30 +122,6 @@ static void intel_texture_invalidate_cb( struct intel_context *intel,
    intel_texture_invalidate( (struct intel_texture_object *) ptr );
 }
 
-#include "texformat.h"
-static GLuint intel_compressed_num_bytes(GLenum mesaFormat)
-{
-    GLuint bytes = 0;
-
-    switch (mesaFormat) {
-    case MESA_FORMAT_RGB_FXT1:
-    case MESA_FORMAT_RGBA_FXT1:
-    case MESA_FORMAT_RGB_DXT1:
-    case MESA_FORMAT_RGBA_DXT1:
-        bytes = 2;
-        break;
-
-    case MESA_FORMAT_RGBA_DXT3:
-    case MESA_FORMAT_RGBA_DXT5:
-        bytes = 4;
-    
-    default:
-        break;
-    }
-
-    return bytes;
-}
-
 /*  
  */
 GLuint intel_finalize_mipmap_tree( struct intel_context *intel,