102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_partial_update 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_partial_update 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Ray Smith 1202f4aeb0Sopenharmony_ci Tom Cooksey 1302f4aeb0Sopenharmony_ci James Jones 1402f4aeb0Sopenharmony_ci Chad Versace 1502f4aeb0Sopenharmony_ci Jesse Hall 1602f4aeb0Sopenharmony_ci 1702f4aeb0Sopenharmony_ciContact 1802f4aeb0Sopenharmony_ci 1902f4aeb0Sopenharmony_ci Ray Smith, ARM (Raymond.Smith 'at' arm.com) 2002f4aeb0Sopenharmony_ci 2102f4aeb0Sopenharmony_ciIP Status 2202f4aeb0Sopenharmony_ci 2302f4aeb0Sopenharmony_ci No known claims. 2402f4aeb0Sopenharmony_ci 2502f4aeb0Sopenharmony_ciNotice 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ci Copyright (c) 2014 The Khronos Group Inc. Copyright terms at 2802f4aeb0Sopenharmony_ci http://www.khronos.org/registry/speccopyright.html 2902f4aeb0Sopenharmony_ci 3002f4aeb0Sopenharmony_ciStatus 3102f4aeb0Sopenharmony_ci 3202f4aeb0Sopenharmony_ci Complete. 3302f4aeb0Sopenharmony_ci Approved by the EGL Working Group on September 17, 2014. 3402f4aeb0Sopenharmony_ci Approved by the Khronos Board of Promoters on November 7, 2014. 3502f4aeb0Sopenharmony_ci 3602f4aeb0Sopenharmony_ciVersion 3702f4aeb0Sopenharmony_ci 3802f4aeb0Sopenharmony_ci Version 12, September 12, 2014 3902f4aeb0Sopenharmony_ci 4002f4aeb0Sopenharmony_ciNumber 4102f4aeb0Sopenharmony_ci 4202f4aeb0Sopenharmony_ci EGL Extension #83 4302f4aeb0Sopenharmony_ci 4402f4aeb0Sopenharmony_ciExtension Type 4502f4aeb0Sopenharmony_ci 4602f4aeb0Sopenharmony_ci EGL display extension 4702f4aeb0Sopenharmony_ci 4802f4aeb0Sopenharmony_ciDependencies 4902f4aeb0Sopenharmony_ci 5002f4aeb0Sopenharmony_ci EGL 1.4 or later is required. 5102f4aeb0Sopenharmony_ci 5202f4aeb0Sopenharmony_ci Written based on the EGL 1.5 specification (March 12, 2014). 5302f4aeb0Sopenharmony_ci 5402f4aeb0Sopenharmony_ci The behavior of part of this extension is different depending on whether the 5502f4aeb0Sopenharmony_ci EGL_EXT_buffer_age extension is also present. 5602f4aeb0Sopenharmony_ci 5702f4aeb0Sopenharmony_ci This extension trivially interacts with EGL_KHR_swap_buffers_with_damage and 5802f4aeb0Sopenharmony_ci EGL_EXT_swap_buffers_with_damage. This extension is worded against the KHR 5902f4aeb0Sopenharmony_ci version, but the interactions with the EXT version are identical. 6002f4aeb0Sopenharmony_ci 6102f4aeb0Sopenharmony_ciNew Procedures and Functions 6202f4aeb0Sopenharmony_ci 6302f4aeb0Sopenharmony_ci 6402f4aeb0Sopenharmony_ci EGLBoolean eglSetDamageRegionKHR(EGLDisplay dpy, 6502f4aeb0Sopenharmony_ci EGLSurface surface, 6602f4aeb0Sopenharmony_ci EGLint *rects, 6702f4aeb0Sopenharmony_ci EGLint n_rects); 6802f4aeb0Sopenharmony_ci 6902f4aeb0Sopenharmony_ciNew Tokens 7002f4aeb0Sopenharmony_ci 7102f4aeb0Sopenharmony_ci Accepted in the <attribute> parameter of eglQuerySurface: 7202f4aeb0Sopenharmony_ci 7302f4aeb0Sopenharmony_ci EGL_BUFFER_AGE_KHR 0x313D 7402f4aeb0Sopenharmony_ci 7502f4aeb0Sopenharmony_ciOverview 7602f4aeb0Sopenharmony_ci 7702f4aeb0Sopenharmony_ci The aim of this extension is to allow efficient partial updates for postable 7802f4aeb0Sopenharmony_ci surfaces. It allows implementations to completely avoid processing areas of 7902f4aeb0Sopenharmony_ci the surface which have not changed between frames, allowing increased 8002f4aeb0Sopenharmony_ci efficiency. 8102f4aeb0Sopenharmony_ci 8202f4aeb0Sopenharmony_ci It does so by providing information and guarantees about the content of the 8302f4aeb0Sopenharmony_ci current back buffer which allow the application to "repair" only areas that 8402f4aeb0Sopenharmony_ci have become out of date since the particular back buffer was last used. 8502f4aeb0Sopenharmony_ci 8602f4aeb0Sopenharmony_ci The information provided is in the form of the "age" of the buffer, that is, 8702f4aeb0Sopenharmony_ci how many frames ago it was last used as the back buffer for the surface. If 8802f4aeb0Sopenharmony_ci the application tracks what changes it has made to the surface since this 8902f4aeb0Sopenharmony_ci back buffer was last used, it can bring the entire back buffer up to date by 9002f4aeb0Sopenharmony_ci only re-rendering the areas it knows to be out of date. 9102f4aeb0Sopenharmony_ci 9202f4aeb0Sopenharmony_ci Use of this extension provides a more efficient alternative to 9302f4aeb0Sopenharmony_ci EGL_BUFFER_PRESERVED swap behaviour. EGL_BUFFER_PRESERVED typically implies 9402f4aeb0Sopenharmony_ci an expensive full-frame copy at the beginning of the frame, as well as a 9502f4aeb0Sopenharmony_ci dependency on the previous frame. Usage of this extension avoids both and 9602f4aeb0Sopenharmony_ci requires only the necessary updates to a back buffer to be made. 9702f4aeb0Sopenharmony_ci 9802f4aeb0Sopenharmony_ciTerminology 9902f4aeb0Sopenharmony_ci 10002f4aeb0Sopenharmony_ci This extension and the EGL_KHR_swap_buffers_with_damage extension both use 10102f4aeb0Sopenharmony_ci the word "damage" for subtly but significantly different purposes: 10202f4aeb0Sopenharmony_ci 10302f4aeb0Sopenharmony_ci "Surface damage" is what the EGL_KHR_swap_buffers_with_damage extension 10402f4aeb0Sopenharmony_ci is concerned with. This is the area of the *surface* that changes between 10502f4aeb0Sopenharmony_ci frames for that surface. It concerns the differences between two buffers - 10602f4aeb0Sopenharmony_ci the current back buffer and the current front buffer. It is useful only to 10702f4aeb0Sopenharmony_ci the consumer. 10802f4aeb0Sopenharmony_ci 10902f4aeb0Sopenharmony_ci "Buffer damage" is what the EGL_KHR_partial_update extension is concerned 11002f4aeb0Sopenharmony_ci with. This is the area of a particular buffer that has changed since that 11102f4aeb0Sopenharmony_ci same buffer was last used. As it only concerns changes to a single buffer, 11202f4aeb0Sopenharmony_ci there is no dependency on the next or previous frames or any other buffer. 11302f4aeb0Sopenharmony_ci It therefore cannot be used to infer anything about changes to the surface, 11402f4aeb0Sopenharmony_ci which requires linking one frame or buffer to another. Buffer damage is 11502f4aeb0Sopenharmony_ci therefore only useful to the producer. 11602f4aeb0Sopenharmony_ci 11702f4aeb0Sopenharmony_ci Following are examples of the two different damage types. Note that the 11802f4aeb0Sopenharmony_ci final surface content is the same in both cases, but the damaged areas 11902f4aeb0Sopenharmony_ci differ according to the type of damage being discussed. 12002f4aeb0Sopenharmony_ci 12102f4aeb0Sopenharmony_ciSurface damage example (EGL_KHR_swap_buffers_with_damage) 12202f4aeb0Sopenharmony_ci 12302f4aeb0Sopenharmony_ci The surface damage for frame n is the difference between frame n and frame 12402f4aeb0Sopenharmony_ci (n-1), and represents the area that a compositor must recompose. 12502f4aeb0Sopenharmony_ci 12602f4aeb0Sopenharmony_ci Frame 0 Frame 1 Frame 2 Frame 3 Frame 4 12702f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 12802f4aeb0Sopenharmony_ci | | |#########| |#########| |#########| |#########| 12902f4aeb0Sopenharmony_ci | | | | |#########| |#########| |#########| Final surface 13002f4aeb0Sopenharmony_ci | | | | | | |#########| |#########| content 13102f4aeb0Sopenharmony_ci | | | | | | | | |#########| 13202f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 13302f4aeb0Sopenharmony_ci 13402f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 13502f4aeb0Sopenharmony_ci |@@@@@@@@@| |@@@@@@@@@| | | | | | | 13602f4aeb0Sopenharmony_ci |@@@@@@@@@| | | |@@@@@@@@@| | | | | Surface damage 13702f4aeb0Sopenharmony_ci |@@@@@@@@@| | | | | |@@@@@@@@@| | | 13802f4aeb0Sopenharmony_ci |@@@@@@@@@| | | | | | | |@@@@@@@@@| 13902f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 14002f4aeb0Sopenharmony_ci 14102f4aeb0Sopenharmony_ciBuffer damage example (EGL_KHR_partial_update) 14202f4aeb0Sopenharmony_ci 14302f4aeb0Sopenharmony_ci The buffer damage for a frame is the area changed since that same buffer was 14402f4aeb0Sopenharmony_ci last used. If the buffer has not been used before, the buffer damage is the 14502f4aeb0Sopenharmony_ci entire area of the buffer. 14602f4aeb0Sopenharmony_ci 14702f4aeb0Sopenharmony_ci The buffer marked with an 'X' in the top left corner is the buffer that is 14802f4aeb0Sopenharmony_ci being used for that frame. This is the buffer to which the buffer age and 14902f4aeb0Sopenharmony_ci the buffer damage relate. 15002f4aeb0Sopenharmony_ci 15102f4aeb0Sopenharmony_ci Note that this example shows a double buffered surface - the actual number 15202f4aeb0Sopenharmony_ci of buffers could be different and variable throughout the lifetime of the 15302f4aeb0Sopenharmony_ci surface. The age *must* therefore be queried for every frame. 15402f4aeb0Sopenharmony_ci 15502f4aeb0Sopenharmony_ci Frame 0 Frame 1 Frame 2 Frame 3 Frame 4 15602f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 15702f4aeb0Sopenharmony_ci | | |#########| |#########| |#########| |#########| 15802f4aeb0Sopenharmony_ci | | | | |#########| |#########| |#########| Final surface 15902f4aeb0Sopenharmony_ci | | | | | | |#########| |#########| content 16002f4aeb0Sopenharmony_ci | | | | | | | | |#########| 16102f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 16202f4aeb0Sopenharmony_ci 16302f4aeb0Sopenharmony_ci X---------+ +---------+ X---------+ +---------+ X---------+ 16402f4aeb0Sopenharmony_ci | | | | |#########| |#########| |#########| 16502f4aeb0Sopenharmony_ci | | | | |#########| |#########| |#########| Buffer 1 content 16602f4aeb0Sopenharmony_ci | | | | | | | | |#########| 16702f4aeb0Sopenharmony_ci | | | | | | | | |#########| 16802f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 16902f4aeb0Sopenharmony_ci 17002f4aeb0Sopenharmony_ci X---------+ +---------+ X---------+ +---------+ 17102f4aeb0Sopenharmony_ci |#########| |#########| |#########| |#########| 17202f4aeb0Sopenharmony_ci | | | | |#########| |#########| Buffer 2 content 17302f4aeb0Sopenharmony_ci | | | | |#########| |#########| 17402f4aeb0Sopenharmony_ci | | | | | | | | 17502f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ 17602f4aeb0Sopenharmony_ci 17702f4aeb0Sopenharmony_ci 0 0 2 2 2 Buffer age 17802f4aeb0Sopenharmony_ci 17902f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 18002f4aeb0Sopenharmony_ci |@@@@@@@@@| |@@@@@@@@@| |@@@@@@@@@| | | | | 18102f4aeb0Sopenharmony_ci |@@@@@@@@@| |@@@@@@@@@| |@@@@@@@@@| |@@@@@@@@@| | | Buffer damage 18202f4aeb0Sopenharmony_ci |@@@@@@@@@| |@@@@@@@@@| | | |@@@@@@@@@| |@@@@@@@@@| 18302f4aeb0Sopenharmony_ci |@@@@@@@@@| |@@@@@@@@@| | | | | |@@@@@@@@@| 18402f4aeb0Sopenharmony_ci +---------+ +---------+ +---------+ +---------+ +---------+ 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci 18702f4aeb0Sopenharmony_ciAdd a new section entitled "Partial updates to postable surfaces" to section 18802f4aeb0Sopenharmony_ci3.5: 18902f4aeb0Sopenharmony_ci 19002f4aeb0Sopenharmony_ci The "damage region" defines the area of the buffer to which all rendering 19102f4aeb0Sopenharmony_ci commands must be restricted. It applies only for surfaces which can be 19202f4aeb0Sopenharmony_ci posted, as described in section 3.10, and only when the swap behavior is 19302f4aeb0Sopenharmony_ci EGL_BUFFER_DESTROYED. 19402f4aeb0Sopenharmony_ci 19502f4aeb0Sopenharmony_ci The contents of the buffer outside of the damage region may always be relied 19602f4aeb0Sopenharmony_ci upon to contain the same content as the last time they were defined for the 19702f4aeb0Sopenharmony_ci current back buffer. See section 3.5.6 for how to query when the current 19802f4aeb0Sopenharmony_ci back buffer was last used, and therefore what those contents are. 19902f4aeb0Sopenharmony_ci 20002f4aeb0Sopenharmony_ci If EGL_EXT_buffer_age is supported, the contents of the buffer inside the 20102f4aeb0Sopenharmony_ci damage region may also be relied upon to contain the same content as the 20202f4aeb0Sopenharmony_ci last time they were defined for the current back buffer. If 20302f4aeb0Sopenharmony_ci EGL_EXT_buffer_age is not supported, the contents of the buffer inside the 20402f4aeb0Sopenharmony_ci damage region are always undefined after calling eglSwapBuffers. 20502f4aeb0Sopenharmony_ci 20602f4aeb0Sopenharmony_ci Setting the damage region appropriately can be used to efficiently update 20702f4aeb0Sopenharmony_ci only the necessary areas inbetween frames. 20802f4aeb0Sopenharmony_ci 20902f4aeb0Sopenharmony_ci After posting the back buffer, the damage region is set to the full 21002f4aeb0Sopenharmony_ci dimensions of the surface. The damage region can only be changed by the 21102f4aeb0Sopenharmony_ci application before any client API commands that draw to the surface have 21202f4aeb0Sopenharmony_ci been made. After this, the damage region is frozen until the back buffer is 21302f4aeb0Sopenharmony_ci posted again. 21402f4aeb0Sopenharmony_ci 21502f4aeb0Sopenharmony_ci Use the command 21602f4aeb0Sopenharmony_ci EGLBoolean eglSetDamageRegionKHR( 21702f4aeb0Sopenharmony_ci EGLDisplay dpy, 21802f4aeb0Sopenharmony_ci EGLSurface surface, 21902f4aeb0Sopenharmony_ci EGLint *rects, 22002f4aeb0Sopenharmony_ci EGLint n_rects) 22102f4aeb0Sopenharmony_ci 22202f4aeb0Sopenharmony_ci to set the damage region. 22302f4aeb0Sopenharmony_ci 22402f4aeb0Sopenharmony_ci The damage region for <surface> is set to the area described by <n_rects> and 22502f4aeb0Sopenharmony_ci <rects> if all of the following conditions are met: 22602f4aeb0Sopenharmony_ci 22702f4aeb0Sopenharmony_ci * <surface> is the current draw surface of the calling thread 22802f4aeb0Sopenharmony_ci * <surface> is a postable surface 22902f4aeb0Sopenharmony_ci * There have been no client API commands which result with rendering to 23002f4aeb0Sopenharmony_ci <surface> since eglSwapBuffers was last called with <surface>, or since 23102f4aeb0Sopenharmony_ci <surface> was created in case eglSwapBuffers has not yet been called with 23202f4aeb0Sopenharmony_ci <surface>. 23302f4aeb0Sopenharmony_ci * The surface's swap behavior is EGL_BUFFER_DESTROYED 23402f4aeb0Sopenharmony_ci 23502f4aeb0Sopenharmony_ci <n_rects> specifies the number of rectangles comprising the damage region. 23602f4aeb0Sopenharmony_ci <rects> is a pointer to a list of values describing the rectangles. The list 23702f4aeb0Sopenharmony_ci should consist of <n_rects> groups of four values, with each group 23802f4aeb0Sopenharmony_ci representing a single rectangle in surface coordinates in the form {x, y, 23902f4aeb0Sopenharmony_ci width, height}. Coordinates are specified relative to the lower left corner 24002f4aeb0Sopenharmony_ci of the surface. It is not necessary to avoid overlaps of the specified 24102f4aeb0Sopenharmony_ci rectangles. Rectangles that lie (partially) outside of the current surface 24202f4aeb0Sopenharmony_ci dimensions (as queryable via the EGL_WIDTH and EGL_HEIGHT attributes) will 24302f4aeb0Sopenharmony_ci be clamped to the current surface dimensions. 24402f4aeb0Sopenharmony_ci 24502f4aeb0Sopenharmony_ci If <n_rects> is zero, <rects> is ignored and the damage region is set to the 24602f4aeb0Sopenharmony_ci full dimensions of the surface. 24702f4aeb0Sopenharmony_ci 24802f4aeb0Sopenharmony_ci If <n_rects> is not zero but the rectangles in <rects> describe a region of 24902f4aeb0Sopenharmony_ci zero area after clamping, the damage region is set to the empty region. 25002f4aeb0Sopenharmony_ci 25102f4aeb0Sopenharmony_ci If <rects> contains more than (4 * <n_rects>) values, the remaining values 25202f4aeb0Sopenharmony_ci are ignored. If <rects> contains fewer than (4 * <n_rects>) values, the 25302f4aeb0Sopenharmony_ci behavior is undefined, up to and including program termination. 25402f4aeb0Sopenharmony_ci 25502f4aeb0Sopenharmony_ci At all times, any client API rendering which falls outside of the damage 25602f4aeb0Sopenharmony_ci region results in undefined framebuffer contents for the entire framebuffer. 25702f4aeb0Sopenharmony_ci It is the client's responsibility to ensure that rendering is confined to 25802f4aeb0Sopenharmony_ci the current damage area. 25902f4aeb0Sopenharmony_ci 26002f4aeb0Sopenharmony_ci If any client API commands resulting in rendering to <surface> have been 26102f4aeb0Sopenharmony_ci issued since eglSwapBuffers was last called with <surface>, or since the 26202f4aeb0Sopenharmony_ci surface was created in case eglSwapBuffers has not yet been called on it, 26302f4aeb0Sopenharmony_ci attempting to set the damage region will result in undefined framebuffer 26402f4aeb0Sopenharmony_ci contents for the entire framebuffer. 26502f4aeb0Sopenharmony_ci 26602f4aeb0Sopenharmony_ci Errors 26702f4aeb0Sopenharmony_ci ------ 26802f4aeb0Sopenharmony_ci eglSetDamageRegionKHR returns EGL_FALSE on failure: 26902f4aeb0Sopenharmony_ci * If <surface> is not a postable surface, an EGL_BAD_MATCH error is 27002f4aeb0Sopenharmony_ci generated 27102f4aeb0Sopenharmony_ci * If <surface> is not the current draw surface for the calling thread, an 27202f4aeb0Sopenharmony_ci EGL_BAD_MATCH error is generated 27302f4aeb0Sopenharmony_ci * If the value of EGL_SWAP_BEHAVIOR for <surface> is not 27402f4aeb0Sopenharmony_ci EGL_BUFFER_DESTROYED, an EGL_BAD_MATCH error is generated 27502f4aeb0Sopenharmony_ci * If eglSetDamageRegionKHR has already been called on <surface> since the 27602f4aeb0Sopenharmony_ci most recent frame boundary, an EGL_BAD_ACCESS error is generated 27702f4aeb0Sopenharmony_ci * If the EGL_BUFFER_AGE_KHR attribute of <surface> has not been queried 27802f4aeb0Sopenharmony_ci since the most recent frame boundary, an EGL_BAD_ACCESS error is generated 27902f4aeb0Sopenharmony_ci 28002f4aeb0Sopenharmony_ciAdd before the final paragraph in section 3.5.6 "Surface Attributes": 28102f4aeb0Sopenharmony_ci 28202f4aeb0Sopenharmony_ci Querying EGL_BUFFER_AGE_KHR returns the age of the color contents of the 28302f4aeb0Sopenharmony_ci current back buffer as the number of frames elapsed since it was most 28402f4aeb0Sopenharmony_ci recently defined. Under certain conditions described below, applications 28502f4aeb0Sopenharmony_ci can, in conjunction with the surface's damage region (see section 3.5.1), 28602f4aeb0Sopenharmony_ci use this age to safely rely on the contents of old back buffers to reduce 28702f4aeb0Sopenharmony_ci the amount of redrawing they do each frame. 28802f4aeb0Sopenharmony_ci 28902f4aeb0Sopenharmony_ci To query the age of a surface, it must be the current draw surface for the 29002f4aeb0Sopenharmony_ci calling thread. 29102f4aeb0Sopenharmony_ci 29202f4aeb0Sopenharmony_ci Function name 29302f4aeb0Sopenharmony_ci -------------------- 29402f4aeb0Sopenharmony_ci eglSwapBuffers 29502f4aeb0Sopenharmony_ci eglSwapBuffersWithDamageKHR 29602f4aeb0Sopenharmony_ci 29702f4aeb0Sopenharmony_ci Table 3.X, Frame Boundary Functions 29802f4aeb0Sopenharmony_ci 29902f4aeb0Sopenharmony_ci Buffers' ages are initialized to 0 at buffer creation time. When a frame 30002f4aeb0Sopenharmony_ci boundary is reached, the following occurs before any exchanging or copying 30102f4aeb0Sopenharmony_ci of color buffers: 30202f4aeb0Sopenharmony_ci 30302f4aeb0Sopenharmony_ci * The current back buffer's age is set to 1. 30402f4aeb0Sopenharmony_ci * Any other color buffers' ages are incremented by 1 if 30502f4aeb0Sopenharmony_ci their age was previously greater than 0. 30602f4aeb0Sopenharmony_ci 30702f4aeb0Sopenharmony_ci For example, with a double buffered surface and an implementation that swaps 30802f4aeb0Sopenharmony_ci via buffer exchanges, the age would usually be 2. With a triple buffered 30902f4aeb0Sopenharmony_ci surface the age would usually be 3. An age of 1 usually means the previous 31002f4aeb0Sopenharmony_ci swap was implemented as a copy. An age of 0 means the buffer has only just 31102f4aeb0Sopenharmony_ci been initialized and the contents are undefined. Single buffered surfaces 31202f4aeb0Sopenharmony_ci have no frame boundaries and therefore always have an age of 0. 31302f4aeb0Sopenharmony_ci 31402f4aeb0Sopenharmony_ci Where specified in terms of the current damage region (see section 3.5.6), 31502f4aeb0Sopenharmony_ci the relevant part of a buffer's content is considered defined when the 31602f4aeb0Sopenharmony_ci buffer's age is a value greater than 0. 31702f4aeb0Sopenharmony_ci 31802f4aeb0Sopenharmony_ci Frame boundaries are the only events that can set a buffer's age to a 31902f4aeb0Sopenharmony_ci positive value. Once EGL_BUFFER_AGE_KHR has been queried then it can be 32002f4aeb0Sopenharmony_ci assumed that the age will remain valid until the next frame boundary. EGL 32102f4aeb0Sopenharmony_ci implementations are permitted, but not required, to reset the buffer age in 32202f4aeb0Sopenharmony_ci response to pixel ownership test changes for any pixels within the drawable, 32302f4aeb0Sopenharmony_ci or if new pixels are added to or removed from the drawable, i.e., the 32402f4aeb0Sopenharmony_ci drawable is resized. A reset of this nature does not affect the age of 32502f4aeb0Sopenharmony_ci content for pixels that pass the pixel ownership test before and after the 32602f4aeb0Sopenharmony_ci event that caused the reset. In other words, applications can assume that 32702f4aeb0Sopenharmony_ci no event will invalidate the content of pixels that continuously pass the 32802f4aeb0Sopenharmony_ci pixel ownership test between when the buffer age was queried and the 32902f4aeb0Sopenharmony_ci following frame boundary. It is up to applications to track pixel ownership 33002f4aeb0Sopenharmony_ci using data collected from relevant window system events, such as 33102f4aeb0Sopenharmony_ci configuration and expose events on the X11 platform. 33202f4aeb0Sopenharmony_ci 33302f4aeb0Sopenharmony_ci EGL_BUFFER_AGE_KHR state is a property of the EGL surface that owns the 33402f4aeb0Sopenharmony_ci buffers and lives in the address space of the application. That is, if an 33502f4aeb0Sopenharmony_ci EGL surface has been created from a native window or pixmap that may be 33602f4aeb0Sopenharmony_ci shared between processes, the buffer age is not guaranteed to be 33702f4aeb0Sopenharmony_ci synchronized across the processes. Binding and unbinding a surface to and 33802f4aeb0Sopenharmony_ci from one or more contexts in the same address space will not affect the ages 33902f4aeb0Sopenharmony_ci of any buffers in that surface. 34002f4aeb0Sopenharmony_ci 34102f4aeb0Sopenharmony_ciAdd to the list of errors for eglQuerySurface at the end of section 3.5.6 34202f4aeb0Sopenharmony_ci"Surface Attributes": 34302f4aeb0Sopenharmony_ci 34402f4aeb0Sopenharmony_ci If <attribute> is EGL_BUFFER_AGE_KHR and <surface> is not the current draw 34502f4aeb0Sopenharmony_ci surface for the calling thread, an EGL_BAD_SURFACE error is generated. 34602f4aeb0Sopenharmony_ci 34702f4aeb0Sopenharmony_ciAdd to the end of section 3.10.1.1 "Native Window Resizing": 34802f4aeb0Sopenharmony_ci 34902f4aeb0Sopenharmony_ci If eglSetDamageRegionKHR has been called with anything other than zero for 35002f4aeb0Sopenharmony_ci <n_rects>, a surface resize will cause the damage region to become 35102f4aeb0Sopenharmony_ci undefined. This will effectively cause the entire framebuffer content to 35202f4aeb0Sopenharmony_ci become undefined until the next frame. 35302f4aeb0Sopenharmony_ci 35402f4aeb0Sopenharmony_ciDependencies on EGL_KHR_swap_buffers_with_damage 35502f4aeb0Sopenharmony_ci 35602f4aeb0Sopenharmony_ci If EGL_KHR_swap_buffers_with_damage is not supported, all references to 35702f4aeb0Sopenharmony_ci eglSwapBuffersWithDamageKHR are removed. 35802f4aeb0Sopenharmony_ci 35902f4aeb0Sopenharmony_ciIssues 36002f4aeb0Sopenharmony_ci 36102f4aeb0Sopenharmony_ci 1) What should happen if the client renders outside of the damage area? 36202f4aeb0Sopenharmony_ci 36302f4aeb0Sopenharmony_ci RESOLVED: The entire framebuffer content will be undefined. 36402f4aeb0Sopenharmony_ci 36502f4aeb0Sopenharmony_ci DISCUSSION: The definedness of different parts of the buffer varies across 36602f4aeb0Sopenharmony_ci implementations, making it hard to define, and providing any more specific 36702f4aeb0Sopenharmony_ci information may encourage improper and non-portable use of this extension. 36802f4aeb0Sopenharmony_ci 36902f4aeb0Sopenharmony_ci 2) How does this interact with EGL_EXT_buffer_age? 37002f4aeb0Sopenharmony_ci 37102f4aeb0Sopenharmony_ci RESOLVED: The initial content of the damage area differs depending on 37202f4aeb0Sopenharmony_ci whether EGL_EXT_buffer_age is present or not, making this extension fully 37302f4aeb0Sopenharmony_ci backwards compatible with EGL_EXT_buffer_age, while not depending on it. 37402f4aeb0Sopenharmony_ci 37502f4aeb0Sopenharmony_ci 3) How does this interact with EGL_KHR_swap_buffers_with_damage? 37602f4aeb0Sopenharmony_ci 37702f4aeb0Sopenharmony_ci RESOLVED: It does not interact materially with 37802f4aeb0Sopenharmony_ci EGL_KHR_swap_buffers_with_damage, except for the trivial interaction with 37902f4aeb0Sopenharmony_ci eglSwapBuffersWithDamageKHR being a frame boundary function if the extension 38002f4aeb0Sopenharmony_ci is also supported. 38102f4aeb0Sopenharmony_ci 38202f4aeb0Sopenharmony_ci DISCUSSION: This extension only provides a way to efficiently update the 38302f4aeb0Sopenharmony_ci back buffer for a surface. It does not have any effect on the subsequent 38402f4aeb0Sopenharmony_ci posting of that buffer. For maximum efficiency, applications should use both 38502f4aeb0Sopenharmony_ci EGL_KHR_partial_update and EGL_KHR_swap_buffers_with_damage simultaneously. 38602f4aeb0Sopenharmony_ci 38702f4aeb0Sopenharmony_ci 4) How does this interact with EGL_BUFFER_PRESERVED? 38802f4aeb0Sopenharmony_ci 38902f4aeb0Sopenharmony_ci RESOLVED: It is an error to call eglSetDamageRegionKHR with a surface with 39002f4aeb0Sopenharmony_ci EGL_BUFFER_PRESERVED swap behavior. However, it is not an error to query the 39102f4aeb0Sopenharmony_ci age of the buffer in this case. 39202f4aeb0Sopenharmony_ci 39302f4aeb0Sopenharmony_ci DISCUSSION: A layered extension will be proposed to guarantee that the age 39402f4aeb0Sopenharmony_ci of a buffer is always 1 after the first frame for a surface. This will 39502f4aeb0Sopenharmony_ci provide similar (but not identical) semantics to EGL_BUFFER_PRESERVED for 39602f4aeb0Sopenharmony_ci applications that need it. 39702f4aeb0Sopenharmony_ci 39802f4aeb0Sopenharmony_ci 5) How does surface resizing affect the damage region? 39902f4aeb0Sopenharmony_ci 40002f4aeb0Sopenharmony_ci RESOLVED: The damage region becomes undefined if a surface resize occurs 40102f4aeb0Sopenharmony_ci after it has been set to anything except the full buffer. Because rendering 40202f4aeb0Sopenharmony_ci outside the damage area results in undefined framebuffer contents, this 40302f4aeb0Sopenharmony_ci effectively means that the entire framebuffer content becomes undefined 40402f4aeb0Sopenharmony_ci until the next frame. 40502f4aeb0Sopenharmony_ci 40602f4aeb0Sopenharmony_ci 6) What happens if the damage region is set after any client rendering 40702f4aeb0Sopenharmony_ci commands? 40802f4aeb0Sopenharmony_ci 40902f4aeb0Sopenharmony_ci OPTION 1: An error is returned. Detecting this condition is non-trivial in 41002f4aeb0Sopenharmony_ci some implementations. 41102f4aeb0Sopenharmony_ci 41202f4aeb0Sopenharmony_ci OPTION 2: The entire framebuffer contents become undefined. 41302f4aeb0Sopenharmony_ci 41402f4aeb0Sopenharmony_ci RESOLVED: Option 2. 41502f4aeb0Sopenharmony_ci 41602f4aeb0Sopenharmony_ci 7) Should the entire region be provided in advance of any rendering, or should 41702f4aeb0Sopenharmony_ci each region be supplied immediately before the rendering commands for that 41802f4aeb0Sopenharmony_ci region, and multiple regions can be defined per frame? 41902f4aeb0Sopenharmony_ci 42002f4aeb0Sopenharmony_ci RESOLVED: The entire region must be provided in advance of any rendering. 42102f4aeb0Sopenharmony_ci 42202f4aeb0Sopenharmony_ci 8) What should be the behavior if eglSetDamageRegionKHR is called multiple 42302f4aeb0Sopenharmony_ci times before the first rendering command? 42402f4aeb0Sopenharmony_ci 42502f4aeb0Sopenharmony_ci RESOLVED: This is an error. The entire region must be provided during a 42602f4aeb0Sopenharmony_ci single call, with no overwrite or modify behavior needed. 42702f4aeb0Sopenharmony_ci 42802f4aeb0Sopenharmony_ci 9) Is it allowed to set the damage region when the buffer age has not been 42902f4aeb0Sopenharmony_ci queried? 43002f4aeb0Sopenharmony_ci 43102f4aeb0Sopenharmony_ci RESOLVED: This is an error. This could only make sense when the damage 43202f4aeb0Sopenharmony_ci region is the entire buffer, which it is initially anyway. Otherwise the 43302f4aeb0Sopenharmony_ci undamaged area needs to be defined to an age that the application doesn't 43402f4aeb0Sopenharmony_ci know about. It's not clear that this would ever be useful to the 43502f4aeb0Sopenharmony_ci application, because it can't know at this point which areas it needs to 43602f4aeb0Sopenharmony_ci update. 43702f4aeb0Sopenharmony_ci 43802f4aeb0Sopenharmony_ci10) What is the behavior if, after clamping, the damage region is empty? 43902f4aeb0Sopenharmony_ci 44002f4aeb0Sopenharmony_ci RESOLVED: The damage region is set to empty. 44102f4aeb0Sopenharmony_ci 44202f4aeb0Sopenharmony_ci 44302f4aeb0Sopenharmony_ciRevision History 44402f4aeb0Sopenharmony_ci 44502f4aeb0Sopenharmony_ci Version 1, 28/01/2014 44602f4aeb0Sopenharmony_ci - Initial draft 44702f4aeb0Sopenharmony_ci Version 2, 05/02/2014 44802f4aeb0Sopenharmony_ci - Removed clip behavior, replaced with undefined framebuffer contents if 44902f4aeb0Sopenharmony_ci client renders outside of given damage region 45002f4aeb0Sopenharmony_ci - Renamed to EGL_KHR_partial_update from EGL_KHR_frame_clip 45102f4aeb0Sopenharmony_ci - Added detailed parameter descriptions and error conditions 45202f4aeb0Sopenharmony_ci - Added dependency on GL_XXX_damage_region 45302f4aeb0Sopenharmony_ci - Defined interactions with EGL_EXT_buffer_age 45402f4aeb0Sopenharmony_ci Version 3, 04/03/2014 45502f4aeb0Sopenharmony_ci - Removed dependency on GL_XXX_damage_region 45602f4aeb0Sopenharmony_ci - Changed error on defining damage region after drawcalls to be undefined 45702f4aeb0Sopenharmony_ci rendering results instead 45802f4aeb0Sopenharmony_ci - Redefined interactions with EGL_EXT_buffer_age to allow both to exist 45902f4aeb0Sopenharmony_ci Version 4, 20/03/2014 46002f4aeb0Sopenharmony_ci - Modified language to allow use with EGLStream producer surfaces 46102f4aeb0Sopenharmony_ci - Clarified that surface must be the current *draw* surface 46202f4aeb0Sopenharmony_ci - Changed n_rects=0 behavior to set the damage region to the entire surface 46302f4aeb0Sopenharmony_ci - Clarified that rendering outside the damage region results in the entire 46402f4aeb0Sopenharmony_ci framebuffer becoming undefined 46502f4aeb0Sopenharmony_ci Version 5, 20/03/2014 46602f4aeb0Sopenharmony_ci - Updated to be based on EGL 1.5 spec 46702f4aeb0Sopenharmony_ci Version 6, 23/04/2014 46802f4aeb0Sopenharmony_ci -Added the pixel ownership logic from EGL_EXT_buffer_age 46902f4aeb0Sopenharmony_ci -Ported over the detailed description of buffer age from EGL_EXT_buffer_age 47002f4aeb0Sopenharmony_ci -Added a "New Functions" and "New Tokens" section. 47102f4aeb0Sopenharmony_ci -Added dependencies on EGL_EXT_swap_buffers_with_damage 47202f4aeb0Sopenharmony_ci Version 7, 20/05/2014 47302f4aeb0Sopenharmony_ci - Removing a couple of now-obsolete sentences 47402f4aeb0Sopenharmony_ci - An age of 1 *usually* means the previous swap was implemented as a copy. 47502f4aeb0Sopenharmony_ci - Reworded "For the purposes of buffer age tracking..." to reference the 47602f4aeb0Sopenharmony_ci conditions under which the different parts of the buffer are actually 47702f4aeb0Sopenharmony_ci defined, which depend on the damage region 47802f4aeb0Sopenharmony_ci Version 8, 20/05/2014 47902f4aeb0Sopenharmony_ci - Added issues list 48002f4aeb0Sopenharmony_ci Version 9, 12/08/2014 48102f4aeb0Sopenharmony_ci - Removed outdated modification to "Posting to a Window" 48202f4aeb0Sopenharmony_ci - Changed names and order of rects/n_rects to match 48302f4aeb0Sopenharmony_ci EGL_EXT_swap_buffers_with_damage 48402f4aeb0Sopenharmony_ci - Resolved issue 3 on EGL_EXT_swap_buffers_with_damage interactions 48502f4aeb0Sopenharmony_ci - Resolved issue 4 on EGL_BUFFER_PRESERVED swap behavior 48602f4aeb0Sopenharmony_ci - Resolved issue 5 on surface resize behavior 48702f4aeb0Sopenharmony_ci - Resolved issue 7 on multiple calls to eglSetDamageRegionKHR 48802f4aeb0Sopenharmony_ci - Added issue 8 and suggested resolution 48902f4aeb0Sopenharmony_ci - Added issue 9 and suggested resolution 49002f4aeb0Sopenharmony_ci - Added issue 10 and suggested resolution 49102f4aeb0Sopenharmony_ci Version 10, 19/08/2014 49202f4aeb0Sopenharmony_ci - Added section on terminology and damage types 49302f4aeb0Sopenharmony_ci Version 11, 10/09/2014 49402f4aeb0Sopenharmony_ci - Resolved outstanding issues 49502f4aeb0Sopenharmony_ci Version 12, 12/09/2014 49602f4aeb0Sopenharmony_ci - Added the restriction that you can only query the age of a surface while 49702f4aeb0Sopenharmony_ci it is the current draw surface. 49802f4aeb0Sopenharmony_ci Version 13, 18/09/2015 49902f4aeb0Sopenharmony_ci - Marked as a Display extension 50002f4aeb0Sopenharmony_ci - Changed remaining references to EGL_EXT_swap_buffers_with_damage to 50102f4aeb0Sopenharmony_ci EGL_KHR_swap_buffers_with_damage 502