diff options
author | marha <marha@users.sourceforge.net> | 2014-03-04 12:18:13 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-03-04 12:23:48 +0100 |
commit | 45392e4a0642880b569ea5d4a350cdc395a2c7db (patch) | |
tree | c3c2a49de903a18c3f8e1bf79684c29337ebcf7c /xorg-server/glamor/glamor_egl.c | |
parent | 5ec0616d4e3c4c6095f4975abbe9c21e5b6af967 (diff) | |
parent | 321c01267ae1c446f1bd22b642567fcafa016c02 (diff) | |
download | vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.tar.gz vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.tar.bz2 vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
libX11 libxcb mesa xserver xcb-proto xkeyboard-config git update 4 Mar 2014
Conflicts:
mesalib/src/mapi/glapi/glapi.h
mesalib/src/mapi/glapi/glthread.c
mesalib/src/mesa/drivers/dri/common/dri_util.c
mesalib/src/mesa/main/bufferobj.c
xorg-server/dix/dispatch.c
xorg-server/hw/xwin/glx/gen_gl_wrappers.py
xorg-server/hw/xwin/winmultiwindowwm.c
Diffstat (limited to 'xorg-server/glamor/glamor_egl.c')
-rw-r--r-- | xorg-server/glamor/glamor_egl.c | 184 |
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; -} |