2011-07-02 09:57:30 +01:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright 2010 LunarG, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
2010-08-14 16:09:12 +01:00
|
|
|
#ifndef EGLSYNC_INCLUDED
|
|
|
|
#define EGLSYNC_INCLUDED
|
|
|
|
|
|
|
|
|
2015-02-28 16:35:22 +00:00
|
|
|
#include "c99_compat.h"
|
|
|
|
|
2010-08-14 16:09:12 +01:00
|
|
|
#include "egltypedefs.h"
|
|
|
|
#include "egldisplay.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Base" class for device driver syncs.
|
|
|
|
*/
|
|
|
|
struct _egl_sync
|
|
|
|
{
|
|
|
|
/* A sync is a display resource */
|
|
|
|
_EGLResource Resource;
|
|
|
|
|
|
|
|
EGLenum Type;
|
|
|
|
EGLenum SyncStatus;
|
2010-08-15 10:09:48 +01:00
|
|
|
EGLenum SyncCondition;
|
2015-05-12 16:34:57 +01:00
|
|
|
EGLAttrib CLEvent;
|
2016-11-18 13:39:33 +00:00
|
|
|
EGLint SyncFd;
|
2010-08-14 16:09:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-02-28 17:20:01 +00:00
|
|
|
extern EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglInitSync(_EGLSync *sync, _EGLDisplay *disp, EGLenum type,
|
egl: Unify the EGLint/EGLAttrib paths in eglCreateSync* (v3)
Pre-patch, there were two code paths for parsing EGLSync attribute
lists: one path for old-style EGLint lists, used by eglCreateSyncKHR,
and another for new-style EGLAttrib lists, used by eglCreateSync (1.5)
and eglCreateSync64 (EGL_KHR_cl_event2).
There were two attrib_list parsing functions,
_eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
_eglParseSyncAttribList64(_EGLSync *sync, const EGLattrib *attrib_list)
This patch unifies the two attrib_list parsing functions into one,
_eglParseSyncAttribList(_EGLSync *sync, const EGLattrib *attrib_list)
Many internal EGLSync function signatures had *two* attrib_list
parameters to accomodate both code paths: one parameter was an EGLint
list and other an EGLAttrib list. At most one of the parameters was
allowed to be non-null. This patch removes the `EGLint *attrib_list`
parameter, leaving only the `EGLAttrib *attrib_list` parameter, for all
internal EGLSync functions.
v2:
- Consistently use condition (sizeof(int_list[0]) ==
sizeof(attrib_list[0])). [for emil]
v3:
- Don't double-unlock the display in eglCreateSyncKHR.
Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v2)
2016-09-27 21:27:21 +01:00
|
|
|
const EGLAttrib *attrib_list);
|
2010-08-14 16:09:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
extern EGLBoolean
|
2020-07-31 00:38:41 +01:00
|
|
|
_eglGetSyncAttrib(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync,
|
2015-05-12 17:14:31 +01:00
|
|
|
EGLint attribute, EGLAttrib *value);
|
2010-08-14 16:09:12 +01:00
|
|
|
|
|
|
|
|
2010-10-23 04:59:03 +01:00
|
|
|
/**
|
|
|
|
* Increment reference count for the sync.
|
|
|
|
*/
|
2015-02-28 16:35:22 +00:00
|
|
|
static inline _EGLSync *
|
2010-10-23 04:59:03 +01:00
|
|
|
_eglGetSync(_EGLSync *sync)
|
|
|
|
{
|
|
|
|
if (sync)
|
|
|
|
_eglGetResource(&sync->Resource);
|
|
|
|
return sync;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decrement reference count for the sync.
|
|
|
|
*/
|
2015-02-28 16:35:22 +00:00
|
|
|
static inline EGLBoolean
|
2010-10-23 04:59:03 +01:00
|
|
|
_eglPutSync(_EGLSync *sync)
|
|
|
|
{
|
|
|
|
return (sync) ? _eglPutResource(&sync->Resource) : EGL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-14 16:09:12 +01:00
|
|
|
/**
|
2010-10-22 17:37:19 +01:00
|
|
|
* Link a sync to its display and return the handle of the link.
|
2010-08-14 16:09:12 +01:00
|
|
|
* The handle can be passed to client directly.
|
|
|
|
*/
|
2015-05-12 16:34:57 +01:00
|
|
|
static inline EGLSync
|
2010-10-22 17:37:19 +01:00
|
|
|
_eglLinkSync(_EGLSync *sync)
|
2010-08-14 16:09:12 +01:00
|
|
|
{
|
2010-10-22 17:37:19 +01:00
|
|
|
_eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
|
2015-05-12 16:34:57 +01:00
|
|
|
return (EGLSync) sync;
|
2010-08-14 16:09:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlink a linked sync from its display.
|
|
|
|
*/
|
2015-02-28 16:35:22 +00:00
|
|
|
static inline void
|
2010-08-14 16:09:12 +01:00
|
|
|
_eglUnlinkSync(_EGLSync *sync)
|
|
|
|
{
|
|
|
|
_eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup a handle to find the linked sync.
|
|
|
|
* Return NULL if the handle has no corresponding linked sync.
|
|
|
|
*/
|
2015-02-28 16:35:22 +00:00
|
|
|
static inline _EGLSync *
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglLookupSync(EGLSync handle, _EGLDisplay *disp)
|
2010-08-14 16:09:12 +01:00
|
|
|
{
|
|
|
|
_EGLSync *sync = (_EGLSync *) handle;
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, disp))
|
2010-08-14 16:09:12 +01:00
|
|
|
sync = NULL;
|
|
|
|
return sync;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the handle of a linked sync, or EGL_NO_SYNC_KHR.
|
|
|
|
*/
|
2015-05-12 16:34:57 +01:00
|
|
|
static inline EGLSync
|
2010-08-14 16:09:12 +01:00
|
|
|
_eglGetSyncHandle(_EGLSync *sync)
|
|
|
|
{
|
|
|
|
_EGLResource *res = (_EGLResource *) sync;
|
|
|
|
return (res && _eglIsResourceLinked(res)) ?
|
2015-05-12 16:34:57 +01:00
|
|
|
(EGLSync) sync : EGL_NO_SYNC_KHR;
|
2010-08-14 16:09:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* EGLSYNC_INCLUDED */
|