15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_texture_query_lod
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_texture_query_lod
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Eric Werness, NVIDIA Corporation (ewerness 'at' nvidia.com)
125bd8deadSopenharmony_ci    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ciContributors
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Pat Brown, NVIDIA
175bd8deadSopenharmony_ci    Greg Roth, NVIDIA
185bd8deadSopenharmony_ci    Eric Werness, NVIDIA
195bd8deadSopenharmony_ci    Alejandro Piñeiro, Igalia, SL
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciNotice
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    Copyright (c) 2009-2013 The Khronos Group Inc. Copyright terms at
245bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ciSpecification Update Policy
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
295bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
305bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
315bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
325bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
335bd8deadSopenharmony_ci    described in more detail at
345bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ciStatus
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    Complete. Approved by the ARB on July 3, 2009.
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ciVersion
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    Last Modified Date:         04/22/2020
435bd8deadSopenharmony_ci    Revision:                   8
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ciNumber
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    ARB Extension #73
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ciDependencies
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    OpenGL 3.0 is required.
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    OpenGL Shading Language 1.30 is required
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    EXT_gpu_shader4 is required.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    EXT_texture_array is required.
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    This extension interacts trivially with ARB_texture_cube_map_array
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    This extension is written against the OpenGL 2.0 specification and
625bd8deadSopenharmony_ci    version 1.30 of the OpenGL Shading Language Specification.
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ciOverview
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    This extension provides a new set of fragment shader texture
675bd8deadSopenharmony_ci    functions (textureLOD) that return the results of automatic
685bd8deadSopenharmony_ci    level-of-detail computations that would be performed if a texture
695bd8deadSopenharmony_ci    lookup were performed.
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ciNew Procedures and Functions
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    None.
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ciNew Tokens
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    None.
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation)
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    None.
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization)
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci    None.
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment
885bd8deadSopenharmony_ciOperations and the Frame Buffer)
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    None.
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions)
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ci    None.
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.0 Specification (State and
975bd8deadSopenharmony_ciState Requests)
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci    None.
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci    None
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ciGLX Protocol
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ci    TBD
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ciErrors
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    None.
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ciNew State
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    None.
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ciNew Implementation Dependent State
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    None.
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ciModifications to The OpenGL Shading Language Specification, Version 1.10.59
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
1245bd8deadSopenharmony_ci    language features described in this extension:
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci      #extension GL_ARB_texture_query_lod
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci    A new preprocessor #define is added to the OpenGL Shading Language:
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci      #define GL_ARB_texture_query_lod 1
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci    Add to section 8.7 "Texture Lookup Functions"
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci    Syntax:
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsampler1D sampler, float coord)
1375bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsampler2D sampler, vec2 coord)
1385bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsampler3D sampler, vec3 coord)
1395bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsamplerCube sampler, vec3 coord)
1405bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsampler1DArray sampler, float coord)
1415bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsampler2DArray sampler, vec2 coord)
1425bd8deadSopenharmony_ci      vec2 textureQueryLOD(gsamplerCubeArray sampler, vec3 coord)
1435bd8deadSopenharmony_ci      vec2 textureQueryLOD(sampler1DShadow sampler, float coord)
1445bd8deadSopenharmony_ci      vec2 textureQueryLOD(sampler2DShadow sampler, vec2 coord)
1455bd8deadSopenharmony_ci      vec2 textureQueryLOD(samplerCubeShadow sampler, vec3 coord)
1465bd8deadSopenharmony_ci      vec2 textureQueryLOD(sampler1DArrayShadow sampler, float coord)
1475bd8deadSopenharmony_ci      vec2 textureQueryLOD(sampler2DArrayShadow sampler, vec2 coord)
1485bd8deadSopenharmony_ci      vec2 textureQueryLOD(samplerCubeArrayShadow sampler, vec3 coord)
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ci    Description:
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci      The textureQueryLOD function takes the components of <coord> and
1535bd8deadSopenharmony_ci      computes the LOD information that the texture pipe would use to
1545bd8deadSopenharmony_ci      make an access of that texture. The computed level of detail
1555bd8deadSopenharmony_ci      lambda_prime (equation 3.19), relative to the base level, is
1565bd8deadSopenharmony_ci      returned in the y component of the result vector. The level of
1575bd8deadSopenharmony_ci      detail is obtained after any LOD bias, but prior to clamping to
1585bd8deadSopenharmony_ci      [TEXTURE_MIN_LOD, TEXTURE_MAX_LOD]. The x component of the result
1595bd8deadSopenharmony_ci      vector contains information on the mipmap array(s) that would be
1605bd8deadSopenharmony_ci      accessed by a normal texture lookup using the same coordinates. If
1615bd8deadSopenharmony_ci      a single level of detail would be accessed, the level-of-detail
1625bd8deadSopenharmony_ci      number relative to the base level is returned. If multiple levels
1635bd8deadSopenharmony_ci      of detail are accessed, a floating-point number between the two
1645bd8deadSopenharmony_ci      levels is returned, with the fractional part equal to the
1655bd8deadSopenharmony_ci      fractional part of the computed and clamped level of detail. The
1665bd8deadSopenharmony_ci      algorithm used is given by the following pseudo-code:
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci      float ComputeAccessedLod(float computedLod)
1695bd8deadSopenharmony_ci      {
1705bd8deadSopenharmony_ci        // Clamp the computed LOD according to the texture LOD clamps.
1715bd8deadSopenharmony_ci        if (computedLod < TEXTURE_MIN_LOD) computedLod = TEXTURE_MIN_LOD;
1725bd8deadSopenharmony_ci        if (computedLod > TEXTURE_MAX_LOD) computedLod = TEXTURE_MAX_LOD;
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci        // Clamp the computed LOD to the range of accessible levels.
1755bd8deadSopenharmony_ci        if (computedLod < 0)
1765bd8deadSopenharmony_ci            computedLod = 0.0;
1775bd8deadSopenharmony_ci        if (computedLod > (float)
1785bd8deadSopenharmony_ci            maxAccessibleLevel) computedLod = (float) maxAccessibleLevel;
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci        // Return a value according to the min filter.
1815bd8deadSopenharmony_ci        if (TEXTURE_MIN_FILTER is LINEAR or NEAREST) {
1825bd8deadSopenharmony_ci          return 0.0;
1835bd8deadSopenharmony_ci        } else if (TEXTURE_MIN_FILTER is NEAREST_MIPMAP_NEAREST
1845bd8deadSopenharmony_ci                   or LINEAR_MIPMAP_NEAREST) {
1855bd8deadSopenharmony_ci          return ceil(computedLod + 0.5) - 1.0;
1865bd8deadSopenharmony_ci        } else {
1875bd8deadSopenharmony_ci          return computedLod;
1885bd8deadSopenharmony_ci        }
1895bd8deadSopenharmony_ci      }
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ci      The value <maxAccessibleLevel> is the level number of the smallest
1925bd8deadSopenharmony_ci      accessible level of the mipmap array (the value q in section
1935bd8deadSopenharmony_ci      3.8.8) minus the base level.
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci      The returned value is then:
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci        vec2(ComputeAccessedLod(lambda_prime), lambda_prime);
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ci      If textureQueryLOD is called on an incomplete texture, the results
2005bd8deadSopenharmony_ci      are undefined. textureQueryLOD is only available fragment shaders.
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ciDependencies on ARB_texture_cube_map_array
2035bd8deadSopenharmony_ci
2045bd8deadSopenharmony_ci      If ARB_texture_cube_map_array is not supported, remove the
2055bd8deadSopenharmony_ci      textureQueryLOD lookup functions taking cube map array samplers.
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ciIssues
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    (1) Should we provide texture LOD functions for shadow sampler
2105bd8deadSopenharmony_ci        targets?
2115bd8deadSopenharmony_ci
2125bd8deadSopenharmony_ci      RESOLVED: Yes. The level of detail computations for a texture used
2135bd8deadSopenharmony_ci      as a shadow map are completely identical to that for other
2145bd8deadSopenharmony_ci      textures.
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci      However, we provide separate data types for the two textures
2175bd8deadSopenharmony_ci      (e.g., sampler2D vs. sampler2DShadow), and there is no mechanism
2185bd8deadSopenharmony_ci      to cast from one to the other. If we didn't provide these
2195bd8deadSopenharmony_ci      functions, the only way to perform an LOD computation for a
2205bd8deadSopenharmony_ci      texture used as a shadow map would be to bind the same texture
2215bd8deadSopenharmony_ci      object to two different texture image units, one associated with a
2225bd8deadSopenharmony_ci      shadow sampler and the other associated with a normal sampler.
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci      Unlike regular shadow texture lookups, the reference depth value
2255bd8deadSopenharmony_ci      is not used for LOD calculations and is not accepted by the
2265bd8deadSopenharmony_ci      corresponding textureQueryLOD() built-infunctions.
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    (2) Should LOD queries for array textures take a layer?
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci      RESOLVED: No. The layer number has no effect on the LOD
2315bd8deadSopenharmony_ci      calcuations, so can be safely ignored. As a result, LOD queries
2325bd8deadSopenharmony_ci      for sampler1DArray, sampler2DArray, and samplerCubeArray samplers
2335bd8deadSopenharmony_ci      take one, two, and three coordinates, respectively.
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ci    (3) The core specification uses the "Lod" spelling, not "LOD". Should
2365bd8deadSopenharmony_ci        this extension be modified to use "Lod"?
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci      RESOLVED: The "Lod" spelling is the correct spelling for the core
2395bd8deadSopenharmony_ci      specification and the preferred spelling for use. However, use of
2405bd8deadSopenharmony_ci      "LOD" also exists, as the extension predated the core specification,
2415bd8deadSopenharmony_ci      so this extension won't remove use of "LOD".
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ciRevision History
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
2465bd8deadSopenharmony_ci    ----  ----------  --------  -----------------------------------------
2475bd8deadSopenharmony_ci    8     04/22/2020  apinheiro Update OpenGL version required, to be
2485bd8deadSopenharmony_ci                                consistent with GLSL version required (internal API
2495bd8deadSopenharmony_ci                                issue 124)
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ci    7     04/10/2013  Jon Leech Add issue 3 regarding different spelling
2525bd8deadSopenharmony_ci                                of "LOD" vs. "Lod" in extension & core.
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci    6     08/02/2009  Jon Leech Reformat to 80 columns and assign ARB
2555bd8deadSopenharmony_ci                                extension number.
2565bd8deadSopenharmony_ci
2575bd8deadSopenharmony_ci    5     07/14/2009  istewart  Fixed preprocessor define and pseudocode for
2585bd8deadSopenharmony_ci                                ComputeAccessedLod.
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    4     06/26/2009  pbrown    Change prototype for textureQueryLOD for
2615bd8deadSopenharmony_ci                                1D and 2D arrays to not take a layer.
2625bd8deadSopenharmony_ci                                Cube map arrays already didn't take a layer.
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ci    3     06/25/2009  groth     Rename extension to ARB_texture_query_lod.
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    2     06/23/2009  groth     correct filtering mode conditional in psuedocode
2675bd8deadSopenharmony_ci
2685bd8deadSopenharmony_ci    1     05/13/2009  groth     Split off of gpu_shader4_1
269