mesa: simplify Driver.TexImage() 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)
As with TexSubImage(), the target, level and texObj values can be obtained
through the texImage pointer.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/nouveau/nouveau_texture.c
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/drivers/dri/radeon/radeon_texture.h
src/mesa/main/dd.h
src/mesa/main/teximage.c
src/mesa/main/texobj.c
src/mesa/main/texstore.c
src/mesa/main/texstore.h
src/mesa/state_tracker/st_cb_texture.c

index 107d3147279e97043d5da8517d45d3884f146da6..32f2e85515e9916c691a88a00ee9c66b228063b4 100644 (file)
@@ -202,16 +202,16 @@ try_pbo_upload(struct gl_context *ctx,
 static void
 intelTexImage(struct gl_context * ctx,
               GLint dims,
-              GLenum target, GLint level,
+              struct gl_texture_image *texImage,
               GLint internalFormat,
               GLint width, GLint height, GLint depth,
               GLenum format, GLenum type, const void *pixels,
               const struct gl_pixelstore_attrib *unpack,
-              struct gl_texture_object *texObj,
-              struct gl_texture_image *texImage, GLsizei imageSize)
+              GLsizei imageSize)
 {
    DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__,
-       _mesa_lookup_enum_by_nr(target), level, width, height, depth);
+       _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+       texImage->Level, width, height, depth);
 
    /* Attempt to use the blitter for PBO image uploads.
     */
@@ -224,59 +224,52 @@ intelTexImage(struct gl_context * ctx,
    DBG("%s: upload image %dx%dx%d pixels %p\n",
        __FUNCTION__, width, height, depth, pixels);
 
-   _mesa_store_teximage3d(ctx, target, level, internalFormat,
+   _mesa_store_teximage3d(ctx, texImage, internalFormat,
                          width, height, depth, 0,
-                         format, type, pixels,
-                         unpack, texObj, texImage);
+                         format, type, pixels, unpack);
 }
 
 
 static void
 intelTexImage3D(struct gl_context * ctx,
-                GLenum target, GLint level,
+                struct gl_texture_image *texImage,
                 GLint internalFormat,
                 GLint width, GLint height, GLint depth,
                 GLint border,
                 GLenum format, GLenum type, const void *pixels,
-                const struct gl_pixelstore_attrib *unpack,
-                struct gl_texture_object *texObj,
-                struct gl_texture_image *texImage)
+                const struct gl_pixelstore_attrib *unpack)
 {
-   intelTexImage(ctx, 3, target, level,
+   intelTexImage(ctx, 3, texImage,
                  internalFormat, width, height, depth,
-                 format, type, pixels, unpack, texObj, texImage, 0);
+                 format, type, pixels, unpack, 0);
 }
 
 
 static void
 intelTexImage2D(struct gl_context * ctx,
-                GLenum target, GLint level,
+                struct gl_texture_image *texImage,
                 GLint internalFormat,
                 GLint width, GLint height, GLint border,
                 GLenum format, GLenum type, const void *pixels,
-                const struct gl_pixelstore_attrib *unpack,
-                struct gl_texture_object *texObj,
-                struct gl_texture_image *texImage)
+                const struct gl_pixelstore_attrib *unpack)
 {
-   intelTexImage(ctx, 2, target, level,
+   intelTexImage(ctx, 2, texImage,
                  internalFormat, width, height, 1,
-                 format, type, pixels, unpack, texObj, texImage, 0);
+                 format, type, pixels, unpack, 0);
 }
 
 
 static void
 intelTexImage1D(struct gl_context * ctx,
-                GLenum target, GLint level,
+                struct gl_texture_image *texImage,
                 GLint internalFormat,
                 GLint width, GLint border,
                 GLenum format, GLenum type, const void *pixels,
-                const struct gl_pixelstore_attrib *unpack,
-                struct gl_texture_object *texObj,
-                struct gl_texture_image *texImage)
+                const struct gl_pixelstore_attrib *unpack)
 {
-   intelTexImage(ctx, 1, target, level,
+   intelTexImage(ctx, 1, texImage,
                  internalFormat, width, 1, 1,
-                 format, type, pixels, unpack, texObj, texImage, 0);
+                 format, type, pixels, unpack, 0);
 }
 
 
