mesa: Remove unnecessary parameters from TexImage
authorPauli Nieminen <pauli.nieminen@linux.intel.com>
Tue, 12 Jun 2012 18:38:43 +0000 (21:38 +0300)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 12 Aug 2012 22:49:13 +0000 (15:49 -0700)
gl_texture_image structure always holds size and internal format before
TexImage driver hook is called. Those passing same information in
function parameters only duplicates information making the interface
harder to understand.

Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
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/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 a023fef563474313daf4af1b06e1294d98a5f71d..acb21fbc7e4abefd15ccf58aefc447dadaf993c7 100644 (file)
@@ -133,8 +133,7 @@ static bool
 try_pbo_upload(struct gl_context *ctx,
                struct gl_texture_image *image,
                const struct gl_pixelstore_attrib *unpack,
-              GLenum format, GLenum type,
-               GLint width, GLint height, const void *pixels)
+              GLenum format, GLenum type, const void *pixels)
 {
    struct intel_texture_image *intelImage = intel_texture_image(image);
    struct intel_context *intel = intel_context(ctx);
@@ -162,7 +161,7 @@ try_pbo_upload(struct gl_context *ctx,
    }
 
    ctx->Driver.AllocTextureImageBuffer(ctx, image, image->TexFormat,
-                                       width, height, 1);
+                                       image->Width, image->Height, 1);
 
    if (!intelImage->mt) {
       DBG("%s: no miptree\n", __FUNCTION__);
@@ -177,7 +176,7 @@ try_pbo_upload(struct gl_context *ctx,
    if (unpack->RowLength > 0)
       src_stride = unpack->RowLength;
    else
-      src_stride = width;
+      src_stride = image->Width;
 
    intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level,
                                  intelImage->base.Base.Face, 0,
@@ -191,7 +190,7 @@ try_pbo_upload(struct gl_context *ctx,
                          src_offset, false,
                          dst_stride, dst_buffer, 0,
                          intelImage->mt->region->tiling,
-                         0, 0, dst_x, dst_y, width, height,
+                         0, 0, dst_x, dst_y, image->Width, image->Height,
                          GL_COPY)) {
       DBG("%s: blit failed\n", __FUNCTION__);
       return false;
@@ -205,28 +204,25 @@ static void
 intelTexImage(struct gl_context * ctx,
               GLuint dims,
               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)
 {
    DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
-       texImage->Level, width, height, depth);
+       texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
 
    /* Attempt to use the blitter for PBO image uploads.
     */
    if (dims <= 2 &&
-       try_pbo_upload(ctx, texImage, unpack, format, type,
-                     width, height, pixels)) {
+       try_pbo_upload(ctx, texImage, unpack, format, type, pixels)) {
       return;
    }
 
    DBG("%s: upload image %dx%dx%d pixels %p\n",
-       __FUNCTION__, width, height, depth, pixels);
+       __FUNCTION__, texImage->Width, texImage->Height, texImage->Depth,
+       pixels);
 
-   _mesa_store_teximage(ctx, dims, texImage, internalFormat,
-                        width, height, depth, 0,
+   _mesa_store_teximage(ctx, dims, texImage,
                         format, type, pixels, unpack);
 }
 
index 0060f464307f895c21b459adb033ac689b5d26bf..18dc9f7e6505bdb8124c53dd1fbd304ea05e4a4d 100644 (file)
@@ -481,8 +481,6 @@ get_teximage_placement(struct gl_texture_image *ti)
 static void
 nouveau_teximage(struct gl_context *ctx, GLint dims,
                 struct gl_texture_image *ti,
-                GLint internalFormat,
-                GLint width, GLint height, GLint depth, GLint border,
                 GLsizei imageSize,
                 GLenum format, GLenum type, const GLvoid *pixels,
                 const struct gl_pixelstore_attrib *packing,
@@ -493,10 +491,11 @@ nouveau_teximage(struct gl_context *ctx, GLint dims,
        struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
        struct nouveau_teximage *nti = to_nouveau_teximage(ti);
        int ret;
+       GLuint depth = compressed ? 1 : ti->Depth;
 
        /* Allocate a new bo for the image. */
        nouveau_surface_alloc(ctx, s, LINEAR, get_teximage_placement(ti),
-                             ti->TexFormat, width, height);
+                             ti->TexFormat, ti->Width, ti->Height);
        nti->base.RowStride = s->pitch / s->cpp;
 
        if (compressed)
@@ -505,19 +504,19 @@ nouveau_teximage(struct gl_context *ctx, GLint dims,
                        pixels, packing, "glCompressedTexImage");
        else
                pixels = _mesa_validate_pbo_teximage(ctx,
-                       dims, width, height, depth, format, type,
+                       dims, ti->Width, ti->Height, depth, format, type,
                        pixels, packing, "glTexImage");
 
        if (pixels) {
                /* Store the pixel data. */
                nouveau_teximage_map(ctx, ti, GL_MAP_WRITE_BIT,
-                                    0, 0, width, height);
+                                    0, 0, ti->Width, ti->Height);
 
                ret = _mesa_texstore(ctx, dims, ti->_BaseFormat,
                                     ti->TexFormat,
                                     s->pitch,
                                      &nti->base.Map,
-                                    width, height, depth,
+                                    ti->Width, ti->Height, depth,
                                     format, type, pixels, packing);
                assert(ret);
 
@@ -525,7 +524,7 @@ nouveau_teximage(struct gl_context *ctx, GLint dims,
                _mesa_unmap_teximage_pbo(ctx, packing);
 
                if (!validate_teximage(ctx, t, level, 0, 0, 0,
-                                      width, height, depth))
+                                      ti->Width, ti->Height, depth))
                        /* It doesn't fit, mark it as dirty. */
                        texture_dirty(t);
        }
