From 18986beffe8fabcf4457e6f475e91476b6f2290c Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 22 Nov 2024 11:14:59 +0100 Subject: [PATCH 1/2] modesetting: use gbm_bo_create_with_modifiers2 when possible Use GBM_BO_USE_SCANOUT by default, and add an argument to drmmode_create_bo so the callers can pass other flags. Signed-off-by: Pierre-Eric Pelloux-Prayer --- .../drivers/modesetting/drmmode_display.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 6d0b4453b..103b4a91c 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -1104,7 +1104,8 @@ drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo, static Bool drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo, - unsigned width, unsigned height, unsigned bpp) + unsigned width, unsigned height, unsigned bpp, + uint32_t gbm_bo_use_flag) { bo->width = width; bo->height = height; @@ -1137,9 +1138,16 @@ drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo, FALSE, TRUE); if (num_modifiers > 0 && !(num_modifiers == 1 && modifiers[0] == DRM_FORMAT_MOD_INVALID)) { +#ifdef GBM_BO_WITH_MODIFIERS2 + bo->gbm = gbm_bo_create_with_modifiers2(drmmode->gbm, width, height, + format, modifiers, + num_modifiers, + GBM_BO_USE_SCANOUT | gbm_bo_use_flag); +#else bo->gbm = gbm_bo_create_with_modifiers(drmmode->gbm, width, height, format, modifiers, num_modifiers); +#endif free(modifiers); if (bo->gbm) { bo->used_modifiers = TRUE; @@ -1149,7 +1157,7 @@ drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo, #endif bo->gbm = gbm_bo_create(drmmode->gbm, width, height, format, - GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT); + GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT | gbm_bo_use_flag); bo->used_modifiers = FALSE; return bo->gbm != NULL; } @@ -2106,7 +2114,7 @@ drmmode_shadow_fb_allocate(xf86CrtcPtr crtc, int width, int height, drmmode_ptr drmmode = drmmode_crtc->drmmode; int ret; - if (!drmmode_create_bo(drmmode, bo, width, height, drmmode->kbpp)) { + if (!drmmode_create_bo(drmmode, bo, width, height, drmmode->kbpp, 0)) { xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "Couldn't allocate shadow memory for rotated CRTC\n"); return NULL; @@ -3658,7 +3666,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) drmmode->fb_id = 0; if (!drmmode_create_bo(drmmode, &drmmode->front_bo, - width, height, drmmode->kbpp)) + width, height, drmmode->kbpp, 0)) goto fail; pitch = drmmode_bo_get_pitch(&drmmode->front_bo); @@ -4431,7 +4439,7 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) width = pScrn->virtualX; height = pScrn->virtualY; - if (!drmmode_create_bo(drmmode, &drmmode->front_bo, width, height, bpp)) + if (!drmmode_create_bo(drmmode, &drmmode->front_bo, width, height, bpp, 0)) return FALSE; pScrn->displayWidth = drmmode_bo_get_pitch(&drmmode->front_bo) / cpp; From 3571e9d6183d8e1e644ba632e31b1cf381e1e7a0 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 22 Nov 2024 15:18:29 +0100 Subject: [PATCH 2/2] modesetting: use GBM_BO_USE_FRONT_RENDERING for front_bo This flag is useful for drivers that need to take some action to deal with front buffer rendering. For instance, disabling framebuffer compression. Signed-off-by: Pierre-Eric Pelloux-Prayer --- hw/xfree86/drivers/modesetting/drmmode_display.c | 14 ++++++++++++-- include/meson.build | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 103b4a91c..125af1b16 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -3666,7 +3666,12 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) drmmode->fb_id = 0; if (!drmmode_create_bo(drmmode, &drmmode->front_bo, - width, height, drmmode->kbpp, 0)) + width, height, drmmode->kbpp, +#ifdef HAVE_GBM_BO_USE_FRONT_RENDERING + GBM_BO_USE_FRONT_RENDERING)) +#else + 0)) +#endif goto fail; pitch = drmmode_bo_get_pitch(&drmmode->front_bo); @@ -4439,7 +4444,12 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) width = pScrn->virtualX; height = pScrn->virtualY; - if (!drmmode_create_bo(drmmode, &drmmode->front_bo, width, height, bpp, 0)) + if (!drmmode_create_bo(drmmode, &drmmode->front_bo, width, height, bpp, +#ifdef HAVE_GBM_BO_USE_FRONT_RENDERING + GBM_BO_USE_FRONT_RENDERING)) +#else + 0)) +#endif return FALSE; pScrn->displayWidth = drmmode_bo_get_pitch(&drmmode->front_bo) / cpp; diff --git a/include/meson.build b/include/meson.build index 6d39bf603..fb066043e 100644 --- a/include/meson.build +++ b/include/meson.build @@ -116,6 +116,8 @@ conf_data.set('GBM_BO_FD_FOR_PLANE', build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 21.1') ? '1' : false) conf_data.set('GBM_BO_WITH_MODIFIERS2', build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 21.3') ? '1' : false) +conf_data.set('HAVE_GBM_BO_USE_FRONT_RENDERING', + build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 22.3') ? '1' : false) conf_data.set_quoted('SERVER_MISC_CONFIG_PATH', serverconfigdir) conf_data.set_quoted('PROJECTROOT', get_option('prefix'))