aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glamor/glamor_egl.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-03-04 08:57:07 +0100
committermarha <marha@users.sourceforge.net>2014-03-04 08:57:07 +0100
commit321c01267ae1c446f1bd22b642567fcafa016c02 (patch)
tree69f6e12bdfd1ccda5d054398321bc1876dd3fc89 /xorg-server/glamor/glamor_egl.c
parent982ac918afe6a1c02d5cf735d7b6c56443a048cc (diff)
downloadvcxsrv-321c01267ae1c446f1bd22b642567fcafa016c02.tar.gz
vcxsrv-321c01267ae1c446f1bd22b642567fcafa016c02.tar.bz2
vcxsrv-321c01267ae1c446f1bd22b642567fcafa016c02.zip
libX11 libxcb mesa xserver xcb-proto xkeyboard-config git update 4 Mar 2014
xserver commit b634e909895f6001e7d9543e1350b20c82c8c01c libxcb commit 4ffa6f83b92763eb901c7ddb7c20775e24d507ca libxcb/xcb-proto commit 4270141a7cb3c68f50251be19a5a628aa18553e6 xkeyboard-config commit d9e3d0ec1a48a5f61ea6dd6d20b8682eeecf3a39 libX11 commit d6bd988bc00494914b38b95ee5df77ac4f32f19f libXdmcp commit 089081dca4ba3598c6f9bf401c029378943b5854 libXext commit d5447c0156f556114dbf97d6064c0c7b0fcd5f70 libfontenc commit 0037a42107b952c9d903719615747e760e4e7247 libXinerama commit edd95182b26eb5d576d4878c559e0f17dddaa909 libXau commit 1e4635be11154dd8262f37b379511bd627defa2a xkbcomp commit 31b90ee4ffc774e0da540277907fc5540c0b012c pixman commit 82d094654a46bd97d47f1f132a01ae0a74b986f3 xextproto commit 66afec3f49e8eb0d4c2e9af7088fc3116d4bafd7 randrproto commit a4a6694c059d74247c16527eef4a0ec9f56bbef6 glproto commit f84853d97d5749308992412a215fa518b6536eb3 mkfontscale commit eac564e0fc9052a39981ea47b271f7f3d2821944 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 libXft commit 4acfdaf95adb0a05c2a25550bdde036c865902f4 libXmu commit 22d9c590901e121936f50dee97dc60c4f7defb63 libxtrans commit 3f0de269abe59353acbd7a5587d68ce0da91db67 fontconfig commit e310d2fac2d874d5aa76c609df70cc7b871c0b6d mesa commit 1a568e0f2b65e4e1e1d19a6dece3a792a33da825
Diffstat (limited to 'xorg-server/glamor/glamor_egl.c')
-rw-r--r--xorg-server/glamor/glamor_egl.c184
1 files changed, 72 insertions, 112 deletions
diff --git a/xorg-server/glamor/glamor_egl.c b/xorg-server/glamor/glamor_egl.c
index 2f97a839b..9dcba71ce 100644
--- a/xorg-server/glamor/glamor_egl.c
+++ b/xorg-server/glamor/glamor_egl.c
@@ -37,8 +37,6 @@
#include <errno.h>
#include <xf86.h>
#include <xf86drm.h>
-#define GL_GLEXT_PROTOTYPES
-#define EGL_EGLEXT_PROTOTYPES
#define EGL_DISPLAY_NO_X_MESA
#ifdef GLAMOR_HAS_GBM
@@ -46,19 +44,12 @@
#include <drm_fourcc.h>
#endif
-#if GLAMOR_GLES2
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#else
-#include <GL/gl.h>
-#endif
-
#define MESA_EGL_NO_X11_HEADERS
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
+#include <epoxy/gl.h>
+#include <epoxy/egl.h>
#include "glamor.h"
-#include "glamor_gl_dispatch.h"
+#include "glamor_priv.h"
static const char glamor_name[] = "glamor";
@@ -91,16 +82,13 @@ struct glamor_egl_screen_private {
int gl_context_depth;
int dri3_capable;
- PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
- PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC egl_image_target_texture2d_oes;
- struct glamor_gl_dispatch *dispatch;
CloseScreenProcPtr saved_close_screen;
xf86FreeScreenProc *saved_free_screen;
};
int xf86GlamorEGLPrivateIndex = -1;
+
static struct glamor_egl_screen_private *
glamor_egl_get_screen_private(ScrnInfoPtr scrn)
{
@@ -108,38 +96,30 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
}
-_X_EXPORT void
-glamor_egl_make_current(ScreenPtr screen)
+static void
+glamor_egl_get_context(struct glamor_context *glamor_ctx)
{
- ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
- struct glamor_egl_screen_private *glamor_egl =
- glamor_egl_get_screen_private(scrn);
-
- if (glamor_egl->gl_context_depth++)
+ if (glamor_ctx->get_count++)
return;
- if (glamor_egl->context != eglGetCurrentContext()) {
- eglMakeCurrent(glamor_egl->display, EGL_NO_SURFACE,
+ if (glamor_ctx->ctx != eglGetCurrentContext()) {
+ eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
- if (!eglMakeCurrent(glamor_egl->display,
+ if (!eglMakeCurrent(glamor_ctx->display,
EGL_NO_SURFACE, EGL_NO_SURFACE,
- glamor_egl->context)) {
+ glamor_ctx->ctx)) {
FatalError("Failed to make EGL context current\n");
}
}
}
-_X_EXPORT void
-glamor_egl_restore_context(ScreenPtr screen)
+static void
+glamor_egl_put_context(struct glamor_context *glamor_ctx)
{
- ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
- struct glamor_egl_screen_private *glamor_egl =
- glamor_egl_get_screen_private(scrn);
-
- if (--glamor_egl->gl_context_depth)
+ if (--glamor_ctx->get_count)
return;
- eglMakeCurrent(glamor_egl->display, EGL_NO_SURFACE,
+ eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
@@ -164,11 +144,11 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
attribs[5] = stride;
if (depth != 32 && depth != 24)
return EGL_NO_IMAGE_KHR;
- image = glamor_egl->egl_create_image_khr(glamor_egl->display,
- glamor_egl->context,
- EGL_DRM_BUFFER_MESA,
- (void *) (uintptr_t) name,
- attribs);
+ image = eglCreateImageKHR(glamor_egl->display,
+ glamor_egl->context,
+ EGL_DRM_BUFFER_MESA,
+ (void *) (uintptr_t) name,
+ attribs);
if (image == EGL_NO_IMAGE_KHR)
return EGL_NO_IMAGE_KHR;
@@ -192,15 +172,13 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
*glamor_egl,
EGLImageKHR image, GLuint * texture)
{
- glamor_egl->dispatch->glGenTextures(1, texture);
- glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, *texture);
- glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
- GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
- GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- (glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D, image);
- glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, 0);
+ glGenTextures(1, texture);
+ glBindTexture(GL_TEXTURE_2D, *texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+ glBindTexture(GL_TEXTURE_2D, 0);
return TRUE;
}
@@ -212,7 +190,7 @@ glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
EGLImageKHR image;
GLuint texture;
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
struct gbm_bo *bo;
EGLNativePixmapType native_pixmap;
@@ -228,15 +206,15 @@ glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
* compile with dri3 support enabled */
native_pixmap = bo;
- image = glamor_egl->egl_create_image_khr(glamor_egl->display,
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- native_pixmap, NULL);
+ image = eglCreateImageKHR(glamor_egl->display,
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ native_pixmap, NULL);
gbm_bo_destroy(bo);
if (image == EGL_NO_IMAGE_KHR)
return 0;
glamor_create_texture_from_image(glamor_egl, image, &texture);
- glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+ eglDestroyImageKHR(glamor_egl->display, image);
return texture;
#else
@@ -300,6 +278,8 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
{
ScreenPtr screen = pixmap->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
struct glamor_egl_screen_private *glamor_egl;
EGLImageKHR image;
GLuint texture;
@@ -308,7 +288,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
glamor_egl = glamor_egl_get_screen_private(scrn);
- glamor_egl_make_current(screen);
+ glamor_get_context(glamor_priv);
if (glamor_egl->has_gem) {
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -338,7 +318,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
ret = TRUE;
done:
- glamor_egl_restore_context(screen);
+ glamor_put_context(glamor_priv);
return ret;
}
@@ -347,6 +327,8 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
{
ScreenPtr screen = pixmap->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
struct glamor_egl_screen_private *glamor_egl;
EGLImageKHR image;
GLuint texture;
@@ -354,11 +336,11 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
glamor_egl = glamor_egl_get_screen_private(scrn);
- glamor_egl_make_current(screen);
+ glamor_get_context(glamor_priv);
- image = glamor_egl->egl_create_image_khr(glamor_egl->display,
- glamor_egl->context,
- EGL_NATIVE_PIXMAP_KHR, bo, NULL);
+ image = eglCreateImageKHR(glamor_egl->display,
+ glamor_egl->context,
+ EGL_NATIVE_PIXMAP_KHR, bo, NULL);
if (image == EGL_NO_IMAGE_KHR) {
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
goto done;
@@ -370,11 +352,11 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
ret = TRUE;
done:
- glamor_egl_restore_context(screen);
+ glamor_put_context(glamor_priv);
return ret;
}
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
int glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd);
void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
int
@@ -409,8 +391,10 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
unsigned int tex,
Bool want_name, CARD16 *stride, CARD32 *size)
{
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
struct glamor_egl_screen_private *glamor_egl;
EGLImageKHR image;
struct gbm_bo *bo;
@@ -424,17 +408,17 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
glamor_egl = glamor_egl_get_screen_private(scrn);
- glamor_egl_make_current(screen);
+ glamor_get_context(glamor_priv);
image = dixLookupPrivate(&pixmap->devPrivates,
glamor_egl_pixmap_private_key);
if (image == EGL_NO_IMAGE_KHR || image == NULL) {
- image = glamor_egl->egl_create_image_khr(glamor_egl->display,
- glamor_egl->context,
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer) (uintptr_t)
- tex, attribs);
+ image = eglCreateImageKHR(glamor_egl->display,
+ glamor_egl->context,
+ EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer) (uintptr_t)
+ tex, attribs);
if (image == EGL_NO_IMAGE_KHR)
goto failure;
@@ -462,7 +446,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
gbm_bo_destroy(bo);
failure:
- glamor_egl_restore_context(screen);
+ glamor_put_context(glamor_priv);
return fd;
#else
return -1;
@@ -476,7 +460,7 @@ glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
CARD16 height,
CARD16 stride, CARD8 depth, CARD8 bpp)
{
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
struct glamor_egl_screen_private *glamor_egl;
struct gbm_bo *bo;
@@ -506,10 +490,10 @@ glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
attribs[3] = height;
attribs[7] = fd;
attribs[11] = stride;
- image = glamor_egl->egl_create_image_khr(glamor_egl->display,
- EGL_NO_CONTEXT,
- EGL_LINUX_DMA_BUF_EXT,
- NULL, attribs);
+ image = eglCreateImageKHR(glamor_egl->display,
+ EGL_NO_CONTEXT,
+ EGL_LINUX_DMA_BUF_EXT,
+ NULL, attribs);
if (image == EGL_NO_IMAGE_KHR)
return NULL;
@@ -518,7 +502,7 @@ glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
* usage of the image. Use gbm_bo to bypass the limitations. */
bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
- glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+ eglDestroyImageKHR(glamor_egl->display, image);
if (!bo)
return NULL;
@@ -555,7 +539,7 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
* a texture. we must call glFlush to make sure the
* operation on that texture has been done.*/
glamor_block_handler(pixmap->drawable.pScreen);
- glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+ eglDestroyImageKHR(glamor_egl->display, image);
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
NULL);
}
@@ -605,8 +589,7 @@ glamor_egl_close_screen(ScreenPtr screen)
glamor_egl = glamor_egl_get_screen_private(scrn);
screen_pixmap = screen->GetScreenPixmap(screen);
- glamor_egl->egl_destroy_image_khr(glamor_egl->display,
- glamor_egl->front_image);
+ eglDestroyImageKHR(glamor_egl->display,glamor_egl->front_image);
dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key,
NULL);
glamor_egl->front_image = NULL;
@@ -614,7 +597,7 @@ glamor_egl_close_screen(ScreenPtr screen)
back_image = dixLookupPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
glamor_egl_pixmap_private_key);
if (back_image != NULL && back_image != EGL_NO_IMAGE_KHR) {
- glamor_egl->egl_destroy_image_khr(glamor_egl->display, back_image);
+ eglDestroyImageKHR(glamor_egl->display, back_image);
dixSetPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
glamor_egl_pixmap_private_key, NULL);
}
@@ -645,7 +628,7 @@ glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
}
void
-glamor_egl_screen_init(ScreenPtr screen)
+glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
struct glamor_egl_screen_private *glamor_egl =
@@ -653,6 +636,12 @@ glamor_egl_screen_init(ScreenPtr screen)
glamor_egl->saved_close_screen = screen->CloseScreen;
screen->CloseScreen = glamor_egl_close_screen;
+
+ glamor_ctx->ctx = glamor_egl->context;
+ glamor_ctx->display = glamor_egl->display;
+
+ glamor_ctx->get_context = glamor_egl_get_context;
+ glamor_ctx->put_context = glamor_egl_put_context;
}
static void
@@ -746,26 +735,11 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
KHR_surfaceless_opengl);
#endif
-#ifdef GLAMOR_HAS_DRI3_SUPPORT
+#ifdef GLAMOR_HAS_GBM
if (glamor_egl_has_extension(glamor_egl, "EGL_KHR_gl_texture_2D_image") &&
glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import"))
glamor_egl->dri3_capable = TRUE;
#endif
- glamor_egl->egl_create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
- eglGetProcAddress("eglCreateImageKHR");
-
- glamor_egl->egl_destroy_image_khr = (PFNEGLDESTROYIMAGEKHRPROC)
- eglGetProcAddress("eglDestroyImageKHR");
-
- glamor_egl->egl_image_target_texture2d_oes =
- (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
- eglGetProcAddress("glEGLImageTargetTexture2DOES");
-
- if (!glamor_egl->egl_create_image_khr
- || !glamor_egl->egl_image_target_texture2d_oes) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetProcAddress() failed\n");
- return FALSE;
- }
glamor_egl->context = eglCreateContext(glamor_egl->display,
NULL, EGL_NO_CONTEXT,
@@ -809,17 +783,3 @@ glamor_egl_init_textured_pixmap(ScreenPtr screen)
glamor_enable_dri3(screen);
return TRUE;
}
-
-Bool
-glamor_gl_dispatch_init(ScreenPtr screen,
- struct glamor_gl_dispatch *dispatch, int gl_version)
-{
- ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
- struct glamor_egl_screen_private *glamor_egl =
- glamor_egl_get_screen_private(scrn);
- if (!glamor_gl_dispatch_init_impl
- (dispatch, gl_version, (get_proc_address_t) eglGetProcAddress))
- return FALSE;
- glamor_egl->dispatch = dispatch;
- return TRUE;
-}