zink: really fix direct image mapping offset (I mean it this time)
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sat, 12 Dec 2020 16:59:40 +0000 (11:59 -0500)
committerMarge Bot <eric+marge@anholt.net>
Mon, 14 Dec 2020 14:30:42 +0000 (14:30 +0000)
I got confused and:
* used the vkformat instead of the pipe format for getting format description
* incorrectly calculated bpp

but this time it's definitely 100% fixed I promise

Fixes: 456b57802ea ("zink: fix direct image mapping offset")

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8074>

src/gallium/drivers/zink/zink_resource.c

index 9f8dde7..7d37b52 100644 (file)
@@ -613,11 +613,11 @@ zink_transfer_map(struct pipe_context *pctx,
          vkGetImageSubresourceLayout(screen->dev, res->image, &isr, &srl);
          trans->base.stride = srl.rowPitch;
          trans->base.layer_stride = srl.arrayPitch;
-         const struct util_format_description *desc = util_format_description(res->format);
+         const struct util_format_description *desc = util_format_description(res->base.format);
          unsigned offset = srl.offset +
                            box->z * srl.depthPitch +
                            (box->y / desc->block.height) * srl.rowPitch +
-                           (box->x / desc->block.width) * (util_format_get_blocksize(res->format) / desc->nr_channels);
+                           (box->x / desc->block.width) * (desc->block.bits / 8);
          ptr = ((uint8_t *)ptr) + offset;
       }
    }