1Name 2 3 EXT_sparse_texture2 4 5Name Strings 6 7 GL_EXT_sparse_texture2 8 9Contact 10 11 Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 12 13Contributors 14 15 Jeff Bolz, NVIDIA Corporation 16 Mathias Heyer, NVIDIA Corporation 17 Daniel Koch, NVIDIA Corporation 18 19Status 20 21 Shipping 22 23Version 24 25 Last Modified Date: April 19, 2016 26 NVIDIA Revision: 3 27 28Number 29 30 OpenGL Extension #463 31 OpenGL ES Extension #259 32 33Dependencies 34 35 This extension is written against the OpenGL 4.4 Specification 36 (Compatibility Profile), dated July 21, 2013. 37 38 This extension is written against the OpenGL Shading Language 39 Specification, version 4.40, revision 6. 40 41 When implemented in OpenGL, this extension requires and extends 42 ARB_sparse_texture. 43 44 When implemented in OpenGL ES, this extension requires and extends 45 EXT_sparse_texture. 46 47 This extension interacts trivially with EXT_depth_bounds_test. 48 49 This extension interacts with NV_gpu_program4 and NV_gpu_program5. 50 51 This extension interacts with OpenGL ES 3.1 (dated October 29th 2014). 52 53 This extension interacts with OpenGL ES Shading Language 3.1 (revision 3). 54 55 This extension interacts with EXT_gpu_shader5 and OES_gpu_shader5. 56 57 This extension interacts with EXT_texture_norm16. 58 59 This extension interacts with EXT_texture_cube_map_array and 60 OES_texture_cube_map_array. 61 62 This extension interacts with OES_texture_storage_multisample_2D_array. 63 64 65Overview 66 67 This extension builds on the ARB_sparse_texture extension, providing the 68 following new functionality: 69 70 * New built-in GLSL texture lookup and image load functions are provided 71 that return information on whether the texels accessed for the texture 72 lookup accessed uncommitted texture memory. 73 74 * New built-in GLSL texture lookup functions are provided that specify a 75 minimum level of detail to use for lookups where the level of detail 76 is computed automatically. This allows shaders to avoid accessing 77 unpopulated portions of high-resolution levels of detail when it knows 78 that the memory accessed is unpopulated, either from a priori 79 knowledge or from feedback provided by the return value of previously 80 executed "sparse" texture lookup functions. 81 82 * Reads of uncommitted texture memory will act as though such memory 83 were filled with zeroes; previously, the values returned by reads were 84 undefined. 85 86 * Standard implementation-independent virtual page sizes for internal 87 formats required to be supported with sparse textures. These standard 88 sizes can be requested by leaving VIRTUAL_PAGE_SIZE_INDEX_ARB at its 89 initial value (0). 90 91 * Support for creating sparse multisample and multisample array textures 92 is added. However, the virtual page sizes for such textures remain 93 fully implementation-dependent. 94 95New Procedures and Functions 96 97 None. 98 99New Tokens 100 101 None. 102 103Modifications to the OpenGL 4.4 Specification (Compatibility Profile) 104 105 Modify Section 8.10, Texture Parameters, p. 250 106 107 (modify the following Errors section entry for TexParameter*, added by 108 ARB_sparse_texture, to allow for sparse multisample and multisample array 109 textures) 110 111 INVALID_VALUE is generated if <pname> is TEXTURE_SPARSE_ARB, <pname> 112 is TRUE and <target> is not one of TEXTURE_2D, TEXTURE_2D_ARRAY, 113 TEXTURE_CUBE_MAP, TEXTURE_CUBE_MAP_ARRAY, TEXTURE_3D, TEXTURE_RECTANGLE, 114 TEXTURE_2D_MULTISAMPLE, or TEXTURE_2D_MULTISAMPLE_ARRAY. 115 116 117 Modify Section 8.14.1, Scale Factor and Level of Detail, p. 261 118 119 (move the next-to-last paragraph, p. 261, describing lod_min and lod_max 120 in equation 8.6, up one paragraph and modify it to read as follows) 121 122 lod_min and lod_max indicate minimum and maximum clamps on the computed 123 level of detail. lod_max is taken directly from the TEXTURE_MAX_LOD 124 texture or sampler parameter. If a texture access is performed in a 125 fragment shader with a minimum level of detail clamp specified in the 126 built-in texture lookup function, lod_min is the larger of the 127 TEXTURE_MIN_LOD texture or sampler parameter and the minimum level of 128 detail provided by the shader. Otherwise, lod_min is taken directly from 129 the TEXTURE_MIN_LOD texture or sampler parameter. The initial values of 130 the TEXTURE_MIN_LOD and TEXTURE_MAX_LOD texture and sampler parameters are 131 chosen so as to never clamp the range of lambda values. 132 133 134 Modify the edits to Section 8.19 (Immutable-Format Texture Images), as 135 made by ARB_sparse_texture 136 137 (remove the following language from the "p. 233" edits starting with "If 138 TEXTURE_SPARSE_ARB is TRUE"; there is no longer a restriction on the base 139 size of a sparse texture allocation) 140 141 [REMOVED LANGUAGE] ... In this case, <width>, <height>, and <depth> must 142 either be integer multiples of the selected virtual page size in the X, Y, 143 and Z dimensions, respectively, or be less than those dimensions. ... 144 145 (remove the following TexStorage error added by ARB_sparse_texture; there 146 is no longer a restriction on the base size of a sparse texture 147 allocation) 148 149 [REMOVED LANGUAGE] An INVALID_VALUE error is generated if 150 TEXTURE_SPARSE_ARB is TRUE and <width>, <height> or <depth> is is not an 151 integer multiple of the page size in the corresponding dimension. 152 153 (remove the error language beginning with "If the value of 154 SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB is FALSE", and replace with 155 the following) 156 157 In older extensions supporting sparse textures, the constant 158 SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB was provided to advertise 159 implementation-dependent limitations potentially prohibiting the 160 allocation of array or cube map textures with full mipmap chains. No such 161 limitations apply in this extension. This constant is retained for 162 backwards compatibility, but all implementations of this extension must 163 return TRUE. 164 165 166 Modify Section 8.20.1 of ARB_sparse_texture (Allocation of and Access to 167 Sparse Textures) 168 169 (insert after the two paragraphs discussing VIRTUAL_PAGE_SIZE_INDEX_ARB) 170 171 When leaving the VIRTUAL_PAGE_SIZE_INDEX_ARB texture parameter at its 172 initial value (0), the virtual page size for many non-multisample sparse 173 textures can be found in Table 8.X. The virtual page size of such a 174 texture comes from the value listed in the "3D Page Size" column for the 175 texture target TEXTURE_3D, or the value listed in the "2D Page Size" 176 column for any other target. If the internal format of the texture is not 177 listed in Table 8.X or if the texture target is TEXTURE_2D_MULTISAMPLE or 178 TEXTURE_2D_MULTISAMPLE_ARRAY, the virtual page size for index zero is 179 fully implementation-dependent. 180 181 Internal Format 2D Page Size 3D Page Size 182 --------------- ------------- ------------ 183 R8 256 x 256 x 1 64 x 32 x 32 184 R8_SNORM 185 R8I 186 R8UI 187 188 R16 256 x 128 x 1 32 x 32 x 32 189 R16_SNORM 190 RG8 191 RG8_SNORM 192 RGB565 193 R16F 194 R16I 195 R16UI 196 RG8I 197 RG8UI 198 199 RG16 128 x 128 x 1 32 x 32 x 16 200 RG16_SNORM 201 RGBA8 202 RGBA8_SNORM 203 RGB10_A2 204 RGB10_A2UI 205 RG16F 206 R32F 207 R11F_G11F_B10F 208 RGB9_E5 209 R32I 210 R32UI 211 RG16I 212 RG16UI 213 RGBA8I 214 RGBA8UI 215 216 RGBA16 128 x 64 x 1 32 x 16 x 16 217 RGBA16_SNORM 218 RGBA16F 219 RG32F 220 RG32I 221 RG32UI 222 RGBA16I 223 RGBA16UI 224 225 RGBA32F 64 x 64 x 1 16 x 16 x 16 226 RGBA32I 227 RGBA32UI 228 229 Table 8.X, Standard Virtual Page Sizes for Sparse Textures 230 231 232 (modify first bullet under "When a sparsely committed texture is accessed 233 by the GL" at the end of the section) 234 235 * Reads from such regions behave as if the data in texture memory for 236 all components present in the texture format were zero. This 237 includes samples required for the implementation of texture 238 filtering, image loads, mipmap generation, and so on. For texture 239 and image loads, components not present in the texture format (e.g., 240 alpha in a texture with an RGB base internal format) will return 241 default values, as in non-sparse textures. 242 243 (modify third bullet under "When a sparsely committed texture is accessed 244 by the GL" at the end of the section) 245 246 * Atomic operations operating on uncommitted regions will not generate 247 exceptions but will always return zero. The result of the atomic 248 operation, which is normally written to memory, will instead be 249 discarded. 250 251 (add new bullets under "When a sparsely committed texture is accessed by 252 the GL" at the end of the section) 253 254 * When performing the stencil test (section 17.3.5), depth buffer test 255 (section 17.3.6), or depth bounds test on pixels in uncommitted 256 regions, the results of the test will be consistent with reading a 257 value of zero from the framebuffer. No value is written to the 258 depth buffer. 259 260 (add a new paragraph at the end of the section) 261 262 The OpenGL Shading Language provides built-in functions that perform a 263 texture fetch or image load and return sparse texture status information 264 to the caller. The status information can be queried by the built-in 265 function sparseTexelsResidentEXT(), which returns false if the lookup 266 function read one or more uncommitted texels and true otherwise. For the 267 purposes of this query, texels addressed by a filter normally computing a 268 weighted average of multiple texels (e.g., LINEAR) will be considered to 269 access only those texels with non-zero weights. 270 271 272 Modify Section 8.20.2 of ARB_sparse_texture (Controlling Sparse Texture 273 Commitment) 274 275 (modify the fifth paragraph of the section from ARB_sparse_texture, 276 starting with "For levels of a sparse texture where..." to guarantee that 277 any level greater than or equal to the page size in all dimensions can be 278 sparsely populated) 279 280 For levels of a sparse texture where each dimension is greater than or 281 equal to of the virtual page size, the residency of individual page-size 282 regions is controlled by TexPageCommitmentARB and such levels may be 283 partially populated. When the mipmap chain reaches a level that is not 284 greater than or equal to the virtual page size in any dimension, padding 285 and memory layout considerations may make it impossible to treat that 286 level and subsequent smaller ones as partially populated. ... 287 288 289Modifications to the OpenGL Shading Language Specification, Version 4.40 290 291 Including the following line in a shader can be used to control the 292 language features described in this extension: 293 294 #extension GL_EXT_sparse_texture2 : <behavior> 295 296 where <behavior> is as specified in section 3.3. 297 298 New preprocessor #defines are added to the OpenGL Shading Language: 299 300 #define GL_EXT_sparse_texture2 1 301 302 Modify Section 8.9, Texture Functions, p. 151 303 304 (insert after first paragraph, p. 152) 305 306 The texture lookup functions with an <lodClamp> parameter specify a 307 minimum clamp applied to the automatic level of detail computations. 308 Since automatic level of detail calculations are only supported by 309 fragment shaders, these lookup functions are also only available in 310 fragment shaders. No functions with the <lodClamp> parameter are provided 311 for rectangle textures, multisample textures, and texture buffers because 312 mipmaps are not allowed for these types of textures. 313 314 315 Modify Section 8.9.2, Texel Lookup Functions, p. 155 316 317 (This extension adds two new variants of texture lookup functions. The 318 "sparse" functions are like normal texture lookup functions, except that 319 they return a sparse texture residency status to the caller and return the 320 actual filtered texel value in an "out" parameter. The "Clamp" variants 321 are functions adding a new parameter specifying a minimum LOD to use for 322 texture lookup functions where level of detail is computed automatically. 323 324 For each set of texture functions, we provide one to three new variants 325 based on whether sparse and LOD clamping functionality are desired. These 326 new variants copy the existing functions, add suffixes to the function 327 names, and add one or more new parameters. 328 329 We create new variants only for the targets for which sparse storage is 330 supported -- no new functions are added for the following sampler types: 331 gsampler1D, sampler1DShadow, gsampler1DArray, sampler1DArrayShadow. 332 Additionally, to reduce the number of new functions added, we are not 333 including any new variants for textureProj*() built-ins. To use the new 334 features with projective texture lookups, shaders can divide through by q 335 and use non-projective variants. We also chose not to provide "Clamp" 336 variants of functions like textureLod() expecting an explicit 337 level-of-detail.) 338 339 (insert new lookup function table cells, at the end of the section, 340 p. 161) 341 342 Syntax: 343 344 int sparseTextureEXT(gsampler2D sampler, vec2 P, 345 out gvec4 texel [, float bias]); 346 int sparseTextureEXT(gsampler3D sampler, vec3 P, 347 out gvec4 texel [, float bias]); 348 int sparseTextureEXT(gsamplerCube sampler, vec3 P, 349 out gvec4 texel [, float bias]); 350 int sparseTextureEXT(sampler2DShadow sampler, vec3 P, 351 out float texel [, float bias]); 352 int sparseTextureEXT(samplerCubeShadow sampler, vec4 P, 353 out float texel [, float bias]); 354 int sparseTextureEXT(gsampler2DArray sampler, vec3 P, 355 out gvec4 texel [, float bias]); 356 int sparseTextureEXT(gsamplerCubeArray sampler, vec4 P, 357 out gvec4 texel [, float bias]); 358 int sparseTextureEXT(sampler2DArrayShadow sampler, vec4 P, 359 out float texel); 360 int sparseTextureEXT(gsampler2DRect sampler, vec2 P, 361 out gvec4 texel); 362 int sparseTextureEXT(sampler2DRectShadow sampler, vec3 P, 363 out float texel); 364 int sparseTextureEXT(samplerCubeArrayShadow sampler, vec4 P, 365 float compare, out float texel); 366 367 Description: 368 369 Do a filtered texture lookup as in texture(), but return texture access 370 residency information from the function and the filtered lookup result in 371 the out parameter <texel>. 372 373 -- 374 375 Syntax: 376 377 int sparseTextureClampEXT(gsampler2D sampler, vec2 P, 378 float lodClamp, out gvec4 texel 379 [, float bias]); 380 int sparseTextureClampEXT(gsampler3D sampler, vec3 P, 381 float lodClamp, out gvec4 texel 382 [, float bias]); 383 int sparseTextureClampEXT(gsamplerCube sampler, vec3 P, 384 float lodClamp, out gvec4 texel 385 [, float bias]); 386 int sparseTextureClampEXT(sampler2DShadow sampler, vec3 P, 387 float lodClamp, out float texel 388 [, float bias]); 389 int sparseTextureClampEXT(samplerCubeShadow sampler, vec4 P, 390 float lodClamp, out float texel 391 [, float bias]); 392 int sparseTextureClampEXT(gsampler2DArray sampler, vec3 P, 393 float lodClamp, out gvec4 texel 394 [, float bias]); 395 int sparseTextureClampEXT(gsamplerCubeArray sampler, vec4 P, 396 float lodClamp, out gvec4 texel 397 [, float bias]); 398 int sparseTextureClampEXT(sampler2DArrayShadow sampler, vec4 P, 399 float lodClamp, out float texel); 400 int sparseTextureClampEXT(samplerCubeArrayShadow sampler, vec4 P, 401 float compare, float lodClamp, 402 out float texel); 403 404 Description: 405 406 Do a filtered texture lookup as in texture(), but return texture access 407 residency information from the function and the filtered lookup result in 408 the out parameter <texel>. Additionally, clamp the automatically computed 409 level of detail to be greater than or equal to <lodClamp>. 410 411 -- 412 413 Syntax: 414 415 gvec4 textureClampEXT(gsampler1D sampler, float P, 416 float lodClamp [, float bias]); 417 gvec4 textureClampEXT(gsampler2D sampler, vec2 P, 418 float lodClamp [, float bias]); 419 gvec4 textureClampEXT(gsampler3D sampler, vec3 P, 420 float lodClamp [, float bias]); 421 gvec4 textureClampEXT(gsamplerCube sampler, vec3 P, 422 float lodClamp [, float bias]); 423 float textureClampEXT(sampler1DShadow sampler, vec3 P, 424 float lodClamp [, float bias]); 425 float textureClampEXT(sampler2DShadow sampler, vec3 P, 426 float lodClamp [, float bias]); 427 float textureClampEXT(samplerCubeShadow sampler, vec4 P, 428 float lodClamp [, float bias]); 429 gvec4 textureClampEXT(gsampler1DArray sampler, vec2 P, 430 float lodClamp [, float bias]); 431 gvec4 textureClampEXT(gsampler2DArray sampler, vec3 P, 432 float lodClamp [, float bias]); 433 gvec4 textureClampEXT(gsamplerCubeArray sampler, vec4 P, 434 float lodClamp [, float bias]); 435 float textureClampEXT(sampler1DArrayShadow sampler, vec3 P, 436 float lodClamp [, float bias]); 437 float textureClampEXT(sampler2DArrayShadow sampler, vec4 P, 438 float lodClamp); 439 float textureClampEXT(samplerCubeArrayShadow sampler, vec4 P, 440 float compare, float lodClamp); 441 442 Description: 443 444 Do a filtered texture lookup as in texture(), but clamp the automatically 445 computed level of detail to be greater than or equal to <lodClamp>. 446 447 -- 448 449 Syntax: 450 451 int sparseTextureLodEXT(gsampler2D sampler, vec2 P, float lod, 452 out gvec4 texel); 453 int sparseTextureLodEXT(gsampler3D sampler, vec3 P, float lod, 454 out gvec4 texel); 455 int sparseTextureLodEXT(gsamplerCube sampler, vec3 P, float lod, 456 out gvec4 texel); 457 int sparseTextureLodEXT(sampler2DShadow sampler, vec3 P, float lod, 458 out float texel); 459 int sparseTextureLodEXT(gsampler2DArray sampler, vec3 P, float lod, 460 out gvec4 texel); 461 int sparseTextureLodEXT(gsamplerCubeArray sampler, vec4 P, float lod, 462 out gvec4 texel); 463 464 Description: 465 466 Do a filtered texture lookup as in textureLod(), but return texture access 467 residency information from the function and the filtered lookup result in 468 the out parameter <texel>. 469 470 -- 471 472 Syntax: 473 474 int sparseTextureOffsetEXT(gsampler2D sampler, vec2 P, 475 ivec2 offset, out gvec4 texel 476 [, float bias]); 477 int sparseTextureOffsetEXT(gsampler3D sampler, vec3 P, 478 ivec3 offset, out gvec4 texel 479 [, float bias]); 480 int sparseTextureOffsetEXT(gsampler2DRect sampler, vec2 P, 481 ivec2 offset, out gvec4 texel); 482 int sparseTextureOffsetEXT(sampler2DRectShadow sampler, vec3 P, 483 ivec2 offset, out float texel); 484 int sparseTextureOffsetEXT(sampler2DShadow sampler, vec3 P, 485 ivec2 offset, out float texel 486 [, float bias]); 487 int sparseTextureOffsetEXT(gsampler2DArray sampler, vec3 P, 488 ivec2 offset, out gvec4 texel 489 [, float bias]); 490 int sparseTextureOffsetEXT(sampler2DArrayShadow sampler, vec4 P, 491 ivec2 offset, out float texel); 492 493 Description: 494 495 Do a filtered texture lookup as in textureOffset(), but return texture 496 access residency information from the function and the filtered lookup 497 result in the out parameter <texel>. 498 499 -- 500 501 Syntax: 502 503 int sparseTextureOffsetClampEXT(gsampler2D sampler, vec2 P, 504 ivec2 offset, float lodClamp, 505 out gvec4 texel [, float bias]); 506 int sparseTextureOffsetClampEXT(gsampler3D sampler, vec3 P, 507 ivec3 offset, float lodClamp, 508 out gvec4 texel [, float bias]); 509 int sparseTextureOffsetClampEXT(sampler2DShadow sampler, vec3 P, 510 ivec2 offset, float lodClamp, 511 out float texel [, float bias]); 512 int sparseTextureOffsetClampEXT(gsampler2DArray sampler, vec3 P, 513 ivec2 offset, float lodClamp, 514 out gvec4 texel [, float bias]); 515 int sparseTextureOffsetClampEXT(sampler2DArrayShadow sampler, vec4 P, 516 ivec2 offset, float lodClamp, 517 out float texel); 518 519 Description: 520 521 Do a filtered texture lookup as in textureOffset(), but return texture 522 access residency information from the function and the filtered lookup 523 result in the out parameter <texel>. Additionally, clamp the 524 automatically computed level of detail to be greater than or equal to 525 <lodClamp>. 526 527 -- 528 529 Syntax: 530 531 gvec4 textureOffsetClampEXT(gsampler1D sampler, float P, 532 int offset, float lodClamp [, float bias]); 533 gvec4 textureOffsetClampEXT(gsampler2D sampler, vec2 P, 534 ivec2 offset, float lodClamp [, float bias]); 535 gvec4 textureOffsetClampEXT(gsampler3D sampler, vec3 P, 536 ivec3 offset, float lodClamp [, float bias]); 537 float textureOffsetClampEXT(sampler1DShadow sampler, vec3 P, 538 int offset, float lodClamp [, float bias]); 539 float textureOffsetClampEXT(sampler2DShadow sampler, vec3 P, 540 ivec2 offset, float lodClamp [, float bias]); 541 gvec4 textureOffsetClampEXT(gsampler1DArray sampler, vec2 P, 542 int offset, float lodClamp [, float bias]); 543 gvec4 textureOffsetClampEXT(gsampler2DArray sampler, vec3 P, 544 ivec2 offset, float lodClamp [, float bias]); 545 float textureOffsetClampEXT(sampler1DArrayShadow sampler, vec3 P, 546 int offset, float lodClamp [, float bias]); 547 float textureOffsetClampEXT(sampler2DArrayShadow sampler, vec4 P, 548 ivec2 offset, float lodClamp); 549 550 Description: 551 552 Do a filtered texture lookup as in textureOffset(), but clamp the 553 automatically computed level of detail to be greater than or equal to 554 <lodClamp>. 555 556 -- 557 558 Syntax: 559 560 int sparseTexelFetchEXT(gsampler2D sampler, ivec2 P, int lod, 561 out gvec4 texel); 562 int sparseTexelFetchEXT(gsampler3D sampler, ivec3 P, int lod, 563 out gvec4 texel); 564 int sparseTexelFetchEXT(gsampler2DRect sampler, ivec2 P, 565 out gvec4 texel); 566 int sparseTexelFetchEXT(gsampler2DArray sampler, ivec3 P, int lod, 567 out gvec4 texel); 568 int sparseTexelFetchEXT(gsampler2DMS sampler, ivec2 P, int sample, 569 out gvec4 texel); 570 int sparseTexelFetchEXT(gsampler2DMSArray sampler, ivec3 P, int sample, 571 out gvec4 texel); 572 573 Description: 574 575 Do a single texel fetch as in texelFetch(), but return texture access 576 residency information from the function and the fetched texel in the out 577 parameter <texel>. 578 579 -- 580 581 Syntax: 582 583 int sparseTexelFetchOffsetEXT(gsampler2D sampler, ivec2 P, int lod, 584 ivec2 offset, out gvec4 texel); 585 int sparseTexelFetchOffsetEXT(gsampler3D sampler, ivec3 P, int lod, 586 ivec3 offset, out gvec4 texel); 587 int sparseTexelFetchOffsetEXT(gsampler2DRect sampler, ivec2 P, 588 ivec2 offset, out gvec4 texel); 589 int sparseTexelFetchOffsetEXT(gsampler2DArray sampler, ivec3 P, int lod, 590 ivec2 offset, out gvec4 texel); 591 592 Description: 593 594 Do a single texel fetch as in texelFetchOffset(), but return texture 595 access residency information from the function and the fetched texel in 596 the out parameter <texel>. 597 598 -- 599 600 Syntax: 601 602 int sparseTextureLodOffsetEXT(gsampler2D sampler, vec2 P, 603 float lod, ivec2 offset, 604 out gvec4 texel); 605 int sparseTextureLodOffsetEXT(gsampler3D sampler, vec3 P, 606 float lod, ivec3 offset, 607 out gvec4 texel); 608 int sparseTextureLodOffsetEXT(sampler2DShadow sampler, vec3 P, 609 float lod, ivec2 offset, 610 out float texel); 611 int sparseTextureLodOffsetEXT(gsampler2DArray sampler, vec3 P, 612 float lod, ivec2 offset, 613 out gvec4 texel); 614 615 Description: 616 617 Do a filtered texture lookup as in textureLodOffset(), but return texture 618 access residency information from the function and the filtered lookup 619 result in the out parameter <texel>. 620 621 -- 622 623 Syntax: 624 625 int sparseTextureGradEXT(gsampler2D sampler, vec2 P, 626 vec2 dPdx, vec2 dPdy, 627 out gvec4 texel); 628 int sparseTextureGradEXT(gsampler3D sampler, vec3 P, 629 vec3 dPdx, vec3 dPdy, 630 out gvec4 texel); 631 int sparseTextureGradEXT(gsamplerCube sampler, vec3 P, 632 vec3 dPdx, vec3 dPdy, 633 out gvec4 texel); 634 int sparseTextureGradEXT(gsampler2DRect sampler, vec2 P, 635 vec2 dPdx, vec2 dPdy, 636 out gvec4 texel); 637 int sparseTextureGradEXT(sampler2DRectShadow sampler, vec3 P, 638 vec2 dPdx, vec2 dPdy, 639 out float texel); 640 int sparseTextureGradEXT(sampler2DShadow sampler, vec3 P, 641 vec2 dPdx, vec2 dPdy, 642 out float texel); 643 int sparseTextureGradEXT(samplerCubeShadow sampler, vec4 P, 644 vec3 dPdx, vec3 dPdy, 645 out float texel); 646 int sparseTextureGradEXT(gsampler2DArray sampler, vec3 P, 647 vec2 dPdx, vec2 dPdy, 648 out gvec4 texel); 649 int sparseTextureGradEXT(sampler2DArrayShadow sampler, vec4 P, 650 vec2 dPdx, vec2 dPdy, 651 out float texel); 652 int sparseTextureGradEXT(gsamplerCubeArray sampler, vec4 P, 653 vec3 dPdx, vec3 dPdy, 654 out gvec4 texel); 655 656 Description: 657 658 Do a filtered texture lookup as in textureGrad(), but return texture 659 access residency information from the function and the filtered lookup 660 result in the out parameter <texel>. 661 662 -- 663 664 Syntax: 665 666 int sparseTextureGradClampEXT(gsampler2D sampler, vec2 P, 667 vec2 dPdx, vec2 dPdy, float lodClamp, 668 out gvec4 texel); 669 int sparseTextureGradClampEXT(gsampler3D sampler, vec3 P, 670 vec3 dPdx, vec3 dPdy, float lodClamp, 671 out gvec4 texel); 672 int sparseTextureGradClampEXT(gsamplerCube sampler, vec3 P, 673 vec3 dPdx, vec3 dPdy, float lodClamp, 674 out gvec4 texel); 675 int sparseTextureGradClampEXT(sampler2DShadow sampler, vec3 P, 676 vec2 dPdx, vec2 dPdy, float lodClamp, 677 out float texel); 678 int sparseTextureGradClampEXT(samplerCubeShadow sampler, vec4 P, 679 vec3 dPdx, vec3 dPdy, float lodClamp, 680 out float texel); 681 int sparseTextureGradClampEXT(gsampler2DArray sampler, vec3 P, 682 vec2 dPdx, vec2 dPdy, float lodClamp, 683 out gvec4 texel); 684 int sparseTextureGradClampEXT(sampler2DArrayShadow sampler, vec4 P, 685 vec2 dPdx, vec2 dPdy, float lodClamp, 686 out float texel); 687 int sparseTextureGradClampEXT(gsamplerCubeArray sampler, vec4 P, 688 vec3 dPdx, vec3 dPdy, float lodClamp, 689 out gvec4 texel); 690 691 Description: 692 693 Do a filtered texture lookup as in textureGrad(), but return texture 694 access residency information from the function and the filtered lookup 695 result in the out parameter <texel>. Additionally, clamp the 696 automatically computed level of detail to be greater than or equal to 697 <lodClamp>. 698 699 -- 700 701 Syntax: 702 703 gvec4 textureGradClampEXT(gsampler1D sampler, float P, 704 float dPdx, float dPdy, float lodClamp); 705 gvec4 textureGradClampEXT(gsampler2D sampler, vec2 P, 706 vec2 dPdx, vec2 dPdy, float lodClamp); 707 gvec4 textureGradClampEXT(gsampler3D sampler, vec3 P, 708 vec3 dPdx, vec3 dPdy, float lodClamp); 709 gvec4 textureGradClampEXT(gsamplerCube sampler, vec3 P, 710 vec3 dPdx, vec3 dPdy, float lodClamp); 711 float textureGradClampEXT(sampler1DShadow sampler, vec3 P, 712 float dPdx, float dPdy, float lodClamp); 713 float textureGradClampEXT(sampler2DShadow sampler, vec3 P, 714 vec2 dPdx, vec2 dPdy, float lodClamp); 715 float textureGradClampEXT(samplerCubeShadow sampler, vec4 P, 716 vec3 dPdx, vec3 dPdy, float lodClamp); 717 gvec4 textureGradClampEXT(gsampler1DArray sampler, vec2 P, 718 float dPdx, float dPdy, float lodClamp); 719 gvec4 textureGradClampEXT(gsampler2DArray sampler, vec3 P, 720 vec2 dPdx, vec2 dPdy, float lodClamp); 721 float textureGradClampEXT(sampler1DArrayShadow sampler, vec3 P, 722 float dPdx, float dPdy, float lodClamp); 723 float textureGradClampEXT(sampler2DArrayShadow sampler, vec4 P, 724 vec2 dPdx, vec2 dPdy, float lodClamp); 725 gvec4 textureGradClampEXT(gsamplerCubeArray sampler, vec4 P, 726 vec3 dPdx, vec3 dPdy, float lodClamp); 727 728 Description: 729 730 Do a filtered texture lookup as in textureGrad(), but clamp the 731 automatically computed level of detail to be greater than or equal to 732 <lodClamp>. 733 734 -- 735 736 Syntax: 737 738 int sparseTextureGradOffsetEXT(gsampler2D sampler, vec2 P, 739 vec2 dPdx, vec2 dPdy, ivec2 offset, 740 out gvec4 texel); 741 int sparseTextureGradOffsetEXT(gsampler3D sampler, vec3 P, 742 vec3 dPdx, vec3 dPdy, ivec3 offset, 743 out gvec4 texel); 744 int sparseTextureGradOffsetEXT(gsampler2DRect sampler, vec2 P, 745 vec2 dPdx, vec2 dPdy, ivec2 offset, 746 out gvec4 texel); 747 int sparseTextureGradOffsetEXT(sampler2DRectShadow sampler, vec3 P, 748 vec2 dPdx, vec2 dPdy, ivec2 offset, 749 out float texel); 750 int sparseTextureGradOffsetEXT(sampler2DShadow sampler, vec3 P, 751 vec2 dPdx, vec2 dPdy, ivec2 offset, 752 out float texel); 753 int sparseTextureGradOffsetEXT(gsampler2DArray sampler, vec3 P, 754 vec2 dPdx, vec2 dPdy, ivec2 offset, 755 out gvec4 texel); 756 int sparseTextureGradOffsetEXT(sampler2DArrayShadow sampler, vec4 P, 757 vec2 dPdx, vec2 dPdy, ivec2 offset, 758 out float texel); 759 760 Description: 761 762 Do a filtered texture lookup as in textureGradOffset(), but return texture 763 access residency information from the function and the filtered lookup 764 result in the out parameter <texel>. 765 766 -- 767 768 Syntax: 769 770 int sparseTextureGradOffsetClampEXT(gsampler2D sampler, vec2 P, 771 vec2 dPdx, vec2 dPdy, ivec2 offset, 772 float lodClamp, out gvec4 texel); 773 int sparseTextureGradOffsetClampEXT(gsampler3D sampler, vec3 P, 774 vec3 dPdx, vec3 dPdy, ivec3 offset, 775 float lodClamp, out gvec4 texel); 776 int sparseTextureGradOffsetClampEXT(sampler2DShadow sampler, vec3 P, 777 vec2 dPdx, vec2 dPdy, ivec2 offset, 778 float lodClamp, out float texel); 779 int sparseTextureGradOffsetClampEXT(gsampler2DArray sampler, vec3 P, 780 vec2 dPdx, vec2 dPdy, ivec2 offset, 781 float lodClamp, out gvec4 texel); 782 int sparseTextureGradOffsetClampEXT(sampler2DArrayShadow sampler, vec4 P, 783 vec2 dPdx, vec2 dPdy, ivec2 offset, 784 float lodClamp, out float texel); 785 786 Description: 787 788 Do a filtered texture lookup as in textureGradOffset(), but return texture 789 access residency information from the function and the filtered lookup 790 result in the out parameter <texel>. Additionally, clamp the 791 automatically computed level of detail to be greater than or equal to 792 <lodClamp>. 793 794 -- 795 796 Syntax: 797 798 gvec4 textureGradOffsetClampEXT(gsampler1D sampler, float P, 799 float dPdx, float dPdy, int offset, 800 float lodClamp); 801 gvec4 textureGradOffsetClampEXT(gsampler2D sampler, vec2 P, 802 vec2 dPdx, vec2 dPdy, ivec2 offset, 803 float lodClamp); 804 gvec4 textureGradOffsetClampEXT(gsampler3D sampler, vec3 P, 805 vec3 dPdx, vec3 dPdy, ivec3 offset, 806 float lodClamp); 807 float textureGradOffsetClampEXT(sampler1DShadow sampler, vec3 P, 808 float dPdx, float dPdy, int offset, 809 float lodClamp); 810 float textureGradOffsetClampEXT(sampler2DShadow sampler, vec3 P, 811 vec2 dPdx, vec2 dPdy, ivec2 offset, 812 float lodClamp); 813 gvec4 textureGradOffsetClampEXT(gsampler1DArray sampler, vec2 P, 814 float dPdx, float dPdy, int offset, 815 float lodClamp); 816 gvec4 textureGradOffsetClampEXT(gsampler2DArray sampler, vec3 P, 817 vec2 dPdx, vec2 dPdy, ivec2 offset, 818 float lodClamp); 819 float textureGradOffsetClampEXT(sampler1DArrayShadow sampler, vec3 P, 820 float dPdx, float dPdy, int offset, 821 float lodClamp); 822 float textureGradOffsetClampEXT(sampler2DArrayShadow sampler, vec4 P, 823 vec2 dPdx, vec2 dPdy, ivec2 offset, 824 float lodClamp); 825 826 Description: 827 828 Do a filtered texture lookup as in textureGrad(), but clamp the 829 automatically computed level of detail to be greater than or equal to 830 <lodClamp>. 831 832 833 Modify Section 8.9.3, Texel Gather Functions, p. 161 834 835 (insert new lookup function table cells, at the end of the section, 836 p. 163) 837 838 Syntax: 839 840 int sparseTextureGatherEXT(gsampler2D sampler, vec2 P, 841 out gvec4 texel [, int comp]); 842 int sparseTextureGatherEXT(gsampler2DArray sampler, vec3 P, 843 out gvec4 texel [, int comp]); 844 int sparseTextureGatherEXT(gsamplerCube sampler, vec3 P, 845 out gvec4 texel [, int comp]); 846 int sparseTextureGatherEXT(gsamplerCubeArray sampler, vec4 P, 847 out gvec4 texel [, int comp]); 848 int sparseTextureGatherEXT(gsampler2DRect sampler, vec2 P, 849 out gvec4 texel [, int comp]); 850 int sparseTextureGatherEXT(gsampler2DShadow sampler, vec2 P, 851 float refZ, out vec4 texel); 852 int sparseTextureGatherEXT(gsampler2DArrayShadow sampler, vec3 P, 853 float refZ, out vec4 texel); 854 int sparseTextureGatherEXT(gsamplerCubeShadow sampler, vec3 P, 855 float refZ, out vec4 texel); 856 int sparseTextureGatherEXT(gsamplerCubeArrayShadow sampler, vec4 P, 857 float refZ, out vec4 texel); 858 int sparseTextureGatherEXT(gsampler2DRectShadow sampler, vec2 P, 859 float refZ, out vec4 texel); 860 861 Description: 862 863 Do a texture gather operation as in textureGather(), but return texture 864 access residency information from the function and the filtered lookup 865 result in the out parameter <texel>. 866 867 -- 868 869 Syntax: 870 871 int sparseTextureGatherOffsetEXT(gsampler2D sampler, vec2 P, 872 ivec2 offset, out gvec4 texel 873 [, int comp]); 874 int sparseTextureGatherOffsetEXT(gsampler2DArray sampler, vec3 P, 875 ivec2 offset, out gvec4 texel 876 [, int comp]); 877 int sparseTextureGatherOffsetEXT(gsampler2DRect sampler, vec2 P, 878 ivec2 offset, out gvec4 texel 879 [, int comp]); 880 int sparseTextureGatherOffsetEXT(gsampler2DShadow sampler, vec2 P, 881 float refZ, ivec2 offset, 882 out vec4 texel); 883 int sparseTextureGatherOffsetEXT(gsampler2DArrayShadow sampler, vec3 P, 884 float refZ, ivec2 offset, 885 out vec4 texel); 886 int sparseTextureGatherOffsetEXT(gsampler2DRectShadow sampler, vec2 P, 887 float refZ, ivec2 offset, 888 out vec4 texel); 889 890 Description: 891 892 Do a texture gather operation as in textureGatherOffset(), but return 893 texture access residency information from the function and the filtered 894 lookup result in the out parameter <texel>. 895 896 -- 897 898 Syntax: 899 900 int sparseTextureGatherOffsetsEXT(gsampler2D sampler, vec2 P, 901 ivec2 offsets[4], out gvec4 texel 902 [, int comp]); 903 int sparseTextureGatherOffsetsEXT(gsampler2DArray sampler, vec3 P, 904 ivec2 offsets[4], out gvec4 texel 905 [, int comp]); 906 int sparseTextureGatherOffsetsEXT(gsampler2DRect sampler, vec2 P, 907 ivec2 offsets[4], out gvec4 texel 908 [, int comp]); 909 int sparseTextureGatherOffsetsEXT(gsampler2DShadow sampler, vec2 P, 910 float refZ, ivec2 offsets[4], 911 out vec4 texel); 912 int sparseTextureGatherOffsetsEXT(gsampler2DArrayShadow sampler, vec3 P, 913 float refZ, ivec2 offsets[4], 914 out vec4 texel); 915 int sparseTextureGatherOffsetsEXT(gsampler2DRectShadow sampler, vec2 P, 916 float refZ, ivec2 offsets[4], 917 out vec4 texel); 918 919 Description: 920 921 Do a texture gather operation as in textureGatherOffset(), but return 922 texture access residency information from the function and the filtered 923 lookup result in the out parameter <texel>. 924 925 926 Add to the end of Section 8.12, Image Functions, p. 167 927 928 (insert new lookup function table cells, at the end of the section, 929 p. 170) 930 931 Syntax: 932 933 int sparseImageLoadEXT(gimage2D image, ivec2 P, 934 out gvec4 texel); 935 int sparseImageLoadEXT(gimage3D image, ivec3 P, 936 out gvec4 texel); 937 int sparseImageLoadEXT(gimage2DRect image, ivec2 P, 938 out gvec4 texel); 939 int sparseImageLoadEXT(gimageCube image, ivec3 P, 940 out gvec4 texel); 941 int sparseImageLoadEXT(gimage2DArray image, ivec3 P, 942 out gvec4 texel); 943 int sparseImageLoadEXT(gimageCubeArray image, ivec3 P, 944 out gvec4 texel); 945 int sparseImageLoadEXT(gimage2DMS image, ivec2 P, int sample, 946 out gvec4 texel); 947 int sparseImageLoadEXT(gimage2DMSArray image, ivec3 P, int sample, 948 out gvec4 texel); 949 950 Description: 951 952 Loads a texel from the image <image> as in imageLoad(), but return texture 953 access residency information from the function and the filtered lookup 954 result in the out parameter <texel>. 955 956 957 Add to the end of Section 8.17, Shader Memory Control Functions, p. 178 958 959 Many of the built-in texture lookup functions in sections 8.9.2 and 8.9.3 960 and the sparseImageLoad() function in section 8.12 can be used to return 961 sparse texture residency information in addition to texel values. In 962 these functions, the sparse texture residency information is returned by 963 the function as an integer and the texel values are returned in the output 964 parameter <texel>. The residency information can be interpreted by a 965 built-in function to determine if the lookup accessed any uncommitted 966 texels. 967 968 Syntax: 969 970 bool sparseTexelsResidentEXT(int code); 971 972 Description: 973 974 Returns false if any of the texels accessed by the sparse texture lookup 975 generating <code> were in uncommitted texture memory, and true 976 otherwise. 977 978 979Additions to the AGL/GLX/WGL Specifications 980 981 None. 982 983Errors 984 985 None. 986 987New State 988 989 None. 990 991New Implementation Dependent State 992 993 None. 994 995Dependencies on OpenGL ES 3.1 996 997 Replace references to ARB_sparse_texture with references to 998 EXT_sparse_texture, in particular functions and enums introduced by 999 EXT_sparse_texture will carry EXT suffixes. 1000 1001 If implemented on OpenGL ES 3.1, remove all references to 1D and 1002 rectangle textures and their respective texture targets (TEXTURE_1D 1003 and TEXTURE_RECTANGLE). Also ignore the corresponding sampler 1004 built-ins thereof: 'gsampler1D', 'gsampler2DRect' and 1005 'gsampler2DRectShadow'. Do not introduce overloads of 1006 sparseTexture*EXT, texture*ClampEXT or sparseTexelFetchEXT for these 1007 sampler types. 1008 1009 Do not introduce sparseImageLoadEXT overloads of gimageRect, 1010 gimage2D, gimage2DArray, gimage2DMS and gimage2DArrayMS. 1011 1012Dependencies on EXT_texture_norm16 1013 1014 If implemented on OpenGL ES 3.1 and EXT_texture_norm16 is not 1015 supported ignore all references to R16, RG16, RGBA16, R16_SNORM, 1016 RG16_SNORM and RGBA16_SNORM. If EXT_texture_norm16 is supported, 1017 these enums are suffixed by _EXT. 1018 1019Dependencies on EXT_texture_cube_map_array and OES_texture_cube_map_array 1020 1021 If implemented on OpenGL ES 3.1 and neither EXT_texture_cube_map_array 1022 nor OES_texture_cube_map_array is supported, ignore all references to 1023 texture sampler types 'gsamplerCubeArray' and 'gsamplerCubeArrayShadow'. 1024 Do not introduce overloads of sparseTexture*EXT, texture*ClampEXT or 1025 sparseTexelFetchEXT for these sampler types. Remove references to 1026 TEXTURE_CUBE_MAP_ARRAY. 1027 1028Dependencies on OES_texture_storage_multisample_2D_array 1029 1030 If implemented on OpenGL ES 3.1 and OES_texture_storage_- 1031 multisample_2D_array is not supported, ignore all references to 1032 texture sampler types 'gsampler2DMS' and 'gsampler2DMSArray'. Do not 1033 introduce overloads of sparseTexture*EXT, texture*ClampEXT or 1034 sparseTexelFetchEXT for these sampler types. Remove references to 1035 TEXTURE_2D_MULTISAMPLE_ARRAY. 1036 1037Dependencies on EXT_gpu_shader5 and OES_gpu_shader5 1038 1039 If implemented on OpenGL GLSL ES 3.1 and neither EXT_gpu_shader5 nor 1040 OES_gpu_shader5 is supported, do not introduce 1041 sparseTextureGatherOffsetsEXT. 1042 1043Dependencies on EXT_depth_bounds_test 1044 1045 If EXT_depth_bounds_test is not supported, references to the depth bounds 1046 test should be removed. 1047 1048Dependencies on NV_gpu_program4 and NV_gpu_program5 1049 1050 Modify Section 2.X.2, Program Grammar 1051 1052 <opModifier> ::= "SPARSE" 1053 | "LODCLAMP" 1054 1055 <ccMaskRule> ::= "RESIDENT" 1056 | "NONRESIDENT" 1057 1058 Modify Section 2.X.3.7, Program Condition Code Registers 1059 1060 (modify the first paragraph) 1061 1062 There are two general-purpose four-component condition code registers (CC0 1063 and CC1), where each component of this register is a collection of 1064 single-bit flags, including a sign flag (SF), a zero flag (ZF), an 1065 overflow flag (OF), and a carry flag (CF). The values of these registers 1066 are undefined at the beginning of program execution. Additionally, there 1067 is a special single-component sparse memory condition code register that 1068 holds the status of the most recently executed texture or image load 1069 instruction using the "SPARSE" opcode modifier. This condition code 1070 includes a resident flag (RESF) indicating whether all memory accessed by 1071 the instruction was populated. 1072 1073 Modify Section 2.X.4.1, Program Instruction Modifiers 1074 1075 (Update the discussion of instruction precision modifiers. If 1076 GL_NV_gpu_program_fp64 is not found in the extension string, the "F64" 1077 instruction modifier described below is not supported.) 1078 1079 (add to Table X.14 of the NV_gpu_program4 specification.) 1080 1081 Modifier Description 1082 -------- ------------------------------------------------------ 1083 SPARSE Update the sparse memory condition code with status on 1084 whether the memory accessed by a texture or image load 1085 instruction was fully populated. 1086 1087 LODCLAMP Clamp the LOD used by texture lookups to a specified 1088 value 1089 1090 For texture fetch, surface load, and surface atomic instructions, the 1091 "SPARSE" modifier specifies that the sparse memory condition code 1092 described in Section 2.X.3.7 should be updated to reflect whether the 1093 memory accessed by the instruction was fully populated. 1094 1095 For texture fetch instructions with implicit LOD calcuations (TEX, TXB, 1096 TXD), the "LODCLAMP" modifier specifies that the instruction includes an 1097 extra floating-point component indicating a minimum level of detail to be 1098 used for the texture lookup. If the implicitly computed level of detail 1099 is less than the level of detail provided in the instruction data, that 1100 level should be used instead. 1101 1102 Modify Section 2.X.4.3, Program Destination Variable Update 1103 1104 (add to Table X.16, Condition Code Tests) 1105 1106 mask rule test name condition 1107 --------------- ---------------------- ----------------- 1108 RESIDENT sparse resident RESF 1109 NONRESIDENT sparse nonresident !RESF 1110 1111 (also modify the table description) 1112 1113 Table X.16, Condition Code Tests. The allowed rules are specified in 1114 the "mask rule" column. For "RESIDENT" or "NONRESIDENT", all four 1115 components of the test result are loaded from the RESF flag of the 1116 sparse condition code. Otherwise, If "0" or "1" is appended ... 1117 1118 (modify the paragraph about condition code updates) 1119 1120 A program instruction can also optionally update one of the two general 1121 condition code registers ... 1122 1123 (add a new paragraph about updating CCSPARSE) 1124 1125 Additionally, a program instruction accessing memory can optionally update 1126 the sparse memory condition code register if the "SPARSE" instruction 1127 modifier is specified. If the memory accessed by the instruction was 1128 fully populated, the resident flag (RESF) is set; otherwise, RESF is 1129 cleared. 1130 1131 Modify Section 2.X.4.4, Program Texture Access 1132 1133 (modify the prototype of the TextureSample utility function, adding 1134 <coord2> and removing <lod>) 1135 1136 result_t_vec 1137 TextureSample(float_vec coord, float_vec coord2, 1138 float_vec ddx, float_vec ddy, int_vec offset); 1139 1140 (modify the description of <coord> to add <coord2>) 1141 1142 <coord> and <coord2> are two four-component floating-point vectors from 1143 which the (s,t,r) texture coordinates used for the texture access, the 1144 layer used for array textures, and the reference value used for depth 1145 comparisons (section 3.8.14) are extracted according to Table X.17. ... 1146 1147 (replace the paragraph discussing <lod>) 1148 1149 <ddx> and <ddy> specify partial derivatives (ds/dx, dt/dx, dr/dx, ds/dy, 1150 dt/dy, and dr/dy) for the texture coordinates, and may be used for level 1151 of detail calculations and to derive footprint shapes for anisotropic 1152 texture filtering. 1153 1154 The level of detail used for the texture lookup is a function of the 1155 texture instruction type, texture target, LODCLAMP qualifier, and the 1156 inputs <ddx> and <ddy>. For TEX, TXB, TXD, and TXP instructions in a base 1157 level of detail is computed based on the partial derivatives <ddx> and 1158 <ddy>. For the TXB and TXL instruction, an additional level of detail 1159 value is taken from the component in <coord> or <coord2> identified by the 1160 first entry in the "lod" column of Table X.17. For TXB, this value is 1161 added to the computed base level of detail; for TXL, it specifies the base 1162 level of detail. After that, per-texture and per-texture unit LOD biases 1163 are added to the level of detail. Finally, if the LODCLAMP opcode 1164 modifier is specified, an LOD clamp value is extracted from <coord> or 1165 <coord2> according to the second entry in the "lod" column of Table X.17. 1166 The computed level of detail is clamped to be greater than or equal to 1167 this LOD clamp value. 1168 1169 coordinates used 1170 texTarget Texture Type s t r lay shd lod 1171 ---------------- --------------------- ----- --- --- ----- 1172 1D TEXTURE_1D x - - - - w,x2 1173 2D TEXTURE_2D x y - - - w,x2 1174 3D TEXTURE_3D x y z - - w,x2 1175 CUBE TEXTURE_CUBE_MAP x y z - - w,x2 1176 RECT TEXTURE_RECTANGLE_ARB x y - - - -,- 1177 ARRAY1D TEXTURE_1D_ARRAY_EXT x - - y - w,x2 1178 ARRAY2D TEXTURE_2D_ARRAY_EXT x y - z - w,x2 1179 ARRAYCUBE TEXTURE_CUBE_MAP_ARRAY x y z w - x2,y2 1180 SHADOW1D TEXTURE_1D x - - - z w,x2 1181 SHADOW2D TEXTURE_2D x y - - z w,x2 1182 SHADOWRECT TEXTURE_RECTANGLE_ARB x y - - z -,- 1183 SHADOWCUBE TEXTURE_CUBE_MAP x y z - w x2,y2 1184 SHADOWARRAY1D TEXTURE_1D_ARRAY_EXT x - - y z w,x2 1185 SHADOWARRAY2D TEXTURE_2D_ARRAY_EXT x y - z w -,x2 1186 SHADOWARRAYCUBE TEXTURE_CUBE_MAP_ARRAY x y z w x2 -,y2 1187 BUFFER TEXTURE_BUFFER_EXT <not supported> 1188 RENDERBUFFER TEXTURE_RENDERBUFFER <not supported> 1189 2DMS TEXTURE_2D_MULTISAMPLE <not supported> 1190 ARRAY2DMS TEXTURE_2D_MULTISAMPLE_ <not supported> 1191 ARRAY 1192 1193 Table X.17: Texture types accessed for each of the <texTarget>, and 1194 coordinate mappings. Components "x", "y", "z", and "w" are taken from 1195 the first coordinate vector <coord>; "x2" and "y2" are taken from the 1196 second vector <coord2>. The "SHADOW" and "ARRAY" targets are special 1197 pseudo-targets described below. The "coordinates used" column indicate 1198 the input values used for each coordinate of the texture lookup, the 1199 layer selector for array textures, the reference value for texture 1200 comparisons, and up to two components of level-of-detail information. 1201 Buffer textures are not supported by normal texture lookup functions, 1202 but are supported by TXF and TXQ, described below. Renderbuffer and 1203 multisample textures are not supported by normal texture lookup 1204 functions, but are supported by TXFMS. The TXB and TXL instructions are 1205 not supported for the targets SHADOWARRAY2D and SHADOWARRAYCUBE, so the 1206 first column of "lod" is ignored. 1207 1208 Modify Section 2.X.8.Z, TXD: Texture Sample with Partials 1209 1210 ... The partial derivatives of the texture coordinates with respect to X 1211 and Y are specified by the second and third floating-point source vectors. 1212 If the LODCLAMP instruction modifier is specified, floating-point 1213 level-of-detail clamp value is specified in the <w> component of the third 1214 floating-point source vector. The level of detail is computed 1215 automatically using the provided partial derivatives. 1216 1217 1218Issues 1219 1220 (1) How does this extension compare to the ARB_sparse_texture extension? 1221 1222 RESOLVED: We extend the mechanisms provided by ARB_sparse_texture in 1223 several ways: 1224 1225 - We add built-in texture and image lookup functions returning 1226 information on memory accesses performed by the built-in functions; 1227 in particular, whether any uncommitted memory was referenced. 1228 1229 - We add built-in texture and image lookup functions clamping the 1230 final level of detail computed based on texture coordinates, 1231 derivatives, and LOD bias to a minimum LOD specified in the shader. 1232 1233 - We specify that all loads and atomics from uncommitted sparse memory 1234 behave as though zero were fetched. 1235 1236 - We remove the requirement that the base size of a sparse texture 1237 must be a multiple of the page size. Implementations are expected 1238 to pad mipmap allocations internally to page size boundaries as 1239 required, until the tail is reached. 1240 1241 - We modify the definition of the sparse texture mipmap tail, so that 1242 all levels greater than or equal to the page size in all dimensions 1243 are guaranteed to be sparsely populated (i.e., not in the tail). 1244 The previous spec allowed implementations to put levels in the tail 1245 if they were not integer multiples of the page size. 1246 1247 - We add support for an implementation-independent virtual page size 1248 for some formats, instead of depending on querying 1249 implementation-dependent page size. For such formats, the default 1250 virtual page size index (0) is guaranteed to specify the standard 1251 page size. 1252 1253 - We require that all implementations of this extension return TRUE 1254 for the value of the implementation-dependent constant 1255 SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB, which removes some 1256 potential errors when allocating sparse array or cube map textures. 1257 1258 - We add support for sparse multisample and multisample array 1259 textures, but require no implementation-independent virtual page 1260 size. 1261 1262 (2) How does this extension compare to the AMD_sparse_texture extension? 1263 1264 RESOLVED: This extension, like the AMD extension, provide built-in 1265 texture lookup functions returning information on whether uncommitted 1266 memory was accessed. There are several differences between these 1267 functions: 1268 1269 - This extension uses an "EXT" suffix on built-in function names. 1270 1271 - This extension provides built-in functions supporting the sparse 1272 return information together with the new LOD clamp feature. 1273 1274 - This extension supports sparse accesses for shadow map sampler types 1275 (e.g., sampler2DShadow). 1276 1277 - This extension supports sparse variants of imageLoad(); the AMD 1278 extension does not. 1279 1280 - This extension doesn't attempt to support sparse variants of 1281 projective texture lookups to reduce the number of texture functions 1282 added. 1283 1284 - This extension doesn't attempt to support sparse variants of 1285 one-dimensional and one-dimensional array texture lookups. Sparse 1286 textures with these targets are explicitly not supported in the ARB 1287 extension. 1288 1289 - This extension returns the texel data in an "out" parameter and 1290 returns a value consistent with sampling zero in any uncommitted 1291 texels. The AMD extension returns the texel data in an "inout" 1292 parameter and guarantees not to write to the return value if any 1293 uncommitted texel is accessed. 1294 1295 - The function sparseTexelResident() from the AMD extension is renamed 1296 to sparseTexelsResidentEXT(). We use "texels" instead of "texel" in 1297 the function name because a texture lookup may access multiple 1298 texels, and the code will reflect non-resident status if any of the 1299 texels is non-resident. 1300 1301 The built-in functions taking an explicit LOD clamp, returning zero on 1302 reads from uncommitted memory, and the standard virtual page size are 1303 not provided by the AMD extension, either. 1304 1305 Neither this extension nor ARB_sparse_texture provide the minimum LOD 1306 warning feature provided by the AMD extension or the related built-in 1307 functions. 1308 1309 (3) How should the "sparse" built-in functions return both access status 1310 and a texel value? 1311 1312 RESOLVED: We mostly followed the precedent of the AMD extension, where 1313 the sparse access status is returned as an integer and the texel values 1314 are returning in a vec4-typed "out" parameter. (This differs slightly 1315 from the AMD extension in that it uses an "inout" parameter.) 1316 1317 We considered included returning the texel values from the function, 1318 just like normal texture lookups, and returning status in a separate 1319 "out" parameter (reversing the order). We also considered returning a 1320 structure type containing both the status and the texel. We ultimately 1321 chose to return the status code to more closely match the AMD extension 1322 and because we expect that shaders caring to use the "sparse" functions 1323 will want to look at the status code first. 1324 1325 (4) What data type should we use for the access status information 1326 returned by the "sparse" built-in functions? 1327 1328 RESOLVED: We chose to follow the precedent of the AMD extension, where 1329 an integer code is returned. Requiring a separate function call 1330 (sparseTexelsResidentEXT) is required to reason about the code returned 1331 is mildly annoying, but we didn't consider it serious enough to warrant 1332 a change. 1333 1334 We could have used a "bool" type instead, but chose to stick with "int" 1335 for compatibility and for possible future expansion. The AMD extension 1336 also includes built-in functions sparseTexelMinLodWarning() and 1337 sparseTexelWarningFetch() that can be used to check the return code for 1338 other conditions not supported by this extension. Shaders that only 1339 care about residency information can still check the status in a single 1340 (long) line: 1341 1342 if (!sparseTexelsResidentEXT(sparseTextureEXT(sampler, coords, 1343 texel)) 1344 { 1345 // do something about the failure 1346 } 1347 1348 (5) When using a "sparse" built-in texture function, what RGBA values are 1349 generated when the lookup accesses one or more uncommited texels? 1350 1351 RESOLVED: We return a filtered result vector where memory for 1352 uncommitted texels is treated as being filled with zeroes. The data 1353 vector returned by the "sparse" functions for this case should exactly 1354 match the vector returned by an equivalent non-"sparse" function. 1355 1356 (6) For "sparse" built-in texture functions, where should the <texel> 1357 return value go relative to other parameters? 1358 1359 RESOLVED: We chose to follow the precedent of the AMD extension, 1360 putting it in (approximately) the last parameter. Note that the 1361 optional <bias> parameter of texture() breaks this pattern; we chose to 1362 keep the optional bias at the end. 1363 1364 Other options considered included: always first (before the sampler), 1365 always second (after the sampler), always third (after the sampler and 1366 the base coordinates). For "always third", note there are a couple 1367 cases like shadow lookups in cube arrays where the coordinates are split 1368 across multiple parameters and "always third" would be awkward. 1369 Additional options are discussed in issue (3). 1370 1371 (7) Should we provide sparse variants of the "2DMS" and "2DMSArray" 1372 variants of texelFetch() and imageLoad() in this extension? 1373 1374 RESOLVED: Yes. ARB_sparse_texture doesn't support multisample 1375 textures. In this extension, we lift this restriction, allow them to be 1376 accessed using normal built-ins, and provide new functions allowing 1377 shaders to determine if uncommitted memory was accessed. 1378 1379 (8) How does the feedback provided in the "sparse" built-in texture 1380 functions interact with texture filtering modes involving multiple 1381 texels? 1382 1383 RESOLVED: The sparse texture lookup status will indicate that 1384 uncommitted memory was accessed if any texel read during the filtering 1385 operation was uncommitted, but will do so only if the filter weight is 1386 non-zero. When applying a texture filter such as LINEAR_MIPMAP_LINEAR, 1387 it's possible that the interpolated texture coordinate lines up exactly 1388 at the center of a texel and/or exactly at an integer level of detail. 1389 According to the standard filtering equations, eight samples are taken 1390 -- four in each of two levels. However, it's possible that only one of 1391 the eight samples has a non-zero weight (if the coordinates hit a texel 1392 center and the LOD is an integer). 1393 1394 This "non-zero weight" feature may be important for getting proper 1395 feedback in some cases, such as displaying a texture tile with an 1396 aligned 1:1 mapping of pixels to texels or forcing a specific level of 1397 detail in some cases. Note that when attempting to apply a 1:1 mapping 1398 of pixels to texels via an interpolated texture attribute, it's possible 1399 that small floating-point errors might produce very small but non-zero 1400 weights for neighboring texels. If avoiding such errors is important 1401 and a 1:1 mapping is required, a single-sample filter like NEAREST 1402 should be used. 1403 1404 (9) Should we support sparse texel fetches and image loads for buffer 1405 textures? 1406 1407 RESOLVED: Not in this extension. This should be handled by a separate 1408 extension allowing for the creation and use of sparse buffer resources. 1409 Such an extension might also provide the ability to get "sparse" 1410 information when non-texture mechanisms are used to access memory (e.g., 1411 ARB_shader_storage_buffer_object, NV_shader_buffer_load). 1412 1413 (10) Should we support "sparse" variants of the image atomic functions 1414 that return information on residency as well as the value normally 1415 returned by the atomic operation? 1416 1417 RESOLVED: Not in this extension; it's not clear that there's an 1418 important use case for this. If required, a shader can use imageLoad() 1419 to probe the residency of a given texel and ignore the data values 1420 returned. 1421 1422 (11) This extension is adding a *large* number of new built-in functions. 1423 What can we do to control this? 1424 1425 RESOLVED: We chose not to add any "sparse" or "LOD clamp" variants of 1426 projective texture lookups (e.g., textureProj). If required, you can 1427 divide through by the "q" texture coordinate and use an equivalent 1428 non-projective lookup. 1429 1430 We obviously don't support features that make no sense -- for example, 1431 LOD clamp on single-level rectangle textures. 1432 1433 We considered the possibility of more significant GLSL syntax changes to 1434 reduce the cross-product of different features. For example, the AMD 1435 extension has a function: 1436 1437 int sparseTextureProjGradOffset(...); 1438 1439 that combines four separate "optional" features (sparse, projection, 1440 explicitly specified gradients, and texel offsets) and is supported for 1441 six separate texture targets. One might consider an approach like: 1442 1443 #define TEX_IS_PROJECTIVE 0x1 1444 #define TEX_HAS_GRADIENTS 0x2 1445 #define TEX_HAS_TEXEL_OFFSET 0x4 1446 #define TEX_WANTS_SPARSE_STATUS 0x8 1447 struct TexLookup3D { 1448 uint flags; /* in */ 1449 float q; /* in */ 1450 vec3 ddx, ddy; /* in */ 1451 ivec3 texelOffset; /* in */ 1452 int sparseStatus; /* out */ 1453 }; 1454 ... 1455 TexLookup3D lookup; 1456 lookup.flags = (TEX_IS_PROJECTIVE | TEX_HAS_GRADIENTS | 1457 TEX_HAS_TEXEL_OFFSET | TEX_WANTS_SPARSE_STATUS); 1458 lookup.q = coords.w; 1459 lookup.ddx = ddx; 1460 lookup.ddy = ddy; 1461 lookup.texelOffset = ivec3(-1,+1,+2); 1462 texture(sampler, lookup); 1463 1464 to handle all possible cases in one interface. Alternately, a 1465 "prettier" C++-style approach with methods on sampler classes could be 1466 used. 1467 1468 Given that either such feature might involve a large change to the 1469 shading language, it seems more appropriate to address this issue in a 1470 future core version of a shading language rather than an extension. 1471 1472 (12) For new "LOD clamp" functions, how does the LOD clamp interact with 1473 the LOD bias? 1474 1475 RESOLVED: The LOD clamp is applied after the LOD bias. Clamping to the 1476 LOD provided in the shader is logically applied at the same point in the 1477 pipeline where the LOD clamps based on the texture/sampler parameters 1478 TEXTURE_{MIN,MAX}_LOD are applied. 1479 1480 (13) How does the "reads produce zero" behave if a sparse texture is bound 1481 to a framebuffer and used for the depth or stencil test? 1482 1483 RESOLVED: The depth and stencil tests act as though zero were read from 1484 the framebuffer. The actual results of the tests depend on the depth 1485 and stencil functions, the incoming depth value, and the stencil 1486 reference value. 1487 1488 There may be cases where it might be advantageous to configure the depth 1489 or stencil tests to fail when touching an unpopulated portion of the 1490 depth/stencil buffer. The "return zero" behavior may work well for some 1491 cases (e.g., returning zero when using a depth test of LESS will cause 1492 the test to almost always fail), but not as well for others (e.g., depth 1493 test of GREATER). We've chosen not to address this case in the current 1494 extension. 1495 1496 (14) How does the "reads produce zero" behave for textures that don't have 1497 all four components? 1498 1499 RESOLVED: Components that are present in the texture will return zero; 1500 others will return default values. For example, an access to an 1501 uncommitted sparse texture whose with a format has no alpha component 1502 (e.g, RGB8) will return 1.0 on the alpha channel of the returned RGBA 1503 vector. The handling of "missing" components is the same as for 1504 non-sparse textures. 1505 1506 (15) Should we provide standard sparse texture page sizes that 1507 applications can rely on without having to query the set of supported 1508 page sizes for each format it uses? If so, how will this be handled? 1509 Will we have some formats that have standard sizes and others that 1510 don't? 1511 1512 RESOLVED: Yes; we will provide standard page sizes for some, but not 1513 all, formats. However, we will still allow for implementation- 1514 dependent page sizes (as in ARB_sparse_textures) for formats that have a 1515 standard page size and allow implementations to support sparse textures 1516 on formats for which a standard page size is not available. The basic 1517 page sizes we use arrange sparse textures into 64KB pages and attempt to 1518 keep the X, Y, and Z (for 3D) dimensions of the page roughly equal. 1519 1520 (16) Should we add specific compressed formats to the required formats list 1521 and provide standard page sizes? 1522 1523 RESOLVED: Not in this extension. Note that the current 1524 ARB_sparse_texture extension already allows implementations to support 1525 compressed formats. 1526 1527 We've chosen not to go to the trouble of enumerating standard page sizes 1528 for all the compressed formats (many of which are added by extension), 1529 but one logical approach would be to treat each 64- or 128-bit block in 1530 common formats as a single logical texel and treat the standard page 1531 sizes of 64- and 128-bit texels as being in units of compression blocks. 1532 1533 (17) How do applications get to use the standard page size? 1534 1535 RESOLVED: Applications opt in to using standard page sizes by leaving 1536 VIRTUAL_PAGE_SIZE_INDEX_ARB at its initial value (zero). 1537 1538 In ARB_sparse_texture, there were no standard page sizes. Applications 1539 can use GetInternalformativ() with <pname> of NUM_VIRTUAL_PAGE_SIZES_ARB 1540 to query the implementation-dependent number of page sizes supported for 1541 any given format. Some formats may be unsupported, and the GL will 1542 return a page size count of zero. Other formats may have a page size 1543 count of one, or more than one if the implementation supports multiple 1544 page sizes. An application can query the properties of each page size 1545 index by calling GetInternalFormativ() with <pname> set to 1546 VIRTUAL_PAGE_SIZE_{X,Y,Z}_ARB. When an application determines the page 1547 size it wants to use from the options returned by the GL, it sets the 1548 VIRTUAL_PAGE_SIZE_INDEX_ARB texture parameter prior to calling 1549 TexStorage* to allocate storage for the sparse texture. 1550 1551 If an application doesn't bother setting the VIRTUAL_PAGE_SIZE_INDEX_ARB 1552 texture parameter, the default index of zero will be used and the page 1553 size will be whatever the implementation chooses for its first page size 1554 index. In the absence of this extension, the application still needs to 1555 call GetInternalFormativ() to determine the page size being used so it 1556 can manage texture residency. But in the presence of this extension, page 1557 size index 0 will be a standard size and will be the same on all 1558 implementations supporting the extension. 1559 1560 (18) Should we support sparse multisample textures? If so, should we 1561 support standard virtual page sizes? 1562 1563 RESOLVED: Yes, we add will support for sparse multisample textures, but 1564 will not specify standard page sizes. 1565 1566 Different implementations of this extension may represent multisample 1567 textures in different ways. Some implementations might interleave 1568 samples in memory, while others might have separate "planes" in memory 1569 for each individual sample. If we were to support a standard page size, 1570 the easiest approach might be to have a greatest-common-multiple 1571 standard page size. For example, the standard page size for 1572 single-sample textures with 32-bit texels is 128x128 (64KB total). We 1573 could choose to use the same page size for multisample textures. For 4x 1574 multisample, a page of 128x128 pixels would have an effective page size 1575 of 256KB. If an implementation interleaves samples, each virtual page 1576 might be assembled from four consecutive 64K physical pages. If an 1577 implementation has separate "planes", the virtual page might be 1578 assembled from four 64K physical pages spread out in memory. 1579 1580 (19) Should we require support for sparse depth or stencil textures? 1581 Sparse support for these formats is optional in ARB_sparse_texture. 1582 If so, should we support standard virtual page sizes? 1583 1584 RESOLVED: Not in this extension. 1585 1586 The current ARB_sparse_texture extension already allows implementations 1587 to support sparse depth/stencil formats, so the only things a change 1588 could accomplish is (a) provide standard page sizes that can be used 1589 without querying implementation page sizes, (b) ensure that apps can 1590 rely on *some* support by just checking the extension without querying 1591 the number of supported page sizes via GetInternalFormat. 1592 1593 We expect that different implementations may store depth and stencil 1594 textures in different ways and might have different "natural" page 1595 sizes. We could deal with this by using a greatest-common-multiple 1596 standard page size (i.e., have a standard page size larger than 64K), 1597 but it's not clear if that will fly. 1598 1599 The advantages of (b) seem low relative to (a), so we aren't proposing 1600 to add depth and stencil formats to the required list for this 1601 extension. 1602 1603 (20) Should we make a separate extension for the LOD clamp GLSL functions? 1604 1605 RESOLVED: No. While the LOD clamp function doesn't have any real 1606 interaction with sparse textures, its intent is to force the use of a 1607 coarser level of detail that is known (or suspected) to be populated. 1608 We expect that applications using sparse textures may make some of the 1609 coarser levels of detail fully resident, but make portions finer levels 1610 of detail resident selectively. Without using the feedback mechanism 1611 (from the sparseTexture*) functions or without being able to have 1612 portions of the texture non-resident, the LOD clamp built-ins don't 1613 really make much sense. 1614 1615 (21) Should we reconsider re-examining some of the non-orthogonalities in 1616 the current set of texture built-ins, which are being extended for 1617 sparse. For example, the texture() built-in for a sampler type of 1618 samplerCubeArrayShadow does not include an optional LOD bias despite 1619 the fact that cubemap arrays do support multiple LODs. 1620 1621 RESOLVED: Not in this extension. 1622 1623 We chose to create "sparse" variants of existing built-ins without 1624 re-examining current capabilities. It might make sense to have an 1625 extension or future core shading language re-examine things and improve 1626 orthogonality if implementations can support it. 1627 1628Revision History 1629 1630 Revision 1 1631 - Internal revisions 1632 Revision 2 - December 18, 2014 - mheyer 1633 - added ES 3.1 interactions 1634 Revision 3 - April 19, 2016 - dkoch 1635 - fix typos, add interactions with OES extensions 1636