summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarad Gautam <varad.gautam@collabora.com>2016-12-06 13:50:00 (GMT)
committerVarad Gautam <varadgautam@gmail.com>2016-12-14 14:12:06 (GMT)
commitef3d217134077e2fbdeb58394ff948a48d308d74 (patch)
tree4c7a616a2b44ead0ae116b1dac63073cce6c0037
parent47a0faab956afc72330c12629153bd80793b2a6f (diff)
downloadmesa-egl-modifiers-i915.tar.gz
mesa-egl-modifiers-i915.tar.xz
i965: support format and modifier queriesegl-modifiers-i915
modifier list as per vsyrjala/fb_format_dedup_2_ccs, ccs only supported for rgb8888 fmts on gen9+. v2 Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 561e711..31ccead 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -311,6 +311,18 @@ static struct intel_image_format intel_image_formats[] = {
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
};
+static const struct intel_modifier_info {
+ uint64_t modifier; /* fourcc modifier code */
+ uint8_t since_gen; /* introduced in gen */
+ bool rgb8888_only; /* only supported with RGB8888 formats */
+} intel_modifier_info[] = {
+ { I915_FORMAT_MOD_Y_TILED, 9, false },
+ { /* I915_FORMAT_MOD_Y_TILED_CCS */ fourcc_mod_code(INTEL, 4), 9, true },
+ /* TODO add Yf_TILED, Yf_TILED_CCS when supported */
+ { I915_FORMAT_MOD_X_TILED, 1, false },
+ { DRM_FORMAT_MOD_NONE, 1, false }
+};
+
static void
intel_image_warn_if_unaligned(__DRIimage *image, const char *func)
{
@@ -1038,6 +1050,47 @@ intel_create_image_from_dma_bufs2(__DRIscreen *dri_screen,
loaderPrivate);
}
+static void
+intel_query_dma_buf_formats(__DRIscreen *screen, int max,
+ int *formats, int *count)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(intel_image_formats) && i < max; i++)
+ formats[i] = intel_image_formats[i].fourcc;
+
+ *count = max ? i + 1 : ARRAY_SIZE(intel_image_formats);
+}
+
+static void
+intel_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
+ uint64_t *modifiers, int *count)
+{
+ struct intel_screen *screen = _screen->driverPrivate;
+ bool is_rgb8888 = false;
+ int num_mods = 0, i;
+
+ switch (fourcc) {
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_ABGR8888:
+ case DRM_FORMAT_XRGB8888:
+ case DRM_FORMAT_ARGB8888:
+ is_rgb8888 = true;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(intel_modifier_info); i++) {
+ if (screen->devinfo.gen >= intel_modifier_info[i].since_gen)
+ if (!intel_modifier_info[i].rgb8888_only ||
+ is_rgb8888 == intel_modifier_info[i].rgb8888_only) {
+ if (max == 0)
+ num_mods++;
+ else if (num_mods < max)
+ modifiers[num_mods++] = intel_modifier_info[i].modifier;
+ }
+ }
+ *count = num_mods;
+}
+
static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
{
@@ -1094,7 +1147,7 @@ done:
}
static const __DRIimageExtension intelImageExtension = {
- .base = { __DRI_IMAGE, 15 },
+ .base = { __DRI_IMAGE, 16 },
.createImageFromName = intel_create_image_from_name,
.createImageFromRenderbuffer = intel_create_image_from_renderbuffer,
@@ -1114,6 +1167,8 @@ static const __DRIimageExtension intelImageExtension = {
.unmapImage = NULL,
.createImageWithModifiers = intel_create_image_with_modifiers,
.createImageFromDmaBufs2 = intel_create_image_from_dma_bufs2,
+ .queryDmaBufFormats = intel_query_dma_buf_formats,
+ .queryDmaBufModifiers = intel_query_dma_buf_modifiers,
};
static int