index e9f74e81a7321099a5311edfb4483ddafa826caf..0fb80ffd9cdabe52445b08aca968b79fbf7c46e4 100644 (file)
@@ -452,14 +452,15 @@ get_teximage_placement(struct gl_texture_image *ti)
 }
 
 static void
-nouveau_teximage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
+nouveau_teximage(struct gl_context *ctx, GLint dims,
+                struct gl_texture_image *ti,
                 GLint internalFormat,
                 GLint width, GLint height, GLint depth, GLint border,
                 GLenum format, GLenum type, const GLvoid *pixels,
-                const struct gl_pixelstore_attrib *packing,
-                struct gl_texture_object *t,
-                struct gl_texture_image *ti)
+                const struct gl_pixelstore_attrib *packing)
 {
+       struct gl_texture_object *t = ti->TexObject;
+       const GLuint level = ti->Level;
        struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
        struct nouveau_teximage *nti = to_nouveau_teximage(ti);
        int ret;
@@ -505,45 +506,42 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
 }
 
 static void
-nouveau_teximage_1d(struct gl_context *ctx, GLenum target, GLint level,
+nouveau_teximage_1d(struct gl_context *ctx,
+                   struct gl_texture_image *ti,
                    GLint internalFormat,
                    GLint width, GLint border,
                    GLenum format, GLenum type, const GLvoid *pixels,
-                   const struct gl_pixelstore_attrib *packing,
-                   struct gl_texture_object *t,
-                   struct gl_texture_image *ti)
+                   const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_teximage(ctx, 1, target, level, internalFormat,
+       nouveau_teximage(ctx, 1, ti, internalFormat,
                         width, 1, 1, border, format, type, pixels,
-                        packing, t, ti);
+                        packing);
 }
 
 static void
-nouveau_teximage_2d(struct gl_context *ctx, GLenum target, GLint level,
+nouveau_teximage_2d(struct gl_context *ctx,
+                   struct gl_texture_image *ti,
                    GLint internalFormat,
                    GLint width, GLint height, GLint border,
                    GLenum format, GLenum type, const GLvoid *pixels,
-                   const struct gl_pixelstore_attrib *packing,
-                   struct gl_texture_object *t,
-                   struct gl_texture_image *ti)
+                   const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_teximage(ctx, 2, target, level, internalFormat,
+       nouveau_teximage(ctx, 2, ti, internalFormat,
                         width, height, 1, border, format, type, pixels,
-                        packing, t, ti);
+                        packing);
 }
 
 static void
-nouveau_teximage_3d(struct gl_context *ctx, GLenum target, GLint level,
+nouveau_teximage_3d(struct gl_context *ctx,
+                   struct gl_texture_image *ti,
                    GLint internalFormat,
                    GLint width, GLint height, GLint depth, GLint border,
                    GLenum format, GLenum type, const GLvoid *pixels,
-                   const struct gl_pixelstore_attrib *packing,
-                   struct gl_texture_object *t,
-                   struct gl_texture_image *ti)
+                   const struct gl_pixelstore_attrib *packing)
 {
-       nouveau_teximage(ctx, 3, target, level, internalFormat,
+       nouveau_teximage(ctx, 3, ti, internalFormat,
                         width, height, depth, border, format, type, pixels,
-                        packing, t, ti);
+                        packing);
 }
 
 static void
