1Name 2 3 ARB_sparse_texture_clamp 4 5Name Strings 6 7 GL_ARB_sparse_texture_clamp 8 9Contact 10 11 Eric Werness, NVIDIA Corporation (ewerness 'at' nvidia.com) 12 13Contributors 14 15 Pat Brown, NVIDIA Corporation 16 Piers Daniell, NVIDIA Corporation 17 Jeff Bolz, NVIDIA Corporation 18 Mathias Heyer, NVIDIA Corporation 19 20Notice 21 22 Copyright (c) 2015 The Khronos Group Inc. Copyright terms at 23 http://www.khronos.org/registry/speccopyright.html 24 25Specification Update Policy 26 27 Khronos-approved extension specifications are updated in response to 28 issues and bugs prioritized by the Khronos OpenGL Working Group. For 29 extensions which have been promoted to a core Specification, fixes will 30 first appear in the latest version of that core Specification, and will 31 eventually be backported to the extension document. This policy is 32 described in more detail at 33 https://www.khronos.org/registry/OpenGL/docs/update_policy.php 34 35Status 36 37 Complete. Approved by the ARB on June 26, 2015. 38 Ratified by the Khronos Board of Promoters on August 7, 2015. 39 40Version 41 42 Last Modified Date: April 30, 2015 43 Revision: 2 44 45Number 46 47 ARB Extension #187 48 49Dependencies 50 51 This extension is written against the OpenGL 4.5 Specification 52 (Compatibility Profile), dated February 2, 2015. 53 54 This extension is written against the OpenGL Shading Language 55 Specification, version 4.50, revision 5. 56 57 This extension requires and extends ARB_sparse_texture2. 58 59 This extension interacts with NV_gpu_program4 and NV_gpu_program5. 60 61Overview 62 63 This extension builds on the ARB_sparse_texture2 extension, providing the 64 following new functionality: 65 66 * New built-in GLSL texture lookup functions are provided that specify a 67 minimum level of detail to use for lookups where the level of detail 68 is computed automatically. This allows shaders to avoid accessing 69 unpopulated portions of high-resolution levels of detail when it knows 70 that the memory accessed is unpopulated, either from a priori 71 knowledge or from feedback provided by the return value of previously 72 executed "sparse" texture lookup functions. 73 74New Procedures and Functions 75 76 None. 77 78New Tokens 79 80 None. 81 82Modifications to the OpenGL 4.5 Specification (Compatibility Profile) 83 84 Modify Section 8.14.1, Scale Factor and Level of Detail, p. 280 85 86 (move the third paragraph, p. 281, describing lod_min and lod_max 87 in equation 8.6, up one paragraph and modify it to read as follows) 88 89 lod_min and lod_max indicate minimum and maximum clamps on the computed 90 level of detail. lod_max is taken directly from the TEXTURE_MAX_LOD 91 texture or sampler parameter. If a texture access is performed in a 92 fragment shader with a minimum level of detail clamp specified in the 93 built-in texture lookup function, lod_min is the larger of the 94 TEXTURE_MIN_LOD texture or sampler parameter and the minimum level of 95 detail provided by the shader. Otherwise, lod_min is taken directly from 96 the TEXTURE_MIN_LOD texture or sampler parameter. The initial values of 97 the TEXTURE_MIN_LOD and TEXTURE_MAX_LOD texture and sampler parameters are 98 chosen so as to never clamp the range of lambda values. 99 100Modifications to the OpenGL Shading Language Specification, Version 4.50 101 102 Including the following line in a shader can be used to control the 103 language features described in this extension: 104 105 #extension GL_ARB_sparse_texture_clamp : <behavior> 106 107 where <behavior> is as specified in section 3.3. 108 109 New preprocessor #defines are added to the OpenGL Shading Language: 110 111 #define GL_ARB_sparse_texture_clamp 1 112 113 Modify Section 8.9, Texture Functions, p. 158 114 115 (insert after first paragraph, p. 159) 116 117 The texture lookup functions with an <lodClamp> parameter specify a 118 minimum clamp applied to the automatic level of detail computations. 119 Since automatic level of detail calculations are only supported by 120 fragment shaders, these lookup functions are also only available in 121 fragment shaders. No functions with the <lodClamp> parameter are provided 122 for rectangle textures, multisample textures, and texture buffers because 123 mipmaps are not allowed for these types of textures. 124 125 126 Modify Section 8.9.2, Texel Lookup Functions, p. 162 127 128 (The combination of this extension and ARB_sparse_texture2 adds two new 129 variants of texture lookup functions. The "sparse" functions are like 130 normal texture lookup functions, except that they return a sparse texture 131 residency status to the caller and return the actual filtered texel value in 132 an "out" parameter. The "Clamp" variants are functions adding a new 133 parameter specifying a minimum LOD to use for texture lookup functions where 134 level of detail is computed automatically. 135 136 For each set of texture functions, we provide one to three new variants 137 based on whether sparse and LOD clamping functionality are desired. These 138 new variants copy the existing functions, add suffixes to the function 139 names, and add one or more new parameters. 140 141 We create new variants only for the targets for which sparse storage is 142 supported -- no new functions are added for the following sampler types: 143 gsampler1D, sampler1DShadow, gsampler1DArray, sampler1DArrayShadow. 144 Additionally, to reduce the number of new functions added, we are not 145 including any new variants for textureProj*() built-ins. To use the new 146 features with projective texture lookups, shaders can divide through by q 147 and use non-projective variants. We also chose not to provide "Clamp" 148 variants of functions like textureLod() expecting an explicit 149 level-of-detail.) 150 151 (insert new lookup function table cells, at the end of the section, 152 p. 168) 153 154 Syntax: 155 156 int sparseTextureClampARB(gsampler2D sampler, vec2 P, 157 float lodClamp, out gvec4 texel 158 [, float bias]); 159 int sparseTextureClampARB(gsampler3D sampler, vec3 P, 160 float lodClamp, out gvec4 texel 161 [, float bias]); 162 int sparseTextureClampARB(gsamplerCube sampler, vec3 P, 163 float lodClamp, out gvec4 texel 164 [, float bias]); 165 int sparseTextureClampARB(sampler2DShadow sampler, vec3 P, 166 float lodClamp, out float texel 167 [, float bias]); 168 int sparseTextureClampARB(samplerCubeShadow sampler, vec4 P, 169 float lodClamp, out float texel 170 [, float bias]); 171 int sparseTextureClampARB(gsampler2DArray sampler, vec3 P, 172 float lodClamp, out gvec4 texel 173 [, float bias]); 174 int sparseTextureClampARB(gsamplerCubeArray sampler, vec4 P, 175 float lodClamp, out gvec4 texel 176 [, float bias]); 177 int sparseTextureClampARB(sampler2DArrayShadow sampler, vec4 P, 178 float lodClamp, out float texel); 179 int sparseTextureClampARB(samplerCubeArrayShadow sampler, vec4 P, 180 float compare, float lodClamp, 181 out float texel); 182 183 Description: 184 185 Do a filtered texture lookup as in texture(), but return texture access 186 residency information from the function and the filtered lookup result in 187 the out parameter <texel>. Additionally, clamp the automatically computed 188 level of detail to be greater than or equal to <lodClamp>. 189 190 -- 191 192 Syntax: 193 194 gvec4 textureClampARB(gsampler1D sampler, float P, 195 float lodClamp [, float bias]); 196 gvec4 textureClampARB(gsampler2D sampler, vec2 P, 197 float lodClamp [, float bias]); 198 gvec4 textureClampARB(gsampler3D sampler, vec3 P, 199 float lodClamp [, float bias]); 200 gvec4 textureClampARB(gsamplerCube sampler, vec3 P, 201 float lodClamp [, float bias]); 202 float textureClampARB(sampler1DShadow sampler, vec3 P, 203 float lodClamp [, float bias]); 204 float textureClampARB(sampler2DShadow sampler, vec3 P, 205 float lodClamp [, float bias]); 206 float textureClampARB(samplerCubeShadow sampler, vec4 P, 207 float lodClamp [, float bias]); 208 gvec4 textureClampARB(gsampler1DArray sampler, vec2 P, 209 float lodClamp [, float bias]); 210 gvec4 textureClampARB(gsampler2DArray sampler, vec3 P, 211 float lodClamp [, float bias]); 212 gvec4 textureClampARB(gsamplerCubeArray sampler, vec4 P, 213 float lodClamp [, float bias]); 214 float textureClampARB(sampler1DArrayShadow sampler, vec3 P, 215 float lodClamp [, float bias]); 216 float textureClampARB(sampler2DArrayShadow sampler, vec4 P, 217 float lodClamp); 218 float textureClampARB(samplerCubeArrayShadow sampler, vec4 P, 219 float compare, float lodClamp); 220 221 Description: 222 223 Do a filtered texture lookup as in texture(), but clamp the automatically 224 computed level of detail to be greater than or equal to <lodClamp>. 225 226 -- 227 228 Syntax: 229 230 int sparseTextureOffsetClampARB(gsampler2D sampler, vec2 P, 231 ivec2 offset, float lodClamp, 232 out gvec4 texel [, float bias]); 233 int sparseTextureOffsetClampARB(gsampler3D sampler, vec3 P, 234 ivec3 offset, float lodClamp, 235 out gvec4 texel [, float bias]); 236 int sparseTextureOffsetClampARB(sampler2DShadow sampler, vec3 P, 237 ivec2 offset, float lodClamp, 238 out float texel [, float bias]); 239 int sparseTextureOffsetClampARB(gsampler2DArray sampler, vec3 P, 240 ivec2 offset, float lodClamp, 241 out gvec4 texel [, float bias]); 242 int sparseTextureOffsetClampARB(sampler2DArrayShadow sampler, vec4 P, 243 ivec2 offset, float lodClamp, 244 out float texel); 245 246 Description: 247 248 Do a filtered texture lookup as in textureOffset(), but return texture 249 access residency information from the function and the filtered lookup 250 result in the out parameter <texel>. Additionally, clamp the 251 automatically computed level of detail to be greater than or equal to 252 <lodClamp>. 253 254 -- 255 256 Syntax: 257 258 gvec4 textureOffsetClampARB(gsampler1D sampler, float P, 259 int offset, float lodClamp [, float bias]); 260 gvec4 textureOffsetClampARB(gsampler2D sampler, vec2 P, 261 ivec2 offset, float lodClamp [, float bias]); 262 gvec4 textureOffsetClampARB(gsampler3D sampler, vec3 P, 263 ivec3 offset, float lodClamp [, float bias]); 264 float textureOffsetClampARB(sampler1DShadow sampler, vec3 P, 265 int offset, float lodClamp [, float bias]); 266 float textureOffsetClampARB(sampler2DShadow sampler, vec3 P, 267 ivec2 offset, float lodClamp [, float bias]); 268 gvec4 textureOffsetClampARB(gsampler1DArray sampler, vec2 P, 269 int offset, float lodClamp [, float bias]); 270 gvec4 textureOffsetClampARB(gsampler2DArray sampler, vec3 P, 271 ivec2 offset, float lodClamp [, float bias]); 272 float textureOffsetClampARB(sampler1DArrayShadow sampler, vec3 P, 273 int offset, float lodClamp [, float bias]); 274 float textureOffsetClampARB(sampler2DArrayShadow sampler, vec4 P, 275 ivec2 offset, float lodClamp); 276 277 Description: 278 279 Do a filtered texture lookup as in textureOffset(), but clamp the 280 automatically computed level of detail to be greater than or equal to 281 <lodClamp>. 282 283 -- 284 285 Syntax: 286 287 int sparseTextureGradClampARB(gsampler2D sampler, vec2 P, 288 vec2 dPdx, vec2 dPdy, float lodClamp, 289 out gvec4 texel); 290 int sparseTextureGradClampARB(gsampler3D sampler, vec3 P, 291 vec3 dPdx, vec3 dPdy, float lodClamp, 292 out gvec4 texel); 293 int sparseTextureGradClampARB(gsamplerCube sampler, vec3 P, 294 vec3 dPdx, vec3 dPdy, float lodClamp, 295 out gvec4 texel); 296 int sparseTextureGradClampARB(sampler2DShadow sampler, vec3 P, 297 vec2 dPdx, vec2 dPdy, float lodClamp, 298 out float texel); 299 int sparseTextureGradClampARB(samplerCubeShadow sampler, vec4 P, 300 vec3 dPdx, vec3 dPdy, float lodClamp, 301 out float texel); 302 int sparseTextureGradClampARB(gsampler2DArray sampler, vec3 P, 303 vec2 dPdx, vec2 dPdy, float lodClamp, 304 out gvec4 texel); 305 int sparseTextureGradClampARB(sampler2DArrayShadow sampler, vec4 P, 306 vec2 dPdx, vec2 dPdy, float lodClamp, 307 out float texel); 308 int sparseTextureGradClampARB(gsamplerCubeArray sampler, vec4 P, 309 vec3 dPdx, vec3 dPdy, float lodClamp, 310 out gvec4 texel); 311 312 Description: 313 314 Do a filtered texture lookup as in textureGrad(), but return texture 315 access residency information from the function and the filtered lookup 316 result in the out parameter <texel>. Additionally, clamp the 317 automatically computed level of detail to be greater than or equal to 318 <lodClamp>. 319 320 -- 321 322 Syntax: 323 324 gvec4 textureGradClampARB(gsampler1D sampler, float P, 325 float dPdx, float dPdy, float lodClamp); 326 gvec4 textureGradClampARB(gsampler2D sampler, vec2 P, 327 vec2 dPdx, vec2 dPdy, float lodClamp); 328 gvec4 textureGradClampARB(gsampler3D sampler, vec3 P, 329 vec3 dPdx, vec3 dPdy, float lodClamp); 330 gvec4 textureGradClampARB(gsamplerCube sampler, vec3 P, 331 vec3 dPdx, vec3 dPdy, float lodClamp); 332 float textureGradClampARB(sampler1DShadow sampler, vec3 P, 333 float dPdx, float dPdy, float lodClamp); 334 float textureGradClampARB(sampler2DShadow sampler, vec3 P, 335 vec2 dPdx, vec2 dPdy, float lodClamp); 336 float textureGradClampARB(samplerCubeShadow sampler, vec4 P, 337 vec3 dPdx, vec3 dPdy, float lodClamp); 338 gvec4 textureGradClampARB(gsampler1DArray sampler, vec2 P, 339 float dPdx, float dPdy, float lodClamp); 340 gvec4 textureGradClampARB(gsampler2DArray sampler, vec3 P, 341 vec2 dPdx, vec2 dPdy, float lodClamp); 342 float textureGradClampARB(sampler1DArrayShadow sampler, vec3 P, 343 float dPdx, float dPdy, float lodClamp); 344 float textureGradClampARB(sampler2DArrayShadow sampler, vec4 P, 345 vec2 dPdx, vec2 dPdy, float lodClamp); 346 gvec4 textureGradClampARB(gsamplerCubeArray sampler, vec4 P, 347 vec3 dPdx, vec3 dPdy, float lodClamp); 348 349 Description: 350 351 Do a filtered texture lookup as in textureGrad(), but clamp the 352 automatically computed level of detail to be greater than or equal to 353 <lodClamp>. 354 355 -- 356 357 Syntax: 358 359 int sparseTextureGradOffsetClampARB(gsampler2D sampler, vec2 P, 360 vec2 dPdx, vec2 dPdy, ivec2 offset, 361 float lodClamp, out gvec4 texel); 362 int sparseTextureGradOffsetClampARB(gsampler3D sampler, vec3 P, 363 vec3 dPdx, vec3 dPdy, ivec3 offset, 364 float lodClamp, out gvec4 texel); 365 int sparseTextureGradOffsetClampARB(sampler2DShadow sampler, vec3 P, 366 vec2 dPdx, vec2 dPdy, ivec2 offset, 367 float lodClamp, out float texel); 368 int sparseTextureGradOffsetClampARB(gsampler2DArray sampler, vec3 P, 369 vec2 dPdx, vec2 dPdy, ivec2 offset, 370 float lodClamp, out gvec4 texel); 371 int sparseTextureGradOffsetClampARB(sampler2DArrayShadow sampler, vec4 P, 372 vec2 dPdx, vec2 dPdy, ivec2 offset, 373 float lodClamp, out float texel); 374 375 Description: 376 377 Do a filtered texture lookup as in textureGradOffset(), but return texture 378 access residency information from the function and the filtered lookup 379 result in the out parameter <texel>. Additionally, clamp the 380 automatically computed level of detail to be greater than or equal to 381 <lodClamp>. 382 383 -- 384 385 Syntax: 386 387 gvec4 textureGradOffsetClampARB(gsampler1D sampler, float P, 388 float dPdx, float dPdy, int offset, 389 float lodClamp); 390 gvec4 textureGradOffsetClampARB(gsampler2D sampler, vec2 P, 391 vec2 dPdx, vec2 dPdy, ivec2 offset, 392 float lodClamp); 393 gvec4 textureGradOffsetClampARB(gsampler3D sampler, vec3 P, 394 vec3 dPdx, vec3 dPdy, ivec3 offset, 395 float lodClamp); 396 float textureGradOffsetClampARB(sampler1DShadow sampler, vec3 P, 397 float dPdx, float dPdy, int offset, 398 float lodClamp); 399 float textureGradOffsetClampARB(sampler2DShadow sampler, vec3 P, 400 vec2 dPdx, vec2 dPdy, ivec2 offset, 401 float lodClamp); 402 gvec4 textureGradOffsetClampARB(gsampler1DArray sampler, vec2 P, 403 float dPdx, float dPdy, int offset, 404 float lodClamp); 405 gvec4 textureGradOffsetClampARB(gsampler2DArray sampler, vec3 P, 406 vec2 dPdx, vec2 dPdy, ivec2 offset, 407 float lodClamp); 408 float textureGradOffsetClampARB(sampler1DArrayShadow sampler, vec3 P, 409 float dPdx, float dPdy, int offset, 410 float lodClamp); 411 float textureGradOffsetClampARB(sampler2DArrayShadow sampler, vec4 P, 412 vec2 dPdx, vec2 dPdy, ivec2 offset, 413 float lodClamp); 414 415 Description: 416 417 Do a filtered texture lookup as in textureGrad(), but clamp the 418 automatically computed level of detail to be greater than or equal to 419 <lodClamp>. 420 421Additions to the AGL/GLX/WGL Specifications 422 423 None. 424 425Errors 426 427 None. 428 429New State 430 431 None. 432 433New Implementation Dependent State 434 435 None. 436 437Dependencies on NV_gpu_program4 and NV_gpu_program5 438 439 Modify Section 2.X.2, Program Grammar 440 441 <opModifier> ::= "LODCLAMP" 442 443 Modify Section 2.X.4.1, Program Instruction Modifiers 444 445 (Update the discussion of instruction precision modifiers. If 446 GL_NV_gpu_program_fp64 is not found in the extension string, the "F64" 447 instruction modifier described below is not supported.) 448 449 (add to Table X.14 of the NV_gpu_program4 specification.) 450 451 Modifier Description 452 -------- ------------------------------------------------------ 453 LODCLAMP Clamp the LOD used by texture lookups to a specified 454 value 455 456 For texture fetch instructions with implicit LOD calcuations (TEX, TXB, 457 TXD), the "LODCLAMP" modifier specifies that the instruction includes an 458 extra floating-point component indicating a minimum level of detail to be 459 used for the texture lookup. If the implicitly computed level of detail 460 is less than the level of detail provided in the instruction data, that 461 level should be used instead. 462 463 Modify Section 2.X.4.4, Program Texture Access 464 465 (modify the prototype of the TextureSample utility function, adding 466 <coord2> and removing <lod>) 467 468 result_t_vec 469 TextureSample(float_vec coord, float_vec coord2, 470 float_vec ddx, float_vec ddy, int_vec offset); 471 472 (modify the description of <coord> to add <coord2>) 473 474 <coord> and <coord2> are two four-component floating-point vectors from 475 which the (s,t,r) texture coordinates used for the texture access, the 476 layer used for array textures, and the reference value used for depth 477 comparisons (section 3.8.14) are extracted according to Table X.17. ... 478 479 (replace the paragraph discussing <lod>) 480 481 <ddx> and <ddy> specify partial derivatives (ds/dx, dt/dx, dr/dx, ds/dy, 482 dt/dy, and dr/dy) for the texture coordinates, and may be used for level 483 of detail calculations and to derive footprint shapes for anisotropic 484 texture filtering. 485 486 The level of detail used for the texture lookup is a function of the 487 texture instruction type, texture target, LODCLAMP qualifier, and the 488 inputs <ddx> and <ddy>. For TEX, TXB, TXD, and TXP instructions in a base 489 level of detail is computed based on the partial derivatives <ddx> and 490 <ddy>. For the TXB and TXL instruction, an additional level of detail 491 value is taken from the component in <coord> or <coord2> identified by the 492 first entry in the "lod" column of Table X.17. For TXB, this value is 493 added to the computed base level of detail; for TXL, it specifies the base 494 level of detail. After that, per-texture and per-texture unit LOD biases 495 are added to the level of detail. Finally, if the LODCLAMP opcode 496 modifier is specified, an LOD clamp value is extracted from <coord> or 497 <coord2> according to the second entry in the "lod" column of Table X.17. 498 The computed level of detail is clamped to be greater than or equal to 499 this LOD clamp value. 500 501 coordinates used 502 texTarget Texture Type s t r lay shd lod 503 ---------------- --------------------- ----- --- --- ----- 504 1D TEXTURE_1D x - - - - w,x2 505 2D TEXTURE_2D x y - - - w,x2 506 3D TEXTURE_3D x y z - - w,x2 507 CUBE TEXTURE_CUBE_MAP x y z - - w,x2 508 RECT TEXTURE_RECTANGLE_ARB x y - - - -,- 509 ARRAY1D TEXTURE_1D_ARRAY_EXT x - - y - w,x2 510 ARRAY2D TEXTURE_2D_ARRAY_EXT x y - z - w,x2 511 ARRAYCUBE TEXTURE_CUBE_MAP_ARRAY x y z w - x2,y2 512 SHADOW1D TEXTURE_1D x - - - z w,x2 513 SHADOW2D TEXTURE_2D x y - - z w,x2 514 SHADOWRECT TEXTURE_RECTANGLE_ARB x y - - z -,- 515 SHADOWCUBE TEXTURE_CUBE_MAP x y z - w x2,y2 516 SHADOWARRAY1D TEXTURE_1D_ARRAY_EXT x - - y z w,x2 517 SHADOWARRAY2D TEXTURE_2D_ARRAY_EXT x y - z w -,x2 518 SHADOWARRAYCUBE TEXTURE_CUBE_MAP_ARRAY x y z w x2 -,y2 519 BUFFER TEXTURE_BUFFER_EXT <not supported> 520 RENDERBUFFER TEXTURE_RENDERBUFFER <not supported> 521 2DMS TEXTURE_2D_MULTISAMPLE <not supported> 522 ARRAY2DMS TEXTURE_2D_MULTISAMPLE_ <not supported> 523 ARRAY 524 525 Table X.17: Texture types accessed for each of the <texTarget>, and 526 coordinate mappings. Components "x", "y", "z", and "w" are taken from 527 the first coordinate vector <coord>; "x2" and "y2" are taken from the 528 second vector <coord2>. The "SHADOW" and "ARRAY" targets are special 529 pseudo-targets described below. The "coordinates used" column indicate 530 the input values used for each coordinate of the texture lookup, the 531 layer selector for array textures, the reference value for texture 532 comparisons, and up to two components of level-of-detail information. 533 Buffer textures are not supported by normal texture lookup functions, 534 but are supported by TXF and TXQ, described below. Renderbuffer and 535 multisample textures are not supported by normal texture lookup 536 functions, but are supported by TXFMS. The TXB and TXL instructions are 537 not supported for the targets SHADOWARRAY2D and SHADOWARRAYCUBE, so the 538 first column of "lod" is ignored. 539 540 Modify Section 2.X.8.Z, TXD: Texture Sample with Partials 541 542 ... The partial derivatives of the texture coordinates with respect to X 543 and Y are specified by the second and third floating-point source vectors. 544 If the LODCLAMP instruction modifier is specified, floating-point 545 level-of-detail clamp value is specified in the <w> component of the third 546 floating-point source vector. The level of detail is computed 547 automatically using the provided partial derivatives. 548 549 550Issues 551 552 (1) How does this extension compare to the ARB_sparse_texture2 extension? 553 554 RESOLVED: We extend the mechanisms provided by ARB_sparse_texture2 in 555 adding built-in texture and image lookup functions clamping the final 556 level of detail computed based on texture coordinates, derivatives, and 557 LOD bias to a minimum LOD specified in the shader. 558 559 (2) The combination of this extension and GL_ARB_sparse_texture2 add a 560 *large* number of new built-in functions. 561 What can we do to control this? 562 563 RESOLVED: We chose not to add any "sparse" or "LOD clamp" variants of 564 projective texture lookups (e.g., textureProj). If required, you can 565 divide through by the "q" texture coordinate and use an equivalent 566 non-projective lookup. 567 568 We obviously don't support features that make no sense -- for example, 569 LOD clamp on single-level rectangle textures. 570 571 We considered the possibility of more significant GLSL syntax changes to 572 reduce the cross-product of different features. For example, the AMD 573 extension has a function: 574 575 int sparseTextureProjGradOffset(...); 576 577 that combines four separate "optional" features (sparse, projection, 578 explicitly specified gradients, and texel offsets) and is supported for 579 six separate texture targets. One might consider an approach like: 580 581 #define TEX_IS_PROJECTIVE 0x1 582 #define TEX_HAS_GRADIENTS 0x2 583 #define TEX_HAS_TEXEL_OFFSET 0x4 584 #define TEX_WANTS_SPARSE_STATUS 0x8 585 struct TexLookup3D { 586 uint flags; /* in */ 587 float q; /* in */ 588 vec3 ddx, ddy; /* in */ 589 ivec3 texelOffset; /* in */ 590 int sparseStatus; /* out */ 591 }; 592 ... 593 TexLookup3D lookup; 594 lookup.flags = (TEX_IS_PROJECTIVE | TEX_HAS_GRADIENTS | 595 TEX_HAS_TEXEL_OFFSET | TEX_WANTS_SPARSE_STATUS); 596 lookup.q = coords.w; 597 lookup.ddx = ddx; 598 lookup.ddy = ddy; 599 lookup.texelOffset = ivec3(-1,+1,+2); 600 texture(sampler, lookup); 601 602 to handle all possible cases in one interface. Alternately, a 603 "prettier" C++-style approach with methods on sampler classes could be 604 used. 605 606 Given that either such feature might involve a large change to the 607 shading language, it seems more appropriate to address this issue in a 608 future core version of a shading language rather than an extension. 609 610 (3) For new "LOD clamp" functions, how does the LOD clamp interact with 611 the LOD bias? 612 613 RESOLVED: The LOD clamp is applied after the LOD bias. Clamping to the 614 LOD provided in the shader is logically applied at the same point in the 615 pipeline where the LOD clamps based on the texture/sampler parameters 616 TEXTURE_{MIN,MAX}_LOD are applied. 617 618Revision History 619 620 Revision 1 621 - Split clamp functions from ARB_sparse_texture2 622