st/mesa: Use _mesa_format_convert to implement st_GetTexImage.
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 26 Nov 2014 09:20:55 +0000 (10:20 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 12 Jan 2015 10:20:29 +0000 (11:20 +0100)
Instead of using _mesa_pack_rgba_span_float. This should allow us to remove
that function in a later patch.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/state_tracker/st_cb_texture.c

index 4b9901a1b0eb17aef5c96a1393873b959982f4ba..1fb9db6fb686509aacb054860d8e63a8e7ace1c0 100644 (file)
@@ -29,6 +29,8 @@
 #include "main/enums.h"
 #include "main/fbobject.h"
 #include "main/formats.h"
+#include "main/format_utils.h"
+#include "main/glformats.h"
 #include "main/image.h"
 #include "main/imports.h"
 #include "main/macros.h"
@@ -1138,6 +1140,8 @@ st_GetTexImage(struct gl_context * ctx,
       /* format translation via floats */
       GLuint row, slice;
       GLfloat *rgba;
+      uint32_t dstMesaFormat;
+      int dstStride, srcStride;
 
       assert(util_format_is_compressed(src->format));
 
@@ -1149,6 +1153,9 @@ st_GetTexImage(struct gl_context * ctx,
       if (ST_DEBUG & DEBUG_FALLBACK)
          debug_printf("%s: fallback format translation\n", __FUNCTION__);
 
+      dstMesaFormat = _mesa_format_from_format_and_type(format, type);
+      dstStride = _mesa_image_row_stride(&ctx->Pack, width, format, type);
+      srcStride = 4 * width * sizeof(GLfloat);
       for (slice = 0; slice < depth; slice++) {
          if (gl_target == GL_TEXTURE_1D_ARRAY) {
             /* 1D array textures.
@@ -1162,8 +1169,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, srcStride,
+                                 width, 1, NULL);
          }
          else {
             for (row = 0; row < height; row++) {
@@ -1175,8 +1183,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, srcStride,
+                                    width, 1, NULL);
             }
          }
          map += tex_xfer->layer_stride;