15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_polygon_offset_clamp
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_polygon_offset_clamp
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Eric Lengyel (lengyel 'at' terathon.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Eric Lengyel, Terathon Software
165bd8deadSopenharmony_ci    Tobias Hector, Imagination Technologies
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciStatus
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Complete.
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciVersion
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Last Modified Date: February 11, 2016
255bd8deadSopenharmony_ci    Revision: 4
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciNumber
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    OpenGL Extension #460
305bd8deadSopenharmony_ci    OpenGL ES Extension #252
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ciDependencies
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ci    OpenGL 3.3 (either core or compatibility profiles), or OpenGL ES 1.0 is
355bd8deadSopenharmony_ci    required.
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    This extension is written against the OpenGL 3.3 (Core Profile)
385bd8deadSopenharmony_ci    Specification (March 11, 2010) and the OpenGL ES 3.1 Specification (October
395bd8deadSopenharmony_ci    29, 2014).
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciOverview
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    This extension adds a new parameter to the polygon offset function
445bd8deadSopenharmony_ci    that clamps the calculated offset to a minimum or maximum value.
455bd8deadSopenharmony_ci    The clamping functionality is useful when polygons are nearly
465bd8deadSopenharmony_ci    parallel to the view direction because their high slopes can result
475bd8deadSopenharmony_ci    in arbitrarily large polygon offsets. In the particular case of
485bd8deadSopenharmony_ci    shadow mapping, the lack of clamping can produce the appearance of
495bd8deadSopenharmony_ci    unwanted holes when the shadow casting polygons are offset beyond
505bd8deadSopenharmony_ci    the shadow receiving polygons, and this problem can be alleviated by
515bd8deadSopenharmony_ci    enforcing a maximum offset value.
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ciIP Status
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    No known IP claims.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ciNew Procedures and Functions
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    void PolygonOffsetClampEXT(float factor, float units, float clamp);
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ciNew Tokens
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ci    Accepted by the <pname> parameters of GetBooleanv, GetIntegerv,
645bd8deadSopenharmony_ci    GetInteger64v, GetFloatv, and GetDoublev:
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci        POLYGON_OFFSET_CLAMP_EXT                0x8E1B
675bd8deadSopenharmony_ci
685bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 3.3 (Core Profile) Specification
695bd8deadSopenharmony_ci(Rasterization), and Chapter 13 of the OpenGL ES Specification (Polygons)
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci -- Modify Open GL section 3.6.4 and OpenGL ES section 13.5.2, "Depth Offset"
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    Replace the 1st paragraph...
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci    "The depth values of all fragments generated by the rasterization of
765bd8deadSopenharmony_ci    a polygon may be offset by a single value that is computed for that
775bd8deadSopenharmony_ci    polygon. The function that determines this value is specified with
785bd8deadSopenharmony_ci    the commands
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci     void PolygonOffsetClampEXT(float factor, float units, float clamp);
815bd8deadSopenharmony_ci     void PolygonOffset(float factor, float units);
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    <factor> scales the maximum depth slope of the polygon, and <units>
845bd8deadSopenharmony_ci    scales an implementation-dependent constant that relates to the
855bd8deadSopenharmony_ci    usable resolution of the depth buffer. The resulting values are
865bd8deadSopenharmony_ci    summed to produce the polygon offset value, which may then be
875bd8deadSopenharmony_ci    clamped to a minimum or maximum value specified by <clamp>. The
885bd8deadSopenharmony_ci    values <factor>, <units>, and <clamp> may each be positive,
895bd8deadSopenharmony_ci    negative, or zero. Calling the command PolygonOffset is equivalent
905bd8deadSopenharmony_ci    to calling the command PolygonOffsetClampEXT with <clamp> equal to
915bd8deadSopenharmony_ci    zero."
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci    Replace the 5th paragraph...
945bd8deadSopenharmony_ci
955bd8deadSopenharmony_ci    "The offset value o for a polygon is
965bd8deadSopenharmony_ci          _
975bd8deadSopenharmony_ci         |   m x <factor> + r x <units>,          if <clamp> = 0 or NaN;
985bd8deadSopenharmony_ci         |
995bd8deadSopenharmony_ci    o = <    min(m x <factor> + r x <units>, <clamp>),   if <clamp> > 0;
1005bd8deadSopenharmony_ci         |
1015bd8deadSopenharmony_ci         |_  max(m x <factor> + r x <units>, <clamp>),   if <clamp> < 0.
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci    m is computed as described above. If the depth buffer uses a fixed-
1045bd8deadSopenharmony_ci    point representation, m is a function of depth values in the range
1055bd8deadSopenharmony_ci    [0, 1], and o is applied to depth values in the same range."
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ci    None
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ciGLX Protocol
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci    A new GL rendering command is added. The following command is sent
1145bd8deadSopenharmony_ci    to the server as part of a glXRender request:
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci        PolygonOffsetClampEXT
1175bd8deadSopenharmony_ci            2           16              rendering command length
1185bd8deadSopenharmony_ci            2           4225            rendering command opcode
1195bd8deadSopenharmony_ci            4           FLOAT32         factor
1205bd8deadSopenharmony_ci            4           FLOAT32         units
1215bd8deadSopenharmony_ci            4           FLOAT32         clamp
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ciErrors
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci    None
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ciNew State (OpenGL)
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci    Get Value                Type  Get Command  Initial Value  Description           Sec    Attrib
1305bd8deadSopenharmony_ci    ------------------------ ----  -----------  -------------  --------------------  -----  -------
1315bd8deadSopenharmony_ci    POLYGON_OFFSET_CLAMP_EXT  R    GetFloatv          0        Polygon offset clamp  3.6.4  polygon
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ciNew State (OpenGL ES)
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ci    Add the following to Table 20.6: Rasterization
1365bd8deadSopenharmony_ci
1375bd8deadSopenharmony_ci    Get Value                Type  Get Command  Initial Value  Description           Sec
1385bd8deadSopenharmony_ci    ------------------------ ----  -----------  -------------  --------------------  ------
1395bd8deadSopenharmony_ci    POLYGON_OFFSET_CLAMP_EXT  R    GetFloatv          0        Polygon offset clamp  13.5.2
1405bd8deadSopenharmony_ci
1415bd8deadSopenharmony_ciNew Implementation Dependent State
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci    None
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_ciIssues
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci    1)  Should the PolygonOffsetClampEXT command specify only the <clamp>
1485bd8deadSopenharmony_ci        parameter, or should it specify all three of the parameters
1495bd8deadSopenharmony_ci        <factor>, <units>, and <clamp>?
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci        Defining a new command that specifies new state in addition to
1525bd8deadSopenharmony_ci        state that can be specified with an existing command has a
1535bd8deadSopenharmony_ci        precedent in the BlendFuncSeparate command. The argument can be
1545bd8deadSopenharmony_ci        made that an application would usually want to set the <factor>
1555bd8deadSopenharmony_ci        and <units> values at the same time it sets the <clamp> value,
1565bd8deadSopenharmony_ci        and making one GL call is better than making two GL calls.
1575bd8deadSopenharmony_ci        Furthermore, requiring that a call to PolygonOffset sets
1585bd8deadSopenharmony_ci        POLYGON_OFFSET_CLAMP_EXT to zero insulates applications unaware
1595bd8deadSopenharmony_ci        of the new state from failures to restore it to its initial
1605bd8deadSopenharmony_ci        value in separate libraries, and this cannot be done if an
1615bd8deadSopenharmony_ci        orthogonal command specifying only the <clamp> value were to be
1625bd8deadSopenharmony_ci        defined.
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci        RESOLVED: This extension defines a new command that specifies
1655bd8deadSopenharmony_ci        the <factor>, <units>, and <clamp> parameters.
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    2)  What happens if <clamp> is infinity or NaN?
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci        As per Section 2.1, the result of providing an infinity or NaN
1705bd8deadSopenharmony_ci        is unspecified. However, if <clamp> is positive or negative
1715bd8deadSopenharmony_ci        infinity, then Equation (3.13), in the literal mathematical
1725bd8deadSopenharmony_ci        sense, is effectively reduced to the case in which no clamping
1735bd8deadSopenharmony_ci        occurs, and this should be the defined behavior.
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci        If <clamp> is a floating-point NaN, then we could leave the
1765bd8deadSopenharmony_ci        result undefined, but that could lead to application code
1775bd8deadSopenharmony_ci        working correctly with one implementation and then inexplicably
1785bd8deadSopenharmony_ci        failing with another. It would be better to define the behavior
1795bd8deadSopenharmony_ci        such that no clamping occurs. If this is not the behavior
1805bd8deadSopenharmony_ci        exhibited by the hardware, then the implementation can turn all
1815bd8deadSopenharmony_ci        infinites and NaNs into zero using the following code:
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ci            int32_t clampBits = *(int32_t *) &clamp;
1845bd8deadSopenharmony_ci            clampBits &= (((clampBits >> 23) & 0xFF) - 0xFF) >> 31;
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ci        This ANDs with all one bits if and only if the floating-point
1875bd8deadSopenharmony_ci        exponent is less than 255. Otherwise, it ANDs with all zero
1885bd8deadSopenharmony_ci        bits. (This assumes a well-defined right shift of negative
1895bd8deadSopenharmony_ci        integers.)
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ci        RESOLVED: If <clamp> is infinity or NaN, then no clamping is
1925bd8deadSopenharmony_ci        applied to the polygon offset.
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ci    3)  What happens if <clamp> is a denormalized floating-point value?
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ci        As per Section 2.1, the result of providing a denormalized value
1975bd8deadSopenharmony_ci        must yield predictable results. However, some implementations
1985bd8deadSopenharmony_ci        may treat denormalized values as equal to zero, and other
1995bd8deadSopenharmony_ci        implementations may treat them as greater than or less than
2005bd8deadSopenharmony_ci        zero. To ensure uniform behavior across all implementations, we
2015bd8deadSopenharmony_ci        can require that denormalized values not be equal to zero. This
2025bd8deadSopenharmony_ci        may necessitate that implementations convert denormalized values
2035bd8deadSopenharmony_ci        to the smallest representable normalized value with the same
2045bd8deadSopenharmony_ci        sign.
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci        RESOLVED: Denormalized values are not considered equal to zero
2075bd8deadSopenharmony_ci        in Equation (3.13).
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ciRevision History
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci    Rev.    Date    Author     Changes
2125bd8deadSopenharmony_ci    ----  -------- ---------  ------------------------------------------
2135bd8deadSopenharmony_ci    4     02/11/16  thector    Fixed an incorrect vendor suffix (was IMG)
2145bd8deadSopenharmony_ci    3     10/21/15  thector    Added OpenGL ES interactions.
2155bd8deadSopenharmony_ci    2     08/27/14  elengyel   Added enum value for new token, resolved
2165bd8deadSopenharmony_ci                               issues, changed status to complete.
2175bd8deadSopenharmony_ci    1     08/14/14  elengyel   Initial draft.
218