mesa: consolidate internal glCompressedTexSubImage1/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 3d689362c6126ab52308dcf78af91a61b4bcb6f0..93fa3c745e7225d79cca9caeec8817b27110f1cc 100644 (file)
@@ -98,9 +98,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->GenerateMipmap = _mesa_meta_GenerateMipmap;
    driver->TestProxyTexImage = _mesa_test_proxy_teximage;
    driver->CompressedTexImage = _mesa_store_compressed_teximage;
-   driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
-   driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
-   driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+   driver->CompressedTexSubImage = _mesa_store_compressed_texsubimage;
    driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
    driver->BindTexture = NULL;
    driver->NewTextureObject = _mesa_new_texture_object;
index 281d1dda4584018ddffd801fa72550821dc7c78c..0060f464307f895c21b459adb033ac689b5d26bf 100644 (file)
@@ -624,15 +624,15 @@ nouveau_texsubimage_123d(struct gl_context *ctx, GLuint dims,
 }
 
 static void
-nouveau_compressed_texsubimage_2d(struct gl_context *ctx,
+nouveau_compressed_texsubimage(struct gl_context *ctx, GLuint dims,
                       struct gl_texture_image *ti,
-                      GLint xoffset, GLint yoffset,
-                      GLsizei width, GLint height,
+                      GLint xoffset, GLint yoffset, GLint zoffset,
+                      GLsizei width, GLint height, GLint depth,
                       GLenum format,
                       GLint imageSize, const void *data)
 {
-       nouveau_texsubimage(ctx, 2, ti, xoffset, yoffset, 0,
-                         width, height, 1, imageSize, format, 0, data,
+       nouveau_texsubimage(ctx, dims, ti, xoffset, yoffset, zoffset,
+                         width, height, depth, imageSize, format, 0, data,
                          &ctx->Unpack, GL_TRUE);
 }
 
@@ -709,7 +709,7 @@ nouveau_texture_functions_init(struct dd_function_table *functions)
        functions->TexImage = nouveau_teximage_123d;
        functions->TexSubImage = nouveau_texsubimage_123d;
        functions->CompressedTexImage = nouveau_compressed_teximage;
-       functions->CompressedTexSubImage2D = nouveau_compressed_texsubimage_2d;
+       functions->CompressedTexSubImage = nouveau_compressed_texsubimage;
        functions->BindTexture = nouveau_bind_texture;
        functions->MapTextureImage = nouveau_map_texture_image;
        functions->UnmapTextureImage = nouveau_unmap_texture_image;
index 07106ac368493997643c132c334126745c744aa9..1582a8c81ec9ce7f54ea3b0f1c52ed87e4c50610 100644 (file)
@@ -279,33 +279,14 @@ struct dd_function_table {
                               GLsizei imageSize, const GLvoid *data);
 
    /**
-    * Called by glCompressedTexSubImage1D().
+    * Called by glCompressedTexSubImage[123]D().
     */
-   void (*CompressedTexSubImage1D)(struct gl_context *ctx,
-                                   struct gl_texture_image *texImage,
-                                   GLint xoffset, GLsizei width,
-                                   GLenum format,
-                                   GLsizei imageSize, const GLvoid *data);
-
-   /**
-    * Called by glCompressedTexSubImage2D().
-    */
-   void (*CompressedTexSubImage2D)(struct gl_context *ctx,
-                                   struct gl_texture_image *texImage,
-                                   GLint xoffset, GLint yoffset,
-                                   GLsizei width, GLint height,
-                                   GLenum format,
-                                   GLsizei imageSize, const GLvoid *data);
-
-   /**
-    * Called by glCompressedTexSubImage3D().
-    */
-   void (*CompressedTexSubImage3D)(struct gl_context *ctx,
-                                   struct gl_texture_image *texImage,
-                                   GLint xoffset, GLint yoffset, GLint zoffset,
-                                   GLsizei width, GLint height, GLint depth,
-                                   GLenum format,
-                                   GLsizei imageSize, const GLvoid *data);
+   void (*CompressedTexSubImage)(struct gl_context *ctx, GLuint dims,
+                                 struct gl_texture_image *texImage,
+                                 GLint xoffset, GLint yoffset, GLint zoffset,
+                                 GLsizei width, GLint height, GLint depth,
+                                 GLenum format,
+                                 GLsizei imageSize, const GLvoid *data);
 
    /**
     * Called by glGetCompressedTexImage.
index 290a4e454dcee83be06bc18ebfb968ae7f59dfe7..b16baaf914cb3aeaeb4c0e8e33a1f33c3b08dd18 100644 (file)
@@ -3633,33 +3633,10 @@ compressed_tex_sub_image(GLuint dims, GLenum target, GLint level,
          /* error was recorded */
       }
       else if (width > 0 && height > 0 && depth > 0) {
-         switch (dims) {
-         case 1:
-            if (ctx->Driver.CompressedTexSubImage1D) {
-               ctx->Driver.CompressedTexSubImage1D(ctx, texImage,
-                                                   xoffset, width,
-                                                   format, imageSize, data);
-            }
-            break;
-         case 2:
-            if (ctx->Driver.CompressedTexSubImage2D) {
-               ctx->Driver.CompressedTexSubImage2D(ctx, texImage,
-                                                   xoffset, yoffset,
-                                                   width, height,
-                                                   format, imageSize, data);
-            }
-            break;
-         case 3:
-            if (ctx->Driver.CompressedTexSubImage3D) {
-               ctx->Driver.CompressedTexSubImage3D(ctx, texImage,
-                                                   xoffset, yoffset, zoffset,
-                                                   width, height, depth,
-                                                   format, imageSize, data);
-            }
-            break;
-         default:
-            ;
-         }
+         ctx->Driver.CompressedTexSubImage(ctx, dims, texImage,
+                                           xoffset, yoffset, zoffset,
+                                           width, height, depth,
+                                           format, imageSize, data);
 
          check_gen_mipmap(ctx, target, texObj, level);
 
index 37ba082a475f9814a8d4b8bc496e2f5b412be9fa..1ced8aac98dae6c0d11f943c3aa21eaa11fa9baa 100644 (file)
@@ -4342,43 +4342,24 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
       return;
    }
 
-   _mesa_store_compressed_texsubimage2d(ctx, texImage,
-                                       0, 0,
-                                       width, height,
-                                       texImage->TexFormat,
-                                       imageSize, data);
+   _mesa_store_compressed_texsubimage(ctx, dims, texImage,
+                                      0, 0, 0,
+                                      width, height, depth,
+                                      texImage->TexFormat,
+                                      imageSize, data);
 }
 
 
 /**
- * Fallback for Driver.CompressedTexSubImage1D()
+ * Fallback for Driver.CompressedTexSubImage()
  */
 void
