mesa_format mesa_format;
GLenum gl_target = texImage->TexObject->Target;
enum pipe_texture_target pipe_target;
+ unsigned dims;
struct pipe_blit_info blit;
unsigned bind;
struct pipe_transfer *tex_xfer;
}
mesa_format = st_pipe_format_to_mesa_format(dst_format);
+ dims = _mesa_get_texture_dimensions(gl_target);
/* copy/pack data into user buffer */
if (_mesa_format_matches_format_and_type(mesa_format, format, type,
GLuint row, slice;
for (slice = 0; slice < depth; slice++) {
- if (gl_target == GL_TEXTURE_1D_ARRAY) {
- /* 1D array textures.
- * We need to convert gallium coords to GL coords.
- */
- void *dest = _mesa_image_address3d(&ctx->Pack, pixels,
- width, depth, format,
- type, 0, slice, 0);
- memcpy(dest, map, bytesPerRow);
- }
- else {
- ubyte *slice_map = map;
+ ubyte *slice_map = map;
- for (row = 0; row < height; row++) {
- void *dest = _mesa_image_address3d(&ctx->Pack, pixels,
- width, height, format,
- type, slice, row, 0);
- memcpy(dest, slice_map, bytesPerRow);
- slice_map += tex_xfer->stride;
- }
+ for (row = 0; row < height; row++) {
+ void *dest = _mesa_image_address(dims, &ctx->Pack, pixels,
+ width, height, format, type,
+ slice, row, 0);
+
+ memcpy(dest, slice_map, bytesPerRow);
+
+ slice_map += tex_xfer->stride;
}
+
map += tex_xfer->layer_stride;
}
}
else {
/* format translation via floats */
- GLuint row, slice;
+ GLuint slice;
GLfloat *rgba;
uint32_t dstMesaFormat;
int dstStride, srcStride;
assert(util_format_is_compressed(src->format));
- rgba = malloc(width * 4 * sizeof(GLfloat));
+ rgba = malloc(width * height * 4 * sizeof(GLfloat));
if (!rgba) {
goto end;
}
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.
- * We need to convert gallium coords to GL coords.
- */
- void *dest = _mesa_image_address3d(&ctx->Pack, pixels,
- width, depth, format,
- type, 0, slice, 0);
+ void *dest = _mesa_image_address(dims, &ctx->Pack, pixels,
+ width, height, format, type,
+ slice, 0, 0);
- /* get float[4] rgba row from surface */
- pipe_get_tile_rgba_format(tex_xfer, map, 0, 0, width, 1,
- dst_format, rgba);
+ /* get float[4] rgba row from surface */
+ pipe_get_tile_rgba_format(tex_xfer, map, 0, 0, width, height,
+ dst_format, rgba);
+
+ _mesa_format_convert(dest, dstMesaFormat, dstStride,
+ rgba, RGBA32_FLOAT, srcStride,
+ width, height, NULL);
- _mesa_format_convert(dest, dstMesaFormat, dstStride,
- rgba, RGBA32_FLOAT, srcStride,
- width, 1, NULL);
- }
- else {
- for (row = 0; row < height; row++) {
- void *dest = _mesa_image_address3d(&ctx->Pack, pixels,
- width, height, format,
- type, slice, row, 0);
-
- /* get float[4] rgba row from surface */
- pipe_get_tile_rgba_format(tex_xfer, map, 0, row, width, 1,
- dst_format, rgba);
-
- _mesa_format_convert(dest, dstMesaFormat, dstStride,
- rgba, RGBA32_FLOAT, srcStride,
- width, 1, NULL);
- }
- }
map += tex_xfer->layer_stride;
}