drivers: use new _mesa_texstore() function
authorBrian Paul <brianp@vmware.com>
Tue, 29 Sep 2009 03:41:11 +0000 (21:41 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 29 Sep 2009 03:41:11 +0000 (21:41 -0600)
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_subimage.c
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/drivers/dri/tdfx/tdfx_tex.c
src/mesa/drivers/dri/unichrome/via_tex.c

index a9f031a3cb2a72eb2d9a76d6bdac57800dae60d9..0e13f600a6339c08d327a9660c239c85e976354d 100644 (file)
@@ -518,9 +518,6 @@ intelTexImage(GLcontext * ctx,
     * conversion and copy:
     */
    if (pixels) {
-      StoreTexImageFunc storeImage =
-         _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
-
        if (compressed) {
           if (intelImage->mt) {
               struct intel_region *dst = intelImage->mt->region;
@@ -531,17 +528,20 @@ intelTexImage(GLcontext * ctx,
                               pixels,
                               srcRowStride,
                               0, 0);
-          } else
+          }
+           else {
               memcpy(texImage->Data, pixels, imageSize);
-       } else if (!storeImage(ctx, dims, 
-                              texImage->_BaseFormat, 
-                              texImage->TexFormat, 
-                              texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
-                              dstRowStride,
-                              texImage->ImageOffsets,
-                              width, height, depth,
-                              format, type, pixels, unpack)) {
-          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+           }
+       }
+       else if (!_mesa_texstore(ctx, dims, 
+                                texImage->_BaseFormat, 
+                                texImage->TexFormat, 
+                                texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
+                                dstRowStride,
+                                texImage->ImageOffsets,
+                                width, height, depth,
+                                format, type, pixels, unpack)) {
+          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
        }
    }
 
index c8de38bc723e5d656e10f27868e0a92662ede3a8..ad5c2271a1b16e21490798fc620b27f4dd4a7ae7 100644 (file)
@@ -105,21 +105,20 @@ intelTexSubimage(GLcontext * ctx,
                          xoffset, yoffset / 4,
                          (width + 3)  & ~3, (height + 3) / 4,
                          pixels, (width + 3) & ~3, 0, 0);
-      } else
+      }
+      else {
         memcpy(texImage->Data, pixels, imageSize);
+      }
    }
    else {
-      StoreTexImageFunc storeImage =
-         _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
-
-      if (!storeImage(ctx, dims, texImage->_BaseFormat,
-                      texImage->TexFormat,
-                      texImage->Data,
-                      xoffset, yoffset, zoffset,
-                      dstRowStride,
-                      texImage->ImageOffsets,
-                      width, height, depth,
-                      format, type, pixels, packing)) {
+      if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+                          texImage->TexFormat,
+                          texImage->Data,
+                          xoffset, yoffset, zoffset,
+                          dstRowStride,
+                          texImage->ImageOffsets,
+                          width, height, depth,
+                          format, type, pixels, packing)) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
       }
    }
index 416ca1974b16765fb32be778b86df2f27bf0bcf1..3ff8cad93e371587f42ee931ca827220e378b5c2 100644 (file)
@@ -624,8 +624,6 @@ static void radeon_teximage(
                } else {
                        GLuint dstRowStride;
                        GLuint *dstImageOffsets;
-                       StoreTexImageFunc storeImage =
-                               _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
 
                        if (image->mt) {
                                radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
@@ -648,15 +646,16 @@ static void radeon_teximage(
                                dstImageOffsets = texImage->ImageOffsets;
                        }
 
-                       if (!storeImage(ctx, dims,
-                                               texImage->_BaseFormat,
-                                               texImage->TexFormat,
-                                               texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
-                                               dstRowStride,
-                                               dstImageOffsets,
-                                               width, height, depth,
-                                               format, type, pixels, packing))
+                       if (!_mesa_texstore(ctx, dims,
+                                           texImage->_BaseFormat,
+                                           texImage->TexFormat,
+                                           texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
+                                           dstRowStride,
+                                           dstImageOffsets,
+                                           width, height, depth,
+                                           format, type, pixels, packing)) {
                                _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+                       }
 
                        if (dims == 3)
                                _mesa_free(dstImageOffsets);
@@ -779,18 +778,17 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve
 
                        copy_rows(img_start, dstRowStride,  pixels, srcRowStride, rows,  bytesPerRow);
                        
-               } else {
-                       StoreTexImageFunc storeImage =
-                               _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
-
-                       if (!storeImage(ctx, dims, texImage->_BaseFormat,
-                                                            texImage->TexFormat, texImage->Data,
-                                                            xoffset, yoffset, zoffset,
-                                                            dstRowStride,
-                                                            texImage->ImageOffsets,
-                                                            width, height, depth,
-                                                            format, type, pixels, packing))
+               }
+               else {
+                       if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+                                           texImage->TexFormat, texImage->Data,
+                                           xoffset, yoffset, zoffset,
+                                           dstRowStride,
+                                           texImage->ImageOffsets,
+                                           width, height, depth,
+                                           format, type, pixels, packing)) {
                                _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
+                       }
                }
        }
 
