xref: /aosp_15_r20/external/angle/extensions/ANGLE_blob_cache.txt (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard WorkerName
2*8975f5c5SAndroid Build Coastguard Worker
3*8975f5c5SAndroid Build Coastguard Worker    ANGLE_blob_cache
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard WorkerName Strings
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Worker    GL_ANGLE_blob_cache
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard WorkerContributors
10*8975f5c5SAndroid Build Coastguard Worker
11*8975f5c5SAndroid Build Coastguard Worker    Geoff Lang
12*8975f5c5SAndroid Build Coastguard Worker
13*8975f5c5SAndroid Build Coastguard WorkerContact
14*8975f5c5SAndroid Build Coastguard Worker
15*8975f5c5SAndroid Build Coastguard Worker    Geoff Lang (geofflang 'at' google.com)
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard WorkerNotice
18*8975f5c5SAndroid Build Coastguard Worker
19*8975f5c5SAndroid Build Coastguard Worker    Copyright (c) 2024 The Khronos Group Inc. Copyright terms at
20*8975f5c5SAndroid Build Coastguard Worker        http://www.khronos.org/registry/speccopyright.html
21*8975f5c5SAndroid Build Coastguard Worker
22*8975f5c5SAndroid Build Coastguard WorkerStatus
23*8975f5c5SAndroid Build Coastguard Worker
24*8975f5c5SAndroid Build Coastguard Worker    Draft
25*8975f5c5SAndroid Build Coastguard Worker
26*8975f5c5SAndroid Build Coastguard WorkerVersion
27*8975f5c5SAndroid Build Coastguard Worker
28*8975f5c5SAndroid Build Coastguard Worker    Version 1, October 4, 2024
29*8975f5c5SAndroid Build Coastguard Worker
30*8975f5c5SAndroid Build Coastguard WorkerNumber
31*8975f5c5SAndroid Build Coastguard Worker
32*8975f5c5SAndroid Build Coastguard Worker    OpenGL ES Extension #??
33*8975f5c5SAndroid Build Coastguard Worker
34*8975f5c5SAndroid Build Coastguard WorkerDependencies
35*8975f5c5SAndroid Build Coastguard Worker
36*8975f5c5SAndroid Build Coastguard Worker    Requires OpenGL ES 2.0
37*8975f5c5SAndroid Build Coastguard Worker
38*8975f5c5SAndroid Build Coastguard Worker    Written against the OpenGL ES 3.2 specification.
39*8975f5c5SAndroid Build Coastguard Worker
40*8975f5c5SAndroid Build Coastguard WorkerOverview
41*8975f5c5SAndroid Build Coastguard Worker
42*8975f5c5SAndroid Build Coastguard Worker    This extension provides a mechanism for an OpenGL context to cache binary
43*8975f5c5SAndroid Build Coastguard Worker    blobs. The application must implement the cache and is in control of caching
44*8975f5c5SAndroid Build Coastguard Worker    behavior.
45*8975f5c5SAndroid Build Coastguard Worker
46*8975f5c5SAndroid Build Coastguard Worker    This extension adds caching callbacks per-context which is useful for
47*8975f5c5SAndroid Build Coastguard Worker    isolating cached data and providing extra security.
48*8975f5c5SAndroid Build Coastguard Worker
49*8975f5c5SAndroid Build Coastguard Worker
50*8975f5c5SAndroid Build Coastguard WorkerNew Procedures and Functions
51*8975f5c5SAndroid Build Coastguard Worker
52*8975f5c5SAndroid Build Coastguard Worker    void SetBlobCacheFuncsANGLE(SETBLOBPROCANGLE set,
53*8975f5c5SAndroid Build Coastguard Worker                                GETBLOBPROCANGLE get,
54*8975f5c5SAndroid Build Coastguard Worker                                const void* userParam);
55*8975f5c5SAndroid Build Coastguard Worker
56*8975f5c5SAndroid Build Coastguard Worker    void GetPointervANGLE(enum pname, void **params);
57*8975f5c5SAndroid Build Coastguard Worker
58*8975f5c5SAndroid Build Coastguard WorkerNew Types
59*8975f5c5SAndroid Build Coastguard Worker
60*8975f5c5SAndroid Build Coastguard Worker    The callback functions that applications can define, and
61*8975f5c5SAndroid Build Coastguard Worker    are accepted by SetBlobCacheFuncsANGLE, are defined as:
62*8975f5c5SAndroid Build Coastguard Worker
63*8975f5c5SAndroid Build Coastguard Worker        typedef GLsizeiptr (GL_APIENTRY *GLGETBLOBPROCANGLE)(const void *key,
64*8975f5c5SAndroid Build Coastguard Worker                                                             GLsizeiptr keySize,
65*8975f5c5SAndroid Build Coastguard Worker                                                             void *value,
66*8975f5c5SAndroid Build Coastguard Worker                                                             GLsizeiptr valueSize,
67*8975f5c5SAndroid Build Coastguard Worker                                                             const void *userParam);
68*8975f5c5SAndroid Build Coastguard Worker
69*8975f5c5SAndroid Build Coastguard Worker        typedef void (GL_APIENTRY *GLSETBLOBPROCANGLE)(const void *key,
70*8975f5c5SAndroid Build Coastguard Worker                                                       GLsizeiptr keySize,
71*8975f5c5SAndroid Build Coastguard Worker                                                       const void *value,
72*8975f5c5SAndroid Build Coastguard Worker                                                       GLsizeiptr valueSize,
73*8975f5c5SAndroid Build Coastguard Worker                                                       const void *userParam);
74*8975f5c5SAndroid Build Coastguard Worker
75*8975f5c5SAndroid Build Coastguard Worker    Note that these function pointers are defined as having the same calling
76*8975f5c5SAndroid Build Coastguard Worker    convention as the GL functions.
77*8975f5c5SAndroid Build Coastguard Worker
78*8975f5c5SAndroid Build Coastguard WorkerNew Tokens
79*8975f5c5SAndroid Build Coastguard Worker
80*8975f5c5SAndroid Build Coastguard Worker    Tokens accepted by the <pname> parameter of GetPointerv:
81*8975f5c5SAndroid Build Coastguard Worker
82*8975f5c5SAndroid Build Coastguard Worker        BLOB_CACHE_GET_FUNCTION_ANGLE                0x96BF
83*8975f5c5SAndroid Build Coastguard Worker        BLOB_CACHE_SET_FUNCTION_ANGLE                0x96EF
84*8975f5c5SAndroid Build Coastguard Worker        BLOB_CACHE_USER_PARAM_ANGLE                  0x972D
85*8975f5c5SAndroid Build Coastguard Worker
86*8975f5c5SAndroid Build Coastguard WorkerAdditions to the OpenGL ES Specification
87*8975f5c5SAndroid Build Coastguard Worker
88*8975f5c5SAndroid Build Coastguard Worker    Add a new section after 18 Debug Output:
89*8975f5c5SAndroid Build Coastguard Worker
90*8975f5c5SAndroid Build Coastguard Worker    "Chapter 19
91*8975f5c5SAndroid Build Coastguard Worker    Persistent Caching
92*8975f5c5SAndroid Build Coastguard Worker
93*8975f5c5SAndroid Build Coastguard Worker    Application developers can set callback functions which GL may use for
94*8975f5c5SAndroid Build Coastguard Worker    getting and setting persistently cached data blobs. The command
95*8975f5c5SAndroid Build Coastguard Worker
96*8975f5c5SAndroid Build Coastguard Worker        void SetBlobCacheFuncsANGLE(SETBLOBPROCANGLE set,
97*8975f5c5SAndroid Build Coastguard Worker                                    GETBLOBPROCANGLE get,
98*8975f5c5SAndroid Build Coastguard Worker                                    const void* userParam);
99*8975f5c5SAndroid Build Coastguard Worker
100*8975f5c5SAndroid Build Coastguard Worker    stores the get and set callbacks and user parameter. Only one blob cache
101*8975f5c5SAndroid Build Coastguard Worker    get and set function can be installed on the current context. Specifying NULL
102*8975f5c5SAndroid Build Coastguard Worker    for the callbacks will clear the current callbacks and disable blob caching.
103*8975f5c5SAndroid Build Coastguard Worker    Applications can provide user-specified data through the pointer <userParam>.
104*8975f5c5SAndroid Build Coastguard Worker    The context  will store this pointer and will include it as one of the parameters
105*8975f5c5SAndroid Build Coastguard Worker    in each call to the callback function.
106*8975f5c5SAndroid Build Coastguard Worker
107*8975f5c5SAndroid Build Coastguard Worker    Applications can query the current callback functions and the current
108*8975f5c5SAndroid Build Coastguard Worker    user-specified parameter by obtaining the values of
109*8975f5c5SAndroid Build Coastguard Worker    BLOB_CACHE_GET_FUNCTION_ANGLE, BLOB_CACHE_SET_FUNCTION_ANGLE and
110*8975f5c5SAndroid Build Coastguard Worker    BLOB_CACHE_USER_PARAM_ANGLE.
111*8975f5c5SAndroid Build Coastguard Worker
112*8975f5c5SAndroid Build Coastguard Worker    To insert a new binary value into the cache and associate it with a given
113*8975f5c5SAndroid Build Coastguard Worker    key, a GL context can call the application-provided callback function
114*8975f5c5SAndroid Build Coastguard Worker
115*8975f5c5SAndroid Build Coastguard Worker        sizeiptr get(const void *key, sizeiptr keySize, void *value, sizeiptr valueSize,
116*8975f5c5SAndroid Build Coastguard Worker                     const void *userParam);
117*8975f5c5SAndroid Build Coastguard Worker
118*8975f5c5SAndroid Build Coastguard Worker    <key> and <value> are pointers to the beginning of the key and value,
119*8975f5c5SAndroid Build Coastguard Worker    respectively, that are to be inserted. <keySize> and <valueSize> specify
120*8975f5c5SAndroid Build Coastguard Worker    the size in bytes of the data pointed to by <key> and <value> respectively.
121*8975f5c5SAndroid Build Coastguard Worker
122*8975f5c5SAndroid Build Coastguard Worker    To retrieve the binary value associated with a given key from the cache, a
123*8975f5c5SAndroid Build Coastguard Worker    GL context can call the application-provided callback function
124*8975f5c5SAndroid Build Coastguard Worker
125*8975f5c5SAndroid Build Coastguard Worker        set(const void *key, sizeiptr keySize, const void *value, sizeiptr valueSize,
126*8975f5c5SAndroid Build Coastguard Worker            const void *userParam);
127*8975f5c5SAndroid Build Coastguard Worker
128*8975f5c5SAndroid Build Coastguard Worker
129*8975f5c5SAndroid Build Coastguard Worker    <key> is a pointer to the beginning of the key. <keySize> specifies the
130*8975f5c5SAndroid Build Coastguard Worker    size in bytes of the binary key pointed to by <key>. If the cache contains
131*8975f5c5SAndroid Build Coastguard Worker    a value associated with the given key then the size of that binary value in
132*8975f5c5SAndroid Build Coastguard Worker    bytes is returned. Otherwise 0 is returned.
133*8975f5c5SAndroid Build Coastguard Worker
134*8975f5c5SAndroid Build Coastguard Worker    If the cache contains a value for the given key and its size in bytes is
135*8975f5c5SAndroid Build Coastguard Worker    less than or equal to <valueSize> then the value is written to the memory
136*8975f5c5SAndroid Build Coastguard Worker    pointed to by <value>. Otherwise nothing is written to the memory pointed
137*8975f5c5SAndroid Build Coastguard Worker    to by <value>.
138*8975f5c5SAndroid Build Coastguard Worker
139*8975f5c5SAndroid Build Coastguard Worker    Additionally, these callbacks must be declared with the same platform-dependent
140*8975f5c5SAndroid Build Coastguard Worker    calling convention used in the definition of the type GLGETBLOBPROCANGLE and
141*8975f5c5SAndroid Build Coastguard Worker    GLSETBLOBPROCANGLE. Anything else will result in undefined behavior.
142*8975f5c5SAndroid Build Coastguard Worker
143*8975f5c5SAndroid Build Coastguard WorkerErrors
144*8975f5c5SAndroid Build Coastguard Worker
145*8975f5c5SAndroid Build Coastguard Worker    An INVALID_OPERATION error is generated by SetBlobCacheFuncsANGLE if one of
146*8975f5c5SAndroid Build Coastguard Worker    <get> or <set> are NULL and the other is non-NULL.
147*8975f5c5SAndroid Build Coastguard Worker
148*8975f5c5SAndroid Build Coastguard WorkerNew State
149*8975f5c5SAndroid Build Coastguard Worker
150*8975f5c5SAndroid Build Coastguard Worker    Modify Table 21.57: Miscellaneous
151*8975f5c5SAndroid Build Coastguard Worker
152*8975f5c5SAndroid Build Coastguard Worker    Add:
153*8975f5c5SAndroid Build Coastguard Worker
154*8975f5c5SAndroid Build Coastguard Worker                                                       Initial
155*8975f5c5SAndroid Build Coastguard Worker    Get Value                         Type Get Command Value   Description
156*8975f5c5SAndroid Build Coastguard Worker    --------------------------------- ---- ----------- ------- ---------------------
157*8975f5c5SAndroid Build Coastguard Worker    GL_BLOB_CACHE_GET_FUNCTION_ANGLE  Y    GetPointerv NULL    Blob cache getter function
158*8975f5c5SAndroid Build Coastguard Worker    GL_BLOB_CACHE_SET_FUNCTION_ANGLE  Y    GetPointerv NULL    Blob cache setter function
159*8975f5c5SAndroid Build Coastguard Worker    GL_BLOB_CACHE_USER_PARAM_ANGLE    Y    GetPointerv NULL    Blob cache callback user
160*8975f5c5SAndroid Build Coastguard Worker                                                               data parameter
161*8975f5c5SAndroid Build Coastguard Worker
162*8975f5c5SAndroid Build Coastguard WorkerConformance Tests
163*8975f5c5SAndroid Build Coastguard Worker
164*8975f5c5SAndroid Build Coastguard Worker    TBD
165*8975f5c5SAndroid Build Coastguard Worker
166*8975f5c5SAndroid Build Coastguard WorkerIssues
167*8975f5c5SAndroid Build Coastguard Worker
168*8975f5c5SAndroid Build Coastguard Worker    None
169*8975f5c5SAndroid Build Coastguard Worker
170*8975f5c5SAndroid Build Coastguard WorkerRevision History
171*8975f5c5SAndroid Build Coastguard Worker
172*8975f5c5SAndroid Build Coastguard Worker    Rev.    Date         Author                 Changes
173*8975f5c5SAndroid Build Coastguard Worker    ----  -------------  ---------              ----------------------------------------
174*8975f5c5SAndroid Build Coastguard Worker      1   Oct 4, 2024    geofflang              Initial version
175