mesa: simplify Driver.TexSubImage() parameters
authorBrian Paul <brianp@vmware.com>
Fri, 30 Dec 2011 15:24:55 +0000 (08:24 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 30 Dec 2011 15:24:55 +0000 (08:24 -0700)
There's no need to pass the target, level and texObj parameters since
they can be easily obtained from the texImage pointer.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
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

index 5098680b6a821eecf088d893af7f1e6ab4150507..785a59531d37f1f7630b37042354971f90ff15b1 100644 (file)
@@ -3157,19 +3157,19 @@ copy_tex_sub_image(struct gl_context *ctx,
     */
    _mesa_meta_begin(ctx, MESA_META_PIXEL_STORE);
    if (target == GL_TEXTURE_1D) {
-      ctx->Driver.TexSubImage1D(ctx, target, level, xoffset,
-                                width, format, type, buf,
-                                &ctx->Unpack, texObj, texImage);
+      ctx->Driver.TexSubImage1D(ctx, texImage,
+                                xoffset, width,
+                                format, type, buf, &ctx->Unpack);
    }
    else if (target == GL_TEXTURE_3D) {
-      ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset,
-                                width, height, 1, format, type, buf,
-                                &ctx->Unpack, texObj, texImage);
+      ctx->Driver.TexSubImage3D(ctx, texImage,
+                                xoffset, yoffset, zoffset, width, height, 1,
+                                format, type, buf, &ctx->Unpack);
    }
    else {
-      ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset,
-                                width, height, format, type, buf,
-                                &ctx->Unpack, texObj, texImage);
+      ctx->Driver.TexSubImage2D(ctx, texImage,
+                                xoffset, yoffset, width, height,
+                                format, type, buf, &ctx->Unpack);
    }
    _mesa_meta_end(ctx);
 
index 662958891b759a714ab8a2cd5464a9a3bd80efa9..45727479779666ac38f31a42cea479ff53a54fee 100644 (file)
 
 static bool
 intel_blit_texsubimage(struct gl_context * ctx,
-                      GLenum target, GLint level,
+                      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,
-                      struct gl_texture_object *texObj,
-                      struct gl_texture_image *texImage)
+                      const struct gl_pixelstore_attrib *packing)
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_texture_image *intelImage = intel_texture_image(texImage);
@@ -69,7 +67,7 @@ intel_blit_texsubimage(struct gl_context * ctx,
    if (intelImage->mt->region->tiling == I915_TILING_Y)
       return false;
 
-   if (target != GL_TEXTURE_2D)
+   if (texImage->TexObject->Target != GL_TEXTURE_2D)
       return false;
 
    /* On gen6, it's probably not worth swapping to the blit ring to do
@@ -83,8 +81,8 @@ intel_blit_texsubimage(struct gl_context * ctx,
 
    DBG("BLT subimage %s target %s level %d offset %d,%d %dx%d\n",
        __FUNCTION__,
-       _mesa_lookup_enum_by_nr(target),
-       level, xoffset, yoffset, width, height);
+       _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+       texImage->Level, xoffset, yoffset, width, height);
 
    pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1,
                                        format, type, pixels, packing,
@@ -112,7 +110,7 @@ intel_blit_texsubimage(struct gl_context * ctx,
    dstMap = temp_bo->virtual;
    dstRowStride = pitch;
 
-   intel_miptree_get_image_offset(intelImage->mt, level,
+   intel_miptree_get_image_offset(intelImage->mt, texImage->Level,
                                  intelImage->base.Base.Face, 0,
                                  &blit_x, &blit_y);
    blit_x += xoffset;
@@ -155,26 +153,21 @@ intel_blit_texsubimage(struct gl_context * ctx,
 
 static void
 intelTexSubImage2D(struct gl_context * ctx,
-                   GLenum target,
-                   GLint level,
+                   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,
-                   struct gl_texture_object *texObj,
-                   struct gl_texture_image *texImage)
+                   const struct gl_pixelstore_attrib *packing)
 {
-   if (!intel_blit_texsubimage(ctx, target, level,
+   if (!intel_blit_texsubimage(ctx, texImage,
                               xoffset, yoffset,
                               width, height,
-                              format, type, pixels, packing,
-                              texObj, texImage)) {
-      _mesa_store_texsubimage2d(ctx, target, level,
+                              format, type, pixels, packing)) {
+      _mesa_store_texsubimage2d(ctx, texImage,
                                xoffset, yoffset,
                                width, height,
-                               format, type, pixels,
-                               packing, texObj, texImage);
+                               format, type, pixels, packing);
    }
 }
 
index 8dd2df47f7f98a3d0652513a3c4bc5d2d981cb0d..e9f74e81a7321099a5311edfb4483ddafa826caf 100644 (file)
@@ -547,13 +547,12 @@ nouveau_teximage_3d(struct gl_context *ctx, GLenum target, GLint level,
 }
 
 static void
-nouveau_texsubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
+nouveau_texsubimage(struct gl_context *ctx, GLint 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,
-                   struct gl_texture_object *t,
-                   struct gl_texture_image *ti)
+                   const struct gl_pixelstore_attrib *packing)
 {
        struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
        struct nouveau_teximage *nti = to_nouveau_teximage(ti);
@@ -577,50 +576,48 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint lev
                _mesa_unmap_teximage_pbo(ctx, packing);
        }
 
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
+       if (!to_nouveau_texture(ti->TexObject)->dirty)
+               validate_teximage(ctx, ti->TexObject, ti->Level,
+                                 xoffset, yoffset, zoffset,
                                  width, height, depth);
 }
 
 static void
-nouveau_texsubimage_3d(struct gl_context *ctx, GLenum target, GLint level,
+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,
-                      struct gl_texture_object *t,
-                      struct gl_texture_image *ti)
+                      const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset,
+       nouveau_texsubimage(ctx, 3, ti, xoffset, yoffset, zoffset,
                            width, height, depth, format, type, pixels,
-                           packing, t, ti);
+                           packing);
 }
 
 static void
-nouveau_texsubimage_2d(struct gl_context *ctx, GLenum target, GLint level,
+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,
-                      struct gl_texture_object *t,
-                      struct gl_texture_image *ti)
+                      const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_texsubimage(ctx, 2, target, level, xoffset, yoffset, 0,
+       nouveau_texsubimage(ctx, 2, ti, xoffset, yoffset, 0,
                            width, height, 1, format, type, pixels,
-                           packing, t, ti);
+                           packing);
 }
 
 static void
-nouveau_texsubimage_1d(struct gl_context *ctx, GLenum target, GLint level,
+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,
-                      struct gl_texture_object *t,
-                      struct gl_texture_image *ti)
+                      const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_texsubimage(ctx, 1, target, level, xoffset, 0, 0,
+       nouveau_texsubimage(ctx, 1, ti, xoffset, 0, 0,
                            width, 1, 1, format, type, pixels,
-                           packing, t, ti);
+                           packing);
 }
 
 static void
index 5816faa783f200c023d29bd01b8e27ffc4d4f2b3..5226a6811cf4f203826ab60cf1730c3c486b99e3 100644 (file)
@@ -245,41 +245,39 @@ struct dd_function_table {
     * with new texel data.
     * \sa dd_function_table::TexImage1D.
     */
-   void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level,
-                          GLint xoffset, GLsizei width,
-                          GLenum format, GLenum type,
-                          const GLvoid *pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage );
+   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, GLenum target, GLint level,
-                          GLint xoffset, GLint yoffset,
-                          GLsizei width, GLsizei height,
-                          GLenum format, GLenum type,
-                          const GLvoid *pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage );
+   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, GLenum target, GLint level,
-                          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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage );
+   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);
+
 
    /**
     * Called by glGetTexImage().
index 867cb22e28a7a430b32ae7ae5344bab581fe1513..9a6c6dea272645765eb24a79e3989cef8c6ed02f 100644 (file)
@@ -2132,11 +2132,10 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
       }
 
       /* The image space was allocated above so use glTexSubImage now */
