mesa: consolidate internal glCompressedTexImage1/2/3D code
authorBrian Paul <brianp@vmware.com>
Tue, 5 Jun 2012 22:32:23 +0000 (16:32 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 6 Jun 2012 13:56:00 +0000 (07:56 -0600)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/dri/nouveau/nouveau_texture.c
src/mesa/main/dd.h
src/mesa/main/teximage.c
src/mesa/main/texstore.c
src/mesa/main/texstore.h
src/mesa/state_tracker/st_cb_texture.c

index 118fc4ab06b5da79f031a3db77dd135900329d93..3d689362c6126ab52308dcf78af91a61b4bcb6f0 100644 (file)
@@ -97,9 +97,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->CopyTexSubImage = _mesa_meta_CopyTexSubImage;
    driver->GenerateMipmap = _mesa_meta_GenerateMipmap;
    driver->TestProxyTexImage = _mesa_test_proxy_teximage;
-   driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
-   driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
-   driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+   driver->CompressedTexImage = _mesa_store_compressed_teximage;
    driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
    driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
    driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
index 4d6518d2426be1592aa28d05a92892bebe40390d..281d1dda4584018ddffd801fa72550821dc7c78c 100644 (file)
@@ -555,10 +555,10 @@ nouveau_teximage_123d(struct gl_context *ctx, GLuint dims,
 }
 
 static void
-nouveau_compressed_teximage_2d(struct gl_context *ctx,
+nouveau_compressed_teximage(struct gl_context *ctx, GLuint dims,
                    struct gl_texture_image *ti,
                    GLint internalFormat,
-                   GLint width, GLint height, GLint border,
+                   GLint width, GLint height, GLint depth, GLint border,
                    GLsizei imageSize, const GLvoid *data)
 {
        nouveau_teximage(ctx, 2, ti, internalFormat,
@@ -708,7 +708,7 @@ nouveau_texture_functions_init(struct dd_function_table *functions)
        functions->ChooseTextureFormat = nouveau_choose_tex_format;
        functions->TexImage = nouveau_teximage_123d;
        functions->TexSubImage = nouveau_texsubimage_123d;
-       functions->CompressedTexImage2D = nouveau_compressed_teximage_2d;
+       functions->CompressedTexImage = nouveau_compressed_teximage;
        functions->CompressedTexSubImage2D = nouveau_compressed_texsubimage_2d;
        functions->BindTexture = nouveau_bind_texture;
        functions->MapTextureImage = nouveau_map_texture_image;
index f66e754baea07451e79877255d6254e13b712e82..07106ac368493997643c132c334126745c744aa9 100644 (file)
@@ -269,37 +269,14 @@ struct dd_function_table {
    /*@{*/
 
    /**
-    * Called by glCompressedTexImage1D().
-    * The parameters are the same as for glCompressedTexImage1D(), plus a
-    * pointer to the destination texure image.
-    */
-   void (*CompressedTexImage1D)(struct gl_context *ctx,
-                                struct gl_texture_image *texImage,
-                                GLint internalFormat,
-                                GLsizei width, GLint border,
-                                GLsizei imageSize, const GLvoid *data);
-   /**
-    * Called by glCompressedTexImage2D().
-    *
-    * \sa dd_function_table::CompressedTexImage1D.
-    */
-   void (*CompressedTexImage2D)(struct gl_context *ctx,
-                                struct gl_texture_image *texImage,
-                                GLint internalFormat,
-                                GLsizei width, GLsizei height, GLint border,
-                                GLsizei imageSize, const GLvoid *data);
-
-   /**
-    * Called by glCompressedTexImage3D().
-    *
-    * \sa dd_function_table::CompressedTexImage3D.
-    */
-   void (*CompressedTexImage3D)(struct gl_context *ctx,
-                                struct gl_texture_image *texImage,
-                                GLint internalFormat,
-                                GLsizei width, GLsizei height, GLsizei depth,
-                                GLint border,
-                                GLsizei imageSize, const GLvoid *data);
+    * Called by glCompressedTexImage[123]D().
+    */
+   void (*CompressedTexImage)(struct gl_context *ctx, GLuint dims,
+                              struct gl_texture_image *texImage,
+                              GLint internalFormat,
+                              GLsizei width, GLsizei height, GLsizei depth,
+                              GLint border,
+                              GLsizei imageSize, const GLvoid *data);
 
    /**
     * Called by glCompressedTexSubImage1D().
index ce42246317f390296fc0e40e9f2ec56708c3496d..290a4e454dcee83be06bc18ebfb968ae7f59dfe7 100644 (file)
@@ -3541,31 +3541,10 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
                                           width, height, depth,
                                           border, internalFormat, texFormat);
 
-               switch (dims) {
-               case 1:
-                  ASSERT(ctx->Driver.CompressedTexImage1D);
-                  ctx->Driver.CompressedTexImage1D(ctx, texImage,
-                                                   internalFormat,
-                                                   width,
-                                                   border, imageSize, data);
-                  break;
-               case 2:
-                  ASSERT(ctx->Driver.CompressedTexImage2D);
-                  ctx->Driver.CompressedTexImage2D(ctx, texImage,
-                                                   internalFormat,
-                                                   width, height,
-                                                   border, imageSize, data);
-                  break;
-               case 3:
-                  ASSERT(ctx->Driver.CompressedTexImage3D);
-                  ctx->Driver.CompressedTexImage3D(ctx, texImage,
-                                                   internalFormat,
-                                                   width, height, depth,
-                                                   border, imageSize, data);
-                  break;
-               default:
-                  _mesa_problem(ctx, "bad dims in compressedteximage");
-               }
+               ctx->Driver.CompressedTexImage(ctx, dims, texImage,
+                                              internalFormat,
+                                              width, height, depth,
+                                              border, imageSize, data);
 
                check_gen_mipmap(ctx, target, texObj, level);
 
index ce8f36bfc2f20c6d8cdce485a2157c484045433d..37ba082a475f9814a8d4b8bc496e2f5b412be9fa 100644 (file)
@@ -4309,36 +4309,23 @@ _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
 }
 
 
-/*
- * Fallback for Driver.CompressedTexImage1D()
- */
-void
-_mesa_store_compressed_teximage1d(struct gl_context *ctx,
-                                  struct gl_texture_image *texImage,
-                                  GLint internalFormat,
-                                  GLint width, GLint border,
-                                  GLsizei imageSize, const GLvoid *data)
-{
-   /* no compressed 1D image formats at this time */
-   (void) ctx;
-   (void) internalFormat;
-   (void) width; (void) border;
-   (void) imageSize; (void) data;
-   (void) texImage;
-}
-
-
-
 /**
- * Fallback for Driver.CompressedTexImage2D()
+ * Fallback for Driver.CompressedTexImage()
  */
 void
-_mesa_store_compressed_teximage2d(struct gl_context *ctx,
-                                  struct gl_texture_image *texImage,
-                                  GLint internalFormat,
-                                  GLint width, GLint height, GLint border,
-                                  GLsizei imageSize, const GLvoid *data)
+_mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
+                                struct gl_texture_image *texImage,
+                                GLint internalFormat,
+                                GLint width, GLint height, GLint depth,
+                                GLint border,
+                                GLsizei imageSize, const GLvoid *data)
 {
+   /* only 2D compressed images are supported at this time */
+   if (dims != 2) {
+      _mesa_problem(ctx, "Unexpected glCompressedTexImage1D/3D call");
+      return;
+   }
+
    /* This is pretty simple, because unlike the general texstore path we don't
     * have to worry about the usual image unpacking or image transfer
     * operations.
@@ -4363,29 +4350,6 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx,
 }
 
 
-
-/*
- * Fallback for Driver.CompressedTexImage3D()
- */
-void
-_mesa_store_compressed_teximage3d(struct gl_context *ctx,
-                                  struct gl_texture_image *texImage,
-                                  GLint internalFormat,
-                                  GLint width, GLint height, GLint depth,
-                                  GLint border,
-                                  GLsizei imageSize, const GLvoid *data)
-{
-   /* this space intentionally left blank */
-   (void) ctx;
-   (void) internalFormat;
-   (void) width; (void) height; (void) depth;
-   (void) border;
-   (void) imageSize; (void) data;
-   (void) texImage;
-}
-
-
-
 /**
  * Fallback for Driver.CompressedTexSubImage1D()
  */
index e6eb2fb4811cbcd6469b3947b44af6db6716f383..68dc4b479608dec9ed55cef77c2319afaf01b5e8 100644 (file)
@@ -109,26 +109,12 @@ _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
 
 
 extern void
-_mesa_store_compressed_teximage1d(struct gl_context *ctx,
-                                  struct gl_texture_image *texImage,
-                                  GLint internalFormat,
-                                  GLint width, GLint border,
-                                  GLsizei imageSize, const GLvoid *data);
-
-extern void
-_mesa_store_compressed_teximage2d(struct gl_context *ctx,
-                                  struct gl_texture_image *texImage,
-                                  GLint internalFormat,
-                                  GLint width, GLint height, GLint border,
-                                  GLsizei imageSize, const GLvoid *data);
-
-extern void
-_mesa_store_compressed_teximage3d(struct gl_context *ctx,
-                                  struct gl_texture_image *texImage,
-                                  GLint internalFormat,
-                                  GLint width, GLint height, GLint depth,
-                                  GLint border,
-                                  GLsizei imageSize, const GLvoid *data);
+_mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
+                                struct gl_texture_image *texImage,
+                                GLint internalFormat,
+                                GLint width, GLint height, GLint depth,
+                                GLint border,
+                                GLsizei imageSize, const GLvoid *data);
 
 
 extern void
index 593dc95cde4bae8fe1cae7070e14a3833336bb03..2fc5964942321216a69e976268367fbc9a49a10f 100644 (file)
@@ -545,16 +545,16 @@ st_TexImage(struct gl_context * ctx, GLuint dims,
 
 
 static void
-st_CompressedTexImage2D(struct gl_context *ctx,
-                        struct gl_texture_image *texImage,
-                        GLint internalFormat,
-                        GLint width, GLint height, GLint border,
-                        GLsizei imageSize, const GLvoid *data)
+st_CompressedTexImage(struct gl_context *ctx, GLuint dims,
+                      struct gl_texture_image *texImage,
+                      GLint internalFormat,
+                      GLint width, GLint height, GLint border, GLint depth,
+                      GLsizei imageSize, const GLvoid *data)
 {
-   prep_teximage(ctx, texImage, internalFormat, width, 1, 1, border,
+   prep_teximage(ctx, texImage, internalFormat, width, height, depth, border,
                  GL_NONE, GL_NONE);
-   _mesa_store_compressed_teximage2d(ctx, texImage, internalFormat, width,
-                                     height, border, imageSize, data);
+   _mesa_store_compressed_teximage(ctx, dims, texImage, internalFormat, width,
+                                   height, depth, border, imageSize, data);
 }
 
 
@@ -1363,7 +1363,7 @@ st_init_texture_functions(struct dd_function_table *functions)
    functions->GetTexImage = st_GetTexImage;
 
    /* compressed texture functions */
-   functions->CompressedTexImage2D = st_CompressedTexImage2D;
+   functions->CompressedTexImage = st_CompressedTexImage;
    functions->GetCompressedTexImage = _mesa_get_compressed_teximage;
 
    functions->NewTextureObject = st_NewTextureObject;