[Mesa-dev] [PATCH 26/29] mesa: Replace _mesa_pack_rgba_span_float with _mesa_format_convert

Iago Toral Quiroga itoral at igalia.com
Tue Nov 18 01:24:07 PST 2014


This replaces all remaining uses of this function, which will be
removed in another commit.
---
 src/mesa/main/texgetimage.c            | 23 +++++++++++------------
 src/mesa/state_tracker/st_cb_texture.c | 14 ++++++++++----
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 13e5ae6..6bf1681 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -247,8 +247,8 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
    const GLuint width = texImage->Width;
    const GLuint height = texImage->Height;
    const GLuint depth = texImage->Depth;
-   GLfloat *tempImage, *tempSlice, *srcRow;
-   GLuint row, slice;
+   GLfloat *tempImage, *tempSlice;
+   GLuint slice;
 
    /* Decompress into temp float buffer, then pack into user buffer */
    tempImage = malloc(width * height * depth
@@ -310,18 +310,17 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
                               rebaseFormat);
    }
 
+   int srcStride = 4 * width * sizeof(GLfloat);
+   int dstStride = _mesa_image_row_stride(&ctx->Pack, width, format, type);
+   uint32_t dstFormat = _mesa_format_from_format_and_type(format, type);
    tempSlice = tempImage;
    for (slice = 0; slice < depth; slice++) {
-      srcRow = tempSlice;
-      for (row = 0; row < height; row++) {
-         void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
-                                          width, height, format, type,
-                                          slice, row, 0);
-
-         _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow,
-                                    format, type, dest, &ctx->Pack, transferOps);
-         srcRow += 4 * width;
-      }
+      void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+                                       width, height, format, type,
+                                       slice, 0, 0);
+      _mesa_format_convert(dest, dstFormat, dstStride,
+                           tempSlice, RGBA8888_FLOAT.as_uint, srcStride,
+                           width, height, destBaseFormat);
       tempSlice += 4 * width * height;
    }
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index a8dbb78..b93d8c1 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -29,6 +29,7 @@
 #include "main/enums.h"
 #include "main/fbobject.h"
 #include "main/formats.h"
+#include "main/format_utils.h"
 #include "main/image.h"
 #include "main/imports.h"
 #include "main/macros.h"
@@ -1149,6 +1150,9 @@ st_GetTexImage(struct gl_context * ctx,
       if (ST_DEBUG & DEBUG_FALLBACK)
          debug_printf("%s: fallback format translation\n", __FUNCTION__);
 
+      uint32_t dstMesaFormat = _mesa_format_from_format_and_type(format, type);
+      int dstStride = _mesa_image_row_stride(&ctx->Pack, width, format, type);
+      int srcStride = 4 * width * sizeof(GLfloat);
       for (slice = 0; slice < depth; slice++) {
          if (gl_target == GL_TEXTURE_1D_ARRAY) {
             /* 1D array textures.
@@ -1162,8 +1166,9 @@ st_GetTexImage(struct gl_context * ctx,
             pipe_get_tile_rgba_format(tex_xfer, map, 0, 0, width, 1,
                                       dst_format, rgba);
 
-            _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format,
-                                       type, dest, &ctx->Pack, 0);
+            _mesa_format_convert(dest, dstMesaFormat, dstStride,
+                                 rgba, RGBA8888_FLOAT.as_uint, srcStride,
+                                 width, 1, GL_RGBA);
          }
          else {
             for (row = 0; row < height; row++) {
@@ -1175,8 +1180,9 @@ st_GetTexImage(struct gl_context * ctx,
                pipe_get_tile_rgba_format(tex_xfer, map, 0, row, width, 1,
                                          dst_format, rgba);
 
-               _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format,
-                                          type, dest, &ctx->Pack, 0);
+               _mesa_format_convert(dest, dstMesaFormat, dstStride,
+                                    rgba, RGBA8888_FLOAT.as_uint, srcStride,
+                                    width, 1, GL_RGBA);
             }
          }
          map += tex_xfer->layer_stride;
-- 
1.9.1



More information about the mesa-dev mailing list