15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_buffer_age 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GLX_EXT_buffer_age 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciNotice 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Copyright 2011,2012 Intel Cooperation. All rights reserved. 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Robert Bragg 165bd8deadSopenharmony_ci Neil Roberts 175bd8deadSopenharmony_ci James Jones 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciContacts 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Robert Bragg, Intel (robert.bragg 'at' intel.com) 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciStatus 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Draft 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciVersion 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci 8 - Sept 20, 2012 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciNumber 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci 427 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ciDependencies 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci Requires GLX 1.4 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci This extension is written against the wording of the GLX 1.4 405bd8deadSopenharmony_ci Specification. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci GLX_OML_swap_method trivially interacts with this extension. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ciOverview 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci The aim of this extension is to expose enough information to 475bd8deadSopenharmony_ci applications about how the driver manages the set of front and 485bd8deadSopenharmony_ci back buffers associated with a given surface to allow applications 495bd8deadSopenharmony_ci to re-use the contents of old frames and minimize how much must be 505bd8deadSopenharmony_ci redrawn for the next frame. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci There are lots of different ways for a driver to manage these 535bd8deadSopenharmony_ci buffers, from double buffering, different styles of triple 545bd8deadSopenharmony_ci buffering and even n-buffering or simply single buffer rendering. 555bd8deadSopenharmony_ci We also need to consider that power management events or memory 565bd8deadSopenharmony_ci pressure events might also result in some of the buffers not 575bd8deadSopenharmony_ci currently in-use being freed. 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci This extension lets applications query the age of the back buffer 605bd8deadSopenharmony_ci contents for a GLX surface as the number of frames elapsed since 615bd8deadSopenharmony_ci the contents were most recently defined. The back buffer can 625bd8deadSopenharmony_ci either be reported as invalid (has an age of 0) or it may be 635bd8deadSopenharmony_ci reported to contain the contents from n frames prior to the 645bd8deadSopenharmony_ci current frame. 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci Once the application has queried the buffer age, the age of 675bd8deadSopenharmony_ci contents remains valid until the end of the frame for all pixels 685bd8deadSopenharmony_ci that continue to pass the pixel ownership test. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci For example if you consider a double buffered application drawing 715bd8deadSopenharmony_ci a small spinning icon, but everything else in the scene is static. 725bd8deadSopenharmony_ci If we know that 2 buffers are continuously being recycled each 735bd8deadSopenharmony_ci time glXSwapBuffers is called then even though 100s of frames may 745bd8deadSopenharmony_ci need to be drawn to animate the icon it can be seen that the two 755bd8deadSopenharmony_ci buffers are remaining unchanged except within the bounds of the 765bd8deadSopenharmony_ci icon. In this scenario ideally the application would simply 775bd8deadSopenharmony_ci perform an incremental update of the old buffer instead of 785bd8deadSopenharmony_ci redundantly redrawing all the static parts of the scene. The 795bd8deadSopenharmony_ci problem up until now though has been that GLX doesn't report how 805bd8deadSopenharmony_ci buffers may be recycled so it wasn't safe for applications to try 815bd8deadSopenharmony_ci and reuse their contents. Now applications can keep track of all 825bd8deadSopenharmony_ci the regions that have changed over the last n frames and by 835bd8deadSopenharmony_ci knowing the age of the buffer they know how to efficiently repair 845bd8deadSopenharmony_ci buffers that are re-cycled instead of redrawing the entire scene. 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ciNew Procedures and Functions 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci None 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ciNew Tokens 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci GLX_BACK_BUFFER_AGE_EXT 0x20F4 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ciAdditions to Section 3.3.6 of the GLX 1.4 Specification (Querying Attributes) 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci Add the following text to the description for glXQueryDrawable 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci Querying GLX_BACK_BUFFER_AGE_EXT returns the age of the color 995bd8deadSopenharmony_ci contents of the current back-buffer as the number of frames 1005bd8deadSopenharmony_ci elapsed since it was most recently defined. Applications can, 1015bd8deadSopenharmony_ci under certain conditions described below, use this age to 1025bd8deadSopenharmony_ci safely rely on the contents of old back-buffers to potentially 1035bd8deadSopenharmony_ci reduce the amount of redrawing they do each frame. A frame is 1045bd8deadSopenharmony_ci the period between calls to any of the functions in table 3.X, 1055bd8deadSopenharmony_ci hereafter referred to as "frame boundaries." 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci Function name 1085bd8deadSopenharmony_ci -------------------- 1095bd8deadSopenharmony_ci glXSwapBuffers 1105bd8deadSopenharmony_ci glXSwapBuffersMscOML 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci Table 3.X, Frame Boundary Functions 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ci Buffers' ages are initialized to 0 at buffer creation time. 1155bd8deadSopenharmony_ci When a frame boundary is reached, the following occurs before 1165bd8deadSopenharmony_ci any exchanging or copying of color buffers: 1175bd8deadSopenharmony_ci 1185bd8deadSopenharmony_ci * The current back buffer's age is set to 1. 1195bd8deadSopenharmony_ci * Any other color buffers' ages are incremented by 1 if 1205bd8deadSopenharmony_ci their age was previously greater than 0. 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci For the purposes of buffer age tracking, a buffer's content 1235bd8deadSopenharmony_ci is considered defined when its age transitions to a value 1245bd8deadSopenharmony_ci greater than 0. 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci For example, with a double buffered surface and an 1275bd8deadSopenharmony_ci implementation that swaps via buffer exchanges, the age would 1285bd8deadSopenharmony_ci usually be 2. With a triple buffered surface the age would 1295bd8deadSopenharmony_ci usually be 3. An age of 1 means the previous swap was 1305bd8deadSopenharmony_ci implemented as a copy. An age of 0 means the buffer has only 1315bd8deadSopenharmony_ci just been initialized and the contents are undefined. Single 1325bd8deadSopenharmony_ci buffered drawables have no frame boundaries and therefore 1335bd8deadSopenharmony_ci always have an age of 0. 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ci Frame boundaries are the only events that can set a buffer's 1365bd8deadSopenharmony_ci age to a positive value. Once GLX_BACK_BUFFER_AGE_EXT has been 1375bd8deadSopenharmony_ci queried then it can be assumed that the age will remain valid 1385bd8deadSopenharmony_ci until the next frame boundary. GLX implementations are 1395bd8deadSopenharmony_ci permitted, but not required, to reset the buffer age in 1405bd8deadSopenharmony_ci response to pixel ownership test changes for any pixels within 1415bd8deadSopenharmony_ci the drawable, or if new pixels are added to or removed from 1425bd8deadSopenharmony_ci the drawable, i.e., the drawable is resized. A reset of this 1435bd8deadSopenharmony_ci nature does not affect the age of pixels that pass the pixel 1445bd8deadSopenharmony_ci ownership test before and after the event that caused the 1455bd8deadSopenharmony_ci reset. In other words, applications can assume that no event 1465bd8deadSopenharmony_ci will invalidate the content of pixels that continuously pass 1475bd8deadSopenharmony_ci the pixel test between when the buffer age was queried and the 1485bd8deadSopenharmony_ci following frame boundary. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci It is up to applications to track pixel ownership using data 1515bd8deadSopenharmony_ci collected from window configuration, expose, and any other 1525bd8deadSopenharmony_ci relevant X events. 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci If the GLX implementation decides to free un-used back-buffers 1555bd8deadSopenharmony_ci when the system is under memory pressure or in response to 1565bd8deadSopenharmony_ci power-management events then GLX will return an age of 0 when 1575bd8deadSopenharmony_ci it allocates a new buffer at the start of a new frame. 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci GLX_BACK_BUFFER_AGE_EXT state, while a property of the GLX 1605bd8deadSopenharmony_ci drawable that owns the buffers, lives in the address space of 1615bd8deadSopenharmony_ci the current GL server context. That is, if a GLX drawable is 1625bd8deadSopenharmony_ci used with multiple direct-rendering contexts in separate 1635bd8deadSopenharmony_ci processes, the buffer age is not guaranteed to be 1645bd8deadSopenharmony_ci synchronized across the processes. Similarly, if a GLX 1655bd8deadSopenharmony_ci drawable is used with both an indirect and a direct context, 1665bd8deadSopenharmony_ci the buffer age may depend on which context the drawable is 1675bd8deadSopenharmony_ci bound to when it is queried. However, binding and unbinding a 1685bd8deadSopenharmony_ci drawable to and from one or more contexts in the same address 1695bd8deadSopenharmony_ci space will not affect the ages of any buffers in that 1705bd8deadSopenharmony_ci drawable. 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci Add the following text to the last paragraph of the description for 1735bd8deadSopenharmony_ci glXQueryDrawable describing error conditions. 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci If querying GLX_BACK_BUFFER_AGE_EXT and <draw> is not bound to 1765bd8deadSopenharmony_ci the calling thread's current context a GLXBadDrawable error is 1775bd8deadSopenharmony_ci generated. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ciDependencies on OpenGL 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci None 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ciDependencies on GLX_OML_sync_control 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci If GLX_OML_sync_control is not supported, glXSwapBuffersMscOML is 1865bd8deadSopenharmony_ci removed from Table 3.X. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ciIssues 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci 1) How can an application know that all pixels of a re-usable 1915bd8deadSopenharmony_ci buffer were originally owned by the current context? 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci RESOLVED: It is up to the application to track pixel 1945bd8deadSopenharmony_ci ownership using existing X11 events, such as expose or 1955bd8deadSopenharmony_ci configure notify events. 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ci 2) What are the semantics if the buffer age attribute is queried 1985bd8deadSopenharmony_ci for a drawable that isn't bound to the calling thread's 1995bd8deadSopenharmony_ci context? 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci RESOLVED: we report a GLXBadDrawable error. 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci 3) Is the buffer age tracked in the GLX client or the GLX server? 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci RESOLVED: Querying the buffer age needs to be a fast 2065bd8deadSopenharmony_ci operation, so it makes sense to track it in the GLX client. 2075bd8deadSopenharmony_ci However, GLX implementations without support for direct 2085bd8deadSopenharmony_ci rendering likely won't have any per-drawable client state. 2095bd8deadSopenharmony_ci Therefore, the buffer age is tracked in the same address space 2105bd8deadSopenharmony_ci as the current GL server context. For direct rendering, this 2115bd8deadSopenharmony_ci is the GLX client. For indirect rendering, it is the GLX 2125bd8deadSopenharmony_ci server. The buffer age is not synchronized between the two 2135bd8deadSopenharmony_ci when changing contexts. 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci 4) What is the buffer age of a single buffered drawable? 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci RESOLVED: 0. This falls out implicitly from the buffer age 2185bd8deadSopenharmony_ci calculations, which dictate that a buffer's age starts at 0, 2195bd8deadSopenharmony_ci and is only incremented by frame boundaries. Since frame 2205bd8deadSopenharmony_ci boundary functions do not affect single buffered drawables, 2215bd8deadSopenharmony_ci their age will always be 0. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ci 5) What guarantees are provided after querying the buffer age? 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci RESOLVED: The buffer age of pixels which continue to pass the 2265bd8deadSopenharmony_ci pixel ownership test must remain valid until the next frame 2275bd8deadSopenharmony_ci boundary otherwise applications can't be absolutely sure of 2285bd8deadSopenharmony_ci the consistency of their rendered content. Implementations 2295bd8deadSopenharmony_ci may reset the queryable age of the buffer when pixel ownership 2305bd8deadSopenharmony_ci changes occur. This is further clarified in section 3.3.6 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ciRevision History 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci Version 1, 07/02/2012 2355bd8deadSopenharmony_ci - First draft 2365bd8deadSopenharmony_ci Version 2, 08/03/2012 2375bd8deadSopenharmony_ci - Document that once the age is queried it remains valid until 2385bd8deadSopenharmony_ci the end of the frame. 2395bd8deadSopenharmony_ci Version 3, 08/03/2012 2405bd8deadSopenharmony_ci - Clarify that only buffers who's contents were fully owned by 2415bd8deadSopenharmony_ci the context are tracked. 2425bd8deadSopenharmony_ci Version 4 21/03/2012 2435bd8deadSopenharmony_ci - Document that an error will be generated if querying the age 2445bd8deadSopenharmony_ci for a drawable not bound to the current context. 2455bd8deadSopenharmony_ci Version 5 21/08/2012 2465bd8deadSopenharmony_ci - Relax pixel ownership requirements 2475bd8deadSopenharmony_ci - Slightly tweak and explicitly document buffer age calculation 2485bd8deadSopenharmony_ci - Note that buffer age is tracked in the GLX client when using 2495bd8deadSopenharmony_ci direct rendering. 2505bd8deadSopenharmony_ci Version 6 11/09/2012 2515bd8deadSopenharmony_ci - Clarify guarantees once the age has been queried 2525bd8deadSopenharmony_ci Version 7 17/09/2012 2535bd8deadSopenharmony_ci - Further clarify pixel age vs. buffer age 2545bd8deadSopenharmony_ci - Rename GLX_BUFFER_AGE_EXT to GLX_BACK_BUFFER_AGE_EXT 2555bd8deadSopenharmony_ci - Assign value to GLX_BACK_BUFFER_AGE_EXT 2565bd8deadSopenharmony_ci Version 8 20/09/2012 2575bd8deadSopenharmony_ci - Remove overly precise definition of buffer age 258