From c06f6d12a59c4a2374188e03f21377e593c80354 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 10 Nov 2018 02:25:24 -0800 Subject: [PATCH] iris: "Fix" transfer maps of buffers 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 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index e4850dd86ae..7fe13e2ed76 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -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 * -- 2.30.2