crocus/gen45: fix mapping compressed textures
authorDave Airlie <airlied@gmail.com>
Mon, 2 Aug 2021 06:26:46 +0000 (02:26 -0400)
committerDave Airlie <airlied@redhat.com>
Mon, 2 Aug 2021 19:37:52 +0000 (05:37 +1000)
I don't think iris ever hits this path, but probably has the same bug if
it did.

Fixes texsubimage on gfx4 + gfx4.5

Fixes: 5bf6ec31ccf6 ("crocus/gen4: restrict memcpy mapping to gen5")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12164>

src/gallium/drivers/crocus/crocus_resource.c

index f189f1a..5adca55 100644 (file)
@@ -1542,12 +1542,17 @@ crocus_map_direct(struct crocus_transfer *map)
       const unsigned cpp = fmtl->bpb / 8;
       unsigned x0_el, y0_el;
 
+      assert(box->x % fmtl->bw == 0);
+      assert(box->y % fmtl->bh == 0);
       get_image_offset_el(surf, xfer->level, box->z, &x0_el, &y0_el);
 
+      x0_el += box->x / fmtl->bw;
+      y0_el += box->y / fmtl->bh;
+
       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;
+      map->ptr = ptr + y0_el * xfer->stride + x0_el * cpp;
    }
 }