iris: "Fix" transfer maps of buffers
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 10 Nov 2018 10:25:24 +0000 (02:25 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:10 +0000 (10:26 -0800)
x should be in bytes, not cpp units

This generally worked out because PIPE_BUFFER is supposedly required
to be R8_UINT or R8_UNORM.  I hear some state trackers pass
PIPE_FORMAT_NONE instead, however, which would make this break.

Just do the right thing directly, to be defensive and clear.

src/gallium/drivers/iris/iris_resource.c

index e4850dd86ae8adaa9253362820d50a1d3989fa3e..7fe13e2ed765e98bb1208ec3d2858508d3b5864f 100644 (file)
@@ -779,14 +779,21 @@ iris_map_direct(struct iris_transfer *map)
    const unsigned cpp = fmtl->bpb / 8;
    unsigned x0_el, y0_el;
 
-   get_image_offset_el(surf, xfer->level, box->z, &x0_el, &y0_el);
+   void *ptr = iris_bo_map(map->dbg, res->bo, xfer->usage);
 
-   xfer->stride = isl_surf_get_row_pitch_B(surf);
-   xfer->layer_stride = isl_surf_get_array_pitch(surf);
+   if (res->base.target == PIPE_BUFFER) {
+      xfer->stride = 0;
+      xfer->layer_stride = 0;
 
-   void *ptr = iris_bo_map(map->dbg, res->bo, xfer->usage);
+      map->ptr = ptr + box->x;
+   } else {
+      get_image_offset_el(surf, xfer->level, box->z, &x0_el, &y0_el);
 
-   map->ptr = ptr + (y0_el + box->y) * xfer->stride + (x0_el + box->x) * cpp;
+      xfer->stride = isl_surf_get_row_pitch_B(surf);
+      xfer->layer_stride = isl_surf_get_array_pitch(surf);
+
+      map->ptr = ptr + (y0_el + box->y) * xfer->stride + (x0_el + box->x) * cpp;
+   }
 }
 
 static void *