index 71eff75cc04684ab9ae678a4f6d0d4702d1a18b7..78fb1b5c7d10bb08864d29845945d6fd4160a4dd 100644 (file)
@@ -578,58 +578,56 @@ static void teximage_assign_miptree(radeonContextPtr rmesa,
  */
 static void radeon_teximage(
        struct gl_context *ctx, int dims,
-       GLenum target, GLint level,
+       struct gl_texture_image *texImage,
        GLint internalFormat,
        GLint width, GLint height, GLint depth,
        GLsizei imageSize,
        GLenum format, GLenum type, const GLvoid * pixels,
        const struct gl_pixelstore_attrib *packing,
-       struct gl_texture_object *texObj,
-       struct gl_texture_image *texImage,
        int compressed)
 {
-       _mesa_store_teximage3d(ctx, target, level, internalFormat,
+       _mesa_store_teximage3d(ctx, texImage, internalFormat,
                               width, height, depth, 0,
                               format, type, pixels,
-                              packing, texObj, texImage);
+                              packing);
 }
 
-void radeonTexImage1D(struct gl_context * ctx, GLenum target, GLint level,
+static void
+radeonTexImage1D(struct gl_context * ctx,
+                     struct gl_texture_image *texImage,
                      GLint internalFormat,
                      GLint width, GLint border,
                      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)
 {
-       radeon_teximage(ctx, 1, target, level, internalFormat, width, 1, 1,
-               0, format, type, pixels, packing, texObj, texImage, 0);
+       radeon_teximage(ctx, 1, texImage, internalFormat, width, 1, 1,
+               0, format, type, pixels, packing, 0);
 }
 
-void radeonTexImage2D(struct gl_context * ctx, GLenum target, GLint level,
-                          GLint internalFormat,
-                          GLint width, GLint height, GLint border,
-                          GLenum format, GLenum type, const GLvoid * pixels,
-                          const struct gl_pixelstore_attrib *packing,
-                          struct gl_texture_object *texObj,
-                          struct gl_texture_image *texImage)
+static void
+radeonTexImage2D(struct gl_context * ctx,
+                     struct gl_texture_image *texImage,
+                     GLint internalFormat,
+                     GLint width, GLint height, GLint border,
+                     GLenum format, GLenum type, const GLvoid * pixels,
+                     const struct gl_pixelstore_attrib *packing)
 
 {
-       radeon_teximage(ctx, 2, target, level, internalFormat, width, height, 1,
-               0, format, type, pixels, packing, texObj, texImage, 0);
+       radeon_teximage(ctx, 2, texImage, internalFormat, width, height, 1,
+               0, format, type, pixels, packing, 0);
 }
 
-void radeonTexImage3D(struct gl_context * ctx, GLenum target, GLint level,
+static void
+radeonTexImage3D(struct gl_context * ctx,
+                     struct gl_texture_image *texImage,
                      GLint internalFormat,
                      GLint width, GLint height, GLint depth,
                      GLint border,
                      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)
 {
-       radeon_teximage(ctx, 3, target, level, internalFormat, width, height, depth,
-               0, format, type, pixels, packing, texObj, texImage, 0);
+       radeon_teximage(ctx, 3, texImage, internalFormat, width, height, depth,
+               0, format, type, pixels, packing, 0);
 }
 
 unsigned radeonIsFormatRenderable(gl_format mesa_format)
index f1af109707fdaf8269074c76b53fd0bd191fcbe8..ebe16c05f9911ffa6df35dc1ea77dffd17f9e091 100644 (file)
@@ -65,34 +65,13 @@ gl_format radeonChooseTextureFormat(struct gl_context * ctx,
                                     GLenum format,
                                     GLenum type, GLboolean fbo);
 
-void radeonTexImage1D(struct gl_context * ctx, GLenum target, GLint level,
-                     GLint internalFormat,
-                     GLint width, GLint border,
-                     GLenum format, GLenum type, const GLvoid * pixels,
-                     const struct gl_pixelstore_attrib *packing,
-                     struct gl_texture_object *texObj,
-                     struct gl_texture_image *texImage);
-void radeonTexImage2D(struct gl_context * ctx, GLenum target, GLint level,
-                     GLint internalFormat,
-                     GLint width, GLint height, GLint border,
-                     GLenum format, GLenum type, const GLvoid * pixels,
-                     const struct gl_pixelstore_attrib *packing,
-                     struct gl_texture_object *texObj,
-                     struct gl_texture_image *texImage);
 void radeonCompressedTexImage2D(struct gl_context * ctx, GLenum target,
                                GLint level, GLint internalFormat,
                                GLint width, GLint height, GLint border,
                                GLsizei imageSize, const GLvoid * data,
                                struct gl_texture_object *texObj,
                                struct gl_texture_image *texImage);
-void radeonTexImage3D(struct gl_context * ctx, GLenum target, GLint level,
-                     GLint internalFormat,
-                     GLint width, GLint height, GLint depth,
-                     GLint border,
-                     GLenum format, GLenum type, const GLvoid * pixels,
-                     const struct gl_pixelstore_attrib *packing,
-                     struct gl_texture_object *texObj,
-                     struct gl_texture_image *texImage);
+
 void radeonTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
                         GLint xoffset,
                         GLsizei width,
index 5226a6811cf4f203826ab60cf1730c3c486b99e3..05e6d354d3c0cdd56e084b0a152bea380cb59e33 100644 (file)
@@ -203,42 +203,38 @@ struct dd_function_table {
     * fully initialized.
     * The parameters are the same as glTexImage1D(), plus:
     * \param packing describes how to unpack the source data.
-    * \param texObj is the target texture object.
-    * \param texImage is the target texture image.
+    * \param texImage is the destination texture image.
     */
-   void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level,
-                       GLint internalFormat,
-                       GLint width, GLint border,
-                       GLenum format, GLenum type, const GLvoid *pixels,
-                       const struct gl_pixelstore_attrib *packing,
-                       struct gl_texture_object *texObj,
-                       struct gl_texture_image *texImage );
+   void (*TexImage1D)(struct gl_context *ctx,
+                      struct gl_texture_image *texImage,
+                      GLint internalFormat,
+                      GLint width, GLint border,
+                      GLenum format, GLenum type, const GLvoid *pixels,
+                      const struct gl_pixelstore_attrib *packing);
 
    /**
     * Called by glTexImage2D().
     * 
     * \sa dd_function_table::TexImage1D.
     */
-   void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level,
-                       GLint internalFormat,
-                       GLint width, GLint height, GLint border,
-                       GLenum format, GLenum type, const GLvoid *pixels,
-                       const struct gl_pixelstore_attrib *packing,
-                       struct gl_texture_object *texObj,
-                       struct gl_texture_image *texImage );
+   void (*TexImage2D)(struct gl_context *ctx,
+                      struct gl_texture_image *texImage,
+                      GLint internalFormat,
+                      GLint width, GLint height, GLint border,
+                      GLenum format, GLenum type, const GLvoid *pixels,
+                      const struct gl_pixelstore_attrib *packing);
    
    /**
     * Called by glTexImage3D().
     * 
     * \sa dd_function_table::TexImage1D.
     */
-   void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level,
-                       GLint internalFormat,
-                       GLint width, GLint height, GLint depth, GLint border,
-                       GLenum format, GLenum type, const GLvoid *pixels,
-                       const struct gl_pixelstore_attrib *packing,
-                       struct gl_texture_object *texObj,
-                       struct gl_texture_image *texImage );
+   void (*TexImage3D)(struct gl_context *ctx,
+                      struct gl_texture_image *texImage,
+                      GLint internalFormat,
+                      GLint width, GLint height, GLint depth, GLint border,
+                      GLenum format, GLenum type, const GLvoid *pixels,
+                      const struct gl_pixelstore_attrib *packing);
 
    /**
     * Called by glTexSubImage1D().  Replace a subset of the target texture
index ad7a1ea0c8d0bc891830fff74af8126575e6fefc..3dfe6dffef99376a8eeac70191b0abd355f5c8e7 100644 (file)
@@ -2481,22 +2481,19 @@ teximage(struct gl_context *ctx, GLuint dims,
                ASSERT(ctx->Driver.TexImage3D);
                switch (dims) {
                case 1:
-                  ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
+                  ctx->Driver.TexImage1D(ctx, texImage, internalFormat,
                                          width, border, format,
-                                         type, pixels, unpack, texObj,
-                                         texImage);
+                                         type, pixels, unpack);
                   break;
                case 2:
-                  ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+                  ctx->Driver.TexImage2D(ctx, texImage, internalFormat,
                                          width, height, border, format,
-                                         type, pixels, unpack, texObj,
-                                         texImage);
+                                         type, pixels, unpack);
                   break;
                case 3:
-                  ctx->Driver.TexImage3D(ctx, target, level, internalFormat,
+                  ctx->Driver.TexImage3D(ctx, texImage, internalFormat,
                                          width, height, depth, border, format,
-                                         type, pixels, unpack, texObj,
-                                         texImage);
+                                         type, pixels, unpack);
                   break;
                default:
                   _mesa_problem(ctx, "invalid dims=%u in teximage()", dims);
@@ -2820,14 +2817,14 @@ copyteximage(struct gl_context *ctx, GLuint dims,
 
             /* Allocate texture memory (no pixel data yet) */
             if (dims == 1) {
-               ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
+               ctx->Driver.TexImage1D(ctx, texImage, internalFormat,
                                       width, border, GL_NONE, GL_NONE, NULL,
-                                      &ctx->Unpack, texObj, texImage);
+                                      &ctx->Unpack);
             }
             else {
-               ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+               ctx->Driver.TexImage2D(ctx, texImage, internalFormat,
                                       width, height, border, GL_NONE, GL_NONE,
-                                      NULL, &ctx->Unpack, texObj, texImage);
+                                      NULL, &ctx->Unpack);
             }
 
             if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
