15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci APPLE_object_purgeable 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_APPLE_object_purgeable 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Andrew Barnes 125bd8deadSopenharmony_ci Bob Beretta 135bd8deadSopenharmony_ci Kenneth Dyke 145bd8deadSopenharmony_ci Alex Eddy 155bd8deadSopenharmony_ci John Harper 165bd8deadSopenharmony_ci Charlie Lao 175bd8deadSopenharmony_ci Jeremy Sandmel 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciContact 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Charlie Lao, Apple Computer Inc. (clao 'at' apple.com) 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciStatus 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci TBD 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciVersion 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci Last Modified Date: September 29, 2006 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciNumber 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci 371 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ciDependencies 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci OpenGL 1.5 is required. 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci The extension is written against the OpenGL 1.5 Specification. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciOverview 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension provides the ability to mark the storage of OpenGL 445bd8deadSopenharmony_ci objects as "purgeable". 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci Many of today's modern virtual memory systems include the concept of 475bd8deadSopenharmony_ci purgeability in order to avoid unnecessary paging when the object 485bd8deadSopenharmony_ci contents are no longer needed. In OpenGL, objects such as textures, 495bd8deadSopenharmony_ci vertex buffers, pixel buffers, and renderbuffers all have 505bd8deadSopenharmony_ci significant storage requirements. By default, the OpenGL is 515bd8deadSopenharmony_ci required to preserve the contents of these objects regardless of 525bd8deadSopenharmony_ci system resource stress, such as vram shortage or physical memory 535bd8deadSopenharmony_ci shortage. Often this is accomplished by temporarily paging the 545bd8deadSopenharmony_ci contents of objects that are not currently needed to some kind of 555bd8deadSopenharmony_ci secondary storage area. This paging operation can be an unnecessary 565bd8deadSopenharmony_ci computational expense in the cases where the data is not going to be 575bd8deadSopenharmony_ci used again or where the content can be reproduced by the application 585bd8deadSopenharmony_ci with less expense than the paging operation would require. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci This extension defines a mechanism for the application to mark the 615bd8deadSopenharmony_ci storage of OpenGL objects as "purgeable" in order to influence these 625bd8deadSopenharmony_ci paging operations. The application can further control the 635bd8deadSopenharmony_ci semantics of making object storage "purgeable" with two options 645bd8deadSopenharmony_ci ("volatile" and "released") and "unpurgeable" with two options 655bd8deadSopenharmony_ci ("undefined" and "retained") 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci Applications that use this extension will typically follow one of 685bd8deadSopenharmony_ci two operational models. The typical model for most applications is 695bd8deadSopenharmony_ci to mark an object storage as "purgeable" with the "volatile" option, 705bd8deadSopenharmony_ci and then later mark the storage as "unpurgeable" with the "retained" 715bd8deadSopenharmony_ci option. When this happens, the application may or may not need to 725bd8deadSopenharmony_ci respecify the object contents, depending on the whether the object 735bd8deadSopenharmony_ci storage was actually released. The application can find out whether 745bd8deadSopenharmony_ci the storage was released by examining the return value of the 755bd8deadSopenharmony_ci function which marks the storage as "unpurgeable". This model is 765bd8deadSopenharmony_ci useful when the application does not know at the time it marks the 775bd8deadSopenharmony_ci object storage as "purgeable" whether it will later need those 785bd8deadSopenharmony_ci contents to be valid. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci Another operational model is for an application to mark the storage 815bd8deadSopenharmony_ci for an object as "purgeable" with the "released" option, and then 825bd8deadSopenharmony_ci later mark the object "unpurgeable" with the "undefined" option. In 835bd8deadSopenharmony_ci this latter model, the application intends to unconditionally reload 845bd8deadSopenharmony_ci the object contents later on, and so it tells the GL that it is okay 855bd8deadSopenharmony_ci if the contents are "undefined" when the storage is re-allocated. 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci Note that in both models, it is possible for the contents to become 885bd8deadSopenharmony_ci undefined since they could have actually been purged from the system 895bd8deadSopenharmony_ci in either case. The various options are still useful, however, 905bd8deadSopenharmony_ci since they give more information to the GL about what the 915bd8deadSopenharmony_ci application expects to happen and the GL can use this information to 925bd8deadSopenharmony_ci make better predictions about which paging choices will be more 935bd8deadSopenharmony_ci efficient. 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ciIP Status 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci No known IP claims. 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ciIssues 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci 1. Why use two functions rather than just one? 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci The reason we chose two functions is that switching between the 1045bd8deadSopenharmony_ci two possible object states - purgeable and unpurgeable - might 1055bd8deadSopenharmony_ci be expensive. In addition, the return values of the operation 1065bd8deadSopenharmony_ci may be different depending on what state the object storage is 1075bd8deadSopenharmony_ci in and whether it has been purged or not. Therefore, we want to 1085bd8deadSopenharmony_ci enforce that the state is changed in matching pairs of function 1095bd8deadSopenharmony_ci calls, similar to Begin/End. In order to enforce this behavior, 1105bd8deadSopenharmony_ci we require two functions. 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci Applications are required to call ObjectPurgeable and 1135bd8deadSopenharmony_ci ObjectUnpurgeable in matched pairs, otherwise INVALID_OPERATION 1145bd8deadSopenharmony_ci is generated. 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci 2. What does calling ObjectUnpurgeable with <option> set to 1175bd8deadSopenharmony_ci UNDEFINED_APPLE really mean? 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci An application calls ObjectUnpurgeable in order to change the 1205bd8deadSopenharmony_ci state of the object storage to unpurgeable. This is the 1215bd8deadSopenharmony_ci "default" state for object storage as defined traditionally in 1225bd8deadSopenharmony_ci GL. 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci Further, by using the <option> of UNDEFINED_APPLE, the 1255bd8deadSopenharmony_ci application is also indicating that it does not care about the 1265bd8deadSopenharmony_ci previous contents of the storage, if they still exist. This 1275bd8deadSopenharmony_ci gives the GL the freedom to allocate new storage or simply reuse 1285bd8deadSopenharmony_ci the old storage without spending time to figure out whether the 1295bd8deadSopenharmony_ci storage was actually freed and without having to tell the 1305bd8deadSopenharmony_ci application which choice was made. In addition, this allows the 1315bd8deadSopenharmony_ci function to return without blocking. 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci In contrast, calling ObjectUnpurgeable with <option> set to 1345bd8deadSopenharmony_ci RETAINED_APPLE requests the GL actually determine whether or not 1355bd8deadSopenharmony_ci it is possible to retain the original contents of the object, 1365bd8deadSopenharmony_ci and to restore the object storage to the previous contents, if 1375bd8deadSopenharmony_ci they still exist. This operation generally requires a flush of 1385bd8deadSopenharmony_ci the current command stream and often involveds additional work 1395bd8deadSopenharmony_ci to determine the state of object. 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci 3. What's the difference between calling ObjectPurgeable and calling 1425bd8deadSopenharmony_ci DeleteTextures? 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci Calling ObjectPurgeable allows the GL to release all storage 1455bd8deadSopenharmony_ci that the GL has allocated for the object's contents, but will 1465bd8deadSopenharmony_ci still retain the object name and other non-content related state 1475bd8deadSopenharmony_ci of the object. If the application intends to re-use the object 1485bd8deadSopenharmony_ci again later, it will indicate so calling ObjectUnpurgeable. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci In contrast, DeleteTextures deletes the object storage, the 1515bd8deadSopenharmony_ci object name, and the rest of the object state. The object can 1525bd8deadSopenharmony_ci never again be used. 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci Note that this means to set the object's name as unused and to 1555bd8deadSopenharmony_ci delete non-content related state of the object, the application 1565bd8deadSopenharmony_ci is still responsible for calling DeleteTextures. 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci There are some additional subtle differences though. 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci In general, calling ObjectPurgeable with the <option> 1615bd8deadSopenharmony_ci VOLATILE_APPLE requires less work of the GL than calling 1625bd8deadSopenharmony_ci ObjectPurgeable with the <option> set to RELEASED_APPLE. 1635bd8deadSopenharmony_ci Further, calling ObjectPurgeable with either option generally 1645bd8deadSopenharmony_ci requires less work of the GL than DeleteTextures. 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci Applications are encouraged, therefore, to use ObjectPurgeable 1675bd8deadSopenharmony_ci with the <option> set to VOLATILE_APPLE where possible and fall 1685bd8deadSopenharmony_ci back to ObjectPurgeable with the <option> set to RELEASED_APPLE 1695bd8deadSopenharmony_ci only if they prefer to have the GL do some amount of work to try 1705bd8deadSopenharmony_ci to release the storage. Only if the application really requires 1715bd8deadSopenharmony_ci the deletion of the object itself, should the application use 1725bd8deadSopenharmony_ci DeleteTextures. 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci Finally note, though the discussion above refers to 1755bd8deadSopenharmony_ci DeleteTextures, the same semantics apply to all object types 1765bd8deadSopenharmony_ci with Delete* operations, such as DeleteBuffers, 1775bd8deadSopenharmony_ci DeleteRenderbuffers, etc. that support this extension. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci 4. What should happen when ObjectPurgeable or ObjectUnpurgeable is 1805bd8deadSopenharmony_ci called between Begin/End? 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci This is illegal and returns INVALID_OPERATION error. 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci 5. What should happen if ObjectPurgeable or ObjectUnpurgeable is 1855bd8deadSopenharmony_ci called on a currently bound texture, whether it is bound to the 1865bd8deadSopenharmony_ci current context or another context? 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci If the current context marks the storage of a currently bound 1895bd8deadSopenharmony_ci object as "purgeable", then attempts to read from or write to 1905bd8deadSopenharmony_ci the contents of that storage will result in undefined behavior. 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci Considering the multiple context case, we use the precedent of 1935bd8deadSopenharmony_ci all other state changes made by one context to an object bound 1945bd8deadSopenharmony_ci by another context. Namely, changes made to an object by 1955bd8deadSopenharmony_ci context A or only guaranteed to be "visible" to context B the 1965bd8deadSopenharmony_ci next time context B binds that object. In the interim period 1975bd8deadSopenharmony_ci the results of the state change are undefined. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci For this extension, this means if context A marks an object's 2005bd8deadSopenharmony_ci storage as purgeable and that object is also bound by context B, 2015bd8deadSopenharmony_ci then it is undefined as to whether the object's storage will 2025bd8deadSopenharmony_ci have defined contents when used by context B. Note that in the 2035bd8deadSopenharmony_ci case of this particular extension, the whole point is to allow 2045bd8deadSopenharmony_ci the contents of the storage to become undefined so this is not a 2055bd8deadSopenharmony_ci particularly surprising outcome. 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ci Applications are therefore advised to assume that they can not 2085bd8deadSopenharmony_ci rely on validity of the contents of any object whose storage has 2095bd8deadSopenharmony_ci been marked purgeable by any other context. Further, until some 2105bd8deadSopenharmony_ci context has marked the object storage as "unpurgeable" again and 2115bd8deadSopenharmony_ci the current context has re-bound the object, the current context 2125bd8deadSopenharmony_ci should not assume the contents are valid either. And even then 2135bd8deadSopenharmony_ci the contents should be assumed to be valid if and only if the 2145bd8deadSopenharmony_ci contents have been respecified or ObjectUnpurgeable returned the 2155bd8deadSopenharmony_ci value RETAINED_APPLE. 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci 6. What should happen if the TestObject routine from the APPLE_fence 2185bd8deadSopenharmony_ci extension is called on an object whose storage has been marked 2195bd8deadSopenharmony_ci purgeable? 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci In short, it should operate "normally". 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ci To be specific, if TestObject is called after calling 2245bd8deadSopenharmony_ci ObjectPurgeable with <option> set to VOLATILE_APPLE, the GL will 2255bd8deadSopenharmony_ci still determine if there are any pending operations using the 2265bd8deadSopenharmony_ci object, and TestObject will return TRUE or FALSE depending on 2275bd8deadSopenharmony_ci what it finds. 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci If TestObject is called after calling ObjectPurgeable with 2305bd8deadSopenharmony_ci <option> set to RELEASED_APPLE, the TestObject will generally 2315bd8deadSopenharmony_ci immediately return TRUE even though the object may still be in 2325bd8deadSopenharmony_ci use. This is acceptable since from user's point of view, the 2335bd8deadSopenharmony_ci object's storage has been freed from further use by the GL. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci 7. How does APPLE_object_purgeable interact with the 2365bd8deadSopenharmony_ci APPLE_texture_range extension? 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci First note that depending on the value of the storage hint 2395bd8deadSopenharmony_ci provided in the APPLE_texture_range extension, the GL may have 2405bd8deadSopenharmony_ci made multiple copies of the texture data. 2415bd8deadSopenharmony_ci 2425bd8deadSopenharmony_ci In general, calling ObjectPurgeable with <option> set to 2435bd8deadSopenharmony_ci VOLATILE_APPLE option indicates that the GL should mark the 2445bd8deadSopenharmony_ci multiple copies of the storage as candidates for eviction but 2455bd8deadSopenharmony_ci should only release them as needed. In contrast, using the 2465bd8deadSopenharmony_ci <option> RELEASED_APPLE indicates that GL should try to go ahead 2475bd8deadSopenharmony_ci and release the storage for as many of these copies as is 2485bd8deadSopenharmony_ci efficient. 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci 8. How does APPLE_object_purgeable interact with the 2515bd8deadSopenharmony_ci APPLE_client_storage extension? 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci For reference, APPLE_client_storage allows the application to 2545bd8deadSopenharmony_ci indicate that it will be responsible for allocating and 2555bd8deadSopenharmony_ci retaining the storage for a texture object. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci In the APPLE_object_purgeable extension it is up to the 2585bd8deadSopenharmony_ci implementation to determine what happens when an object's 2595bd8deadSopenharmony_ci storage is marked purgeable and its up to the application to 2605bd8deadSopenharmony_ci query to determine whether the storage has been released. Given 2615bd8deadSopenharmony_ci that, the APPLE_client_storage has no real practical 2625bd8deadSopenharmony_ci interactions with APPLE_object_purgeable. 2635bd8deadSopenharmony_ci 2645bd8deadSopenharmony_ci However, if APPLE_client_storage is supported on a platform that 2655bd8deadSopenharmony_ci gives the application control over the volatility of of client 2665bd8deadSopenharmony_ci memory, for instance via some sort of virtual memory system 2675bd8deadSopenharmony_ci call, then it's possible the application use the 2685bd8deadSopenharmony_ci platform-specific virtual memory API to mark as volatile the the 2695bd8deadSopenharmony_ci memory backing a texture using APPLE_client_storage for its 2705bd8deadSopenharmony_ci storage. The application on such a platform would be 2715bd8deadSopenharmony_ci responsible for using additional virtual memory system calls to 2725bd8deadSopenharmony_ci determine what happened to memory that was marked purgeable when 2735bd8deadSopenharmony_ci it goes to access that memory later on. In this scenario, the 2745bd8deadSopenharmony_ci effect would be very similar to the results of using the 2755bd8deadSopenharmony_ci APPLE_object_purgeable to mark a texture object's storage as 2765bd8deadSopenharmony_ci purgeable, but there is no direct interaction between the two 2775bd8deadSopenharmony_ci API's. 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci 9. How does APPLE_object_purgeable interact with the 2805bd8deadSopenharmony_ci aglSurfaceTexture API? 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ci For reference, the aglSurfaceTexture allows the application to 2835bd8deadSopenharmony_ci specify an AGL drawable as the storage for a GL texture object. 2845bd8deadSopenharmony_ci Such a texture object is informally called a "surface texture". 2855bd8deadSopenharmony_ci 2865bd8deadSopenharmony_ci Similar to the APPLE_client_storage case, it is up to the API 2875bd8deadSopenharmony_ci that allocated the storage object to handle the purgeability of 2885bd8deadSopenharmony_ci that object. Given that, the APPLE_client_storage has no real 2895bd8deadSopenharmony_ci practical interactions with AGL surface textures. 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci 2925bd8deadSopenharmony_ci 10. How does APPLE_object_purgeable interact with the 2935bd8deadSopenharmony_ci ARB_vertex_buffer_object and ARB_pixel_buffer_object extensions? 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci The interactions should be analogous to those that occur with 2965bd8deadSopenharmony_ci texture objects. 2975bd8deadSopenharmony_ci 2985bd8deadSopenharmony_ci To mark the storage for a buffer object as purgeable or 2995bd8deadSopenharmony_ci unpurgeable, the application can specify BUFFER_OBJECT_APPLE as 3005bd8deadSopenharmony_ci the <objectType> parameter in ObjectPurgeable or 3015bd8deadSopenharmony_ci ObjectUnpurgeable, respectively. The same rules about undefined 3025bd8deadSopenharmony_ci results from reading from or writing to the buffer object 3035bd8deadSopenharmony_ci storage while PURGEABLE_APPLE is TRUE apply as well. 3045bd8deadSopenharmony_ci 3055bd8deadSopenharmony_ci 13. After an object's storage has been marked as purgeable, what 3065bd8deadSopenharmony_ci should happen if CopyTexImage{1|2}D, CopyTexSubImage{1|2}D, 3075bd8deadSopenharmony_ci TexSubImage{1|2|3}D, or TexImage{1|2|3}D is called on the 3085bd8deadSopenharmony_ci texture? What if user try to texture from it or render to it? 3095bd8deadSopenharmony_ci 3105bd8deadSopenharmony_ci After an object's storage has been marked purgeable, any usage 3115bd8deadSopenharmony_ci of the object is undefined until it is marked unpurgeable. 3125bd8deadSopenharmony_ci 3135bd8deadSopenharmony_ci 3145bd8deadSopenharmony_ciNew Procedures and Functions 3155bd8deadSopenharmony_ci 3165bd8deadSopenharmony_ci enum ObjectPurgeableAPPLE(enum objectType, uint name, enum option) 3175bd8deadSopenharmony_ci enum ObjectUnpurgeableAPPLE(enum objectType, uint name, enum option) 3185bd8deadSopenharmony_ci void GetObjectParameterivAPPLE(enum objectType, uint name, enum 3195bd8deadSopenharmony_ci pname, int* params) 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ciNew Types 3225bd8deadSopenharmony_ci 3235bd8deadSopenharmony_ci None 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ciNew Tokens 3265bd8deadSopenharmony_ci 3275bd8deadSopenharmony_ci Accepted by the <option> parameter of ObjectPurgeable, and returned 3285bd8deadSopenharmony_ci by ObjectPurgeable: 3295bd8deadSopenharmony_ci 3305bd8deadSopenharmony_ci RELEASED_APPLE 0x8A19 3315bd8deadSopenharmony_ci VOLATILE_APPLE 0x8A1A 3325bd8deadSopenharmony_ci 3335bd8deadSopenharmony_ci Accepted by the <option> parameters of ObjectUnpurgeable, and 3345bd8deadSopenharmony_ci returned by ObjectUnpurgeable: 3355bd8deadSopenharmony_ci 3365bd8deadSopenharmony_ci RETAINED_APPLE 0x8A1B 3375bd8deadSopenharmony_ci UNDEFINED_APPLE 0x8A1C 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci Accepted by the <pname> parameters of GetObjectParameteriv: 3405bd8deadSopenharmony_ci 3415bd8deadSopenharmony_ci PURGEABLE_APPLE 0x8A1D 3425bd8deadSopenharmony_ci 3435bd8deadSopenharmony_ci Accepted by the <objectType> parameters of ObjectPurgeableAPPLE, 3445bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE and GetObjectParameteriv: 3455bd8deadSopenharmony_ci 3465bd8deadSopenharmony_ci BUFFER_OBJECT_APPLE 0x85B3 3475bd8deadSopenharmony_ci 3485bd8deadSopenharmony_ci (Note: BUFFER_OBJECT_APPLE is also defined in APPLE_fence extension 3495bd8deadSopenharmony_ci with the same value.) 3505bd8deadSopenharmony_ci 3515bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.5 Specification 3525bd8deadSopenharmony_ci(OpenGL Operation) 3535bd8deadSopenharmony_ci 3545bd8deadSopenharmony_ci None 3555bd8deadSopenharmony_ci 3565bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.5 Specification (Rasterization) 3575bd8deadSopenharmony_ci 3585bd8deadSopenharmony_ci Additions to Chapter 3 of OpenGL 1.5 Specification (Rasterization) 3595bd8deadSopenharmony_ci 3605bd8deadSopenharmony_ci (add a new section 3.8.16) 3615bd8deadSopenharmony_ci 3625bd8deadSopenharmony_ci 3.8.16 Purgeability 3635bd8deadSopenharmony_ci 3645bd8deadSopenharmony_ci The internal data storage of a texture object, renderbuffer object, 3655bd8deadSopenharmony_ci or buffer object has a boolean state, PURGEABLE_APPLE that 3665bd8deadSopenharmony_ci influences how the object's storage is managed by the GL. The 3675bd8deadSopenharmony_ci initial value of PURGEABLE_APPLE is FALSE. The application can 3685bd8deadSopenharmony_ci change the value of PURGEABLE_APPLE by using the routines below. 3695bd8deadSopenharmony_ci 3705bd8deadSopenharmony_ci The routine 3715bd8deadSopenharmony_ci 3725bd8deadSopenharmony_ci enum ObjectPurgeableAPPLE(enum objectType, uint name, enum option) 3735bd8deadSopenharmony_ci 3745bd8deadSopenharmony_ci sets PURGEABLE_APPLE to TRUE for the object of type <objectType> 3755bd8deadSopenharmony_ci with the id <name>. <objectType> must be one of TEXTURE, 3765bd8deadSopenharmony_ci BUFFER_OBJECT_APPLE, or RENDERBUFFER_EXT. If ObjectPurgeableAPPLE is 3775bd8deadSopenharmony_ci called and PURGEABLE_APPLE is already TRUE, the error 3785bd8deadSopenharmony_ci INVALID_OPERATION is generated. 3795bd8deadSopenharmony_ci 3805bd8deadSopenharmony_ci While PURGEABLE_APPLE is TRUE, the GL may release the storage for 3815bd8deadSopenharmony_ci this object and the results of issuing any commands that read from 3825bd8deadSopenharmony_ci or write to the storage of that object are undefined. 3835bd8deadSopenharmony_ci 3845bd8deadSopenharmony_ci <option> must be either VOLATILE_APPLE or RELEASED_APPLE. Calling 3855bd8deadSopenharmony_ci ObjectPurgeableAPPLE with either option sets PURGEABLE_APPLE to 3865bd8deadSopenharmony_ci TRUE, but the value of <option> is used by the GL as a hint to 3875bd8deadSopenharmony_ci indicate the application's intended future use of the named object's 3885bd8deadSopenharmony_ci storage. 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci By calling ObjectPurgeableAPPLE with an <option> of VOLATILE_APPLE, 3915bd8deadSopenharmony_ci the application is indicating that it does not know if it will want 3925bd8deadSopenharmony_ci to re-use the current contents of the object storage again later. 3935bd8deadSopenharmony_ci Further, the application is stating that it would like the GL to do 3945bd8deadSopenharmony_ci only the minimal amount of work required to set PURGEABLE_APPLE to 3955bd8deadSopenharmony_ci TRUE. If ObjectPurgeableAPPLE is called with an <option> of 3965bd8deadSopenharmony_ci VOLATILE_APPLE, then ObjectPurgeableAPPLE will also return the value 3975bd8deadSopenharmony_ci VOLATILE_APPLE. 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci In contrast, by calling ObjectPurgeableAPPLE with an <option> of 4005bd8deadSopenharmony_ci RELEASED_APPLE, the application is indicating that it does not 4015bd8deadSopenharmony_ci intend to re-use the contents of the storage again. Further, the 4025bd8deadSopenharmony_ci application is stating that it is acceptable for the GL to do a more 4035bd8deadSopenharmony_ci work to encourage the GL to actually release the storage for the 4045bd8deadSopenharmony_ci object. The actual mechanism for releasing the storage is 4055bd8deadSopenharmony_ci implementation-dependent, but it may require some level of 4065bd8deadSopenharmony_ci synchronization and may flush the current context. If 4075bd8deadSopenharmony_ci ObjectPurgeableAPPLE is called with an <option> of RELEASED_APPLE, 4085bd8deadSopenharmony_ci then ObjectPurgeableAPPLE may return either the value RELEASED_APPLE 4095bd8deadSopenharmony_ci or the value VOLATILE_APPLE. 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ci If ObjectPurgeableAPPLE returns the value VOLATILE_APPLE, this means 4125bd8deadSopenharmony_ci that the storage for the object may not have been released when 4135bd8deadSopenharmony_ci ObjectPurgeableAPPLE returns. In contrast, if ObjectPurgeableAPPLE 4145bd8deadSopenharmony_ci returns the value RELEASED_APPLE, this means that the storage for 4155bd8deadSopenharmony_ci the object has been released when ObjectPurgeableAPPLE returns. 4165bd8deadSopenharmony_ci 4175bd8deadSopenharmony_ci The routine 4185bd8deadSopenharmony_ci 4195bd8deadSopenharmony_ci enum ObjectUnpurgeableAPPLE(enum object, uint name, enum option) 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci sets the value of PURGEABLE_APPLE to FALSE for the object of type 4225bd8deadSopenharmony_ci <objectType> with the id <name>. If ObjectUnpurgeableAPPLE is 4235bd8deadSopenharmony_ci called and PURGEABLE_APPLE is already FALSE, the error 4245bd8deadSopenharmony_ci INVALID_OPERATION is returned. 4255bd8deadSopenharmony_ci 4265bd8deadSopenharmony_ci While PURGEABLE_APPLE is FALSE, the storage for an object will not 4275bd8deadSopenharmony_ci be released by the GL. This is the default state for object storage. 4285bd8deadSopenharmony_ci 4295bd8deadSopenharmony_ci <option> must be either RETAINED_APPLE or UNDEFINED_APPLE. Calling 4305bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE with either option sets PURGEABLE_APPLE to 4315bd8deadSopenharmony_ci FALSE, but the value of <option> is used by the GL as a hint to 4325bd8deadSopenharmony_ci indicate the application's intended future use of the named object's 4335bd8deadSopenharmony_ci storage. 4345bd8deadSopenharmony_ci 4355bd8deadSopenharmony_ci By calling ObjectUnpurgeableAPPLE with an <option> of 4365bd8deadSopenharmony_ci RETAINED_APPLE, the application is indicating that it would like to 4375bd8deadSopenharmony_ci re-use the contents of the storage, if the storage has not yet been 4385bd8deadSopenharmony_ci released. Further, the application is stating that it is acceptable 4395bd8deadSopenharmony_ci for the GL to do more work to try to restore the storage the same 4405bd8deadSopenharmony_ci state it was in before PURGEABLE_APPLE was set to TRUE. The actual 4415bd8deadSopenharmony_ci mechanism for attempting to restore the storage of the object is 4425bd8deadSopenharmony_ci implementation-dependent, but it may require some level of 4435bd8deadSopenharmony_ci synchronization and may flush the current context. If 4445bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE is called with an <option> of RETAINED_APPLE, 4455bd8deadSopenharmony_ci then ObjectPurgeableAPPLE may return either the value RETAINED_APPLE 4465bd8deadSopenharmony_ci or the value UNDEFINED_APPLE. 4475bd8deadSopenharmony_ci 4485bd8deadSopenharmony_ci In contrast, by calling ObjectUnpurgeableAPPLE with an <option> of 4495bd8deadSopenharmony_ci UNDEFINED_APPLE, the application is indicating that it intends to 4505bd8deadSopenharmony_ci recreate the contents of the storage from scratch. Further, the 4515bd8deadSopenharmony_ci application is is stating that it would like the GL to do only the 4525bd8deadSopenharmony_ci minimal amount of work set PURGEABLE_APPLE to FALSE. If 4535bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE is called with the <option> set to 4545bd8deadSopenharmony_ci UNDEFINED_APPLE, then ObjectUnpurgeableAPPLE will return the value 4555bd8deadSopenharmony_ci UNDEFINED_APPLE. 4565bd8deadSopenharmony_ci 4575bd8deadSopenharmony_ci If ObjectUnpurgeableAPPLE returns the value UNDEFINED_APPLE, the 4585bd8deadSopenharmony_ci storage is in the same state as a newly created object with 4595bd8deadSopenharmony_ci undefined contents. In contrast, if ObjectUnpurgeableAPPLE returns 4605bd8deadSopenharmony_ci the value RETAINED_APPLE, this means that the storage has the same 4615bd8deadSopenharmony_ci the same contents it did when PURGEABLE_APPLE was most recently set 4625bd8deadSopenharmony_ci to FALSE. 4635bd8deadSopenharmony_ci 4645bd8deadSopenharmony_ci 4655bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.5 Specification (Per-Fragment 4665bd8deadSopenharmony_ciOperations and the Frame Buffer) 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci None 4695bd8deadSopenharmony_ci 4705bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.5 Specification 4715bd8deadSopenharmony_ci(Special Functions) 4725bd8deadSopenharmony_ci 4735bd8deadSopenharmony_ci None 4745bd8deadSopenharmony_ci 4755bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.5 Specification (State and State 4765bd8deadSopenharmony_ciRequests) 4775bd8deadSopenharmony_ci 4785bd8deadSopenharmony_ci (In section 6.1.3, Enumerated Queries, in the list of state query 4795bd8deadSopenharmony_ci functions, add the following) 4805bd8deadSopenharmony_ci 4815bd8deadSopenharmony_ci "void GetObjectParameterivAPPLE(enum objectType, 4825bd8deadSopenharmony_ci int name, 4835bd8deadSopenharmony_ci enum pname, 4845bd8deadSopenharmony_ci void* params);" 4855bd8deadSopenharmony_ci 4865bd8deadSopenharmony_ci (and add the following description to the end of this section) 4875bd8deadSopenharmony_ci 4885bd8deadSopenharmony_ci "GetObjectParameterivAPPLE places in <params> information about the 4895bd8deadSopenharmony_ci object of type <objectType> with the id <name>. <objectType> must 4905bd8deadSopenharmony_ci be one of TEXTURE, BUFFER_OBJECT_APPLE, or RENDERBUFFER_EXT. 4915bd8deadSopenharmony_ci <name> must be a non-zero name of an object of type <type>. If 4925bd8deadSopenharmony_ci <pname> is PURGEABLE_APPLE, then when GetObjectParameterivAPPLE 4935bd8deadSopenharmony_ci returns, <params> will contain the current value of PURGEABLE_APPLE 4945bd8deadSopenharmony_ci for the named object's storage. Note that this query does not 4955bd8deadSopenharmony_ci return whether or not the object storage has been purged but simply 4965bd8deadSopenharmony_ci whether the state PURGEABLE_APPLE is set to TRUE or FALSE." 4975bd8deadSopenharmony_ci 4985bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 1.5 Specification (Invariance) 4995bd8deadSopenharmony_ci 5005bd8deadSopenharmony_ci None 5015bd8deadSopenharmony_ci 5025bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications 5035bd8deadSopenharmony_ci 5045bd8deadSopenharmony_ci None 5055bd8deadSopenharmony_ci 5065bd8deadSopenharmony_ciErrors 5075bd8deadSopenharmony_ci 5085bd8deadSopenharmony_ci INVALID_ENUM is generated if the <objectType> parameter of 5095bd8deadSopenharmony_ci ObjectPurgeableAPPLE or ObjectUnpurgeableAPPLE is not one of 5105bd8deadSopenharmony_ci TEXTURE, BUFFER_OBJECT_APPLE, RENDERBUFFER_EXT. 5115bd8deadSopenharmony_ci 5125bd8deadSopenharmony_ci INVALID_ENUM is generated if the <option> parameter of 5135bd8deadSopenharmony_ci ObjectPurgeableAPPLE is not VOLATILE_APPLE or RELEASED_APPLE. 5145bd8deadSopenharmony_ci 5155bd8deadSopenharmony_ci INVALID_ENUM is generated if the <option> parameter of 5165bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE is not RETAINED_APPLE or UNDEFINED_APPLE. 5175bd8deadSopenharmony_ci 5185bd8deadSopenharmony_ci INVALID_VALUE is generated if the <name> parameter of 5195bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE or ObjectUnpurgeableAPPLE is zero. 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci INVALID_OPERATION is generated if either ObjectUnpurgeableAPPLE or 5225bd8deadSopenharmony_ci ObjectUnpurgeableAPPLE is called between the execution of Begin and 5235bd8deadSopenharmony_ci the corresponding execution of End. 5245bd8deadSopenharmony_ci 5255bd8deadSopenharmony_ci INVALID_OPERATION is generated if ObjectPurgeableAPPLE is called on 5265bd8deadSopenharmony_ci an object with a current value of PURGEABLE set to TRUE 5275bd8deadSopenharmony_ci 5285bd8deadSopenharmony_ci INVALID_OPERATION is generated if ObjectUnpurgeableAPPLE is called 5295bd8deadSopenharmony_ci on an object with a current value of PURGEABLE set to FALSE 5305bd8deadSopenharmony_ci 5315bd8deadSopenharmony_ci INVALID_ENUM is generated if the <objectType> parameter of 5325bd8deadSopenharmony_ci GetObjectParameterivAPPLE is not one of TEXTURE, 5335bd8deadSopenharmony_ci BUFFER_OBJECT_APPLE, or RENDERBUFFER_EXT. 5345bd8deadSopenharmony_ci 5355bd8deadSopenharmony_ci INVALID_VALUE is generated if the <name> parameter of 5365bd8deadSopenharmony_ci GetObjectParameterivAPPLE is not the name of an existing 5375bd8deadSopenharmony_ci object of type <objectType>. 5385bd8deadSopenharmony_ci 5395bd8deadSopenharmony_ci INVALID_VALUE is generated if the <name> parameter of 5405bd8deadSopenharmony_ci GetObjectParameterivAPPLE is zero. 5415bd8deadSopenharmony_ci 5425bd8deadSopenharmony_ci INVALID_ENUM is generated if the <pname> parameter of 5435bd8deadSopenharmony_ci GetObjectParameterivAPPLE is PURGEABLE_APPLE. 5445bd8deadSopenharmony_ci 5455bd8deadSopenharmony_ci 5465bd8deadSopenharmony_ciNew State 5475bd8deadSopenharmony_ci 5485bd8deadSopenharmony_ci Each object type that supports this extension has the following new 5495bd8deadSopenharmony_cistate: 5505bd8deadSopenharmony_ci 5515bd8deadSopenharmony_ci Type Get Command Inital Value Description Section Attribute 5525bd8deadSopenharmony_ci ---- ----------------- ------------ ------------ ------- --------- 5535bd8deadSopenharmony_ci Z2 GetObjectParameter FALSE GL_PURGEABLE_APPLE 3.8.16 - 5545bd8deadSopenharmony_ci 5555bd8deadSopenharmony_ciNew Implementation Dependent State 5565bd8deadSopenharmony_ci 5575bd8deadSopenharmony_ci None 5585bd8deadSopenharmony_ci 5595bd8deadSopenharmony_ciSample Code 5605bd8deadSopenharmony_ci 5615bd8deadSopenharmony_ci A "one shot" texture is a texture specified, used once, and then 5625bd8deadSopenharmony_ci respecified again before it's next use. The sample code below shows 5635bd8deadSopenharmony_ci how to use APPLE_object_purgeable to handle "one shot" textures: 5645bd8deadSopenharmony_ci 5655bd8deadSopenharmony_ci /* First, find out if the texture is purgeable already */ 5665bd8deadSopenharmony_ci boolean purgeable = FALSE; 5675bd8deadSopenharmony_ci GetObjectParameter(TEXTURE, name, &purgeable); 5685bd8deadSopenharmony_ci if(purgeable) 5695bd8deadSopenharmony_ci ObjectUnpurgeable(TEXTURE, name, UNDEFINED_APPLE); 5705bd8deadSopenharmony_ci 5715bd8deadSopenharmony_ci /* Now that the texture is unpurgeable, respecify its contents 5725bd8deadSopenharmony_ci */ 5735bd8deadSopenharmony_ci BindTexture(TEXTURE_2D, name); 5745bd8deadSopenharmony_ci Enable(TEXTURE_2D); 5755bd8deadSopenharmony_ci TexImage2D(TEXTURE_2D, 0, RGBA, width, height, 0, RGBA, 5765bd8deadSopenharmony_ci UNSIGNED_BYTE, pixels); 5775bd8deadSopenharmony_ci 5785bd8deadSopenharmony_ci /* Draw using the texture */ 5795bd8deadSopenharmony_ci MyDrawRoutine goes here(...); 5805bd8deadSopenharmony_ci 5815bd8deadSopenharmony_ci /* Now mark the texture as purgeable */ 5825bd8deadSopenharmony_ci ObjectPurgeable(TEXTURE, name, RELEASED_APPLE); 5835bd8deadSopenharmony_ci 5845bd8deadSopenharmony_ci Texture speculative caching: A FBO is created and texture_name is 5855bd8deadSopenharmony_ci attached to it. The application then renders to texture and is 5865bd8deadSopenharmony_ci expecting to use this texture later on. In the mean time it does 5875bd8deadSopenharmony_ci not want the GL to page it off because it is easy to recreate if 5885bd8deadSopenharmony_ci needed. 5895bd8deadSopenharmony_ci 5905bd8deadSopenharmony_ci /* during system idle time, bind the fbo and render into it */ 5915bd8deadSopenharmony_ci BindFramebufferEXT(FRAMEBUFFER_EXT, fbo_name); 5925bd8deadSopenharmony_ci MyDrawRoutineToSpecifyTextureContents(...); 5935bd8deadSopenharmony_ci 5945bd8deadSopenharmony_ci /* We've rendered into the texture but we don't necessarily */ 5955bd8deadSopenharmony_ci /* need for it to remain valid if the GL wants to release it */ 5965bd8deadSopenharmony_ci /* so we mark it as purgeable */ 5975bd8deadSopenharmony_ci ObjectPurgeable(TEXTURE, texture_name, VOLATILE_APPLE); 5985bd8deadSopenharmony_ci 5995bd8deadSopenharmony_ci /* now do some other unrelated rendering */ 6005bd8deadSopenharmony_ci MyOtherDrawRoutineGoesHere(...); 6015bd8deadSopenharmony_ci 6025bd8deadSopenharmony_ci /* Some time passes and then the application wants to */ 6035bd8deadSopenharmony_ci /* use the texture, so it markes the texture storage as */ 6045bd8deadSopenharmony_ci /* unpurgeable and indicates it would like the GL to try to */ 6055bd8deadSopenharmony_ci /* retain the storage if it still exists */ 6065bd8deadSopenharmony_ci 6075bd8deadSopenharmony_ci obj_state = ObjectUnpurgeable(TEXTURE, 6085bd8deadSopenharmony_ci texture_name, RETAINED_APPLE); 6095bd8deadSopenharmony_ci if(obj_state == RETAINED_APPLE) 6105bd8deadSopenharmony_ci { 6115bd8deadSopenharmony_ci /* object storage was retained so we can go ahead and use it 6125bd8deadSopenharmony_ci */ 6135bd8deadSopenharmony_ci BindTexture(TEXTURE_2D, texture_name); 6145bd8deadSopenharmony_ci MyDrawRoutineThatUsesTheOriginalTexture(...); 6155bd8deadSopenharmony_ci } 6165bd8deadSopenharmony_ci else /* object storage was lost */ 6175bd8deadSopenharmony_ci { 6185bd8deadSopenharmony_ci /* We must recreate the original texture contents */ 6195bd8deadSopenharmony_ci BindFramebufferEXT(FRAMEBUFFER_EXT, fbo_name); 6205bd8deadSopenharmony_ci MyDrawRoutineToRespecifyTextureContents(...); 6215bd8deadSopenharmony_ci 6225bd8deadSopenharmony_ci /* object storage has been re-specified so we can go */ 6235bd8deadSopenharmony_ci /* ahead and use it now */ 6245bd8deadSopenharmony_ci BindFramebufferEXT(FRAMEBUFFER_EXT, 0); 6255bd8deadSopenharmony_ci BindTexture(TEXTURE_2D, texture_name); 6265bd8deadSopenharmony_ci MyDrawRoutineThatUsesTheOriginalTexture(...); 6275bd8deadSopenharmony_ci } 6285bd8deadSopenharmony_ci 6295bd8deadSopenharmony_ciRevision History 6305bd8deadSopenharmony_ci 6315bd8deadSopenharmony_ci Revision 2, 2006/10/20 6325bd8deadSopenharmony_ci - updated issue language to remove some stale resolutions 6335bd8deadSopenharmony_ci - revised and clarified language in terms of application intent 6345bd8deadSopenharmony_ci for the various <option> flags instead of implementation details 6355bd8deadSopenharmony_ci - replaced IsPurgeable with GetObjectParameter 6365bd8deadSopenharmony_ci - renamed extension "APPLE_object_purgeable" instead of 6375bd8deadSopenharmony_ci "APPLE_object_purgeability" to correlate with new state variable 6385bd8deadSopenharmony_ci GL_PURGEABLE_APPLE. 6395bd8deadSopenharmony_ci 6405bd8deadSopenharmony_ci Revision 1, 2006/09/29 6415bd8deadSopenharmony_ci - Initial checkin. 6425bd8deadSopenharmony_ci 6435bd8deadSopenharmony_ci 6445bd8deadSopenharmony_ci 645