102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci NV_stream_sync 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_NV_stream_sync 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Acorn Pooley 1202f4aeb0Sopenharmony_ci Marcus Lorentzon 1302f4aeb0Sopenharmony_ci 1402f4aeb0Sopenharmony_ciContacts 1502f4aeb0Sopenharmony_ci 1602f4aeb0Sopenharmony_ci Ian Stewart, NVIDIA (istewart 'at' nvidia.com) 1702f4aeb0Sopenharmony_ci 1802f4aeb0Sopenharmony_ciStatus 1902f4aeb0Sopenharmony_ci 2002f4aeb0Sopenharmony_ci Complete 2102f4aeb0Sopenharmony_ci 2202f4aeb0Sopenharmony_ciVersion 2302f4aeb0Sopenharmony_ci 2402f4aeb0Sopenharmony_ci Version 6, June 5, 2012 2502f4aeb0Sopenharmony_ci 2602f4aeb0Sopenharmony_ciNumber 2702f4aeb0Sopenharmony_ci 2802f4aeb0Sopenharmony_ci EGL Extension #56 2902f4aeb0Sopenharmony_ci 3002f4aeb0Sopenharmony_ciDependencies 3102f4aeb0Sopenharmony_ci 3202f4aeb0Sopenharmony_ci Requires EGL 1.2. 3302f4aeb0Sopenharmony_ci Requires EGL_KHR_stream extension 3402f4aeb0Sopenharmony_ci Requires EGL_KHR_reusable_sync 3502f4aeb0Sopenharmony_ci 3602f4aeb0Sopenharmony_ci This extension is written based on the wording of the EGL 1.2 3702f4aeb0Sopenharmony_ci specification. 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ciOverview 4002f4aeb0Sopenharmony_ci 4102f4aeb0Sopenharmony_ci This extension defines a new type of reusable sync object. This 4202f4aeb0Sopenharmony_ci sync object will be signaled each time a new image frame becomes 4302f4aeb0Sopenharmony_ci available in an EGLStream for the consumer to consume. 4402f4aeb0Sopenharmony_ci 4502f4aeb0Sopenharmony_ciNew functions 4602f4aeb0Sopenharmony_ci 4702f4aeb0Sopenharmony_ci EGLSyncKHR eglCreateStreamSyncNV( 4802f4aeb0Sopenharmony_ci EGLDisplay dpy, 4902f4aeb0Sopenharmony_ci EGLStreamKHR stream, 5002f4aeb0Sopenharmony_ci EGLenum type, 5102f4aeb0Sopenharmony_ci const EGLint *attrib_list); 5202f4aeb0Sopenharmony_ci 5302f4aeb0Sopenharmony_ciNew Tokens 5402f4aeb0Sopenharmony_ci 5502f4aeb0Sopenharmony_ci Accepted by the <type> parameter of eglCreateSyncKHR, and returned 5602f4aeb0Sopenharmony_ci in <value> when eglGetSyncAttribKHR is called with <attribute> 5702f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR: 5802f4aeb0Sopenharmony_ci 5902f4aeb0Sopenharmony_ci EGL_SYNC_NEW_FRAME_NV 0x321F 6002f4aeb0Sopenharmony_ci 6102f4aeb0Sopenharmony_ci 6202f4aeb0Sopenharmony_ciAdd a new paragraph to section "3.8.1 Sync Objects" in the 6302f4aeb0Sopenharmony_ciEGL_KHR_reusable_sync extension, just before the paragraph that 6402f4aeb0Sopenharmony_cimentions the eglClientWaitSyncKHR function: 6502f4aeb0Sopenharmony_ci 6602f4aeb0Sopenharmony_ci The command 6702f4aeb0Sopenharmony_ci 6802f4aeb0Sopenharmony_ci EGLSyncKHR eglCreateStreamSyncNV( 6902f4aeb0Sopenharmony_ci EGLDisplay dpy, 7002f4aeb0Sopenharmony_ci EGLStreamKHR stream, 7102f4aeb0Sopenharmony_ci EGLenum type, 7202f4aeb0Sopenharmony_ci const EGLint *attrib_list); 7302f4aeb0Sopenharmony_ci 7402f4aeb0Sopenharmony_ci creates a sync object of the specified <type> associated with the 7502f4aeb0Sopenharmony_ci specified display <dpy> and the specified EGLStream <stream>, and 7602f4aeb0Sopenharmony_ci returns a handle to the new object. <attrib_list> is an 7702f4aeb0Sopenharmony_ci attribute-value list specifying other attributes of the sync 7802f4aeb0Sopenharmony_ci object, terminated by an attribute entry EGL_NONE. Attributes not 7902f4aeb0Sopenharmony_ci specified in the list will be assigned their default values. The 8002f4aeb0Sopenharmony_ci state of <stream> must not be EGL_STREAM_STATE_CREATED_KHR or 8102f4aeb0Sopenharmony_ci EGL_STREAM_STATE_DISCONNECTED_KHR. 8202f4aeb0Sopenharmony_ci 8302f4aeb0Sopenharmony_ci If <type> is EGL_SYNC_NEW_FRAME_NV, a stream-new-frame reusable 8402f4aeb0Sopenharmony_ci sync object is created. In this case <attrib_list> must be NULL or 8502f4aeb0Sopenharmony_ci empty (containing only EGL_NONE). Attributes of the reusable 8602f4aeb0Sopenharmony_ci stream-new-frame sync object are set as follows: 8702f4aeb0Sopenharmony_ci 8802f4aeb0Sopenharmony_ci Attribute Name Initial Attribute Value(s) 8902f4aeb0Sopenharmony_ci --------------- -------------------------- 9002f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR EGL_SYNC_NEW_FRAME_NV 9102f4aeb0Sopenharmony_ci EGL_SYNC_STATUS_KHR EGL_UNSIGNALED_KHR 9202f4aeb0Sopenharmony_ci 9302f4aeb0Sopenharmony_ci Any time the state of <stream> transitions to 9402f4aeb0Sopenharmony_ci EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR (from any other state), 9502f4aeb0Sopenharmony_ci the returned stream-new-frame reusable sync object is signaled. 9602f4aeb0Sopenharmony_ci (This effectively means the sync object will become signaled 9702f4aeb0Sopenharmony_ci whenever the producer inserts a new image frame into the 9802f4aeb0Sopenharmony_ci EGLStream.) 9902f4aeb0Sopenharmony_ci 10002f4aeb0Sopenharmony_ci EGL does not automatically unsignal the stream-new-frame reusable 10102f4aeb0Sopenharmony_ci sync object. Generally applications will want to unsignal the 10202f4aeb0Sopenharmony_ci sync object after it has been signaled so that the availability 10302f4aeb0Sopenharmony_ci of the next frame can 10402f4aeb0Sopenharmony_ci be detected. 10502f4aeb0Sopenharmony_ci 10602f4aeb0Sopenharmony_ci Errors 10702f4aeb0Sopenharmony_ci ------ 10802f4aeb0Sopenharmony_ci 10902f4aeb0Sopenharmony_ci * If <dpy> is not the name of a valid, initialized EGLDisplay, 11002f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is 11102f4aeb0Sopenharmony_ci generated. 11202f4aeb0Sopenharmony_ci * If <attrib_list> is neither NULL nor empty (containing only 11302f4aeb0Sopenharmony_ci EGL_NONE), EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE 11402f4aeb0Sopenharmony_ci error is generated. 11502f4aeb0Sopenharmony_ci * If <stream> is not a valid EGLStream created for <dpy>, 11602f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR is returned and an EGL_BAD_STREAM error is 11702f4aeb0Sopenharmony_ci generated. 11802f4aeb0Sopenharmony_ci * If <stream>'s state is EGL_STREAM_STATE_CREATED_KHR or 11902f4aeb0Sopenharmony_ci EGL_STREAM_STATE_DISCONNECTED_KHR then EGL_NO_SYNC_KHR is 12002f4aeb0Sopenharmony_ci returned and an EGL_BAD_ACCESS error is generated. 12102f4aeb0Sopenharmony_ci * If a sync object of <type> has already been created for 12202f4aeb0Sopenharmony_ci <stream> (and not destroyed), EGL_NO_SYNC_KHR is returned and 12302f4aeb0Sopenharmony_ci an EGL_BAD_ACCESS error is generated. 12402f4aeb0Sopenharmony_ci * If <type> is not a supported type of stream sync object, 12502f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is 12602f4aeb0Sopenharmony_ci generated. 12702f4aeb0Sopenharmony_ci 12802f4aeb0Sopenharmony_ciIssues 12902f4aeb0Sopenharmony_ci 1. Is this extension useful, or does the built in blocking 13002f4aeb0Sopenharmony_ci behavior of the consumer described by the 13102f4aeb0Sopenharmony_ci EGL_NV_stream_consumer_gltexture extension render this 13202f4aeb0Sopenharmony_ci un-useful? 13302f4aeb0Sopenharmony_ci 13402f4aeb0Sopenharmony_ci RESOLVED: Yes. It is useful to have a thread waiting on the 13502f4aeb0Sopenharmony_ci signal. 13602f4aeb0Sopenharmony_ci 13702f4aeb0Sopenharmony_ci 2. Does EGL automatically unsignal the sync object? 13802f4aeb0Sopenharmony_ci 13902f4aeb0Sopenharmony_ci RESOLVED: No. After the sync object has been signaled, it is 14002f4aeb0Sopenharmony_ci up to the application to unsignal it before waiting on it 14102f4aeb0Sopenharmony_ci again. It is important to check for the availability of 14202f4aeb0Sopenharmony_ci another frame by querying EGL_PRODUCER_FRAME_KHR after 14302f4aeb0Sopenharmony_ci unsignaling the sync object and before waiting on the sync 14402f4aeb0Sopenharmony_ci object to prevent a race condition. This can be done using 14502f4aeb0Sopenharmony_ci the following code: 14602f4aeb0Sopenharmony_ci 14702f4aeb0Sopenharmony_ci void ConsumeFrames(EGLDisplay dpy, EGLStreamKHR stream) 14802f4aeb0Sopenharmony_ci { 14902f4aeb0Sopenharmony_ci EGLuint64KHR last_frame = 0; 15002f4aeb0Sopenharmony_ci EGLuint64KHR new_frame = 0; 15102f4aeb0Sopenharmony_ci EGLSyncKHR sync; 15202f4aeb0Sopenharmony_ci 15302f4aeb0Sopenharmony_ci sync = eglCreateStreamSyncNV(dpy, 15402f4aeb0Sopenharmony_ci stream, 15502f4aeb0Sopenharmony_ci EGL_SYNC_NEW_FRAME_NV, 15602f4aeb0Sopenharmony_ci 0); 15702f4aeb0Sopenharmony_ci 15802f4aeb0Sopenharmony_ci for(;;) { 15902f4aeb0Sopenharmony_ci eglSignalSyncKHR(dpy, sync, EGL_UNSIGNALED_KHR); 16002f4aeb0Sopenharmony_ci eglQueryStreamu64KHR(dpy, 16102f4aeb0Sopenharmony_ci stream, 16202f4aeb0Sopenharmony_ci EGL_PRODUCER_FRAME_KHR, 16302f4aeb0Sopenharmony_ci &new_frame); 16402f4aeb0Sopenharmony_ci if (new_frame != last_frame) { 16502f4aeb0Sopenharmony_ci last_frame = new_frame; 16602f4aeb0Sopenharmony_ci ConsumeNewFrame(stream); 16702f4aeb0Sopenharmony_ci } else { 16802f4aeb0Sopenharmony_ci eglClientWaitSyncKHR(dpy, sync, 0, EGL_FOREVER_KHR); 16902f4aeb0Sopenharmony_ci } 17002f4aeb0Sopenharmony_ci } 17102f4aeb0Sopenharmony_ci } 17202f4aeb0Sopenharmony_ci 17302f4aeb0Sopenharmony_ciRevision History 17402f4aeb0Sopenharmony_ci 17502f4aeb0Sopenharmony_ci #7 (July 10, 2013) Jon Leech 17602f4aeb0Sopenharmony_ci - Fix spelling of 'signalled' -> 'signaled' and assign extension 17702f4aeb0Sopenharmony_ci number for publication. 17802f4aeb0Sopenharmony_ci 17902f4aeb0Sopenharmony_ci #6 (June 5, 2012) Acorn Pooley 18002f4aeb0Sopenharmony_ci - Add error if stream is in state EGL_STREAM_STATE_CREATED_KHR 18102f4aeb0Sopenharmony_ci or EGL_STREAM_STATE_DISCONNECTED_KHR when sync is created. 18202f4aeb0Sopenharmony_ci 18302f4aeb0Sopenharmony_ci #5 (September 30, 2011) Acorn Pooley 18402f4aeb0Sopenharmony_ci - Change eglCreateStreamSyncKHR to eglCreateStreamSyncNV 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci #4 (September 28, 2011) Acorn Pooley 18702f4aeb0Sopenharmony_ci - Add issue 2 18802f4aeb0Sopenharmony_ci - Fix return type of eglCreateStreamSyncNV 18902f4aeb0Sopenharmony_ci 19002f4aeb0Sopenharmony_ci #3 (September 27, 2011) Acorn Pooley 19102f4aeb0Sopenharmony_ci - Assign enum values (bug 8064) 19202f4aeb0Sopenharmony_ci 19302f4aeb0Sopenharmony_ci #2 (July 6, 2011) Acorn Pooley 19402f4aeb0Sopenharmony_ci - Rename EGL_KHR_image_stream to EGL_KHR_stream 19502f4aeb0Sopenharmony_ci 19602f4aeb0Sopenharmony_ci #1 (June 30, 2011) Acorn Pooley 19702f4aeb0Sopenharmony_ci - Initial draft 19802f4aeb0Sopenharmony_ci 199