-_mesa_store_compressed_texsubimage1d(struct gl_context *ctx,
-                                     struct gl_texture_image *texImage,
-                                     GLint xoffset, GLsizei width,
-                                     GLenum format,
-                                     GLsizei imageSize, const GLvoid *data)
-{
-   /* there are no compressed 1D texture formats yet */
-   (void) ctx;
-   (void) xoffset; (void) width;
-   (void) format;
-   (void) imageSize; (void) data;
-   (void) texImage;
-}
-
-
-/**
- * Fallback for Driver.CompressedTexSubImage2D()
- */
-void
-_mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
-                                     struct gl_texture_image *texImage,
-                                     GLint xoffset, GLint yoffset,
-                                     GLsizei width, GLsizei height,
-                                     GLenum format,
-                                     GLsizei imageSize, const GLvoid *data)
+_mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims,
+                                   struct gl_texture_image *texImage,
+                                   GLint xoffset, GLint yoffset, GLint zoffset,
+                                   GLsizei width, GLsizei height, GLsizei depth,
+                                   GLenum format,
+                                   GLsizei imageSize, const GLvoid *data)
 {
    GLint bytesPerRow, dstRowStride, srcRowStride;
    GLint i, rows;
@@ -4387,6 +4368,11 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
    const gl_format texFormat = texImage->TexFormat;
    GLuint bw, bh;
 
+   if (dims != 2) {
+      _mesa_problem(ctx, "Unexpected 1D/3D compressed texsubimage call");
+      return;
+   }
+
    _mesa_get_format_block_size(texFormat, &bw, &bh);
 
    /* these should have been caught sooner */
@@ -4430,24 +4416,3 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
 
    _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
 }
-
-
-/**
- * Fallback for Driver.CompressedTexSubImage3D()
- */
-void
-_mesa_store_compressed_texsubimage3d(struct gl_context *ctx,
-                                     struct gl_texture_image *texImage,
-                                     GLint xoffset, GLint yoffset, GLint zoffset,
-                                     GLsizei width, GLsizei height, GLsizei depth,
-                                     GLenum format,
-                                     GLsizei imageSize, const GLvoid *data)
-{
-   /* there are no compressed 3D texture formats yet */
-   (void) ctx;
-   (void) xoffset; (void) yoffset; (void) zoffset;
-   (void) width; (void) height; (void) depth;
-   (void) format;
-   (void) imageSize; (void) data;
-   (void) texImage;
-}
index 68dc4b479608dec9ed55cef77c2319afaf01b5e8..5a1c014231c8cef521aaaedb19db7f25597b9150 100644 (file)
@@ -118,27 +118,12 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
 
 
 extern void
-_mesa_store_compressed_texsubimage1d(struct gl_context *ctx,
-                                     struct gl_texture_image *texImage,
-                                     GLint xoffset, GLsizei width,
-                                     GLenum format,
-                                     GLsizei imageSize, const GLvoid *data);
-
-extern void
-_mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
-                                     struct gl_texture_image *texImage,
-                                     GLint xoffset, GLint yoffset,
-                                     GLsizei width, GLsizei height,
-                                     GLenum format,
-                                     GLsizei imageSize, const GLvoid *data);
-
-extern void
-_mesa_store_compressed_texsubimage3d(struct gl_context *ctx,
-                                     struct gl_texture_image *texImage,
-                                     GLint xoffset, GLint yoffset, GLint zoffset,
-                                     GLsizei width, GLsizei height, GLsizei depth,
-                                     GLenum format,
-                                     GLsizei imageSize, const GLvoid *data);
+_mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims,
+                                   struct gl_texture_image *texImage,
+                                   GLint xoffset, GLint yoffset, GLint zoffset,
+                                   GLsizei width, GLsizei height, GLsizei depth,
+                                   GLenum format,
+                                   GLsizei imageSize, const GLvoid *data);
 
 
 #endif
index 2fc5964942321216a69e976268367fbc9a49a10f..9d1b7f672f5dc6917844119563986db0600097b6 100644 (file)
@@ -1354,9 +1354,7 @@ st_init_texture_functions(struct dd_function_table *functions)
    functions->ChooseTextureFormat = st_ChooseTextureFormat;
    functions->TexImage = st_TexImage;
    functions->TexSubImage = _mesa_store_texsubimage;
-   functions->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
-   functions->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
-   functions->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+   functions->CompressedTexSubImage = _mesa_store_compressed_texsubimage;
    functions->CopyTexSubImage = st_CopyTexSubImage;
    functions->GenerateMipmap = st_generate_mipmap;