swr: fix texture layout for compressed formats
authorIlia Mirkin <imirkin@alum.mit.edu>
Wed, 9 Nov 2016 21:41:16 +0000 (16:41 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 16 Nov 2016 01:25:15 +0000 (20:25 -0500)
Fixes the texsubimage piglit and lets the copyteximage one get further.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/swr_context.cpp
src/gallium/drivers/swr/swr_screen.cpp

index 6c0782a40d31188760d3f819776baeeb0438c1fc..a5ab2362e55abaf228d6eeaf7a6922f9f1711b04 100644 (file)
@@ -157,8 +157,9 @@ swr_transfer_map(struct pipe_context *pipe,
       }
    }
 
-   unsigned offset = box->z * pt->layer_stride + box->y * pt->stride
-      + box->x * util_format_get_blocksize(format);
+   unsigned offset = box->z * pt->layer_stride +
+      util_format_get_nblocksy(format, box->y) * pt->stride +
+      util_format_get_stride(format, box->x);
 
    *transfer = pt;
 
index fa16edd1250ad5fe4407cf2f526a123ef7861d9f..16a8bcf2c4a9840bf2ea529d7e76462652da5b60 100644 (file)
@@ -796,8 +796,9 @@ swr_texture_layout(struct swr_screen *screen,
          res->alignedHeight = alignedHeight;
       }
 
-      res->row_stride[level] = alignedWidth * finfo.Bpp;
-      res->img_stride[level] = res->row_stride[level] * alignedHeight;
+      res->row_stride[level] = util_format_get_stride(fmt, alignedWidth);
+      res->img_stride[level] =
+         res->row_stride[level] * util_format_get_nblocksy(fmt, alignedHeight);
       res->mip_offsets[level] = total_size;
 
       if (pt->target == PIPE_TEXTURE_3D)