mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
glamor/glamor_egl: xfree86/glamor_egl: Split generic and xf86 glamor egl code
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
committed by
Enrico Weigelt
parent
36d80785ab
commit
2027509a86
@@ -28,13 +28,11 @@
|
||||
*/
|
||||
#include <dix-config.h>
|
||||
|
||||
#define GLAMOR_FOR_XORG
|
||||
#define GLAMOR_FOR_XORG /* for -Wmissing-prototypes */
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86Priv.h>
|
||||
#include <xf86drm.h>
|
||||
#define EGL_DISPLAY_NO_X_MESA
|
||||
|
||||
@@ -45,45 +43,11 @@
|
||||
#include "glamor/glamor_priv.h"
|
||||
#include "os/bug_priv.h"
|
||||
|
||||
#include "glamor.h"
|
||||
#include "glamor_egl.h"
|
||||
#include "glamor_glx_provider.h"
|
||||
#include "dri3.h"
|
||||
|
||||
#if 1 /* xf86-only */
|
||||
static int xf86GlamorEGLPrivateIndex = -1;
|
||||
|
||||
static inline glamor_egl_priv_t*
|
||||
glamor_xf86_egl_get_scrn_private(ScrnInfoPtr scrn)
|
||||
{
|
||||
return (glamor_egl_priv_t *)
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||
}
|
||||
|
||||
static glamor_egl_priv_t*
|
||||
glamor_xf86_egl_get_screen_private(ScreenPtr screen)
|
||||
{
|
||||
return glamor_xf86_egl_get_scrn_private(xf86ScreenToScrn(screen));
|
||||
}
|
||||
|
||||
static void glamor_egl_cleanup(glamor_egl_priv_t *glamor_egl);
|
||||
|
||||
static void
|
||||
glamor_xf86_egl_free_screen(ScrnInfoPtr scrn)
|
||||
{
|
||||
glamor_egl_priv_t *glamor_egl;
|
||||
|
||||
glamor_egl = glamor_xf86_egl_get_scrn_private(scrn);
|
||||
if (glamor_egl != NULL) {
|
||||
scrn->FreeScreen = glamor_egl->saved_free_screen;
|
||||
glamor_egl_cleanup(glamor_egl);
|
||||
free(glamor_egl);
|
||||
scrn->FreeScreen(scrn);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Hack to not break xf86 drivers.
|
||||
*
|
||||
@@ -1142,7 +1106,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void glamor_egl_cleanup(glamor_egl_priv_t *glamor_egl)
|
||||
void glamor_egl_cleanup(glamor_egl_priv_t *glamor_egl)
|
||||
{
|
||||
if (!glamor_egl) {
|
||||
return;
|
||||
@@ -1246,17 +1210,6 @@ glamor_egl_try_gles_api(glamor_egl_priv_t *glamor_egl)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
enum {
|
||||
GLAMOREGLOPT_RENDERING_API,
|
||||
GLAMOREGLOPT_VENDOR_LIBRARY
|
||||
};
|
||||
|
||||
static const OptionInfoRec GlamorEGLOptions[] = {
|
||||
{ GLAMOREGLOPT_RENDERING_API, "RenderingAPI", OPTV_STRING, {0}, FALSE },
|
||||
{ GLAMOREGLOPT_VENDOR_LIBRARY, "GlxVendorLibrary", OPTV_STRING, {0}, FALSE },
|
||||
{ -1, NULL, OPTV_NONE, {0}, FALSE },
|
||||
};
|
||||
|
||||
Bool
|
||||
glamor_egl_init2(glamor_egl_priv_t* glamor_egl)
|
||||
{
|
||||
@@ -1357,10 +1310,8 @@ glamor_egl_init2(glamor_egl_priv_t* glamor_egl)
|
||||
"EGL_EXT_image_dma_buf_import") &&
|
||||
epoxy_has_egl_extension(glamor_egl->display,
|
||||
"EGL_EXT_image_dma_buf_import_modifiers")) {
|
||||
if (xf86Info.debug != NULL)
|
||||
glamor_egl->dmabuf_capable = !!strstr(xf86Info.debug,
|
||||
"dmabuf_capable");
|
||||
else if (strstr((const char *)renderer, "Intel"))
|
||||
|
||||
if (strstr((const char *)renderer, "Intel"))
|
||||
glamor_egl->dmabuf_capable = TRUE;
|
||||
else if (strstr((const char *)renderer, "zink"))
|
||||
glamor_egl->dmabuf_capable = TRUE;
|
||||
@@ -1369,7 +1320,7 @@ glamor_egl_init2(glamor_egl_priv_t* glamor_egl)
|
||||
else if (strstr((const char *)renderer, "radeonsi"))
|
||||
glamor_egl->dmabuf_capable = TRUE;
|
||||
else
|
||||
glamor_egl->dmabuf_capable = FALSE;
|
||||
glamor_egl->dmabuf_capable = (glamor_egl->dmabuf_capable == TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1409,57 +1360,3 @@ error:
|
||||
glamor_egl_cleanup(glamor_egl);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||
{
|
||||
glamor_egl_priv_t *glamor_egl;
|
||||
OptionInfoPtr options;
|
||||
const char *api = NULL;
|
||||
const char *glvnd_vendor = NULL;
|
||||
|
||||
glamor_egl = calloc(1, sizeof(*glamor_egl));
|
||||
if (glamor_egl == NULL)
|
||||
return FALSE;
|
||||
if (xf86GlamorEGLPrivateIndex == -1)
|
||||
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
||||
|
||||
options = XNFalloc(sizeof(GlamorEGLOptions));
|
||||
memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions));
|
||||
xf86ProcessOptions(scrn->scrnIndex, scrn->options, options);
|
||||
glvnd_vendor = xf86GetOptValString(options, GLAMOREGLOPT_VENDOR_LIBRARY);
|
||||
if (glvnd_vendor) {
|
||||
glamor_egl->glvnd_vendor = strdup(glvnd_vendor);
|
||||
if (!glamor_egl->glvnd_vendor) {
|
||||
LogMessage(X_WARNING, "Couldn't set gl vendor to: %s\n", glvnd_vendor);
|
||||
}
|
||||
}
|
||||
api = xf86GetOptValString(options, GLAMOREGLOPT_RENDERING_API);
|
||||
if (api && !strncasecmp(api, "es", 2))
|
||||
glamor_egl->force_es = TRUE;
|
||||
else if (api && !strncasecmp(api, "gl", 2))
|
||||
glamor_egl->es_disallowed = TRUE;
|
||||
free(options);
|
||||
|
||||
glamor_egl->GLAMOR_EGL_PRIV_PROC = glamor_xf86_egl_get_screen_private;
|
||||
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||
|
||||
glamor_egl->fd = fd;
|
||||
|
||||
if (glamor_egl_init2(glamor_egl)) {
|
||||
glamor_egl->saved_free_screen = scrn->FreeScreen;
|
||||
scrn->FreeScreen = glamor_xf86_egl_free_screen;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
free(glamor_egl);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Stub to retain compatibility with pre-server-1.16 ABI. */
|
||||
Bool
|
||||
glamor_egl_init_textured_pixmap(ScreenPtr screen)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ typedef struct glamor_egl_screen_private {
|
||||
struct glamor_egl_screen_private* (*GLAMOR_EGL_PRIV_PROC)(ScreenPtr screen);
|
||||
} glamor_egl_priv_t;
|
||||
|
||||
void glamor_egl_cleanup(glamor_egl_priv_t *glamor_egl);
|
||||
|
||||
/* Initialize an egl context suitable to be used by glamor. */
|
||||
Bool glamor_egl_init2(glamor_egl_priv_t* glamor_egl);
|
||||
|
||||
/*
|
||||
* Create an EGLDisplay from a native display type. This is a little quirky
|
||||
* for a few reasons.
|
||||
|
||||
111
hw/xfree86/glamor_egl/glamor_xf86_egl.c
Normal file
111
hw/xfree86/glamor_egl/glamor_xf86_egl.c
Normal file
@@ -0,0 +1,111 @@
|
||||
/* SPDX-License-Identifier: MIT OR X11
|
||||
*
|
||||
* Copyright © 2026 stefan11111 <stefan11111@shitposting.expert>
|
||||
*/
|
||||
|
||||
#include <dix-config.h>
|
||||
|
||||
#define GLAMOR_FOR_XORG
|
||||
#include <xf86.h>
|
||||
#include <xf86Priv.h>
|
||||
|
||||
#include "glamor.h"
|
||||
#include "../../glamor/glamor_egl.h"
|
||||
|
||||
enum {
|
||||
GLAMOREGLOPT_RENDERING_API,
|
||||
GLAMOREGLOPT_VENDOR_LIBRARY
|
||||
};
|
||||
|
||||
static const OptionInfoRec GlamorEGLOptions[] = {
|
||||
{ GLAMOREGLOPT_RENDERING_API, "RenderingAPI", OPTV_STRING, {0}, FALSE },
|
||||
{ GLAMOREGLOPT_VENDOR_LIBRARY, "GlxVendorLibrary", OPTV_STRING, {0}, FALSE },
|
||||
{ -1, NULL, OPTV_NONE, {0}, FALSE },
|
||||
};
|
||||
|
||||
static int xf86GlamorEGLPrivateIndex = -1;
|
||||
|
||||
static inline glamor_egl_priv_t*
|
||||
glamor_xf86_egl_get_scrn_private(ScrnInfoPtr scrn)
|
||||
{
|
||||
return (glamor_egl_priv_t *)
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||
}
|
||||
|
||||
static glamor_egl_priv_t*
|
||||
glamor_xf86_egl_get_screen_private(ScreenPtr screen)
|
||||
{
|
||||
return glamor_xf86_egl_get_scrn_private(xf86ScreenToScrn(screen));
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_xf86_egl_free_screen(ScrnInfoPtr scrn)
|
||||
{
|
||||
glamor_egl_priv_t *glamor_egl;
|
||||
|
||||
glamor_egl = glamor_xf86_egl_get_scrn_private(scrn);
|
||||
if (glamor_egl != NULL) {
|
||||
scrn->FreeScreen = glamor_egl->saved_free_screen;
|
||||
glamor_egl_cleanup(glamor_egl);
|
||||
free(glamor_egl);
|
||||
scrn->FreeScreen(scrn);
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||
{
|
||||
glamor_egl_priv_t *glamor_egl;
|
||||
OptionInfoPtr options;
|
||||
const char *api = NULL;
|
||||
const char *glvnd_vendor = NULL;
|
||||
|
||||
glamor_egl = calloc(1, sizeof(*glamor_egl));
|
||||
if (glamor_egl == NULL)
|
||||
return FALSE;
|
||||
if (xf86GlamorEGLPrivateIndex == -1)
|
||||
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
||||
|
||||
options = XNFalloc(sizeof(GlamorEGLOptions));
|
||||
memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions));
|
||||
xf86ProcessOptions(scrn->scrnIndex, scrn->options, options);
|
||||
glvnd_vendor = xf86GetOptValString(options, GLAMOREGLOPT_VENDOR_LIBRARY);
|
||||
if (glvnd_vendor) {
|
||||
glamor_egl->glvnd_vendor = strdup(glvnd_vendor);
|
||||
if (!glamor_egl->glvnd_vendor) {
|
||||
LogMessage(X_WARNING, "Couldn't set gl vendor to: %s\n", glvnd_vendor);
|
||||
}
|
||||
}
|
||||
api = xf86GetOptValString(options, GLAMOREGLOPT_RENDERING_API);
|
||||
if (api && !strncasecmp(api, "es", 2))
|
||||
glamor_egl->force_es = TRUE;
|
||||
else if (api && !strncasecmp(api, "gl", 2))
|
||||
glamor_egl->es_disallowed = TRUE;
|
||||
free(options);
|
||||
|
||||
glamor_egl->GLAMOR_EGL_PRIV_PROC = glamor_xf86_egl_get_screen_private;
|
||||
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||
|
||||
glamor_egl->fd = fd;
|
||||
|
||||
if (xf86Info.debug != NULL)
|
||||
glamor_egl->dmabuf_capable = !!strstr(xf86Info.debug,
|
||||
"dmabuf_capable");
|
||||
|
||||
if (glamor_egl_init2(glamor_egl)) {
|
||||
glamor_egl->saved_free_screen = scrn->FreeScreen;
|
||||
scrn->FreeScreen = glamor_xf86_egl_free_screen;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
free(glamor_egl);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Stub to retain compatibility with pre-server-1.16 ABI. */
|
||||
Bool
|
||||
glamor_egl_init_textured_pixmap(ScreenPtr screen)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
glamoregl_src = [
|
||||
'../../../glamor/glamor_egl.c',
|
||||
'../../../glamor/glamor_eglmodule.c',
|
||||
'glamor_xf86_egl.c',
|
||||
'glamor_xf86_xv.c',
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user