@@ -544,13 +543,10 @@ nouveau_teximage(struct gl_context *ctx, GLint dims,
 static void
 nouveau_teximage_123d(struct gl_context *ctx, GLuint 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)
 {
-       nouveau_teximage(ctx, dims, ti, internalFormat,
-                        width, height, depth, border, 0, format, type, pixels,
+       nouveau_teximage(ctx, dims, ti, 0, format, type, pixels,
                         packing, GL_FALSE);
 }
 
@@ -561,8 +557,7 @@ nouveau_compressed_teximage(struct gl_context *ctx, GLuint dims,
                    GLint width, GLint height, GLint depth, GLint border,
                    GLsizei imageSize, const GLvoid *data)
 {
-       nouveau_teximage(ctx, 2, ti, internalFormat,
-                        width, height, 1, border, imageSize, 0, 0, data,
+       nouveau_teximage(ctx, 2, ti, imageSize, 0, 0, data,
                         &ctx->Unpack, GL_TRUE);
 }
 
index 6c7171953bba1be2316681932f6068622a75f368..04f3e232b3727fb6a51cfd64bd24ee7c26696f81 100644 (file)
@@ -573,38 +573,6 @@ static void teximage_assign_miptree(radeonContextPtr rmesa,
                                "%s Failed to allocate miptree.\n", __func__);
 }
 
-/**
- * All glTexImage calls go through this function.
- */
-static void radeon_teximage(
-       struct gl_context *ctx, int dims,
-       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,
-       int compressed)
-{
-       _mesa_store_teximage(ctx, dims, texImage, internalFormat,
-                            width, height, depth, 0,
-                            format, type, pixels,
-                            packing);
-}
-
-static void
-radeonTexImage(struct gl_context * ctx, GLuint dims,
-                     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)
-{
-       radeon_teximage(ctx, dims, texImage, internalFormat, width, height, depth,
-               0, format, type, pixels, packing, 0);
-}
-
 unsigned radeonIsFormatRenderable(gl_format mesa_format)
 {
        if (mesa_format == _radeon_texformat_argb8888 || mesa_format == _radeon_texformat_rgb565 ||
@@ -725,8 +693,6 @@ radeon_init_common_texture_funcs(radeonContextPtr radeon,
 
        functions->ChooseTextureFormat  = radeonChooseTextureFormat_mesa;
 
-       functions->TexImage = radeonTexImage;
-
        functions->CopyTexSubImage = radeonCopyTexSubImage;
 
        functions->Bitmap = _mesa_meta_Bitmap;
index e60d019bb0d8c5933ea96275e9f7734ce646e652..546e360819a8269fdb54f85556248eecd4353657 100644 (file)
@@ -208,8 +208,6 @@ struct dd_function_table {
     */
    void (*TexImage)(struct gl_context *ctx, GLuint dims,
                     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);
 
index 9ffdb4656680f7f99e31e447fc5b43ee5c76d35d..607869cdf765eabc379da6e3a70abd0872d1df1c 100644 (file)
@@ -2616,8 +2616,7 @@ teximage(struct gl_context *ctx, GLuint dims,
                                           border, internalFormat, texFormat);
 
                /* Give the texture to the driver.  <pixels> may be null. */
-               ctx->Driver.TexImage(ctx, dims, texImage, internalFormat,
-                                    width, height, depth, border, format,
+               ctx->Driver.TexImage(ctx, dims, texImage, format,
                                     type, pixels, unpack);
 
                check_gen_mipmap(ctx, target, texObj, level);
@@ -2945,8 +2944,8 @@ copyteximage(struct gl_context *ctx, GLuint dims,
                                        border, internalFormat, texFormat);
 
             /* Allocate texture memory (no pixel data yet) */
-            ctx->Driver.TexImage(ctx, dims, texImage, internalFormat,
-                                 width, height, 1, border, GL_NONE, GL_NONE,
+            ctx->Driver.TexImage(ctx, dims, texImage,
+                                 GL_NONE, GL_NONE,
                                  NULL, &ctx->Unpack);
 
             if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY,
index 529a6d449297301537a5b18092ae60676dad627d..f70da4fbc94162b59eada1bd75bccf97edfe83b1 100644 (file)
@@ -807,8 +807,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
                                     0, /* border */
                                     GL_RGBA, texFormat);
 
-         ctx->Driver.TexImage(ctx, dims, texImage, GL_RGBA,
-                              width, height, depth, 0,
+         ctx->Driver.TexImage(ctx, dims, texImage,
                               GL_RGBA, GL_UNSIGNED_BYTE, texel,
                               &ctx->DefaultPacking);
       }
index ab9fdf26d3e7098f4dcce86e291f6dfb9817cecd..52eef3ebab37f920f34c9d425ce915e672a3fd6a 100644 (file)
@@ -4336,25 +4336,24 @@ void
 _mesa_store_teximage(struct gl_context *ctx,
                      GLuint dims,
                      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)
 {
    assert(dims == 1 || dims == 2 || dims == 3);
 
-   if (width == 0 || height == 0 || depth == 0)
+   if (texImage->Width == 0 || texImage->Height == 0 || texImage->Depth == 0)
       return;
 
    /* allocate storage for texture data */
    if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
-                                            width, height, depth)) {
+                                            texImage->Width, texImage->Height,
+                                            texImage->Depth)) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
       return;
    }
 
    store_texsubimage(ctx, texImage,
-                     0, 0, 0, width, height, depth,
+                     0, 0, 0, texImage->Width, texImage->Height, texImage->Depth,
                      format, type, pixels, packing, "glTexImage");
 }
 
index 5a1c014231c8cef521aaaedb19db7f25597b9150..fbcb41b490d70e204e912edc98a19ca41ebe4e67 100644 (file)
@@ -93,8 +93,6 @@ extern void
 _mesa_store_teximage(struct gl_context *ctx,
                      GLuint dims,
                      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);
 
index 92ce3fa2073e63d355b716961a0b17d381a1659d..0c4e8a8f47b365c4afdbe5fa1756c8ef49d0c449 100644 (file)
@@ -500,8 +500,6 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
  */
 static void
 prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
-              GLint internalFormat,
-              GLint width, GLint height, GLint depth, GLint border,
               GLenum format, GLenum type)
 {
    struct gl_texture_object *texObj = texImage->TexObject;
@@ -518,11 +516,13 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
 
       /* oops, need to init this image again */
       texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
-                                              internalFormat, format, type);
+                                              texImage->InternalFormat, format,
+                                              type);
 
       _mesa_init_teximage_fields(ctx, texImage,
-                                 width, height, depth, border,
-                                 internalFormat, texFormat);
+                                 texImage->Width, texImage->Height,
+                                 texImage->Depth, texImage->Border,
+                                 texImage->InternalFormat, texFormat);
 
       stObj->surface_based = GL_FALSE;
    }
@@ -532,15 +532,11 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
 static void
 st_TexImage(struct gl_context * ctx, GLuint dims,
             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)
 {
-   prep_teximage(ctx, texImage, internalFormat, width, height, depth, border,
-                 format, type);
-   _mesa_store_teximage(ctx, dims, texImage, internalFormat, width, height, depth,
-                        border, format, type, pixels, unpack);
+   prep_teximage(ctx, texImage, format, type);
+   _mesa_store_teximage(ctx, dims, texImage, format, type, pixels, unpack);
 }
 
 
@@ -551,8 +547,7 @@ st_CompressedTexImage(struct gl_context *ctx, GLuint dims,
                       GLint width, GLint height, GLint border, GLint depth,
                       GLsizei imageSize, const GLvoid *data)
 {
-   prep_teximage(ctx, texImage, internalFormat, width, height, depth, border,
-                 GL_NONE, GL_NONE);
+   prep_teximage(ctx, texImage, GL_NONE, GL_NONE);
    _mesa_store_compressed_teximage(ctx, dims, texImage, internalFormat, width,
                                    height, depth, border, imageSize, data);
 }