summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2017-08-30 00:45:42 -0400
committerJason Ekstrand <jason.ekstrand@intel.com>2017-09-05 12:40:14 -0700
commitf48a7a8a19958e31a72817118333707447f69743 (patch)
treefa4b7c9fa683548fcd4369da94c7232ac9e2f2d9
parent19531d012c7208dfbe34cb9d6248133af50bdcb7 (diff)
modesetting: Create scanout buffers using supported modifierslfrb-modifiers-v2
Use most optimal buffer format (e.g. tiled/compressed) available for scanout. Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 95005f4de..bd0bbdba7 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -73,6 +73,48 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
#endif
+static uint32_t
+get_modifiers_set(ScrnInfoPtr scrn, uint32_t format, uint64_t **modifiers)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c, i, j, k, count_modifiers = 0;
+ uint64_t *tmp, *ret = NULL;
+
+ *modifiers = NULL;
+ for (c = 0; c < xf86_config->num_crtc; c++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ for (i = 0; i < drmmode_crtc->count_formats; i++) {
+ drmmode_format_ptr iter = &drmmode_crtc->formats[i];
+
+ if (iter->format != format)
+ continue;
+
+ for (j = 0; j < iter->count_modifiers; j++) {
+ Bool found = FALSE;
+
+ for (k = 0; k < count_modifiers; k++) {
+ if (iter->modifiers[j] == ret[k])
+ found = TRUE;
+ }
+ if (!found) {
+ count_modifiers++;
+ tmp = realloc(ret, count_modifiers * sizeof(uint64_t));
+ if (!tmp) {
+ free(ret);
+ return 0;
+ }
+ ret[count_modifiers - 1] = iter->modifiers[j];
+ }
+ }
+ }
+ }
+
+ *modifiers = ret;
+ return count_modifiers;
+}
+
static Bool
drmmode_zaphod_string_matches(ScrnInfoPtr scrn, const char *s, char *output_name)
{
@@ -601,6 +643,20 @@ drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
#ifdef GLAMOR_HAS_GBM
if (drmmode->glamor) {
+#ifdef GBM_BO_WITH_MODIFIERS
+ uint32_t num_modifiers;
+ uint64_t *modifiers = NULL;
+
+ num_modifiers = get_modifiers_set(drmmode->scrn, DRM_FORMAT_ARGB8888,
+ &modifiers);
+ bo->gbm = gbm_bo_create_with_modifiers(drmmode->gbm, width, height,
+ GBM_FORMAT_ARGB8888,
+ modifiers, num_modifiers);
+ free(modifiers);
+ if (bo->gbm)
+ return TRUE;
+#endif
+
bo->gbm = gbm_bo_create(drmmode->gbm, width, height,
GBM_FORMAT_ARGB8888,
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);