index 8e447cabdd47d05f27891870425e4f9722aa865f..425cb5d84fdea02a3c2ac5d32d2f0503fcb89b4b 100644 (file)
@@ -799,10 +799,10 @@ _mesa_get_fallback_texture(struct gl_context *ctx)
       ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
 
       /* set image data */
-      ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA,
+      ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA,
                              8, 8, 0,
                              GL_RGBA, GL_UNSIGNED_BYTE, texels,
-                             &ctx->DefaultPacking, texObj, texImage);
+                             &ctx->DefaultPacking);
 
       _mesa_test_texobj_completeness(ctx, texObj);
       assert(texObj->_Complete);
index e97178dc8b5b2620e03468814115d732dad688ed..5e18b8a1b88f70d768fb6463791206ed3296f30e 100644 (file)
@@ -4698,13 +4698,12 @@ store_texsubimage(struct gl_context *ctx,
  * This is the fallback for Driver.TexImage1D().
  */
 void
-_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage1d(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint internalFormat,
                        GLint width, GLint border,
                        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 (width == 0)
       return;
@@ -4726,13 +4725,12 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
  * This is the fallback for Driver.TexImage2D().
  */
 void
-_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage2d(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint internalFormat,
                        GLint width, GLint height, GLint border,
                        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)
 {
    if (width == 0 || height == 0)
       return;
@@ -4755,13 +4753,12 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
  * This is the fallback for Driver.TexImage3D().
  */
 void
-_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage3d(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint internalFormat,
                        GLint width, GLint height, GLint depth, GLint border,
                        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)
 {
    if (width == 0 || height == 0 || depth == 0)
       return;
index 83826ce97e004d9f450e76d99e593f3af6c47dcf..2a9b17743a52ad01fca873defe350f1eec148a79 100644 (file)
@@ -91,33 +91,30 @@ _mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims,
                            GLbitfield transferOps);
 
 extern void
-_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage1d(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint internalFormat,
                        GLint width, GLint border,
                        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_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage2d(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint internalFormat,
                        GLint width, GLint height, GLint border,
                        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_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
+_mesa_store_teximage3d(struct gl_context *ctx,
+                       struct gl_texture_image *texImage,
                        GLint internalFormat,
                        GLint width, GLint height, GLint depth, GLint border,
                        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
index 8d30d7acb54837a329eb2de33403f6ec1e63f97c..8597dff0789fd6a672a817deb34129844951aa65 100644 (file)
@@ -501,19 +501,20 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
 static void
 st_TexImage(struct gl_context * ctx,
             GLint dims,
-            GLenum target, GLint level,
+            struct gl_texture_image *texImage,
             GLint internalFormat,
             GLint width, GLint height, GLint depth,
             GLint border,
             GLenum format, GLenum type, const void *pixels,
             const struct gl_pixelstore_attrib *unpack,
-            struct gl_texture_object *texObj,
-            struct gl_texture_image *texImage,
             GLsizei imageSize, GLboolean compressed_src)
 {
    struct st_context *st = st_context(ctx);
+   struct gl_texture_object *texObj = texImage->TexObject;
    struct st_texture_object *stObj = st_texture_object(texObj);
    struct st_texture_image *stImage = st_texture_image(texImage);
+   const GLenum target = texObj->Target;
+   const GLuint level = texImage->Level;
    GLuint dstRowStride = 0;
    enum pipe_transfer_usage transfer_usage = 0;
    GLubyte *dstMap;
@@ -736,48 +737,41 @@ done:
 
 static void
 st_TexImage3D(struct gl_context * ctx,
-              GLenum target, GLint level,
+              struct gl_texture_image *texImage,
               GLint internalFormat,
               GLint width, GLint height, GLint depth,
               GLint border,
               GLenum format, GLenum type, const void *pixels,
-              const struct gl_pixelstore_attrib *unpack,
-              struct gl_texture_object *texObj,
-              struct gl_texture_image *texImage)
+              const struct gl_pixelstore_attrib *unpack)
 {
-   st_TexImage(ctx, 3, target, level, internalFormat, width, height, depth,
-               border, format, type, pixels, unpack, texObj, texImage,
-               0, GL_FALSE);
+   st_TexImage(ctx, 3, texImage, internalFormat, width, height, depth, border,
+               format, type, pixels, unpack, 0, GL_FALSE);
 }
 
 
 static void
 st_TexImage2D(struct gl_context * ctx,
-              GLenum target, GLint level,
+              struct gl_texture_image *texImage,
               GLint internalFormat,
               GLint width, GLint height, GLint border,
               GLenum format, GLenum type, const void *pixels,
-              const struct gl_pixelstore_attrib *unpack,
-              struct gl_texture_object *texObj,
-              struct gl_texture_image *texImage)
+              const struct gl_pixelstore_attrib *unpack)
 {
-   st_TexImage(ctx, 2, target, level, internalFormat, width, height, 1, border,
-               format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
+   st_TexImage(ctx, 2, texImage, internalFormat, width, height, 1, border,
+               format, type, pixels, unpack, 0, GL_FALSE);
 }
 
 
 static void
 st_TexImage1D(struct gl_context * ctx,
-              GLenum target, GLint level,
+              struct gl_texture_image *texImage,
               GLint internalFormat,
               GLint width, GLint border,
               GLenum format, GLenum type, const void *pixels,
-              const struct gl_pixelstore_attrib *unpack,
-              struct gl_texture_object *texObj,
-              struct gl_texture_image *texImage)
+              const struct gl_pixelstore_attrib *unpack)
 {
-   st_TexImage(ctx, 1, target, level, internalFormat, width, 1, 1, border,
-               format, type, pixels, unpack, texObj, texImage, 0, GL_FALSE);
+   st_TexImage(ctx, 1, texImage, internalFormat, width, 1, 1, border,
+               format, type, pixels, unpack, 0, GL_FALSE);
 }
 
 
@@ -789,8 +783,8 @@ st_CompressedTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
                         struct gl_texture_object *texObj,
                         struct gl_texture_image *texImage)
 {
-   st_TexImage(ctx, 2, target, level, internalFormat, width, height, 1, border,
-               0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, GL_TRUE);
+   st_TexImage(ctx, 2, texImage, internalFormat, width, height, 1, border,
+               0, 0, data, &ctx->Unpack, imageSize, GL_TRUE);
 }
 
 
@@ -1644,13 +1638,13 @@ st_get_default_texture(struct st_context *st)
                                  16, 16, 1, 0,  /* w, h, d, border */
                                  GL_RGBA, MESA_FORMAT_RGBA8888);
 
-      st_TexImage(st->ctx, 2, target,
-                  0, GL_RGBA,    /* level, intformat */
+      st_TexImage(st->ctx, 2,
+                  texImg,
+                  GL_RGBA,    /* level, intformat */
                   16, 16, 1, 0,  /* w, h, d, border */
                   GL_RGBA, GL_UNSIGNED_BYTE, pixels,
                   &st->ctx->DefaultPacking,
-                  texObj, texImg,
-                  0, 0);
+                  0, GL_FALSE);
 
       texObj->Sampler.MinFilter = GL_NEAREST;
       texObj->Sampler.MagFilter = GL_NEAREST;