OSDN Git Service

minigbm: vgem: align to llvm tile size
authorGurchetan Singh <gurchetansingh@chromium.org>
Wed, 30 Nov 2016 04:36:13 +0000 (20:36 -0800)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 9 Dec 2016 11:30:19 +0000 (03:30 -0800)
We're planning on using Mesa with llvmpipe when running
the Android container in a virtual machine. It's faster
than softpipe. llvmpipe requires alignment to a 64-byte
tile size, so add it here.  This is the analogue to
norvez@'s drm_gralloc commiti (ag/1599269).

BUG=b:28802929, chromium:616275
TEST=run arc-cros-gralloc in QEMU

CQ-DEPEND=CL:414537

Change-Id: If4160d376447ce218df3bc410a8427b284de74fd
Reviewed-on: https://chromium-review.googlesource.com/416291
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
vgem.c

diff --git a/vgem.c b/vgem.c
index 3b6fb5a..14f2c0e 100644 (file)
--- a/vgem.c
+++ b/vgem.c
@@ -8,6 +8,9 @@
 #include "helpers.h"
 #include "util.h"
 
+#define MESA_LLVMPIPE_TILE_ORDER 6
+#define MESA_LLVMPIPE_TILE_SIZE (1 << MESA_LLVMPIPE_TILE_ORDER)
+
 static struct supported_combination combos[2] = {
        {DRM_FORMAT_ABGR8888, DRM_FORMAT_MOD_NONE,
                BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
@@ -21,6 +24,18 @@ static int vgem_init(struct driver *drv)
        return 0;
 }
 
+static int vgem_bo_create(struct bo *bo, uint32_t width, uint32_t height,
+                         uint32_t format, uint32_t flags)
+{
+       int ret = drv_dumb_bo_create(bo, ALIGN(width, MESA_LLVMPIPE_TILE_SIZE),
+                                    ALIGN(height, MESA_LLVMPIPE_TILE_SIZE),
+                                    format, flags);
+       bo->width = width;
+       bo->height = height;
+
+       return ret;
+}
+
 static uint32_t vgem_resolve_format(uint32_t format)
 {
        switch (format) {
@@ -38,7 +53,7 @@ struct backend backend_vgem =
 {
        .name = "vgem",
        .init = vgem_init,
-       .bo_create = drv_dumb_bo_create,
+       .bo_create = vgem_bo_create,
        .bo_destroy = drv_dumb_bo_destroy,
        .bo_map = drv_dumb_bo_map,
        .resolve_format = vgem_resolve_format,