102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_lock_surface2 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_lock_surface2 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Mark Callow 1202f4aeb0Sopenharmony_ci Gary King 1302f4aeb0Sopenharmony_ci Jon Leech 1402f4aeb0Sopenharmony_ci Marko Lukat 1502f4aeb0Sopenharmony_ci Alon Or-bach 1602f4aeb0Sopenharmony_ci Tim Renouf 1702f4aeb0Sopenharmony_ci 1802f4aeb0Sopenharmony_ciContacts 1902f4aeb0Sopenharmony_ci 2002f4aeb0Sopenharmony_ci Jon Leech (jon 'at' alumni.caltech.edu) 2102f4aeb0Sopenharmony_ci 2202f4aeb0Sopenharmony_ciNotice 2302f4aeb0Sopenharmony_ci 2402f4aeb0Sopenharmony_ci Copyright (c) 2006-2013 The Khronos Group Inc. Copyright terms at 2502f4aeb0Sopenharmony_ci http://www.khronos.org/registry/speccopyright.html 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ciStatus 2802f4aeb0Sopenharmony_ci 2902f4aeb0Sopenharmony_ci This extension is obsolete and has been replaced by 3002f4aeb0Sopenharmony_ci EGL_KHR_lock_surface3. Khronos recommends implementers who support this 3102f4aeb0Sopenharmony_ci extension also implement lock_surface3, and begin transitioning 3202f4aeb0Sopenharmony_ci developers to using that extension. See issue 21 for the reason. 3302f4aeb0Sopenharmony_ci 3402f4aeb0Sopenharmony_ci Complete. Version 2 approved by the Khronos Board of Promoters on 3502f4aeb0Sopenharmony_ci May 28, 2010. 3602f4aeb0Sopenharmony_ci Implemented by Antix Labs. 3702f4aeb0Sopenharmony_ci 3802f4aeb0Sopenharmony_ciVersion 3902f4aeb0Sopenharmony_ci 4002f4aeb0Sopenharmony_ci Version 3, December 4, 2013 4102f4aeb0Sopenharmony_ci 4202f4aeb0Sopenharmony_ciNumber 4302f4aeb0Sopenharmony_ci 4402f4aeb0Sopenharmony_ci EGL Extension #16 4502f4aeb0Sopenharmony_ci 4602f4aeb0Sopenharmony_ciDependencies 4702f4aeb0Sopenharmony_ci 4802f4aeb0Sopenharmony_ci Requires EGL 1.0 and EGL_KHR_lock_surface version 18. 4902f4aeb0Sopenharmony_ci 5002f4aeb0Sopenharmony_ci This extension is written against the wording of the EGL 1.3 5102f4aeb0Sopenharmony_ci and EGL 1.4 Specifications. Unless otherwise specified, each change 5202f4aeb0Sopenharmony_ci applies to both specifications. Unless otherwise specified, a page 5302f4aeb0Sopenharmony_ci number refers to the EGL 1.3 specification. 5402f4aeb0Sopenharmony_ci 5502f4aeb0Sopenharmony_ci This extension is written against the wording of EGL_KHR_lock_surface 5602f4aeb0Sopenharmony_ci version 18. 5702f4aeb0Sopenharmony_ci 5802f4aeb0Sopenharmony_ciOverview 5902f4aeb0Sopenharmony_ci 6002f4aeb0Sopenharmony_ci This extension slightly modifies and clarifies some semantic aspects 6102f4aeb0Sopenharmony_ci of the EGL_KHR_lock_surface extension, in a way that is backwards 6202f4aeb0Sopenharmony_ci compatible for applications. 6302f4aeb0Sopenharmony_ci 6402f4aeb0Sopenharmony_ci The extension is presented here as the full text of the 6502f4aeb0Sopenharmony_ci EGL_KHR_lock_surface extension (minus the Status, Version, Number and 6602f4aeb0Sopenharmony_ci Dependencies sections at the start) as modified by the changes made by 6702f4aeb0Sopenharmony_ci this EGL_KHR_lock_surface2 extension. A diff utility can be used between 6802f4aeb0Sopenharmony_ci EGL_KHR_lock_surface version 18 and this EGL_KHR_lock_surface2 extension 6902f4aeb0Sopenharmony_ci to show the exact changes. 7002f4aeb0Sopenharmony_ci 7102f4aeb0Sopenharmony_ci An application which needs to tell whether the implementation supports 7202f4aeb0Sopenharmony_ci EGL_KHR_lock_surface2, or just the original EGL_KHR_lock_surface, can 7302f4aeb0Sopenharmony_ci use eglQueryString with EGL_EXTENSIONS to query the list of 7402f4aeb0Sopenharmony_ci implemented extensions. 7502f4aeb0Sopenharmony_ci 7602f4aeb0Sopenharmony_ci The changes over EGL_KHR_lock_surface can be summarized as follows: 7702f4aeb0Sopenharmony_ci 7802f4aeb0Sopenharmony_ci * EGL_KHR_lock_surface had the EGL_MAP_PRESERVE_PIXELS_KHR attribute on 7902f4aeb0Sopenharmony_ci eglLockSurfaceKHR, but failed to point out how the surface attribute 8002f4aeb0Sopenharmony_ci EGL_SWAP_BEHAVIOR would interact with lock surface rendering. 8102f4aeb0Sopenharmony_ci EGL_KHR_lock_surface2 specifies that the locked buffer contains the 8202f4aeb0Sopenharmony_ci back buffer pixels if EGL_SWAP_BEHAVIOR is EGL_BUFFER_PRESERVED 8302f4aeb0Sopenharmony_ci _or_ if EGL_MAP_PRESERVE_PIXELS_KHR is EGL_TRUE, and provides a way to 8402f4aeb0Sopenharmony_ci set EGL_SWAP_BEHAVIOR on creation of a lockable window surface, 8502f4aeb0Sopenharmony_ci even if EGL_SWAP_BEHAVIOR is not otherwise modifiable. 8602f4aeb0Sopenharmony_ci EGL_SWAP_BEHAVIOR now defaults to EGL_BUFFER_PRESERVED for a 8702f4aeb0Sopenharmony_ci lockable surface. 8802f4aeb0Sopenharmony_ci 8902f4aeb0Sopenharmony_ci * EGL_KHR_lock_surface failed to specify its interaction with the 9002f4aeb0Sopenharmony_ci EGL requirement that a context be current at eglSwapBuffers; no 9102f4aeb0Sopenharmony_ci context is used for lock surface rendering. EGL_KHR_lock_surface2 9202f4aeb0Sopenharmony_ci relaxes that requirement for a lockable window surface, in a way 9302f4aeb0Sopenharmony_ci that is anticipated to apply to all window surfaces in a future 9402f4aeb0Sopenharmony_ci version of EGL. 9502f4aeb0Sopenharmony_ci 9602f4aeb0Sopenharmony_ci * Wording in EGL_KHR_lock_surface could be read to imply that almost 9702f4aeb0Sopenharmony_ci all surface attributes are invariant for a lockable surface. 9802f4aeb0Sopenharmony_ci EGL_KHR_lock_surface2 clarifies the wording. 9902f4aeb0Sopenharmony_ci 10002f4aeb0Sopenharmony_ci * EGL_KHR_lock_surface2 clarifies what is returned when 10102f4aeb0Sopenharmony_ci the attribute EGL_MATCH_FORMAT_KHR is queried, especially when 10202f4aeb0Sopenharmony_ci one of the "inexact" formats was used to choose the config. 10302f4aeb0Sopenharmony_ci 10402f4aeb0Sopenharmony_ci * EGL_KHR_lock_surface did not specify when a surface could change size. 10502f4aeb0Sopenharmony_ci EGL_KHR_lock_surface2 specifies that a surface cannot change size 10602f4aeb0Sopenharmony_ci when it is locked. 10702f4aeb0Sopenharmony_ci 10802f4aeb0Sopenharmony_ci * EGL_KHR_lock_surface2 adds the config attribute 10902f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_SIZE_KHR, to allow an application to dynamically 11002f4aeb0Sopenharmony_ci detect pixel layout for a format with a "hole", such as RGBU8888 11102f4aeb0Sopenharmony_ci (where "U" means "unused"). 11202f4aeb0Sopenharmony_ci 11302f4aeb0Sopenharmony_ciNew Tokens 11402f4aeb0Sopenharmony_ci 11502f4aeb0Sopenharmony_ci Accepted by the <attribute> parameter of eglQuerySurface: 11602f4aeb0Sopenharmony_ci 11702f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 11802f4aeb0Sopenharmony_ci 11902f4aeb0Sopenharmony_ciFull text of EGL_KHR_lock_surface plus EGL_KHR_lock_surface2: 12002f4aeb0Sopenharmony_ci 12102f4aeb0Sopenharmony_ciOverview 12202f4aeb0Sopenharmony_ci 12302f4aeb0Sopenharmony_ci This extension allows mapping color buffers of EGL surfaces into the 12402f4aeb0Sopenharmony_ci client address space. This is useful primarily for software 12502f4aeb0Sopenharmony_ci rendering on low-end devices which do not support EGL client 12602f4aeb0Sopenharmony_ci rendering APIs, although it may be implemented efficiently on more 12702f4aeb0Sopenharmony_ci capable devices as well. 12802f4aeb0Sopenharmony_ci 12902f4aeb0Sopenharmony_ciNew Types 13002f4aeb0Sopenharmony_ci 13102f4aeb0Sopenharmony_ci None 13202f4aeb0Sopenharmony_ci 13302f4aeb0Sopenharmony_ciNew Procedures and Functions 13402f4aeb0Sopenharmony_ci 13502f4aeb0Sopenharmony_ci EGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface, 13602f4aeb0Sopenharmony_ci const EGLint *attrib_list); 13702f4aeb0Sopenharmony_ci EGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, 13802f4aeb0Sopenharmony_ci EGLSurface surface); 13902f4aeb0Sopenharmony_ci 14002f4aeb0Sopenharmony_ciNew Tokens 14102f4aeb0Sopenharmony_ci 14202f4aeb0Sopenharmony_ci Returned in the EGL_SURFACE_TYPE bitmask attribute of EGLConfigs: 14302f4aeb0Sopenharmony_ci 14402f4aeb0Sopenharmony_ci EGL_LOCK_SURFACE_BIT_KHR 0x0080 14502f4aeb0Sopenharmony_ci EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 14602f4aeb0Sopenharmony_ci 14702f4aeb0Sopenharmony_ci Accepted as an attribute name in the <attrib_list> argument of 14802f4aeb0Sopenharmony_ci eglChooseConfig, and the <attribute> argument of eglGetConfigAttrib: 14902f4aeb0Sopenharmony_ci 15002f4aeb0Sopenharmony_ci EGL_MATCH_FORMAT_KHR 0x3043 15102f4aeb0Sopenharmony_ci 15202f4aeb0Sopenharmony_ci Accepted as attribute values for the EGL_MATCH_FORMAT_KHR attribute 15302f4aeb0Sopenharmony_ci of eglChooseConfig, and defined as possible values of that attribute 15402f4aeb0Sopenharmony_ci when querying it: 15502f4aeb0Sopenharmony_ci 15602f4aeb0Sopenharmony_ci EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 15702f4aeb0Sopenharmony_ci EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 15802f4aeb0Sopenharmony_ci 15902f4aeb0Sopenharmony_ci Accepted as attribute values for the EGL_MATCH_FORMAT_KHR attribute 16002f4aeb0Sopenharmony_ci of eglChooseConfig: 16102f4aeb0Sopenharmony_ci 16202f4aeb0Sopenharmony_ci EGL_FORMAT_RGB_565_KHR 0x30C1 16302f4aeb0Sopenharmony_ci EGL_FORMAT_RGBA_8888_KHR 0x30C3 16402f4aeb0Sopenharmony_ci 16502f4aeb0Sopenharmony_ci Accepted as attribute names in the <attrib_list> argument of 16602f4aeb0Sopenharmony_ci eglLockSurfaceKHR: 16702f4aeb0Sopenharmony_ci 16802f4aeb0Sopenharmony_ci EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 16902f4aeb0Sopenharmony_ci EGL_LOCK_USAGE_HINT_KHR 0x30C5 17002f4aeb0Sopenharmony_ci 17102f4aeb0Sopenharmony_ci Accepted as bit values in the EGL_LOCK_USAGE_HINT_KHR bitmask attribute 17202f4aeb0Sopenharmony_ci of eglLockSurfaceKHR: 17302f4aeb0Sopenharmony_ci 17402f4aeb0Sopenharmony_ci EGL_READ_SURFACE_BIT_KHR 0x0001 17502f4aeb0Sopenharmony_ci EGL_WRITE_SURFACE_BIT_KHR 0x0002 17602f4aeb0Sopenharmony_ci 17702f4aeb0Sopenharmony_ci Accepted by the <attribute> parameter of eglQuerySurface: 17802f4aeb0Sopenharmony_ci 17902f4aeb0Sopenharmony_ci EGL_BITMAP_POINTER_KHR 0x30C6 18002f4aeb0Sopenharmony_ci EGL_BITMAP_PITCH_KHR 0x30C7 18102f4aeb0Sopenharmony_ci EGL_BITMAP_ORIGIN_KHR 0x30C8 18202f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 18302f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA 18402f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB 18502f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC 18602f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD 18702f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 18802f4aeb0Sopenharmony_ci 18902f4aeb0Sopenharmony_ci Returns in the *<value> parameter of eglQuerySurface when 19002f4aeb0Sopenharmony_ci <attribute> is EGL_BITMAP_ORIGIN_KHR: 19102f4aeb0Sopenharmony_ci 19202f4aeb0Sopenharmony_ci EGL_LOWER_LEFT_KHR 0x30CE 19302f4aeb0Sopenharmony_ci EGL_UPPER_LEFT_KHR 0x30CF 19402f4aeb0Sopenharmony_ci 19502f4aeb0Sopenharmony_ciAdditions to Chapter 2 of the EGL 1.3 Specification (EGL Operation) 19602f4aeb0Sopenharmony_ci 19702f4aeb0Sopenharmony_ci Add to the end of section 2.2.2: 19802f4aeb0Sopenharmony_ci 19902f4aeb0Sopenharmony_ci Finally, some surfaces may be <locked>, which allows the 20002f4aeb0Sopenharmony_ci implementation to map buffers of that surface into client memory 20102f4aeb0Sopenharmony_ci for use by software renderers(fn). Locked surfaces cannot be 20202f4aeb0Sopenharmony_ci used for any other purpose. When a locked surface is <unlocked>, 20302f4aeb0Sopenharmony_ci any changes to the mapped buffer(s) are reflected in the actual 20402f4aeb0Sopenharmony_ci graphics or system memory containing the surface. 20502f4aeb0Sopenharmony_ci 20602f4aeb0Sopenharmony_ci [fn: on implementations not supporting mapping graphics 20702f4aeb0Sopenharmony_ci memory, or which do not wish to take the stability and 20802f4aeb0Sopenharmony_ci security risks that entail, mapping may be done using 20902f4aeb0Sopenharmony_ci copy-out and copy-in behavior.] 21002f4aeb0Sopenharmony_ci 21102f4aeb0Sopenharmony_ciAdditions to Chapter 3 of the EGL 1.3 Specification (EGL Functions and Errors) 21202f4aeb0Sopenharmony_ci 21302f4aeb0Sopenharmony_ci Add to the description of the EGL_BAD_ACCESS error in section 3.1: 21402f4aeb0Sopenharmony_ci 21502f4aeb0Sopenharmony_ci "... or, a surface is locked)." 21602f4aeb0Sopenharmony_ci 21702f4aeb0Sopenharmony_ci Add to table 3.2 ("Types of surfaces supported by an EGLConfig") 21802f4aeb0Sopenharmony_ci 21902f4aeb0Sopenharmony_ci EGL Token Name Description 22002f4aeb0Sopenharmony_ci -------------------- ------------------------------------ 22102f4aeb0Sopenharmony_ci EGL_LOCK_SURFACE_BIT_KHR EGLConfig allows locking surfaces 22202f4aeb0Sopenharmony_ci EGL_OPTIMAL_FORMAT_BIT_KHR This format is considered optimal 22302f4aeb0Sopenharmony_ci (preferred) when locking / mapping / 22402f4aeb0Sopenharmony_ci unlocking is being done. 22502f4aeb0Sopenharmony_ci 22602f4aeb0Sopenharmony_ci Change the first paragraph under "Other EGLConfig Attribute 22702f4aeb0Sopenharmony_ci Descriptions" on p. 16: 22802f4aeb0Sopenharmony_ci 22902f4aeb0Sopenharmony_ci "EGL_SURFACE_TYPE is a mask indicating both the surface types 23002f4aeb0Sopenharmony_ci that can be created by the corresponding EGLConfig (the config 23102f4aeb0Sopenharmony_ci is said to <support> those surface types), and the optional 23202f4aeb0Sopenharmony_ci behaviors such surfaces may allow. The valid bit settings are 23302f4aeb0Sopenharmony_ci shown in Table 3.2." 23402f4aeb0Sopenharmony_ci 23502f4aeb0Sopenharmony_ci Add a new paragraph following the second paragraph of the same 23602f4aeb0Sopenharmony_ci section: 23702f4aeb0Sopenharmony_ci 23802f4aeb0Sopenharmony_ci "If EGL_LOCK_SURFACE_BIT_KHR is set in EGL_SURFACE_TYPE, then 23902f4aeb0Sopenharmony_ci a surface created from the EGLConfig may be locked, mapped into 24002f4aeb0Sopenharmony_ci client memory, and unlocked. Locking is described in section 24102f4aeb0Sopenharmony_ci 3.5.6. If EGL_OPTIMAL_FORMAT_BIT_KHR is set in 24202f4aeb0Sopenharmony_ci EGL_SURFACE_TYPE, then the surface is considered optimal (by 24302f4aeb0Sopenharmony_ci the implementation) from a performance standpoint when buffer 24402f4aeb0Sopenharmony_ci mapping is being done." 24502f4aeb0Sopenharmony_ci 24602f4aeb0Sopenharmony_ci Replace the second paragraph of section 3.3 "EGL Versioning": 24702f4aeb0Sopenharmony_ci 24802f4aeb0Sopenharmony_ci "The EGL_CLIENT_APIS string describes which client rendering APIs 24902f4aeb0Sopenharmony_ci are supported. It is zero-terminated and contains a 25002f4aeb0Sopenharmony_ci space-separated list of API names, which may include 25102f4aeb0Sopenharmony_ci ``OpenGL_ES'' if OpenGL ES is supported, and ``OpenVG'' if 25202f4aeb0Sopenharmony_ci OpenVG is supported. If no client APIs are supported, then the 25302f4aeb0Sopenharmony_ci empty string is returned." 25402f4aeb0Sopenharmony_ci 25502f4aeb0Sopenharmony_ci Insert a new paragraph and table in section 3.4.1 "Querying 25602f4aeb0Sopenharmony_ci Configurations", following the description of 25702f4aeb0Sopenharmony_ci EGL_MATCH_NATIVE_PIXMAP on page 21: 25802f4aeb0Sopenharmony_ci 25902f4aeb0Sopenharmony_ci "If EGL_MATCH_FORMAT_KHR is specified in <attrib_list>, it must 26002f4aeb0Sopenharmony_ci be followed by one of the attribute values EGL_DONT_CARE, 26102f4aeb0Sopenharmony_ci EGL_NONE, or one of the format tokens in table 26202f4aeb0Sopenharmony_ci [locksurf.format]. 26302f4aeb0Sopenharmony_ci 26402f4aeb0Sopenharmony_ci When EGL_MATCH_FORMAT_KHR has the value EGL_NONE, only configs 26502f4aeb0Sopenharmony_ci which cannot be locked or mapped will match. Such configs must 26602f4aeb0Sopenharmony_ci not have the EGL_LOCK_SURFACE_BIT_KHR set in EGL_SURFACE_TYPE. 26702f4aeb0Sopenharmony_ci 26802f4aeb0Sopenharmony_ci When EGL_MATCH_FORMAT_KHR has the value EGL_DONT_CARE, it is 26902f4aeb0Sopenharmony_ci ignored. 27002f4aeb0Sopenharmony_ci 27102f4aeb0Sopenharmony_ci When EGL_MATCH_FORMAT_KHR has one of the values in table 27202f4aeb0Sopenharmony_ci [locksurf.format], only EGLConfigs describing surfaces whose 27302f4aeb0Sopenharmony_ci color buffers have the specified format, when mapped with 27402f4aeb0Sopenharmony_ci eglLockSurface, will match this attribute. In this case, the 27502f4aeb0Sopenharmony_ci EGL_<component>_SIZE attributes of resulting configs must agree 27602f4aeb0Sopenharmony_ci with the specific component sizes specified by the format." 27702f4aeb0Sopenharmony_ci 27802f4aeb0Sopenharmony_ci Specific Format Name Description 27902f4aeb0Sopenharmony_ci -------------------- ----------- 28002f4aeb0Sopenharmony_ci EGL_FORMAT_RGB_565_EXACT_KHR RGB565 fields in order from MSB to LSB within a 16-bit integer 28102f4aeb0Sopenharmony_ci EGL_FORMAT_RGB_565_KHR RGB565 fields in implementation-chosen order within a 16-bit integer 28202f4aeb0Sopenharmony_ci EGL_FORMAT_RGBA_8888_EXACT_KHR RGBA8888 fields in B, G, R, A byte order in memory 28302f4aeb0Sopenharmony_ci EGL_FORMAT_RGBA_8888_KHR RGBA8888 fields in implementation-chosen order within a 32-bit integer 28402f4aeb0Sopenharmony_ci ------------------------------------------------------------------------------------------------------ 28502f4aeb0Sopenharmony_ci Table [locksurf.format]: Specific formats for mapped pixels. 28602f4aeb0Sopenharmony_ci 28702f4aeb0Sopenharmony_ci Add to table 3.4 ("Default values and match critera for EGLConfig 28802f4aeb0Sopenharmony_ci attributes") on page 22: 28902f4aeb0Sopenharmony_ci 29002f4aeb0Sopenharmony_ci Attribute Default Selection Sort Sort 29102f4aeb0Sopenharmony_ci Criteria Order Priority 29202f4aeb0Sopenharmony_ci -------------------- ------------- --------- ----- -------- 29302f4aeb0Sopenharmony_ci EGL_MATCH_FORMAT_KHR EGL_DONT_CARE Exact None - 29402f4aeb0Sopenharmony_ci 29502f4aeb0Sopenharmony_ci Add EGL_MATCH_FORMAT_KHR to the last paragraph in section 3.4.1 on 29602f4aeb0Sopenharmony_ci p. 23, describing attributes not used for sorting EGLConfigs. 29702f4aeb0Sopenharmony_ci 29802f4aeb0Sopenharmony_ci Add a new paragraph to the end of section 3.4.3 "Querying Configuration 29902f4aeb0Sopenharmony_ci Attributes": 30002f4aeb0Sopenharmony_ci 30102f4aeb0Sopenharmony_ci "Querying the EGL_MATCH_FORMAT_KHR attribute results in EGL_NONE 30202f4aeb0Sopenharmony_ci for an EGLConfig that is not lockable, one of the "exact" formats 30302f4aeb0Sopenharmony_ci (EGL_FORMAT_RGB_565_EXACT_KHR, EGL_FORMAT_RGBA_8888_EXACT_KHR) 30402f4aeb0Sopenharmony_ci if the color buffer matches that format when mapped with 30502f4aeb0Sopenharmony_ci eglLockSurface, or for any other format a value that is not 30602f4aeb0Sopenharmony_ci EGL_NONE or EGL_DONT_CARE but is otherwise undefined. In particular, 30702f4aeb0Sopenharmony_ci the color buffer format matching one of the "inexact" formats 30802f4aeb0Sopenharmony_ci does not guarantee that that EGL_FORMAT_* value is returned." 30902f4aeb0Sopenharmony_ci 31002f4aeb0Sopenharmony_ci In section 3.5.1 "Creating On-Screen Rendering Surfaces", add the 31102f4aeb0Sopenharmony_ci following to the paragraph that lists the attributes that can be set 31202f4aeb0Sopenharmony_ci in attrib_list: 31302f4aeb0Sopenharmony_ci 31402f4aeb0Sopenharmony_ci "... and EGL_SWAP_BEHAVIOR." 31502f4aeb0Sopenharmony_ci 31602f4aeb0Sopenharmony_ci and add a new penultimate paragraph: 31702f4aeb0Sopenharmony_ci 31802f4aeb0Sopenharmony_ci "EGL_SWAP_BEHAVIOR specifies the initial value of the 31902f4aeb0Sopenharmony_ci EGL_SWAP_BEHAVIOR surface attribute (section 3.5.6), and is thus 32002f4aeb0Sopenharmony_ci either EGL_BUFFER_PRESERVED or EGL_BUFFER_DESTROYED. This setting 32102f4aeb0Sopenharmony_ci of EGL_SWAP_BEHAVIOR at surface creation time is supported only 32202f4aeb0Sopenharmony_ci for a lockable surface, i.e. where the EGLConfig has 32302f4aeb0Sopenharmony_ci EGL_LOCK_SURFACE_BIT_KHR set in EGL_SURFACE_TYPE." 32402f4aeb0Sopenharmony_ci 32502f4aeb0Sopenharmony_ci In EGL 1.4, also add the following text to that same paragraph: 32602f4aeb0Sopenharmony_ci 32702f4aeb0Sopenharmony_ci "For such a lockable surface, whether it is possible to change 32802f4aeb0Sopenharmony_ci the EGL_SWAP_BEHAVIOR attribute after surface creation is 32902f4aeb0Sopenharmony_ci determined by EGL_SWAP_BEHAVIOR_PRESERVED_BIT in the 33002f4aeb0Sopenharmony_ci EGL_SURFACE_TYPE EGLConfig attribute." 33102f4aeb0Sopenharmony_ci 33202f4aeb0Sopenharmony_ci Add a new section following the current section 3.5.5: 33302f4aeb0Sopenharmony_ci 33402f4aeb0Sopenharmony_ci "3.5.6 Locking and Mapping Rendering Surfaces 33502f4aeb0Sopenharmony_ci 33602f4aeb0Sopenharmony_ci A rendering surface may be <locked> by calling 33702f4aeb0Sopenharmony_ci 33802f4aeb0Sopenharmony_ci EGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, 33902f4aeb0Sopenharmony_ci EGLSurface surface, 34002f4aeb0Sopenharmony_ci const EGLint *attrib_list); 34102f4aeb0Sopenharmony_ci 34202f4aeb0Sopenharmony_ci While a surface is locked, only two operations can be performed 34302f4aeb0Sopenharmony_ci on it. First, a surface attribute may be queried using 34402f4aeb0Sopenharmony_ci eglQuerySurface. This includes the case of querying 34502f4aeb0Sopenharmony_ci EGL_BITMAP_POINTER_KHR, which causes the surface to be 34602f4aeb0Sopenharmony_ci <mapped> (if not already mapped) and gives 34702f4aeb0Sopenharmony_ci a pointer into client memory corresponding to the memory 34802f4aeb0Sopenharmony_ci of the mapped buffer. Second, the surface may be unlocked. Any 34902f4aeb0Sopenharmony_ci attempts to use a locked surface in other EGL APIs will fail and 35002f4aeb0Sopenharmony_ci generate an EGL_BAD_ACCESS error. 35102f4aeb0Sopenharmony_ci 35202f4aeb0Sopenharmony_ci While a surface is locked, its dimensions (the values of the EGL_WIDTH 35302f4aeb0Sopenharmony_ci and EGL_HEIGHT surface attributes) do not change. They may change 35402f4aeb0Sopenharmony_ci at any other time, therefore an application must query these 35502f4aeb0Sopenharmony_ci attributes <after> the call to eglLockSurfaceKHR to ensure that it has 35602f4aeb0Sopenharmony_ci the correct size of the mapped buffer. 35702f4aeb0Sopenharmony_ci 35802f4aeb0Sopenharmony_ci <attrib_list> specifies additional parameters affecting the locking 35902f4aeb0Sopenharmony_ci operation. The list has the same structure as described for 36002f4aeb0Sopenharmony_ci eglChooseConfig. Attributes that may be defined are shown in table 36102f4aeb0Sopenharmony_ci [locksurf.attr], together with their default values if not specified 36202f4aeb0Sopenharmony_ci in <attrib_list>, and possible values which may be specified for 36302f4aeb0Sopenharmony_ci them in <attrib_list>. 36402f4aeb0Sopenharmony_ci 36502f4aeb0Sopenharmony_ci Attribute Name Type Default Value Possible Values 36602f4aeb0Sopenharmony_ci ----------------------- ------- ------------- ------------------------- 36702f4aeb0Sopenharmony_ci EGL_MAP_PRESERVE_PIXELS_KHR boolean EGL_FALSE EGL_TRUE / EGL_FALSE 36802f4aeb0Sopenharmony_ci EGL_LOCK_USAGE_HINT_KHR bitmask EGL_READ_SURFACE_BIT_KHR | Any combination of 36902f4aeb0Sopenharmony_ci EGL_WRITE_SURFACE_BIT_KHR EGL_READ_SURFACE_BIT_KHR 37002f4aeb0Sopenharmony_ci and EGL_WRITE_SURFACE_BIT_KHR 37102f4aeb0Sopenharmony_ci -------------------------------------------------------------- 37202f4aeb0Sopenharmony_ci Table [locksurf.attr]: eglLockSurfaceKHR attribute names, 37302f4aeb0Sopenharmony_ci default values, and possible values. 37402f4aeb0Sopenharmony_ci 37502f4aeb0Sopenharmony_ci On failure, the surface is unaffected and eglLockSurfaceKHR 37602f4aeb0Sopenharmony_ci returns EGL_FALSE. An EGL_BAD_ACCESS error is generated if any 37702f4aeb0Sopenharmony_ci of these condition, are true: 37802f4aeb0Sopenharmony_ci 37902f4aeb0Sopenharmony_ci * <surface> was created with an EGLConfig whose 38002f4aeb0Sopenharmony_ci EGL_SURFACE_TYPE attribute does not contain 38102f4aeb0Sopenharmony_ci EGL_LOCK_SURFACE_BIT_KHR. 38202f4aeb0Sopenharmony_ci * <surface> is already locked. 38302f4aeb0Sopenharmony_ci * Any client API is current to <surface>. 38402f4aeb0Sopenharmony_ci 38502f4aeb0Sopenharmony_ci An EGL_BAD_ATTRIBUTE error is generated if an attribute or 38602f4aeb0Sopenharmony_ci attribute value not described in table [locksurf.attr] is 38702f4aeb0Sopenharmony_ci specified. 38802f4aeb0Sopenharmony_ci 38902f4aeb0Sopenharmony_ci Mapping Buffers of a Locked Surface 39002f4aeb0Sopenharmony_ci ----------------------------------- 39102f4aeb0Sopenharmony_ci 39202f4aeb0Sopenharmony_ci The color buffer of a locked surface can be <mapped> by calling 39302f4aeb0Sopenharmony_ci eglQuerySurface (see section 3.5.7) with <attribute> 39402f4aeb0Sopenharmony_ci EGL_BITMAP_POINTER_KHR(fn). The query returns a pointer to a 39502f4aeb0Sopenharmony_ci buffer in client memory corresponding to the color buffer of 39602f4aeb0Sopenharmony_ci <surface>. In the case of a back-buffered surface, color buffer 39702f4aeb0Sopenharmony_ci refers to the back buffer. 39802f4aeb0Sopenharmony_ci 39902f4aeb0Sopenharmony_ci [fn: "mapped" only means that the pointer returned is 40002f4aeb0Sopenharmony_ci intended to *correspond* to graphics memory. Implementation 40102f4aeb0Sopenharmony_ci are not required to return an actual pointer into graphics 40202f4aeb0Sopenharmony_ci memory, and often will not.] 40302f4aeb0Sopenharmony_ci 40402f4aeb0Sopenharmony_ci 40502f4aeb0Sopenharmony_ci The contents of the mapped buffer are initially undefined(fn) 40602f4aeb0Sopenharmony_ci unless either the EGL_MAP_PRESERVE_PIXELS_KHR attribute of 40702f4aeb0Sopenharmony_ci eglLockSurfaceKHR is set to EGL_TRUE, or (for a window surface) 40802f4aeb0Sopenharmony_ci the EGL_SWAP_BEHAVIOR surface attribute is set to 40902f4aeb0Sopenharmony_ci EGL_BUFFER_PRESERVE, in which case the contents 41002f4aeb0Sopenharmony_ci of the buffer are taken from the contents of <surface>'s color 41102f4aeb0Sopenharmony_ci buffer. The default value of EGL_MAP_PRESERVE_PIXELS_KHR is 41202f4aeb0Sopenharmony_ci EGL_FALSE. 41302f4aeb0Sopenharmony_ci 41402f4aeb0Sopenharmony_ci [fn: In order to avoid pipeline stalls and readback delays on 41502f4aeb0Sopenharmony_ci accelerated implementations, we do not mandate that the 41602f4aeb0Sopenharmony_ci current contents of a color buffer appear when it's mapped 41702f4aeb0Sopenharmony_ci to client memory, unless the EGL_MAP_PRESERVE_PIXELS_KHR 41802f4aeb0Sopenharmony_ci flag is set or (for a window surface) EGL_SWAP_BEHAVIOR is 41902f4aeb0Sopenharmony_ci set to EGL_BUFFER_PRESERVE. Applications using mapped 42002f4aeb0Sopenharmony_ci buffers which are not 42102f4aeb0Sopenharmony_ci preserved must write to every pixel of the buffer before 42202f4aeb0Sopenharmony_ci unlocking the surface. This constraint is considered 42302f4aeb0Sopenharmony_ci acceptable for the intended usage scenario (full-frame 42402f4aeb0Sopenharmony_ci software renderers). Such an application may lock-render-unlock 42502f4aeb0Sopenharmony_ci multiple times per frame (i.e. per eglSwapBuffers) by setting 42602f4aeb0Sopenharmony_ci EGL_MAP_PRESERVE_PIXELS_KHR to EGL_TRUE for the second and 42702f4aeb0Sopenharmony_ci subsequent locks. 42802f4aeb0Sopenharmony_ci 42902f4aeb0Sopenharmony_ci Note that EGL_SWAP_BEHAVIOR also controls whether the color 43002f4aeb0Sopenharmony_ci buffer contents are preserved over a call to eglSwapBuffers.] 43102f4aeb0Sopenharmony_ci 43202f4aeb0Sopenharmony_ci The EGL_LOCK_USAGE_HINT_KHR attribute of eglLockSurfaceKHR is a 43302f4aeb0Sopenharmony_ci bitmask describing the intended use of the mapped buffer. If the 43402f4aeb0Sopenharmony_ci mask contains EGL_READ_SURFACE_BIT_KHR, data will be read from 43502f4aeb0Sopenharmony_ci the mapped buffer. If the mask contains 43602f4aeb0Sopenharmony_ci EGL_WRITE_SURFACE_BIT_KHR, data will be written to the mapped 43702f4aeb0Sopenharmony_ci buffer. Implementations must support both reading and writing to 43802f4aeb0Sopenharmony_ci a mapped buffer regardless of the value of 43902f4aeb0Sopenharmony_ci EGL_LOCK_USAGE_HINT_KHR, but performance may be better if the 44002f4aeb0Sopenharmony_ci hint is consistent with the actual usage of the buffer. The 44102f4aeb0Sopenharmony_ci default value of EGL_LOCK_USAGE_HINT_KHR hints that both reads 44202f4aeb0Sopenharmony_ci and writes to the mapped buffer will be done. 44302f4aeb0Sopenharmony_ci 44402f4aeb0Sopenharmony_ci Other attributes of the mapped buffer describe the format of 44502f4aeb0Sopenharmony_ci pixels it contains, including its pitch (EGL_BITMAP_PITCH_KHR), 44602f4aeb0Sopenharmony_ci origin (EGL_BITMAP_ORIGIN_KHR), and the bit location of each color 44702f4aeb0Sopenharmony_ci component within a pixel (EGL_BITMAP_PIXEL_x_OFFSET_KHR). These 44802f4aeb0Sopenharmony_ci attributes may be queried using eglQuerySurface, and are described 44902f4aeb0Sopenharmony_ci in more detail in section 3.5.7. 45002f4aeb0Sopenharmony_ci 45102f4aeb0Sopenharmony_ci The EGL_BITMAP_POINTER_KHR and EGL_BITMAP_PITCH_KHR attributes 45202f4aeb0Sopenharmony_ci of a locked surface may change following successive calls to 45302f4aeb0Sopenharmony_ci eglLockSurfaceKHR(fn), so they must be queried each time a 45402f4aeb0Sopenharmony_ci buffer is mapped. Other attributes of a mapped buffer (listed in 45502f4aeb0Sopenharmony_ci the paragraph above) are invariant and need be queried only once 45602f4aeb0Sopenharmony_ci following surface creation. 45702f4aeb0Sopenharmony_ci 45802f4aeb0Sopenharmony_ci [fn: The pointer and pitch of a mapped buffer may change due 45902f4aeb0Sopenharmony_ci to display mode changes, for example.] 46002f4aeb0Sopenharmony_ci 46102f4aeb0Sopenharmony_ci Mapping will not suceed if client memory to map the surface into 46202f4aeb0Sopenharmony_ci cannot be allocated. In this case, querying eglQuerySurface with 46302f4aeb0Sopenharmony_ci <attribute> EGL_BITMAP_POINTER_KHR will fail and generate an EGL 46402f4aeb0Sopenharmony_ci error. 46502f4aeb0Sopenharmony_ci 46602f4aeb0Sopenharmony_ci Unlocking Surfaces 46702f4aeb0Sopenharmony_ci ------------------ 46802f4aeb0Sopenharmony_ci 46902f4aeb0Sopenharmony_ci A rendering surface may be <unlocked> by calling 47002f4aeb0Sopenharmony_ci 47102f4aeb0Sopenharmony_ci EGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, 47202f4aeb0Sopenharmony_ci EGLSurface surface); 47302f4aeb0Sopenharmony_ci 47402f4aeb0Sopenharmony_ci Any mapped buffers of <surface> become unmapped following 47502f4aeb0Sopenharmony_ci eglUnlockSurfaceKHR. Any changes made to mapped buffers of 47602f4aeb0Sopenharmony_ci <surface> which it was locked are reflected in the surface after 47702f4aeb0Sopenharmony_ci unlocking(fn). 47802f4aeb0Sopenharmony_ci 47902f4aeb0Sopenharmony_ci [fn: This language enables implementations to either map 48002f4aeb0Sopenharmony_ci video memory, or copy from a separate buffer in client 48102f4aeb0Sopenharmony_ci memory.] 48202f4aeb0Sopenharmony_ci 48302f4aeb0Sopenharmony_ci If <surface> was created with an EGLConfig whose 48402f4aeb0Sopenharmony_ci EGL_SURFACE_TYPE attribute contains EGL_OPTIMAL_FORMAT_BIT_KHR, 48502f4aeb0Sopenharmony_ci then the surface is considered optimal (by the implementation) 48602f4aeb0Sopenharmony_ci from a performance standpoint when buffer mapping is being 48702f4aeb0Sopenharmony_ci done(fn). 48802f4aeb0Sopenharmony_ci 48902f4aeb0Sopenharmony_ci [fn: This often means that the format of all mapped buffers 49002f4aeb0Sopenharmony_ci corresponds directly to the format of those buffers in 49102f4aeb0Sopenharmony_ci <surface>, so no format conversions are required during 49202f4aeb0Sopenharmony_ci unmapping. This results in a high-performance software 49302f4aeb0Sopenharmony_ci rendering path. But "optimal format" is really just a hint 49402f4aeb0Sopenharmony_ci from EGL that this config is preferred, whatever the actual 49502f4aeb0Sopenharmony_ci reason.] 49602f4aeb0Sopenharmony_ci 49702f4aeb0Sopenharmony_ci On failure, eglUnlockSurfaceKHR returns EGL_FALSE. An 49802f4aeb0Sopenharmony_ci EGL_BAD_ACCESS error is generated if any of these conditions are 49902f4aeb0Sopenharmony_ci true: 50002f4aeb0Sopenharmony_ci 50102f4aeb0Sopenharmony_ci * <surface> is already unlocked. 50202f4aeb0Sopenharmony_ci * A display mode change occurred while the surface was locked, 50302f4aeb0Sopenharmony_ci and the implementation was unable to reflect mapped buffer 50402f4aeb0Sopenharmony_ci state(fn). In this case, <surface> will still be unlocked. 50502f4aeb0Sopenharmony_ci However, the contents of the previously mapped buffers of 50602f4aeb0Sopenharmony_ci <surface> become undefined, rather than reflecting changes 50702f4aeb0Sopenharmony_ci made in the mapped buffers in client memory. 50802f4aeb0Sopenharmony_ci 50902f4aeb0Sopenharmony_ci [fn: Usually this may only occur with window surfaces which 51002f4aeb0Sopenharmony_ci have been mapped. EGL does not have an event mechanism to 51102f4aeb0Sopenharmony_ci indicate display mode changes. If such a mechanism exists 51202f4aeb0Sopenharmony_ci (using native platform events or the OpenKODE event system), 51302f4aeb0Sopenharmony_ci applications should respond to mode changes by regenerating 51402f4aeb0Sopenharmony_ci all visible window content, including re-doing any software 51502f4aeb0Sopenharmony_ci rendering overlapping the mode change.]" 51602f4aeb0Sopenharmony_ci 51702f4aeb0Sopenharmony_ci Add to table 3.5 ("Queryable surface attributes and types") 51802f4aeb0Sopenharmony_ci 51902f4aeb0Sopenharmony_ci Attribute Type Description 52002f4aeb0Sopenharmony_ci --------- ---- ----------- 52102f4aeb0Sopenharmony_ci EGL_BITMAP_POINTER_KHR pointer Address of a mapped color buffer (MCB). 52202f4aeb0Sopenharmony_ci EGL_BITMAP_PITCH_KHR integer Number of bytes between the start of 52302f4aeb0Sopenharmony_ci adjacent rows in an MCB. 52402f4aeb0Sopenharmony_ci EGL_BITMAP_ORIGIN_KHR enum Bitmap origin & direction 52502f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_x_OFFSET_KHR integer Bit location of each color buffer 52602f4aeb0Sopenharmony_ci component within a pixel in an MCB. 52702f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_SIZE_KHR integer Bits per pixel 52802f4aeb0Sopenharmony_ci 52902f4aeb0Sopenharmony_ci In EGL 1.4 only, in the description of eglSurfaceAttrib properties 53002f4aeb0Sopenharmony_ci that can be set in section 3.5.6 (renumbered to 3.5.7), on page 35, 53102f4aeb0Sopenharmony_ci add to the first paragraph describing EGL_SWAP_BEHAVIOR: 53202f4aeb0Sopenharmony_ci 53302f4aeb0Sopenharmony_ci "The value of EGL_SWAP_BEHAVIOR also affects the semantics of 53402f4aeb0Sopenharmony_ci eglLockSurfaceKHR for a lockable window surface. See section 3.5.6." 53502f4aeb0Sopenharmony_ci 53602f4aeb0Sopenharmony_ci In EGL 1.4 only, in the description of eglSurfaceAttrib properties 53702f4aeb0Sopenharmony_ci that can be set in section 3.5.6 (renumbered to 3.5.7), on page 35, 53802f4aeb0Sopenharmony_ci change the paragraph concerning the initial value of EGL_SWAP_BEHAVIOR 53902f4aeb0Sopenharmony_ci to: 54002f4aeb0Sopenharmony_ci 54102f4aeb0Sopenharmony_ci "The initial value of EGL_SWAP_BEHAVIOR is chosen by the 54202f4aeb0Sopenharmony_ci implementation, except for a lockable window surface (i.e. where the 54302f4aeb0Sopenharmony_ci EGLConfig has both EGL_LOCK_SURFACE_BIT_KHR and EGL_WINDOW_BIT set in 54402f4aeb0Sopenharmony_ci EGL_SURFACE_TYPE), where the default is EGL_BUFFER_PRESERVED, but it 54502f4aeb0Sopenharmony_ci may be overridden by specifying EGL_SWAP_BEHAVIOR to 54602f4aeb0Sopenharmony_ci eglCreateWindowSurface." 54702f4aeb0Sopenharmony_ci 54802f4aeb0Sopenharmony_ci In EGL 1.3 only, in the description of eglQuerySurface properties 54902f4aeb0Sopenharmony_ci that can be queried in section 3.5.6 (renumbered to 3.5.7), on page 33, 55002f4aeb0Sopenharmony_ci add to the paragraph describing EGL_SWAP_BEHAVIOR: 55102f4aeb0Sopenharmony_ci 55202f4aeb0Sopenharmony_ci "The value of EGL_SWAP_BEHAVIOR also affects the semantics of 55302f4aeb0Sopenharmony_ci eglLockSurfaceKHR for a lockable window surface. See section 3.5.6. 55402f4aeb0Sopenharmony_ci For a lockable window surface (one whose EGLConfig has both 55502f4aeb0Sopenharmony_ci EGL_LOCK_SURFACE_BIT_KHR and EGL_WINDOW_BIT set in EGL_SURFACE_TYPE), 55602f4aeb0Sopenharmony_ci the value of this attribute may be set in the eglCreateWindowSurface 55702f4aeb0Sopenharmony_ci call, and if not set there defaults to EGL_BUFFER_PRESERVED. See 55802f4aeb0Sopenharmony_ci section 3.5.1. The default for a non-lockable surface is chosen by the 55902f4aeb0Sopenharmony_ci implementation." 56002f4aeb0Sopenharmony_ci 56102f4aeb0Sopenharmony_ci Add to the description of eglQuerySurface properties in section 56202f4aeb0Sopenharmony_ci 3.5.6 (renumbered to 3.5.7) on page 33: 56302f4aeb0Sopenharmony_ci 56402f4aeb0Sopenharmony_ci "Properties of a bitmap surface which may be queried include: 56502f4aeb0Sopenharmony_ci * EGL_BITMAP_POINTER_KHR, which maps the color buffer of a 56602f4aeb0Sopenharmony_ci locked surface and returns the address in client memory of 56702f4aeb0Sopenharmony_ci the mapped buffer. 56802f4aeb0Sopenharmony_ci * EGL_BITMAP_PITCH_KHR, which returns the number of bytes 56902f4aeb0Sopenharmony_ci between successive rows of a mapped buffer. 57002f4aeb0Sopenharmony_ci * EGL_BITMAP_ORIGIN_KHR, which describes the way in which a 57102f4aeb0Sopenharmony_ci mapped color buffer is displayed on the screen. Possible 57202f4aeb0Sopenharmony_ci values are either EGL_LOWER_LEFT_KHR or EGL_UPPER_LEFT_KHR, 57302f4aeb0Sopenharmony_ci indicating that the first pixel of the mapped buffer 57402f4aeb0Sopenharmony_ci corresponds to the lower left or upper left of a visible 57502f4aeb0Sopenharmony_ci window, respectively. 57602f4aeb0Sopenharmony_ci * EGL_BITMAP_PIXEL_<x>_OFFSET_KHR, which describes the bit 57702f4aeb0Sopenharmony_ci location of the least significant bit of each color 57802f4aeb0Sopenharmony_ci component of a pixel within a mapped buffer. <x> is one of 57902f4aeb0Sopenharmony_ci RED, GREEN, BLUE, ALPHA, or LUMINANCE. 58002f4aeb0Sopenharmony_ci 58102f4aeb0Sopenharmony_ci The offset for a color component should be treated as the 58202f4aeb0Sopenharmony_ci number of bits to left shift the component value to place it 58302f4aeb0Sopenharmony_ci within a n-bit 58402f4aeb0Sopenharmony_ci integer containing the pixel, where n is the number of bits 58502f4aeb0Sopenharmony_ci per pixel. If a color 58602f4aeb0Sopenharmony_ci component does not exist in the mapped buffer, then the bit 58702f4aeb0Sopenharmony_ci offset of that component is zero. If a color component 58802f4aeb0Sopenharmony_ci does exist but not in a single contiguous range of bits, 58902f4aeb0Sopenharmony_ci then the value of the attribute is EGL_UNKNOWN. 59002f4aeb0Sopenharmony_ci 59102f4aeb0Sopenharmony_ci * EGL_BITMAP_PIXEL_SIZE_KHR, which returns the number of bits 59202f4aeb0Sopenharmony_ci per pixel, assumed to be least significant leftmost if there 59302f4aeb0Sopenharmony_ci are multiple pixels per byte. The attribute takes the value 59402f4aeb0Sopenharmony_ci EGL_UNKNOWN if this assumption is not true, or if pixels are not 59502f4aeb0Sopenharmony_ci laid out left to right in memory (for example pairs of 16-bit 59602f4aeb0Sopenharmony_ci pixels are swapped in memory). 59702f4aeb0Sopenharmony_ci 59802f4aeb0Sopenharmony_ci In addition to these attributes, the number of bits for each 59902f4aeb0Sopenharmony_ci color component of a pixel within a mapped buffer is obtained by 60002f4aeb0Sopenharmony_ci querying the EGL_<x>_SIZE attribute of the EGLConfig used to 60102f4aeb0Sopenharmony_ci create the surface, where <x> is <x> is one of RED, GREEN, BLUE, 60202f4aeb0Sopenharmony_ci ALPHA, or LUMINANCE. 60302f4aeb0Sopenharmony_ci 60402f4aeb0Sopenharmony_ci Querying EGL_BITMAP_POINTER_KHR and EGL_BITMAP_PITCH_KHR is only 60502f4aeb0Sopenharmony_ci allowed when <surface> is mapped (see section 3.5.6). Querying 60602f4aeb0Sopenharmony_ci either of these attributes for the first time after calling 60702f4aeb0Sopenharmony_ci eglLockSurfaceKHR causes the color buffer of the locked surface 60802f4aeb0Sopenharmony_ci to be mapped. Querying them again before unlocking the surface 60902f4aeb0Sopenharmony_ci will return the same values as the first time. However, after 61002f4aeb0Sopenharmony_ci calling eglUnlockSurfaceKHR, these properties become undefined. 61102f4aeb0Sopenharmony_ci After a second call to eglLockSurfaceKHR, these properties may 61202f4aeb0Sopenharmony_ci again be queried, but their values may have changed. 61302f4aeb0Sopenharmony_ci 61402f4aeb0Sopenharmony_ci Other properties of the mapped color buffer of a surface 61502f4aeb0Sopenharmony_ci (in the list above) are 61602f4aeb0Sopenharmony_ci invariant, and need be queried only once following surface 61702f4aeb0Sopenharmony_ci creation. If <surface> was created with an EGLConfig whose 61802f4aeb0Sopenharmony_ci EGL_SURFACE_TYPE attribute does not contain 61902f4aeb0Sopenharmony_ci EGL_LOCK_SURFACE_BIT_KHR, queries of EGL_BITMAP_ORIGIN_KHR, 62002f4aeb0Sopenharmony_ci EGL_BITMAP_PIXEL_<x>_OFFSET_KHR and EGL_BITMAP_PIXEL_SIZE_KHR 62102f4aeb0Sopenharmony_ci return undefined values." 62202f4aeb0Sopenharmony_ci 62302f4aeb0Sopenharmony_ci Add to the description of eglQuerySurface errors in the last 62402f4aeb0Sopenharmony_ci paragraph of section 3.5.6 (renumbered to 3.5.7) on page 34: 62502f4aeb0Sopenharmony_ci 62602f4aeb0Sopenharmony_ci "... If <attribute> is either EGL_BITMAP_POINTER_KHR or 62702f4aeb0Sopenharmony_ci EGL_BITMAP_PITCH_KHR, and either <surface> is not locked using 62802f4aeb0Sopenharmony_ci eglLockSurfaceKHR, or <surface> is locked but mapping fails, 62902f4aeb0Sopenharmony_ci then an EGL_BAD_ACCESS error is generated." 63002f4aeb0Sopenharmony_ci 63102f4aeb0Sopenharmony_ci In section 3.9.3 Posting Semantics on page 46, append to the first 63202f4aeb0Sopenharmony_ci paragraph: 63302f4aeb0Sopenharmony_ci 63402f4aeb0Sopenharmony_ci "This restriction does not apply to lockable surfaces; for such 63502f4aeb0Sopenharmony_ci a surface, eglSwapBuffers and eglCopyBuffers may be called for 63602f4aeb0Sopenharmony_ci a surface not bound to any client API context(fn). 63702f4aeb0Sopenharmony_ci 63802f4aeb0Sopenharmony_ci [fn: Normally this would only be done when using methods other 63902f4aeb0Sopenharmony_ci than client API rendering to specify the color buffer contents, 64002f4aeb0Sopenharmony_ci such as software rendering to a locked surface.]" 64102f4aeb0Sopenharmony_ci 64202f4aeb0Sopenharmony_ci and replace the second paragraph ("If <dpy> and <surface> ... not be 64302f4aeb0Sopenharmony_ci executed until posting is completed.") with: 64402f4aeb0Sopenharmony_ci 64502f4aeb0Sopenharmony_ci "If <surface> is bound to a current client API context for the calling 64602f4aeb0Sopenharmony_ci thread, eglSwapBuffers and eglCopyBuffers perform an implicit flush 64702f4aeb0Sopenharmony_ci operation on the context (glFlush for an OpenGL or OpenGL ES context, 64802f4aeb0Sopenharmony_ci vgFlush for an OpenVG context). Subsequent client API commands can be 64902f4aeb0Sopenharmony_ci issued immediately, but will not be executed until posting is 65002f4aeb0Sopenharmony_ci completed. 65102f4aeb0Sopenharmony_ci 65202f4aeb0Sopenharmony_ci If <surface> is current to a client API context in any thread other 65302f4aeb0Sopenharmony_ci than the calling thread, eglSwapBuffers and eglCopyBuffers will fail. 65402f4aeb0Sopenharmony_ci 65502f4aeb0Sopenharmony_ci and append the following sentence to the eglSwapInterval paragraph: 65602f4aeb0Sopenharmony_ci 65702f4aeb0Sopenharmony_ci "The swap interval has no effect on an eglSwapBuffers for a surface 65802f4aeb0Sopenharmony_ci not bound to a current client API context." 65902f4aeb0Sopenharmony_ci 66002f4aeb0Sopenharmony_ci In 3.9.4 Posting Errors, change the sentence "If <surface> is not bound 66102f4aeb0Sopenharmony_ci to the calling thread's current context, an EGL_BAD_SURFACE error is 66202f4aeb0Sopenharmony_ci generated." to: 66302f4aeb0Sopenharmony_ci 66402f4aeb0Sopenharmony_ci "If <surface> is bound to a current context in a thread other 66502f4aeb0Sopenharmony_ci than the calling thread, an EGL_BAD_SURFACE error is generated." 66602f4aeb0Sopenharmony_ci 66702f4aeb0Sopenharmony_ci 66802f4aeb0Sopenharmony_ciIssues 66902f4aeb0Sopenharmony_ci 67002f4aeb0Sopenharmony_ci 1) What is the rationale for this extension? 67102f4aeb0Sopenharmony_ci 67202f4aeb0Sopenharmony_ci Software renderers on low-end implementations need an efficient way 67302f4aeb0Sopenharmony_ci to draw pixel data to the screen. High-end implementations must 67402f4aeb0Sopenharmony_ci support the same interface for compatibility, while not compromising 67502f4aeb0Sopenharmony_ci the accelerability of OpenGL ES and OpenVG client APIs using 67602f4aeb0Sopenharmony_ci dedicated graphics hardware and memory. 67702f4aeb0Sopenharmony_ci 67802f4aeb0Sopenharmony_ci Using lock/unlock semantics enables low-end implementations to 67902f4aeb0Sopenharmony_ci expose pointers directly into display memory (as extremely dangerous 68002f4aeb0Sopenharmony_ci as that may be), while high-end implementations may choose to create 68102f4aeb0Sopenharmony_ci backing store in client memory when mapping a buffer, and copy it to 68202f4aeb0Sopenharmony_ci graphics memory when the surface is unlocked. Making the initial 68302f4aeb0Sopenharmony_ci contents of a mapped buffer undefined means that no readbacks from 68402f4aeb0Sopenharmony_ci graphics memory are required, avoiding pipeline stalls. 68502f4aeb0Sopenharmony_ci 68602f4aeb0Sopenharmony_ci This extension is not intended to support mixed-mode (client API and 68702f4aeb0Sopenharmony_ci software) rendering. Since mapped buffer contents are undefined, 68802f4aeb0Sopenharmony_ci unless the buffer is explicitly preserved (which may be unacceptably 68902f4aeb0Sopenharmony_ci expensive on many implementations), applications doing software 69002f4aeb0Sopenharmony_ci rendering must touch every pixel of mapped buffers at least once 69102f4aeb0Sopenharmony_ci before unlocking the surface. 69202f4aeb0Sopenharmony_ci 69302f4aeb0Sopenharmony_ci 2) Do we need to know if locked surfaces are "fast" or "native"? 69402f4aeb0Sopenharmony_ci 69502f4aeb0Sopenharmony_ci RESOLVED: Yes. This is indicated with the EGL_OPTIMAL_FORMAT_BIT_KHR 69602f4aeb0Sopenharmony_ci of EGL_SURFACE_TYPE. However, note that there is no way to guarantee 69702f4aeb0Sopenharmony_ci what "fast" or "no format conversions" really means; this is little 69802f4aeb0Sopenharmony_ci more than an implementation hint. 69902f4aeb0Sopenharmony_ci 70002f4aeb0Sopenharmony_ci 3) Should we be able to map buffers other than the color buffer? 70102f4aeb0Sopenharmony_ci 70202f4aeb0Sopenharmony_ci RESOLVED: Not initially. However, the <attrib_list> parameter of 70302f4aeb0Sopenharmony_ci eglLockSurfaceKHR supports this in the future. There is no <buffer> 70402f4aeb0Sopenharmony_ci attribute to eglQuerySurface, so such a layered extension would have 70502f4aeb0Sopenharmony_ci to either create a new naming convention (such as 70602f4aeb0Sopenharmony_ci EGL_BITMAP_{DEPTH,COLOR,STENCIL,ALPHA_MASK}_POINTER), or define an 70702f4aeb0Sopenharmony_ci extended query eglQuerySurfaceBuffer() which takes a <buffer> 70802f4aeb0Sopenharmony_ci parameter. It would also be tricky to support interleaved depth / 70902f4aeb0Sopenharmony_ci stencil formats. But the attribute list offers some future-proofing 71002f4aeb0Sopenharmony_ci at low cost. 71102f4aeb0Sopenharmony_ci 71202f4aeb0Sopenharmony_ci 4) What properties of mapped buffers can be queried? 71302f4aeb0Sopenharmony_ci 71402f4aeb0Sopenharmony_ci RESOLVED: A pointer to the buffer and its pitch, both of which may 71502f4aeb0Sopenharmony_ci change in successive lock/unlock cycles. These may be queried only 71602f4aeb0Sopenharmony_ci while the underlying surface is locked, and are undefined after 71702f4aeb0Sopenharmony_ci unlocking. The first query following locking is the point at which 71802f4aeb0Sopenharmony_ci actual buffer mapping must occur. 71902f4aeb0Sopenharmony_ci 72002f4aeb0Sopenharmony_ci RESOLVED: Additionally, the pixel size, origin, and color component 72102f4aeb0Sopenharmony_ci bitfield size and offset for each component, which are invariant 72202f4aeb0Sopenharmony_ci and may be queried at any time. 72302f4aeb0Sopenharmony_ci 72402f4aeb0Sopenharmony_ci 5) How are mode changes indicated? What happens to the mapped 72502f4aeb0Sopenharmony_ci buffer during a mode change? 72602f4aeb0Sopenharmony_ci 72702f4aeb0Sopenharmony_ci RESOLVED: UnlockSurfaceKHR fails and raises an error if a mode 72802f4aeb0Sopenharmony_ci change occurred while the surface was locked (although the surface 72902f4aeb0Sopenharmony_ci still ends up in the unlocked state - this is necessary since 73002f4aeb0Sopenharmony_ci there's no way to clear the error!). If a mode change occurs while a 73102f4aeb0Sopenharmony_ci buffer is mapped, the implementation must still allow the 73202f4aeb0Sopenharmony_ci application to access mapped buffer memory, even though the contents 73302f4aeb0Sopenharmony_ci of the mapped buffer may not be reflected in the changed window 73402f4aeb0Sopenharmony_ci after unmapping. 73502f4aeb0Sopenharmony_ci 73602f4aeb0Sopenharmony_ci Note: There's no convenient way to indicate mode changes while 73702f4aeb0Sopenharmony_ci a surface is unlocked, despite that being useful to tell apps they 73802f4aeb0Sopenharmony_ci have to redraw. The problem is that we don't have an event system, 73902f4aeb0Sopenharmony_ci and the power management functionality is overkill since the only 74002f4aeb0Sopenharmony_ci resources which are likely to be damaged by a mode change are 74102f4aeb0Sopenharmony_ci visible window contents. Fortunately, this problem is beyond the 74202f4aeb0Sopenharmony_ci scope of this extension. 74302f4aeb0Sopenharmony_ci 74402f4aeb0Sopenharmony_ci 6) Does locking a surface imply mapping its buffers? 74502f4aeb0Sopenharmony_ci 74602f4aeb0Sopenharmony_ci RESOLVED: No. Locking simply places the surface in that state and 74702f4aeb0Sopenharmony_ci prevents it from being made current / swapped / etc. Buffers are 74802f4aeb0Sopenharmony_ci mapped only when their pointers or pitch are queried using 74902f4aeb0Sopenharmony_ci eglQuerySurface. 75002f4aeb0Sopenharmony_ci 75102f4aeb0Sopenharmony_ci An interesting side effect of this resolution is that calling 75202f4aeb0Sopenharmony_ci eglLockSurfaceKHR immediately followed by eglUnlockSurfaceKHR DOES 75302f4aeb0Sopenharmony_ci NOT CHANGE THE CONTENTS OF BUFFERS, since none of them were mapped. 75402f4aeb0Sopenharmony_ci Likewise locking a surface, querying a buffer pointer or pitch, and 75502f4aeb0Sopenharmony_ci then unlocking it without changing the mapped buffer contents causes 75602f4aeb0Sopenharmony_ci the surface contents of the mapper buffer(s) to become undefined. 75702f4aeb0Sopenharmony_ci 75802f4aeb0Sopenharmony_ci At the Atlanta F2F, there was a suggestion that eglLockSurfaceKHR 75902f4aeb0Sopenharmony_ci should immediately map the color buffer and return a pointer to it, 76002f4aeb0Sopenharmony_ci on the basis that this would make it harder for applications to 76102f4aeb0Sopenharmony_ci mistakenly use an old buffer pointer from a previous mapping cycle. 76202f4aeb0Sopenharmony_ci At the same time, people working on more powerful GPUs wanted the 76302f4aeb0Sopenharmony_ci lock operation to be lightweight. These are not consistent goals and 76402f4aeb0Sopenharmony_ci we have thus far chosen to separate the lightweight locking, and 76502f4aeb0Sopenharmony_ci more expensive mapping operations. 76602f4aeb0Sopenharmony_ci 76702f4aeb0Sopenharmony_ci 7) Can buffer contents be preserved in mapping? 76802f4aeb0Sopenharmony_ci 76902f4aeb0Sopenharmony_ci RESOLVED: Yes. The default behavior is to discard / leave undefined 77002f4aeb0Sopenharmony_ci the mapped buffer contents, but the EGL_MAP_PRESERVE_PIXELS_KHR flag 77102f4aeb0Sopenharmony_ci may be specified to eglLockSurfaceKHR. 77202f4aeb0Sopenharmony_ci 77302f4aeb0Sopenharmony_ci 8) Should usage hints be provided during mapping? 77402f4aeb0Sopenharmony_ci 77502f4aeb0Sopenharmony_ci RESOLVED: Yes, they may be provided in the EGL_LOCK_USAGE_HINT_KHR 77602f4aeb0Sopenharmony_ci bitmask attribute to eglLockSurfaceKHR. Implementations are required 77702f4aeb0Sopenharmony_ci to behave correctly no matter the value of the flag vs. the 77802f4aeb0Sopenharmony_ci operations actually performed, so the hint may be ignored. 77902f4aeb0Sopenharmony_ci 78002f4aeb0Sopenharmony_ci 9) Should we be able to lock subrectangles of a surface? 78102f4aeb0Sopenharmony_ci 78202f4aeb0Sopenharmony_ci RESOLVED: No. However, the attribute list parameter of 78302f4aeb0Sopenharmony_ci eglLockSurfaceKHR allows a layered extension to implement this 78402f4aeb0Sopenharmony_ci behavior by specifying an origin and size to map within the buffer. 78502f4aeb0Sopenharmony_ci 78602f4aeb0Sopenharmony_ci10) Should the BITMAP_PIXEL_<component>_OFFSET attributes belong to the 78702f4aeb0Sopenharmony_ci surface, or the config? 78802f4aeb0Sopenharmony_ci 78902f4aeb0Sopenharmony_ci RESOLVED: Part of the surface. Configs supporting a specific format 79002f4aeb0Sopenharmony_ci are matched with config attribute EGL_MATCH_FORMAT_KHR, which 79102f4aeb0Sopenharmony_ci supports specific bit-exact formats such as 79202f4aeb0Sopenharmony_ci EGL_FORMAT_565_EXACT_KHR. 79302f4aeb0Sopenharmony_ci 79402f4aeb0Sopenharmony_ci11) Can the pixel size in a mapped buffer be derived from the 79502f4aeb0Sopenharmony_ci EGL_BUFFER_SIZE attribute of the config used to create it? 79602f4aeb0Sopenharmony_ci 79702f4aeb0Sopenharmony_ci RESOLVED: Yes. In principle, hardware using padding bytes in its 79802f4aeb0Sopenharmony_ci framebuffer storage could be a problem, and a separate 79902f4aeb0Sopenharmony_ci BITMAP_PIXEL_SIZE surface attribute would be needed. However, we 80002f4aeb0Sopenharmony_ci don't think implementations are likely to waste graphics memory and 80102f4aeb0Sopenharmony_ci bandwidth in this fashion. 80202f4aeb0Sopenharmony_ci 80302f4aeb0Sopenharmony_ci12) How are color component locations within a pixel described? 80402f4aeb0Sopenharmony_ci 80502f4aeb0Sopenharmony_ci RESOLVED: Each R, G, B, and A component has a queryable bit offset 80602f4aeb0Sopenharmony_ci within an integer. The size of the integer depends on the total size 80702f4aeb0Sopenharmony_ci of the pixel; for the 565 formats, the pixel is a 16-bit integer. 80802f4aeb0Sopenharmony_ci For the 8888 formats, the pixel is a 32-bit integer. 80902f4aeb0Sopenharmony_ci 81002f4aeb0Sopenharmony_ci We cannot describe component locations with byte locations, since 81102f4aeb0Sopenharmony_ci the 565 formats have components straddling byte boundaries. However, 81202f4aeb0Sopenharmony_ci this means that offsets for the RGBA8888_EXACT format are different 81302f4aeb0Sopenharmony_ci between little- and big-endian CPUs, since the desired format is B, 81402f4aeb0Sopenharmony_ci G, R, A components laid out as bytes in increasing memory order. 81502f4aeb0Sopenharmony_ci 81602f4aeb0Sopenharmony_ci13) Can mapped buffer contents be affected by other EGL operations? 81702f4aeb0Sopenharmony_ci 81802f4aeb0Sopenharmony_ci RESOLVED: No. A locked surface only allows two operations: 81902f4aeb0Sopenharmony_ci unlocking, and mapping. No other EGL operations can take place while 82002f4aeb0Sopenharmony_ci the surface is locked (if this were not the case, then 82102f4aeb0Sopenharmony_ci eglSwapBuffers might destroy the contents of a mapped buffer). 82202f4aeb0Sopenharmony_ci 82302f4aeb0Sopenharmony_ci It is possible that operations outside the scope of EGL could affect 82402f4aeb0Sopenharmony_ci a mapped color buffer. For example, if a surface's color buffer were 82502f4aeb0Sopenharmony_ci made up of an EGLImage, one of the EGL client APIs could draw to 82602f4aeb0Sopenharmony_ci that image while it was mapped. Responsibility for avoiding this 82702f4aeb0Sopenharmony_ci situation is in the hands of the client. 82802f4aeb0Sopenharmony_ci 82902f4aeb0Sopenharmony_ci14) Can EGL_MATCH_FORMAT_KHR be queried for a config? 83002f4aeb0Sopenharmony_ci 83102f4aeb0Sopenharmony_ci RESOLVED: Yes. Unlockable configs return EGL_NONE for this 83202f4aeb0Sopenharmony_ci attribute. 83302f4aeb0Sopenharmony_ci 83402f4aeb0Sopenharmony_ci For a config whose format matches one of the EGL_FORMAT_*_EXACT_KHR 83502f4aeb0Sopenharmony_ci definitions, that value is returned. 83602f4aeb0Sopenharmony_ci 83702f4aeb0Sopenharmony_ci For a config whose format does not match one of the 83802f4aeb0Sopenharmony_ci EGL_FORMAT_*_EXACT_KHR definitions, but it does match one of the 83902f4aeb0Sopenharmony_ci inexact definitions, we do not want to specify that it returns that 84002f4aeb0Sopenharmony_ci value, since that precludes it returning an exact format if one were 84102f4aeb0Sopenharmony_ci to be defined in a future extension, or a future version of this 84202f4aeb0Sopenharmony_ci extension. 84302f4aeb0Sopenharmony_ci 84402f4aeb0Sopenharmony_ci Therefore, for a config whose format does not match a defined 84502f4aeb0Sopenharmony_ci "exact" format, the attribute returns a value other than the defined 84602f4aeb0Sopenharmony_ci "exact" formats and EGL_NONE and EGL_DONT_CARE. 84702f4aeb0Sopenharmony_ci 84802f4aeb0Sopenharmony_ci15) Is a goal of this extension to support "mixed-mode" rendering (both 84902f4aeb0Sopenharmony_ci software and EGL client API rendering to the same surface)? 85002f4aeb0Sopenharmony_ci 85102f4aeb0Sopenharmony_ci RESOLVED: No. An implementation *can* choose to export configs 85202f4aeb0Sopenharmony_ci supporting creation of lockable surfaces which also support 85302f4aeb0Sopenharmony_ci rendering by OpenGL ES, OpenVG, or other client APIs (when the 85402f4aeb0Sopenharmony_ci surface is not locked). But there is nothing in the extension 85502f4aeb0Sopenharmony_ci requiring this, and the motivation for the extension is simply to 85602f4aeb0Sopenharmony_ci support software rendering. 85702f4aeb0Sopenharmony_ci 85802f4aeb0Sopenharmony_ci16) Can mapping a locked surface fail? 85902f4aeb0Sopenharmony_ci 86002f4aeb0Sopenharmony_ci RESOLVED: Yes, if memory can't be allocated in the client. This is 86102f4aeb0Sopenharmony_ci indicated by queries of EGL_BITMAP_POINTER_KHR and 86202f4aeb0Sopenharmony_ci EGL_BITMAP_PITCH_KHR failing and generating an EGL_BAD_ACCESS error. 86302f4aeb0Sopenharmony_ci 86402f4aeb0Sopenharmony_ci17) How does the application specify that it would like the pixels in the 86502f4aeb0Sopenharmony_ci mapped buffer to be preserved from the state at the last unlock? 86602f4aeb0Sopenharmony_ci [Bug 4410] 86702f4aeb0Sopenharmony_ci 86802f4aeb0Sopenharmony_ci There are actually two items that need to be configurable: 86902f4aeb0Sopenharmony_ci 87002f4aeb0Sopenharmony_ci a. Whether eglSwapBuffers preserves the color buffer. 87102f4aeb0Sopenharmony_ci 87202f4aeb0Sopenharmony_ci b. Whether eglLockSurfaceKHR puts the color buffer pixels into the 87302f4aeb0Sopenharmony_ci locked buffer. 87402f4aeb0Sopenharmony_ci 87502f4aeb0Sopenharmony_ci An implementation may use two different render paths depending on whether 87602f4aeb0Sopenharmony_ci the application is full frame rendering or incrementally rendering, where 87702f4aeb0Sopenharmony_ci the full frame rendering path may involve less copying than the 87802f4aeb0Sopenharmony_ci incrementally rendering path. The implementation needs to know in advance 87902f4aeb0Sopenharmony_ci which path to use; finding out from EGL_MAP_PRESERVE_PIXELS_KHR on 88002f4aeb0Sopenharmony_ci eglLockSurfaceKHR whether that lock should have the color buffer pixels 88102f4aeb0Sopenharmony_ci from the last eglUnlockSurfaceKHR in the last frame is too late. 88202f4aeb0Sopenharmony_ci 88302f4aeb0Sopenharmony_ci This need to know in advance only applies to (a). 88402f4aeb0Sopenharmony_ci 88502f4aeb0Sopenharmony_ci Note that the original EGL_KHR_lock_surface extension failed to state 88602f4aeb0Sopenharmony_ci that EGL_SWAP_BEHAVIOR needed to be set to EGL_BUFFER_PRESERVED for 88702f4aeb0Sopenharmony_ci incremental rendering. 88802f4aeb0Sopenharmony_ci 88902f4aeb0Sopenharmony_ci RESOLVED: EGL_MAP_PRESERVE_PIXELS_KHR continues to control (b), as in the 89002f4aeb0Sopenharmony_ci original EGL_KHR_lock_surface extension. EGL_SWAP_BEHAVIOR continues 89102f4aeb0Sopenharmony_ci to control (a), as in unextended EGL. It is possible to set 89202f4aeb0Sopenharmony_ci EGL_SWAP_BEHAVIOR in eglCreateWindowSurface, even on EGL versions 89302f4aeb0Sopenharmony_ci before 1.4, and even if the config does not have 89402f4aeb0Sopenharmony_ci EGL_SWAP_BEHAVIOR_PRESERVED_BIT set in EGL_SURFACE_TYPE. 89502f4aeb0Sopenharmony_ci 89602f4aeb0Sopenharmony_ci For a lockable window surface, EGL_SWAP_BEHAVIOR needs to default to 89702f4aeb0Sopenharmony_ci EGL_BUFFER_PRESERVED, and having EGL_SWAP_BEHAVIOR set to 89802f4aeb0Sopenharmony_ci EGL_BUFFER_PRESERVED needs to override EGL_MAP_PRESERVE_PIXELS_KHR. This is for 89902f4aeb0Sopenharmony_ci compatibility with version 1 of this extension, which had EGL_SWAP_BEHAVIOR 90002f4aeb0Sopenharmony_ci as the sole means of controlling (a) and (b). 90102f4aeb0Sopenharmony_ci 90202f4aeb0Sopenharmony_ci This resolution is backward compatible with the original 90302f4aeb0Sopenharmony_ci EGL_KHR_lock_surface extension as it now defaults to preserving pixels, 90402f4aeb0Sopenharmony_ci and thus has that default for an old application that does not know about 90502f4aeb0Sopenharmony_ci setting EGL_SWAP_BEHAVIOR=EGL_BUFFER_DESTROYED to optimize full frame 90602f4aeb0Sopenharmony_ci rendering. The downside is a possible performance reduction of an old 90702f4aeb0Sopenharmony_ci application that does not want pixels preserved, until it is appropriately 90802f4aeb0Sopenharmony_ci modified and recompiled. 90902f4aeb0Sopenharmony_ci 91002f4aeb0Sopenharmony_ci18) When can a lockable surface change size? [Bug 4522] 91102f4aeb0Sopenharmony_ci 91202f4aeb0Sopenharmony_ci RESOLVED: The surface cannot change size while it is locked. For any 91302f4aeb0Sopenharmony_ci window size change during that time, EGL defers the corresponding 91402f4aeb0Sopenharmony_ci surface size change until some time after the unlock. 91502f4aeb0Sopenharmony_ci The implication is that an application must get the surface size 91602f4aeb0Sopenharmony_ci _after_locking, otherwise the size may have changed in between the 91702f4aeb0Sopenharmony_ci attribute query and the lock. 91802f4aeb0Sopenharmony_ci 91902f4aeb0Sopenharmony_ci As part of this change, using eglQuerySurface on any surface attribute 92002f4aeb0Sopenharmony_ci while the surface is locked has been allowed. 92102f4aeb0Sopenharmony_ci 92202f4aeb0Sopenharmony_ci19) Should we provide for more than one pixel per byte, or a format with 92302f4aeb0Sopenharmony_ci a "hole", or a byte-swapped 16-bit format? [Bug 4513] 92402f4aeb0Sopenharmony_ci 92502f4aeb0Sopenharmony_ci For the use case where the application uses EGL_FORMAT_* to 92602f4aeb0Sopenharmony_ci determine the pixel format, this is not an issue. For the use case 92702f4aeb0Sopenharmony_ci where the application is written to cope with any format by reading 92802f4aeb0Sopenharmony_ci the EGL_BITMAP_* attributes and adjusting its rendering at runtime, 92902f4aeb0Sopenharmony_ci this is an issue. 93002f4aeb0Sopenharmony_ci 93102f4aeb0Sopenharmony_ci RESOLVED: We add a new attribute EGL_BITMAP_PIXEL_SIZE_KHR which gives 93202f4aeb0Sopenharmony_ci the pixel size in bits. 93302f4aeb0Sopenharmony_ci The use of this attribute assumes that multiple pixels packed into 93402f4aeb0Sopenharmony_ci a byte are arranged least significant on the left, and that pixels 93502f4aeb0Sopenharmony_ci are arranged leftmost first in memory. If either of these assumptions 93602f4aeb0Sopenharmony_ci is false, then EGL_BITMAP_PIXEL_SIZE_KHR is EGL_UNKNOWN to indicate 93702f4aeb0Sopenharmony_ci that an application attempting to use these attributes to adjust its 93802f4aeb0Sopenharmony_ci rendering code will not work. 93902f4aeb0Sopenharmony_ci 94002f4aeb0Sopenharmony_ci We also define that any of the EGL_BITMAP_PIXEL_x_OFFSET_KHR attributes 94102f4aeb0Sopenharmony_ci have a value of EGL_UNKNOWN if the corresponding color component is not 94202f4aeb0Sopenharmony_ci a contiguous bit range. 94302f4aeb0Sopenharmony_ci 94402f4aeb0Sopenharmony_ci20) EGL states that surface must be bound to the thread's current context 94502f4aeb0Sopenharmony_ci when posting, but there is no current context when using lock surface. 94602f4aeb0Sopenharmony_ci eglSwapInterval is also related to the context. [Bug 5923] 94702f4aeb0Sopenharmony_ci 94802f4aeb0Sopenharmony_ci RESOLVED: The posting restrictions are relaxed, so it is allowed to 94902f4aeb0Sopenharmony_ci post for a surface not bound to any client API context. In this case 95002f4aeb0Sopenharmony_ci no eglSwapInterval setting affects an eglSwapBuffers. This relaxation 95102f4aeb0Sopenharmony_ci only applies to a lockable surface so that this extension continues 95202f4aeb0Sopenharmony_ci to be implementable as a middleware layer on top of a "real" EGL. 95302f4aeb0Sopenharmony_ci The relaxation applies to a surface that is both lockable and client 95402f4aeb0Sopenharmony_ci API renderable; the implicit flush in a post only occurs when the surface 95502f4aeb0Sopenharmony_ci is bound to a current API context. Posting a surface bound to a different 95602f4aeb0Sopenharmony_ci thread's current API context is still disallowed. 95702f4aeb0Sopenharmony_ci 95802f4aeb0Sopenharmony_ci21) Why has this extension been obsoleted and replaced by 95902f4aeb0Sopenharmony_ci EGL_KHR_lock_surface3? 96002f4aeb0Sopenharmony_ci 96102f4aeb0Sopenharmony_ci RESOLVED: Starting with the December 4, 2013 release of EGL 1.4, EGLint 96202f4aeb0Sopenharmony_ci is defined to be the same size as the native platform "int" type. Handle 96302f4aeb0Sopenharmony_ci and pointer attribute values *cannot* be represented in attribute lists 96402f4aeb0Sopenharmony_ci on platforms where sizeof(handle/pointer) > sizeof(int). Existing 96502f4aeb0Sopenharmony_ci extensions which assume this functionality are being replaced with new 96602f4aeb0Sopenharmony_ci extensions specifying new entry points to work around this issue. See 96702f4aeb0Sopenharmony_ci the latest EGL 1.4 Specification for more details. 96802f4aeb0Sopenharmony_ci 96902f4aeb0Sopenharmony_ci 97002f4aeb0Sopenharmony_ciRevision History 97102f4aeb0Sopenharmony_ci 97202f4aeb0Sopenharmony_ci Version 3, 2013/12/04 - Add issue 21 explaining that the bitmap pointer 97302f4aeb0Sopenharmony_ci cannot be safely queried using this extension on 64-bit platforms, 97402f4aeb0Sopenharmony_ci and suggesting EGL_KHR_lock_surface3 instead. Change formal 97502f4aeb0Sopenharmony_ci parameter names from 'display' to 'dpy' to match other EGL APIs. 97602f4aeb0Sopenharmony_ci Version 2, 2010/03/10 97702f4aeb0Sopenharmony_ci Allocated extension number 16. 97802f4aeb0Sopenharmony_ci [Bug 6089] Clarified that it is the back buffer of a back-buffered 97902f4aeb0Sopenharmony_ci surface that is mapped. 98002f4aeb0Sopenharmony_ci [Bug 4410] Issue 17: Reinstate EGL_MAP_PRESERVE_PIXELS_KHR attribute on 98102f4aeb0Sopenharmony_ci eglLockSurfaceKHR as the means of configuring whether a locked 98202f4aeb0Sopenharmony_ci buffer contains pixel data from the color buffer, as in 98302f4aeb0Sopenharmony_ci EGL_KHR_lock_surface, but, for a lockable window surface, 98402f4aeb0Sopenharmony_ci make EGL_SWAP_BEHAVIOR=EGL_BUFFER_PRESERVED override the effect 98502f4aeb0Sopenharmony_ci of that attribute. Tidy wording so that behavior, and that the 98602f4aeb0Sopenharmony_ci default of EGL_SWAP_BEHAVIOR must be EGL_BUFFER_PRESERVED, only 98702f4aeb0Sopenharmony_ci applies to lockable window surfaces, not lockable pbuffer or 98802f4aeb0Sopenharmony_ci pixmap surfaces. 98902f4aeb0Sopenharmony_ci [Bug 5923] Issue 20: A config that is lockable and renderable by 99002f4aeb0Sopenharmony_ci an EGL client API is now allowed. Posting restrictions are relaxed 99102f4aeb0Sopenharmony_ci to allow posting for a lockable surface not bound to any client 99202f4aeb0Sopenharmony_ci API context. 99302f4aeb0Sopenharmony_ci [Bug 5143] Fixed typos EGL_SURFACE_TYPE_KHR. Added summary of 99402f4aeb0Sopenharmony_ci changes over EGL_KHR_lock_surface. 99502f4aeb0Sopenharmony_ci Version 1, 2010/01/19 99602f4aeb0Sopenharmony_ci [Bug 4410] Issue 17: Change to use EGL_SWAP_BEHAVIOR as the 99702f4aeb0Sopenharmony_ci primary means of determining whether the application wants pixels 99802f4aeb0Sopenharmony_ci preserved between lock/unlock cycles. 99902f4aeb0Sopenharmony_ci Allowed setting of EGL_SWAP_BEHAVIOR in 100002f4aeb0Sopenharmony_ci eglCreateWindowSurface for a lockable surface. Made the 100102f4aeb0Sopenharmony_ci default EGL_BUFFER_PRESERVED on a lockable surface to maintain 100202f4aeb0Sopenharmony_ci compatibility with the original lock surface extension. 100302f4aeb0Sopenharmony_ci [Bug 3192] Wording clarification to avoid accidentally suggesting 100402f4aeb0Sopenharmony_ci that almost all surface attributes are invariant. 100502f4aeb0Sopenharmony_ci [Bug 4518] Issue 14: Clarify the returned value when 100602f4aeb0Sopenharmony_ci EGL_MATCH_FORMAT_KHR is queried. 100702f4aeb0Sopenharmony_ci [Bug 4522] Issue 18: Clarify that a locked surface cannot change 100802f4aeb0Sopenharmony_ci size. 100902f4aeb0Sopenharmony_ci [Bug 4513] Issue 19: Added EGL_BITMAP_PIXEL_SIZE_KHR. 101002f4aeb0Sopenharmony_ci [Bug 5923] Issue 20: Must be no current context when posting 101102f4aeb0Sopenharmony_ci a lockable surface. In that case any eglSwapInterval setting 101202f4aeb0Sopenharmony_ci is ignored. Disallowed a config that is lockable and renderable 101302f4aeb0Sopenharmony_ci by an EGL client API. 101402f4aeb0Sopenharmony_ci 101502f4aeb0Sopenharmony_ciRevision History of original EGL_KHR_lock_surface extension 101602f4aeb0Sopenharmony_ci 101702f4aeb0Sopenharmony_ci Version 18, 2010/03/23 - Added introductory remark referring to the 101802f4aeb0Sopenharmony_ci EGL_KHR_lock_surface2 extension. 101902f4aeb0Sopenharmony_ci Version 17, 2008/10/08 - Updated status (approved as part of 102002f4aeb0Sopenharmony_ci OpenKODE 1.0). 102102f4aeb0Sopenharmony_ci Version 16, 2008/01/24 - Add issue 16 noting that mapping can fail, 102202f4aeb0Sopenharmony_ci and a corresponding new error condition for eglQuerySurface. 102302f4aeb0Sopenharmony_ci Clean up the issues list. 102402f4aeb0Sopenharmony_ci Version 15, 2008/01/09 - Add issue 15 noting that supporting 102502f4aeb0Sopenharmony_ci mixed-mode rendering is not a goal or requirement of the 102602f4aeb0Sopenharmony_ci extension. 102702f4aeb0Sopenharmony_ci Version 14, 2007/11/07 - change ARGB_8888_EXACT back to 102802f4aeb0Sopenharmony_ci RGBA_8888_EXACT, since the offsets are now dependent on the 102902f4aeb0Sopenharmony_ci endianness of the CPU. Add issue 12 describing this, and clarify 103002f4aeb0Sopenharmony_ci that offsets are within a 16- or 32-bit integer depending on the 103102f4aeb0Sopenharmony_ci format. Added issue 13 clarifying that locked buffer contents 103202f4aeb0Sopenharmony_ci are not affected by eglSwapBuffers, because eglSwapBuffers 103302f4aeb0Sopenharmony_ci cannot be issued on a mapped surface. Allow querying 103402f4aeb0Sopenharmony_ci EGL_MATCH_FORMAT_KHR for a config, and added related issue 14. 103502f4aeb0Sopenharmony_ci Version 13, 2007/05/10 - change RGBA_8888_EXACT to ARGB_8888_EXACT 103602f4aeb0Sopenharmony_ci to match hardware layout. 103702f4aeb0Sopenharmony_ci Version 12, 2007/04/06 - clarify that when EGL_MATCH_FORMAT_KHR is 103802f4aeb0Sopenharmony_ci EGL_DONT_CARE, it does not affect component size of selected 103902f4aeb0Sopenharmony_ci configs. 104002f4aeb0Sopenharmony_ci Version 11, 2007/04/05 - add missing KHR suffix to some tokens. 104102f4aeb0Sopenharmony_ci Version 10, 2007/04/05 - assign enumerant values. Add OpenKODE 1.0 104202f4aeb0Sopenharmony_ci Provisional disclaimer. 104302f4aeb0Sopenharmony_ci Version 9, 2007/03/26 - add format tokens to "New Tokens" 104402f4aeb0Sopenharmony_ci section. Correct description of RGBA format tokens. 104502f4aeb0Sopenharmony_ci Version 8, 2007/03/26 - add issue 11 noting theoretical possibility 104602f4aeb0Sopenharmony_ci of EGL_BUFFER_SIZE not directly corresponding to the mapped 104702f4aeb0Sopenharmony_ci pixel size. Add EGL_MATCH_FORMAT_KHR attribute to 104802f4aeb0Sopenharmony_ci eglChooseConfig, and 565 / 8888 formats for it. 104902f4aeb0Sopenharmony_ci Version 7, 2007/03/25 - note in issue 5 that access to a mapped 105002f4aeb0Sopenharmony_ci buffer must continue to work even after a mode change. Add KHR 105102f4aeb0Sopenharmony_ci suffix to new functions and tokens. Remove BITMAP_PIXEL_<x>_BITS 105202f4aeb0Sopenharmony_ci and BITMAP_PIXEL_SIZE tokens, which duplicate information in the 105302f4aeb0Sopenharmony_ci EGLConfig. Add issue 10 asking whether bitmap pixel offset 105402f4aeb0Sopenharmony_ci attributes belong to the config, or to the surface. 105502f4aeb0Sopenharmony_ci Version 6, 2007/02/26 - allow EGL_CLIENT_APIS string to be empty in 105602f4aeb0Sopenharmony_ci implementations supporting only this extension. 105702f4aeb0Sopenharmony_ci Version 5, 2007/02/05 - update contributor list. Changed bit offset 105802f4aeb0Sopenharmony_ci queries to return LSB offset, rather than MSB offset. 105902f4aeb0Sopenharmony_ci Version 4, 2007/02/02 - correct extension name. Change 106002f4aeb0Sopenharmony_ci name of FAST_UNLOCK_BIT_KHR to OPTIMAL_FORMAT_BIT_KHR. 106102f4aeb0Sopenharmony_ci Replace buffer_mask parameter of eglLockSurfaceKHR with an 106202f4aeb0Sopenharmony_ci attribute list. Add the EGL_MAP_PRESERVE_PIXELS_KHR and 106302f4aeb0Sopenharmony_ci EGL_LOCK_USAGE_HINT_KHR attributes per request from Gary. Add issues 106402f4aeb0Sopenharmony_ci 7, 8, and 9 describing these attributes and how to support 106502f4aeb0Sopenharmony_ci locking subrects in a layered extension, by extending the 106602f4aeb0Sopenharmony_ci attribute list. 106702f4aeb0Sopenharmony_ci Version 3, 2007/02/01 - the implementation once again controls the 106802f4aeb0Sopenharmony_ci mapped buffer memory. There is no longer a separate bitmap 106902f4aeb0Sopenharmony_ci surface type; any type surface may potentially be mapped, using 107002f4aeb0Sopenharmony_ci lock/unlock semantics. 107102f4aeb0Sopenharmony_ci Version 2, 2006/12/22 - simplify by only supporting drawing from 107202f4aeb0Sopenharmony_ci client memory to EGL surface color buffers. Specify use of 107302f4aeb0Sopenharmony_ci OpenGL DrawPixels terminology. Change name of the extension to 107402f4aeb0Sopenharmony_ci EGL_KHR_draw_pixels, since there is no longer any "bitmap 107502f4aeb0Sopenharmony_ci surface" involved. 107602f4aeb0Sopenharmony_ci Version 1, 2006/12/14 - write up as formal spec language for 107702f4aeb0Sopenharmony_ci external review. 1078