index e87ee9eba2b545c37e3be927f6b24160d699ddfe..84fe6984de45aac250c7ee50869ad71907aefd85 100644 (file)
@@ -138,18 +138,15 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
    }
 
    if (bpt) {
-      StoreTexImageFunc storeImage =
-         _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
-
       src = _s;
       dst = _d;
-      storeImage(ctx, 2, texImage->_BaseFormat,
-                                      texImage->TexFormat, dstImage,
-                                      0, 0, 0, /* dstX/Y/Zoffset */
-                                      dstWidth * bpt,
-                                      &dstImageOffsets,
-                                      dstWidth, dstHeight, 1,
-                                      GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, dstImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     dstWidth * bpt,
+                     &dstImageOffsets,
+                     dstWidth, dstHeight, 1,
+                     GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
       FREE(dst);
       FREE(src);
    }
@@ -1231,21 +1228,19 @@ adjust2DRatio (GLcontext *ctx,
 
    if (!texImage->IsCompressed) {
       GLubyte *destAddr;
-      StoreTexImageFunc storeImage =
-         _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
 
       tempImage = MALLOC(width * height * texelBytes);
       if (!tempImage) {
          return GL_FALSE;
       }
 
-      storeImage(ctx, 2, texImage->_BaseFormat,
-                 texImage->TexFormat, tempImage,
-                 0, 0, 0, /* dstX/Y/Zoffset */
-                 width * texelBytes, /* dstRowStride */
-                 &dstImageOffsets,
-                 width, height, 1,
-                 format, type, pixels, packing);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, tempImage,
+                     0, 0, 0, /* dstX/Y/Zoffset */
+                     width * texelBytes, /* dstRowStride */
+                     &dstImageOffsets,
+                     width, height, 1,
+                     format, type, pixels, packing);
 
       /* now rescale */
       /* compute address of dest subimage within the overal tex image */
@@ -1262,8 +1257,6 @@ adjust2DRatio (GLcontext *ctx,
    } else {
       const GLint rawBytes = 4;
       GLvoid *rawImage = MALLOC(width * height * rawBytes);
-      StoreTexImageFunc storeImage =
-         _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
 
       if (!rawImage) {
          return GL_FALSE;
@@ -1287,13 +1280,13 @@ adjust2DRatio (GLcontext *ctx,
                                width, height, /* src */
                                newWidth, newHeight, /* dst */
                                rawImage /*src*/, tempImage /*dst*/ );
-      storeImage(ctx, 2, texImage->_BaseFormat,
-                 texImage->TexFormat, texImage->Data,
-                 xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
-                 dstRowStride,
-                 &dstImageOffsets,
-                 newWidth, newHeight, 1,
-                 GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+      _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                     texImage->TexFormat, texImage->Data,
+                     xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+                     dstRowStride,
+                     &dstImageOffsets,
+                     newWidth, newHeight, 1,
+                     GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
       FREE(rawImage);
    }
 
@@ -1446,16 +1439,13 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
        else {
           /* no rescaling needed */
           /* unpack image, apply transfer ops and store in texImage->Data */
-          StoreTexImageFunc storeImage =
-             _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
-
-          storeImage(ctx, 2, texImage->_BaseFormat,
-                     texImage->TexFormat, texImage->Data,
-                     0, 0, 0, /* dstX/Y/Zoffset */
-                     dstRowStride,
-                     texImage->ImageOffsets,
-                     width, height, 1,
-                     format, type, pixels, packing);
+          _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                         texImage->TexFormat, texImage->Data,
+                         0, 0, 0, /* dstX/Y/Zoffset */
+                         dstRowStride,
+                         texImage->ImageOffsets,
+                         width, height, 1,
+                         format, type, pixels, packing);
        }
     }
 
@@ -1519,16 +1509,13 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
     }
     else {
         /* no rescaling needed */
-       StoreTexImageFunc storeImage =
-          _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
-
-        storeImage(ctx, 2, texImage->_BaseFormat,
-                   texImage->TexFormat, texImage->Data,
-                   xoffset, yoffset, 0,
-                   dstRowStride,
-                   texImage->ImageOffsets,
-                   width, height, 1,
-                   format, type, pixels, packing);
+       _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                      texImage->TexFormat, texImage->Data,
+                      xoffset, yoffset, 0,
+                      dstRowStride,
+                      texImage->ImageOffsets,
+                      width, height, 1,
+                      format, type, pixels, packing);
     }
 
     ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
index 02a0043bbe3369b0d79c9d6304c114dbecd45cd6..f70099402599408ad7d884ba56f0689f62a67db6 100644 (file)
@@ -792,8 +792,6 @@ static void viaTexImage(GLcontext *ctx,
    else {
       GLint dstRowStride;
       GLboolean success;
-      StoreTexImageFunc storeImage =
-         _mesa_get_texstore_func(texImage->TexFormat->MesaFormat);
 
       if (texImage->IsCompressed) {
          dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
@@ -801,16 +799,15 @@ static void viaTexImage(GLcontext *ctx,
       else {
          dstRowStride = postConvWidth * _mesa_get_format_bytes(texImage->TexFormat->MesaFormat);
       }
-      ASSERT(storeImage);
-      success = storeImage(ctx, dims,
-                           texImage->_BaseFormat,
-                           texImage->TexFormat,
-                           texImage->Data,
-                           0, 0, 0,  /* dstX/Y/Zoffset */
-                           dstRowStride,
-                           texImage->ImageOffsets,
-                           width, height, 1,
-                           format, type, pixels, packing);
+      success = _mesa_texstore(ctx, dims,
+                               texImage->_BaseFormat,
+                               texImage->TexFormat,
+                               texImage->Data,
+                               0, 0, 0,  /* dstX/Y/Zoffset */
+                               dstRowStride,
+                               texImage->ImageOffsets,
+                               width, height, 1,
+                               format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
       }