15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_shader_texture_footprint 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_shader_texture_footprint 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Chris Lentini, NVIDIA (clentini 'at' nvidia.com) 125bd8deadSopenharmony_ci Pat Brown, NVIDIA (pbrown 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContributors 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Jeff Bolz, NVIDIA 175bd8deadSopenharmony_ci Daniel Koch, NVIDIA 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciStatus 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Shipping 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciVersion 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Last Modified Date: February 8, 2018 265bd8deadSopenharmony_ci NVIDIA Revision: 2 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ciNumber 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci OpenGL Extension #530 315bd8deadSopenharmony_ci OpenGL ES Extension #313 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciDependencies 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci This extension is written against the OpenGL 4.6 Specification 365bd8deadSopenharmony_ci (Compatibility Profile), dated July 30, 2017. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci OpenGL 4.5 or OpenGL ES 3.2 is required. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci This extension requires support for the OpenGL Shading Language (GLSL) 415bd8deadSopenharmony_ci extension "NV_shader_texture_footprint", which can be found at the Khronos 425bd8deadSopenharmony_ci Group Github site here: 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci https://github.com/KhronosGroup/GLSL 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ciOverview 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci This extension adds OpenGL API support for the OpenGL Shading Language 495bd8deadSopenharmony_ci (GLSL) extension "NV_shader_texture_footprint". That extension adds a new 505bd8deadSopenharmony_ci set of texture query functions ("textureFootprint*NV") to GLSL. These 515bd8deadSopenharmony_ci built-in functions prepare to perform a filtered texture lookup based on 525bd8deadSopenharmony_ci coordinates and other parameters passed in by the calling code. However, 535bd8deadSopenharmony_ci instead of returning data from the provided texture image, these query 545bd8deadSopenharmony_ci functions instead return data identifying the _texture footprint_ for an 555bd8deadSopenharmony_ci equivalent texture access. The texture footprint identifies a set of 565bd8deadSopenharmony_ci texels that may be accessed in order to return a filtered result for the 575bd8deadSopenharmony_ci texture access. 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci The footprint itself is a structure that includes integer values that 605bd8deadSopenharmony_ci identify a small neighborhood of texels in the texture being accessed and 615bd8deadSopenharmony_ci a bitfield that indicates which texels in that neighborhood would be used. 625bd8deadSopenharmony_ci Each bit in the returned bitfield identifies whether any texel in a small 635bd8deadSopenharmony_ci aligned block of texels would be fetched by the texture lookup. The size 645bd8deadSopenharmony_ci of each block is specified by an access _granularity_ provided by the 655bd8deadSopenharmony_ci shader. The minimum granularity supported by this extension is 2x2 (for 665bd8deadSopenharmony_ci 2D textures) and 2x2x2 (for 3D textures); the maximum granularity is 675bd8deadSopenharmony_ci 256x256 (for 2D textures) or 64x32x32 (for 3D textures). Each footprint 685bd8deadSopenharmony_ci query returns the footprint from a single texture level. When using 695bd8deadSopenharmony_ci minification filters that combine accesses from multiple mipmap levels, 705bd8deadSopenharmony_ci shaders must perform separate queries for the two levels accessed ("fine" 715bd8deadSopenharmony_ci and "coarse"). The footprint query also returns a flag indicating if the 725bd8deadSopenharmony_ci texture lookup would access texels from only one mipmap level or from two 735bd8deadSopenharmony_ci neighboring levels. 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci This extension should be useful for multi-pass rendering operations that 765bd8deadSopenharmony_ci do an initial expensive rendering pass to produce a first image that is 775bd8deadSopenharmony_ci then used as a texture for a second pass. If the second pass ends up 785bd8deadSopenharmony_ci accessing only portions of the first image (e.g., due to visibility), the 795bd8deadSopenharmony_ci work spent rendering the non-accessed portion of the first image was 805bd8deadSopenharmony_ci wasted. With this feature, an application can limit this waste using an 815bd8deadSopenharmony_ci initial pass over the geometry in the second image that performs a 825bd8deadSopenharmony_ci footprint query for each visible pixel to determine the set of pixels that 835bd8deadSopenharmony_ci it needs from the first image. This pass would accumulate an aggregate 845bd8deadSopenharmony_ci footprint of all visible pixels into a separate "footprint texture" using 855bd8deadSopenharmony_ci shader atomics. Then, when rendering the first image, the application can 865bd8deadSopenharmony_ci kill all shading work for pixels not in this aggregate footprint. 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci The implementation of this extension has a number of limitations. The 895bd8deadSopenharmony_ci texture footprint query functions are only supported for two- and 905bd8deadSopenharmony_ci three-dimensional textures (TEXTURE_2D, TEXTURE_3D). Texture footprint 915bd8deadSopenharmony_ci evaluation only supports the CLAMP_TO_EDGE wrap mode; results are 925bd8deadSopenharmony_ci undefined for all other wrap modes. The implementation supports only a 935bd8deadSopenharmony_ci limited set of granularity values and does not support separate coverage 945bd8deadSopenharmony_ci information for each texel in the original texture. 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ciNew Procedures and Functions 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci None 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ciNew Tokens 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci None 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL 4.6 (Compatibility Profile) Specification 1065bd8deadSopenharmony_ci(Textures and Samplers) 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci (add a new section immediately after section 8.15, Texture Magnification) 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci Section 8.X, Texture Footprint Queries 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci The OpenGL Shading Language provides a collection of built-in functions, 1135bd8deadSopenharmony_ci all beginning with "textureFootprint", that allow shaders to query a 1145bd8deadSopenharmony_ci _texture footprint_. The texture footprint is a set of texels belonging 1155bd8deadSopenharmony_ci to a single texture level that would be accessed when performing a 1165bd8deadSopenharmony_ci filtered texture lookup. The shader code calling the footprint query 1175bd8deadSopenharmony_ci functions passes in a _granularity_ value, which is used to subdivide a 1185bd8deadSopenharmony_ci texture level into an array of fixed-size _texel groups_ whose size is 1195bd8deadSopenharmony_ci given by the granularity. The texture footprint query functions return 1205bd8deadSopenharmony_ci the footprint using a built-in GLSL data structure that identifies the set 1215bd8deadSopenharmony_ci of texel groups containing one or more texels that would be accessed in an 1225bd8deadSopenharmony_ci equivalent texture lookup. Texture footprint queries are only supported 1235bd8deadSopenharmony_ci for two- and three-dimensional textures (targets TEXTURE_2D and 1245bd8deadSopenharmony_ci TEXTURE_3D). Additionally, footprint queries require the use of the 1255bd8deadSopenharmony_ci CLAMP_TO_EDGE sampler wrap mode in all relevant dimensions; the results of 1265bd8deadSopenharmony_ci the footprint query are undefined if any other wrap mode is used. 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci Each texture footprint query built-in function accepts a set of texture 1295bd8deadSopenharmony_ci coordinates and any additional parameters (e.g., explicit level of detail, 1305bd8deadSopenharmony_ci level of detail bias, or derivatives) needed to specify a normal texture 1315bd8deadSopenharmony_ci lookup operation whose footprint should be evaluated. The footprint query 1325bd8deadSopenharmony_ci functions also accept a <granularity> parameter and a <coarse> flag used 1335bd8deadSopenharmony_ci to select the level of detail whose footprint is returned. The 1345bd8deadSopenharmony_ci granularity parameter identifies the size of the texel groups used for the 1355bd8deadSopenharmony_ci footprint query as described in Table X.1. The <coarse> flag is used to 1365bd8deadSopenharmony_ci select between the two levels of detail used when minifying using a filter 1375bd8deadSopenharmony_ci (NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR) that averages texels from 1385bd8deadSopenharmony_ci multiple levels of detail. When such minification is performed, a value 1395bd8deadSopenharmony_ci of "false" requests the footprint in the higher-resolution (fine) level of 1405bd8deadSopenharmony_ci detail, while "true" requests the footprint in the lower-resolution 1415bd8deadSopenharmony_ci (coarse) level of detail. When a texture access uses only a single level 1425bd8deadSopenharmony_ci of detail, its footprint will be returned for queries with <coarse> set to 1435bd8deadSopenharmony_ci false, while queries with <coarse> set to true will return an empty 1445bd8deadSopenharmony_ci footprint. Since many texture accesses may use only a single level, the 1455bd8deadSopenharmony_ci footprint query functions return a boolean value, which will be true if 1465bd8deadSopenharmony_ci and only if all accessed texels are in a single level of detail. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci Granularity Value | TEXTURE_2D | TEXTURE_3D 1495bd8deadSopenharmony_ci ------------------+---------------+---------------- 1505bd8deadSopenharmony_ci 0 | unsupported | unsupported 1515bd8deadSopenharmony_ci 1 | 2x2 | 2x2x2 1525bd8deadSopenharmony_ci 2 | 4x2 | unsupported 1535bd8deadSopenharmony_ci 3 | 4x4 | 4x4x2 1545bd8deadSopenharmony_ci 4 | 8x4 | unsupported 1555bd8deadSopenharmony_ci 5 | 8x8 | unsupported 1565bd8deadSopenharmony_ci 6 | 16x8 | unsupported 1575bd8deadSopenharmony_ci 7 | 16x16 | unsupported 1585bd8deadSopenharmony_ci 8 | unsupported | unsupported 1595bd8deadSopenharmony_ci 9 | unsupported | unsupported 1605bd8deadSopenharmony_ci 10 | unsupported | 16x16x16 1615bd8deadSopenharmony_ci 11 | 64x64 | 32x16x16 1625bd8deadSopenharmony_ci 12 | 128x64 | 32x32x16 1635bd8deadSopenharmony_ci 13 | 128x128 | 32x32x32 1645bd8deadSopenharmony_ci 14 | 256x128 | 64x32x32 1655bd8deadSopenharmony_ci 15 | 256x256 | unsupported 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci Table X.1: Supported granularities for texture footprint queries, for 1685bd8deadSopenharmony_ci two-dimensional (TEXTURE_2D) and three-dimensional (TEXTURE_3D) 1695bd8deadSopenharmony_ci accesses. Granularity values not listed in the table or listed as 1705bd8deadSopenharmony_ci "unsupported" are not supported by this extension and result in 1715bd8deadSopenharmony_ci undefined behavior if used. 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci In addition to the boolean result, texture footprint queries return 1745bd8deadSopenharmony_ci footprint data in a structure of the type gl_TextureFootprint2DNV (for 1755bd8deadSopenharmony_ci two-dimensional textures) or gl_TextureFootprint3DNV (for 1765bd8deadSopenharmony_ci three-dimensional textures). In either structure, the member <lod> 1775bd8deadSopenharmony_ci specifies the level-of-detail number used for the footprint. The 1785bd8deadSopenharmony_ci members <anchor> and <offset> identify a small neighborhood of texel 1795bd8deadSopenharmony_ci groups in the texture used by the query. The member <mask> specifies 64 1805bd8deadSopenharmony_ci bits of data indicating which texel groups in the neighborhood are part 1815bd8deadSopenharmony_ci of the footprint. The member <granularity> returns information on the 1825bd8deadSopenharmony_ci size of the texel groups in the footprint, which is sometimes larger 1835bd8deadSopenharmony_ci than the requested granularity, as described below. 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci For two-dimensional footprint queries, the neighborhood returned by the 1865bd8deadSopenharmony_ci query is an 8x8 array of texel groups, where each texel group in 1875bd8deadSopenharmony_ci neighborhood is identified by a coordinate (x,y), where <x> and <y> are 1885bd8deadSopenharmony_ci integer values in the range [0,7]. Each texel group corresponds to a 1895bd8deadSopenharmony_ci set of texels whose (u,v) coordinates satisfy the inequalities: 1905bd8deadSopenharmony_ci 1915bd8deadSopenharmony_ci u1 <= u <= u2 1925bd8deadSopenharmony_ci v1 <= v <= v2 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci computed using the following logic: 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci // The footprint logic returns a mask whose bits are aligned to 8x8 1975bd8deadSopenharmony_ci // sets of texel groups. This allows shaders to use atomics to 1985bd8deadSopenharmony_ci // efficiently accumulate footprint results across many invocations, 1995bd8deadSopenharmony_ci // storing an 8x8 array of bits for each group into one RG32UI texel. 2005bd8deadSopenharmony_ci // The texel group number in the neighborhood is treated as an offset 2015bd8deadSopenharmony_ci // relative to the anchor point. 2025bd8deadSopenharmony_ci uvec2 texel_group = 8 * result.anchor + uvec2(x,y); 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci // If the neighborhood crosses the boundaries of an 8x8 set, the bits 2055bd8deadSopenharmony_ci // of the mask are effectively split across multiple sets (up to 2065bd8deadSopenharmony_ci // four for 2D). The "offset" parameter returned by the query 2075bd8deadSopenharmony_ci // identifies which x/y group values in the neighborhood are 2085bd8deadSopenharmony_ci // assigned to which set. An all-zero offset indicates that the 2095bd8deadSopenharmony_ci // footprint is fully contained in a single 8x8 set at the anchor. 2105bd8deadSopenharmony_ci // "Low" x/y values identify texel groups at the beginning of the 8x8 2115bd8deadSopenharmony_ci // set identified by the anchor, while "high" values correspond to 2125bd8deadSopenharmony_ci // texel groups at the end of the previous set. The offset 2135bd8deadSopenharmony_ci // indicates the number of texel groups assigned to the previous set. 2145bd8deadSopenharmony_ci if (x + result.offset.x >= 8) { 2155bd8deadSopenharmony_ci texel_group.x -= 8; 2165bd8deadSopenharmony_ci } 2175bd8deadSopenharmony_ci if (y + result.offset.y >= 8) { 2185bd8deadSopenharmony_ci texel_group.y -= 8; 2195bd8deadSopenharmony_ci } 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci // Once we have a group number, u/v texel number ranges are generated by 2225bd8deadSopenharmony_ci // multiplying by the texel group size. 2235bd8deadSopenharmony_ci uint u1 = texel_group.x * granularity_x; 2245bd8deadSopenharmony_ci uint u2 = u1 + granularity_x - 1; 2255bd8deadSopenharmony_ci uint v1 = texel_group.y * granularity_y; 2265bd8deadSopenharmony_ci uint v2 = v1 + granularity_y - 1; 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci In the equations above, <granularity_x> and <granularity_y> refer to the 2295bd8deadSopenharmony_ci texel group size as in Table X.1. result.anchor and result.offset 2305bd8deadSopenharmony_ci specify the <anchor> and <offset> members of the returned structure, and 2315bd8deadSopenharmony_ci <x> and <y> specify the texel group number in the neighborhood. 2325bd8deadSopenharmony_ci 2335bd8deadSopenharmony_ci Each bit in the <mask> member of the returned structure corresponds to 2345bd8deadSopenharmony_ci one of the texel groups in the 8x8 neighborhood. That bit will be set 2355bd8deadSopenharmony_ci if and only if any of the texels in the texel group is covered by the 2365bd8deadSopenharmony_ci footprint. The texel group (x,y) is considered to be covered if and 2375bd8deadSopenharmony_ci only if the following logic computes true for <covered>: 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci uint64_t mask = result.mask.x | (result.mask.y << 32); 2405bd8deadSopenharmony_ci uint32_t bit = y * 8 + x; 2415bd8deadSopenharmony_ci bool covered = (0 != ((mask >> bit) & 1)); 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ci For three-dimensional footprint queries, the logic is very similar, 2445bd8deadSopenharmony_ci except that the neighborhood returned by the query is a 4x4x4 array of 2455bd8deadSopenharmony_ci texel groups. Each texel group in neighborhood is identified by a 2465bd8deadSopenharmony_ci coordinate (x,y,z), where <x>, <y>, and <z> are integer values in the 2475bd8deadSopenharmony_ci range [0,3]. Each texel group corresponds to a set of texels whose 2485bd8deadSopenharmony_ci (u,v,w) coordinates satisfy the inequalities: 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci u1 <= u <= u2 2515bd8deadSopenharmony_ci v1 <= v <= v2 2525bd8deadSopenharmony_ci w1 <= w <= w2 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci computed using the following logic: 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ci uvec3 texel_group = 4 * result.anchor + uvec3(x,y,z); 2575bd8deadSopenharmony_ci if (x + result.offset.x >= 4) { 2585bd8deadSopenharmony_ci texel_group.x -= 4; 2595bd8deadSopenharmony_ci } 2605bd8deadSopenharmony_ci if (y + result.offset.y >= 4) { 2615bd8deadSopenharmony_ci texel_group.y -= 4; 2625bd8deadSopenharmony_ci } 2635bd8deadSopenharmony_ci if (z + result.offset.z >= 4) { 2645bd8deadSopenharmony_ci texel_group.z -= 4; 2655bd8deadSopenharmony_ci } 2665bd8deadSopenharmony_ci uint u1 = texel_group.x * granularity_x; 2675bd8deadSopenharmony_ci uint u2 = u1 + granularity_x - 1; 2685bd8deadSopenharmony_ci uint v1 = texel_group.y * granularity_y; 2695bd8deadSopenharmony_ci uint v2 = v1 + granularity_y - 1; 2705bd8deadSopenharmony_ci uint w1 = texel_group.z * granularity_z; 2715bd8deadSopenharmony_ci uint w2 = w1 + granularity_z - 1; 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci As in the two-dimensional logic, <granularity_x>, <granularity_y>, and 2745bd8deadSopenharmony_ci <granularity_z> refer to the texel group size as in Table X.1. 2755bd8deadSopenharmony_ci result.anchor and result.offset specify the <anchor> and <offset> 2765bd8deadSopenharmony_ci members of the returned structure, and <x>, <y>, and <z> specify the 2775bd8deadSopenharmony_ci texel group number in the neighborhood. 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci Each bit in the <mask> member of the returned structure corresponds to 2805bd8deadSopenharmony_ci one of the texel groups in the 4x4x4 neighborhood. That bit will be set 2815bd8deadSopenharmony_ci if and only if any of the texels in the texel group is covered by the 2825bd8deadSopenharmony_ci footprint. The texel group (x,y,z) is considered to be covered if and 2835bd8deadSopenharmony_ci only if the following logic computes true for <covered>: 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci uint64_t mask = result.mask.x | (result.mask.y << 32); 2865bd8deadSopenharmony_ci uint32_t bit = z * 16 + y * 4 + x; 2875bd8deadSopenharmony_ci bool covered = (0 != ((mask >> bit) & 1)); 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ci In most cases, the texel group sizes used by the footprint query will 2905bd8deadSopenharmony_ci match the value passed to the query, as interpreted according to Table 2915bd8deadSopenharmony_ci X.1. However, in some cases, the footprint may be too large to be 2925bd8deadSopenharmony_ci expressed as a collection of 8x8 or 4x4x4 set of texel groups using the 2935bd8deadSopenharmony_ci requested granularity. In this case, the implementation uses a texel 2945bd8deadSopenharmony_ci group size that is larger than the requested granularity. If a larger 2955bd8deadSopenharmony_ci texel group size is used, the implementation will return the texel group 2965bd8deadSopenharmony_ci size used in the <granularity> member of the footprint structure, which 2975bd8deadSopenharmony_ci should also be interpreted according to Table X.1. If the requested 2985bd8deadSopenharmony_ci texel group size is used, the implementation will return zero in 2995bd8deadSopenharmony_ci <granularity>. The texel group size will only be increased by the 3005bd8deadSopenharmony_ci implementation if anisotropic filtering is used. If the texture and 3015bd8deadSopenharmony_ci sampler objects used by the footprint query do not enable anisotropic 3025bd8deadSopenharmony_ci texture filtering, the footprint query will always use the original 3035bd8deadSopenharmony_ci requested granularity and return zero in the <granularity> member. 3045bd8deadSopenharmony_ci 3055bd8deadSopenharmony_ciErrors 3065bd8deadSopenharmony_ci 3075bd8deadSopenharmony_ci None 3085bd8deadSopenharmony_ci 3095bd8deadSopenharmony_ciNew State 3105bd8deadSopenharmony_ci 3115bd8deadSopenharmony_ci None 3125bd8deadSopenharmony_ci 3135bd8deadSopenharmony_ciNew Implementation Dependent State 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci None 3165bd8deadSopenharmony_ci 3175bd8deadSopenharmony_ciIssues 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ci None, but please refer to issues in the GLSL extension specification. 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ciRevision History 3225bd8deadSopenharmony_ci 3235bd8deadSopenharmony_ci Revision 2 (pknowles) 3245bd8deadSopenharmony_ci - Add ES interactions. 3255bd8deadSopenharmony_ci 3265bd8deadSopenharmony_ci Revision 1 (clentini, pbrown) 3275bd8deadSopenharmony_ci - Internal revisions. 328