diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2014-12-09 12:43:57 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2014-12-11 11:26:19 -0800 |
commit | 7b784df51bd6be38238d7101b1f5e320eb4aa5b8 (patch) | |
tree | 33a9021c3ffd872df7e74e6ccac5a644ae1dd78b /hw | |
parent | cfef64b0cabe7677c7584a72d7432c20343d9361 (diff) |
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>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xfree86/drivers/modesetting/driver.c | 16 | ||||
-rw-r--r-- | hw/xfree86/drivers/modesetting/drmmode_display.c | 52 | ||||
-rw-r--r-- | hw/xfree86/drivers/modesetting/drmmode_display.h | 8 |
3 files changed, 68 insertions, 8 deletions
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index dea709eab..cad900063 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -877,7 +877,7 @@ CreateScreenResources(ScreenPtr pScreen) modesettingPtr ms = modesettingPTR(pScrn); PixmapPtr rootPixmap; Bool ret; - void *pixels; + void *pixels = NULL; pScreen->CreateScreenResources = ms->createScreenResources; ret = pScreen->CreateScreenResources(pScreen); @@ -893,9 +893,12 @@ CreateScreenResources(ScreenPtr pScreen) if (!ms->drmmode.sw_cursor) drmmode_map_cursor_bos(pScrn, &ms->drmmode); - pixels = drmmode_map_front_bo(&ms->drmmode); - if (!pixels) - return FALSE; + + if (!ms->drmmode.gbm) { + pixels = drmmode_map_front_bo(&ms->drmmode); + if (!pixels) + return FALSE; + } rootPixmap = pScreen->GetScreenPixmap(pScreen); @@ -985,6 +988,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) if (!SetMaster(pScrn)) return FALSE; +#ifdef GLAMOR_HAS_GBM + if (ms->drmmode.glamor) + ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen); +#endif + /* HW dependent - FIXME */ pScrn->displayWidth = pScrn->virtualX; if (!drmmode_create_initial_bos(pScrn, &ms->drmmode)) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 29b88445f..13a96dc90 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -53,6 +53,9 @@ #ifdef GLAMOR #define GLAMOR_FOR_XORG 1 #include "glamor.h" +#ifdef GLAMOR_HAS_GBM +#include <gbm.h> +#endif #endif static int @@ -60,6 +63,13 @@ drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo) { int ret; +#ifdef GLAMOR_HAS_GBM + if (bo->gbm) { + gbm_bo_destroy(bo->gbm); + bo->gbm = NULL; + } +#endif + if (bo->dumb) { ret = dumb_bo_destroy(drmmode->fd, bo->dumb); if (ret == 0) @@ -72,12 +82,22 @@ drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo) static uint32_t 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; } uint32_t 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; } @@ -85,6 +105,15 @@ static Bool drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo, 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); return bo->dumb != NULL; } @@ -1110,10 +1139,22 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode) #ifdef GLAMOR ScrnInfoPtr scrn = drmmode->scrn; ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn); + PixmapPtr screen_pixmap; + void *gbm_bo; if (!drmmode->glamor) 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, drmmode_bo_get_handle(&drmmode->front_bo), scrn->displayWidth * @@ -1123,6 +1164,7 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode) return FALSE; } #endif +#endif 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 cpp = (scrn->bitsPerPixel + 7) / 8; PixmapPtr ppix = screen->GetScreenPixmap(screen); - void *new_pixels; + void *new_pixels = NULL; if (scrn->virtualX == width && scrn->virtualY == height) return TRUE; @@ -1178,9 +1220,11 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) if (ret) goto fail; - new_pixels = drmmode_map_front_bo(drmmode); - if (!new_pixels) - goto fail; + if (!drmmode->gbm) { + new_pixels = drmmode_map_front_bo(drmmode); + if (!new_pixels) + goto fail; + } if (drmmode->shadow_enable) { uint32_t size = scrn->displayWidth * scrn->virtualY * diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h index 7c1ff0589..645081187 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/modesetting/drmmode_display.h @@ -34,8 +34,13 @@ #include "dumb_bo.h" +struct gbm_device; + typedef struct { struct dumb_bo *dumb; +#ifdef GLAMOR_HAS_GBM + struct gbm_bo *gbm; +#endif } drmmode_bo; typedef struct { @@ -46,6 +51,9 @@ typedef struct { drmModeFBPtr mode_fb; int cpp; ScrnInfoPtr scrn; + + struct gbm_device *gbm; + #ifdef CONFIG_UDEV_KMS struct udev_monitor *uevent_monitor; InputHandlerProc uevent_handler; |