OSDN Git Service

minigbm: remove BO_USE_RENDERING from certain formats
authorGurchetan Singh <gurchetansingh@google.com>
Mon, 15 May 2017 16:34:22 +0000 (09:34 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Wed, 24 May 2017 06:59:12 +0000 (23:59 -0700)
We can't use GR88, R8, YV12, NV12, UYVY, YUYV buffers as render
targets, so let's remove the BO_USE_RENDERING flag from these
formats. However, we can sample from these formats (though this
feature still needs to be enabled in our drivers), so the
BO_USE_TEXTURE flag remains set.

Also, change our interpretation of the GRALLOC_USAGE_HW_COMPOSER
flag such that it implies BO_USE_SCANOUT | BO_USE_TEXTURE. This
is because the OpenGL fallback textures from the buffer if
can't be scanned-out, not renders to it.

BUG=none
TEST=run Youtube app on Kevin

Change-Id: I9ea8452279e110bc1a9579f162abe1c72192eb40
Reviewed-on: https://chromium-review.googlesource.com/506812
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
20 files changed:
amdgpu.c
cirrus.c
cros_gralloc/cros_gralloc_helpers.cc
drv.h
drv_priv.h
evdi.c
exynos.c
gma500.c
helpers.c
helpers.h
i915.c
marvell.c
mediatek.c
nouveau.c
rockchip.c
tegra.c
udl.c
vc4.c
vgem.c
virtio_gpu.c

index 1fd9d13..571529b 100644 (file)
--- a/amdgpu.c
+++ b/amdgpu.c
@@ -41,8 +41,8 @@ enum {
 };
 // clang-format on
 
-const static uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR8888,
-                                             DRM_FORMAT_XRGB8888 };
+const static uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR8888,
+                                                 DRM_FORMAT_XRGB8888 };
 
 static int amdgpu_set_metadata(int fd, uint32_t handle, struct amdgpu_bo_metadata *info)
 {
@@ -271,7 +271,7 @@ static int amdgpu_init(struct driver *drv)
        int ret;
        void *addrlib;
        struct format_metadata metadata;
-       uint32_t flags = BO_COMMON_USE_MASK;
+       uint32_t flags = BO_USE_RENDER_MASK;
 
        addrlib = amdgpu_addrlib_init(drv_get_fd(drv));
        if (!addrlib)
@@ -283,8 +283,8 @@ static int amdgpu_init(struct driver *drv)
        metadata.priority = 1;
        metadata.modifier = DRM_FORMAT_MOD_NONE;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, flags);
        if (ret)
                return ret;
 
@@ -296,8 +296,8 @@ static int amdgpu_init(struct driver *drv)
        metadata.priority = 2;
        metadata.modifier = DRM_FORMAT_MOD_NONE;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, flags);
        if (ret)
                return ret;
 
@@ -308,8 +308,8 @@ static int amdgpu_init(struct driver *drv)
        metadata.tiling = ADDR_DISPLAYABLE << 16 | ADDR_TM_2D_TILED_THIN1;
        metadata.priority = 3;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, flags);
        if (ret)
                return ret;
 
@@ -320,8 +320,8 @@ static int amdgpu_init(struct driver *drv)
        metadata.tiling = ADDR_NON_DISPLAYABLE << 16 | ADDR_TM_2D_TILED_THIN1;
        metadata.priority = 4;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, flags);
        if (ret)
                return ret;
 
index bcd308b..4f0e983 100644 (file)
--- a/cirrus.c
+++ b/cirrus.c
@@ -8,12 +8,18 @@
 #include "helpers.h"
 #include "util.h"
 