-      ctx->Driver.TexSubImage2D(ctx, target, level + 1,
+      ctx->Driver.TexSubImage2D(ctx, dstImage,
                                 0, 0, dstWidth, dstHeight,
                                 temp_base_format, temp_datatype,
-                                temp_dst, &ctx->DefaultPacking,
-                                texObj, dstImage);
+                                temp_dst, &ctx->DefaultPacking);
 
       /* swap src and dest pointers */
       {
index 18a7b87c0d3ce22f8ff37b51d637c9f30899a1fe..ad7a1ea0c8d0bc891830fff74af8126575e6fefc 100644 (file)
@@ -2681,23 +2681,20 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
 
          switch (dims) {
          case 1:
-            ctx->Driver.TexSubImage1D(ctx, target, level,
+            ctx->Driver.TexSubImage1D(ctx, texImage,
                                       xoffset, width,
-                                      format, type, pixels,
-                                      &ctx->Unpack, texObj, texImage );
+                                      format, type, pixels, &ctx->Unpack);
             break;
          case 2:
-            ctx->Driver.TexSubImage2D(ctx, target, level,
+            ctx->Driver.TexSubImage2D(ctx, texImage,
                                       xoffset, yoffset, width, height,
-                                      format, type, pixels,
-                                      &ctx->Unpack, texObj, texImage );
+                                      format, type, pixels, &ctx->Unpack);
             break;
          case 3:
-            ctx->Driver.TexSubImage3D(ctx, target, level,
+            ctx->Driver.TexSubImage3D(ctx, texImage,
                                       xoffset, yoffset, zoffset,
                                       width, height, depth,
-                                      format, type, pixels,
-                                      &ctx->Unpack, texObj, texImage );
+                                      format, type, pixels, &ctx->Unpack);
             break;
          default:
             _mesa_problem(ctx, "unexpected dims in subteximage()");
index 86c35d38f7458e5024d941a47b69ddf0279847d9..e97178dc8b5b2620e03468814115d732dad688ed 100644 (file)
@@ -4785,12 +4785,11 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
  * This is the fallback for Driver.TexSubImage1D().
  */
 void
-_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
+_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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
+                          const struct gl_pixelstore_attrib *packing)
 {
    store_texsubimage(ctx, texImage,
                      xoffset, 0, 0, width, 1, 1,
@@ -4803,13 +4802,12 @@ _mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
  * This is the fallback for Driver.TexSubImage2D().
  */
 void
-_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
+_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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
+                          const struct gl_pixelstore_attrib *packing)
 {
    store_texsubimage(ctx, texImage,
                      xoffset, yoffset, 0, width, height, 1,
@@ -4821,13 +4819,12 @@ _mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
  * This is the fallback for Driver.TexSubImage3D().
  */
 void
-_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
+_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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
+                          const struct gl_pixelstore_attrib *packing)
 {
    store_texsubimage(ctx, texImage,
                      xoffset, yoffset, zoffset, width, height, depth,
index f956b0436b959813d13f7f8b05a3423c025199fe..83826ce97e004d9f450e76d99e593f3af6c47dcf 100644 (file)
@@ -121,32 +121,29 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
 
 
 extern void
-_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
+_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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage);
+                          const struct gl_pixelstore_attrib *packing);
 
 
 extern void
-_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
+_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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage);
+                          const struct gl_pixelstore_attrib *packing);
 
 
 extern void
-_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
+_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,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage);
+                          const struct gl_pixelstore_attrib *packing);
 
 
 extern void