glamor: Use gbm_bo_create_with_modifiers for internal pixmap allocation
Using modifier might allow the driver to use a more optimal format (e.g. tiled/compressed). Let's try to use those if possible. v2: Don't filter out multi-plane modifiers Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
cef12efc15
commit
8d0d897159
|
@ -256,6 +256,7 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap)
|
||||||
glamor_get_pixmap_private(pixmap);
|
glamor_get_pixmap_private(pixmap);
|
||||||
unsigned width = pixmap->drawable.width;
|
unsigned width = pixmap->drawable.width;
|
||||||
unsigned height = pixmap->drawable.height;
|
unsigned height = pixmap->drawable.height;
|
||||||
|
uint32_t format;
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
PixmapPtr exported;
|
PixmapPtr exported;
|
||||||
GCPtr scratch_gc;
|
GCPtr scratch_gc;
|
||||||
|
@ -270,14 +271,33 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bo = gbm_bo_create(glamor_egl->gbm, width, height,
|
if (pixmap->drawable.depth == 30)
|
||||||
(pixmap->drawable.depth == 30) ?
|
format = GBM_FORMAT_ARGB2101010;
|
||||||
GBM_FORMAT_ARGB2101010 : GBM_FORMAT_ARGB8888,
|
else
|
||||||
|
format = GBM_FORMAT_ARGB8888;
|
||||||
|
|
||||||
|
#ifdef GBM_BO_WITH_MODIFIERS
|
||||||
|
if (glamor_egl->dmabuf_capable) {
|
||||||
|
uint32_t num_modifiers;
|
||||||
|
uint64_t *modifiers = NULL;
|
||||||
|
|
||||||
|
glamor_get_modifiers(screen, format, &num_modifiers, &modifiers);
|
||||||
|
|
||||||
|
bo = gbm_bo_create_with_modifiers(glamor_egl->gbm, width, height,
|
||||||
|
format, modifiers, num_modifiers);
|
||||||
|
free(modifiers);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
bo = gbm_bo_create(glamor_egl->gbm, width, height, format,
|
||||||
#ifdef GLAMOR_HAS_GBM_LINEAR
|
#ifdef GLAMOR_HAS_GBM_LINEAR
|
||||||
(pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED ?
|
(pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED ?
|
||||||
GBM_BO_USE_LINEAR : 0) |
|
GBM_BO_USE_LINEAR : 0) |
|
||||||
#endif
|
#endif
|
||||||
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
|
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
|
||||||
|
}
|
||||||
|
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to make %dx%dx%dbpp GBM bo\n",
|
"Failed to make %dx%dx%dbpp GBM bo\n",
|
||||||
|
|
|
@ -227,14 +227,30 @@ xwl_glamor_create_pixmap(ScreenPtr screen,
|
||||||
{
|
{
|
||||||
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
|
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
|
uint32_t format;
|
||||||
|
|
||||||
if (width > 0 && height > 0 && depth >= 15 &&
|
if (width > 0 && height > 0 && depth >= 15 &&
|
||||||
(hint == 0 ||
|
(hint == 0 ||
|
||||||
hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
|
hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
|
||||||
hint == CREATE_PIXMAP_USAGE_SHARED)) {
|
hint == CREATE_PIXMAP_USAGE_SHARED)) {
|
||||||
bo = gbm_bo_create(xwl_screen->gbm, width, height,
|
format = gbm_format_for_depth(depth);
|
||||||
gbm_format_for_depth(depth),
|
|
||||||
|
#ifdef GBM_BO_WITH_MODIFIERS
|
||||||
|
if (xwl_screen->dmabuf_capable) {
|
||||||
|
uint32_t num_modifiers;
|
||||||
|
uint64_t *modifiers = NULL;
|
||||||
|
|
||||||
|
glamor_get_modifiers(screen, format, &num_modifiers, &modifiers);
|
||||||
|
bo = gbm_bo_create_with_modifiers(xwl_screen->gbm, width, height,
|
||||||
|
format, modifiers, num_modifiers);
|
||||||
|
free(modifiers);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
bo = gbm_bo_create(xwl_screen->gbm, width, height, format,
|
||||||
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||||
|
}
|
||||||
|
|
||||||
if (bo)
|
if (bo)
|
||||||
return xwl_glamor_create_pixmap_for_bo(screen, bo, depth);
|
return xwl_glamor_create_pixmap_for_bo(screen, bo, depth);
|
||||||
|
|
Loading…
Reference in New Issue