summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c67
-rw-r--r--src/egl/drivers/glx/egl_glx.c33
-rw-r--r--src/egl/main/Makefile2
-rw-r--r--src/egl/main/eglapi.c52
-rw-r--r--src/egl/main/eglconfig.c225
-rw-r--r--src/egl/main/eglconfig.h133
-rw-r--r--src/egl/main/eglcontext.c11
-rw-r--r--src/egl/main/egldisplay.c2
-rw-r--r--src/egl/main/egldriver.c1
-rw-r--r--src/egl/main/eglsurface.c14
10 files changed, 301 insertions, 239 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 856029091a2..d17a2ab88c2 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -292,7 +292,7 @@ dri2_process_buffers(struct dri2_egl_surface *dri2_surf,
struct dri2_egl_display *dri2_dpy =
dri2_egl_display(dri2_surf->base.Resource.Display);
xcb_rectangle_t rectangle;
- int i;
+ unsigned i;
dri2_surf->buffer_count = count;
dri2_surf->have_fake_front = 0;
@@ -339,6 +339,8 @@ dri2_get_buffers(__DRIdrawable * driDrawable,
xcb_dri2_get_buffers_reply_t *reply;
xcb_dri2_get_buffers_cookie_t cookie;
+ (void) driDrawable;
+
cookie = xcb_dri2_get_buffers_unchecked (dri2_dpy->conn,
dri2_surf->drawable,
count, count, attachments);
@@ -360,23 +362,28 @@ dri2_get_buffers(__DRIdrawable * driDrawable,
static void
dri2_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
+ (void) driDrawable;
+
/* FIXME: Does EGL support front buffer rendering at all? */
#if 0
struct dri2_egl_surface *dri2_surf = loaderPrivate;
dri2WaitGL(dri2_surf);
+#else
+ (void) loaderPrivate;
#endif
}
static __DRIimage *
-dri2_lookup_egl_image(__DRIcontext *context, void *image, void *data)
+dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
{
- struct dri2_egl_context *dri2_ctx = data;
- _EGLDisplay *disp = dri2_ctx->base.Resource.Display;
+ _EGLDisplay *disp = data;
struct dri2_egl_image *dri2_img;
_EGLImage *img;
+ (void) screen;
+
img = _eglLookupImage(image, disp);
if (img == NULL) {
_eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image");
@@ -407,6 +414,8 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
xcb_dri2_get_buffers_with_format_cookie_t cookie;
xcb_dri2_attach_format_t *format_attachments;
+ (void) driDrawable;
+
format_attachments = (xcb_dri2_attach_format_t *) attachments;
cookie = xcb_dri2_get_buffers_with_format_unchecked (dri2_dpy->conn,
dri2_surf->drawable,
@@ -440,14 +449,14 @@ struct dri2_extension_match {
static struct dri2_extension_match dri2_driver_extensions[] = {
{ __DRI_CORE, 1, offsetof(struct dri2_egl_display, core) },
{ __DRI_DRI2, 1, offsetof(struct dri2_egl_display, dri2) },
- { NULL }
+ { NULL, 0, 0 }
};
static struct dri2_extension_match dri2_core_extensions[] = {
{ __DRI2_FLUSH, 1, offsetof(struct dri2_egl_display, flush) },
{ __DRI_TEX_BUFFER, 2, offsetof(struct dri2_egl_display, tex_buffer) },
{ __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
- { NULL }
+ { NULL, 0, 0 }
};
static EGLBoolean
@@ -728,7 +737,7 @@ dri2_create_screen(_EGLDisplay *disp)
dri2_dpy = disp->DriverData;
dri2_dpy->dri_screen =
dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions,
- &dri2_dpy->driver_configs, dri2_dpy);
+ &dri2_dpy->driver_configs, disp);
if (dri2_dpy->dri_screen == NULL) {
_eglLog(_EGL_WARNING, "DRI2: failed to create dri screen");
@@ -772,6 +781,8 @@ dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp,
{
struct dri2_egl_display *dri2_dpy;
+ (void) drv;
+
dri2_dpy = malloc(sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
@@ -1075,6 +1086,8 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
const __DRIconfig *dri_config;
int api;
+ (void) drv;
+
dri2_ctx = malloc(sizeof *dri2_ctx);
if (!dri2_ctx) {
_eglError(EGL_BAD_ALLOC, "eglCreateContext");
@@ -1146,6 +1159,8 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+ (void) drv;
+
if (_eglIsSurfaceBound(surf))
return EGL_TRUE;
@@ -1221,6 +1236,8 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
xcb_screen_iterator_t s;
xcb_generic_error_t *error;
+ (void) drv;
+
dri2_surf = malloc(sizeof *dri2_surf);
if (!dri2_surf) {
_eglError(EGL_BAD_ALLOC, "dri2_create_surface");
@@ -1369,7 +1386,7 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw,
xcb_rectangle_t rectangles[16];
int i;
- if (numRects > ARRAY_SIZE(rectangles))
+ if (numRects > (int)ARRAY_SIZE(rectangles))
return dri2_copy_region(drv, disp, draw, dri2_surf->region);
/* FIXME: Invert y here? */
@@ -1394,6 +1411,8 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw,
static _EGLProc
dri2_get_proc_address(_EGLDriver *drv, const char *procname)
{
+ (void) drv;
+
/* FIXME: Do we need to support lookup of EGL symbols too? */
return (_EGLProc) _glapi_get_proc_address(procname);
@@ -1405,6 +1424,8 @@ dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(ctx->DrawSurface);
+ (void) drv;
+
/* FIXME: If EGL allows frontbuffer rendering for window surfaces,
* we need to copy fake to real here.*/
@@ -1416,6 +1437,9 @@ dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
static EGLBoolean
dri2_wait_native(_EGLDriver *drv, _EGLDisplay *disp, EGLint engine)
{
+ (void) drv;
+ (void) disp;
+
if (engine != EGL_CORE_NATIVE_ENGINE)
return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
/* glXWaitX(); */
@@ -1438,6 +1462,8 @@ dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
xcb_gcontext_t gc;
+ (void) drv;
+
(*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
gc = xcb_generate_id(dri2_dpy->conn);
@@ -1501,6 +1527,11 @@ static EGLBoolean
dri2_release_tex_image(_EGLDriver *drv,
_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
{
+ (void) drv;
+ (void) disp;
+ (void) surf;
+ (void) buffer;
+
return EGL_TRUE;
}
@@ -1509,7 +1540,6 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
EGLClientBuffer buffer, const EGLint *attr_list)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
struct dri2_egl_image *dri2_img;
unsigned int attachments[1];
xcb_drawable_t drawable;
@@ -1521,6 +1551,8 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
xcb_generic_error_t *error;
int stride, format;
+ (void) ctx;
+
drawable = (xcb_drawable_t) buffer;
xcb_dri2_create_drawable (dri2_dpy->conn, drawable);
attachments[0] = XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT;
@@ -1577,7 +1609,7 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
stride = buffers[0].pitch / buffers[0].cpp;
dri2_img->dri_image =
- dri2_dpy->image->createImageFromName(dri2_ctx->dri_context,
+ dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
buffers_reply->width,
buffers_reply->height,
format,
@@ -1628,10 +1660,11 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
EGLClientBuffer buffer, const EGLint *attr_list)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
struct dri2_egl_image *dri2_img;
EGLint width, height, format, name, stride, pitch, i, err;
+ (void) ctx;
+
name = (EGLint) buffer;
err = EGL_SUCCESS;
@@ -1697,7 +1730,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
}
dri2_img->dri_image =
- dri2_dpy->image->createImageFromName(dri2_ctx->dri_context,
+ dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
width,
height,
format,
@@ -1718,6 +1751,8 @@ dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
_EGLContext *ctx, EGLenum target,
EGLClientBuffer buffer, const EGLint *attr_list)
{
+ (void) drv;
+
switch (target) {
case EGL_NATIVE_PIXMAP_KHR:
return dri2_create_image_khr_pixmap(disp, ctx, buffer, attr_list);
@@ -1737,6 +1772,8 @@ dri2_destroy_image_khr(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image)
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(image);
+ (void) drv;
+
dri2_dpy->image->destroyImage(dri2_img->dri_image);
free(dri2_img);
@@ -1753,6 +1790,8 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp,
unsigned int use, dri_use, valid_mask;
EGLint err = EGL_SUCCESS;
+ (void) drv;
+
dri2_img = malloc(sizeof *dri2_img);
if (!dri2_img) {
_eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
@@ -1853,6 +1892,8 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img,
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(img);
+ (void) drv;
+
if (name && !dri2_dpy->image->queryImage(dri2_img->dri_image,
__DRI_IMAGE_ATTRIB_NAME, name)) {
_eglError(EGL_BAD_ALLOC, "dri2_export_drm_image_mesa");
@@ -1879,6 +1920,8 @@ _eglMain(const char *args)
{
struct dri2_egl_driver *dri2_drv;
+ (void) args;
+
dri2_drv = malloc(sizeof *dri2_drv);
if (!dri2_drv)
return NULL;
diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index b2076e2e3fd..8a46f9c4a61 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -162,7 +162,8 @@ static EGLBoolean
convert_fbconfig(Display *dpy, GLXFBConfig fbconfig,
struct GLX_egl_config *GLX_conf)
{
- int err = 0, attr, egl_attr, val, i;
+ int err = 0, attr, egl_attr, val;
+ unsigned i;
EGLint conformant, config_caveat, surface_type;
for (i = 0; i < ARRAY_SIZE(fbconfig_attributes); i++) {
@@ -243,7 +244,8 @@ static EGLBoolean
convert_visual(Display *dpy, XVisualInfo *vinfo,
struct GLX_egl_config *GLX_conf)
{
- int err, attr, egl_attr, val, i;
+ int err, attr, egl_attr, val;
+ unsigned i;
EGLint conformant, config_caveat, surface_type;
/* the visual must support OpenGL */
@@ -457,6 +459,8 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp,
{
struct GLX_egl_display *GLX_dpy;
+ (void) drv;
+
if (disp->Platform != _EGL_PLATFORM_X11)
return EGL_FALSE;
@@ -541,6 +545,8 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
struct GLX_egl_context *GLX_ctx_shared = GLX_egl_context(share_list);
+ (void) drv;
+
if (!GLX_ctx) {
_eglError(EGL_BAD_ALLOC, "eglCreateContext");
return NULL;
@@ -604,6 +610,8 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
GLXContext cctx;
EGLBoolean ret = EGL_FALSE;
+ (void) drv;
+
/* bind the new context and return the "orphaned" one */
if (!_eglBindContext(&ctx, &dsurf, &rsurf))
return EGL_FALSE;
@@ -656,6 +664,8 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp,
struct GLX_egl_surface *GLX_surf;
uint width, height;
+ (void) drv;
+
GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
if (!GLX_surf) {
_eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface");
@@ -702,6 +712,8 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp,
struct GLX_egl_surface *GLX_surf;
uint width, height;
+ (void) drv;
+
GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
if (!GLX_surf) {
_eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface");
@@ -762,6 +774,8 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
int attribs[5];
int i;
+ (void) drv;
+
GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
if (!GLX_surf) {
_eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface");
@@ -820,6 +834,8 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
static EGLBoolean
GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
{
+ (void) drv;
+
if (!_eglIsSurfaceBound(surf))
destroy_surface(disp, surf);
@@ -833,6 +849,8 @@ GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
struct GLX_egl_surface *GLX_surf = GLX_egl_surface(draw);
+ (void) drv;
+
glXSwapBuffers(GLX_dpy->dpy, GLX_surf->glx_drawable);
return EGL_TRUE;
@@ -844,12 +862,18 @@ GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
static _EGLProc
GLX_eglGetProcAddress(_EGLDriver *drv, const char *procname)
{
+ (void) drv;
+
return (_EGLProc) glXGetProcAddress((const GLubyte *) procname);
}
static EGLBoolean
GLX_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
{
+ (void) drv;
+ (void) dpy;
+ (void) ctx;
+
glXWaitGL();
return EGL_TRUE;
}
@@ -857,6 +881,9 @@ GLX_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
static EGLBoolean
GLX_eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
{
+ (void) drv;
+ (void) dpy;
+
if (engine != EGL_CORE_NATIVE_ENGINE)
return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
glXWaitX();
@@ -880,6 +907,8 @@ _eglMain(const char *args)
{
struct GLX_egl_driver *GLX_drv = CALLOC_STRUCT(GLX_egl_driver);
+ (void) args;
+
if (!GLX_drv)
return NULL;
diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile
index baee1a2f9dd..19085a31f18 100644
--- a/src/egl/main/Makefile
+++ b/src/egl/main/Makefile
@@ -57,7 +57,7 @@ EGL_NATIVE_PLATFORM=_EGL_INVALID_PLATFORM
ifeq ($(firstword $(EGL_PLATFORMS)),x11)
EGL_NATIVE_PLATFORM=_EGL_PLATFORM_X11
endif
-ifeq ($(firstword $(EGL_PLATFORMS)),kms)
+ifeq ($(firstword $(EGL_PLATFORMS)),drm)
EGL_NATIVE_PLATFORM=_EGL_PLATFORM_DRM
endif
ifeq ($(firstword $(EGL_PLATFORMS)),fbdev)
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 829d700b24f..e8f856f6beb 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -402,10 +402,15 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
_EGLContext *context;
EGLContext ret;
- if (config)
- _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT, drv);
- else
- _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv);
+ _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv);
+
+ if (!config) {
+ /* config may be NULL if surfaceless */
+ if (!disp->Extensions.KHR_surfaceless_gles1 &&
+ !disp->Extensions.KHR_surfaceless_gles2 &&
+ !disp->Extensions.KHR_surfaceless_opengl)
+ RETURN_EGL_ERROR(disp, EGL_BAD_CONFIG, EGL_NO_CONTEXT);
+ }
if (!share && share_list != EGL_NO_CONTEXT)
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
@@ -459,9 +464,19 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
if (!context && ctx != EGL_NO_CONTEXT)
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
- if ((!draw_surf && draw != EGL_NO_SURFACE) ||
- (!read_surf && read != EGL_NO_SURFACE))
- RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+ if (!draw_surf || !read_surf) {
+ /* surfaces may be NULL if surfaceless */
+ if (!disp->Extensions.KHR_surfaceless_gles1 &&
+ !disp->Extensions.KHR_surfaceless_gles2 &&
+ !disp->Extensions.KHR_surfaceless_opengl)
+ RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+
+ if ((!draw_surf && draw != EGL_NO_SURFACE) ||
+ (!read_surf && read != EGL_NO_SURFACE))
+ RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+ if (draw_surf || read_surf)
+ RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE);
+ }
ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context);
@@ -1276,6 +1291,8 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
EGLImageKHR ret;
_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);
@@ -1296,6 +1313,8 @@ eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
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);
@@ -1321,6 +1340,8 @@ eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
EGLSyncKHR ret;
_EGL_CHECK_DISPLAY(disp, EGL_NO_SYNC_KHR, drv);
+ if (!disp->Extensions.KHR_reusable_sync)
+ RETURN_EGL_EVAL(disp, EGL_NO_SYNC_KHR);
sync = drv->API.CreateSyncKHR(drv, disp, type, attrib_list);
ret = (sync) ? _eglLinkSync(sync, disp) : EGL_NO_SYNC_KHR;
@@ -1338,6 +1359,8 @@ eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
EGLBoolean ret;
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
+ assert(disp->Extensions.KHR_reusable_sync);
+
_eglUnlinkSync(s);
ret = drv->API.DestroySyncKHR(drv, disp, s);
@@ -1354,6 +1377,7 @@ eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR t
EGLint ret;
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
+ assert(disp->Extensions.KHR_reusable_sync);
ret = drv->API.ClientWaitSyncKHR(drv, disp, s, flags, timeout);
RETURN_EGL_EVAL(disp, ret);
@@ -1369,6 +1393,7 @@ eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
EGLBoolean ret;
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
+ assert(disp->Extensions.KHR_reusable_sync);
ret = drv->API.SignalSyncKHR(drv, disp, s, mode);
RETURN_EGL_EVAL(disp, ret);
@@ -1384,6 +1409,7 @@ eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *v
EGLBoolean ret;
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
+ assert(disp->Extensions.KHR_reusable_sync);
ret = drv->API.GetSyncAttribKHR(drv, disp, s, attribute, value);
RETURN_EGL_EVAL(disp, ret);
@@ -1407,14 +1433,14 @@ eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface,
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
+ if (!disp->Extensions.NOK_swap_region)
+ RETURN_EGL_EVAL(disp, EGL_FALSE);
+
/* surface must be bound to current context in EGL 1.4 */
if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
- if (drv->API.SwapBuffersRegionNOK)
- ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects);
- else
- ret = drv->API.SwapBuffers(drv, disp, surf);
+ ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects);
RETURN_EGL_EVAL(disp, ret);
}
@@ -1433,6 +1459,8 @@ eglCreateDRMImageMESA(EGLDisplay dpy, const EGLint *attr_list)
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);
img = drv->API.CreateDRMImageMESA(drv, disp, attr_list);
ret = (img) ? _eglLinkImage(img, disp) : EGL_NO_IMAGE_KHR;
@@ -1450,6 +1478,8 @@ eglExportDRMImageMESA(EGLDisplay dpy, EGLImageKHR image,
EGLBoolean ret;
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+ assert(disp->Extensions.MESA_drm_image);
+
if (!img)
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 01e7144d40a..4d313a9bb5b 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -24,20 +24,18 @@
* IDs are from 1 to N respectively.
*/
void
-_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id)
+_eglInitConfig(_EGLConfig *conf, _EGLDisplay *dpy, EGLint id)
{
- memset(config, 0, sizeof(*config));
+ memset(conf, 0, sizeof(*conf));
- config->Display = dpy;
+ conf->Display = dpy;
/* some attributes take non-zero default values */
- SET_CONFIG_ATTRIB(config, EGL_CONFIG_ID, id);
- SET_CONFIG_ATTRIB(config, EGL_CONFIG_CAVEAT, EGL_NONE);
- SET_CONFIG_ATTRIB(config, EGL_TRANSPARENT_TYPE, EGL_NONE);
- SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_TYPE, EGL_NONE);
-#ifdef EGL_VERSION_1_2
- SET_CONFIG_ATTRIB(config, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
-#endif /* EGL_VERSION_1_2 */
+ conf->ConfigID = id;
+ conf->ConfigCaveat = EGL_NONE;
+ conf->TransparentType = EGL_NONE;
+ conf->NativeVisualType = EGL_NONE;
+ conf->ColorBufferType = EGL_RGB_BUFFER;
}
@@ -51,7 +49,7 @@ EGLConfig
_eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf)
{
/* sanity check */
- assert(GET_CONFIG_ATTRIB(conf, EGL_CONFIG_ID) > 0);
+ assert(conf->ConfigID > 0);
if (!dpy->Configs) {
dpy->Configs = _eglCreateArray("Config", 16);
@@ -104,6 +102,7 @@ static const struct {
EGLint default_value;
} _eglValidationTable[] =
{
+ /* core */
{ EGL_BUFFER_SIZE, ATTRIB_TYPE_INTEGER,
ATTRIB_CRITERION_ATLEAST,
0 },
@@ -200,22 +199,13 @@ static const struct {
{ EGL_TRANSPARENT_BLUE_VALUE, ATTRIB_TYPE_INTEGER,
ATTRIB_CRITERION_EXACT,
EGL_DONT_CARE },
- /* these are not real attributes */
{ EGL_MATCH_NATIVE_PIXMAP, ATTRIB_TYPE_PSEUDO,
ATTRIB_CRITERION_SPECIAL,
EGL_NONE },
- /* there is a gap before EGL_SAMPLES */
- { 0x3030, ATTRIB_TYPE_PSEUDO,
- ATTRIB_CRITERION_IGNORE,
- 0 },
- { EGL_NONE, ATTRIB_TYPE_PSEUDO,
- ATTRIB_CRITERION_IGNORE,
- 0 },
-
+ /* extensions */
{ EGL_Y_INVERTED_NOK, ATTRIB_TYPE_BOOLEAN,
ATTRIB_CRITERION_EXACT,
- EGL_DONT_CARE },
-
+ EGL_DONT_CARE }
};
@@ -232,18 +222,13 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
{
EGLint i, attr, val;
EGLBoolean valid = EGL_TRUE;
- EGLint red_size = 0, green_size = 0, blue_size = 0, luminance_size = 0;
- EGLint alpha_size = 0, buffer_size = 0;
-
- /* all attributes should have been listed */
- assert(ARRAY_SIZE(_eglValidationTable) == _EGL_CONFIG_NUM_ATTRIBS);
/* check attributes by their types */
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) {
EGLint mask;
attr = _eglValidationTable[i].attr;
- val = GET_CONFIG_ATTRIB(conf, attr);
+ val = _eglGetConfigKey(conf, attr);
switch (_eglValidationTable[i].type) {
case ATTRIB_TYPE_INTEGER:
@@ -255,30 +240,14 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
break;
case EGL_SAMPLE_BUFFERS:
/* there can be at most 1 sample buffer */
- if (val > 1)
+ if (val > 1 || val < 0)
valid = EGL_FALSE;
break;
- case EGL_RED_SIZE:
- red_size = val;
- break;
- case EGL_GREEN_SIZE:
- green_size = val;
- break;
- case EGL_BLUE_SIZE:
- blue_size = val;
- break;
- case EGL_LUMINANCE_SIZE:
- luminance_size = val;
- break;
- case EGL_ALPHA_SIZE:
- alpha_size = val;
- break;
- case EGL_BUFFER_SIZE:
- buffer_size = val;
+ default:
+ if (val < 0)
+ valid = EGL_FALSE;
break;
}
- if (val < 0)
- valid = EGL_FALSE;
break;
case ATTRIB_TYPE_BOOLEAN:
if (val != EGL_TRUE && val != EGL_FALSE)
@@ -366,17 +335,18 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
/* now check for conflicting attribute values */
- switch (GET_CONFIG_ATTRIB(conf, EGL_COLOR_BUFFER_TYPE)) {
+ switch (conf->ColorBufferType) {
case EGL_RGB_BUFFER:
- if (luminance_size)
+ if (conf->LuminanceSize)
valid = EGL_FALSE;
- if (red_size + green_size + blue_size + alpha_size != buffer_size)
+ if (conf->RedSize + conf->GreenSize +
+ conf->BlueSize + conf->AlphaSize != conf->BufferSize)
valid = EGL_FALSE;
break;
case EGL_LUMINANCE_BUFFER:
- if (red_size || green_size || blue_size)
+ if (conf->RedSize || conf->GreenSize || conf->BlueSize)
valid = EGL_FALSE;
- if (luminance_size + alpha_size != buffer_size)
+ if (conf->LuminanceSize + conf->AlphaSize != conf->BufferSize)
valid = EGL_FALSE;
break;
}
@@ -385,23 +355,19 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
return EGL_FALSE;
}
- val = GET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS);
- if (!val && GET_CONFIG_ATTRIB(conf, EGL_SAMPLES))
+ if (!conf->SampleBuffers && conf->Samples)
valid = EGL_FALSE;
if (!valid) {
_eglLog(_EGL_DEBUG, "conflicting samples and sample buffers");
return EGL_FALSE;
}
- val = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE);
- if (!(val & EGL_WINDOW_BIT)) {
- if (GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID) != 0 ||
- GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE) != EGL_NONE)
+ if (!(conf->SurfaceType & EGL_WINDOW_BIT)) {
+ if (conf->NativeVisualID != 0 || conf->NativeVisualType != EGL_NONE)
valid = EGL_FALSE;
}
- if (!(val & EGL_PBUFFER_BIT)) {
- if (GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB) ||
- GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA))
+ if (!(conf->SurfaceType & EGL_PBUFFER_BIT)) {
+ if (conf->BindToTextureRGB || conf->BindToTextureRGBA)
valid = EGL_FALSE;
}
if (!valid) {
@@ -433,11 +399,11 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria)
continue;
attr = _eglValidationTable[i].attr;
- cmp = GET_CONFIG_ATTRIB(criteria, attr);
+ cmp = _eglGetConfigKey(criteria, attr);
if (cmp == EGL_DONT_CARE)
continue;
- val = GET_CONFIG_ATTRIB(conf, attr);
+ val = _eglGetConfigKey(conf, attr);
switch (_eglValidationTable[i].criterion) {
case ATTRIB_CRITERION_EXACT:
if (val != cmp)
@@ -478,16 +444,11 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria)
static INLINE EGLBoolean
_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
{
- if (_eglIndexConfig(conf, attr) < 0)
+ if (_eglOffsetOfConfig(attr) < 0)
return EGL_FALSE;
- /* there are some holes in the range */
switch (attr) {
- case 0x3030 /* a gap before EGL_SAMPLES */:
- case EGL_NONE:
-#ifdef EGL_VERSION_1_4
case EGL_MATCH_NATIVE_PIXMAP:
-#endif
return EGL_FALSE;
case EGL_Y_INVERTED_NOK:
return conf->Display->Extensions.NOK_texture_from_pixmap;
@@ -506,15 +467,12 @@ EGLBoolean
_eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list)
{
EGLint attr, val, i;
- EGLint config_id = 0, level = 0;
- EGLBoolean has_native_visual_type = EGL_FALSE;
- EGLBoolean has_transparent_color = EGL_FALSE;
/* reset to default values */
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) {
attr = _eglValidationTable[i].attr;
val = _eglValidationTable[i].default_value;
- SET_CONFIG_ATTRIB(conf, attr, val);
+ _eglSetConfigKey(conf, attr, val);
}
/* parse the list */
@@ -524,59 +482,33 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list)
if (!_eglIsConfigAttribValid(conf, attr))
return EGL_FALSE;
-
- SET_CONFIG_ATTRIB(conf, attr, val);
- /* rememeber some attributes for post-processing */
- switch (attr) {
- case EGL_CONFIG_ID:
- config_id = val;
- break;
- case EGL_LEVEL:
- level = val;
- break;
- case EGL_NATIVE_VISUAL_TYPE:
- has_native_visual_type = EGL_TRUE;
- break;
- case EGL_TRANSPARENT_RED_VALUE:
- case EGL_TRANSPARENT_GREEN_VALUE:
- case EGL_TRANSPARENT_BLUE_VALUE:
- has_transparent_color = EGL_TRUE;
- break;
- default:
- break;
- }
+ _eglSetConfigKey(conf, attr, val);
}
if (!_eglValidateConfig(conf, EGL_TRUE))
return EGL_FALSE;
/* the spec says that EGL_LEVEL cannot be EGL_DONT_CARE */
- if (level == EGL_DONT_CARE)
+ if (conf->Level == EGL_DONT_CARE)
return EGL_FALSE;
/* ignore other attributes when EGL_CONFIG_ID is given */
- if (config_id > 0) {
- _eglResetConfigKeys(conf, EGL_DONT_CARE);
- SET_CONFIG_ATTRIB(conf, EGL_CONFIG_ID, config_id);
+ if (conf->ConfigID > 0) {
+ for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) {
+ attr = _eglValidationTable[i].attr;
+ if (attr != EGL_CONFIG_ID)
+ _eglSetConfigKey(conf, attr, EGL_DONT_CARE);
+ }
}
else {
- if (has_native_visual_type) {
- val = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE);
- if (!(val & EGL_WINDOW_BIT))
- SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE);
- }
+ if (!(conf->SurfaceType & EGL_WINDOW_BIT))
+ conf->NativeVisualType = EGL_DONT_CARE;
- if (has_transparent_color) {
- val = GET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE);
- if (val == EGL_NONE) {
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_RED_VALUE,
- EGL_DONT_CARE);
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_GREEN_VALUE,
- EGL_DONT_CARE);
- SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_BLUE_VALUE,
- EGL_DONT_CARE);
- }
+ if (conf->TransparentType == EGL_NONE) {
+ conf->TransparentRedValue = EGL_DONT_CARE;
+ conf->TransparentGreenValue = EGL_DONT_CARE;
+ conf->TransparentBlueValue = EGL_DONT_CARE;
}
}
@@ -610,7 +542,6 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
EGL_ALPHA_MASK_SIZE,
};
EGLint val1, val2;
- EGLBoolean rgb_buffer;
EGLint i;
if (conf1 == conf2)
@@ -619,44 +550,41 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
/* the enum values have the desired ordering */
assert(EGL_NONE < EGL_SLOW_CONFIG);
assert(EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG);
- val1 = GET_CONFIG_ATTRIB(conf1, EGL_CONFIG_CAVEAT);
- val2 = GET_CONFIG_ATTRIB(conf2, EGL_CONFIG_CAVEAT);
- if (val1 != val2)
- return (val1 - val2);
+ val1 = conf1->ConfigCaveat - conf2->ConfigCaveat;
+ if (val1)
+ return val1;
/* the enum values have the desired ordering */
assert(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER);
- val1 = GET_CONFIG_ATTRIB(conf1, EGL_COLOR_BUFFER_TYPE);
- val2 = GET_CONFIG_ATTRIB(conf2, EGL_COLOR_BUFFER_TYPE);
- if (val1 != val2)
- return (val1 - val2);
- rgb_buffer = (val1 == EGL_RGB_BUFFER);
+ val1 = conf1->ColorBufferType - conf2->ColorBufferType;
+ if (val1)
+ return val1;
if (criteria) {
val1 = val2 = 0;
- if (rgb_buffer) {
- if (GET_CONFIG_ATTRIB(criteria, EGL_RED_SIZE) > 0) {
- val1 += GET_CONFIG_ATTRIB(conf1, EGL_RED_SIZE);
- val2 += GET_CONFIG_ATTRIB(conf2, EGL_RED_SIZE);
+ if (conf1->ColorBufferType == EGL_RGB_BUFFER) {
+ if (criteria->RedSize > 0) {
+ val1 += conf1->RedSize;
+ val2 += conf2->RedSize;
}
- if (GET_CONFIG_ATTRIB(criteria, EGL_GREEN_SIZE) > 0) {
- val1 += GET_CONFIG_ATTRIB(conf1, EGL_GREEN_SIZE);
- val2 += GET_CONFIG_ATTRIB(conf2, EGL_GREEN_SIZE);
+ if (criteria->GreenSize > 0) {
+ val1 += conf1->GreenSize;
+ val2 += conf2->GreenSize;
}
- if (GET_CONFIG_ATTRIB(criteria, EGL_BLUE_SIZE) > 0) {
- val1 += GET_CONFIG_ATTRIB(conf1, EGL_BLUE_SIZE);
- val2 += GET_CONFIG_ATTRIB(conf2, EGL_BLUE_SIZE);
+ if (criteria->BlueSize > 0) {
+ val1 += conf1->BlueSize;
+ val2 += conf2->BlueSize;
}
}
else {
- if (GET_CONFIG_ATTRIB(criteria, EGL_LUMINANCE_SIZE) > 0) {
- val1 += GET_CONFIG_ATTRIB(conf1, EGL_LUMINANCE_SIZE);
- val2 += GET_CONFIG_ATTRIB(conf2, EGL_LUMINANCE_SIZE);
+ if (criteria->LuminanceSize > 0) {
+ val1 += conf1->LuminanceSize;
+ val2 += conf2->LuminanceSize;
}
}
- if (GET_CONFIG_ATTRIB(criteria, EGL_ALPHA_SIZE) > 0) {
- val1 += GET_CONFIG_ATTRIB(conf1, EGL_ALPHA_SIZE);
- val2 += GET_CONFIG_ATTRIB(conf2, EGL_ALPHA_SIZE);
+ if (criteria->AlphaSize > 0) {
+ val1 += conf1->AlphaSize;
+ val2 += conf2->AlphaSize;
}
}
else {
@@ -669,24 +597,15 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
return (val2 - val1);
for (i = 0; i < ARRAY_SIZE(compare_attribs); i++) {
- val1 = GET_CONFIG_ATTRIB(conf1, compare_attribs[i]);
- val2 = GET_CONFIG_ATTRIB(conf2, compare_attribs[i]);
+ val1 = _eglGetConfigKey(conf1, compare_attribs[i]);
+ val2 = _eglGetConfigKey(conf2, compare_attribs[i]);
if (val1 != val2)
return (val1 - val2);
}
/* EGL_NATIVE_VISUAL_TYPE cannot be compared here */
- if (compare_id) {
- val1 = GET_CONFIG_ATTRIB(conf1, EGL_CONFIG_ID);
- val2 = GET_CONFIG_ATTRIB(conf2, EGL_CONFIG_ID);
- assert(val1 != val2);
- }
- else {
- val1 = val2 = 0;
- }
-
- return (val1 - val2);
+ return (compare_id) ? (conf1->ConfigID - conf2->ConfigID) : 0;
}
@@ -802,7 +721,7 @@ _eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
if (!value)
return _eglError(EGL_BAD_PARAMETER, "eglGetConfigAttrib");
- *value = GET_CONFIG_ATTRIB(conf, attribute);
+ *value = _eglGetConfigKey(conf, attribute);
return EGL_TRUE;
}
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h
index 0ad58cf473d..0b6a0c27521 100644
--- a/src/egl/main/eglconfig.h
+++ b/src/egl/main/eglconfig.h
@@ -6,26 +6,49 @@
#include "egltypedefs.h"
-#define _EGL_CONFIG_FIRST_ATTRIB EGL_BUFFER_SIZE
-#define _EGL_CONFIG_LAST_ATTRIB EGL_CONFORMANT
-#define _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS \
- (_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1)
-
-/* Attributes outside the contiguous block:
- *
- * EGL_Y_INVERTED_NOK
- */
-#define _EGL_CONFIG_FIRST_EXTRA_ATTRIB _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS
-#define _EGL_CONFIG_NUM_EXTRA_ATTRIBS 1
-
-#define _EGL_CONFIG_NUM_ATTRIBS \
- _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS + _EGL_CONFIG_NUM_EXTRA_ATTRIBS
-
-
+/* update _eglValidationTable and _eglOffsetOfConfig before updating this
+ * struct */
struct _egl_config
{
_EGLDisplay *Display;
- EGLint Storage[_EGL_CONFIG_NUM_ATTRIBS];
+
+ /* core */
+ EGLint BufferSize;
+ EGLint AlphaSize;
+ EGLint BlueSize;
+ EGLint GreenSize;
+ EGLint RedSize;
+ EGLint DepthSize;
+ EGLint StencilSize;
+ EGLint ConfigCaveat;
+ EGLint ConfigID;
+ EGLint Level;
+ EGLint MaxPbufferHeight;
+ EGLint MaxPbufferPixels;
+ EGLint MaxPbufferWidth;
+ EGLint NativeRenderable;
+ EGLint NativeVisualID;
+ EGLint NativeVisualType;
+ EGLint Samples;
+ EGLint SampleBuffers;
+ EGLint SurfaceType;
+ EGLint TransparentType;
+ EGLint TransparentBlueValue;
+ EGLint TransparentGreenValue;
+ EGLint TransparentRedValue;
+ EGLint BindToTextureRGB;
+ EGLint BindToTextureRGBA;
+ EGLint MinSwapInterval;
+ EGLint MaxSwapInterval;
+ EGLint LuminanceSize;
+ EGLint AlphaMaskSize;
+ EGLint ColorBufferType;
+ EGLint RenderableType;
+ EGLint MatchNativePixmap;
+ EGLint Conformant;
+
+ /* extensions */
+ EGLint YInvertedNOK;
};
@@ -37,20 +60,50 @@ struct _egl_config
/**
- * Given a key, return an index into the storage of the config.
- * Return -1 if the key is invalid.
+ * Map an EGL attribute enum to the offset of the member in _EGLConfig.
*/
static INLINE EGLint
-_eglIndexConfig(const _EGLConfig *conf, EGLint key)
+_eglOffsetOfConfig(EGLint attr)
{
- (void) conf;
- if (key >= _EGL_CONFIG_FIRST_ATTRIB &&
- key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS)
- return key - _EGL_CONFIG_FIRST_ATTRIB;
-
- switch (key) {
- case EGL_Y_INVERTED_NOK:
- return _EGL_CONFIG_FIRST_EXTRA_ATTRIB;
+ switch (attr) {
+#define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
+ /* core */
+ ATTRIB_MAP(EGL_BUFFER_SIZE, BufferSize);
+ ATTRIB_MAP(EGL_ALPHA_SIZE, AlphaSize);
+ ATTRIB_MAP(EGL_BLUE_SIZE, BlueSize);
+ ATTRIB_MAP(EGL_GREEN_SIZE, GreenSize);
+ ATTRIB_MAP(EGL_RED_SIZE, RedSize);
+ ATTRIB_MAP(EGL_DEPTH_SIZE, DepthSize);
+ ATTRIB_MAP(EGL_STENCIL_SIZE, StencilSize);
+ ATTRIB_MAP(EGL_CONFIG_CAVEAT, ConfigCaveat);
+ ATTRIB_MAP(EGL_CONFIG_ID, ConfigID);
+ ATTRIB_MAP(EGL_LEVEL, Level);
+ ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT, MaxPbufferHeight);
+ ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS, MaxPbufferPixels);
+ ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH, MaxPbufferWidth);
+ ATTRIB_MAP(EGL_NATIVE_RENDERABLE, NativeRenderable);
+ ATTRIB_MAP(EGL_NATIVE_VISUAL_ID, NativeVisualID);
+ ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE, NativeVisualType);
+ ATTRIB_MAP(EGL_SAMPLES, Samples);
+ ATTRIB_MAP(EGL_SAMPLE_BUFFERS, SampleBuffers);
+ ATTRIB_MAP(EGL_SURFACE_TYPE, SurfaceType);
+ ATTRIB_MAP(EGL_TRANSPARENT_TYPE, TransparentType);
+ ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE, TransparentBlueValue);
+ ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE, TransparentGreenValue);
+ ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE, TransparentRedValue);
+ ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB, BindToTextureRGB);
+ ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA, BindToTextureRGBA);
+ ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL, MinSwapInterval);
+ ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL, MaxSwapInterval);
+ ATTRIB_MAP(EGL_LUMINANCE_SIZE, LuminanceSize);
+ ATTRIB_MAP(EGL_ALPHA_MASK_SIZE, AlphaMaskSize);
+ ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE, ColorBufferType);
+ ATTRIB_MAP(EGL_RENDERABLE_TYPE, RenderableType);
+ ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP, MatchNativePixmap);
+ ATTRIB_MAP(EGL_CONFORMANT, Conformant);
+ /* extensions */
+ ATTRIB_MAP(EGL_Y_INVERTED_NOK, YInvertedNOK);
+#undef ATTRIB_MAP
default:
return -1;
}
@@ -58,18 +111,6 @@ _eglIndexConfig(const _EGLConfig *conf, EGLint key)
/**
- * Reset all keys in the config to a given value.
- */
-static INLINE void
-_eglResetConfigKeys(_EGLConfig *conf, EGLint val)
-{
- EGLint i;
- for (i = 0; i < _EGL_CONFIG_NUM_ATTRIBS; i++)
- conf->Storage[i] = val;
-}
-
-
-/**
* Update a config for a given key.
*
* Note that a valid key is not necessarily a valid attribute. There are gaps
@@ -79,9 +120,9 @@ _eglResetConfigKeys(_EGLConfig *conf, EGLint val)
static INLINE void
_eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
{
- EGLint idx = _eglIndexConfig(conf, key);
- assert(idx >= 0);
- conf->Storage[idx] = val;
+ EGLint offset = _eglOffsetOfConfig(key);
+ assert(offset >= 0);
+ *((EGLint *) ((char *) conf + offset)) = val;
}
@@ -91,9 +132,9 @@ _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
static INLINE EGLint
_eglGetConfigKey(const _EGLConfig *conf, EGLint key)
{
- EGLint idx = _eglIndexConfig(conf, key);
- assert(idx >= 0);
- return conf->Storage[idx];
+ EGLint offset = _eglOffsetOfConfig(key);
+ assert(offset >= 0);
+ return *((EGLint *) ((char *) conf + offset));
}
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index bc22913d401..ec35be9d3a8 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -113,13 +113,12 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
err = _eglParseContextAttribList(ctx, attrib_list);
if (err == EGL_SUCCESS && ctx->Config) {
- EGLint renderable_type, api_bit;
+ EGLint api_bit;
- renderable_type = GET_CONFIG_ATTRIB(ctx->Config, EGL_RENDERABLE_TYPE);
api_bit = _eglGetContextAPIBit(ctx);
- if (!(renderable_type & api_bit)) {
+ if (!(ctx->Config->RenderableType & api_bit)) {
_eglLog(_EGL_DEBUG, "context api is 0x%x while config supports 0x%x",
- api_bit, renderable_type);
+ api_bit, ctx->Config->RenderableType);
err = EGL_BAD_CONFIG;
}
}
@@ -183,7 +182,9 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c,
switch (attribute) {
case EGL_CONFIG_ID:
- *value = GET_CONFIG_ATTRIB(c->Config, EGL_CONFIG_ID);
+ if (!c->Config)
+ return _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext");
+ *value = c->Config->ConfigID;
break;
case EGL_CONTEXT_CLIENT_VERSION:
*value = c->ClientVersion;
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 31ff090484c..cc0f03e01ba 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -27,7 +27,7 @@ _eglGetNativePlatformFromEnv(void)
} egl_platforms[_EGL_NUM_PLATFORMS] = {
{ _EGL_PLATFORM_WINDOWS, "gdi" },
{ _EGL_PLATFORM_X11, "x11" },
- { _EGL_PLATFORM_DRM, "kms" },
+ { _EGL_PLATFORM_DRM, "drm" },
{ _EGL_PLATFORM_FBDEV, "fbdev" }
};
_EGLPlatformType plat = _EGL_INVALID_PLATFORM;
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 67f1d3dbaa4..a4ff6911be6 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -18,7 +18,6 @@
#include "eglmisc.h"
#include "eglmode.h"
#include "eglscreen.h"
-#include "eglstring.h"
#include "eglsurface.h"
#include "eglimage.h"
#include "eglsync.h"
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 52f5c240c65..ec51dd6ba22 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -17,12 +17,12 @@
static void
_eglClampSwapInterval(_EGLSurface *surf, EGLint interval)
{
- EGLint bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MAX_SWAP_INTERVAL);
+ EGLint bound = surf->Config->MaxSwapInterval;
if (interval >= bound) {
interval = bound;
}
else {
- bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MIN_SWAP_INTERVAL);
+ bound = surf->Config->MinSwapInterval;
if (interval < bound)
interval = bound;
}
@@ -263,7 +263,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
return EGL_FALSE;
}
- if ((GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE) & type) == 0) {
+ if ((conf->SurfaceType & type) == 0) {
/* The config can't be used to create a surface of this type */
_eglError(EGL_BAD_CONFIG, func);
return EGL_FALSE;
@@ -333,7 +333,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
*value = surface->Height;
break;
case EGL_CONFIG_ID:
- *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID);
+ *value = surface->Config->ConfigID;
break;
case EGL_LARGEST_PBUFFER:
*value = surface->LargestPbuffer;
@@ -445,7 +445,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
switch (attribute) {
case EGL_MIPMAP_LEVEL:
- confval = GET_CONFIG_ATTRIB(surface->Config, EGL_RENDERABLE_TYPE);
+ confval = surface->Config->RenderableType;
if (!(confval & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT))) {
err = EGL_BAD_PARAMETER;
break;
@@ -457,7 +457,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
case EGL_MULTISAMPLE_RESOLVE_DEFAULT:
break;
case EGL_MULTISAMPLE_RESOLVE_BOX:
- confval = GET_CONFIG_ATTRIB(surface->Config, EGL_SURFACE_TYPE);
+ confval = surface->Config->SurfaceType;
if (!(confval & EGL_MULTISAMPLE_RESOLVE_BOX_BIT))
err = EGL_BAD_MATCH;
break;
@@ -474,7 +474,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
case EGL_BUFFER_DESTROYED:
break;
case EGL_BUFFER_PRESERVED:
- confval = GET_CONFIG_ATTRIB(surface->Config, EGL_SURFACE_TYPE);
+ confval = surface->Config->SurfaceType;
if (!(confval & EGL_SWAP_BEHAVIOR_PRESERVED_BIT))
err = EGL_BAD_MATCH;
break;