-const static uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB888,
-                                             DRM_FORMAT_XRGB8888 };
+const static uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB888,
+                                                 DRM_FORMAT_XRGB8888 };
 
 static int cirrus_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 struct backend backend_cirrus = {
index 280e5f8..6504b10 100644 (file)
@@ -33,7 +33,7 @@ uint64_t cros_gralloc_convert_flags(int flags)
                usage |= BO_USE_RENDERING;
        if (flags & GRALLOC_USAGE_HW_COMPOSER)
                /* HWC wants to use display hardware, but can defer to OpenGL. */
-               usage |= BO_USE_SCANOUT | BO_USE_RENDERING;
+               usage |= BO_USE_SCANOUT | BO_USE_TEXTURE;
        if (flags & GRALLOC_USAGE_HW_FB)
                usage |= BO_USE_NONE;
        if (flags & GRALLOC_USAGE_EXTERNAL_DISP)
diff --git a/drv.h b/drv.h
index 18e9233..f478a66 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -49,10 +49,6 @@ extern "C" {
 #define DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED fourcc_code('9', '9', '9', '8')
 #define DRM_FORMAT_FLEX_YCbCr_420_888          fourcc_code('9', '9', '9', '9')
 
-#define BO_COMMON_USE_MASK BO_USE_LINEAR | BO_USE_RENDERING | \
-                          BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
-                          BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | \
-                          BO_USE_TEXTURE
 // clang-format on
 struct driver;
 struct bo;
index 8884ea7..df5c8e9 100644 (file)
@@ -79,4 +79,15 @@ struct backend {
        struct combinations combos;
 };
 
+// clang-format off
+#define BO_USE_RENDER_MASK BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_SW_READ_OFTEN | \
+                          BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \
+                          BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
+
+#define BO_USE_TEXTURE_MASK BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \
+                           BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE
+
+#define LINEAR_METADATA (struct format_metadata) { 0, 1, DRM_FORMAT_MOD_NONE }
+// clang-format on
+
 #endif
diff --git a/evdi.c b/evdi.c
index dbdb79f..f66fb2d 100644 (file)
--- a/evdi.c
+++ b/evdi.c
@@ -8,11 +8,17 @@
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
 
 static int evdi_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 struct backend backend_evdi = {
index 7ff46e5..0d935eb 100644 (file)
--- a/exynos.c
+++ b/exynos.c
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_NV12,
-                                             DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
+
+static const uint32_t texture_source_formats[] = { DRM_FORMAT_NV12 };
 
 static int exynos_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                  &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 static int exynos_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
index 93d1bb8..5b08bc3 100644 (file)
--- a/gma500.c
+++ b/gma500.c
@@ -8,11 +8,17 @@
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_RGBX8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_RGBX8888 };
 
 static int gma500_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 struct backend backend_gma500 = {
index e9d2836..9a665ce 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -501,21 +501,12 @@ out:
        return items;
 }
 
-int drv_add_linear_combinations(struct driver *drv, const uint32_t *formats, uint32_t num_formats)
+int drv_modify_linear_combinations(struct driver *drv)
 {
-       int ret;
        uint32_t i, j, num_items;
        struct kms_item *items;
        struct combination *combo;
-       struct format_metadata metadata;
-
-       metadata.tiling = 0;
-       metadata.priority = 1;
-       metadata.modifier = DRM_FORMAT_MOD_NONE;
 
-       ret = drv_add_combinations(drv, formats, num_formats, &metadata, BO_COMMON_USE_MASK);
-       if (ret)
-               return ret;
        /*
         * All current drivers can scanout linear XRGB8888/ARGB8888 as a primary
         * plane and as a cursor. Some drivers don't support
@@ -523,8 +514,10 @@ int drv_add_linear_combinations(struct driver *drv, const uint32_t *formats, uin
         * kernel disregards the alpha component of ARGB unless it's an overlay
         * plane.
         */
-       drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
-       drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
+       drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &LINEAR_METADATA,
+                              BO_USE_CURSOR | BO_USE_SCANOUT);
+       drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &LINEAR_METADATA,
+                              BO_USE_CURSOR | BO_USE_SCANOUT);
 
        items = drv_query_kms(drv, &num_items);
        if (!items || !num_items)
index ebe6987..b42a3c2 100644 (file)
--- a/helpers.h
+++ b/helpers.h
@@ -28,5 +28,5 @@ int drv_add_combinations(struct driver *drv, const uint32_t *formats, uint32_t n
 void drv_modify_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata,
                            uint64_t usage);
 struct kms_item *drv_query_kms(struct driver *drv, uint32_t *num_items);
-int drv_add_linear_combinations(struct driver *drv, const uint32_t *formats, uint32_t num_formats);
+int drv_modify_linear_combinations(struct driver *drv);
 #endif
diff --git a/i915.c b/i915.c
index efdeda6..aee3055 100644 (file)
--- a/i915.c
+++ b/i915.c
 #define I915_CACHELINE_SIZE 64
 #define I915_CACHELINE_MASK (I915_CACHELINE_SIZE - 1)
 
-static const uint32_t tileable_formats[] = { DRM_FORMAT_ARGB1555, DRM_FORMAT_ABGR8888,
-                                            DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
-                                            DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB1555,
-                                            DRM_FORMAT_XRGB8888, DRM_FORMAT_UYVY,
-                                            DRM_FORMAT_YUYV };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB1555, DRM_FORMAT_ABGR8888,
+                                                 DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
+                                                 DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB1555,
+                                                 DRM_FORMAT_XRGB8888 };
 
