modesetting: Use GBM for buffer allocations if Glamor supports it.
For performance, Glamor wants to render to tiled buffers, not linear ones. Using GBM allows us to pick the 3D driver's preferred tiling modes. v2: Declare drmmode->gbm as void * if !GLAMOR_HAS_GBM. v3: Just use a forward declaration of struct gbm_device. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Tested-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
cfef64b0ca
commit
7b784df51b
|
@ -877,7 +877,7 @@ CreateScreenResources(ScreenPtr pScreen)
|
||||||
modesettingPtr ms = modesettingPTR(pScrn);
|
modesettingPtr ms = modesettingPTR(pScrn);
|
||||||
PixmapPtr rootPixmap;
|
PixmapPtr rootPixmap;
|
||||||
Bool ret;
|
Bool ret;
|
||||||
void *pixels;
|
void *pixels = NULL;
|
||||||
|
|
||||||
pScreen->CreateScreenResources = ms->createScreenResources;
|
pScreen->CreateScreenResources = ms->createScreenResources;
|
||||||
ret = pScreen->CreateScreenResources(pScreen);
|
ret = pScreen->CreateScreenResources(pScreen);
|
||||||
|
@ -893,9 +893,12 @@ CreateScreenResources(ScreenPtr pScreen)
|
||||||
|
|
||||||
if (!ms->drmmode.sw_cursor)
|
if (!ms->drmmode.sw_cursor)
|
||||||
drmmode_map_cursor_bos(pScrn, &ms->drmmode);
|
drmmode_map_cursor_bos(pScrn, &ms->drmmode);
|
||||||
|
|
||||||
|
if (!ms->drmmode.gbm) {
|
||||||
pixels = drmmode_map_front_bo(&ms->drmmode);
|
pixels = drmmode_map_front_bo(&ms->drmmode);
|
||||||
if (!pixels)
|
if (!pixels)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
rootPixmap = pScreen->GetScreenPixmap(pScreen);
|
rootPixmap = pScreen->GetScreenPixmap(pScreen);
|
||||||
|
|
||||||
|
@ -985,6 +988,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
|
||||||
if (!SetMaster(pScrn))
|
if (!SetMaster(pScrn))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
if (ms->drmmode.glamor)
|
||||||
|
ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* HW dependent - FIXME */
|
/* HW dependent - FIXME */
|
||||||
pScrn->displayWidth = pScrn->virtualX;
|
pScrn->displayWidth = pScrn->virtualX;
|
||||||
if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
|
if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
#ifdef GLAMOR
|
#ifdef GLAMOR
|
||||||
#define GLAMOR_FOR_XORG 1
|
#define GLAMOR_FOR_XORG 1
|
||||||
#include "glamor.h"
|
#include "glamor.h"
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
#include <gbm.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -60,6 +63,13 @@ drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
if (bo->gbm) {
|
||||||
|
gbm_bo_destroy(bo->gbm);
|
||||||
|
bo->gbm = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bo->dumb) {
|
if (bo->dumb) {
|
||||||
ret = dumb_bo_destroy(drmmode->fd, bo->dumb);
|
ret = dumb_bo_destroy(drmmode->fd, bo->dumb);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
@ -72,12 +82,22 @@ drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo)
|
||||||
static uint32_t
|
static uint32_t
|
||||||
drmmode_bo_get_pitch(drmmode_bo *bo)
|
drmmode_bo_get_pitch(drmmode_bo *bo)
|
||||||
{
|
{
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
if (bo->gbm)
|
||||||
|
return gbm_bo_get_stride(bo->gbm);
|
||||||
|
#endif
|
||||||
|
|
||||||
return bo->dumb->pitch;
|
return bo->dumb->pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
drmmode_bo_get_handle(drmmode_bo *bo)
|
drmmode_bo_get_handle(drmmode_bo *bo)
|
||||||
{
|
{
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
if (bo->gbm)
|
||||||
|
return gbm_bo_get_handle(bo->gbm).u32;
|
||||||
|
#endif
|
||||||
|
|
||||||
return bo->dumb->handle;
|
return bo->dumb->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +105,15 @@ static Bool
|
||||||
drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
|
drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
|
||||||
unsigned width, unsigned height, unsigned bpp)
|
unsigned width, unsigned height, unsigned bpp)
|
||||||
{
|
{
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
if (drmmode->glamor) {
|
||||||
|
bo->gbm = gbm_bo_create(drmmode->gbm, width, height,
|
||||||
|
GBM_FORMAT_ARGB8888,
|
||||||
|
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
|
||||||
|
return bo->gbm != NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bo->dumb = dumb_bo_create(drmmode->fd, width, height, bpp);
|
bo->dumb = dumb_bo_create(drmmode->fd, width, height, bpp);
|
||||||
return bo->dumb != NULL;
|
return bo->dumb != NULL;
|
||||||
}
|
}
|
||||||
|
@ -1110,10 +1139,22 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
|
||||||
#ifdef GLAMOR
|
#ifdef GLAMOR
|
||||||
ScrnInfoPtr scrn = drmmode->scrn;
|
ScrnInfoPtr scrn = drmmode->scrn;
|
||||||
ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
|
ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
|
||||||
|
PixmapPtr screen_pixmap;
|
||||||
|
void *gbm_bo;
|
||||||
|
|
||||||
if (!drmmode->glamor)
|
if (!drmmode->glamor)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
gbm_bo = drmmode->front_bo.gbm;
|
||||||
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
|
|
||||||
|
if (!glamor_egl_create_textured_pixmap_from_gbm_bo(screen_pixmap, gbm_bo)) {
|
||||||
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
glamor_set_screen_pixmap(screen_pixmap, NULL);
|
||||||
|
#else
|
||||||
if (!glamor_egl_create_textured_screen(screen,
|
if (!glamor_egl_create_textured_screen(screen,
|
||||||
drmmode_bo_get_handle(&drmmode->front_bo),
|
drmmode_bo_get_handle(&drmmode->front_bo),
|
||||||
scrn->displayWidth *
|
scrn->displayWidth *
|
||||||
|
@ -1122,6 +1163,7 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
|
||||||
"glamor_egl_create_textured_screen() failed\n");
|
"glamor_egl_create_textured_screen() failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1142,7 +1184,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
|
||||||
int i, pitch, old_width, old_height, old_pitch;
|
int i, pitch, old_width, old_height, old_pitch;
|
||||||
int cpp = (scrn->bitsPerPixel + 7) / 8;
|
int cpp = (scrn->bitsPerPixel + 7) / 8;
|
||||||
PixmapPtr ppix = screen->GetScreenPixmap(screen);
|
PixmapPtr ppix = screen->GetScreenPixmap(screen);
|
||||||
void *new_pixels;
|
void *new_pixels = NULL;
|
||||||
|
|
||||||
if (scrn->virtualX == width && scrn->virtualY == height)
|
if (scrn->virtualX == width && scrn->virtualY == height)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1178,9 +1220,11 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
if (!drmmode->gbm) {
|
||||||
new_pixels = drmmode_map_front_bo(drmmode);
|
new_pixels = drmmode_map_front_bo(drmmode);
|
||||||
if (!new_pixels)
|
if (!new_pixels)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
if (drmmode->shadow_enable) {
|
if (drmmode->shadow_enable) {
|
||||||
uint32_t size = scrn->displayWidth * scrn->virtualY *
|
uint32_t size = scrn->displayWidth * scrn->virtualY *
|
||||||
|
|
|
@ -34,8 +34,13 @@
|
||||||
|
|
||||||
#include "dumb_bo.h"
|
#include "dumb_bo.h"
|
||||||
|
|
||||||
|
struct gbm_device;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct dumb_bo *dumb;
|
struct dumb_bo *dumb;
|
||||||
|
#ifdef GLAMOR_HAS_GBM
|
||||||
|
struct gbm_bo *gbm;
|
||||||
|
#endif
|
||||||
} drmmode_bo;
|
} drmmode_bo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -46,6 +51,9 @@ typedef struct {
|
||||||
drmModeFBPtr mode_fb;
|
drmModeFBPtr mode_fb;
|
||||||
int cpp;
|
int cpp;
|
||||||
ScrnInfoPtr scrn;
|
ScrnInfoPtr scrn;
|
||||||
|
|
||||||
|
struct gbm_device *gbm;
|
||||||
|
|
||||||
#ifdef CONFIG_UDEV_KMS
|
#ifdef CONFIG_UDEV_KMS
|
||||||
struct udev_monitor *uevent_monitor;
|
struct udev_monitor *uevent_monitor;
|
||||||
InputHandlerProc uevent_handler;
|
InputHandlerProc uevent_handler;
|
||||||
|
|
Loading…
Reference in New Issue