102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci NOK_swap_region2 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_NOK_swap_region2 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciNotice 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Copyright 2010 Nokia. All rights reserved. 1202f4aeb0Sopenharmony_ci 1302f4aeb0Sopenharmony_ciContributors 1402f4aeb0Sopenharmony_ci 1502f4aeb0Sopenharmony_ci Robert Palmer 1602f4aeb0Sopenharmony_ci Sami Kyöstilä 1702f4aeb0Sopenharmony_ci 1802f4aeb0Sopenharmony_ciContacts 1902f4aeb0Sopenharmony_ci 2002f4aeb0Sopenharmony_ci Robert Palmer, Nokia (robert.palmer 'at' nokia.com) 2102f4aeb0Sopenharmony_ci Sami Kyöstilä, Nokia (sami.kyostila 'at' nokia.com) 2202f4aeb0Sopenharmony_ci 2302f4aeb0Sopenharmony_ciStatus 2402f4aeb0Sopenharmony_ci 2502f4aeb0Sopenharmony_ci Internally reviewed 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ciVersion 2802f4aeb0Sopenharmony_ci 2902f4aeb0Sopenharmony_ci 2 - April 29, 2010 3002f4aeb0Sopenharmony_ci 3102f4aeb0Sopenharmony_ciNumber 3202f4aeb0Sopenharmony_ci 3302f4aeb0Sopenharmony_ci EGL Extension #23 3402f4aeb0Sopenharmony_ci 3502f4aeb0Sopenharmony_ciDependencies 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ci Requires EGL 1.4 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ci This extension is written against the wording of the EGL 1.4 4002f4aeb0Sopenharmony_ci Specification. 4102f4aeb0Sopenharmony_ci 4202f4aeb0Sopenharmony_ciOverview 4302f4aeb0Sopenharmony_ci 4402f4aeb0Sopenharmony_ci This extension adds a new function which provides an alternative to 4502f4aeb0Sopenharmony_ci eglSwapBuffers. eglSwapBuffersRegion2NOK accepts two new parameters 4602f4aeb0Sopenharmony_ci in addition to those in eglSwapBuffers. The new parameters consist 4702f4aeb0Sopenharmony_ci of a pointer to a list of 4-integer blocks defining rectangles 4802f4aeb0Sopenharmony_ci (x, y, width, height) and an integer specifying the number of 4902f4aeb0Sopenharmony_ci rectangles in the list. 5002f4aeb0Sopenharmony_ci 5102f4aeb0Sopenharmony_ci The new parameters allow users to declare the region of the surface 5202f4aeb0Sopenharmony_ci that has been updated. The implementation uses this information to transfer 5302f4aeb0Sopenharmony_ci the updated region to the front buffer. Only the pixels within the 5402f4aeb0Sopenharmony_ci specified region are copied; any rendering outside that region will not 5502f4aeb0Sopenharmony_ci become visible on the window surface. This in contrast with the 5602f4aeb0Sopenharmony_ci EGL_NOK_swap_region extension which treats the modified region only as a 5702f4aeb0Sopenharmony_ci hint. 5802f4aeb0Sopenharmony_ci 5902f4aeb0Sopenharmony_ci This functional change is aimed at further reducing the processing and 6002f4aeb0Sopenharmony_ci bandwidth requirements of optimizations of applications whose graphics are 6102f4aeb0Sopenharmony_ci commonly subjected to region-based changes. Specifically, this extension 6202f4aeb0Sopenharmony_ci enables partial surface updates without requiring the use of preserved 6302f4aeb0Sopenharmony_ci swaps. 6402f4aeb0Sopenharmony_ci 6502f4aeb0Sopenharmony_ciNew Procedures and Functions 6602f4aeb0Sopenharmony_ci 6702f4aeb0Sopenharmony_ci EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK( 6802f4aeb0Sopenharmony_ci EGLDisplay dpy, 6902f4aeb0Sopenharmony_ci EGLSurface surface, 7002f4aeb0Sopenharmony_ci EGLint numRects, 7102f4aeb0Sopenharmony_ci const EGLint* rects); 7202f4aeb0Sopenharmony_ci 7302f4aeb0Sopenharmony_ciNew Types 7402f4aeb0Sopenharmony_ci 7502f4aeb0Sopenharmony_ci None 7602f4aeb0Sopenharmony_ci 7702f4aeb0Sopenharmony_ciNew Tokens 7802f4aeb0Sopenharmony_ci 7902f4aeb0Sopenharmony_ci None 8002f4aeb0Sopenharmony_ci 8102f4aeb0Sopenharmony_ciAdditions to Chapter 3 of the EGL 1.4 Specification (EGL Functions 8202f4aeb0Sopenharmony_ciand Errors) 8302f4aeb0Sopenharmony_ci 8402f4aeb0Sopenharmony_ci Add the following text to the end of the first subsection in 8502f4aeb0Sopenharmony_ci section 3.9.1 (prior to 'Native Window Resizing' subsection): 8602f4aeb0Sopenharmony_ci 8702f4aeb0Sopenharmony_ci "eglSwapBuffersRegion2NOK is an alternative to eglSwapBuffers 8802f4aeb0Sopenharmony_ci that allows the client to provide the region of the surface 8902f4aeb0Sopenharmony_ci which has been updated. This will allow processing and 9002f4aeb0Sopenharmony_ci bandwidth optimizations for applications whose graphics are 9102f4aeb0Sopenharmony_ci commonly subject to region-based changes. 9202f4aeb0Sopenharmony_ci 9302f4aeb0Sopenharmony_ci eglSwapBuffersRegion2NOK behaves in the same way as 9402f4aeb0Sopenharmony_ci eglSwapBuffers with the following modification: the additional 9502f4aeb0Sopenharmony_ci parameters <numRects> and <rects> provide specify a region which was 9602f4aeb0Sopenharmony_ci rendered to by the application. The implementation uses this 9702f4aeb0Sopenharmony_ci information to combine the modified backbuffer region with the previous 9802f4aeb0Sopenharmony_ci frontbuffer to form the new frontbuffer. The implementation guarantees 9902f4aeb0Sopenharmony_ci that all of the pixels within the modified region are posted for 10002f4aeb0Sopenharmony_ci display and none of the pixels outside the region are sourced. Only 10102f4aeb0Sopenharmony_ci back buffered surfaces can be used with eglSwapBuffersRegion2NOK. 10202f4aeb0Sopenharmony_ci 10302f4aeb0Sopenharmony_ci <rects> specifies a pointer to a list of 4-integer blocks 10402f4aeb0Sopenharmony_ci defining rectangles. The area covered by the rectangles 10502f4aeb0Sopenharmony_ci constitutes the region of the color buffer which has been 10602f4aeb0Sopenharmony_ci updated by the client. <numRects> specifies the number of 10702f4aeb0Sopenharmony_ci rectangles in the <rects> list. If <numRects> is set to zero 10802f4aeb0Sopenharmony_ci the update region is set to the width and height of the 10902f4aeb0Sopenharmony_ci surface. 11002f4aeb0Sopenharmony_ci 11102f4aeb0Sopenharmony_ci Each rectangle is specified as an integer 4-tuple in the form 11202f4aeb0Sopenharmony_ci (x, y, width, height). The x and y values provided by the client 11302f4aeb0Sopenharmony_ci must specify the bottom left corner of each rectangle as the 11402f4aeb0Sopenharmony_ci origin of the coordinate system is bottom left. Rectangles are 11502f4aeb0Sopenharmony_ci clipped (restricted) to the bounds of the EGLSurface. A 11602f4aeb0Sopenharmony_ci rectangle with width or height less than or equal 0 is ignored. 11702f4aeb0Sopenharmony_ci The region is defined by the union of all the specified 11802f4aeb0Sopenharmony_ci rectangles. The rectangles as specified must be disjoint. If 11902f4aeb0Sopenharmony_ci the rectangles are not disjoint or the user has rendered 12002f4aeb0Sopenharmony_ci outside of the region declared, the rendering results are 12102f4aeb0Sopenharmony_ci undefined." 12202f4aeb0Sopenharmony_ci 12302f4aeb0Sopenharmony_ci Insert "eglSwapBuffersRegion2NOK" appropriately after each instance 12402f4aeb0Sopenharmony_ci of "eglSwapBuffers" in the first paragraph in section 3.9.4 12502f4aeb0Sopenharmony_ci 12602f4aeb0Sopenharmony_ci Add the following before the last sentence in the first 12702f4aeb0Sopenharmony_ci paragraph in section 3.9.4 12802f4aeb0Sopenharmony_ci 12902f4aeb0Sopenharmony_ci "If eglSwapBuffersRegion2NOK is called and <numRects> is greater 13002f4aeb0Sopenharmony_ci than zero and <rects> is NULL, an EGL_BAD_PARAMETER error is 13102f4aeb0Sopenharmony_ci generated. If <numRects> is less than zero, an 13202f4aeb0Sopenharmony_ci EGL_BAD_PARAMETER error is generated." 13302f4aeb0Sopenharmony_ci 13402f4aeb0Sopenharmony_ci "If eglSwapBuffersRegion2NOK is called with a single buffered 13502f4aeb0Sopenharmony_ci <surface>, an EGL_BAD_MATCH error is generated." 13602f4aeb0Sopenharmony_ci 13702f4aeb0Sopenharmony_ciDependencies on OpenGL ES 13802f4aeb0Sopenharmony_ci 13902f4aeb0Sopenharmony_ci None 14002f4aeb0Sopenharmony_ci 14102f4aeb0Sopenharmony_ciDependencies on OpenVG 14202f4aeb0Sopenharmony_ci 14302f4aeb0Sopenharmony_ci None 14402f4aeb0Sopenharmony_ci 14502f4aeb0Sopenharmony_ci 14602f4aeb0Sopenharmony_ciIssues 14702f4aeb0Sopenharmony_ci 14802f4aeb0Sopenharmony_ci 1) Is there a limit on the number of rectangles that can be used? 14902f4aeb0Sopenharmony_ci Should there be a specified number which are guaranteed to be 15002f4aeb0Sopenharmony_ci supported? 15102f4aeb0Sopenharmony_ci 15202f4aeb0Sopenharmony_ci RESOLVED: This is limited by the amount of resources available to the 15302f4aeb0Sopenharmony_ci implementation. The implementation is free to fail with EGL_BAD_ALLOC if a 15402f4aeb0Sopenharmony_ci given update region cannot be processed due to resource constraints. 15502f4aeb0Sopenharmony_ci 15602f4aeb0Sopenharmony_ci 2) Are there any limitations on the location or size of rectangles? 15702f4aeb0Sopenharmony_ci 15802f4aeb0Sopenharmony_ci RESOLVED: The limitations placed on the validity of a rectangle is 15902f4aeb0Sopenharmony_ci that the width and height must be greater than zero and should not 16002f4aeb0Sopenharmony_ci overlap. Rectangles which have a width or height less than or equal 16102f4aeb0Sopenharmony_ci to zero will be ignored. If rectangles overlap the rendering 16202f4aeb0Sopenharmony_ci results are undefined. In addition all rectangles are clipped to 16302f4aeb0Sopenharmony_ci the area of the surface. Rectangles which are partially or 16402f4aeb0Sopenharmony_ci completely outside the boundary of the surface will not generate an 16502f4aeb0Sopenharmony_ci error. 16602f4aeb0Sopenharmony_ci 16702f4aeb0Sopenharmony_ci 3) How does eglSwapBuffersRegion2NOK interact with incremental 16802f4aeb0Sopenharmony_ci rendering? 16902f4aeb0Sopenharmony_ci 17002f4aeb0Sopenharmony_ci RESOLVED: This extension does not affect the client's ability to 17102f4aeb0Sopenharmony_ci perform incremental rendering. The ability to perform incremental 17202f4aeb0Sopenharmony_ci rendering is determined solely by the EGLSurface's 17302f4aeb0Sopenharmony_ci EGL_SWAP_BEHAVIOR attribute. The use of eglSwapBuffersRegion2NOK to 17402f4aeb0Sopenharmony_ci describe changed regions can still assist window system composition 17502f4aeb0Sopenharmony_ci optimizations even if the client is physically redrawing the entire 17602f4aeb0Sopenharmony_ci surface on every frame. 17702f4aeb0Sopenharmony_ci 17802f4aeb0Sopenharmony_ci If EGL_SWAP_BEHAVIOR is EGL_BUFFER_PRESERVED, the client can 17902f4aeb0Sopenharmony_ci restrict their rendering to a particular region (e.g. using scissor 18002f4aeb0Sopenharmony_ci rects) and then declare this region using eglSwapBuffersRegion2NOK. 18102f4aeb0Sopenharmony_ci 18202f4aeb0Sopenharmony_ci If EGL_SWAP_BEHAVIOR is EGL_BUFFER_DESTROYED, the client can 18302f4aeb0Sopenharmony_ci also restrict rendering to a particular region of the surface, but that 18402f4aeb0Sopenharmony_ci region must be completely re-rendered because the previous frame contents 18502f4aeb0Sopenharmony_ci are no longer available within that region. The application can then post 18602f4aeb0Sopenharmony_ci this region with eglSwapBuffersRegion2NOK. Since the buffer posting is 18702f4aeb0Sopenharmony_ci guaranteed to be limited to the declared region, the application does not 18802f4aeb0Sopenharmony_ci need to re-render or otherwise ensure pixel data outside the updated region 18902f4aeb0Sopenharmony_ci is valid. 19002f4aeb0Sopenharmony_ci 19102f4aeb0Sopenharmony_ci 4) How is this extension an improvement over EGL_NOK_swap_region? 19202f4aeb0Sopenharmony_ci 19302f4aeb0Sopenharmony_ci RESOLVED: This extension builds on the previous EGL_NOK_swap_region 19402f4aeb0Sopenharmony_ci extension by requiring that the implementation considers the update region 19502f4aeb0Sopenharmony_ci provided by the application as a mandate rather than a hint. This allows 19602f4aeb0Sopenharmony_ci for region-restricted rendering without requiring the use of preserved buffer 19702f4aeb0Sopenharmony_ci swaps which may be relatively expensive for the implementation. 19802f4aeb0Sopenharmony_ci 19902f4aeb0Sopenharmony_ci Furthermore, whilst preserved swap behaviour is necessary for incremental 20002f4aeb0Sopenharmony_ci rendering, many applications fully re-render modified surface regions and 20102f4aeb0Sopenharmony_ci so don't require preserved swap behaviour. This extension provides a 20202f4aeb0Sopenharmony_ci lighter weight surface update mechanism for such applications. 20302f4aeb0Sopenharmony_ci 20402f4aeb0Sopenharmony_ci 5) How does this extension compare to MESA_copy_sub_buffer? 20502f4aeb0Sopenharmony_ci 20602f4aeb0Sopenharmony_ci RESOLVED: There are two main differences between MESA_copy_sub_buffer and 20702f4aeb0Sopenharmony_ci this extension: 20802f4aeb0Sopenharmony_ci 20902f4aeb0Sopenharmony_ci 1. This extension allows for arbitrary update regions instead of a 21002f4aeb0Sopenharmony_ci single rectangle. 21102f4aeb0Sopenharmony_ci 21202f4aeb0Sopenharmony_ci 2. eglSwapBuffersRegion2NOK is specified to be a frame swap, so the 21302f4aeb0Sopenharmony_ci implementation is free to apply destructive swap behavior in 21402f4aeb0Sopenharmony_ci conjunction with this function call. This may allow for a 21502f4aeb0Sopenharmony_ci performance improvement. 21602f4aeb0Sopenharmony_ci 21702f4aeb0Sopenharmony_ciRevision History 21802f4aeb0Sopenharmony_ci 21902f4aeb0Sopenharmony_ci Version 1, 2010/04/28 (Sami Kyöstilä) 22002f4aeb0Sopenharmony_ci - First revision based on EGL_NOK_swap_region version 10. 22102f4aeb0Sopenharmony_ci Version 2, 2010/04/29 (Sami Kyöstilä) 22202f4aeb0Sopenharmony_ci - Specify operation in terms of copying from the back buffer into the 22302f4aeb0Sopenharmony_ci front buffer instead of involving the the system composition or the 22402f4aeb0Sopenharmony_ci display. 22502f4aeb0Sopenharmony_ci - Disallowed usage with anything else than back buffered surfaces. 22602f4aeb0Sopenharmony_ci - Clarified some sentences. 22702f4aeb0Sopenharmony_ci