Commit cb1b1e18 authored by Adam Jackson's avatar Adam Jackson 🦃

Revert "Revert "modesetting: Indirect the glamor API through LoaderSymbol""

Now that we've fixed LoaderSymbolFromModule this should work properly.

This reverts commit 5c7c6d5c.
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
parent ab61c16e
Pipeline #81582 passed with stages
in 7 minutes and 36 seconds
......@@ -123,6 +123,7 @@ ms_dri2_create_buffer2(ScreenPtr screen, DrawablePtr drawable,
unsigned int attachment, unsigned int format)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
DRI2Buffer2Ptr buffer;
PixmapPtr pixmap;
CARD32 size;
......@@ -200,7 +201,7 @@ ms_dri2_create_buffer2(ScreenPtr screen, DrawablePtr drawable,
*/
buffer->flags = 0;
buffer->name = glamor_name_from_pixmap(pixmap, &pitch, &size);
buffer->name = ms->glamor.name_from_pixmap(pixmap, &pitch, &size);
buffer->pitch = pitch;
if (buffer->name == -1) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
......@@ -510,11 +511,12 @@ update_front(DrawablePtr draw, DRI2BufferPtr front)
ScreenPtr screen = draw->pScreen;
PixmapPtr pixmap = get_drawable_pixmap(draw);
ms_dri2_buffer_private_ptr priv = front->driverPrivate;
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen));
CARD32 size;
CARD16 pitch;
int name;
name = glamor_name_from_pixmap(pixmap, &pitch, &size);
name = ms->glamor.name_from_pixmap(pixmap, &pitch, &size);
if (name < 0)
return FALSE;
......@@ -618,7 +620,7 @@ ms_dri2_exchange_buffers(DrawablePtr draw, DRI2BufferPtr front,
*front_pix = *back_pix;
*back_pix = tmp_pix;
glamor_egl_exchange_buffers(front_priv->pixmap, back_priv->pixmap);
ms->glamor.egl_exchange_buffers(front_priv->pixmap, back_priv->pixmap);
/* Post damage on the front buffer so that listeners, such
* as DisplayLink know take a copy and shove it over the USB.
......@@ -1036,7 +1038,7 @@ ms_dri2_screen_init(ScreenPtr screen)
modesettingPtr ms = modesettingPTR(scrn);
DRI2InfoRec info;
if (!glamor_supports_pixmap_import_export(screen)) {
if (!ms->glamor.supports_pixmap_import_export(screen)) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"DRI2: glamor lacks support for pixmap import/export\n");
}
......
......@@ -615,7 +615,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty, int *timeout)
* the shared pixmap, but not all).
*/
if (ms->drmmode.glamor)
glamor_finish(screen);
ms->glamor.finish(screen);
#endif
/* Ensure the slave processes the damage immediately */
if (timeout)
......@@ -743,6 +743,26 @@ FreeRec(ScrnInfoPtr pScrn)
}
static void
bind_glamor_api(void *mod, modesettingPtr ms)
{
ms->glamor.back_pixmap_from_fd = LoaderSymbolFromModule(mod, "glamor_back_pixmap_from_fd");
ms->glamor.block_handler = LoaderSymbolFromModule(mod, "glamor_block_handler");
ms->glamor.egl_create_textured_pixmap = LoaderSymbolFromModule(mod, "glamor_egl_create_textured_pixmap");
ms->glamor.egl_create_textured_pixmap_from_gbm_bo = LoaderSymbolFromModule(mod, "glamor_egl_create_textured_pixmap_from_gbm_bo");
ms->glamor.egl_exchange_buffers = LoaderSymbolFromModule(mod, "glamor_egl_exchange_buffers");
ms->glamor.egl_get_gbm_device = LoaderSymbolFromModule(mod, "glamor_egl_get_gbm_device");
ms->glamor.egl_init = LoaderSymbolFromModule(mod, "glamor_egl_init");
ms->glamor.finish = LoaderSymbolFromModule(mod, "glamor_finish");
ms->glamor.gbm_bo_from_pixmap = LoaderSymbolFromModule(mod, "glamor_gbm_bo_from_pixmap");
ms->glamor.init = LoaderSymbolFromModule(mod, "glamor_init");
ms->glamor.name_from_pixmap = LoaderSymbolFromModule(mod, "glamor_name_from_pixmap");
ms->glamor.set_drawable_modifiers_func = LoaderSymbolFromModule(mod, "glamor_set_drawable_modifiers_func");
ms->glamor.shareable_fd_from_pixmap = LoaderSymbolFromModule(mod, "glamor_shareable_fd_from_pixmap");
ms->glamor.supports_pixmap_import_export = LoaderSymbolFromModule(mod, "glamor_supports_pixmap_import_export");
ms->glamor.xv_init = LoaderSymbolFromModule(mod, "glamor_xv_init");
}
static void
try_enable_glamor(ScrnInfoPtr pScrn)
{
......@@ -751,6 +771,7 @@ try_enable_glamor(ScrnInfoPtr pScrn)
OPTION_ACCEL_METHOD);
Bool do_glamor = (!accel_method_str ||
strcmp(accel_method_str, "glamor") == 0);
void *mod;
ms->drmmode.glamor = FALSE;
......@@ -765,8 +786,10 @@ try_enable_glamor(ScrnInfoPtr pScrn)
return;
}
if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
if (glamor_egl_init(pScrn, ms->fd)) {
mod = xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME);
if (mod) {
bind_glamor_api(mod, ms);
if (ms->glamor.egl_init(pScrn, ms->fd)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
ms->drmmode.glamor = TRUE;
} else {
......@@ -1421,11 +1444,12 @@ static Bool
msSharePixmapBacking(PixmapPtr ppix, ScreenPtr screen, void **handle)
{
#ifdef GLAMOR_HAS_GBM
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen));
int ret;
CARD16 stride;
CARD32 size;
ret = glamor_shareable_fd_from_pixmap(ppix->drawable.pScreen, ppix,
&stride, &size);
ret = ms->glamor.shareable_fd_from_pixmap(ppix->drawable.pScreen, ppix,
&stride, &size);
if (ret == -1)
return FALSE;
......@@ -1450,11 +1474,12 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
return drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, 0, 0);
if (ms->drmmode.reverse_prime_offload_mode) {
ret = glamor_back_pixmap_from_fd(ppix, ihandle,
ppix->drawable.width,
ppix->drawable.height,
ppix->devKind, ppix->drawable.depth,
ppix->drawable.bitsPerPixel);
ret = ms->glamor.back_pixmap_from_fd(ppix, ihandle,
ppix->drawable.width,
ppix->drawable.height,
ppix->devKind,
ppix->drawable.depth,
ppix->drawable.bitsPerPixel);
} else {
int size = ppix->devKind * ppix->drawable.height;
ret = drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, ppix->devKind, size);
......@@ -1571,7 +1596,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
#ifdef GLAMOR_HAS_GBM
if (ms->drmmode.glamor)
ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen);
ms->drmmode.gbm = ms->glamor.egl_get_gbm_device(pScreen);
#endif
/* HW dependent - FIXME */
......@@ -1715,7 +1740,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
if (ms->drmmode.glamor) {
XF86VideoAdaptorPtr glamor_adaptor;
glamor_adaptor = glamor_xv_init(pScreen, 16);
glamor_adaptor = ms->glamor.xv_init(pScreen, 16);
if (glamor_adaptor != NULL)
xf86XVScreenInit(pScreen, &glamor_adaptor, 1);
else
......
......@@ -132,6 +132,30 @@ typedef struct _modesettingRec {
void (*UpdatePacked)(ScreenPtr, shadowBufPtr);
} shadow;
/* glamor API */
struct {
Bool (*back_pixmap_from_fd)(PixmapPtr, int, CARD16, CARD16, CARD16,
CARD8, CARD8);
void (*block_handler)(ScreenPtr);
Bool (*egl_create_textured_pixmap)(PixmapPtr, int, int);
Bool (*egl_create_textured_pixmap_from_gbm_bo)(PixmapPtr,
struct gbm_bo *,
Bool);
void (*egl_exchange_buffers)(PixmapPtr, PixmapPtr);
struct gbm_device *(*egl_get_gbm_device)(ScreenPtr);
Bool (*egl_init)(ScrnInfoPtr, int);
void (*finish)(ScreenPtr);
struct gbm_bo *(*gbm_bo_from_pixmap)(ScreenPtr, PixmapPtr);
Bool (*init)(ScreenPtr, unsigned int);
int (*name_from_pixmap)(PixmapPtr, CARD16 *, CARD32 *);
void (*set_drawable_modifiers_func)(ScreenPtr,
GetDrawableModifiersFuncPtr);
int (*shareable_fd_from_pixmap)(ScreenPtr, PixmapPtr, CARD16 *,
CARD32 *);
Bool (*supports_pixmap_import_export)(ScreenPtr);
XF86VideoAdaptorPtr (*xv_init)(ScreenPtr, int);
} glamor;
} modesettingRec, *modesettingPtr;
#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
......
......@@ -1378,6 +1378,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int fbcon_id)
PixmapPtr pixmap = drmmode->fbcon_pixmap;
drmModeFBPtr fbcon;
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
modesettingPtr ms = modesettingPTR(pScrn);
Bool ret;
if (pixmap)
......@@ -1398,7 +1399,8 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int fbcon_id)
if (!pixmap)
goto out_free_fb;
ret = glamor_egl_create_textured_pixmap(pixmap, fbcon->handle, fbcon->pitch);
ret = ms->glamor.egl_create_textured_pixmap(pixmap, fbcon->handle,
fbcon->pitch);
if (!ret) {
FreePixmap(pixmap);
pixmap = NULL;
......@@ -1417,6 +1419,7 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
#ifdef GLAMOR_HAS_GBM
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
modesettingPtr ms = modesettingPTR(pScrn);
PixmapPtr src, dst;
int fbcon_id = 0;
GCPtr gc;
......@@ -1454,7 +1457,7 @@ drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
FreeScratchGC(gc);
glamor_finish(pScreen);
ms->glamor.finish(pScreen);
pScreen->canDoBGNoneRoot = TRUE;
......@@ -3090,12 +3093,13 @@ drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo)
{
#ifdef GLAMOR_HAS_GBM
ScrnInfoPtr scrn = drmmode->scrn;
modesettingPtr ms = modesettingPTR(scrn);
if (!drmmode->glamor)
return TRUE;
if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm,
bo->used_modifiers)) {
if (!ms->glamor.egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm,
bo->used_modifiers)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create pixmap\n");
return FALSE;
}
......@@ -3410,13 +3414,14 @@ drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
{
#ifdef GLAMOR_HAS_GBM
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
modesettingPtr ms = modesettingPTR(pScrn);
if (drmmode->glamor) {
if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) {
if (!ms->glamor.init(pScreen, GLAMOR_USE_EGL_SCREEN)) {
return FALSE;
}
#ifdef GBM_BO_WITH_MODIFIERS
glamor_set_drawable_modifiers_func(pScreen, get_drawable_modifiers);
ms->glamor.set_drawable_modifiers_func(pScreen, get_drawable_modifiers);
#endif
}
#endif
......
......@@ -244,9 +244,9 @@ ms_do_pageflip(ScreenPtr screen,
uint32_t flags;
int i;
struct ms_flipdata *flipdata;
glamor_block_handler(screen);
ms->glamor.block_handler(screen);
new_front_bo.gbm = glamor_gbm_bo_from_pixmap(screen, new_front);
new_front_bo.gbm = ms->glamor.gbm_bo_from_pixmap(screen, new_front);
new_front_bo.dumb = NULL;
if (!new_front_bo.gbm) {
......
......@@ -166,7 +166,7 @@ ms_present_flush(WindowPtr window)
modesettingPtr ms = modesettingPTR(scrn);
if (ms->drmmode.glamor)
glamor_block_handler(screen);
ms->glamor.block_handler(screen);
#endif
}
......@@ -259,7 +259,7 @@ ms_present_check_unflip(RRCrtcPtr crtc,
#ifdef GBM_BO_WITH_MODIFIERS
/* Check if buffer format/modifier is supported by all active CRTCs */
gbm = glamor_gbm_bo_from_pixmap(screen, pixmap);
gbm = ms->glamor.gbm_bo_from_pixmap(screen, pixmap);
if (gbm) {
uint32_t format;
uint64_t modifier;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment