Mesa EGL: Kolibri specific code

git-svn-id: svn://kolibrios.org@6114 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-01-31 15:45:42 +00:00
parent 23302af49d
commit d059d77499
8 changed files with 276 additions and 3 deletions

View File

@ -83,9 +83,14 @@ typedef void *EGLImageKHR;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
EGLAPI EGLImageKHR EGLAPIENTRY eglCreatePlanarImage (EGLDisplay dpy, EGLContext ctx, EGLClientBuffer buffer, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyPlanarImage (EGLDisplay dpy, EGLImageKHR image);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEPLANARIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYPLANARIMAGEPROC) (EGLDisplay dpy, EGLImageKHR image);
#endif
#ifndef EGL_KHR_vg_parent_image

View File

@ -9,7 +9,7 @@ CFLAGS = -c $(CFLAGS_OPT)
LDFLAGS = -nostdlib -shared -s --image-base 0 -T $(SRC_DIR)/newlib/dll.lds --out-implib libegl.dll.a -e _DllStartup
INC_EGL:= -I$(SRC_DIR)/newlib/libc/include -I$(SDK_DIR)/includes -I$(SRC_DIR)/Mesa/mesa-9.2.5/include
INC_EGL+= -I$(SRC_DIR)/libdrm -I$(SRC_DIR)/libdrm/include/drm -I./main
INC_EGL+= -I$(SRC_DIR)/libdrm -I$(SRC_DIR)/libdrm/include/drm -I./main -I./wayland
INC_EGL+= -I$(MESA_SRC)/gbm/backends/dri -I$(MESA_SRC)/gbm/main
LIBPATH:= -L$(SDK_DIR)/lib -L/home/autobuild/tools/win32/mingw32/lib

View File

@ -41,6 +41,7 @@
#define EGL_EGLEXT_PROTOTYPES
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <wayland-kos32.h>
#include "eglmode.h"
#include "eglscreen.h"
@ -1227,8 +1228,6 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
return dri2_create_image(disp, dri_image);
}
#ifdef HAVE_WAYLAND_PLATFORM
/* This structure describes how a wl_buffer maps to one or more
* __DRIimages. A wl_drm_buffer stores the wl_drm format code and the
* offsets and strides of the planes in the buffer. This table maps a
@ -1247,6 +1246,7 @@ static const struct wl_drm_components_descriptor {
{ __DRI_IMAGE_COMPONENTS_Y_XUXV, EGL_TEXTURE_Y_XUXV_WL, 2 },
};
#if 0
static _EGLImage *
dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
EGLClientBuffer _buffer,
@ -1691,6 +1691,104 @@ dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
}
#endif
static void
dri2_reference_planar_buffer(struct dri2_egl_display *dri2_dpy, uint32_t name,
struct egl_planar_buffer *buffer)
{
__DRIimage *img;
int i, dri_components = 0;
img = dri2_dpy->image->createImageFromNames(dri2_dpy->dri_screen,
buffer->width,
buffer->height,
buffer->format,
(int*)&name, 1,
buffer->stride,
buffer->offset,
NULL);
if (img == NULL)
return;
dri2_dpy->image->queryImage(img, __DRI_IMAGE_ATTRIB_COMPONENTS, &dri_components);
buffer->driver_format = NULL;
for (i = 0; i < ARRAY_SIZE(wl_drm_components); i++)
if (wl_drm_components[i].dri_components == dri_components)
buffer->driver_format = &wl_drm_components[i];
if (buffer->driver_format == NULL)
dri2_dpy->image->destroyImage(img);
else
buffer->driver_buffer = img;
}
_EGLImage *
dri2_create_planar_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
EGLClientBuffer clbuffer, const EGLint *attrib_list)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
_EGLImageAttribs attrs;
struct egl_planar_buffer *buffer;
EGLint name, err;
name = (EGLint) (uintptr_t) clbuffer;
err = _eglParseImageAttribList(&attrs, dpy, attrib_list);
if (err != EGL_SUCCESS)
return NULL;
if (attrs.Width <= 0 || attrs.Height <= 0 )
{
_eglError(EGL_BAD_PARAMETER,
"bad width, height or stride");
return NULL;
}
switch (attrs.DRMBufferFormatMESA)
{
case WL_DRM_FORMAT_YUV410:
case WL_DRM_FORMAT_YUV411:
case WL_DRM_FORMAT_YUV420:
case WL_DRM_FORMAT_YUV422:
case WL_DRM_FORMAT_YUV444:
case WL_DRM_FORMAT_NV12:
case WL_DRM_FORMAT_NV16:
break;
default:
_eglError(EGL_BAD_PARAMETER, "invalid format");
return NULL;
}
buffer = calloc(1, sizeof *buffer);
if (buffer == NULL) {
_eglError(EGL_BAD_ALLOC, "planar buffer");
return NULL;
}
buffer->width = attrs.Width;
buffer->height = attrs.Height;
buffer->format = attrs.DRMBufferFormatMESA;
buffer->offset[0] = attrs.Plane0_offset;
buffer->stride[0] = attrs.Plane0_pitch;
buffer->offset[1] = attrs.Plane1_offset;
buffer->stride[1] = attrs.Plane1_pitch;
buffer->offset[2] = attrs.Plane2_offset;
buffer->stride[2] = attrs.Plane2_pitch;
dri2_reference_planar_buffer(dri2_dpy, name, buffer);
if (buffer->driver_buffer == NULL)
{
_eglError(EGL_BAD_PARAMETER,"invalid name\n");
free(buffer);
return NULL;
};
return (_EGLImage*)buffer;
}
static void
dri2_unload(_EGLDriver *drv)
{
@ -1766,6 +1864,8 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.API.CreatePlanarImage = dri2_create_planar_image;
dri2_drv->base.API.DestroyPlanarImage = NULL;
dri2_drv->base.API.CreateDRMImageMESA = dri2_create_drm_image_mesa;
dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
#ifdef HAVE_WAYLAND_PLATFORM

View File

@ -950,6 +950,8 @@ eglGetProcAddress(const char *procname)
#endif
{ "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR },
{ "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR },
{ "eglCreatePlanarImage", (_EGLProc) eglCreatePlanarImage },
{ "eglDestroyPlanarImage", (_EGLProc) eglDestroyPlanarImage },
{ "eglCreateSyncKHR", (_EGLProc) eglCreateSyncKHR },
{ "eglDestroySyncKHR", (_EGLProc) eglDestroySyncKHR },
{ "eglClientWaitSyncKHR", (_EGLProc) eglClientWaitSyncKHR },
@ -1352,6 +1354,26 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
RETURN_EGL_EVAL(disp, ret);
}
EGLImageKHR EGLAPIENTRY
eglCreatePlanarImage(EGLDisplay dpy, EGLContext ctx,
EGLClientBuffer buffer, const EGLint *attr_list)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLContext *context = _eglLookupContext(ctx, disp);
_EGLDriver *drv;
_EGLImage *img;
_EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
if (!disp->Extensions.KHR_image_base)
RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR);
if (!context && ctx != EGL_NO_CONTEXT)
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
img = drv->API.CreatePlanarImage(drv,
disp, context, buffer, attr_list);
return (EGLImageKHR)img;
}
EGLBoolean EGLAPIENTRY
eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
@ -1373,6 +1395,24 @@ eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
RETURN_EGL_EVAL(disp, ret);
}
EGLBoolean EGLAPIENTRY
eglDestroyPlanarImage(EGLDisplay dpy, EGLImageKHR image)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLImage *img = (_EGLImage*)image;
_EGLDriver *drv;
EGLBoolean ret;
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
if (!disp->Extensions.KHR_image_base)
RETURN_EGL_EVAL(disp, EGL_FALSE);
if (!img)
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
// ret = drv->API.DestroyImageKHR(drv, disp, img);
RETURN_EGL_EVAL(disp, ret);
}
EGLSyncKHR EGLAPIENTRY
eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)

View File

@ -101,6 +101,8 @@ typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDis
typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
typedef _EGLImage *(*CreatePlanarImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean *(*DestroyPlanarImage_t) (_EGLDriver *drv, EGLDisplay dpy, _EGLImage *image);
typedef _EGLSync *(*CreateSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum type, const EGLint *attrib_list);
@ -189,6 +191,8 @@ struct _egl_api
CreateImageKHR_t CreateImageKHR;
DestroyImageKHR_t DestroyImageKHR;
CreatePlanarImage_t CreatePlanarImage;
DestroyPlanarImage_t DestroyPlanarImage;
GetImageFB_t GetImageFB;
CreateSyncKHR_t CreateSyncKHR;

View File

@ -93,6 +93,30 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
attrs->PlaneWL = val;
break;
case EGL_DMA_BUF_PLANE0_OFFSET_EXT:
attrs->Plane0_offset = val;
break;
case EGL_DMA_BUF_PLANE1_OFFSET_EXT:
attrs->Plane1_offset = val;
break;
case EGL_DMA_BUF_PLANE2_OFFSET_EXT:
attrs->Plane2_offset = val;
break;
case EGL_DMA_BUF_PLANE0_PITCH_EXT:
attrs->Plane0_pitch = val;
break;
case EGL_DMA_BUF_PLANE1_PITCH_EXT:
attrs->Plane1_pitch = val;
break;
case EGL_DMA_BUF_PLANE2_PITCH_EXT:
attrs->Plane2_pitch = val;
break;
default:
/* unknown attrs are ignored */
break;

View File

@ -53,6 +53,15 @@ struct _egl_image_attribs
/* EGL_WL_bind_wayland_display */
EGLint PlaneWL;
/* Kolibri specific */
EGLint Plane0_offset;
EGLint Plane1_offset;
EGLint Plane2_offset;
EGLint Plane0_pitch;
EGLint Plane1_pitch;
EGLint Plane2_pitch;
};
/**

View File

@ -0,0 +1,91 @@
#ifndef WAYLAND_H
#define WAYLAND_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <stdint.h>
#ifndef WL_DRM_FORMAT_ENUM
#define WL_DRM_FORMAT_ENUM
enum wl_drm_format {
WL_DRM_FORMAT_C8 = 0x20203843,
WL_DRM_FORMAT_RGB332 = 0x38424752,
WL_DRM_FORMAT_BGR233 = 0x38524742,
WL_DRM_FORMAT_XRGB4444 = 0x32315258,
WL_DRM_FORMAT_XBGR4444 = 0x32314258,
WL_DRM_FORMAT_RGBX4444 = 0x32315852,
WL_DRM_FORMAT_BGRX4444 = 0x32315842,
WL_DRM_FORMAT_ARGB4444 = 0x32315241,
WL_DRM_FORMAT_ABGR4444 = 0x32314241,
WL_DRM_FORMAT_RGBA4444 = 0x32314152,
WL_DRM_FORMAT_BGRA4444 = 0x32314142,
WL_DRM_FORMAT_XRGB1555 = 0x35315258,
WL_DRM_FORMAT_XBGR1555 = 0x35314258,
WL_DRM_FORMAT_RGBX5551 = 0x35315852,
WL_DRM_FORMAT_BGRX5551 = 0x35315842,
WL_DRM_FORMAT_ARGB1555 = 0x35315241,
WL_DRM_FORMAT_ABGR1555 = 0x35314241,
WL_DRM_FORMAT_RGBA5551 = 0x35314152,
WL_DRM_FORMAT_BGRA5551 = 0x35314142,
WL_DRM_FORMAT_RGB565 = 0x36314752,
WL_DRM_FORMAT_BGR565 = 0x36314742,
WL_DRM_FORMAT_RGB888 = 0x34324752,
WL_DRM_FORMAT_BGR888 = 0x34324742,
WL_DRM_FORMAT_XRGB8888 = 0x34325258,
WL_DRM_FORMAT_XBGR8888 = 0x34324258,
WL_DRM_FORMAT_RGBX8888 = 0x34325852,
WL_DRM_FORMAT_BGRX8888 = 0x34325842,
WL_DRM_FORMAT_ARGB8888 = 0x34325241,
WL_DRM_FORMAT_ABGR8888 = 0x34324241,
WL_DRM_FORMAT_RGBA8888 = 0x34324152,
WL_DRM_FORMAT_BGRA8888 = 0x34324142,
WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
WL_DRM_FORMAT_YUYV = 0x56595559,
WL_DRM_FORMAT_YVYU = 0x55595659,
WL_DRM_FORMAT_UYVY = 0x59565955,
WL_DRM_FORMAT_VYUY = 0x59555956,
WL_DRM_FORMAT_AYUV = 0x56555941,
WL_DRM_FORMAT_NV12 = 0x3231564e,
WL_DRM_FORMAT_NV21 = 0x3132564e,
WL_DRM_FORMAT_NV16 = 0x3631564e,
WL_DRM_FORMAT_NV61 = 0x3136564e,
WL_DRM_FORMAT_YUV410 = 0x39565559,
WL_DRM_FORMAT_YVU410 = 0x39555659,
WL_DRM_FORMAT_YUV411 = 0x31315559,
WL_DRM_FORMAT_YVU411 = 0x31315659,
WL_DRM_FORMAT_YUV420 = 0x32315559,
WL_DRM_FORMAT_YVU420 = 0x32315659,
WL_DRM_FORMAT_YUV422 = 0x36315559,
WL_DRM_FORMAT_YVU422 = 0x36315659,
WL_DRM_FORMAT_YUV444 = 0x34325559,
WL_DRM_FORMAT_YVU444 = 0x34325659,
};
#endif /* WL_DRM_FORMAT_ENUM */
struct egl_planar_buffer
{
uint32_t width;
uint32_t height;
uint32_t format;
const void *driver_format;
uint32_t offset[3];
uint32_t stride[3];
void *driver_buffer;
};
#ifdef __cplusplus
}
#endif
#endif