102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_display_reference 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_display_reference 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci James Jones 1202f4aeb0Sopenharmony_ci Daniel Kartch 1302f4aeb0Sopenharmony_ci 1402f4aeb0Sopenharmony_ciContacts 1502f4aeb0Sopenharmony_ci 1602f4aeb0Sopenharmony_ci James Jones, NVIDIA (jajones 'at' nvidia.com) 1702f4aeb0Sopenharmony_ci 1802f4aeb0Sopenharmony_ciStatus 1902f4aeb0Sopenharmony_ci 2002f4aeb0Sopenharmony_ci Complete 2102f4aeb0Sopenharmony_ci Ratified by the Khronos Board of Promoters on March 31, 2017. 2202f4aeb0Sopenharmony_ci 2302f4aeb0Sopenharmony_ciVersion 2402f4aeb0Sopenharmony_ci 2502f4aeb0Sopenharmony_ci Version 4 - March 15, 2018 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ciNumber 2802f4aeb0Sopenharmony_ci 2902f4aeb0Sopenharmony_ci EGL Extension #126 3002f4aeb0Sopenharmony_ci 3102f4aeb0Sopenharmony_ciExtension Type 3202f4aeb0Sopenharmony_ci 3302f4aeb0Sopenharmony_ci EGL client extension 3402f4aeb0Sopenharmony_ci 3502f4aeb0Sopenharmony_ciDependencies 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ci Written based on the wording of the EGL 1.5 specification. 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ci Requires EGL_EXT_platform_base or EGL 1.5 4002f4aeb0Sopenharmony_ci 4102f4aeb0Sopenharmony_ci Interacts with EGL platform extensions. 4202f4aeb0Sopenharmony_ci 4302f4aeb0Sopenharmony_ci Interacts with the EGL_EXT_device_query extension. 4402f4aeb0Sopenharmony_ci 4502f4aeb0Sopenharmony_ciOverview 4602f4aeb0Sopenharmony_ci 4702f4aeb0Sopenharmony_ci The existing semantics of EGLDisplay object lifetimes work well for 4802f4aeb0Sopenharmony_ci applications in which one module manages all EGL usage, and in which 4902f4aeb0Sopenharmony_ci EGL displays are expected to remain available until application 5002f4aeb0Sopenharmony_ci termination once they are instantiated. However, EGL does not 5102f4aeb0Sopenharmony_ci provide reasonable semantics in the case where applications rely on 5202f4aeb0Sopenharmony_ci toolkit libraries which use EGL independently from the application 5302f4aeb0Sopenharmony_ci itself. 5402f4aeb0Sopenharmony_ci 5502f4aeb0Sopenharmony_ci This issue can be solved by adding a per-EGLDisplay reference 5602f4aeb0Sopenharmony_ci counter which is incremented by eglInitialize calls. Resource 5702f4aeb0Sopenharmony_ci destruction can then be deferred until a corresponding number of 5802f4aeb0Sopenharmony_ci eglTerminate calls is made. However, switching to this behavior 5902f4aeb0Sopenharmony_ci universally could cause backwards incompatibility problems with 6002f4aeb0Sopenharmony_ci existing applications that assume a single eglTerminate will 6102f4aeb0Sopenharmony_ci immediately free resources regardless of how many times the display 6202f4aeb0Sopenharmony_ci has been initialized. 6302f4aeb0Sopenharmony_ci 6402f4aeb0Sopenharmony_ci We therefore must support both behaviors. A new attribute specified 6502f4aeb0Sopenharmony_ci when the EGLDisplay is obtained will indicate whether or not 6602f4aeb0Sopenharmony_ci reference counting is enabled. If an application requests the 6702f4aeb0Sopenharmony_ci EGLDisplay multiple times with different values for this attribute, 6802f4aeb0Sopenharmony_ci two separate displays will be returned. The one potential drawaback 6902f4aeb0Sopenharmony_ci is that these displays will have independent resource spaces, so 7002f4aeb0Sopenharmony_ci objects allocated from one cannot be used by the other. However, the 7102f4aeb0Sopenharmony_ci goal here is to support modules that access EGL independently. In 7202f4aeb0Sopenharmony_ci such a use case, they are not likely to need to share resources with 7302f4aeb0Sopenharmony_ci another module, particularly one that uses a different method for 7402f4aeb0Sopenharmony_ci accessing the display. 7502f4aeb0Sopenharmony_ci 7602f4aeb0Sopenharmony_ciNew Types 7702f4aeb0Sopenharmony_ci 7802f4aeb0Sopenharmony_ci None 7902f4aeb0Sopenharmony_ci 8002f4aeb0Sopenharmony_ciNew Functions 8102f4aeb0Sopenharmony_ci 8202f4aeb0Sopenharmony_ci EGLBoolean eglQueryDisplayAttribKHR(EGLDisplay dpy, 8302f4aeb0Sopenharmony_ci EGLint name, 8402f4aeb0Sopenharmony_ci EGLAttrib *value); 8502f4aeb0Sopenharmony_ci 8602f4aeb0Sopenharmony_ciNew Tokens 8702f4aeb0Sopenharmony_ci 8802f4aeb0Sopenharmony_ci Accepted as an attribute in the <attrib_list> parameter of 8902f4aeb0Sopenharmony_ci eglGetPlatformDisplay and the <name> parameter of 9002f4aeb0Sopenharmony_ci eglQueryDisplayAttribKHR: 9102f4aeb0Sopenharmony_ci 9202f4aeb0Sopenharmony_ci EGL_TRACK_REFERENCES_KHR 0x3352 9302f4aeb0Sopenharmony_ci 9402f4aeb0Sopenharmony_ciIn section "3.2 Initialization": 9502f4aeb0Sopenharmony_ci 9602f4aeb0Sopenharmony_ciRemove the sentence in the description of eglGetPlatformDisplay 9702f4aeb0Sopenharmony_ciindicating no valid attribute names are defined, and add the following: 9802f4aeb0Sopenharmony_ci 9902f4aeb0Sopenharmony_ci The EGL_TRACK_REFERENCES_KHR attribute may be set to EGL_TRUE or 10002f4aeb0Sopenharmony_ci EGL_FALSE to indicate whether or not an EGLDisplay that tracks 10102f4aeb0Sopenharmony_ci reference counts for eglInitialize and eglTerminate calls (as 10202f4aeb0Sopenharmony_ci described below) is desired. If not specified, the default is 10302f4aeb0Sopenharmony_ci platform dependent. Implementations are not required to support both 10402f4aeb0Sopenharmony_ci EGL_TRUE and EGL_FALSE for this attribute. If separate successful 10502f4aeb0Sopenharmony_ci calls are made to eglGetPlatformDisplay requesting default and non- 10602f4aeb0Sopenharmony_ci default behavior for reference counting, two independent EGLDisplays 10702f4aeb0Sopenharmony_ci will be returned. 10802f4aeb0Sopenharmony_ci 10902f4aeb0Sopenharmony_ciAlso add to the Errors section: 11002f4aeb0Sopenharmony_ci 11102f4aeb0Sopenharmony_ci An EGL_BAD_ATTRIBUTE error is generated if the requested value for 11202f4aeb0Sopenharmony_ci EGL_TRACK_REFERENCES_KHR is not supported. 11302f4aeb0Sopenharmony_ci 11402f4aeb0Sopenharmony_ciReplace the first sentence of the second paragraph of the description of 11502f4aeb0Sopenharmony_cieglInitialize with: 11602f4aeb0Sopenharmony_ci 11702f4aeb0Sopenharmony_ci When a previously uninitialized display is initialized, its 11802f4aeb0Sopenharmony_ci reference count will be set to one. Initializing an already- 11902f4aeb0Sopenharmony_ci initialized display is allowed, and will return EGL_TRUE and update 12002f4aeb0Sopenharmony_ci the EGL version numbers, but has no other effect except to increment 12102f4aeb0Sopenharmony_ci the display's reference count if its EGL_TRACK_REFERENCES_KHR 12202f4aeb0Sopenharmony_ci attribute is EGL_TRUE. 12302f4aeb0Sopenharmony_ci 12402f4aeb0Sopenharmony_ciInsert after the declaration of eglTerminate: 12502f4aeb0Sopenharmony_ci 12602f4aeb0Sopenharmony_ci If the specified display's EGL_TRACK_REFERENCES_KHR attribute is 12702f4aeb0Sopenharmony_ci EGL_FALSE, eglTerminate will immediately set its reference count 12802f4aeb0Sopenharmony_ci to zero. Otherwise, its reference count will be decremented if it 12902f4aeb0Sopenharmony_ci is above zero. When an initialized display's reference count reaches 13002f4aeb0Sopenharmony_ci zero, termination will occur. 13102f4aeb0Sopenharmony_ci 13202f4aeb0Sopenharmony_ciReplace the second sentence of the last paragraph with: 13302f4aeb0Sopenharmony_ci 13402f4aeb0Sopenharmony_ci All displays start out uninitialized with a reference count of zero. 13502f4aeb0Sopenharmony_ci 13602f4aeb0Sopenharmony_ciAdd to the end of section "3.3 EGL Queries". 13702f4aeb0Sopenharmony_ci 13802f4aeb0Sopenharmony_ci To query non-string attributes of an initialized display, use: 13902f4aeb0Sopenharmony_ci 14002f4aeb0Sopenharmony_ci EGLBoolean eglQueryDisplayAttribKHR(EGLDisplay dpy, 14102f4aeb0Sopenharmony_ci EGLint name, 14202f4aeb0Sopenharmony_ci EGLAttrib *value); 14302f4aeb0Sopenharmony_ci 14402f4aeb0Sopenharmony_ci On success, EGL_TRUE is returned, and the value of the attribute 14502f4aeb0Sopenharmony_ci specified by <name> is returned in the space pointed to by <value>. 14602f4aeb0Sopenharmony_ci 14702f4aeb0Sopenharmony_ci On failure, EGL_FALSE is returned. An EGL_NOT_INITIALIZED error 14802f4aeb0Sopenharmony_ci is generated if EGL is not initialized for <dpy>. An 14902f4aeb0Sopenharmony_ci EGL_BAD_ATTRIBUTE error is generated if <name> is not a valid 15002f4aeb0Sopenharmony_ci value. Currently, the only valid attribute name is 15102f4aeb0Sopenharmony_ci EGL_TRACK_REFERENCES_KHR. 15202f4aeb0Sopenharmony_ci 15302f4aeb0Sopenharmony_ciInteractions with EGL_KHR_platform_android: 15402f4aeb0Sopenharmony_ci 15502f4aeb0Sopenharmony_ci If eglGetPlatformDisplay() is called with <platform> set to 15602f4aeb0Sopenharmony_ci EGL_PLATFORM_ANDROID_KHR, the default value of 15702f4aeb0Sopenharmony_ci EGL_TRACK_REFERENCES_KHR is EGL_TRUE. 15802f4aeb0Sopenharmony_ci 15902f4aeb0Sopenharmony_ciInteractions with EGL_EXT_platform_device, EGL_KHR_platform_gbm, 16002f4aeb0Sopenharmony_ciEGL_KHR_platform_x11, and EGL_KHR_platform_wayland: 16102f4aeb0Sopenharmony_ci 16202f4aeb0Sopenharmony_ci If eglGetPlatformDisplay() is called with <platform> set to 16302f4aeb0Sopenharmony_ci EGL_PLATFORM_DEVICE_EXT, EGL_PLATFORM_GBM_KHR, EGL_PLATFORM_X11_KHR, 16402f4aeb0Sopenharmony_ci or EGL_PLATFORM_WAYLAND_KHR, the default value of 16502f4aeb0Sopenharmony_ci EGL_TRACK_REFERENCES_KHR is EGL_FALSE. 16602f4aeb0Sopenharmony_ci 16702f4aeb0Sopenharmony_ciInteractions with EGL_EXT_device_query: 16802f4aeb0Sopenharmony_ci 16902f4aeb0Sopenharmony_ci The eglQueryDisplayAttribKHR function defined here is equivalent to 17002f4aeb0Sopenharmony_ci eglQueryDisplayAttribEXT defined by EGL_EXT_device_query, and the 17102f4aeb0Sopenharmony_ci attribute names supported are a superset of those provided by both 17202f4aeb0Sopenharmony_ci extensions and any others which rely on them. 17302f4aeb0Sopenharmony_ci 17402f4aeb0Sopenharmony_ciIssues 17502f4aeb0Sopenharmony_ci 17602f4aeb0Sopenharmony_ci 1. What is the default value for EGL_TRACK_REFERENCES_KHR? 17702f4aeb0Sopenharmony_ci 17802f4aeb0Sopenharmony_ci RESOLUTION: For backwards compatibility reasons, the default 17902f4aeb0Sopenharmony_ci value is platform-specific. The Android platform has 18002f4aeb0Sopenharmony_ci historically implemented the behavior of 18102f4aeb0Sopenharmony_ci EGL_TRACK_REFERENCES_KHR = EGL_TRUE, while other platforms 18202f4aeb0Sopenharmony_ci defaulted to the opposite behavior. Application components 18302f4aeb0Sopenharmony_ci capable of supporting either behavior will be able to query 18402f4aeb0Sopenharmony_ci the value to determine how to proceed. 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci 2. Should the value of EGL_TRACK_REFERENCES_KHR affect whether 18702f4aeb0Sopenharmony_ci eglGetPlatformDisplay returns a new display handle or an 18802f4aeb0Sopenharmony_ci existing one given otherwise identical parameters? 18902f4aeb0Sopenharmony_ci 19002f4aeb0Sopenharmony_ci RESOLUTION: Yes. For any given combination of platform display 19102f4aeb0Sopenharmony_ci handle and other attributes, calling eglGetPlatformDisplay 19202f4aeb0Sopenharmony_ci with different values for EGL_TRACK_REFERENCES_KHR will result 19302f4aeb0Sopenharmony_ci in two different EGLDisplay handles being returned. 19402f4aeb0Sopenharmony_ci 19502f4aeb0Sopenharmony_ci Resources created with respect to one of these EGLDisplays will 19602f4aeb0Sopenharmony_ci not be accessible to the other. This restriction is unlikely to 19702f4aeb0Sopenharmony_ci cause issues, because the reference counting is added primarily 19802f4aeb0Sopenharmony_ci to support independent toolkits. Application components which 19902f4aeb0Sopenharmony_ci independently initialize and terminate the display are not 20002f4aeb0Sopenharmony_ci likely to share resources, particularly if they use different 20102f4aeb0Sopenharmony_ci methods for that initialization. 20202f4aeb0Sopenharmony_ci 20302f4aeb0Sopenharmony_ci 3. Should the new display attribute be queryable? 20402f4aeb0Sopenharmony_ci 20502f4aeb0Sopenharmony_ci RESOLUTION: Yes. Not all implemenations will support both TRUE 20602f4aeb0Sopenharmony_ci and FALSE for this attribute. Application components capable of 20702f4aeb0Sopenharmony_ci supporting either value will allow the default to be chosen, and 20802f4aeb0Sopenharmony_ci then query the value to determine how to handle termination. 20902f4aeb0Sopenharmony_ci 21002f4aeb0Sopenharmony_ci 4. Should implementations which support this extension be required 21102f4aeb0Sopenharmony_ci to support both TRUE and FALSE for the attribute? 21202f4aeb0Sopenharmony_ci 21302f4aeb0Sopenharmony_ci RESOLUTION: No. Lack of refcounting in the core specification is 21402f4aeb0Sopenharmony_ci considered by many to be a flaw, and some implementations/platforms 21502f4aeb0Sopenharmony_ci will choose to always provide refcounting behavior. This technically 21602f4aeb0Sopenharmony_ci makes them non-compliant. The addition of this extension should allow 21702f4aeb0Sopenharmony_ci that deviation. 21802f4aeb0Sopenharmony_ci 21902f4aeb0Sopenharmony_ciRevision History 22002f4aeb0Sopenharmony_ci 22102f4aeb0Sopenharmony_ci #4 (March 15, 2018) Jon Leech 22202f4aeb0Sopenharmony_ci 22302f4aeb0Sopenharmony_ci - Change extension number from 118 to 126 to avoid an accidental 22402f4aeb0Sopenharmony_ci collision. 22502f4aeb0Sopenharmony_ci 22602f4aeb0Sopenharmony_ci #3 (January 12, 2017) Daniel Kartch 22702f4aeb0Sopenharmony_ci 22802f4aeb0Sopenharmony_ci - Change to KHR. 22902f4aeb0Sopenharmony_ci - Allocate enum value. 23002f4aeb0Sopenharmony_ci 23102f4aeb0Sopenharmony_ci #2 (November 15, 2016) Daniel Kartch 23202f4aeb0Sopenharmony_ci 23302f4aeb0Sopenharmony_ci - Full termination portion split off into separate extension 23402f4aeb0Sopenharmony_ci EGL_XXX_full_termination. 23502f4aeb0Sopenharmony_ci - Update reference counting to have separate EGLDisplays for 23602f4aeb0Sopenharmony_ci the same native display, one with reference counting and 23702f4aeb0Sopenharmony_ci one without. 23802f4aeb0Sopenharmony_ci - Add query function to determine attribute value. 23902f4aeb0Sopenharmony_ci 24002f4aeb0Sopenharmony_ci #1 (October 28, 2014) James Jones 24102f4aeb0Sopenharmony_ci 24202f4aeb0Sopenharmony_ci - Initial draft as EGL_XXX_display_reference 243