• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    AMD_sparse_texture
4
5Name Strings
6
7    GL_AMD_sparse_texture
8
9Contributors
10
11    Graham Sellers, AMD
12    Pierre Boudier, AMD
13    Juraj Obert, AMD
14
15Contact
16
17    Graham Sellers, AMD (graham.sellers 'at' amd.com)
18
19Status
20
21    Shipping.
22
23Version
24
25    Last Modified Date:         03/27/2012
26    AMD Revision:               6
27
28Number
29
30    426
31
32Dependencies
33
34    OpenGL 2.0 or ARB_fragment_shader is required.
35
36    This extension is written against the OpenGL 4.2 (Core) Specification.
37
38    This extension is written against the OpenGL Shading Language (GLSL)
39    Specification, version 4.20.
40
41Overview
42
43    Recent advances in application complexity and a desire for higher
44    resolutions have pushed texture sizes up considerably. Often, the amount
45    of physical memory available to a graphics processor is a limiting factor
46    in the performance of texture-heavy applications. Once the available
47    physical memory is exhausted, paging may occur bringing performance down
48    considerably - or worse, the application may fail. Nevertheless, the amount
49    of address space available to the graphics processor has increased to the
50    point where many gigabytes - or even terabytes of address space may be
51    usable even though that amount of physical memory is not present.
52
53    This extension allows the separation of the graphics processor's address
54    space (reservation) from the requirement that all textures must be
55    physically backed (commitment). This exposes a limited form of
56    virtualization for textures. Use cases include sparse (or partially
57    resident) textures, texture paging, on-demand and delayed loading of
58    texture assets and application controlled level of detail.
59
60New Procedures and Functions
61
62        void TexStorageSparseAMD(enum target,
63                                 enum internalFormat,
64                                 sizei width,
65                                 sizei height,
66                                 sizei depth,
67                                 sizei layers,
68                                 bitfield flags);
69
70        void TextureStorageSparseAMD(uint texture,
71                                     enum target,
72                                     enum internalFormat,
73                                     sizei width,
74                                     sizei height,
75                                     sizei depth,
76                                     sizei layers,
77                                     bitfield flags);
78
79New Tokens
80
81    Accepted by the <flags> parameter to TexStorageSparseAMD and TextureStorageSparseAMD:
82
83        TEXTURE_STORAGE_SPARSE_BIT_AMD                  0x00000001
84
85    Accepted by the <pname> parameter to GetInternalformativ:
86
87        VIRTUAL_PAGE_SIZE_X_AMD                         0x9195
88        VIRTUAL_PAGE_SIZE_Y_AMD                         0x9196
89        VIRTUAL_PAGE_SIZE_Z_AMD                         0x9197
90
91    Accepted by the <pname> parameter to GetIntegerv, GetFloatv, GetDoublev,
92    GetInteger64v, and GetBooleanv:
93
94        MAX_SPARSE_TEXTURE_SIZE_AMD                     0x9198
95        MAX_SPARSE_3D_TEXTURE_SIZE_AMD                  0x9199
96        MAX_SPARSE_ARRAY_TEXTURE_LAYERS                 0x919A
97
98    Accepted by the <pname> parameter of GetTexParameter{if}v:
99
100        MIN_SPARSE_LEVEL_AMD                            0x919B
101
102    Accepted by the <pname> parameter of TexParameter{if}{v} and
103    GetTexParameter{if}v:
104
105        MIN_LOD_WARNING_AMD                             0x919C
106
107Additions to Chapter 2 of the OpenGL 4.2 (Core) Specification (OpenGL Operation)
108
109    None.
110
111Additions to Chapter 3 of the OpenGL 4.2 (Core) Specification (Rasterization)
112
113    Add new Subsection 3.8.3 "Texture Storage Allocation". Renumber
114    subsequent sections.
115
116    3.8.3 Texture Storage Allocation
117
118    The command
119
120        void TexStorageSparseAMD(enum target,
121                                 enum internalFormat,
122                                 sizei width,
123                                 sizei height,
124                                 sizei depth,
125                                 sizei layers,
126                                 bitfield flags);
127
128    is used to specify the storage requirements for a texture object. <target>
129    must be one of TEXTURE_1D, TEXTURE_1D_ARRAY, TEXTURE_2D, TEXTURE_RECTANGLE,
130    TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP, TEXTURE_CUBE_MAP_ARRAY or TEXTURE_3D
131    for a one-dimensional texture, one-dimensional array texture,
132    two-dimensional texture, rectangular texture, two-dimensional array texture,
133    cube-map texture, cube-map array texture, or three-dimensional texture,
134    respectively.
135
136    <width>, <height>, and <depth> determine the size of the allocated texture.
137    When <target> is TEXTURE_1D or TEXTURE_1D_ARRAY, <height> and <depth> must
138    be 1. When <target> is TEXTURE_2D, TEXTURE_RECTANGLE or TEXTURE_2D_ARRAY,
139    <depth> must be 1. When <target> is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY,
140    <width>, <height> and <depth> must be equal. For the non-array targets (TEXTURE_1D,
141    TEXTURE_2D, TEXTURE_CUBE_MAP and TEXTURE_3D), <layers> must be 1, otherwise
142    it specifies the number of layers in the array. <internalFormat> specifies
143    the internal storage format for the texture data and must be one of the
144    sized internal formats listed in Table 3.12.
145
146    <width>, and <height> must be less than or equal to the value of
147    MAX_SPARSE_TEXTURE_SIZE_AMD, and <depth> must be less than or equal to the
148    value of MAX_SPARSE_3D_TEXTURE_SIZE_AMD. <layers> must be less than or
149    equal to the value of MAX_SPARSE_ARRAY_TEXTURE_LAYERS_AMD.
150
151    <flags> contains a bitfield that is used to control the allocation strategy
152    used for the texture.
153
154    If <flags> contains TEXTURE_STORAGE_SPARSE_BIT_AMD, storage is reserved for
155    the texture data, but not committed immediately, otherwise, storage is
156    both reserved and committed at time of specification . If the texture is
157    marked as sparse (and storage is therefore uncommitted), storage for the
158    texture data is committed on later specification through commands such as
159    TexSubImage1D, TexSubImage2D or CopyTexSubImage2D.
160
161    Texture image stores allocated via calls to TextStorageSparseAMD are always
162    considered complete, whether or not physical backing store for all mipmap
163    levels has been allocated.
164
165    The TextureStorageSparseAMD command operates identically to the
166    TexStorageSparseAMD command except, rather than specifying storage requirements
167    for the current bound texture for the texture unit indicated by the current
168    active texture state and the target parameter, this command specifies storage
169    requirements for the texture object named by the initial texture parameter.
170    The error INVALID_VALUE is generated if <texture> is zero.
171
172    Add new Subsection 3.8.6 "Texture Storage Commitment and Decommitment",
173    p.212. Renumber subsequent sections.
174
175    For texture images allocated by calling TexStorageSparseAMD or
176    TextureStorageSparseAMD with a <flags> parameter which contains
177    the TEXTURE_STORAGE_SPARSE_BIT_AMD, physical storage for the underlying
178    texture data may not yet be committed. Commitment is made by calling
179    TexSubImage1D, TexSubImage2D, TexSubImage3D, with <data> containing a value
180    other than NULL. When such a command is encountered, physical storage
181    for the specified region of the texture is committed and the data
182    becomes resident. If <data> is NULL and no buffer is bound to the
183    PIXEL_UNPACK_BUFFER binding, then the data corresponding to
184    the specified region is decommitted and released to the GL. If a buffer is
185    bound to the PIXEL_UNPACK_BUFFER binding point, then <data> is interpreted
186    as normal - that is, if <data> is NULL, then it indicates an offset of
187    zero into that buffer's data store.
188
189    Compressed texture data may be specified by calling CompressedTexSubImage1D,
190    CompressedTexSubImage2D or CompressedTexSubImage3D. Again, physical pages
191    are allocated on demand when <data> is non-NULL and freed when <data> is
192    NULL and no buffer is bound to the PIXEL_UNPACK_BUFFER binding point.
193
194    The origin and size of committed regions must be integer multiples of the
195    virtual page size in each dimension as appropriate for the specified level
196    of the specified texture. The virtual page size for a sparse texture may be
197    determined by calling GetInternalformativ with <pname> set to
198    VIRTUAL_PAGE_SIZE_X_AMD, VIRTUAL_PAGE_SIZE_Y_AMD or VIRTUAL_PAGE_SIZE_Z_AMD
199    to query the X, Y or Z dimension of the page size, respectively. Calling
200    TexSubImage* or CopyTexSubImage* with <width>, <height> (for 2D and 3D
201    textures) or <depth> (for 3D textures) not set to integer multiples of
202    VIRTUAL_PAGE_SIZE_X_AMD, VIRTUAL_PAGE_SIZE_Y_AMD or VIRTUAL_PAGE_SIZE_Z_AMD,
203    respectively, will generate an INVALID_VALUE error. An INVALID_VALUE error
204    is also generated if <xoffset>, <yoffset> (for 2D and 3D textures) or
205    <zoffset> (for 3D textures) is not a multiple of VIRTUAL_PAGE_SIZE_X_AMD,
206    VIRTUAL_PAGE_SIZE_Y_AMD or VIRTUAL_PAGE_SIZE_Z_AMD, respectively.
207
208    Calling TexStorageSparseAMD or TextureStorageSparseAMD on an already
209    committed texture decommits any associated storage and, if <flags>
210    contains TEXTURE_STORAGE_SPARSE_BIT_AMD, returns the image store to
211    fully uncommitted. Likewise, calling one of the TexImage commands
212    reallocates the storage for the texture image data and commits it
213    immediately.
214
215    When storage is committed for texture levels greater than or equal to
216    the value of MIN_SPARSE_LEVEL_AMD for a sparse texture, all levels greater
217    than or equal to that level become committed. The value of
218    MIN_SPARSE_LEVEL_AMD may be retrieved by calling GetTexParameter{if}v with
219    <pname> set to MIN_SPARSE_LEVEL_AMD. Sampling from a committed level of a
220    texture that has not yet had data specified produces undefined results,
221    but will not result in instability or program termination.
222
223    Add new paragraph heading "Effects of Texture Commitment on Completeness"
224    to end of Section 3.8.17 "Texture Completeness", p.237.
225
226    Effects of Texture Commitment on Completeness
227
228    Texture images whose storage was allocated without commitment (by calling
229    TexStorageSparseAMD or TextureStorageSparseAMD with a <flags> parameter
230    containing TEXTURE_STORAGE_SPARSE_BIT_AMD) are always considered complete,
231    regardless of their commitment status. Using such a texture image as
232    the source for rendering operations produces results as described
233    in sections XXX and XXX of the OpenGL Specification and section XXX
234    of the OpenGL Shading Language specification.
235
236    User-Specified LOD Warning Thresholds
237
238    In addition to detecting attempts to read from uncommitted regions of a
239    sparse texture, the GL can also signal to the shader that it required texels
240    that reside at LODs below some user specified threshold. This may be used,
241    for example, to specify a watermark and to provide feedback to an
242    application before it attempts to fetch from uncommitted texture regions.
243    Any attempt to fetch from lower LOD than the user-specified LOD warning
244    level will generate an LOD warning, which may be detected in the shader
245    by calling the sparseTexelMinLodWarning built-in function. When this
246    function returns <true>, the sparseTexelLodWarningFetch function may
247    be called to determine the requested LOD that generated this warning. If
248    the data representing this LOD is resident, the texture read will still
249    return valid texel data.
250
251    To specify the user-defined LOD watermark for a texture, call TexParameteri
252    with <target> set to a valid texture target, and with <pname> set to
253    MIN_LOD_WARNING_AMD. Setting MIN_LOD_WARNING_AMD to zero effectively
254    disables the warning.
255
256Additions to Chapter 4 of the OpenGL 4.2 (Core) Specification (Per-Fragment Operations
257and the Framebuffer)
258
259    None.
260
261Additions to Chapter 5 of the OpenGL 4.2 (Core) Specification (Special
262Functions)
263
264    None.
265
266Additions to Chapter 6 of the OpenGL 4.2 (Core) Specification (State and
267State Requests)
268
269    None.
270
271Additions to Chapter 2 of the OpenGL Shading Language (GLSL) Specification,
272version 4.20, (Overview of OpenGL Shading)
273
274    None.
275
276Additions to Chapter 3 of the OpenGL Shading Language (GLSL) Specification,
277version 4.20, (Basics)
278
279    None.
280
281Additions to Chapter 4 of the OpenGL Shading Language (GLSL) Specification,
282version 4.20, (Variables and Types)
283
284    None.
285
286Additions to Chapter 5 of the OpenGL Shading Language (GLSL) Specification,
287version 4.20, (Operators and Expressions)
288
289    None.
290
291Additions to Chapter 6 of the OpenGL Shading Language (GLSL) Specification,
292version 4.20, (Statement Structure)
293
294    None.
295
296Additions to Chapter 7 of the OpenGL Shading Language (GLSL) Specification,
297version 4.20 (Built-in variables)
298
299    None.
300
301Additions to Chapter 8 of the OpenGL Shading Language (GLSL) Specification,
302version 4.20, (Built-in Functions)
303
304    Add the Subection 8.9.3, "Uncommitted Texture Images", renumber subsequent
305    sections.
306
307    If a standard texture function is used to sample from a region of a texture
308    image where storage is uncommitted, undefined data is returned to the
309    shader (although no instability results). If the application can guarantee
310    that this will not occur (such as when well defined texture coordinates are
311    used with a texture atlas, for example), then standard texturing functions
312    may be used with partially resident textures. If there is a possibility that
313    at the time of use, data in the texture may be non-resident (uncommitted),
314    one of the sparse texture functions may be used to determine the residency
315    status of the data.
316
317    The sparse texture functions return a condition code indicating the success
318    of a texel fetch operation. If texture data is present at the sampled
319    location, the texture data is returned in the <texel> inout parameter and
320    the function returns zero. If texture data is not present at the sampled
321    location, <texel> is unmodified and the function returns a non-zero status
322    code. It is then the responsibility of the shader to determine the
323    appropriate course of action.
324
325    Add the following tables to the end of Section 8.9.3:
326
327    Sparse texture lookup functions:
328
329    +-------------------------------------------------------------------+-------------------------------------------+
330    | Syntax                                                            | Description                               |
331    +-------------------------------------------------------------------+-------------------------------------------+
332    | int sparseTexture(gsampler1D sampler, float P,                    | Behave as in texture(), but with          |
333    |                   inout gvec4 texel [, float bias]);              | data returned in <texel> and a            |
334    |                                                                   | status code produced as the return value  |
335    | int sparseTexture(gsampler2D sampler, vec2 P,                     | of the function.                          |
336    |                   inout gvec4 texel [, float bias]);              |                                           |
337    |                                                                   |                                           |
338    | int sparseTexture(gsampler2DRect sampler, vec2 P,                 |                                           |
339    |                   inout gvec4 texel [, float bias]);              |                                           |
340    |                                                                   |                                           |
341    | int sparseTexture(gsampler3D sampler, vec3 P,                     |                                           |
342    |                   inout gvec4 texel [, float bias]);              |                                           |
343    |                                                                   |                                           |
344    | int sparseTexture(gsampler1DArray sampler, vec2 P,                |                                           |
345    |                   inout gvec4 texel [, float bias]);              |                                           |
346    |                                                                   |                                           |
347    | int sparseTexture(gsampler2DArray sampler, vec3 P,                |                                           |
348    |                   inout gvec4 texel [, float bias]);              |                                           |
349    |                                                                   |                                           |
350    | int sparseTexture(gsamplerCube sampler, vec3 P,                   |                                           |
351    |                   inout gvec4 texel [, float bias]);              |                                           |
352    |                                                                   |                                           |
353    | int sparseTexture(gsamplerCubeArray sampler, vec4 P,              |                                           |
354    |                   inout gvec4 texel [, float bias]);              |                                           |
355    +-------------------------------------------------------------------+-------------------------------------------+
356    | int sparseTextureProj(gsampler1D sampler,                         | Behave as in textureProj(), but with      |
357    |                       vec2 P,                                     | data returned in <texel> and a            |
358    |                       inout gvec4 texel [, float bias]);          | status code produced as the return value  |
359    |                                                                   | of the function.                          |
360    | int sparseTextureProj(gsampler1D sampler,                         |                                           |
361    |                       vec4 P,                                     |                                           |
362    |                       inout gvec4 texel [, float bias]);          |                                           |
363    |                                                                   |                                           |
364    | int sparseTextureProj(gsampler2D sampler,                         |                                           |
365    |                       vec3 P,                                     |                                           |
366    |                       inout gvec4 texel [, float bias]);          |                                           |
367    |                                                                   |                                           |
368    | int sparseTextureProj(gsampler2DRect sampler,                     |                                           |
369    |                       vec3 P,                                     |                                           |
370    |                       inout gvec4 texel [, float bias]);          |                                           |
371    |                                                                   |                                           |
372    | int sparseTextureProj(gsampler2D sampler,                         |                                           |
373    |                       vec4 P,                                     |                                           |
374    |                       inout gvec4 texel [, float bias]);          |                                           |
375    |                                                                   |                                           |
376    | int sparseTextureProj(gsampler2DRect sampler,                     |                                           |
377    |                       vec4 P,                                     |                                           |
378    |                       inout gvec4 texel [, float bias]);          |                                           |
379    |                                                                   |                                           |
380    | int sparseTextureProj(gsampler3D sampler,                         |                                           |
381    |                       vec4 P,                                     |                                           |
382    |                       inout gvec4 texel [, float bias]);          |                                           |
383    +-------------------------------------------------------------------+-------------------------------------------+
384    | int sparseTextureLod(gsampler1D sampler,                          | Behave as in textureLod(), but with       |
385    |                      float P, float lod,                          | data returned in <texel> and a            |
386    |                      inout gvec4 texel);                          | status code produced as the return value  |
387    |                                                                   | of the function.                          |
388    | int sparseTextureLod(gsampler2D sampler,                          |                                           |
389    |                      vec2 P, float lod,                           |                                           |
390    |                      inout gvec4 texel);                          |                                           |
391    |                                                                   |                                           |
392    | int sparseTextureLod(gsampler3D sampler,                          |                                           |
393    |                      vec3 P, float lod,                           |                                           |
394    |                      inout gvec4 texel);                          |                                           |
395    |                                                                   |                                           |
396    | int sparseTextureLod(gsampler1DArray sampler,                     |                                           |
397    |                      vec2 P, float lod,                           |                                           |
398    |                      inout gvec4 texel);                          |                                           |
399    |                                                                   |                                           |
400    | int sparseTextureLod(gsampler2DArray sampler,                     |                                           |
401    |                      vec3 P, float lod,                           |                                           |
402    |                      inout gvec4 texel);                          |                                           |
403    |                                                                   |                                           |
404    | int sparseTextureLod(gsamplerCube sampler,                        |                                           |
405    |                      vec3 P, float lod,                           |                                           |
406    |                      inout gvec4 texel);                          |                                           |
407    |                                                                   |                                           |
408    | int sparseTextureLod(gsamplerCubeArray sampler,                   |                                           |
409    |                      vec4 P, float lod,                           |                                           |
410    |                      inout gvec4 texel);                          |                                           |
411    +-------------------------------------------------------------------+-------------------------------------------+
412    | int sparseTextureOffset(gsampler1D sampler,                       | Behave as in textureOffset(), but         |
413    |                         float P, int offset,                      | with data returned in <texel> and a       |
414    |                         inout gvec4 texel [, float bias]);        | status code produced as the return value  |
415    |                                                                   | of the function.                          |
416    | int sparseTextureOffset(gsampler2D sampler,                       |                                           |
417    |                         vec2 P, ivec2 offset,                     |                                           |
418    |                         inout gvec4 texel [, float bias]);        |                                           |
419    |                                                                   |                                           |
420    | int sparseTextureOffset(gsampler3D sampler,                       |                                           |
421    |                         vec3 P, ivec3 offset,                     |                                           |
422    |                         inout gvec4 texel [, float bias]);        |                                           |
423    |                                                                   |                                           |
424    | int sparseTextureOffset(gsampler1DArray sampler,                  |                                           |
425    |                         vec2 P, int offset,                       |                                           |
426    |                         inout gvec4 texel [, float bias]);        |                                           |
427    |                                                                   |                                           |
428    | int sparseTextureOffset(gsampler2DArray sampler,                  |                                           |
429    |                         vec3 P, ivec2 offset,                     |                                           |
430    |                         inout gvec4 texel [, float bias]);        |                                           |
431    +-------------------------------------------------------------------+-------------------------------------------+
432    | int sparseTextureProjOffset(gsampler1D sampler,                   | Behave as in textureProjOffset(), but     |
433    |                             vec2 P, int offset,                   | with data returned in <texel> and a       |
434    |                             inout gvec4 texel [, float bias]);    | status code produced as the return value  |
435    |                                                                   | of the function.                          |
436    | int sparseTextureProjOffset(gsampler1D sampler,                   |                                           |
437    |                             vec4 P, int offset,                   |                                           |
438    |                             inout gvec4 texel [, float bias]);    |                                           |
439    |                                                                   |                                           |
440    | int sparseTextureProjOffset(gsampler2D sampler,                   |                                           |
441    |                             vec3 P, ivec2 offset,                 |                                           |
442    |                             inout gvec4 texel [, float bias]);    |                                           |
443    |                                                                   |                                           |
444    | int sparseTextureProjOffset(gsampler2D sampler,                   |                                           |
445    |                             vec4 P, ivec2 offset,                 |                                           |
446    |                             inout gvec4 texel [, float bias]);    |                                           |
447    |                                                                   |                                           |
448    | int sparseTextureProjOffset(gsampler3D sampler,                   |                                           |
449    |                             vec4 P, ivec3 offset,                 |                                           |
450    |                             inout gvec4 texel [, float bias]);    |                                           |
451    +-------------------------------------------------------------------+-------------------------------------------+
452    | int sparseTextureLodOffset(gsampler1D sampler,                    | Behave as in textureLodOffset(), but      |
453    |                            float P, float lod, int offset,        | with data returned in <texel> and a       |
454    |                            inout gvec4 texel);                    | status code produced as the return value  |
455    |                                                                   | of the function.                          |
456    | int sparseTextureLodOffset(gsampler2D sampler,                    |                                           |
457    |                            vec2 P, float lod, ivec2 offset,       |                                           |
458    |                            inout gvec4 texel);                    |                                           |
459    |                                                                   |                                           |
460    | int sparseTextureLodOffset(gsampler3D sampler,                    |                                           |
461    |                            vec3 P, float lod, ivec3 offset,       |                                           |
462    |                            inout gvec4 texel);                    |                                           |
463    |                                                                   |                                           |
464    | int sparseTextureLodOffset(gsampler1DArray sampler,               |                                           |
465    |                            vec2 P, float lod, int offset,         |                                           |
466    |                            inout gvec4 texel);                    |                                           |
467    |                                                                   |                                           |
468    | int sparseTextureLodOffset(gsampler2DArray sampler,               |                                           |
469    |                            vec3 P, float lod, ivec2 offset,       |                                           |
470    |                            inout gvec4 texel);                    |                                           |
471    +-------------------------------------------------------------------+-------------------------------------------+
472    | int sparseTextureProjLod(gsampler1D sampler,                      | Behave as in textureProjLod(), but        |
473    |                          vec2 P, float lod,                       | with data returned in <texel> and a       |
474    |                          inout gvec4 texel);                      | status code produced as the return value  |
475    |                                                                   | of the function.                          |
476    | int sparseTextureProjLod(gsampler1D sampler,                      |                                           |
477    |                          vec4 P, float lod,                       |                                           |
478    |                          inout gvec4 texel);                      |                                           |
479    |                                                                   |                                           |
480    | int sparseTextureProjLod(gsampler2D sampler,                      |                                           |
481    |                          vec3 P, float lod,                       |                                           |
482    |                          inout gvec4 texel);                      |                                           |
483    |                                                                   |                                           |
484    | int sparseTextureProjLod(gsampler2D sampler,                      |                                           |
485    |                          vec4 P, float lod,                       |                                           |
486    |                          inout gvec4 texel);                      |                                           |
487    |                                                                   |                                           |
488    | int sparseTextureProjLod(gsampler3D sampler,                      |                                           |
489    |                          vec4 P, float lod,                       |                                           |
490    |                          inout gvec4 texel);                      |                                           |
491    +-------------------------------------------------------------------+-------------------------------------------+
492    | int sparseTextureProjLodOffset(gsampler1D sampler,                | Behave as in textureProjLodOffset(), but  |
493    |                                vec2 P, float lod, int offset,     | with data returned in <texel> and a       |
494    |                                inout gvec4 texel);                | status code produced as the return value  |
495    |                                                                   | of the function.                          |
496    | int sparseTextureProjLodOffset(gsampler1D sampler,                |                                           |
497    |                                vec4 P, float lod, int offset,     |                                           |
498    |                                inout gvec4 texel);                |                                           |
499    |                                                                   |                                           |
500    | int sparseTextureProjLodOffset(gsampler2D sampler,                |                                           |
501    |                                vec3 P, float lod, ivec2 offset,   |                                           |
502    |                                inout gvec4 texel);                |                                           |
503    |                                                                   |                                           |
504    | int sparseTextureProjLodOffset(gsampler2D sampler,                |                                           |
505    |                                vec4 P, float lod, ivec2 offset,   |                                           |
506    |                                inout gvec4 texel);                |                                           |
507    |                                                                   |                                           |
508    | int sparseTextureProjLodOffset(gsampler3D sampler,                |                                           |
509    |                                vec4 P, float lod, ivec3 offset,   |                                           |
510    |                                inout gvec4 texel);                |                                           |
511    +-------------------------------------------------------------------+-------------------------------------------+
512    | int sparseTextureGrad(gsampler1D sampler, float P,                | Behave as in textureGrad(), but           |
513    |                       float dPdx, float dPdy,                     | with data returned in <texel> and a       |
514    |                       inout gvec4 texel);                         | status code produced as the return value  |
515    |                                                                   | of the function.                          |
516    | int sparseTextureGrad(gsampler2D sampler, vec2 P,                 |                                           |
517    |                       vec2 dPdx, vec2 dPdy,                       |                                           |
518    |                       inout gvec4 texel);                         |                                           |
519    |                                                                   |                                           |
520    | int sparseTextureGrad(gsampler3D sampler, vec3 P,                 |                                           |
521    |                       vec3 dPdx, vec3 dPdy,                       |                                           |
522    |                       inout gvec4 texel);                         |                                           |
523    |                                                                   |                                           |
524    | int sparseTextureGrad(gsampler1DArray sampler, vec2 P,            |                                           |
525    |                       float dPdx, float dPdy,                     |                                           |
526    |                       inout gvec4 texel);                         |                                           |
527    |                                                                   |                                           |
528    | int sparseTextureGrad(gsampler2DArray sampler, vec3 P,            |                                           |
529    |                       vec2 dPdx, vec2 dPdy,                       |                                           |
530    |                       inout gvec4 texel);                         |                                           |
531    |                                                                   |                                           |
532    | int sparseTextureGrad(gsamplerCube sampler, vec3 P,               |                                           |
533    |                       vec2 dPdx, vec2 dPdy,                       |                                           |
534    |                       inout gvec4 texel);                         |                                           |
535    |                                                                   |                                           |
536    | int sparseTextureGrad(gsamplerCubeArray sampler, vec4 P,          |                                           |
537    |                       vec2 dPdx, vec2 dPdy,                       |                                           |
538    |                       inout gvec4 texel);                         |                                           |
539    +-------------------------------------------------------------------+-------------------------------------------+
540    | int sparseTextureGradOffset(gsampler1D sampler, float P,          | Behave as in textureGradOffset(), but     |
541    |                             float dPdx, float dPdy, int offset,   | with data returned in <texel> and a       |
542    |                             inout gvec4 texel);                   | status code produced as the return value  |
543    |                                                                   | of the function.                          |
544    | int sparseTextureGradOffset(gsampler2D sampler, vec2 P,           |                                           |
545    |                             vec2 dPdx, vec2 dPdy, ivec2 offset,   |                                           |
546    |                             inout gvec4 texel);                   |                                           |
547    |                                                                   |                                           |
548    | int sparseTextureGradOffset(gsampler3D sampler, vec3 P,           |                                           |
549    |                             vec3 dPdx, vec3 dPdy, ivec3 offset,   |                                           |
550    |                             inout gvec4 texel);                   |                                           |
551    |                                                                   |                                           |
552    | int sparseTextureGradOffset(gsampler1DArray sampler, vec2 P,      |                                           |
553    |                             float dPdx, float dPdy, int offset,   |                                           |
554    |                             inout gvec4 texel);                   |                                           |
555    |                                                                   |                                           |
556    | int sparseTextureGradOffset(gsampler2DArray sampler, vec3 P,      |                                           |
557    |                             vec2 dPdx, vec2 dPdy, ivec2 offset,   |                                           |
558    |                             inout gvec4 texel);                   |                                           |
559    +-------------------------------------------------------------------+-------------------------------------------+
560    | int sparseTextureProjGrad(gsampler1D sampler,                     | Behave as in textureProjGrad(), but       |
561    |                           vec2 P, float dPdx, float dPdy,         | with data returned in <texel> and a       |
562    |                           inout gvec4 texel);                     | status code produced as the return value  |
563    |                                                                   | of the function.                          |
564    | int sparseTextureProjGrad(gsampler1D sampler,                     |                                           |
565    |                           vec4 P, float dPdx, float dPdy,         |                                           |
566    |                           inout gvec4 texel);                     |                                           |
567    |                                                                   |                                           |
568    | int sparseTextureProjGrad(gsampler2D sampler,                     |                                           |
569    |                           vec3 P, vec2 dPdx, vec2 dPdy,           |                                           |
570    |                       inout gvec4 texel);                         |                                           |
571    |                                                                   |                                           |
572    | int sparseTextureProjGrad(gsampler2D sampler,                     |                                           |
573    |                           vec4 P, vec2 dPdx, vec2 dPdy,           |                                           |
574    |                           inout gvec4 texel);                     |                                           |
575    |                                                                   |                                           |
576    | int sparseTextureProjGrad(gsampler3D sampler,                     |                                           |
577    |                           vec4 P,                                 |                                           |
578    |                           inout gvec4 texel);                     |                                           |
579    +-------------------------------------------------------------------+-------------------------------------------+
580    | int sparseTextureProjGradOffset(gsampler1D sampler, vec2 P,       | Behave as in textureProjGradOffset(), but |
581    |                                 float dPdx, float dPdy,           | with data returned in <texel> and a       |
582    |                                 int offset, inout gvec4 texel);   | status code produced as the return value  |
583    |                                                                   | of the function.                          |
584    | int sparseTextureProjGradOffset(gsampler1D sampler, vec4 P,       |                                           |
585    |                                 float dPdx, float dPdy,           |                                           |
586    |                                 int offset, inout gvec4 texel);   |                                           |
587    |                                                                   |                                           |
588    | int sparseTextureProjGradOffset(gsampler2D sampler, vec3 P,       |                                           |
589    |                                 vec2 dPdx, vec2 dPdy,             |                                           |
590    |                                 ivec2 offset, inout gvec4 texel); |                                           |
591    |                                                                   |                                           |
592    | int sparseTextureProjGradOffset(gsampler2D sampler, vec4 P,       |                                           |
593    |                                 vec2 dPdx, vec2 dPdy,             |                                           |
594    |                                 ivec2 offset, inout gvec4 texel); |                                           |
595    |                                                                   |                                           |
596    | int sparseTextureProjGradOffset(gsampler3D sampler, vec4 P,       |                                           |
597    |                                 vec3 dPdx, vec3 dPdy,             |                                           |
598    |                                 ivec3 offset, inout gvec4 texel); |                                           |
599    +-------------------------------------------------------------------+-------------------------------------------+
600
601    Add the following table and description.
602
603    The following functions may be used to interpret the status codes returned
604    by the sparse texture lookup functions.
605
606    +-------------------------------------------------------------------+-------------------------------------------+
607    | Syntax                                                            | Description                               |
608    +-------------------------------------------------------------------+-------------------------------------------+
609    | bool sparseTexelResident(int code);                               | Returns true if the texture read that     |
610    |                                                                   | produced <code> retrieved valid data, and |
611    |                                                                   | false otherwise.                          |
612    |                                                                   |                                           |
613    | bool sparseTexelMinLodWarning(int code);                          | Returns true if the texture read that     |
614    |                                                                   | produced <code> required a texel fetch    |
615    |                                                                   | from any LOD lower than the user          |
616    |                                                                   | specified LOD warning threshold.          |
617    |                                                                   |                                           |
618    | int sparseTexelLodWarningFetch(int code);                         | Returns the LOD calculated by the texture |
619    |                                                                   | read that generated <code> and resulted   |
620    |                                                                   | in a condition that would cause           |
621    |                                                                   | sparseTexelMinLodWarning to return true.  |
622    |                                                                   | If the LOD warning was not encountered,   |
623    |                                                                   | this function returns zero.               |
624    +-------------------------------------------------------------------+-------------------------------------------+
625
626
627Additions to Chapter 9 of the OpenGL Shading Language (GLSL) Specification,
628version 4.20, (Shading Language Grammar)
629
630    None.
631
632Additions to the AGL/GLX/WGL Specifications
633
634    None.
635
636GLX Protocol
637
638    None.
639
640Errors
641
642    INVALID_ENUM is generated by TexStorageSparseAMD
643    and TextureStorageSparseAMD if <target> is not one of the supported
644    texture targets.
645
646    INVALID_ENUM is generated by TexStorageSparseAMD
647    and TextureStorageSparseAMD if <internalFormat> is not one of the
648    accepted internal texture formats.
649
650    INVALID_VALUE is generated by TexStorageSparseAMD
651    and TextureStorageSparseAMD if <height> or <depth> is not 1 and
652    <target> is TEXTURE_1D or TEXTURE_1D_ARRAY.
653
654    INVALID_VALUE is generated by TexStorageSparseAMD
655    and TextureStorageSparseAMD if <height> is not 1 and <target> is
656    TEXTURE_2D, TEXTURE_RECTANGLE or TEXTURE_2D_ARRAY.
657
658    INVALID_VALUE is generated by TexStorageSparseAMD
659    and TextureStorageSparseAMD if <width>, <height> and <depth> are not
660    equal and <target> is TEXTURE_CUBE_MAP or TEXTURE_CUBE_MAP_ARRAY.
661
662    INVALID_VALUE is generated by TexStorageSparseAMD
663    and TextureStorageSparseAMD if <layers> is not 1 and <target> is not
664    one of the ARRAY texture targets.
665
666    INVALID_VALUE is generated by TexStorageSparseAMD
667    and TextureStorageSparseAMD if <width> or <height> is greater than the
668    value of MAX_SPARSE_TEXTURE_SIZE_AMD, or if <depth> is greater than
669    the value of MAX_SPARSE_3D_TEXTURE_SIZE_AMD, or if <layers> is greater
670    than the value of MAX_SPARSE_ARRAY_TEXTURE_LAYERS_AMD.
671
672    INVALID_VALUE is generated by TexImage* and CopyTexImage* if the dimensions
673    of the updated region are not integer multiples of VIRTUAL_PAGE_SIZE_X_AMD,
674    VIRTUAL_PAGE_SIZE_Y_AMD (for 2D and 3D textures) and VIRTUAL_PAGE_SIZE_Z_AMD
675    (for 3D textures).
676
677New State
678
679    Append to Table 6.16, "Textures (state per texture object)"
680
681    +-----------------------+-------+-------------------+---------------+-------------------------------------------+-------+
682    | Get Value             | Type  | Get Command       | Initial Value | Description                               | Sec.  |
683    +-----------------------+-------+-------------------+---------------+-------------------------------------------+-------+
684    | MIN_LOD_WARNING_AMD   | Z+    | GetTexParameteriv | 0             | User-specified minimum LOD warning level. | 3.8.6 |
685    +-----------------------+-------+-------------------+---------------+-------------------------------------------+-------+
686
687New Implementation Dependent State
688
689    Append to Table 6.42, "Implementation Dependent Values"
690
691    +-----------------------------------+-------+-------------+-----------------+---------------------------------------+-------+
692    | Get Value                         | Type  | Get Command | Minimum Value   | Description                           | Sec.  |
693    +-----------------------------------+-------+-------------+-----------------+---------------------------------------+-------+
694    | MAX_SPARSE_TEXTURE_SIZE_AMD       | Z+    | GetIntegerv | 16384           | Maximum 1D/2D/rectangle texture image | 3.8.6 |
695    |                                   |       |             |                 | dimension for a sparse texture.       |       |
696    | MAX_SPARSE_3D_TEXTURE_SIZE_AMD    | Z+    | GetIntegerv | 2048            | Maximum 3D texture image dimension    | 3.8.6 |
697    |                                   |       |             |                 | for a sparse texture.                 |       |
698    | MAX_SPARSE_3D_TEXTURE_SIZE_AMD    | Z+    | GetIntegerv | 2048            | Maximum number of layers in a sparse  | 3.8.6 |
699    |                                   |       |             |                 | array texture.                        |       |
700    +-----------------------------------+-------+-------------+-----------------+---------------------------------------+-------+
701
702Issues
703
704    1) Are all supported texture targets exposed? Are any exposed that are not
705       supported well by hardware?
706
707       RESOLVED: All texture targets are exposed except for multisample, and
708       buffer textures.
709
710    2) Why do we have <depth> and <layers> separate in TexStorageSparseAMD and
711       TextureStorageSparseAMD, whereas in TexImage3D, <depth> specifies the
712       size of the 2D array, for example?
713
714       Because it's easier to validate and because I don't want to hack up my
715       extension if we introduce 3D-array textures.
716
717    3) Does this play nice with the proposed EXT_texture_storage extension
718       (which defines some very similar entry points to TexStorageSparseAMD
719       and TextureStorageSparseAMD)? Can it be made to play nice?
720
721       RESOLVED: Yes, it should interact just fine. Unfortunately,
722       EXT_texture_storage didn't introduce any mechanism to convey flags or
723       allocation strategies and so those entry points could not be used here.
724       Otherwise, textures allocated with TexStorage* APIs should appear as
725       fully resident textures if used with sparse texture sampling functions.
726
727    4) Is it possible to attach a partially resident texture to an FBO and
728       render into it?
729
730       RESOLVED: Yes, this is supported. Keep in mind, though, that data rendered
731       to an attachment in areas that are not resident will be discarded and there
732       is no mechanism to detect this. Also, depth, stencil and multisample
733       formats are not supported by this extension.
734
735    5) What happens if TEXTURE_STORAGE_SPARSE_BIT_AMD is not present in
736       TexStorageSparseAMD or TextureStorageSparseAMD?
737
738       RESOLVED: Texture storage will be both allocated and committed. The
739       texture is still considered immutable and so this is mostly equivalent
740       to calling the TexStorage API.
741
742    6) Does this extension increase the maximum supported texture size?
743
744       RESOLVED: No, not explicitly. The maximum supported texture size is
745       still queryable by retrieving the value of MAX_TEXTURE_SIZE. A new token,
746       MAX_SPARSE_TEXTURE_SIZE_AMD is added to query the maximum sparse texture
747       size, which may be larger than the non-sparse maximum. However, there
748       is no requirement for it to be so.
749
750    7) What if a larger sparse textures are supported than non-sparse textures?
751
752       RESOLVED: Query the maximum sparse texture size by retrieving the value
753       of MAX_SPARSE_TEXTURE_SIZE_AMD.
754
755    8) How do you decommit (free) a region of a sparse texture?
756
757       RESOLVED: Call TexSubImageND with <data> set to NULL and without a
758       pixel unpack buffer bound.
759
760    9) -
761
762    10) Is compression supported for sparse textures?
763
764        RESOLVED: Yes, but be aware that the dimensions of a single tile could
765        be substantially larger when the texture is compressed.
766
767    11) Does this work with non-power-of-two textures?
768
769        RESOLVED: Yes, so long as the texture size is an integer multiple of
770        the texture tile size in all dimensions.
771
772    12) Are multisampled sparse textures supported?
773
774        RESOLVED: No.
775
776    13) What about OUT_OF_MEMORY errors?
777
778        RESOLVED: OUT_OF_MEMORY errors can be reported if there isn't sufficient
779        system memory to allocate internal structures (even a fully uncommitted
780        sparse texture requires some internal resources), or if there isn't
781        sufficient video memory to commit all requested regions.
782
783        The error doesn't have to be reported upon creation of a sparse texture.
784        For example, allocation of two 64 GB sparse textures might succeed, but
785        their simulatenous use in one draw call might result in an OUT_OF_MEMORY
786        error being reported by the GL later.
787
788    14) Does CopyTexSubImage work with sparse textures?
789
790        RESOLVED: Yes.
791
792    15) Does GetTexImage work with sparse texture?
793
794        RESOLVED: Yes in general. However, the call can fail based on
795        implementation-specific limitations.
796
797Revision History
798
799    Rev.    Date      Author    Changes
800    ----  --------    --------  -----------------------------------------
801
802     6    03/27/2012  gsellers  Resolve some issues.
803                                Clarify interactions with PBO.
804     5    03/14/2012  jobert    Rename some tokens.
805                                Assign token values.
806     4    20/04/2011  gsellers  Add min-lod warning.
807                                Add sparse texture fetch return code built-ins.
808                                Add new state tables.
809                                Add 3D sparse texture size limit.
810                                Add support for cube textures and cube texture
811                                arrays.
812                                Add issues 10 and 11, remove issue 9.
813     3    25/03/2011  gsellers  Change required version of GL to 2.0 (or
814                                equivalent extensions).
815                                Add query for virtual page size.
816                                Add restrictions on page size and alignment
817                                during commitment.
818                                Add MAX_SPARSE_TEXTURE_SIZE_AMD.
819                                Add issues 6 through 9.
820                                Add MIN_SPARSE_LEVEL_AMD.
821     2    25/02/2011  jobert    Expanded the Issues section
822     1    11/02/2011  gsellers  Initial Revision
823