2012-05-30 02:14:36 +00:00
|
|
|
Name
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
ANDROID_native_fence_sync
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Name Strings
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_ANDROID_native_fence_sync
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Contributors
|
|
|
|
|
|
|
|
Jamie Gennis
|
|
|
|
|
|
|
|
Contact
|
|
|
|
|
|
|
|
Jamie Gennis, Google Inc. (jgennis 'at' google.com)
|
|
|
|
|
|
|
|
Status
|
|
|
|
|
|
|
|
Draft.
|
|
|
|
|
|
|
|
Version
|
|
|
|
|
2012-09-06 02:45:44 +00:00
|
|
|
Version 3, September 4, 2012
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Number
|
|
|
|
|
|
|
|
EGL Extension #XXX
|
|
|
|
|
|
|
|
Dependencies
|
|
|
|
|
|
|
|
Requires EGL 1.1
|
|
|
|
|
|
|
|
This extension is written against the wording of the EGL 1.2 Specification
|
|
|
|
|
|
|
|
EGL_KHR_fence_sync is required.
|
|
|
|
|
|
|
|
Overview
|
|
|
|
|
|
|
|
This extension enables the creation of EGL fence sync objects that are
|
2012-09-05 02:49:51 +00:00
|
|
|
associated with a native synchronization fence object that is referenced
|
|
|
|
using a file descriptor. These EGL fence sync objects have nearly
|
|
|
|
identical semantics to those defined by the KHR_fence_sync extension,
|
|
|
|
except that they have an additional attribute storing the file descriptor
|
|
|
|
referring to the native fence object.
|
|
|
|
|
|
|
|
This extension assumes the existence of a native fence synchronization
|
|
|
|
object that behaves similarly to an EGL fence sync object. These native
|
|
|
|
objects must have a signal status like that of an EGLSyncKHR object that
|
|
|
|
indicates whether the fence has ever been signaled. Once signaled the
|
|
|
|
native object's signal status may not change again.
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
New Types
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
New Procedures and Functions
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
EGLint eglDupNativeFenceFDANDROID(
|
2012-07-20 18:55:07 +00:00
|
|
|
EGLDisplay dpy,
|
|
|
|
EGLSyncKHR);
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
New Tokens
|
|
|
|
|
|
|
|
Accepted by the <type> parameter of eglCreateSyncKHR, and returned
|
|
|
|
in <value> when eglGetSyncAttribKHR is called with <attribute>
|
|
|
|
EGL_SYNC_TYPE_KHR:
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
|
2012-05-30 02:14:36 +00:00
|
|
|
|
2012-07-20 18:55:07 +00:00
|
|
|
Accepted by the <attrib_list> parameter of eglCreateSyncKHR:
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
|
2012-05-30 02:14:36 +00:00
|
|
|
|
2012-07-20 18:55:07 +00:00
|
|
|
Accepted by the <attrib_list> parameter of eglCreateSyncKHR, and returned
|
2012-09-05 02:49:51 +00:00
|
|
|
by eglDupNativeFenceFDANDROID in the event of an error:
|
2012-07-20 18:55:07 +00:00
|
|
|
|
2012-09-06 21:52:00 +00:00
|
|
|
EGL_NO_NATIVE_FENCE_FD_ANDROID -1
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Returned in <value> when eglGetSyncAttribKHR is called with <attribute>
|
|
|
|
EGL_SYNC_CONDITION_KHR:
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
|
|
|
|
|
|
|
|
Add the following after the sixth paragraph of Section 3.8.1 (Sync
|
|
|
|
Objects), added by KHR_fence_sync
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
"If <type> is EGL_SYNC_NATIVE_FENCE_ANDROID, an EGL native fence sync
|
|
|
|
object is created. In this case the EGL_SYNC_NATIVE_FENCE_FD_ANDROID
|
2012-07-20 18:55:07 +00:00
|
|
|
attribute may optionally be specified. If this attribute is specified, it
|
2012-09-05 02:49:51 +00:00
|
|
|
must be set to either a file descriptor that refers to a native fence
|
2012-09-06 21:52:00 +00:00
|
|
|
object or to the value EGL_NO_NATIVE_FENCE_FD_ANDROID.
|
2012-05-30 02:14:36 +00:00
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
The default values for the EGL native fence sync object attributes are as
|
2012-05-30 02:14:36 +00:00
|
|
|
follows:
|
|
|
|
|
2012-07-20 18:55:07 +00:00
|
|
|
Attribute Name Initial Attribute Value(s)
|
|
|
|
--------------- --------------------------
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_SYNC_TYPE_KHR EGL_SYNC_NATIVE_FENCE_ANDROID
|
2012-07-20 18:55:07 +00:00
|
|
|
EGL_SYNC_STATUS_KHR EGL_UNSIGNALED_KHR
|
|
|
|
EGL_SYNC_CONDITION_KHR EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR
|
2012-11-26 21:54:56 +00:00
|
|
|
EGL_SYNC_NATIVE_FENCE_FD_ANDROID EGL_NO_NATIVE_FENCE_FD_ANDROID
|
2012-07-20 18:55:07 +00:00
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute is not
|
2012-11-26 21:54:56 +00:00
|
|
|
EGL_NO_NATIVE_FENCE_FD_ANDROID then the EGL_SYNC_CONDITION_KHR attribute is
|
2012-09-05 02:49:51 +00:00
|
|
|
set to EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID and the EGL_SYNC_STATUS_KHR
|
|
|
|
attribute is set to reflect the signal status of the native fence object.
|
|
|
|
Additionally, the EGL implementation assumes ownership of the file
|
2012-07-20 18:55:07 +00:00
|
|
|
descriptor, so the caller must not use it after calling eglCreateSyncKHR."
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Modify Section 3.8.1 (Sync Objects), added by KHR_fence_sync, starting at
|
|
|
|
the seventh paragraph
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
"When a fence sync object is created or when an EGL native fence sync
|
|
|
|
object is created with the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute set
|
2012-11-26 21:54:56 +00:00
|
|
|
to EGL_NO_NATIVE_FENCE_FD_ANDROID, eglCreateSyncKHR also inserts a fence
|
2012-07-20 18:55:07 +00:00
|
|
|
command into the command stream of the bound client API's current context
|
|
|
|
(i.e., the context returned by eglGetCurrentContext), and associates it
|
|
|
|
with the newly created sync object.
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
After associating the fence command with an EGL native fence sync object,
|
2012-07-20 18:55:07 +00:00
|
|
|
the next Flush() operation performed by the current client API causes a
|
2012-09-05 02:49:51 +00:00
|
|
|
new native fence object to be created, and the
|
|
|
|
EGL_SYNC_NATIVE_FENCE_ANDROID attribute of the EGL native fence object is
|
|
|
|
set to a file descriptor that refers to the new native fence object. This
|
|
|
|
new native fence object is signaled when the EGL native fence sync object
|
|
|
|
is signaled.
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
When the condition of the sync object is satisfied by the fence command,
|
|
|
|
the sync is signaled by the associated client API context, causing any
|
2012-09-05 02:49:51 +00:00
|
|
|
eglClientWaitSyncKHR commands (see below) blocking on <sync> to unblock.
|
|
|
|
If the sync object is an EGL native fence sync object then the native
|
2012-05-30 02:14:36 +00:00
|
|
|
fence object is also signaled when the condition is satisfied. The
|
|
|
|
EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR condition is satisfied by completion
|
|
|
|
of the fence command corresponding to the sync object and all preceding
|
|
|
|
commands in the associated client API context's command stream. The sync
|
|
|
|
object will not be signaled until all effects from these commands on the
|
|
|
|
client API's internal and framebuffer state are fully realized. No other
|
|
|
|
state is affected by execution of the fence command.
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
The EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID condition is satisfied by the
|
|
|
|
signaling of the native fence object referred to by the
|
|
|
|
EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute. When this happens any
|
2012-05-30 02:14:36 +00:00
|
|
|
eglClientWaitSyncKHR commands blocking on <sync> unblock."
|
|
|
|
|
|
|
|
Modify the list of eglCreateSyncKHR errors in Section 3.8.1 (Sync Objects),
|
|
|
|
added by KHR_fence_sync
|
|
|
|
|
|
|
|
"Errors
|
|
|
|
------
|
|
|
|
|
|
|
|
* If <dpy> is not the name of a valid, initialized EGLDisplay,
|
|
|
|
EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
|
|
|
|
generated.
|
|
|
|
* If <type> is EGL_SYNC_FENCE_KHR and <attrib_list> is neither NULL nor
|
|
|
|
empty (containing only EGL_NONE), EGL_NO_SYNC_KHR is returned and an
|
|
|
|
EGL_BAD_ATTRIBUTE error is generated.
|
2012-09-05 02:49:51 +00:00
|
|
|
* If <type> is EGL_SYNC_NATIVE_FENCE_ANDROID and <attrib_list> contains
|
2012-11-26 21:54:56 +00:00
|
|
|
an attribute other than EGL_SYNC_NATIVE_FENCE_FD_ANDROID,
|
|
|
|
EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
|
|
|
|
generated.
|
2012-05-30 02:14:36 +00:00
|
|
|
* If <type> is not a supported type of sync object,
|
|
|
|
EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
|
|
|
|
generated.
|
2012-09-05 02:49:51 +00:00
|
|
|
* If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
|
2012-05-30 02:14:36 +00:00
|
|
|
no context is current for the bound API (i.e., eglGetCurrentContext
|
|
|
|
returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
|
|
|
|
EGL_BAD_MATCH error is generated.
|
2012-09-05 02:49:51 +00:00
|
|
|
* If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
|
2012-05-30 02:14:36 +00:00
|
|
|
<dpy> does not match the EGLDisplay of the currently bound context for
|
|
|
|
the currently bound client API (the EGLDisplay returned by
|
|
|
|
eglGetCurrentDisplay()) then EGL_NO_SYNC_KHR is returned and an
|
|
|
|
EGL_BAD_MATCH error is generated.
|
2012-09-05 02:49:51 +00:00
|
|
|
* If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
|
2012-05-30 02:14:36 +00:00
|
|
|
the currently bound client API does not support the client API
|
|
|
|
extension indicating it can place fence commands, then EGL_NO_SYNC_KHR
|
|
|
|
is returned and an EGL_BAD_MATCH error is generated."
|
|
|
|
|
|
|
|
Modify table 3.cc in Section 3.8.1 (Sync Objects), added by KHR_fence_sync
|
|
|
|
|
|
|
|
"
|
2012-07-20 18:55:07 +00:00
|
|
|
Attribute Description Supported Sync Objects
|
|
|
|
----------------- ----------------------- ----------------------
|
|
|
|
EGL_SYNC_TYPE_KHR Type of the sync object All
|
|
|
|
EGL_SYNC_STATUS_KHR Status of the sync object All
|
|
|
|
EGL_SYNC_CONDITION_KHR Signaling condition EGL_SYNC_FENCE_KHR and
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_SYNC_NATIVE_FENCE_ANDROID only
|
2012-05-30 02:14:36 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
Modify the second paragraph description of eglDestroySyncKHR in Section
|
|
|
|
3.8.1 (Sync Objects), added by KHR_fence_sync
|
|
|
|
|
|
|
|
"If no errors are generated, EGL_TRUE is returned, and <sync> will no
|
|
|
|
longer be the handle of a valid sync object. Additionally, if <sync> is an
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL native fence sync object and the EGL_SYNC_NATIVE_FENCE_FD_ANDROID
|
2012-11-26 21:54:56 +00:00
|
|
|
attribute is not EGL_NO_NATIVE_FENCE_FD_ANDROID then that file descriptor
|
|
|
|
is closed."
|
2012-07-20 18:55:07 +00:00
|
|
|
|
|
|
|
Add the following after the last paragraph of Section 3.8.1 (Sync
|
|
|
|
Objects), added by KHR_fence_sync
|
|
|
|
|
|
|
|
The command
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
EGLint eglDupNativeFenceFDANDROID(
|
2012-09-06 21:52:00 +00:00
|
|
|
EGLDisplay dpy,
|
2012-07-20 18:55:07 +00:00
|
|
|
EGLSyncKHR sync);
|
|
|
|
|
|
|
|
duplicates the file descriptor stored in the
|
2012-09-05 02:49:51 +00:00
|
|
|
EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of an EGL native fence sync
|
2012-07-20 18:55:07 +00:00
|
|
|
object and returns the new file descriptor.
|
|
|
|
|
|
|
|
Errors
|
|
|
|
------
|
|
|
|
|
|
|
|
* If <sync> is not a valid sync object for <dpy>,
|
2012-11-26 21:54:56 +00:00
|
|
|
EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
|
2012-07-20 18:55:07 +00:00
|
|
|
error is generated.
|
2012-09-05 02:49:51 +00:00
|
|
|
* If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of <sync> is
|
2012-11-26 21:54:56 +00:00
|
|
|
EGL_NO_NATIVE_FENCE_FD_ANDROID, EGL_NO_NATIVE_FENCE_FD_ANDROID is
|
|
|
|
returned and an EGL_BAD_PARAMETER error is generated.
|
2012-07-20 18:55:07 +00:00
|
|
|
* If <dpy> does not match the display passed to eglCreateSyncKHR
|
|
|
|
when <sync> was created, the behaviour is undefined."
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Issues
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
1. Should EGLSyncKHR objects that wrap native fence objects use the
|
2012-05-30 02:14:36 +00:00
|
|
|
EGL_SYNC_FENCE_KHR type?
|
|
|
|
|
|
|
|
RESOLVED: A new sync object type will be added.
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
We don't want to require all EGL fence sync objects to wrap native fence
|
2012-05-30 02:14:36 +00:00
|
|
|
objects, so we need some way to tell the EGL implementation at sync object
|
2012-09-05 02:49:51 +00:00
|
|
|
creation whether the sync object should support querying the native fence
|
2012-05-30 02:14:36 +00:00
|
|
|
FD attribute. We could do this with either a new sync object type or with a
|
|
|
|
boolean attribute. It might be nice to pick up future signaling conditions
|
|
|
|
that might be added for fence sync objects, but there may be things that
|
2012-09-05 02:49:51 +00:00
|
|
|
get added that don't make sense in the context of native fence objects.
|
2012-05-30 02:14:36 +00:00
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
2. Who is responsible for dup'ing the native fence file descriptors?
|
2012-05-30 02:14:36 +00:00
|
|
|
|
2012-07-20 18:55:07 +00:00
|
|
|
RESOLVED: Whenever a file descriptor is passed into or returned from an
|
|
|
|
EGL call in this extension, ownership of that file descriptor is
|
|
|
|
transfered. The recipient of the file descriptor must close it when it is
|
|
|
|
no longer needed, and the provider of the file descriptor must dup it
|
2012-09-05 02:49:51 +00:00
|
|
|
before providing it if they require continued use of the native fence.
|
2012-05-30 02:14:36 +00:00
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
3. Can the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute be queried?
|
2012-07-20 18:55:07 +00:00
|
|
|
|
|
|
|
RESOLVED: No.
|
|
|
|
|
|
|
|
Returning the file descriptor owned by the EGL implementation would
|
|
|
|
violate the file descriptor ownership rule described in issue #2. Having
|
|
|
|
eglGetSyncAttribKHR return a different (dup'd) file descriptor each time
|
|
|
|
it's called seems wrong, so a new function was added to explicitly dup the
|
|
|
|
file descriptor.
|
|
|
|
|
|
|
|
That said, the attribute is useful both as a way to pass an existing file
|
|
|
|
descriptor to eglCreateSyncKHR and as a way to describe the subsequent
|
2012-09-05 02:49:51 +00:00
|
|
|
behavior of EGL native fence sync objects, so it is left as an attribute
|
2012-07-20 18:55:07 +00:00
|
|
|
for which the value cannot be queried.
|
2012-05-30 02:14:36 +00:00
|
|
|
|
|
|
|
Revision History
|
|
|
|
|
2012-09-05 02:49:51 +00:00
|
|
|
#3 (Jamie Gennis, September 4, 2012)
|
|
|
|
- Reworded the extension to refer to "native fence" objects rather than
|
|
|
|
"Android fence" objects.
|
|
|
|
- Added a paragraph to the overview that describes assumptions about the
|
|
|
|
native fence sync objects.
|
|
|
|
|
2012-07-20 18:55:07 +00:00
|
|
|
#2 (Jamie Gennis, July 23, 2012)
|
|
|
|
- Changed the file descriptor ownership transferring behavior.
|
|
|
|
- Added the eglDupAndroidFenceFDANDROID function.
|
2012-09-05 02:49:51 +00:00
|
|
|
- Removed EGL_SYNC_NATIVE_FENCE_FD_ANDROID from the table of gettable
|
2012-07-20 18:55:07 +00:00
|
|
|
attributes.
|
|
|
|
- Added language specifying that a native Android fence is created at the
|
|
|
|
flush following the creation of an EGL Android fence sync object that is
|
|
|
|
not passed an existing native fence.
|
|
|
|
|
2012-05-30 02:14:36 +00:00
|
|
|
#1 (Jamie Gennis, May 29, 2012)
|
|
|
|
- Initial draft.
|