Caused assertion failures / crashes with Xorg. Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/916
This commit is contained in:
parent
5315f988d9
commit
535f14656a
|
@ -927,11 +927,7 @@ glamor_close_screen(ScreenPtr screen)
|
||||||
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
||||||
|
|
||||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
/* For DDX like Xwayland and Xorg, the pixmap is not destroyed so
|
glamor_pixmap_destroy_fbo(screen_pixmap);
|
||||||
* we should do so here.
|
|
||||||
*/
|
|
||||||
if (screen_pixmap)
|
|
||||||
glamor_pixmap_destroy_fbo(screen_pixmap);
|
|
||||||
|
|
||||||
glamor_release_screen_priv(screen);
|
glamor_release_screen_priv(screen);
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,8 @@ typedef Bool (*GetDrawableModifiersFuncPtr) (DrawablePtr draw,
|
||||||
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
||||||
#define GLAMOR_USE_EGL_SCREEN (1 << 0)
|
#define GLAMOR_USE_EGL_SCREEN (1 << 0)
|
||||||
#define GLAMOR_NO_DRI3 (1 << 1)
|
#define GLAMOR_NO_DRI3 (1 << 1)
|
||||||
#define GLAMOR_NO_MODIFIERS (1 << 2)
|
|
||||||
#define GLAMOR_VALID_FLAGS (GLAMOR_USE_EGL_SCREEN \
|
#define GLAMOR_VALID_FLAGS (GLAMOR_USE_EGL_SCREEN \
|
||||||
| GLAMOR_NO_DRI3 \
|
| GLAMOR_NO_DRI3)
|
||||||
| GLAMOR_NO_MODIFIERS)
|
|
||||||
|
|
||||||
/* until we need geometry shaders GL3.1 should suffice. */
|
/* until we need geometry shaders GL3.1 should suffice. */
|
||||||
#define GLAMOR_GL_CORE_VER_MAJOR 3
|
#define GLAMOR_GL_CORE_VER_MAJOR 3
|
||||||
|
@ -334,18 +332,20 @@ extern _X_EXPORT Bool glamor_get_drawable_modifiers(DrawablePtr draw,
|
||||||
extern _X_EXPORT void glamor_set_drawable_modifiers_func(ScreenPtr screen,
|
extern _X_EXPORT void glamor_set_drawable_modifiers_func(ScreenPtr screen,
|
||||||
GetDrawableModifiersFuncPtr func);
|
GetDrawableModifiersFuncPtr func);
|
||||||
|
|
||||||
|
#ifdef GLAMOR_FOR_XORG
|
||||||
|
|
||||||
#define GLAMOR_EGL_MODULE_NAME "glamoregl"
|
#define GLAMOR_EGL_MODULE_NAME "glamoregl"
|
||||||
|
|
||||||
/* @glamor_egl_init: Initialize EGL environment.
|
/* @glamor_egl_init: Initialize EGL environment.
|
||||||
*
|
*
|
||||||
* @screen: Current screen pointer.
|
* @scrn: Current screen info pointer.
|
||||||
* @fd: Current drm fd.
|
* @fd: Current drm fd.
|
||||||
*
|
*
|
||||||
* This function creates and intialize EGL contexts.
|
* This function creates and intialize EGL contexts.
|
||||||
* Should be called from DDX's preInit function.
|
* Should be called from DDX's preInit function.
|
||||||
* Return TRUE if success, otherwise return FALSE.
|
* Return TRUE if success, otherwise return FALSE.
|
||||||
* */
|
* */
|
||||||
extern _X_EXPORT Bool glamor_egl_init(ScreenPtr screen, int fd);
|
extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
|
||||||
|
|
||||||
extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
|
extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
|
||||||
|
|
||||||
|
@ -396,6 +396,8 @@ extern _X_EXPORT Bool
|
||||||
struct gbm_bo *bo,
|
struct gbm_bo *bo,
|
||||||
Bool used_modifiers);
|
Bool used_modifiers);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
|
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
|
||||||
struct glamor_context *glamor_ctx);
|
struct glamor_context *glamor_ctx);
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,13 @@
|
||||||
|
|
||||||
#include "dix-config.h"
|
#include "dix-config.h"
|
||||||
|
|
||||||
|
#define GLAMOR_FOR_XORG
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <xf86.h>
|
||||||
|
#include <xf86Priv.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#define EGL_DISPLAY_NO_X_MESA
|
#define EGL_DISPLAY_NO_X_MESA
|
||||||
|
|
||||||
|
@ -50,20 +53,25 @@ struct glamor_egl_screen_private {
|
||||||
EGLContext context;
|
EGLContext context;
|
||||||
char *device_path;
|
char *device_path;
|
||||||
|
|
||||||
|
CreateScreenResourcesProcPtr CreateScreenResources;
|
||||||
|
CloseScreenProcPtr CloseScreen;
|
||||||
int fd;
|
int fd;
|
||||||
struct gbm_device *gbm;
|
struct gbm_device *gbm;
|
||||||
int dmabuf_capable;
|
int dmabuf_capable;
|
||||||
|
|
||||||
CloseScreenProcPtr saved_close_screen;
|
CloseScreenProcPtr saved_close_screen;
|
||||||
DestroyPixmapProcPtr saved_destroy_pixmap;
|
DestroyPixmapProcPtr saved_destroy_pixmap;
|
||||||
|
xf86FreeScreenProc *saved_free_screen;
|
||||||
};
|
};
|
||||||
|
|
||||||
static DevPrivateKeyRec glamor_egl_screen_private_key;
|
int xf86GlamorEGLPrivateIndex = -1;
|
||||||
|
|
||||||
|
|
||||||
static struct glamor_egl_screen_private *
|
static struct glamor_egl_screen_private *
|
||||||
glamor_egl_get_screen_private(ScreenPtr screen)
|
glamor_egl_get_screen_private(ScrnInfoPtr scrn)
|
||||||
{
|
{
|
||||||
return dixLookupPrivate(&screen->devPrivates, &glamor_egl_screen_private_key);
|
return (struct glamor_egl_screen_private *)
|
||||||
|
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -131,19 +139,20 @@ struct gbm_device *
|
||||||
glamor_egl_get_gbm_device(ScreenPtr screen)
|
glamor_egl_get_gbm_device(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
|
||||||
return glamor_egl->gbm;
|
return glamor_egl->gbm;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
||||||
{
|
{
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
PixmapPtr screen_pixmap;
|
PixmapPtr screen_pixmap;
|
||||||
|
|
||||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
|
|
||||||
if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
|
if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to create textured screen.");
|
"Failed to create textured screen.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +170,8 @@ glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image,
|
||||||
old = pixmap_priv->image;
|
old = pixmap_priv->image;
|
||||||
if (old) {
|
if (old) {
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
struct glamor_egl_screen_private *glamor_egl = glamor_egl_get_screen_private(screen);
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
|
struct glamor_egl_screen_private *glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
|
|
||||||
eglDestroyImageKHR(glamor_egl->display, old);
|
eglDestroyImageKHR(glamor_egl->display, old);
|
||||||
}
|
}
|
||||||
|
@ -173,8 +183,9 @@ Bool
|
||||||
glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(scrn);
|
||||||
int ret, fd;
|
int ret, fd;
|
||||||
|
|
||||||
/* GBM doesn't have an import path from handles, so we make a
|
/* GBM doesn't have an import path from handles, so we make a
|
||||||
|
@ -182,7 +193,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||||
*/
|
*/
|
||||||
ret = drmPrimeHandleToFD(glamor_egl->fd, handle, O_CLOEXEC, &fd);
|
ret = drmPrimeHandleToFD(glamor_egl->fd, handle, O_CLOEXEC, &fd);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to make prime FD for handle: %d\n", errno);
|
"Failed to make prime FD for handle: %d\n", errno);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +204,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||||
stride,
|
stride,
|
||||||
pixmap->drawable.depth,
|
pixmap->drawable.depth,
|
||||||
pixmap->drawable.bitsPerPixel)) {
|
pixmap->drawable.bitsPerPixel)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to make import prime FD as pixmap: %d\n", errno);
|
"Failed to make import prime FD as pixmap: %d\n", errno);
|
||||||
close(fd);
|
close(fd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -209,6 +220,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
|
||||||
Bool used_modifiers)
|
Bool used_modifiers)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_screen_private *glamor_priv =
|
struct glamor_screen_private *glamor_priv =
|
||||||
glamor_get_screen_private(screen);
|
glamor_get_screen_private(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl;
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
|
@ -216,7 +228,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
Bool ret = FALSE;
|
Bool ret = FALSE;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
|
|
||||||
glamor_make_current(glamor_priv);
|
glamor_make_current(glamor_priv);
|
||||||
|
|
||||||
|
@ -251,8 +263,9 @@ static Bool
|
||||||
glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok)
|
glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(scrn);
|
||||||
struct glamor_pixmap_private *pixmap_priv =
|
struct glamor_pixmap_private *pixmap_priv =
|
||||||
glamor_get_pixmap_private(pixmap);
|
glamor_get_pixmap_private(pixmap);
|
||||||
unsigned width = pixmap->drawable.width;
|
unsigned width = pixmap->drawable.width;
|
||||||
|
@ -285,7 +298,7 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok)
|
||||||
format = GBM_FORMAT_R8;
|
format = GBM_FORMAT_R8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to make %d depth, %dbpp pixmap exportable\n",
|
"Failed to make %d depth, %dbpp pixmap exportable\n",
|
||||||
pixmap->drawable.depth, pixmap->drawable.bitsPerPixel);
|
pixmap->drawable.depth, pixmap->drawable.bitsPerPixel);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -317,7 +330,7 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
LogMessage(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",
|
||||||
width, height, pixmap->drawable.bitsPerPixel);
|
width, height, pixmap->drawable.bitsPerPixel);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -328,7 +341,7 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok)
|
||||||
gbm_bo_get_stride(bo), NULL);
|
gbm_bo_get_stride(bo), NULL);
|
||||||
if (!glamor_egl_create_textured_pixmap_from_gbm_bo(exported, bo,
|
if (!glamor_egl_create_textured_pixmap_from_gbm_bo(exported, bo,
|
||||||
used_modifiers)) {
|
used_modifiers)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to make %dx%dx%dbpp pixmap from GBM bo\n",
|
"Failed to make %dx%dx%dbpp pixmap from GBM bo\n",
|
||||||
width, height, pixmap->drawable.bitsPerPixel);
|
width, height, pixmap->drawable.bitsPerPixel);
|
||||||
screen->DestroyPixmap(exported);
|
screen->DestroyPixmap(exported);
|
||||||
|
@ -358,7 +371,7 @@ static struct gbm_bo *
|
||||||
glamor_gbm_bo_from_pixmap_internal(ScreenPtr screen, PixmapPtr pixmap)
|
glamor_gbm_bo_from_pixmap_internal(ScreenPtr screen, PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
|
||||||
struct glamor_pixmap_private *pixmap_priv =
|
struct glamor_pixmap_private *pixmap_priv =
|
||||||
glamor_get_pixmap_private(pixmap);
|
glamor_get_pixmap_private(pixmap);
|
||||||
|
|
||||||
|
@ -455,7 +468,7 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
|
||||||
|
|
||||||
if (!glamor_make_pixmap_exportable(pixmap, FALSE))
|
if (!glamor_make_pixmap_exportable(pixmap, FALSE))
|
||||||
goto failure;
|
goto failure;
|
||||||
|
@ -483,12 +496,13 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
|
||||||
CARD16 stride, CARD8 depth, CARD8 bpp)
|
CARD16 stride, CARD8 depth, CARD8 bpp)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl;
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
struct gbm_bo *bo;
|
struct gbm_bo *bo;
|
||||||
struct gbm_import_fd_data import_data = { 0 };
|
struct gbm_import_fd_data import_data = { 0 };
|
||||||
Bool ret;
|
Bool ret;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
|
|
||||||
if (bpp != 32 || !(depth == 24 || depth == 32 || depth == 30) || width == 0 || height == 0)
|
if (bpp != 32 || !(depth == 24 || depth == 32 || depth == 30) || width == 0 || height == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -542,7 +556,7 @@ glamor_pixmap_from_fds(ScreenPtr screen,
|
||||||
Bool ret = FALSE;
|
Bool ret = FALSE;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
|
||||||
|
|
||||||
pixmap = screen->CreatePixmap(screen, 0, 0, depth, 0);
|
pixmap = screen->CreatePixmap(screen, 0, 0, depth, 0);
|
||||||
|
|
||||||
|
@ -616,7 +630,7 @@ glamor_get_formats(ScreenPtr screen,
|
||||||
/* Explicitly zero the count as the caller may ignore the return value */
|
/* Explicitly zero the count as the caller may ignore the return value */
|
||||||
*num_formats = 0;
|
*num_formats = 0;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
|
||||||
|
|
||||||
if (!glamor_egl->dmabuf_capable)
|
if (!glamor_egl->dmabuf_capable)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -656,7 +670,7 @@ glamor_get_modifiers(ScreenPtr screen, uint32_t format,
|
||||||
/* Explicitly zero the count as the caller may ignore the return value */
|
/* Explicitly zero the count as the caller may ignore the return value */
|
||||||
*num_modifiers = 0;
|
*num_modifiers = 0;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
|
||||||
|
|
||||||
if (!glamor_egl->dmabuf_capable)
|
if (!glamor_egl->dmabuf_capable)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -690,8 +704,9 @@ static Bool
|
||||||
glamor_egl_destroy_pixmap(PixmapPtr pixmap)
|
glamor_egl_destroy_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(scrn);
|
||||||
Bool ret;
|
Bool ret;
|
||||||
|
|
||||||
if (pixmap->refcnt == 1) {
|
if (pixmap->refcnt == 1) {
|
||||||
|
@ -733,53 +748,23 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
|
||||||
glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
|
glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glamor_egl_cleanup(ScreenPtr screen)
|
|
||||||
{
|
|
||||||
struct glamor_egl_screen_private *glamor_egl;
|
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
|
||||||
if (glamor_egl->display != EGL_NO_DISPLAY) {
|
|
||||||
eglMakeCurrent(glamor_egl->display,
|
|
||||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
||||||
/*
|
|
||||||
* Force the next glamor_make_current call to update the context
|
|
||||||
* (on hot unplug another GPU may still be using glamor)
|
|
||||||
*/
|
|
||||||
lastGLContext = NULL;
|
|
||||||
eglTerminate(glamor_egl->display);
|
|
||||||
}
|
|
||||||
if (glamor_egl->gbm)
|
|
||||||
gbm_device_destroy(glamor_egl->gbm);
|
|
||||||
free(glamor_egl->device_path);
|
|
||||||
free(glamor_egl);
|
|
||||||
|
|
||||||
screen->DestroyPixmap = glamor_egl->saved_destroy_pixmap;
|
|
||||||
screen->CloseScreen = glamor_egl->saved_close_screen;
|
|
||||||
|
|
||||||
dixSetPrivate(&screen->devPrivates, &glamor_egl_screen_private_key, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
glamor_egl_close_screen(ScreenPtr screen)
|
glamor_egl_close_screen(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
|
ScrnInfoPtr scrn;
|
||||||
struct glamor_egl_screen_private *glamor_egl;
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
struct glamor_pixmap_private *pixmap_priv;
|
struct glamor_pixmap_private *pixmap_priv;
|
||||||
PixmapPtr screen_pixmap;
|
PixmapPtr screen_pixmap;
|
||||||
|
|
||||||
glamor_egl = glamor_egl_get_screen_private(screen);
|
scrn = xf86ScreenToScrn(screen);
|
||||||
|
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||||
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
||||||
|
|
||||||
/* For DDX like Xwayland and Xorg, the pixmap is not destroyed so
|
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
|
||||||
* we should do so here.
|
pixmap_priv->image = NULL;
|
||||||
*/
|
|
||||||
if (pixmap_priv) {
|
|
||||||
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
|
|
||||||
pixmap_priv->image = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen->CloseScreen = glamor_egl->saved_close_screen;
|
screen->CloseScreen = glamor_egl->saved_close_screen;
|
||||||
glamor_egl_cleanup(screen);
|
|
||||||
|
|
||||||
return screen->CloseScreen(screen);
|
return screen->CloseScreen(screen);
|
||||||
}
|
}
|
||||||
|
@ -791,8 +776,9 @@ glamor_dri3_open_client(ClientPtr client,
|
||||||
RRProviderPtr provider,
|
RRProviderPtr provider,
|
||||||
int *fdp)
|
int *fdp)
|
||||||
{
|
{
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(scrn);
|
||||||
int fd;
|
int fd;
|
||||||
drm_magic_t magic;
|
drm_magic_t magic;
|
||||||
|
|
||||||
|
@ -849,12 +835,19 @@ static const dri3_screen_info_rec glamor_dri3_info = {
|
||||||
void
|
void
|
||||||
glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
||||||
{
|
{
|
||||||
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||||
struct glamor_egl_screen_private *glamor_egl =
|
struct glamor_egl_screen_private *glamor_egl =
|
||||||
glamor_egl_get_screen_private(screen);
|
glamor_egl_get_screen_private(scrn);
|
||||||
#ifdef DRI3
|
#ifdef DRI3
|
||||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glamor_egl->saved_close_screen = screen->CloseScreen;
|
||||||
|
screen->CloseScreen = glamor_egl_close_screen;
|
||||||
|
|
||||||
|
glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
|
||||||
|
screen->DestroyPixmap = glamor_egl_destroy_pixmap;
|
||||||
|
|
||||||
glamor_ctx->ctx = glamor_egl->context;
|
glamor_ctx->ctx = glamor_egl->context;
|
||||||
glamor_ctx->display = glamor_egl->display;
|
glamor_ctx->display = glamor_egl->display;
|
||||||
|
|
||||||
|
@ -866,9 +859,6 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
||||||
*/
|
*/
|
||||||
glamor_enable_dri3(screen);
|
glamor_enable_dri3(screen);
|
||||||
|
|
||||||
if (glamor_priv->flags & GLAMOR_NO_MODIFIERS)
|
|
||||||
glamor_egl->dmabuf_capable = FALSE;
|
|
||||||
|
|
||||||
/* If the driver wants to do its own auth dance (e.g. Xwayland
|
/* If the driver wants to do its own auth dance (e.g. Xwayland
|
||||||
* on pre-3.15 kernels that don't have render nodes and thus
|
* on pre-3.15 kernels that don't have render nodes and thus
|
||||||
* has the wayland compositor as a master), then it needs us
|
* has the wayland compositor as a master), then it needs us
|
||||||
|
@ -881,15 +871,46 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
||||||
glamor_egl->device_path = drmGetDeviceNameFromFd2(glamor_egl->fd);
|
glamor_egl->device_path = drmGetDeviceNameFromFd2(glamor_egl->fd);
|
||||||
|
|
||||||
if (!dri3_screen_init(screen, &glamor_dri3_info)) {
|
if (!dri3_screen_init(screen, &glamor_dri3_info)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to initialize DRI3.\n");
|
"Failed to initialize DRI3.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void glamor_egl_cleanup(struct glamor_egl_screen_private *glamor_egl)
|
||||||
|
{
|
||||||
|
if (glamor_egl->display != EGL_NO_DISPLAY) {
|
||||||
|
eglMakeCurrent(glamor_egl->display,
|
||||||
|
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
/*
|
||||||
|
* Force the next glamor_make_current call to update the context
|
||||||
|
* (on hot unplug another GPU may still be using glamor)
|
||||||
|
*/
|
||||||
|
lastGLContext = NULL;
|
||||||
|
eglTerminate(glamor_egl->display);
|
||||||
|
}
|
||||||
|
if (glamor_egl->gbm)
|
||||||
|
gbm_device_destroy(glamor_egl->gbm);
|
||||||
|
free(glamor_egl->device_path);
|
||||||
|
free(glamor_egl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
glamor_egl_free_screen(ScrnInfoPtr scrn)
|
||||||
|
{
|
||||||
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
|
|
||||||
|
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||||
|
if (glamor_egl != NULL) {
|
||||||
|
scrn->FreeScreen = glamor_egl->saved_free_screen;
|
||||||
|
glamor_egl_cleanup(glamor_egl);
|
||||||
|
scrn->FreeScreen(scrn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
glamor_egl_init(ScreenPtr screen, int fd)
|
glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||||
{
|
{
|
||||||
struct glamor_egl_screen_private *glamor_egl;
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
const GLubyte *renderer;
|
const GLubyte *renderer;
|
||||||
|
@ -899,22 +920,10 @@ glamor_egl_init(ScreenPtr screen, int fd)
|
||||||
glamor_egl = calloc(sizeof(*glamor_egl), 1);
|
glamor_egl = calloc(sizeof(*glamor_egl), 1);
|
||||||
if (glamor_egl == NULL)
|
if (glamor_egl == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (xf86GlamorEGLPrivateIndex == -1)
|
||||||
|
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
||||||
|
|
||||||
if (!dixRegisterPrivateKey(&glamor_egl_screen_private_key, PRIVATE_SCREEN, 0)) {
|
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||||
LogMessage(X_WARNING,
|
|
||||||
"glamor%d: Failed to allocate egl screen private\n",
|
|
||||||
screen->myNum);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
dixSetPrivate(&screen->devPrivates, &glamor_egl_screen_private_key, glamor_egl);
|
|
||||||
|
|
||||||
glamor_egl->saved_close_screen = screen->CloseScreen;
|
|
||||||
screen->CloseScreen = glamor_egl_close_screen;
|
|
||||||
|
|
||||||
glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
|
|
||||||
screen->DestroyPixmap = glamor_egl_destroy_pixmap;
|
|
||||||
|
|
||||||
glamor_egl->fd = fd;
|
glamor_egl->fd = fd;
|
||||||
glamor_egl->gbm = gbm_create_device(glamor_egl->fd);
|
glamor_egl->gbm = gbm_create_device(glamor_egl->fd);
|
||||||
if (glamor_egl->gbm == NULL) {
|
if (glamor_egl->gbm == NULL) {
|
||||||
|
@ -925,12 +934,12 @@ glamor_egl_init(ScreenPtr screen, int fd)
|
||||||
glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA,
|
glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA,
|
||||||
glamor_egl->gbm);
|
glamor_egl->gbm);
|
||||||
if (!glamor_egl->display) {
|
if (!glamor_egl->display) {
|
||||||
LogMessage(X_ERROR, "eglGetDisplay() failed\n");
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetDisplay() failed\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglInitialize(glamor_egl->display, NULL, NULL)) {
|
if (!eglInitialize(glamor_egl->display, NULL, NULL)) {
|
||||||
LogMessage(X_ERROR, "eglInitialize() failed\n");
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglInitialize() failed\n");
|
||||||
glamor_egl->display = EGL_NO_DISPLAY;
|
glamor_egl->display = EGL_NO_DISPLAY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -980,13 +989,13 @@ glamor_egl_init(ScreenPtr screen, int fd)
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
|
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"glamor: Failed to bind either GL or GLES APIs.\n");
|
"glamor: Failed to bind either GL or GLES APIs.\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig(glamor_egl->display, NULL, &egl_config, 1, &n)) {
|
if (!eglChooseConfig(glamor_egl->display, NULL, &egl_config, 1, &n)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"glamor: No acceptable EGL configs found\n");
|
"glamor: No acceptable EGL configs found\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -996,26 +1005,26 @@ glamor_egl_init(ScreenPtr screen, int fd)
|
||||||
config_attribs);
|
config_attribs);
|
||||||
}
|
}
|
||||||
if (glamor_egl->context == EGL_NO_CONTEXT) {
|
if (glamor_egl->context == EGL_NO_CONTEXT) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"glamor: Failed to create GL or GLES2 contexts\n");
|
"glamor: Failed to create GL or GLES2 contexts\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglMakeCurrent(glamor_egl->display,
|
if (!eglMakeCurrent(glamor_egl->display,
|
||||||
EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
|
EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"Failed to make EGL context current\n");
|
"Failed to make EGL context current\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer = glGetString(GL_RENDERER);
|
renderer = glGetString(GL_RENDERER);
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"glGetString() returned NULL, your GL is broken\n");
|
"glGetString() returned NULL, your GL is broken\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (strstr((const char *)renderer, "llvmpipe")) {
|
if (strstr((const char *)renderer, "llvmpipe")) {
|
||||||
LogMessage(X_INFO,
|
xf86DrvMsg(scrn->scrnIndex, X_INFO,
|
||||||
"Refusing to try glamor on llvmpipe\n");
|
"Refusing to try glamor on llvmpipe\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -1027,26 +1036,33 @@ glamor_egl_init(ScreenPtr screen, int fd)
|
||||||
lastGLContext = NULL;
|
lastGLContext = NULL;
|
||||||
|
|
||||||
if (!epoxy_has_gl_extension("GL_OES_EGL_image")) {
|
if (!epoxy_has_gl_extension("GL_OES_EGL_image")) {
|
||||||
LogMessage(X_ERROR,
|
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||||
"glamor acceleration requires GL_OES_EGL_image\n");
|
"glamor acceleration requires GL_OES_EGL_image\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage(X_INFO, "glamor X acceleration enabled on %s\n", renderer);
|
xf86DrvMsg(scrn->scrnIndex, X_INFO, "glamor X acceleration enabled on %s\n",
|
||||||
|
renderer);
|
||||||
|
|
||||||
#ifdef GBM_BO_WITH_MODIFIERS
|
#ifdef GBM_BO_WITH_MODIFIERS
|
||||||
if (epoxy_has_egl_extension(glamor_egl->display,
|
if (epoxy_has_egl_extension(glamor_egl->display,
|
||||||
"EGL_EXT_image_dma_buf_import") &&
|
"EGL_EXT_image_dma_buf_import") &&
|
||||||
epoxy_has_egl_extension(glamor_egl->display,
|
epoxy_has_egl_extension(glamor_egl->display,
|
||||||
"EGL_EXT_image_dma_buf_import_modifiers")) {
|
"EGL_EXT_image_dma_buf_import_modifiers")) {
|
||||||
|
if (xf86Info.debug != NULL)
|
||||||
|
glamor_egl->dmabuf_capable = !!strstr(xf86Info.debug,
|
||||||
|
"dmabuf_capable");
|
||||||
|
else
|
||||||
glamor_egl->dmabuf_capable = TRUE;
|
glamor_egl->dmabuf_capable = TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glamor_egl->saved_free_screen = scrn->FreeScreen;
|
||||||
|
scrn->FreeScreen = glamor_egl_free_screen;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
glamor_egl_cleanup(screen);
|
glamor_egl_cleanup(glamor_egl);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,6 @@ from The Open Group.
|
||||||
#include "glx_extinit.h"
|
#include "glx_extinit.h"
|
||||||
#include "randrstr.h"
|
#include "randrstr.h"
|
||||||
|
|
||||||
#ifdef GLAMOR_HAS_GBM
|
|
||||||
#include <glamor.h>
|
|
||||||
#include <gbm.h>
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define VFB_DEFAULT_WIDTH 1280
|
#define VFB_DEFAULT_WIDTH 1280
|
||||||
#define VFB_DEFAULT_HEIGHT 1024
|
#define VFB_DEFAULT_HEIGHT 1024
|
||||||
#define VFB_DEFAULT_DEPTH 24
|
#define VFB_DEFAULT_DEPTH 24
|
||||||
|
@ -109,12 +101,6 @@ typedef struct {
|
||||||
#ifdef HAS_SHM
|
#ifdef HAS_SHM
|
||||||
int shmid;
|
int shmid;
|
||||||
#endif
|
#endif
|
||||||
#ifdef GLAMOR_HAS_GBM
|
|
||||||
int fd;
|
|
||||||
CreateScreenResourcesProcPtr createScreenResources;
|
|
||||||
struct gbm_device *gbm;
|
|
||||||
struct gbm_bo *front_bo;
|
|
||||||
#endif
|
|
||||||
} vfbScreenInfo, *vfbScreenInfoPtr;
|
} vfbScreenInfo, *vfbScreenInfoPtr;
|
||||||
|
|
||||||
static int vfbNumScreens;
|
static int vfbNumScreens;
|
||||||
|
@ -740,110 +726,10 @@ vfbCloseScreen(ScreenPtr pScreen)
|
||||||
if (pScreen->devPrivate)
|
if (pScreen->devPrivate)
|
||||||
(*pScreen->DestroyPixmap) (pScreen->devPrivate);
|
(*pScreen->DestroyPixmap) (pScreen->devPrivate);
|
||||||
pScreen->devPrivate = NULL;
|
pScreen->devPrivate = NULL;
|
||||||
#ifdef GLAMOR_HAS_GBM
|
|
||||||
if (pvfb->fd >= 0) {
|
|
||||||
if (pvfb->front_bo) {
|
|
||||||
gbm_bo_destroy(pvfb->front_bo);
|
|
||||||
pvfb->front_bo = NULL;
|
|
||||||
}
|
|
||||||
close(pvfb->fd);
|
|
||||||
pvfb->fd = -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* XXX: There is an existing vfbScreens leak. Should we free() it directly
|
|
||||||
* or otherwise - input welcome.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return pScreen->CloseScreen(pScreen);
|
return pScreen->CloseScreen(pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GLAMOR_HAS_GBM
|
|
||||||
static Bool
|
|
||||||
vfbCreateScreenResources(ScreenPtr pScreen)
|
|
||||||
{
|
|
||||||
vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
|
|
||||||
PixmapPtr pixmap;
|
|
||||||
Bool ret;
|
|
||||||
|
|
||||||
pScreen->CreateScreenResources = pvfb->createScreenResources;
|
|
||||||
ret = pScreen->CreateScreenResources(pScreen);
|
|
||||||
pScreen->CreateScreenResources = vfbCreateScreenResources;
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
pixmap = pScreen->GetScreenPixmap(pScreen);
|
|
||||||
/* TODO: add support for modifiers at some point */
|
|
||||||
if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, pvfb->front_bo,
|
|
||||||
FALSE)) {
|
|
||||||
LogMessage(X_ERROR, "glamor_egl_create_textured_pixmap() failed\n");
|
|
||||||
/* TODO: plug the leak, aka undo the CreateScreenResources() call above. */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
vfbDRIInit(ScreenPtr pScreen)
|
|
||||||
{
|
|
||||||
vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
|
|
||||||
/* TODO: don't hardcode the node name */
|
|
||||||
const char *node_name = "/dev/dri/renderD128";
|
|
||||||
const char *error_msg;
|
|
||||||
|
|
||||||
pvfb->fd = open(node_name, O_RDWR | O_CLOEXEC);
|
|
||||||
if (pvfb->fd < 0) {
|
|
||||||
error_msg = "Failed to open device node";
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!glamor_egl_init(pScreen, pvfb->fd)) {
|
|
||||||
error_msg = "Failed to initialize glamor";
|
|
||||||
goto close_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
pvfb->gbm = glamor_egl_get_gbm_device(pScreen);
|
|
||||||
if (!pvfb->gbm) {
|
|
||||||
error_msg = "Failed to get gbm device";
|
|
||||||
goto egl_fini;
|
|
||||||
}
|
|
||||||
pvfb->front_bo = gbm_bo_create(pvfb->gbm,
|
|
||||||
pScreen->width, pScreen->height,
|
|
||||||
GBM_FORMAT_ARGB8888,
|
|
||||||
GBM_BO_USE_RENDERING);
|
|
||||||
if (!pvfb->front_bo) {
|
|
||||||
error_msg = "Failed to create front buffer";
|
|
||||||
goto egl_fini;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) {
|
|
||||||
error_msg = "Failed to initialize glamor at ScreenInit() time";
|
|
||||||
goto destroy_bo;
|
|
||||||
}
|
|
||||||
|
|
||||||
pvfb->createScreenResources = pScreen->CreateScreenResources;
|
|
||||||
pScreen->CreateScreenResources = vfbCreateScreenResources;
|
|
||||||
return;
|
|
||||||
|
|
||||||
destroy_bo:
|
|
||||||
gbm_bo_destroy(pvfb->front_bo);
|
|
||||||
egl_fini:
|
|
||||||
/* TODO: There's no glamor_egl_fini just yet */
|
|
||||||
close_fd:
|
|
||||||
close(pvfb->fd);
|
|
||||||
out:
|
|
||||||
LogMessage(X_ERROR, "%s. Disabling GLAMOR/DRI3.\n", error_msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void
|
|
||||||
vfbDRIInit(ScreenPtr pScreen)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
vfbRROutputValidateMode(ScreenPtr pScreen,
|
vfbRROutputValidateMode(ScreenPtr pScreen,
|
||||||
RROutputPtr output,
|
RROutputPtr output,
|
||||||
|
@ -1036,14 +922,12 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv)
|
||||||
|
|
||||||
ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
|
ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
|
||||||
dpix, dpiy, pvfb->paddedWidth, pvfb->bitsPerPixel);
|
dpix, dpiy, pvfb->paddedWidth, pvfb->bitsPerPixel);
|
||||||
|
if (ret && Render)
|
||||||
|
fbPictureInit(pScreen, 0, 0);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (Render) {
|
|
||||||
fbPictureInit(pScreen, 0, 0);
|
|
||||||
vfbDRIInit(pScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vfbRandRInit(pScreen))
|
if (!vfbRandRInit(pScreen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,6 @@ bin_PROGRAMS = Xvfb
|
||||||
|
|
||||||
AM_CFLAGS = -DHAVE_DIX_CONFIG_H \
|
AM_CFLAGS = -DHAVE_DIX_CONFIG_H \
|
||||||
$(XVFBMODULES_CFLAGS) \
|
$(XVFBMODULES_CFLAGS) \
|
||||||
-I$(top_srcdir)/glamor/ \
|
|
||||||
-I$(top_srcdir)/dri3/ \
|
|
||||||
$(LIBDRM_CFLAGS) \
|
|
||||||
$(GBM_CFLAGS) \
|
|
||||||
$(DIX_CFLAGS)
|
$(DIX_CFLAGS)
|
||||||
|
|
||||||
SRCS = InitInput.c \
|
SRCS = InitInput.c \
|
||||||
|
@ -17,7 +13,6 @@ SRCS = InitInput.c \
|
||||||
Xvfb_SOURCES = $(SRCS)
|
Xvfb_SOURCES = $(SRCS)
|
||||||
|
|
||||||
XVFB_LIBS = \
|
XVFB_LIBS = \
|
||||||
$(glamor_lib) \
|
|
||||||
@XVFB_LIBS@ \
|
@XVFB_LIBS@ \
|
||||||
$(MAIN_LIB) \
|
$(MAIN_LIB) \
|
||||||
$(XSERVER_LIBS) \
|
$(XSERVER_LIBS) \
|
||||||
|
@ -27,13 +22,5 @@ Xvfb_LDADD = $(XVFB_LIBS) $(XVFB_SYS_LIBS) $(XSERVER_SYS_LIBS)
|
||||||
Xvfb_DEPENDENCIES = $(XVFB_LIBS)
|
Xvfb_DEPENDENCIES = $(XVFB_LIBS)
|
||||||
Xvfb_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
|
Xvfb_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
|
||||||
|
|
||||||
if GLAMOR_EGL
|
|
||||||
Xvfb_SOURCES += $(top_srcdir)/glamor/glamor_egl.c
|
|
||||||
glamor_lib = $(top_builddir)/glamor/libglamor.la
|
|
||||||
|
|
||||||
Xvfb_LDADD += $(GLAMOR_LIBS) $(GBM_LIBS) $(LIBDRM_LIBS) -lEGL -lGL
|
|
||||||
Xvfb_DEPENDENCIES = $(glamor_lib) $(XVFB_LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
relink:
|
relink:
|
||||||
$(AM_V_at)rm -f Xvfb$(EXEEXT) && $(MAKE) Xvfb$(EXEEXT)
|
$(AM_V_at)rm -f Xvfb$(EXEEXT) && $(MAKE) Xvfb$(EXEEXT)
|
||||||
|
|
|
@ -4,27 +4,12 @@ srcs = [
|
||||||
'../../mi/miinitext.c',
|
'../../mi/miinitext.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
vfb_dep = []
|
|
||||||
vfb_glamor = []
|
|
||||||
if build_glamor
|
|
||||||
srcs += '../../glamor/glamor_egl.c'
|
|
||||||
vfb_dep += [
|
|
||||||
libdrm_dep,
|
|
||||||
gbm_dep,
|
|
||||||
]
|
|
||||||
vfb_glamor += glamor
|
|
||||||
endif
|
|
||||||
|
|
||||||
xvfb_server = executable(
|
xvfb_server = executable(
|
||||||
'Xvfb',
|
'Xvfb',
|
||||||
srcs,
|
srcs,
|
||||||
include_directories: inc,
|
include_directories: inc,
|
||||||
dependencies: [
|
dependencies: common_dep,
|
||||||
common_dep,
|
|
||||||
vfb_dep,
|
|
||||||
],
|
|
||||||
link_with: [
|
link_with: [
|
||||||
vfb_glamor,
|
|
||||||
libxserver_main,
|
libxserver_main,
|
||||||
libxserver_fb,
|
libxserver_fb,
|
||||||
libxserver,
|
libxserver,
|
||||||
|
|
|
@ -768,7 +768,7 @@ try_enable_glamor(ScrnInfoPtr pScrn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
|
if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
|
||||||
if (glamor_egl_init(xf86ScrnToScreen(pScrn), ms->fd)) {
|
if (glamor_egl_init(pScrn, ms->fd)) {
|
||||||
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
|
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
|
||||||
ms->drmmode.glamor = TRUE;
|
ms->drmmode.glamor = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "dumb_bo.h"
|
#include "dumb_bo.h"
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
#include "xf86str.h"
|
#include "xf86str.h"
|
||||||
#include "xf86Priv.h"
|
|
||||||
#include "X11/Xatom.h"
|
#include "X11/Xatom.h"
|
||||||
#include "micmap.h"
|
#include "micmap.h"
|
||||||
#include "xf86cmap.h"
|
#include "xf86cmap.h"
|
||||||
|
@ -3413,12 +3412,7 @@ drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
|
||||||
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
|
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
|
||||||
|
|
||||||
if (drmmode->glamor) {
|
if (drmmode->glamor) {
|
||||||
unsigned int flags = GLAMOR_USE_EGL_SCREEN;
|
if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) {
|
||||||
|
|
||||||
if (xf86Info.debug != NULL && !strstr(xf86Info.debug, "dmabuf_capable"))
|
|
||||||
flags |= GLAMOR_NO_MODIFIERS;
|
|
||||||
|
|
||||||
if (!glamor_init(pScreen, flags)) {
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#ifdef GBM_BO_WITH_MODIFIERS
|
#ifdef GBM_BO_WITH_MODIFIERS
|
||||||
|
|
|
@ -324,8 +324,8 @@ endif
|
||||||
gbm_dep = dependency('', required: false)
|
gbm_dep = dependency('', required: false)
|
||||||
epoxy_dep = dependency('', required: false)
|
epoxy_dep = dependency('', required: false)
|
||||||
if build_glamor
|
if build_glamor
|
||||||
gbm_dep = dependency('gbm', version: gbm_req, required: true)
|
gbm_dep = dependency('gbm', version: gbm_req, required: false)
|
||||||
epoxy_dep = dependency('epoxy', required: true)
|
epoxy_dep = dependency('epoxy', required: false)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
eglstream_option = get_option('xwayland_eglstream')
|
eglstream_option = get_option('xwayland_eglstream')
|
||||||
|
|
Loading…
Reference in New Issue