-static const uint32_t linear_only_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_YVU420,
-                                               DRM_FORMAT_YVU420_ANDROID };
+static const uint32_t tileable_texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8,
+                                                           DRM_FORMAT_UYVY, DRM_FORMAT_YUYV };
+
+static const uint32_t texture_source_formats[] = { DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID };
 
 struct i915_device {
        uint32_t gen;
@@ -79,42 +80,66 @@ static int i915_add_combinations(struct driver *drv)
        uint32_t i, num_items;
        struct kms_item *items;
        struct format_metadata metadata;
-       uint64_t flags = BO_COMMON_USE_MASK;
+       uint64_t render_flags, texture_flags;
+
+       render_flags = BO_USE_RENDER_MASK;
+       texture_flags = BO_USE_TEXTURE_MASK;
 
        metadata.tiling = I915_TILING_NONE;
        metadata.priority = 1;
        metadata.modifier = DRM_FORMAT_MOD_NONE;
 
-       ret = drv_add_combinations(drv, linear_only_formats, ARRAY_SIZE(linear_only_formats),
-                                  &metadata, flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, render_flags);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                  &metadata, texture_flags);
        if (ret)
                return ret;
 
-       ret = drv_add_combinations(drv, tileable_formats, ARRAY_SIZE(tileable_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, tileable_texture_source_formats,
+                                  ARRAY_SIZE(texture_source_formats), &metadata, texture_flags);
        if (ret)
                return ret;
 
        drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
        drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
 
-       flags &= ~BO_USE_SW_WRITE_OFTEN;
-       flags &= ~BO_USE_SW_READ_OFTEN;
-       flags &= ~BO_USE_LINEAR;
+       render_flags &= ~BO_USE_SW_WRITE_OFTEN;
+       render_flags &= ~BO_USE_SW_READ_OFTEN;
+       render_flags &= ~BO_USE_LINEAR;
+
+       texture_flags &= ~BO_USE_SW_WRITE_OFTEN;
+       texture_flags &= ~BO_USE_SW_READ_OFTEN;
+       texture_flags &= ~BO_USE_LINEAR;
 
        metadata.tiling = I915_TILING_X;
        metadata.priority = 2;
 
-       ret = drv_add_combinations(drv, tileable_formats, ARRAY_SIZE(tileable_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, render_flags);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, tileable_texture_source_formats,
+                                  ARRAY_SIZE(tileable_texture_source_formats), &metadata,
+                                  texture_flags);
        if (ret)
                return ret;
 
        metadata.tiling = I915_TILING_Y;
        metadata.priority = 3;
 
-       ret = drv_add_combinations(drv, tileable_formats, ARRAY_SIZE(tileable_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, render_flags);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, tileable_texture_source_formats,
+                                  ARRAY_SIZE(tileable_texture_source_formats), &metadata,
+                                  texture_flags);
        if (ret)
                return ret;
 
index d39e264..8114ac7 100644 (file)
--- a/marvell.c
+++ b/marvell.c
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
 
 static int marvell_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_add_linear_combinations(drv, render_target_formats,
+                                          ARRAY_SIZE(render_target_formats));
 }
 
 struct backend backend_marvell = {
index ce7ff87..0078cf0 100644 (file)
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
-                                             DRM_FORMAT_R8,       DRM_FORMAT_RGB565,
-                                             DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
-                                             DRM_FORMAT_YVU420,   DRM_FORMAT_YVU420_ANDROID };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
+                                                 DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
+                                                 DRM_FORMAT_XRGB8888 };
+
+static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_YVU420,
+                                                  DRM_FORMAT_YVU420_ANDROID };
 
 static int mediatek_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                  &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 static int mediatek_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
index aa832c2..7cdab3a 100644 (file)
--- a/nouveau.c
+++ b/nouveau.c
@@ -8,11 +8,17 @@
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
 
 static int nouveau_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 struct backend backend_nouveau = {
index 74a23d4..50ea4ef 100644 (file)
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ABGR8888,      DRM_FORMAT_ARGB8888,
-                                             DRM_FORMAT_NV12,          DRM_FORMAT_R8,
-                                             DRM_FORMAT_RGB565,        DRM_FORMAT_XBGR8888,
-                                             DRM_FORMAT_XRGB8888,      DRM_FORMAT_YVU420,
-                                             DRM_FORMAT_YVU420_ANDROID };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
+                                                 DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
+                                                 DRM_FORMAT_XRGB8888 };
+
+static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_NV12,
+                                                  DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID };
 
 static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, uint32_t format)
 {
@@ -71,7 +72,7 @@ static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, u
 static int rockchip_add_kms_item(struct driver *drv, const struct kms_item *item)
 {
        int ret;
-       uint32_t i;
+       uint32_t i, j;
        uint64_t flags;
        struct combination *combo;
        struct format_metadata metadata;
@@ -85,6 +86,11 @@ static int rockchip_add_kms_item(struct driver *drv, const struct kms_item *item
                                metadata.tiling = 0;
                                metadata.priority = 2;
 
+                               for (j = 0; j < ARRAY_SIZE(texture_source_formats); j++) {
+                                       if (item->format == texture_source_formats[j])
+                                               flags &= ~BO_USE_RENDERING;
+                               }
+
                                ret = drv_add_combination(drv, item[i].format, &metadata, flags);
                                if (ret)
                                        return ret;
@@ -108,8 +114,13 @@ static int rockchip_init(struct driver *drv)
        metadata.priority = 1;
        metadata.modifier = DRM_FORMAT_MOD_NONE;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  BO_COMMON_USE_MASK);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                  &metadata, BO_USE_TEXTURE_MASK);
        if (ret)
                return ret;
 
diff --git a/tegra.c b/tegra.c
index afdf431..9fca689 100644 (file)
--- a/tegra.c
+++ b/tegra.c
@@ -45,7 +45,7 @@ struct tegra_private_map_data {
        void *untiled;
 };
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
 
 static int compute_block_height_log2(int height)
 {
@@ -170,14 +170,14 @@ static int tegra_init(struct driver *drv)
 {
        int ret;
        struct format_metadata metadata;
-       uint64_t flags = BO_COMMON_USE_MASK;
+       uint64_t flags = BO_USE_RENDER_MASK;
 
        metadata.tiling = NV_MEM_KIND_PITCH;
        metadata.priority = 1;
        metadata.modifier = DRM_FORMAT_MOD_NONE;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, flags);
        if (ret)
                return ret;
 
@@ -191,8 +191,8 @@ static int tegra_init(struct driver *drv)
        metadata.tiling = NV_MEM_KIND_C32_2CRA;
        metadata.priority = 2;
 
-       ret = drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats), &metadata,
-                                  flags);
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &metadata, flags);
        if (ret)
                return ret;
 
diff --git a/udl.c b/udl.c
index dffd5f5..eb15fbe 100644 (file)
--- a/udl.c
+++ b/udl.c
@@ -8,11 +8,17 @@
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
 
 static int udl_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 struct backend backend_udl = {
diff --git a/vc4.c b/vc4.c
index a120f3d..99896b9 100644 (file)
--- a/vc4.c
+++ b/vc4.c
 #include "helpers.h"
 #include "util.h"
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
-                                             DRM_FORMAT_XRGB8888 };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
+                                                 DRM_FORMAT_XRGB8888 };
 
 static int vc4_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 static int vc4_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
diff --git a/vgem.c b/vgem.c
index 15da101..95aee0a 100644 (file)
--- a/vgem.c
+++ b/vgem.c
 #define MESA_LLVMPIPE_TILE_ORDER 6
 #define MESA_LLVMPIPE_TILE_SIZE (1 << MESA_LLVMPIPE_TILE_ORDER)
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
-                                             DRM_FORMAT_R8,       DRM_FORMAT_RGB565,
-                                             DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
-                                             DRM_FORMAT_YVU420,   DRM_FORMAT_YVU420_ANDROID };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
+                                                 DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
+                                                 DRM_FORMAT_XRGB8888 };
+
+static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_YVU420,
+                                                  DRM_FORMAT_YVU420_ANDROID };
 
 static int vgem_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                  &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 static int vgem_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
index 0a351dd..5780600 100644 (file)
 #define MESA_LLVMPIPE_TILE_ORDER 6
 #define MESA_LLVMPIPE_TILE_SIZE (1 << MESA_LLVMPIPE_TILE_ORDER)
 
-static const uint32_t supported_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
-                                             DRM_FORMAT_R8,       DRM_FORMAT_RGB565,
-                                             DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
-                                             DRM_FORMAT_YVU420,   DRM_FORMAT_YVU420_ANDROID };
+static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
+                                                 DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
+                                                 DRM_FORMAT_XRGB8888 };
+
+static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_YVU420,
+                                                  DRM_FORMAT_YVU420_ANDROID };
 
 static int virtio_gpu_init(struct driver *drv)
 {
-       return drv_add_linear_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats));
+       int ret;
+       ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                  &LINEAR_METADATA, BO_USE_RENDER_MASK);
+       if (ret)
+               return ret;
+
+       ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                  &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
+       if (ret)
+               return ret;
+
+       return drv_modify_linear_combinations(drv);
 }
 
 static int virtio_gpu_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,