egl: new eglGetBufferImage()

glsl: builtins

git-svn-id: svn://kolibrios.org@4494 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-01-20 14:59:07 +00:00
parent de57cc6ce9
commit abe6d536c5
6 changed files with 20531 additions and 0 deletions

View File

@ -275,9 +275,12 @@ typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dp
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
#define EGL_DRM_BUFFER_FRONT 0x0000
#define EGL_DRM_BUFFER_BACK 0x0001
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
EGLAPI EGLImageKHR EGLAPIENTRY eglGetBufferImage(EGLDisplay dpy, EGLSurface surface, EGLint type);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);

View File

@ -206,6 +206,8 @@ struct dri2_egl_surface
/* EGL-owned buffers */
__DRIbuffer *local_buffers[__DRI_BUFFER_COUNT];
#endif
_EGLImage *egl_front, *egl_back;
EGLImageKHR khr_front, khr_back;
};

View File

@ -107,6 +107,9 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
struct dri2_egl_config *dri2_conf = dri2_egl_config(conf);
struct dri2_egl_surface *dri2_surf;
struct gbm_dri_surface *surf;
struct gbm_bo *bo;
_EGLImage *img;
EGLint attr[10];
(void) drv;
@ -133,6 +136,41 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
goto cleanup_surf;
}
attr[0] = EGL_WIDTH;
attr[1] = surf->base.width;
attr[2] = EGL_HEIGHT;
attr[3] = surf->base.height;
attr[4] = EGL_DRM_BUFFER_FORMAT_MESA;
attr[5] = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
attr[6] = EGL_DRM_BUFFER_USE_MESA;
attr[7] = EGL_DRM_BUFFER_USE_SHARE_MESA;
attr[8] = EGL_NONE;
img = drv->API.CreateDRMImageMESA(drv, disp, attr);
dri2_surf->egl_front = img;
dri2_surf->khr_front = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR;
bo = gbm_bo_import(&dri2_dpy->gbm_dri->base.base,
GBM_BO_IMPORT_EGL_IMAGE, dri2_surf->khr_front, 0);
if( bo == NULL){
_eglError(EGL_BAD_ALLOC, "gbm_bo_create front buffer");
goto cleanup_surf;
}
dri2_surf->color_buffers[1].bo = bo;
img = drv->API.CreateDRMImageMESA(drv, disp, attr);
dri2_surf->egl_back = img;
dri2_surf->khr_back = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR;
bo = gbm_bo_import(&dri2_dpy->gbm_dri->base.base,
GBM_BO_IMPORT_EGL_IMAGE, dri2_surf->khr_back, 0);
if( bo == NULL){
_eglError(EGL_BAD_ALLOC, "gbm_bo_create back buffer");
goto cleanup_surf;
}
dri2_surf->color_buffers[2].bo = bo;
dri2_surf->dri_drawable =
(*dri2_dpy->dri2->createNewDrawable) (dri2_dpy->dri_screen,
dri2_conf->dri_double_config,
@ -151,6 +189,15 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
return NULL;
}
static EGLImageKHR
dri2_get_fb_image(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, EGLint type)
{
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
return (type == EGL_DRM_BUFFER_FRONT) ? dri2_surf->khr_front:dri2_surf->khr_back;
}
static _EGLSurface *
dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
_EGLConfig *conf, EGLNativeWindowType window,
@ -565,6 +612,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
drv->API.SwapBuffers = dri2_swap_buffers;
drv->API.CreateImageKHR = dri2_drm_create_image_khr;
drv->API.QueryBufferAge = dri2_query_buffer_age;
drv->API.GetImageFB = dri2_get_fb_image;
disp->Extensions.EXT_buffer_age = EGL_TRUE;

View File

@ -1529,6 +1529,22 @@ eglExportDRMImageMESA(EGLDisplay dpy, EGLImageKHR image,
RETURN_EGL_EVAL(disp, ret);
}
EGLImageKHR EGLAPIENTRY
eglGetBufferImage(EGLDisplay dpy, EGLSurface surface, EGLint type)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLDriver *drv;
EGLImageKHR ret;
_EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
if (!disp->Extensions.MESA_drm_image)
RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR);
ret = drv->API.GetImageFB(drv, disp, surface, type);
RETURN_EGL_EVAL(disp, ret);
}
#endif
#ifdef EGL_WL_bind_wayland_display

View File

@ -117,6 +117,7 @@ typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp,
#ifdef EGL_MESA_drm_image
typedef _EGLImage *(*CreateDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attr_list);
typedef EGLBoolean (*ExportDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride);
typedef EGLImageKHR (*GetImageFB_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, EGLint type);
#endif
#ifdef EGL_WL_bind_wayland_display
@ -188,6 +189,7 @@ struct _egl_api
CreateImageKHR_t CreateImageKHR;
DestroyImageKHR_t DestroyImageKHR;
GetImageFB_t GetImageFB;
CreateSyncKHR_t CreateSyncKHR;
DestroySyncKHR_t DestroySyncKHR;

File diff suppressed because one or more lines are too long