mesa: consolidate internal glTexSubImage1/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:55:59 +0000 (07:55 -0600)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/common/meta.c
src/mesa/drivers/dri/intel/intel_tex_subimage.c
src/mesa/drivers/dri/nouveau/nouveau_texture.c
src/mesa/main/dd.h
src/mesa/main/mipmap.c
src/mesa/main/teximage.c
src/mesa/main/texstore.c
src/mesa/main/texstore.h
src/mesa/state_tracker/st_cb_texture.c

index 54e5221b28b334021953442d30bbbfee235a377a..a9ccbd565dac3131c92d7da065f5eccc8dfebf80 100644 (file)
@@ -92,9 +92,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    /* Texture functions */
    driver->ChooseTextureFormat = _mesa_choose_tex_format;
    driver->TexImage = _mesa_store_teximage;
-   driver->TexSubImage1D = _mesa_store_texsubimage1d;
-   driver->TexSubImage2D = _mesa_store_texsubimage2d;
-   driver->TexSubImage3D = _mesa_store_texsubimage3d;
+   driver->TexSubImage = _mesa_store_texsubimage;
    driver->GetTexImage = _mesa_meta_GetTexImage;
    driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D;
    driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D;
index 7978b08cbfedd3f7c5984d9a8d3988a9b4c5a4e3..af21d3b0697091a8748851ee1489086994aef970 100644 (file)
@@ -3127,7 +3127,6 @@ copy_tex_sub_image(struct gl_context *ctx,
                    GLsizei width, GLsizei height)
 {
    struct gl_texture_object *texObj = texImage->TexObject;
-   const GLenum target = texObj->Target;
    GLenum format, type;
    GLint bpp;
    void *buf;
@@ -3181,21 +3180,11 @@ copy_tex_sub_image(struct gl_context *ctx,
     * Store texture data (with pixel transfer ops)
     */
    _mesa_meta_begin(ctx, MESA_META_PIXEL_STORE);
-   if (target == GL_TEXTURE_1D) {
-      ctx->Driver.TexSubImage1D(ctx, texImage,
-                                xoffset, width,
-                                format, type, buf, &ctx->Unpack);
-   }
-   else if (target == GL_TEXTURE_3D) {
-      ctx->Driver.TexSubImage3D(ctx, texImage,
-                                xoffset, yoffset, zoffset, width, height, 1,
-                                format, type, buf, &ctx->Unpack);
-   }
-   else {
-      ctx->Driver.TexSubImage2D(ctx, texImage,
-                                xoffset, yoffset, width, height,
-                                format, type, buf, &ctx->Unpack);
-   }
+
+   ctx->Driver.TexSubImage(ctx, dims, texImage,
+                           xoffset, yoffset, zoffset, width, height, 1,
+                           format, type, buf, &ctx->Unpack);
+
    _mesa_meta_end(ctx);
 
    _mesa_lock_texture(ctx, texObj); /* re-lock */
index eb8b9839a2b7dd7d248d2464e372acd8373241ff..ae4b3bca305dd3083034a60927940d4b32f88c82 100644 (file)
@@ -149,27 +149,29 @@ intel_blit_texsubimage(struct gl_context * ctx,
 }
 
 static void
-intelTexSubImage2D(struct gl_context * ctx,
-                   struct gl_texture_image *texImage,
-                   GLint xoffset, GLint yoffset,
-                   GLsizei width, GLsizei height,
-                   GLenum format, GLenum type,
-                   const GLvoid * pixels,
-                   const struct gl_pixelstore_attrib *packing)
+intelTexSubImage(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, GLenum type,
+                 const GLvoid * pixels,
+                 const struct gl_pixelstore_attrib *packing)
 {
-   if (!intel_blit_texsubimage(ctx, texImage,
+   /* The intel_blit_texsubimage() function only handles 2D images */
+   if (dims != 2 || !intel_blit_texsubimage(ctx, texImage,
                               xoffset, yoffset,
                               width, height,
                               format, type, pixels, packing)) {
-      _mesa_store_texsubimage2d(ctx, texImage,
-                               xoffset, yoffset,
-                               width, height,
-                               format, type, pixels, packing);
+      _mesa_store_texsubimage(ctx, dims, texImage,
+                              xoffset, yoffset, zoffset,
+                              width, height, depth,
+                              format, type, pixels, packing);
    }
 }
 
 void
 intelInitTextureSubImageFuncs(struct dd_function_table *functions)
 {
-   functions->TexSubImage2D = intelTexSubImage2D;
+   functions->TexSubImage = intelTexSubImage;
 }
index e5ef3d3ff9ffee15f0021bf18ec661fff580b766..4d6518d2426be1592aa28d05a92892bebe40390d 100644 (file)
@@ -611,43 +611,18 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims,
 }
 
 static void
-nouveau_texsubimage_3d(struct gl_context *ctx,
-                      struct gl_texture_image *ti,
-                      GLint xoffset, GLint yoffset, GLint zoffset,
-                      GLint width, GLint height, GLint depth,
-                      GLenum format, GLenum type, const void *pixels,
-                      const struct gl_pixelstore_attrib *packing)
+nouveau_texsubimage_123d(struct gl_context *ctx, GLuint dims,
+                         struct gl_texture_image *ti,
+                         GLint xoffset, GLint yoffset, GLint zoffset,
+                         GLint width, GLint height, GLint depth,
+                         GLenum format, GLenum type, const void *pixels,
+                         const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_texsubimage(ctx, 3, ti, xoffset, yoffset, zoffset,
+       nouveau_texsubimage(ctx, dims, ti, xoffset, yoffset, zoffset,
                            width, height, depth, 0, format, type, pixels,
                            packing, GL_FALSE);
 }
 
-static void
-nouveau_texsubimage_2d(struct gl_context *ctx,
-                      struct gl_texture_image *ti,
-                      GLint xoffset, GLint yoffset,
-                      GLint width, GLint height,
-                      GLenum format, GLenum type, const void *pixels,
-                      const struct gl_pixelstore_attrib *packing)
-{
-       nouveau_texsubimage(ctx, 2, ti, xoffset, yoffset, 0,
-                           width, height, 1, 0, format, type, pixels,
-                           packing, GL_FALSE);
-}
-
-static void
-nouveau_texsubimage_1d(struct gl_context *ctx,
-                      struct gl_texture_image *ti,
-                      GLint xoffset, GLint width,
-                      GLenum format, GLenum type, const void *pixels,
-                      const struct gl_pixelstore_attrib *packing)
-{
-       nouveau_texsubimage(ctx, 1, ti, xoffset, 0, 0,
-                           width, 1, 1, 0, format, type, pixels,
-                           packing, GL_FALSE);
-}
-
 static void
 nouveau_compressed_texsubimage_2d(struct gl_context *ctx,
                       struct gl_texture_image *ti,
@@ -732,9 +707,7 @@ nouveau_texture_functions_init(struct dd_function_table *functions)
        functions->FreeTextureImageBuffer = nouveau_teximage_free;
        functions->ChooseTextureFormat = nouveau_choose_tex_format;
        functions->TexImage = nouveau_teximage_123d;
-       functions->TexSubImage1D = nouveau_texsubimage_1d;
-       functions->TexSubImage2D = nouveau_texsubimage_2d;
-       functions->TexSubImage3D = nouveau_texsubimage_3d;
+       functions->TexSubImage = nouveau_texsubimage_123d;
        functions->CompressedTexImage2D = nouveau_compressed_teximage_2d;
        functions->CompressedTexSubImage2D = nouveau_compressed_texsubimage_2d;
        functions->BindTexture = nouveau_bind_texture;
index 711143c5594808318dd586fa08df5dfe9e2d5dda..c7984177d7f5bb11ad36cde05017bd6e557a2c11 100644 (file)
@@ -213,44 +213,17 @@ struct dd_function_table {
                     GLenum format, GLenum type, const GLvoid *pixels,
                     const struct gl_pixelstore_attrib *packing);
 
-
    /**
-    * Called by glTexSubImage1D().  Replace a subset of the target texture
-    * with new texel data.
-    * \sa dd_function_table::TexImage1D.
+    * Called by glTexSubImage[123]D().
+    * Replace a subset of the target texture with new texel data.
     */
-   void (*TexSubImage1D)(struct gl_context *ctx,
-                         struct gl_texture_image *texImage,
-                         GLint xoffset, GLsizei width,
-                         GLenum format, GLenum type,
-                         const GLvoid *pixels,
-                         const struct gl_pixelstore_attrib *packing);
-   
-   /**
-    * Called by glTexSubImage2D().
-    *
-    * \sa dd_function_table::TexSubImage1D.
-    */
-   void (*TexSubImage2D)(struct gl_context *ctx,
-                         struct gl_texture_image *texImage,
-                         GLint xoffset, GLint yoffset,
-                         GLsizei width, GLsizei height,
-                         GLenum format, GLenum type,
-                         const GLvoid *pixels,
-                         const struct gl_pixelstore_attrib *packing);
-   
-   /**
-    * Called by glTexSubImage3D().
-    *
-    * \sa dd_function_table::TexSubImage1D.
-    */
-   void (*TexSubImage3D)(struct gl_context *ctx,
-                         struct gl_texture_image *texImage,
-                         GLint xoffset, GLint yoffset, GLint zoffset,
-                         GLsizei width, GLsizei height, GLint depth,
-                         GLenum format, GLenum type,
-                         const GLvoid *pixels,
-                         const struct gl_pixelstore_attrib *packing);
+   void (*TexSubImage)(struct gl_context *ctx, GLuint dims,
+                       struct gl_texture_image *texImage,
+                       GLint xoffset, GLint yoffset, GLint zoffset,
+                       GLsizei width, GLsizei height, GLint depth,
+                       GLenum format, GLenum type,
+                       const GLvoid *pixels,
+                       const struct gl_pixelstore_attrib *packing);
 
 
    /**
index abd26b8d3c861913fb44b8d8f93d3bed69d91289..250d3c6dcf9094a84691a9b84e6f0b211c2044a2 100644 (file)
@@ -2133,10 +2133,10 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
       }
 
       /* The image space was allocated above so use glTexSubImage now */
-      ctx->Driver.TexSubImage2D(ctx, dstImage,
-                                0, 0, dstWidth, dstHeight,
-                                temp_base_format, temp_datatype,
-                                temp_dst, &ctx->DefaultPacking);
+      ctx->Driver.TexSubImage(ctx, 2, dstImage,
+                              0, 0, 0, dstWidth, dstHeight, 1,
+                              temp_base_format, temp_datatype,
+                              temp_dst, &ctx->DefaultPacking);
 
       /* swap src and dest pointers */
       {
index 5bb21cd80a8c8a864a033bce0763c65b3f4c0e39..e835346375823f784c62e70a74e49204f0547d52 100644 (file)
@@ -2792,26 +2792,10 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
             xoffset += texImage->Border;
          }
 
-         switch (dims) {
-         case 1:
-            ctx->Driver.TexSubImage1D(ctx, texImage,
-                                      xoffset, width,
-                                      format, type, pixels, &ctx->Unpack);
-            break;
-         case 2:
-            ctx->Driver.TexSubImage2D(ctx, texImage,
-                                      xoffset, yoffset, width, height,
-                                      format, type, pixels, &ctx->Unpack);
-            break;
-         case 3:
-            ctx->Driver.TexSubImage3D(ctx, texImage,
-                                      xoffset, yoffset, zoffset,
-                                      width, height, depth,
-                                      format, type, pixels, &ctx->Unpack);
-            break;
-         default:
-            _mesa_problem(ctx, "unexpected dims in subteximage()");
-         }
+         ctx->Driver.TexSubImage(ctx, dims, texImage,
+                                 xoffset, yoffset, zoffset,
+                                 width, height, depth,
+                                 format, type, pixels, &ctx->Unpack);
 
          check_gen_mipmap(ctx, target, texObj, level);
 
index 1aa79625287f9d171b99520ce5e2e2cc00de4b00..ce8f36bfc2f20c6d8cdce485a2157c484045433d 100644 (file)
@@ -4293,53 +4293,19 @@ _mesa_store_teximage(struct gl_context *ctx,
 
 
 /*
- * This is the fallback for Driver.TexSubImage1D().
+ * Fallback for Driver.TexSubImage().
  */
 void
-_mesa_store_texsubimage1d(struct gl_context *ctx,
-                          struct gl_texture_image *texImage,
-                          GLint xoffset, GLint width,
-                          GLenum format, GLenum type, const void *pixels,
-                          const struct gl_pixelstore_attrib *packing)
-{
-   store_texsubimage(ctx, texImage,
-                     xoffset, 0, 0, width, 1, 1,
-                     format, type, pixels, packing, "glTexSubImage1D");
-}
-
-
-
-/**
- * This is the fallback for Driver.TexSubImage2D().
- */
-void
-_mesa_store_texsubimage2d(struct gl_context *ctx,
-                          struct gl_texture_image *texImage,
-                          GLint xoffset, GLint yoffset,
-                          GLint width, GLint height,
-                          GLenum format, GLenum type, const void *pixels,
-                          const struct gl_pixelstore_attrib *packing)
-{
-   store_texsubimage(ctx, texImage,
-                     xoffset, yoffset, 0, width, height, 1,
-                     format, type, pixels, packing, "glTexSubImage2D");
-}
-
-
-/*
- * This is the fallback for Driver.TexSubImage3D().
- */
-void
-_mesa_store_texsubimage3d(struct gl_context *ctx,
-                          struct gl_texture_image *texImage,
-                          GLint xoffset, GLint yoffset, GLint zoffset,
-                          GLint width, GLint height, GLint depth,
-                          GLenum format, GLenum type, const void *pixels,
-                          const struct gl_pixelstore_attrib *packing)
+_mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
+                        struct gl_texture_image *texImage,
+                        GLint xoffset, GLint yoffset, GLint zoffset,
+                        GLint width, GLint height, GLint depth,
+                        GLenum format, GLenum type, const void *pixels,
+                        const struct gl_pixelstore_attrib *packing)
 {
    store_texsubimage(ctx, texImage,
                      xoffset, yoffset, zoffset, width, height, depth,
-                     format, type, pixels, packing, "glTexSubImage3D");
+                     format, type, pixels, packing, "glTexSubImage");
 }
 
 
index b4995fbc8986ccc9ba991a974b755bd933257a43..e6eb2fb4811cbcd6469b3947b44af6db6716f383 100644 (file)
@@ -100,29 +100,12 @@ _mesa_store_teximage(struct gl_context *ctx,
 
 
 extern void
-_mesa_store_texsubimage1d(struct gl_context *ctx,
-                          struct gl_texture_image *texImage,
-                          GLint xoffset, GLint width,
-                          GLenum format, GLenum type, const GLvoid *pixels,
-                          const struct gl_pixelstore_attrib *packing);
-
-
-extern void
-_mesa_store_texsubimage2d(struct gl_context *ctx,
-                          struct gl_texture_image *texImage,
-                          GLint xoffset, GLint yoffset,
-                          GLint width, GLint height,
-                          GLenum format, GLenum type, const GLvoid *pixels,
-                          const struct gl_pixelstore_attrib *packing);
-
-
-extern void
-_mesa_store_texsubimage3d(struct gl_context *ctx,
-                          struct gl_texture_image *texImage,
-                          GLint xoffset, GLint yoffset, GLint zoffset,
-                          GLint width, GLint height, GLint depth,
-                          GLenum format, GLenum type, const GLvoid *pixels,
-                          const struct gl_pixelstore_attrib *packing);
+_mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
+                        struct gl_texture_image *texImage,
+                        GLint xoffset, GLint yoffset, GLint zoffset,
+                        GLint width, GLint height, GLint depth,
+                        GLenum format, GLenum type, const GLvoid *pixels,
+                        const struct gl_pixelstore_attrib *packing);
 
 
 extern void
index 3ab14a1bbd912d216a612664b5a0c1009e7e6d62..eb861586c4aa6291cead750c4d106ee2b08147ef 100644 (file)
@@ -1397,9 +1397,7 @@ st_init_texture_functions(struct dd_function_table *functions)
 {
    functions->ChooseTextureFormat = st_ChooseTextureFormat;
    functions->TexImage = st_TexImage;
-   functions->TexSubImage1D = _mesa_store_texsubimage1d;
-   functions->TexSubImage2D = _mesa_store_texsubimage2d;
-   functions->TexSubImage3D = _mesa_store_texsubimage3d;
+   functions->TexSubImage = _mesa_store_texsubimage;
    functions->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
    functions->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
    functions->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;