am f42449e1: Merge "EGL_ANDROID_fence_sync: make it more generic" into jb-mr1-dev

* commit 'f42449e1259315d726efa75129bf1c4f5c0150d7':
  EGL_ANDROID_fence_sync: make it more generic
This commit is contained in:
Jamie Gennis 2012-09-05 13:51:41 -07:00 committed by Android Git Automerger
commit 6d53451b03

View File

@ -1,10 +1,10 @@
Name Name
ANDROID_fence_sync ANDROID_native_fence_sync
Name Strings Name Strings
EGL_ANDROID_fence_sync EGL_ANDROID_native_fence_sync
Contributors Contributors
@ -37,10 +37,17 @@ Dependencies
Overview Overview
This extension enables the creation of EGL fence sync objects that are This extension enables the creation of EGL fence sync objects that are
associated with an Android Sync HAL fence object. These EGL fence sync associated with a native synchronization fence object that is referenced
objects have nearly identical semantics to those defined by the using a file descriptor. These EGL fence sync objects have nearly
KHR_fence_sync extension, except that they have an additional attribute identical semantics to those defined by the KHR_fence_sync extension,
storing the file descriptor referring to the native Android fence object. 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.
New Types New Types
@ -48,7 +55,7 @@ New Types
New Procedures and Functions New Procedures and Functions
EGLint eglDupAndroidFenceFDANDROID( EGLint eglDupNativeFenceFDANDROID(
EGLDisplay dpy, EGLDisplay dpy,
EGLSyncKHR); EGLSyncKHR);
@ -58,72 +65,72 @@ New Tokens
in <value> when eglGetSyncAttribKHR is called with <attribute> in <value> when eglGetSyncAttribKHR is called with <attribute>
EGL_SYNC_TYPE_KHR: EGL_SYNC_TYPE_KHR:
EGL_SYNC_ANDROID_FENCE_ANDROID 0x3144 EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
Accepted by the <attrib_list> parameter of eglCreateSyncKHR: Accepted by the <attrib_list> parameter of eglCreateSyncKHR:
EGL_SYNC_ANDROID_FENCE_FD_ANDROID 0x3145 EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
Accepted by the <attrib_list> parameter of eglCreateSyncKHR, and returned Accepted by the <attrib_list> parameter of eglCreateSyncKHR, and returned
by eglDupAndroidFenceFDANDROID in the event of an error: by eglDupNativeFenceFDANDROID in the event of an error:
EGL_NO_ANDROID_FENCE_ANDROID -1 EGL_NO_NATIVE_FENCE_ANDROID -1
Returned in <value> when eglGetSyncAttribKHR is called with <attribute> Returned in <value> when eglGetSyncAttribKHR is called with <attribute>
EGL_SYNC_CONDITION_KHR: EGL_SYNC_CONDITION_KHR:
EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID 0x3146 EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors) 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 Add the following after the sixth paragraph of Section 3.8.1 (Sync
Objects), added by KHR_fence_sync Objects), added by KHR_fence_sync
"If <type> is EGL_SYNC_ANDROID_FENCE_ANDROID, an EGL Android fence sync "If <type> is EGL_SYNC_NATIVE_FENCE_ANDROID, an EGL native fence sync
object is created. In this case the EGL_SYNC_ANDROID_FENCE_FD_ANDROID object is created. In this case the EGL_SYNC_NATIVE_FENCE_FD_ANDROID
attribute may optionally be specified. If this attribute is specified, it attribute may optionally be specified. If this attribute is specified, it
must be set to either a file descriptor that refers to a native Android must be set to either a file descriptor that refers to a native fence
fence object or to the value EGL_NO_ANDROID_FENCE_ANDROID. object or to the value EGL_NO_NATIVE_FENCE_ANDROID.
The default values for the EGL Android fence sync object attributes are as The default values for the EGL native fence sync object attributes are as
follows: follows:
Attribute Name Initial Attribute Value(s) Attribute Name Initial Attribute Value(s)
--------------- -------------------------- --------------- --------------------------
EGL_SYNC_TYPE_KHR EGL_SYNC_ANDROID_FENCE_ANDROID EGL_SYNC_TYPE_KHR EGL_SYNC_NATIVE_FENCE_ANDROID
EGL_SYNC_STATUS_KHR EGL_UNSIGNALED_KHR EGL_SYNC_STATUS_KHR EGL_UNSIGNALED_KHR
EGL_SYNC_CONDITION_KHR EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR EGL_SYNC_CONDITION_KHR EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR
EGL_SYNC_ANDROID_FENCE_FD_ANDROID EGL_NO_ANDROID_FENCE_ANDROID EGL_SYNC_NATIVE_FENCE_FD_ANDROID EGL_NO_NATIVE_FENCE_ANDROID
If the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute is not If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute is not
EGL_NO_ANDROID_FENCE_ANDROID then the EGL_SYNC_CONDITION_KHR attribute is EGL_NO_NATIVE_FENCE_ANDROID then the EGL_SYNC_CONDITION_KHR attribute is
set to EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID and the EGL_SYNC_STATUS_KHR 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 Android fence attribute is set to reflect the signal status of the native fence object.
object. Additionally, the EGL implementation assumes ownership of the file Additionally, the EGL implementation assumes ownership of the file
descriptor, so the caller must not use it after calling eglCreateSyncKHR." descriptor, so the caller must not use it after calling eglCreateSyncKHR."
Modify Section 3.8.1 (Sync Objects), added by KHR_fence_sync, starting at Modify Section 3.8.1 (Sync Objects), added by KHR_fence_sync, starting at
the seventh paragraph the seventh paragraph
"When a fence sync object is created or when an EGL Android fence sync "When a fence sync object is created or when an EGL native fence sync
object is created with the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute set object is created with the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute set
to EGL_NO_ANDROID_FENCE_ANDROID, eglCreateSyncKHR also inserts a fence to EGL_NO_NATIVE_FENCE_ANDROID, eglCreateSyncKHR also inserts a fence
command into the command stream of the bound client API's current context command into the command stream of the bound client API's current context
(i.e., the context returned by eglGetCurrentContext), and associates it (i.e., the context returned by eglGetCurrentContext), and associates it
with the newly created sync object. with the newly created sync object.
After associating the fence command with an EGL Android fence sync object, After associating the fence command with an EGL native fence sync object,
the next Flush() operation performed by the current client API causes a the next Flush() operation performed by the current client API causes a
new native Android fence object to be created, and the new native fence object to be created, and the
EGL_SYNC_ANDROID_FENCE_ANDROID attribute of the EGL Android fence object EGL_SYNC_NATIVE_FENCE_ANDROID attribute of the EGL native fence object is
is set to a file descriptor that refers to the new native Android fence set to a file descriptor that refers to the new native fence object. This
object. This new native Android fence object is signaled when the EGL new native fence object is signaled when the EGL native fence sync object
Android fence sync object is signaled. is signaled.
When the condition of the sync object is satisfied by the fence command, 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 the sync is signaled by the associated client API context, causing any
eglClientWaitSyncKHR commands (see below) blocking on <sync> to unblock. If eglClientWaitSyncKHR commands (see below) blocking on <sync> to unblock.
the sync object is an EGL Android fence sync object then the native Android If the sync object is an EGL native fence sync object then the native
fence object is also signaled when the condition is satisfied. The fence object is also signaled when the condition is satisfied. The
EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR condition is satisfied by completion EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR condition is satisfied by completion
of the fence command corresponding to the sync object and all preceding of the fence command corresponding to the sync object and all preceding
@ -132,9 +139,9 @@ Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
client API's internal and framebuffer state are fully realized. No other client API's internal and framebuffer state are fully realized. No other
state is affected by execution of the fence command. state is affected by execution of the fence command.
The EGL_SYNC_ANDROID_FENCE_SIGNALED_ANDROID condition is satisfied by the The EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID condition is satisfied by the
signaling of the native Android fence object referred to by the signaling of the native fence object referred to by the
EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute. When this happens any EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute. When this happens any
eglClientWaitSyncKHR commands blocking on <sync> unblock." eglClientWaitSyncKHR commands blocking on <sync> unblock."
Modify the list of eglCreateSyncKHR errors in Section 3.8.1 (Sync Objects), Modify the list of eglCreateSyncKHR errors in Section 3.8.1 (Sync Objects),
@ -149,22 +156,22 @@ Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
* If <type> is EGL_SYNC_FENCE_KHR and <attrib_list> is neither NULL nor * 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 empty (containing only EGL_NONE), EGL_NO_SYNC_KHR is returned and an
EGL_BAD_ATTRIBUTE error is generated. EGL_BAD_ATTRIBUTE error is generated.
* If <type> is EGL_SYNC_ANDROID_FENCE_ANDROID and <attrib_list> contains * If <type> is EGL_SYNC_NATIVE_FENCE_ANDROID and <attrib_list> contains
an attribute other than EGL_SYNC_ANDROID_FENCE_FD_ANDROID, EGL_NO_SYNC_KHR is an attribute other than EGL_SYNC_NATIVE_FENCE_FD_ANDROID, EGL_NO_SYNC_KHR is
returned and an EGL_BAD_ATTRIBUTE error is generated. returned and an EGL_BAD_ATTRIBUTE error is generated.
* If <type> is not a supported type of sync object, * If <type> is not a supported type of sync object,
EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
generated. generated.
* If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_ANDROID_FENCE_ANDROID and * If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
no context is current for the bound API (i.e., eglGetCurrentContext no context is current for the bound API (i.e., eglGetCurrentContext
returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
EGL_BAD_MATCH error is generated. EGL_BAD_MATCH error is generated.
* If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_ANDROID_FENCE_ANDROID and * If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
<dpy> does not match the EGLDisplay of the currently bound context for <dpy> does not match the EGLDisplay of the currently bound context for
the currently bound client API (the EGLDisplay returned by the currently bound client API (the EGLDisplay returned by
eglGetCurrentDisplay()) then EGL_NO_SYNC_KHR is returned and an eglGetCurrentDisplay()) then EGL_NO_SYNC_KHR is returned and an
EGL_BAD_MATCH error is generated. EGL_BAD_MATCH error is generated.
* If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_ANDROID_FENCE_ANDROID and * If <type> is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
the currently bound client API does not support the client API the currently bound client API does not support the client API
extension indicating it can place fence commands, then EGL_NO_SYNC_KHR extension indicating it can place fence commands, then EGL_NO_SYNC_KHR
is returned and an EGL_BAD_MATCH error is generated." is returned and an EGL_BAD_MATCH error is generated."
@ -177,7 +184,7 @@ Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
EGL_SYNC_TYPE_KHR Type of the sync object All EGL_SYNC_TYPE_KHR Type of the sync object All
EGL_SYNC_STATUS_KHR Status 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 EGL_SYNC_CONDITION_KHR Signaling condition EGL_SYNC_FENCE_KHR and
EGL_SYNC_ANDROID_FENCE_ANDROID only EGL_SYNC_NATIVE_FENCE_ANDROID only
" "
Modify the second paragraph description of eglDestroySyncKHR in Section Modify the second paragraph description of eglDestroySyncKHR in Section
@ -185,8 +192,8 @@ Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
"If no errors are generated, EGL_TRUE is returned, and <sync> will no "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 longer be the handle of a valid sync object. Additionally, if <sync> is an
EGL Android fence sync object and the EGL_SYNC_ANDROID_FENCE_FD_ANDROID EGL native fence sync object and the EGL_SYNC_NATIVE_FENCE_FD_ANDROID
attribute is not EGL_NO_ANDROID_FENCE_ANDROID then that file descriptor is attribute is not EGL_NO_NATIVE_FENCE_ANDROID then that file descriptor is
closed." closed."
Add the following after the last paragraph of Section 3.8.1 (Sync Add the following after the last paragraph of Section 3.8.1 (Sync
@ -194,51 +201,50 @@ Changes to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
The command The command
EGLint eglDupAndroidFenceFDANDROID( EGLint eglDupNativeFenceFDANDROID(
EGLdisplay dpy, EGLdisplay dpy,
EGLSyncKHR sync); EGLSyncKHR sync);
duplicates the file descriptor stored in the duplicates the file descriptor stored in the
EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute of an EGL Android fence sync EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of an EGL native fence sync
object and returns the new file descriptor. object and returns the new file descriptor.
Errors Errors
------ ------
* If <sync> is not a valid sync object for <dpy>, * If <sync> is not a valid sync object for <dpy>,
EGL_NO_ANDROID_FENCE_ANDROID is returned and an EGL_BAD_PARAMETER EGL_NO_NATIVE_FENCE_ANDROID is returned and an EGL_BAD_PARAMETER
error is generated. error is generated.
* If the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute of <sync> is * If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of <sync> is
EGL_NO_ANDROID_FENCE_ANDROID, EGL_NO_ANDROID_FENCE_ANDROID is returned EGL_NO_NATIVE_FENCE_ANDROID, EGL_NO_NATIVE_FENCE_ANDROID is returned
and an EGL_BAD_PARAMETER error is generated. and an EGL_BAD_PARAMETER error is generated.
* If <dpy> does not match the display passed to eglCreateSyncKHR * If <dpy> does not match the display passed to eglCreateSyncKHR
when <sync> was created, the behaviour is undefined." when <sync> was created, the behaviour is undefined."
Issues Issues
1. Should EGLSyncKHR objects that wrap Android fence objects use the 1. Should EGLSyncKHR objects that wrap native fence objects use the
EGL_SYNC_FENCE_KHR type? EGL_SYNC_FENCE_KHR type?
RESOLVED: A new sync object type will be added. RESOLVED: A new sync object type will be added.
We don't want to require all EGL fence sync objects to wrap Android fence We don't want to require all EGL fence sync objects to wrap native fence
objects, so we need some way to tell the EGL implementation at sync object objects, so we need some way to tell the EGL implementation at sync object
creation whether the sync object should support querying the Android fence creation whether the sync object should support querying the native fence
FD attribute. We could do this with either a new sync object type or with a 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 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 that might be added for fence sync objects, but there may be things that
get added that don't make sense in the context of Android fence objects. get added that don't make sense in the context of native fence objects.
2. Who is responsible for dup'ing the Android fence file descriptors? 2. Who is responsible for dup'ing the native fence file descriptors?
RESOLVED: Whenever a file descriptor is passed into or returned from an RESOLVED: Whenever a file descriptor is passed into or returned from an
EGL call in this extension, ownership of that file descriptor is EGL call in this extension, ownership of that file descriptor is
transfered. The recipient of the file descriptor must close it when it 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 no longer needed, and the provider of the file descriptor must dup it
before providing it if they require continued use of the native Android before providing it if they require continued use of the native fence.
fence.
3. Can the EGL_SYNC_ANDROID_FENCE_FD_ANDROID attribute be queried? 3. Can the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute be queried?
RESOLVED: No. RESOLVED: No.
@ -250,15 +256,21 @@ Issues
That said, the attribute is useful both as a way to pass an existing file 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 descriptor to eglCreateSyncKHR and as a way to describe the subsequent
behavior of EGL Android fence sync objects, so it is left as an attribute behavior of EGL native fence sync objects, so it is left as an attribute
for which the value cannot be queried. for which the value cannot be queried.
Revision History Revision History
#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.
#2 (Jamie Gennis, July 23, 2012) #2 (Jamie Gennis, July 23, 2012)
- Changed the file descriptor ownership transferring behavior. - Changed the file descriptor ownership transferring behavior.
- Added the eglDupAndroidFenceFDANDROID function. - Added the eglDupAndroidFenceFDANDROID function.
- Removed EGL_SYNC_ANDROID_FENCE_FD_ANDROID from the table of gettable - Removed EGL_SYNC_NATIVE_FENCE_FD_ANDROID from the table of gettable
attributes. attributes.
- Added language specifying that a native Android fence is created at the - 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 flush following the creation of an EGL Android fence sync object that is