15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_clip_control
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_clip_control
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Timo Suoranta, Broadcom
165bd8deadSopenharmony_ci    Piers Daniell, NVIDIA
175bd8deadSopenharmony_ci    Stefan Dösinger, CodeWeavers
185bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA
195bd8deadSopenharmony_ci    John McDonald, NVIDIA
205bd8deadSopenharmony_ci    Brian Paul, VMware, Mesa3D
215bd8deadSopenharmony_ci    Jason Mitchell, Valve
225bd8deadSopenharmony_ci    Alex Corscadden, VMware
235bd8deadSopenharmony_ci    Simon Bennett, VMware
245bd8deadSopenharmony_ci    Mark Callow, HI Corporation
255bd8deadSopenharmony_ci    Patrick Doane, Blizzard
265bd8deadSopenharmony_ci    Pat Brown, NVIDIA
275bd8deadSopenharmony_ci    Brano Kemen
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciNotice
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    Copyright (c) 2014 The Khronos Group Inc. Copyright terms at
325bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciSpecification Update Policy
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
375bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
385bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
395bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
405bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
415bd8deadSopenharmony_ci    described in more detail at
425bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ciStatus
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    Complete.
475bd8deadSopenharmony_ci    Approved by the ARB on June 26, 2014.
485bd8deadSopenharmony_ci    Ratified by the Khronos Board of Promoters on August 7, 2014.
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ciVersion
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    Last Modified Date:  2018/04/06
535bd8deadSopenharmony_ci    NVIDIA Revision:     19
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ciNumber
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    ARB Extension #160
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ciDependencies
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    Written based on the wording of the OpenGL 4.4 (Compatibility Profile)
625bd8deadSopenharmony_ci    specification.
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ciOverview
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    This extension provides additional clip control modes to configure how
675bd8deadSopenharmony_ci    clip space is mapped to window space.  This extension's goal is to 1)
685bd8deadSopenharmony_ci    allow OpenGL to effectively match Direct3D's coordinate system
695bd8deadSopenharmony_ci    conventions, and 2) potentially improve the numerical precision of the Z
705bd8deadSopenharmony_ci    coordinate mapping.
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    Developers interested in this functionality may be porting content
735bd8deadSopenharmony_ci    from Direct3D to OpenGL and/or interested in improving the numerical
745bd8deadSopenharmony_ci    accuracy of depth testing, particularly with floating-point depth
755bd8deadSopenharmony_ci    buffers.
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    OpenGL's initial and conventional clip control state is configured by:
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci        glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    where geometry with (x,y) normalized device coordinates of (-1,-1)
825bd8deadSopenharmony_ci    correspond to the lower-left corner of the viewport and the near and far
835bd8deadSopenharmony_ci    planes correspond to z normalized device coordinates of -1 and +1,
845bd8deadSopenharmony_ci    respectively.
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ci    This extension can be used to render content used in a Direct3D
875bd8deadSopenharmony_ci    application in OpenGL in a straightforward way without modifying vertex or
885bd8deadSopenharmony_ci    matrix data.  When rendering into a window, the command
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci        glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    configures the near clip plane to correspond to a z normalized device
935bd8deadSopenharmony_ci    coordinate of 0 as in Direct3D.  Geometry with (x,y) normalized device
945bd8deadSopenharmony_ci    coordinates of (-1,-1) correspond to the lower-left corner of the viewport
955bd8deadSopenharmony_ci    in Direct3D, so no change relative to OpenGL conventions is needed there.
965bd8deadSopenharmony_ci    Other state related to screen-space coordinates may need to be modified
975bd8deadSopenharmony_ci    for the application to map from Direct3D to OpenGL window coordinate
985bd8deadSopenharmony_ci    conventions.  For example, the viewport rectangle in Direct3D needs to be
995bd8deadSopenharmony_ci    inverted within the window to work properly in OpenGL windowed rendering:
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci       glViewport(d3d_viewport_x,
1025bd8deadSopenharmony_ci                  window_height - (d3d_viewport_y + d3d_viewport_height),
1035bd8deadSopenharmony_ci                  d3d_viewport_width, d3d_viewport_height);
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    When rendering Direct3D content into a framebuffer object in OpenGL, there
1065bd8deadSopenharmony_ci    is one complication -- how to get a correct image *out* of the related
1075bd8deadSopenharmony_ci    textures.  Direct3D applications would expect a texture coordinate of
1085bd8deadSopenharmony_ci    (0,0) to correspond to the upper-left corner of a rendered image, while
1095bd8deadSopenharmony_ci    OpenGL FBO conventions would map (0,0) to the lower-left corner of the
1105bd8deadSopenharmony_ci    rendered image.  For applications wishing to use Direct3D content with
1115bd8deadSopenharmony_ci    unmodified texture coordinates, the command
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci        glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE);
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    configures the OpenGL to invert geometry vertically inside the viewport.
1165bd8deadSopenharmony_ci    Content at the top of the viewport for Direct3D will be rendered to the
1175bd8deadSopenharmony_ci    bottom of the viewport from the point of view of OpenGL, but will have a
1185bd8deadSopenharmony_ci    <t> texture coordinate of zero in both cases.  When operating in this
1195bd8deadSopenharmony_ci    mode, applications need not invert the programmed viewport rectangle as
1205bd8deadSopenharmony_ci    recommended for windowed rendering above.
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ci    Applications happy with OpenGL's origin conventions but seeking
1235bd8deadSopenharmony_ci    potentially improved depth precision can configure clip controls using:
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci        glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci    to avoid the loss of precision from the DepthRange transformation
1285bd8deadSopenharmony_ci    (which by default is z_window = z_ndc * 0.5 + 0.5).
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ciNew Procedures and Functions
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci    void ClipControl(enum origin, enum depth);
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ciNew Tokens
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    Accepted by the <origin> parameter of ClipControl:
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci        LOWER_LEFT                                  0x8CA1
1395bd8deadSopenharmony_ci        UPPER_LEFT                                  0x8CA2
1405bd8deadSopenharmony_ci
1415bd8deadSopenharmony_ci    Accepted by the <depth> parameter of ClipControl:
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci        NEGATIVE_ONE_TO_ONE                         0x935E
1445bd8deadSopenharmony_ci        ZERO_TO_ONE                                 0x935F
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
1475bd8deadSopenharmony_ci    GetFloatv, and GetDoublev:
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci        CLIP_ORIGIN                                 0x935C
1505bd8deadSopenharmony_ci        CLIP_DEPTH_MODE                             0x935D
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ciAdditions to Chapter 13 of the OpenGL 4.4 (Compatibility Profile)
1535bd8deadSopenharmony_ciSpecification (Fixed-Function Vertex Post-Processing)
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci -- Modify section 13.5 "Primitive Clipping"
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    Insert before the 1st paragraph...
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci    "The command
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci        ClipControl(enum origin, enum depth);
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    controls the clipping volume behavior.  /origin/ must be either
1645bd8deadSopenharmony_ci    LOWER_LEFT or UPPER_LEFT, otherwise the error INVALID_ENUM is
1655bd8deadSopenharmony_ci    generated.  /depth/ must be either NEGATIVE_ONE_TO_ONE or
1665bd8deadSopenharmony_ci    ZERO_TO_ONE, otherwise the error INVALID_ENUM is generated.
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci      These parameters update the clip control origin and
1695bd8deadSopenharmony_ci    depth mode respectively.  The state required for clip control is one
1705bd8deadSopenharmony_ci    bit for clip control origin and one bit for clip control depth mode.
1715bd8deadSopenharmony_ci    The initial value of the clip control origin is LOWER_LEFT and the
1725bd8deadSopenharmony_ci    initial value of the depth mode is NEGATIVE_ONE_TO_ONE.
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci      The error INVALID_OPERATION is generated if ClipControl is
1755bd8deadSopenharmony_ci    executed between the execution of Begin and the corresponding
1765bd8deadSopenharmony_ci    execution of End."
1775bd8deadSopenharmony_ci
1785bd8deadSopenharmony_ci    Replace the first paragraph with...
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci    "Primitives are clipped to the clip volume. In clip coordinates,
1815bd8deadSopenharmony_ci    the view volume is defined by
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ci        -w_c <= x_c <= w_c
1845bd8deadSopenharmony_ci        -w_c <= y_c <= w_c
1855bd8deadSopenharmony_ci          zm <= z_c <= w_c
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci     where zm is -w_c when the clip control depth mode is
1885bd8deadSopenharmony_ci     NEGATIVE_ONE_TO_ONE or zero when the mode is ZERO_TO_ONE."
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci     Change the last sentence of the 7th paragraph to read...
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci     "If depth clamping is enabled, the
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ci        zm <= z_c <= w_c
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ci      plane equation (see the clip volume definition) is ignored by
1975bd8deadSopenharmony_ci      view volume clipping (effectively, there is no near or far plane
1985bd8deadSopenharmony_ci      clipping)."
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci -- Modify section 13.6 "Coordinate Transformations"
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ci    Replace the 3rd paragraph with (where ^T means transpose):
2035bd8deadSopenharmony_ci
2045bd8deadSopenharmony_ci    "If a vertex in clip coordinates is given by (x_c y_c z_c w_c)^T
2055bd8deadSopenharmony_ci    then the vertex's normalized device coordinates are (x_d y_d z_d)^T =
2065bd8deadSopenharmony_ci    (x_c/w_c f*y_c/w_c z_c/w_c)^T where /f/ is +1 when the clip control
2075bd8deadSopenharmony_ci    origin is LOWER_LEFT and -1 when the origin is UPPER_LEFT."
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci -- Modify section 13.6.1 "Controlling the Viewport"
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci    Replace the 2nd sentence of the 1st paragraph with (where ^T means
2125bd8deadSopenharmony_ci    transpose):
2135bd8deadSopenharmony_ci
2145bd8deadSopenharmony_ci    "The vertex's window coordinates, (x_w y_w z_w)^T are given by:
2155bd8deadSopenharmony_ci
2165bd8deadSopenharmony_ci        ( x_w )     ( p_x/2 x_d + o_x )
2175bd8deadSopenharmony_ci        ( y_w )  =  ( p_y/2 y_d + o_y )
2185bd8deadSopenharmony_ci        ( z_w )     (     s z_d + b   )
2195bd8deadSopenharmony_ci
2205bd8deadSopenharmony_ci    where s is (f-n)/2 and b is (n+f)/2 when the clip control depth mode
2215bd8deadSopenharmony_ci    is NEGATIVE_ONE_TO_ONE; or s is (f-n) and b is n when the mode
2225bd8deadSopenharmony_ci    is ZERO_TO_ONE."
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ciAdditions to Chapter 14 of the OpenGL 4.4 (Compatibility Profile)
2255bd8deadSopenharmony_ciSpecification (Fixed-Function Primitive Assembly and Rasterization)
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci -- Modify section 14.6.1 "Basic Polygon Rasterization"
2285bd8deadSopenharmony_ci
2295bd8deadSopenharmony_ci    Replace the 3rd sentence of the 1st paragraph with:
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ci    "One way to compute this area is
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci               n-1
2345bd8deadSopenharmony_ci               ___
2355bd8deadSopenharmony_ci               \
2365bd8deadSopenharmony_ci      a = 1/2 f \  x^i_w * y^i(+)1_w - x^i(+)1_w * y^i_w
2375bd8deadSopenharmony_ci                /
2385bd8deadSopenharmony_ci               /__
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci    where f is +1 when the clip control origin is LOWER_LEFT and -1 when
2415bd8deadSopenharmony_ci    the origin is UPPER_LEFT, x^i_w and y^i_w are the x and y window
2425bd8deadSopenharmony_ci    coordinates of the ith vertex of the n-vertex polygon (vertices
2435bd8deadSopenharmony_ci    are numbered starting at zero for purposes of this computation),
2445bd8deadSopenharmony_ci    and i(+)1 is (i+1) mod n."
2455bd8deadSopenharmony_ci
2465bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
2475bd8deadSopenharmony_ci
2485bd8deadSopenharmony_ci    None
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ciGLX Protocol
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci    A new GL rendering command is added. The following command is sent to the
2535bd8deadSopenharmony_ci    server as part of a glXRender request:
2545bd8deadSopenharmony_ci
2555bd8deadSopenharmony_ci        ClipControl
2565bd8deadSopenharmony_ci            2           12              rendering command length
2575bd8deadSopenharmony_ci            2           1340            rendering command opcode
2585bd8deadSopenharmony_ci            4           ENUM            origin
2595bd8deadSopenharmony_ci            4           ENUM            depth
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ciErrors
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci    The error INVALID_ENUM is generated by ClipControl if origin is not
2645bd8deadSopenharmony_ci    LOWER_LEFT or UPPER_LEFT.
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    The error INVALID_ENUM is generated by ClipControl if depth is not
2675bd8deadSopenharmony_ci    NEGATIVE_ONE_TO_ONE or ZERO_TO_ONE.
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    The error INVALID_OPERATION is generated if ClipControl is executed
2705bd8deadSopenharmony_ci    between the execution of Begin and the corresponding execution of
2715bd8deadSopenharmony_ci    End.
2725bd8deadSopenharmony_ci
2735bd8deadSopenharmony_ciNew State
2745bd8deadSopenharmony_ci
2755bd8deadSopenharmony_ci    Get Value         Type  Get Command  Initial Value        Description      Sec   Attribute
2765bd8deadSopenharmony_ci    ----------------  ----  -----------  -------------------  ---------------  ----  ---------
2775bd8deadSopenharmony_ci    CLIP_ORIGIN       Z2    GetIntegerv  LOWER_LEFT           Clip origin      13.5  xform
2785bd8deadSopenharmony_ci    CLIP_DEPTH_MODE   Z2    GetIntegerv  NEGATIVE_ONE_TO_ONE  Clip depth mode  13.5  xform
2795bd8deadSopenharmony_ci
2805bd8deadSopenharmony_ciNew Implementation Dependent State
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ci    None
2835bd8deadSopenharmony_ci
2845bd8deadSopenharmony_ciIssues
2855bd8deadSopenharmony_ci
2865bd8deadSopenharmony_ci    1)  What should this extension be called?
2875bd8deadSopenharmony_ci
2885bd8deadSopenharmony_ci        RESOLVED:  ARB_clip_control
2895bd8deadSopenharmony_ci
2905bd8deadSopenharmony_ci        We frame this extension in terms of how the fixed-function
2915bd8deadSopenharmony_ci        transformation from clip coordinates to window coordinates
2925bd8deadSopenharmony_ci        is specified.  The crucial modifications to OpenGL's existing
2935bd8deadSopenharmony_ci        behavior involve controlling how clip space is interpreted.
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci        An upper-left origin is really simply negating (flipping) the
2965bd8deadSopenharmony_ci        clip space Y coordinate.  Subsequently the sense of counter-clockwise
2975bd8deadSopenharmony_ci        and clockwise for face culling must be adjusted (flipped).
2985bd8deadSopenharmony_ci
2995bd8deadSopenharmony_ci        A zero-to-one Z mode involves adjusting the clipping equation
3005bd8deadSopenharmony_ci        for the clip space Z coordinate.  Subsequently the depth range
3015bd8deadSopenharmony_ci        transform equation must be adjusted (scaled and biased).
3025bd8deadSopenharmony_ci
3035bd8deadSopenharmony_ci        Hence clip control is a sensible name.
3045bd8deadSopenharmony_ci
3055bd8deadSopenharmony_ci    2)  Should this functionality be exposed with glEnable/glDisable or
3065bd8deadSopenharmony_ci        with a new command.
3075bd8deadSopenharmony_ci
3085bd8deadSopenharmony_ci        RESOLVED:  With a new command, glClipControl.
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci        We note that this extension does not actually enable or disable
3115bd8deadSopenharmony_ci        functionality, but rather modifies an existing transformation.
3125bd8deadSopenharmony_ci
3135bd8deadSopenharmony_ci        We note that Direct3D is different in two ways: clip Y inversion
3145bd8deadSopenharmony_ci        and zero-to-one clip Z.
3155bd8deadSopenharmony_ci
3165bd8deadSopenharmony_ci        We note the difficulty of a clear enable name.
3175bd8deadSopenharmony_ci        GL_NEGATIVE_ONE_TO_ONE and GL_ZERO_TO_ONE
3185bd8deadSopenharmony_ci        are very explicit about how the Z clip coordinate is treated by
3195bd8deadSopenharmony_ci        the clip equations.  Likewise, GL_LOWER_LEFT and GL_UPPER_LEFT
3205bd8deadSopenharmony_ci        are explicit (and match the token names and meaning for the
3215bd8deadSopenharmony_ci        point sprite functionality).
3225bd8deadSopenharmony_ci
3235bd8deadSopenharmony_ci        We also note the possibility for other possible conventions.
3245bd8deadSopenharmony_ci        For example, an origin at the center of the window.  Hence an
3255bd8deadSopenharmony_ci        enumeration of clip modes is a better choice.  Likewise, a future
3265bd8deadSopenharmony_ci        Z mode could expose W-buffering.
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci    3)  Why does unextended OpenGL have symmetric clip equations?
3295bd8deadSopenharmony_ci
3305bd8deadSopenharmony_ci        RESOLVED:  This is a legacy of implementation worthy of some
3315bd8deadSopenharmony_ci        explanation...
3325bd8deadSopenharmony_ci
3335bd8deadSopenharmony_ci        Handling the X, Y, and Z directions the same way better
3345bd8deadSopenharmony_ci        facilitates vector operation for hardware efficiency.
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci        When transformations are done with 32-bit IEEE-754 floating-point
3375bd8deadSopenharmony_ci        values, after transformation to clip space for clipping, the
3385bd8deadSopenharmony_ci        Z values are typically converted to fixed-point for use by a
3395bd8deadSopenharmony_ci        conventional 24-bit fixed-point depth buffer.
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci        The process of scaling by 0.5 and adding 0.5 to a 32-bit
3425bd8deadSopenharmony_ci        floating-point number in the range [-1,+1] has the effect of
3435bd8deadSopenharmony_ci        appropriately rounding the value so it can be efficiently
3445bd8deadSopenharmony_ci        bit-shifted into a 24-bit fixed-point value in the [0,1]
3455bd8deadSopenharmony_ci        range suitable for depth buffering via linear fixed-point
3465bd8deadSopenharmony_ci        interpolation.
3475bd8deadSopenharmony_ci
3485bd8deadSopenharmony_ci    4)  Should the face culling behavior be modified in GL_UPPER_LEFT
3495bd8deadSopenharmony_ci        clip origin mode?
3505bd8deadSopenharmony_ci
3515bd8deadSopenharmony_ci        RESOLVED:  Yes.
3525bd8deadSopenharmony_ci
3535bd8deadSopenharmony_ci        See how the modifications to section 14.6.1 "Basic Polygon
3545bd8deadSopenharmony_ci        Rasterization" negate the sign of the polygon area when the clip
3555bd8deadSopenharmony_ci        control origin is GL_UPPER_LEFT.
3565bd8deadSopenharmony_ci
3575bd8deadSopenharmony_ci        Since culling behavior is specified as CW (clockwise) or CCW
3585bd8deadSopenharmony_ci        (counter-clockwise) different triangle faces would be culled
3595bd8deadSopenharmony_ci        when the clip origin is changed, which would be an unacceptable
3605bd8deadSopenharmony_ci        side effect.
3615bd8deadSopenharmony_ci
3625bd8deadSopenharmony_ci    5)  Are the projective matrices generated by glFrustum and glOrtho
3635bd8deadSopenharmony_ci        appropriate when the clip Z mode is GL_ZERO_TO_ONE?
3645bd8deadSopenharmony_ci
3655bd8deadSopenharmony_ci        RESOLVED:  No.
3665bd8deadSopenharmony_ci
3675bd8deadSopenharmony_ci    6)  Should the behavior of glFrustum and glOrtho change?
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci        RESOLVED:  No.
3705bd8deadSopenharmony_ci
3715bd8deadSopenharmony_ci        It's not worth encumbering these routines with adjustments,
3725bd8deadSopenharmony_ci        plus it is easy to make the proper adjustments...
3735bd8deadSopenharmony_ci
3745bd8deadSopenharmony_ci        Taking advantage of how matrix changes concatenate...
3755bd8deadSopenharmony_ci
3765bd8deadSopenharmony_ci        If your clip control origin is GL_UPPER_LEFT, prior to your
3775bd8deadSopenharmony_ci        glFrustum or glOrtho command by:
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci            glScalef(1,-1,1);
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci        If your clip control depth mode is GL_ZERO_TO_ONE, precede
3825bd8deadSopenharmony_ci        your glFrustum or glOrtho command by:
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ci            glTranslatef(0,0,0.5);
3855bd8deadSopenharmony_ci            glScalef(1,1,0.5);
3865bd8deadSopenharmony_ci
3875bd8deadSopenharmony_ci        For example, if your code to configure the projection matrix
3885bd8deadSopenharmony_ci        reads:
3895bd8deadSopenharmony_ci
3905bd8deadSopenharmony_ci            glMatrixMode(GL_PROJECTION);
3915bd8deadSopenharmony_ci            glLoadIdentity();
3925bd8deadSopenharmony_ci            glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3);
3935bd8deadSopenharmony_ci
3945bd8deadSopenharmony_ci        And you wanted to call:
3955bd8deadSopenharmony_ci
3965bd8deadSopenharmony_ci            glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE);
3975bd8deadSopenharmony_ci
3985bd8deadSopenharmony_ci        Then configure your projection matrix as
3995bd8deadSopenharmony_ci
4005bd8deadSopenharmony_ci            glMatrixMode(GL_PROJECTION);
4015bd8deadSopenharmony_ci            glLoadIdentity();
4025bd8deadSopenharmony_ci            // adjust for GL_UPPER_LEFT
4035bd8deadSopenharmony_ci            glScalef(1,-1,1);
4045bd8deadSopenharmony_ci            // adjust for GL_ZERO_TO_ONE
4055bd8deadSopenharmony_ci            glTranslatef(0,0,0.5);
4065bd8deadSopenharmony_ci            glScalef(1,1,0.5);
4075bd8deadSopenharmony_ci            glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3);
4085bd8deadSopenharmony_ci
4095bd8deadSopenharmony_ci        Technically, the two glScalef could be combined as
4105bd8deadSopenharmony_ci        glScalef(1,-1,0.5);
4115bd8deadSopenharmony_ci
4125bd8deadSopenharmony_ci    7)  Has this topic been discussed elsewhere?
4135bd8deadSopenharmony_ci
4145bd8deadSopenharmony_ci        RESOLVED:  Yes, see:
4155bd8deadSopenharmony_ci
4165bd8deadSopenharmony_ci        "Maximizing Depth Buffer Range and Precision"
4175bd8deadSopenharmony_ci        Brano Kemen
4185bd8deadSopenharmony_ci        http://outerra.blogspot.co.uk/2012/11/maximizing-depth-buffer-range-and.html
4195bd8deadSopenharmony_ci        November 28, 2012
4205bd8deadSopenharmony_ci
4215bd8deadSopenharmony_ci        "Minimum Triangle Separation for Correct Z-Buffer"
4225bd8deadSopenharmony_ci        Kurt Akeley and Jonathan Su
4235bd8deadSopenharmony_ci        http://research.microsoft.com/apps/pubs/default.aspx?id=79213
4245bd8deadSopenharmony_ci        August 2006
4255bd8deadSopenharmony_ci
4265bd8deadSopenharmony_ci        "Tightening the Precision of Perspective Rendering"
4275bd8deadSopenharmony_ci        Paul Upchurch and Mathieu Desbrun
4285bd8deadSopenharmony_ci        http://www.geometry.caltech.edu/pubs/UD12.pdf
4295bd8deadSopenharmony_ci        Journal of Graphics Tools, Volume 16, Issue 1, 2012.
4305bd8deadSopenharmony_ci
4315bd8deadSopenharmony_ci    8)  How does this extension interact with the unclamped depth range
4325bd8deadSopenharmony_ci        parameters of NV_depth_buffer_float's glDepthRangedNV and OpenGL
4335bd8deadSopenharmony_ci        4.3?
4345bd8deadSopenharmony_ci
4355bd8deadSopenharmony_ci        RESOLVED:  Simply apply the equations as specified.
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ci        The implications of this are explored...
4385bd8deadSopenharmony_ci
4395bd8deadSopenharmony_ci        An unclamped depth range applies to floating-point depth buffers.
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci        (For a conventional [0,1] fixed-point depth buffer, the depth
4425bd8deadSopenharmony_ci        range is clamped to "the range appropriate to the depth buffer's
4435bd8deadSopenharmony_ci        representation."  In practice, this means that unclamped depth
4445bd8deadSopenharmony_ci        values are clamped to the [0,1] range when used with a
4455bd8deadSopenharmony_ci        conventional depth buffer so are effectively still clamped.)
4465bd8deadSopenharmony_ci
4475bd8deadSopenharmony_ci        If an application were to mix the two like this:
4485bd8deadSopenharmony_ci
4495bd8deadSopenharmony_ci          glDepthRangedNV(-1,1);
4505bd8deadSopenharmony_ci          glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
4515bd8deadSopenharmony_ci
4525bd8deadSopenharmony_ci        this would lead to generating interpolated depth values in a
4535bd8deadSopenharmony_ci        [-1,+1] range.  Because floating-point has more precision in the
4545bd8deadSopenharmony_ci        neighborhood of zero, the depth buffer precision is concentrated
4555bd8deadSopenharmony_ci        at zero in window-space Z.  This corresponds to 0.5 in normalized
4565bd8deadSopenharmony_ci        device coordinates.
4575bd8deadSopenharmony_ci
4585bd8deadSopenharmony_ci        Consider if our projection matrix mapped eye-space 2 to
4595bd8deadSopenharmony_ci        clip-space 0.0 and eye-space 1000 to 1.0 with the Z matrix row:
4605bd8deadSopenharmony_ci
4615bd8deadSopenharmony_ci           [  0   0   (n+f)/(n-f)   f*n/(n-f)  ]
4625bd8deadSopenharmony_ci
4635bd8deadSopenharmony_ci        so that
4645bd8deadSopenharmony_ci
4655bd8deadSopenharmony_ci            Zc = -0.5 = 0*x_e + 0*y_e + ((2+1000)/(2-1000))*z_e + (2*1000/(2-1000))*w_e
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ci        solving for z_e when w_e is one, means z_e equals -1.498
4685bd8deadSopenharmony_ci
4695bd8deadSopenharmony_ci        OpenGL 4.3 made a slightly incompatible change in the parameter
4705bd8deadSopenharmony_ci        types for glDepthRange (and related commands) from clamped
4715bd8deadSopenharmony_ci        floating-point types (GLclampd) to unclamped floating-point
4725bd8deadSopenharmony_ci        types (GLdouble).  Hence the functionality of glDepthRangedNV
4735bd8deadSopenharmony_ci        also applies to OpenGL 4.3 in the case of floating-point depth
4745bd8deadSopenharmony_ci        buffers.
4755bd8deadSopenharmony_ci
4765bd8deadSopenharmony_ci    9)  Can an application be guaranteed the exact same pixels being
4775bd8deadSopenharmony_ci        rasterized when the clip control origin is GL_UPPER_LEFT versus
4785bd8deadSopenharmony_ci        GL_LOWER_LEFT, except having the scanlines reversed?
4795bd8deadSopenharmony_ci
4805bd8deadSopenharmony_ci        RESOLVED:  No such rasterization invariance is reasonable to
4815bd8deadSopenharmony_ci        guarantee.  Slight pixel variances are possible.
4825bd8deadSopenharmony_ci
4835bd8deadSopenharmony_ci        The polygon rasterization rules for OpenGL (section 14.6.1,
4845bd8deadSopenharmony_ci        "Polygon Rasterization") states: In such a case [fragment's center
4855bd8deadSopenharmony_ci        lies on a polygon boundary edge] we require that if two polygons
4865bd8deadSopenharmony_ci        lie on either side of a common edge (with identical endpoints)
4875bd8deadSopenharmony_ci        on which a fragment center lies, then exactly one of the polygons
4885bd8deadSopenharmony_ci        results in the production of the fragment during rasterization."
4895bd8deadSopenharmony_ci
4905bd8deadSopenharmony_ci        The specification leaves it to implementations to define the
4915bd8deadSopenharmony_ci        exact edge rule in this case.  If the sense of Y in clip space
4925bd8deadSopenharmony_ci        is flipped, this rule may be decided differently.
4935bd8deadSopenharmony_ci
4945bd8deadSopenharmony_ci        This is further complicated by multisampling where the sample pattern
4955bd8deadSopenharmony_ci        is unlikely to be mirrored in the Y direction.
4965bd8deadSopenharmony_ci
4975bd8deadSopenharmony_ci        These issues are razor's edge cases and should not be an issue
4985bd8deadSopenharmony_ci        for real applications.
4995bd8deadSopenharmony_ci
5005bd8deadSopenharmony_ci    10) Are all the possible combinations of glClipControl useful?
5015bd8deadSopenharmony_ci
5025bd8deadSopenharmony_ci        RESOLVED: Yes, the initial state (GL_LOWER_LEFT/
5035bd8deadSopenharmony_ci        GL_NEGATIVE_ONE_TO_ONE) corresponds to OpenGL's traditional
5045bd8deadSopenharmony_ci        behavior.
5055bd8deadSopenharmony_ci
5065bd8deadSopenharmony_ci        The state GL_LOWER_LEFT/GL_ZERO_TO_ONE corresponds to OpenGL's
5075bd8deadSopenharmony_ci        traditional origin and Direct3D's depth mode.
5085bd8deadSopenharmony_ci
5095bd8deadSopenharmony_ci        The state GL_UPPER_LEFT/GL_ZERO_TO_ONE corresponds to Direct3D's
5105bd8deadSopenharmony_ci        clip volume definition.
5115bd8deadSopenharmony_ci
5125bd8deadSopenharmony_ci        The state GL_UPPER_LEFT/GL_NEGATIVE_ONE_TO_ONE is consistent with
5135bd8deadSopenharmony_ci        the upper-left origin of the window coordinate system of Microsoft
5145bd8deadSopenharmony_ci        Windows and the X Window System.
5155bd8deadSopenharmony_ci
5165bd8deadSopenharmony_ci    11) Should all the possible combinations of glClipControl
5175bd8deadSopenharmony_ci        parameters supported be supported?
5185bd8deadSopenharmony_ci
5195bd8deadSopenharmony_ci        RESOLVED:  Yes, all the combinations should be supported.  The cost
5205bd8deadSopenharmony_ci        is low and this provides orthogonality.
5215bd8deadSopenharmony_ci
5225bd8deadSopenharmony_ci        So it is legal to call:
5235bd8deadSopenharmony_ci
5245bd8deadSopenharmony_ci            glClipControl(GL_UPPER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
5255bd8deadSopenharmony_ci
5265bd8deadSopenharmony_ci    12) Does setting the clip control origin to GL_UPPER_LEFT change the
5275bd8deadSopenharmony_ci        origin of the window coordinate system use for commands such as
5285bd8deadSopenharmony_ci        glViewport, glScissor, glWindowPos2i, and glReadPixels?
5295bd8deadSopenharmony_ci
5305bd8deadSopenharmony_ci        RESOLVED:  No.
5315bd8deadSopenharmony_ci
5325bd8deadSopenharmony_ci        The (x,y) window space location passed to these commands have the
5335bd8deadSopenharmony_ci        (0,0) origin at the lower left corner of the window, independent
5345bd8deadSopenharmony_ci        of the state of the clip control origin.
5355bd8deadSopenharmony_ci
5365bd8deadSopenharmony_ci        So, for example, an application wanting a Direct3D upper-left orign
5375bd8deadSopenharmony_ci        specifying the scissor with upper-left (x,y) coordinates would call:
5385bd8deadSopenharmony_ci
5395bd8deadSopenharmony_ci            glScissor(upper_left_x,
5405bd8deadSopenharmony_ci                      window_height - upper_left_y,
5415bd8deadSopenharmony_ci                      window_width, window_height);
5425bd8deadSopenharmony_ci
5435bd8deadSopenharmony_ci        The rationale for this choice is to avoid confusion for how
5445bd8deadSopenharmony_ci        window space coordinates are passed to commands.  When rendering
5455bd8deadSopenharmony_ci        to resizable windows, the window width and height can change
5465bd8deadSopenharmony_ci        asychronously.  This would mean the scissor command would need
5475bd8deadSopenharmony_ci        to specify a "gravity" for the window origin.  There would also
5485bd8deadSopenharmony_ci        need to be a way to "query" this state relative to difference
5495bd8deadSopenharmony_ci        origin conventions and subject asynchronous window resizes.
5505bd8deadSopenharmony_ci
5515bd8deadSopenharmony_ci        Moreover, this extension is not changing how window space is
5525bd8deadSopenharmony_ci        specified but rather how clip space is specified.
5535bd8deadSopenharmony_ci
5545bd8deadSopenharmony_ci    13) Does the polygon stipple orientation change when the clip control
5555bd8deadSopenharmony_ci        origin is set to GL_UPPER_LEFT?
5565bd8deadSopenharmony_ci
5575bd8deadSopenharmony_ci        RESOLVED:  No.
5585bd8deadSopenharmony_ci
5595bd8deadSopenharmony_ci    14) Will using the GL_ZERO_TO_ONE clip control depth mode improve
5605bd8deadSopenharmony_ci        my depth precision?
5615bd8deadSopenharmony_ci
5625bd8deadSopenharmony_ci        RESOLVED:  Yes, if you use a floating-point depth buffer and
5635bd8deadSopenharmony_ci        place the near and far values at 1.0 and 0.0 (reversed from the
5645bd8deadSopenharmony_ci        normal convention).
5655bd8deadSopenharmony_ci
5665bd8deadSopenharmony_ci        But not much if you use a conventional fixed-point depth buffer.
5675bd8deadSopenharmony_ci
5685bd8deadSopenharmony_ci        This really depends on whether the particular hardware
5695bd8deadSopenharmony_ci        implementation can numerically improve its depth interpolation
5705bd8deadSopenharmony_ci        result.  This depends on a lot of things including the quality
5715bd8deadSopenharmony_ci        of the depth plane equation setup, the number of bits of
5725bd8deadSopenharmony_ci        sub-pixel precision available, and how the depth interpolation
5735bd8deadSopenharmony_ci        is performed.
5745bd8deadSopenharmony_ci
5755bd8deadSopenharmony_ci        With a conventional 24-bit fixed-point depth buffer, applications
5765bd8deadSopenharmony_ci        may be able to achieve half a least significant bit (LSB) of
5775bd8deadSopenharmony_ci        improved depth buffer precision.
5785bd8deadSopenharmony_ci
5795bd8deadSopenharmony_ci        There are typically far better strategies for improving depth
5805bd8deadSopenharmony_ci        precision such as W-buffering, avoiding concatenation of the
5815bd8deadSopenharmony_ci        modelview and projection matrices, and (probably the easiest)
5825bd8deadSopenharmony_ci        better managing your scene's near and far planes.
5835bd8deadSopenharmony_ci
5845bd8deadSopenharmony_ci        With a floating-point depth buffer, it is more likely the
5855bd8deadSopenharmony_ci        GL_ZERO_TO_ONE depth mode will improve depth precision.
5865bd8deadSopenharmony_ci        Unfortunately in the conventional depth range [0,1], the
5875bd8deadSopenharmony_ci        improvement is primarily close to the near plane where there
5885bd8deadSopenharmony_ci        is already excessive precision.  Reversing the depth range with
5895bd8deadSopenharmony_ci        the command
5905bd8deadSopenharmony_ci
5915bd8deadSopenharmony_ci            glDepthRange(1.0, 0.0);
5925bd8deadSopenharmony_ci
5935bd8deadSopenharmony_ci        effectively reverses the near and far values in the depth
5945bd8deadSopenharmony_ci        buffer.  Also remember to reverse the depth function; so
5955bd8deadSopenharmony_ci        glDepthFunc(GL_LESS) should become glDepthFunc(GL_GREATER).
5965bd8deadSopenharmony_ci        However, this involves computing 1-Z which effectively truncates
5975bd8deadSopenharmony_ci        far values (for much the same reason adding +0.5 does).
5985bd8deadSopenharmony_ci
5995bd8deadSopenharmony_ci        Alternatively, the reversal of near and far can happen as part
6005bd8deadSopenharmony_ci        of the projection transformation so the depth range specified
6015bd8deadSopenharmony_ci        with glDepthRange can be the conventional range [0,1].  Arguably
6025bd8deadSopenharmony_ci        folding the near and far reversal into the projection matrix is
6035bd8deadSopenharmony_ci        slightly better than reversing the depth range.  However the
6045bd8deadSopenharmony_ci        problem remains that a very large value is added with a small
6055bd8deadSopenharmony_ci        value close to the far plane so effective depth precision is
6065bd8deadSopenharmony_ci        not substantially improved with a fixed-point depth buffer but
6075bd8deadSopenharmony_ci        has a substantial advantage for a floating-point depth buffer.
6085bd8deadSopenharmony_ci
6095bd8deadSopenharmony_ci    15) How does this extension interact with geometry shaders?
6105bd8deadSopenharmony_ci
6115bd8deadSopenharmony_ci        RESOLVED:  If there is a geometry shader active, it is the
6125bd8deadSopenharmony_ci        geometry shader which is actually writing the clip space position
6135bd8deadSopenharmony_ci        (not the vertex shader).
6145bd8deadSopenharmony_ci
6155bd8deadSopenharmony_ci        One way to implement this extension (ignoring geometry shaders
6165bd8deadSopenharmony_ci        for now) would be to add an epilogue to the application's vertex
6175bd8deadSopenharmony_ci        shader to invert the clip space Y output when the clip control
6185bd8deadSopenharmony_ci        origin is GL_UPPER_LEFT and perform a scale by 2 and bias by negative
6195bd8deadSopenharmony_ci        clip space W to the clip space Z (biasing by negative clip space
6205bd8deadSopenharmony_ci        W is like subtracting 1 in normalized device coordinates).
6215bd8deadSopenharmony_ci
6225bd8deadSopenharmony_ci        However, this epilogue would need to be moved to the geometry
6235bd8deadSopenharmony_ci        shader if a geometry shader was active.
6245bd8deadSopenharmony_ci
6255bd8deadSopenharmony_ci    16) How does this extension interact with tessellation evaluation
6265bd8deadSopenharmony_ci        shaders (without a geometry shader)?
6275bd8deadSopenharmony_ci
6285bd8deadSopenharmony_ci        RESOLVED:  Then the epilogue discussed in issue #15 would need to
6295bd8deadSopenharmony_ci        be added to the tessellation evaluation shader (and not the vertex
6305bd8deadSopenharmony_ci        shader since it is really transforming patch control points).
6315bd8deadSopenharmony_ci
6325bd8deadSopenharmony_ci        If there was a geometry shader active, the geometry shader is
6335bd8deadSopenharmony_ci        where the epilogue would be done.
6345bd8deadSopenharmony_ci
6355bd8deadSopenharmony_ci    17) Does the discussion of the use an epilogue in the last two issues
6365bd8deadSopenharmony_ci        mean using the GL_UPPER_LEFT or GL_ZERO_TO_ONE modes is
6375bd8deadSopenharmony_ci        necessarily slower?
6385bd8deadSopenharmony_ci
6395bd8deadSopenharmony_ci        RESOLVED:  Generally no.
6405bd8deadSopenharmony_ci
6415bd8deadSopenharmony_ci        GPUs that support Direct3D are expected to have a mode to support
6425bd8deadSopenharmony_ci        GL_UPPER_LEFT and GL_ZERO_TO_ONE at full speed and OpenGL
6435bd8deadSopenharmony_ci        implementations for such GPUs should operate at full speed.
6445bd8deadSopenharmony_ci
6455bd8deadSopenharmony_ci    18) Should the clip control state be changed frequently?
6465bd8deadSopenharmony_ci
6475bd8deadSopenharmony_ci        RESOLVED:  Most applications are expected to set the clip control
6485bd8deadSopenharmony_ci        conventions once; for example, to match the Direct3D conventions.
6495bd8deadSopenharmony_ci
6505bd8deadSopenharmony_ci        Some implementations may introduce a flush when changing the
6515bd8deadSopenharmony_ci        clip control state.  Hence frequent clip control changes are
6525bd8deadSopenharmony_ci        not recommended.
6535bd8deadSopenharmony_ci
6545bd8deadSopenharmony_ci        No flush is explicitly required when the clip control changes
6555bd8deadSopenharmony_ci        and some implementations (NVIDIA) will have no significant
6565bd8deadSopenharmony_ci        performance penalty for changing the clip control state.
6575bd8deadSopenharmony_ci
6585bd8deadSopenharmony_ci    19) Issue #6 addresses fixed-function vertex processing adjustments
6595bd8deadSopenharmony_ci        under different clip control modes.  How would a GLSL vertex
6605bd8deadSopenharmony_ci        shader be adjusted, assuming how the shader computes its
6615bd8deadSopenharmony_ci        clip-space position does not change, for different clip control
6625bd8deadSopenharmony_ci        conventions?
6635bd8deadSopenharmony_ci
6645bd8deadSopenharmony_ci        RESOLVED:  The following GLSL epilogues could be added...
6655bd8deadSopenharmony_ci
6665bd8deadSopenharmony_ci        If the clip control origin is GL_UPPER_LEFT, you could add a final
6675bd8deadSopenharmony_ci        operation to negate the clip-space Y component.  So:
6685bd8deadSopenharmony_ci
6695bd8deadSopenharmony_ci           gl_Position.y *= -1;
6705bd8deadSopenharmony_ci
6715bd8deadSopenharmony_ci        If the clip control depth mode is GL_ZERO_TO_ONE, you
6725bd8deadSopenharmony_ci        could scale and bias the conventional [-1,+1] range of
6735bd8deadSopenharmony_ci        normalized-device-coordinate-space Z to the [0,1] range like
6745bd8deadSopenharmony_ci        this:
6755bd8deadSopenharmony_ci
6765bd8deadSopenharmony_ci           gl_Position.z = 0.5*gl_Positon.z + 0.5*gl_Position.w;
6775bd8deadSopenharmony_ci
6785bd8deadSopenharmony_ci        Because
6795bd8deadSopenharmony_ci
6805bd8deadSopenharmony_ci           z_ndc = z_c / w_c
6815bd8deadSopenharmony_ci
6825bd8deadSopenharmony_ci        so the epilogue above computes an adjusted z_ndc':
6835bd8deadSopenharmony_ci
6845bd8deadSopenharmony_ci           z_ndc' = (0.5*z_c + 0.5+w_c)/w_c
6855bd8deadSopenharmony_ci
6865bd8deadSopenharmony_ci        which is the same as:
6875bd8deadSopenharmony_ci
6885bd8deadSopenharmony_ci           z_ndc' = 0.5*z_c/w_c + 0.5
6895bd8deadSopenharmony_ci                  = 0.5*z_ndc + 0.5
6905bd8deadSopenharmony_ci
6915bd8deadSopenharmony_ci        and scaling a [-1,+1] range by 0.5 and biasing by 0.5 computes
6925bd8deadSopenharmony_ci        a linear mapping to the range [0,1].
6935bd8deadSopenharmony_ci
6945bd8deadSopenharmony_ci        Alternatively, rather than adding an epilogue as described,
6955bd8deadSopenharmony_ci        the adjustments above could be folded into the transform matrix
6965bd8deadSopenharmony_ci        typically used to transform object-space to clip-space.  This is
6975bd8deadSopenharmony_ci        a faster approach since it avoids extra math operations in the
6985bd8deadSopenharmony_ci        vertex shaders.
6995bd8deadSopenharmony_ci
7005bd8deadSopenharmony_ci    20) Explain the numerical advantage for potential increased depth
7015bd8deadSopenharmony_ci        precision for the GL_ZERO_TO_ONE clip control depth mode.
7025bd8deadSopenharmony_ci
7035bd8deadSopenharmony_ci        RESOLVED:  If the normal depth range sets near to 0.0 and far
7045bd8deadSopenharmony_ci        to 1.0, this means the effective viewport transform for Z (see
7055bd8deadSopenharmony_ci        section 13.6.1 "Controlling the Viewport") becomes an identity
7065bd8deadSopenharmony_ci        mapping.  So the mapping in GL_ZERO_TO_ONE depth mode is:
7075bd8deadSopenharmony_ci
7085bd8deadSopenharmony_ci            z_w = (f-n)  * z_d + n
7095bd8deadSopenharmony_ci
7105bd8deadSopenharmony_ci        and when near (n) is 0.0 and far (f) is 1.0, this becomes simply:
7115bd8deadSopenharmony_ci
7125bd8deadSopenharmony_ci           z_w = z_d;
7135bd8deadSopenharmony_ci
7145bd8deadSopenharmony_ci        This identity mapping results in no lose or change in the
7155bd8deadSopenharmony_ci        per-vertex window space position.
7165bd8deadSopenharmony_ci
7175bd8deadSopenharmony_ci        Contrast this with the same situation with the
7185bd8deadSopenharmony_ci        GL_NEGATIVE_ONE_TO_ONE depth mode with the mapping:
7195bd8deadSopenharmony_ci
7205bd8deadSopenharmony_ci           z_w =  (f-n)/2 * z_d + (n+f)/2
7215bd8deadSopenharmony_ci
7225bd8deadSopenharmony_ci        and when near (n) is 0.0 and far (f) is 1.0, this becomes simply:
7235bd8deadSopenharmony_ci
7245bd8deadSopenharmony_ci           z_w = 0.5 * z_d + 0.5
7255bd8deadSopenharmony_ci
7265bd8deadSopenharmony_ci        While multiplying z_d by 0.5 has no precision loss (ignoring
7275bd8deadSopenharmony_ci        denorms, this scale simply decrements the exponent by 1 without
7285bd8deadSopenharmony_ci        disturbing the mantissa).  However a bias by 0.5 does distrurb
7295bd8deadSopenharmony_ci        the floating-point precision (also see Issue #3), losing one
7305bd8deadSopenharmony_ci        least-significant-bit (LSB) of precision.
7315bd8deadSopenharmony_ci
7325bd8deadSopenharmony_ci    21) What should the state to control the GL_NEGATIVE_ONE_TO_ONE
7335bd8deadSopenharmony_ci        and GL_ZERO_TO_ONE convention be called?
7345bd8deadSopenharmony_ci
7355bd8deadSopenharmony_ci        RESOLVED:  GL_CLIP_DEPTH_MODE.
7365bd8deadSopenharmony_ci
7375bd8deadSopenharmony_ci        An alternative would be GL_CLIP_Z_MODE but the convention
7385bd8deadSopenharmony_ci        is well-established in the OpenGL API that Z values that are
7395bd8deadSopenharmony_ci        interpreted as depth values are described as DEPTH.
7405bd8deadSopenharmony_ci
7415bd8deadSopenharmony_ci    22) Direct3D 8 and 9 have a window-space coordinate system where
7425bd8deadSopenharmony_ci        pixel centers are centered on integer coordinates.  OpenGL
7435bd8deadSopenharmony_ci        (and Direct3D 10 and 11) position pixel centers at half-pixel
7445bd8deadSopenharmony_ci        locations.  Should ARB_clip_control account for the older Direct3D
7455bd8deadSopenharmony_ci        integer pixel center convention?
7465bd8deadSopenharmony_ci
7475bd8deadSopenharmony_ci        RESOLVED:  No, because existing functionality covers this...
7485bd8deadSopenharmony_ci
7495bd8deadSopenharmony_ci        The EXT_viewport_array extension (made a core part of OpenGL
7505bd8deadSopenharmony_ci        with version 4.1) extends the viewport state to be specified as
7515bd8deadSopenharmony_ci        floating-point (technically fixed-point) values.  Prior to this
7525bd8deadSopenharmony_ci        extension, the viewport parameters were integral.
7535bd8deadSopenharmony_ci
7545bd8deadSopenharmony_ci        With the EXT_viewport_array functionality, you can add a bias of
7555bd8deadSopenharmony_ci        (0.5,0.5) to the viewport (x,y) to shift integer Direct3D 8/9
7565bd8deadSopenharmony_ci        style window space locations to OpenGL's half-pixel convention.
7575bd8deadSopenharmony_ci
7585bd8deadSopenharmony_ci        If you had a Direct3D upper-left viewport (x,y), you'd match
7595bd8deadSopenharmony_ci        the Direct3D clip-space AND window-space conventions like this:
7605bd8deadSopenharmony_ci
7615bd8deadSopenharmony_ci            glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE);
7625bd8deadSopenharmony_ci            const GLuint viewport_index = 0;  // Prior to DirectX 10, there's only a single viewport
7635bd8deadSopenharmony_ci            glViewportIndexedf(viewport_index,
7645bd8deadSopenharmony_ci                x + 0.5f, window_height - (y + view_height) + 0.5f,
7655bd8deadSopenharmony_ci                view_width, view_height);
7665bd8deadSopenharmony_ci
7675bd8deadSopenharmony_ci        where window_height is the height of the window/surface in pixels.
7685bd8deadSopenharmony_ci
7695bd8deadSopenharmony_ci        Also note the EXT_fragment_coord_conventions (made a core part
7705bd8deadSopenharmony_ci        of OpenGL with version 3.2) allows the window position varying
7715bd8deadSopenharmony_ci        input to fragment shaders to reflect the Direct3D 9 window-space
7725bd8deadSopenharmony_ci        convention.  See that extension for details.
7735bd8deadSopenharmony_ci
7745bd8deadSopenharmony_ci    23) Does this extension's state affect user clip planes?
7755bd8deadSopenharmony_ci
7765bd8deadSopenharmony_ci        RESOLVED:  No, user clip planes operate on eye-space coordinates
7775bd8deadSopenharmony_ci        which are not affected by this extension's state.
7785bd8deadSopenharmony_ci
7795bd8deadSopenharmony_ci    24) Does this extension's state affect fixed-function fog?
7805bd8deadSopenharmony_ci
7815bd8deadSopenharmony_ci        RESOLVED:  No, fixed-function fog operates on eye-space distance
7825bd8deadSopenharmony_ci        which is not affected by this extension's state.
7835bd8deadSopenharmony_ci
7845bd8deadSopenharmony_ci    25) Does this extension's state affect the point sprite origin?
7855bd8deadSopenharmony_ci
7865bd8deadSopenharmony_ci        RESOLVED:  No.
7875bd8deadSopenharmony_ci
7885bd8deadSopenharmony_ci        When the EXT_point_sprite functionality was promoted to a core
7895bd8deadSopenharmony_ci        feature in OpenGL 2.0, the GL_POINT_SPRITE_ORIGIN state was added
7905bd8deadSopenharmony_ci        to specify whether the 2D texture coordinate has a lower-left
7915bd8deadSopenharmony_ci        (OpenGL's convention in EXT_point_sprite and NV_point_sprite)
7925bd8deadSopenharmony_ci        or upper-left (Direct3D convention).
7935bd8deadSopenharmony_ci
7945bd8deadSopenharmony_ci        An application wanting to emulate Direct3D's upper-left point
7955bd8deadSopenharmony_ci        sprite texture coordinate origin should change the origin state
7965bd8deadSopenharmony_ci        with an explicit point parameter command.  Specifically:
7975bd8deadSopenharmony_ci
7985bd8deadSopenharmony_ci            glPointParameteri(GL_POINT_SPRITE_ORIGIN, GL_UPPER_LEFT);
7995bd8deadSopenharmony_ci
8005bd8deadSopenharmony_ci        This command is in addition to calling glClipControl and
8015bd8deadSopenharmony_ci        specifying a GL_UPPER_LEFT origin.
8025bd8deadSopenharmony_ci
8035bd8deadSopenharmony_ci    26) Issue #12 says the origin for glWindowPos2i and other glWindowPos*
8045bd8deadSopenharmony_ci        commands is lower-left independent of the clip control state.
8055bd8deadSopenharmony_ci        What about glRasterPos2i and other glRasterPos* commands?
8065bd8deadSopenharmony_ci
8075bd8deadSopenharmony_ci        RESOLVED:  Yes, the raster position specified by glRasterPos2i,
8085bd8deadSopenharmony_ci        etc.  is affected by the clip control state because the
8095bd8deadSopenharmony_ci        object-space position is transformed and clipped just as a point
8105bd8deadSopenharmony_ci        vertex position would be to arrive at the clip-space raster
8115bd8deadSopenharmony_ci        position that is further transformed to window space.
8125bd8deadSopenharmony_ci
8135bd8deadSopenharmony_ci    27) Is the depth value specified for glClearDepth affected by this
8145bd8deadSopenharmony_ci        extension's clip control state?
8155bd8deadSopenharmony_ci
8165bd8deadSopenharmony_ci        RESOLVED:  No, glClearDepth takes a window-space depth value.
8175bd8deadSopenharmony_ci
8185bd8deadSopenharmony_ci        This extension only affects how clip space clipping and the
8195bd8deadSopenharmony_ci        transformation from clip space to window space operates.
8205bd8deadSopenharmony_ci
8215bd8deadSopenharmony_ci        Likewise depth values read (glReadPixels), drawn (glDrawPixels),
8225bd8deadSopenharmony_ci        or copied (glCopyPixels, glBlitFramebuffer) are unaffected by
8235bd8deadSopenharmony_ci        this extension's clip control state.
8245bd8deadSopenharmony_ci
8255bd8deadSopenharmony_ci    28) Does this extension's state affect the operation of polygon
8265bd8deadSopenharmony_ci        offset?
8275bd8deadSopenharmony_ci
8285bd8deadSopenharmony_ci        RESOLVED:  No, polygon offset operates on window-space depth
8295bd8deadSopenharmony_ci        values.  This extension's clip control state operates prior
8305bd8deadSopenharmony_ci        to polygon offset.
8315bd8deadSopenharmony_ci
8325bd8deadSopenharmony_ci    29) Can glClipControl be display listed?
8335bd8deadSopenharmony_ci
8345bd8deadSopenharmony_ci        RESOLVED:  Yes.
8355bd8deadSopenharmony_ci
8365bd8deadSopenharmony_ci    30) Should the command be glClipParameteri to anticipate more
8375bd8deadSopenharmony_ci        control of clipping state?
8385bd8deadSopenharmony_ci
8395bd8deadSopenharmony_ci        RESOLVED:  No.  Given over 20 years with basically zero extensions
8405bd8deadSopenharmony_ci        in the area of clipping state, we realistically don't anticipate
8415bd8deadSopenharmony_ci        more clipping parameters.  Even in the case of this extension, the
8425bd8deadSopenharmony_ci        rationale for this extension is quite limited and not about adding
8435bd8deadSopenharmony_ci        any "features" to clipping.  Instead the purpose is simply to
8445bd8deadSopenharmony_ci        match the conventions of Direct3D (not a functional change).
8455bd8deadSopenharmony_ci        While Direct3D's convention is different from OpenGL, there
8465bd8deadSopenharmony_ci        simply aren't any futher 3D APIs or standards which clip
8475bd8deadSopenharmony_ci        differently.
8485bd8deadSopenharmony_ci
8495bd8deadSopenharmony_ci        Also glClipControl maintains consistency with the existing
8505bd8deadSopenharmony_ci        glClipPlane command pattern for the clipping API.
8515bd8deadSopenharmony_ci
8525bd8deadSopenharmony_ci        Historically "Parameter" has been used for commands that affect
8535bd8deadSopenharmony_ci        managed "object" state and/or have a speciailized "Get" query
8545bd8deadSopenharmony_ci        command (glGetColorTableParameter*) rather than fixed-function
8555bd8deadSopenharmony_ci        pipeline state.  This isn't completely uniform (exceptions:
8565bd8deadSopenharmony_ci        point parameters, patch parameters) but the vast majority of
8575bd8deadSopenharmony_ci        fixed-function rendering state isn't set with gl*Parameter
8585bd8deadSopenharmony_ci        style commands.  When "Parameter" commands are used there
8595bd8deadSopenharmony_ci        is typically a plurality of state settings with different
8605bd8deadSopenharmony_ci        integer/float/double/boolean types.  None of the situations
8615bd8deadSopenharmony_ci        that justify gl*Parameter style commands are present in this
8625bd8deadSopenharmony_ci        extension.
8635bd8deadSopenharmony_ci
8645bd8deadSopenharmony_ci    31) This extension is only useful if it is widely available.  So how
8655bd8deadSopenharmony_ci        easy would this extension be to implement?
8665bd8deadSopenharmony_ci
8675bd8deadSopenharmony_ci        RESOLVED:  No special hardware is required due to the careful
8685bd8deadSopenharmony_ci        way this extension is specified.  The clip control functionality
8695bd8deadSopenharmony_ci        could all be done by inexpensive epilogue math appended to the
8705bd8deadSopenharmony_ci        last shader in the graphics pipeline.  The Y inversion could be
8715bd8deadSopenharmony_ci        performed as part of the viewport transform.
8725bd8deadSopenharmony_ci
8735bd8deadSopenharmony_ci        Given the prevalance of Direct3D-capable hardware, we expect
8745bd8deadSopenharmony_ci        some hardware vendors will implement this extension with
8755bd8deadSopenharmony_ci        special existing modes in their hardware to handle the Direct3D
8765bd8deadSopenharmony_ci        conventions.  However we emphasize no special hardware is required
8775bd8deadSopenharmony_ci        and the performance benefit attributable to such hardware is
8785bd8deadSopenharmony_ci        likely to be extremely meager.
8795bd8deadSopenharmony_ci
8805bd8deadSopenharmony_ci        With respect to Mesa3D and Gallium, Brian Paul observes:  "This
8815bd8deadSopenharmony_ci        extension should be pretty easy to implement in Mesa/gallium.
8825bd8deadSopenharmony_ci        In Gallium we already have a state variable for Z 0/1 vs. -1/+1
8835bd8deadSopenharmony_ci        clipping.  And I think we could implement the Y origin via our
8845bd8deadSopenharmony_ci        viewport state (which is specified in floats)."
8855bd8deadSopenharmony_ci
8865bd8deadSopenharmony_ci    32) Is support for the GL_UPPER_LEFT convention just to match
8875bd8deadSopenharmony_ci        Direct3D/Windows?
8885bd8deadSopenharmony_ci
8895bd8deadSopenharmony_ci        RESOLVED:  No.  Along with Windows/Direct3D/Direct2D, X11 and
8905bd8deadSopenharmony_ci        Java also have upper-left graphics device coordinate systems.
8915bd8deadSopenharmony_ci
8925bd8deadSopenharmony_ci        OpenGL, PostScript, PHIGS, GKS, and Apple's Core Graphics
8935bd8deadSopenharmony_ci        (Quartz 2D) have lower-left graphics device coordinate systems.
8945bd8deadSopenharmony_ci
8955bd8deadSopenharmony_ci    33) When rendering to off-screen framebuffer objects (FBOs) that
8965bd8deadSopenharmony_ci        will subsequently be textured from, how do I make sure the texture
8975bd8deadSopenharmony_ci        coordinate origin and the window space origin are consistent?
8985bd8deadSopenharmony_ci
8995bd8deadSopenharmony_ci        RESOLVED:  Use GL_LOWER_LEFT for the origin parameter of
9005bd8deadSopenharmony_ci        glClipControl in this case.  Use the GL_UPPER_LEFT for the
9015bd8deadSopenharmony_ci        origin parameter when matching Direct3D's origin *and* drawing
9025bd8deadSopenharmony_ci        into a window framebuffer to be directly presented.
9035bd8deadSopenharmony_ci
9045bd8deadSopenharmony_ci    34) Can you provide an example illustrating how applications using the
9055bd8deadSopenharmony_ci        coordinate system conventions of Direct3D map onto this extension?
9065bd8deadSopenharmony_ci
9075bd8deadSopenharmony_ci        RESOLVED:  Consider a Direct3D application rendering a triangle ABC
9085bd8deadSopenharmony_ci        (with counter-clockwise orientation) to a viewport in the upper-left
9095bd8deadSopenharmony_ci        quadrant of the destination surface.  The surface (with Direct3D
9105bd8deadSopenharmony_ci        window coordinates) is illustrated here.
9115bd8deadSopenharmony_ci
9125bd8deadSopenharmony_ci            (0,0)         (960,0)          (1920,0)
9135bd8deadSopenharmony_ci            +------(A)-------+----------------+
9145bd8deadSopenharmony_ci            |^ Y_c == +W_c ^ |                |
9155bd8deadSopenharmony_ci            |                |                |
9165bd8deadSopenharmony_ci            |                |                |
9175bd8deadSopenharmony_ci            |                |                |
9185bd8deadSopenharmony_ci            |v Y_c == -W_c v |                |
9195bd8deadSopenharmony_ci            +-(B)--------(C)-+----------------+
9205bd8deadSopenharmony_ci            |                |                |
9215bd8deadSopenharmony_ci            |                |                |
9225bd8deadSopenharmony_ci            |                |                |
9235bd8deadSopenharmony_ci            |                |                |
9245bd8deadSopenharmony_ci            |                |                |
9255bd8deadSopenharmony_ci            +----------------+----------------+
9265bd8deadSopenharmony_ci            (0,1080)                      (1920,1080)
9275bd8deadSopenharmony_ci
9285bd8deadSopenharmony_ci        In this example, assume vertices A, B, and C have clip coordinates of:
9295bd8deadSopenharmony_ci
9305bd8deadSopenharmony_ci          A = (+0.0, +1.0, +0.5, +1.0)
9315bd8deadSopenharmony_ci          B = (-0.8, -1.0, +0.5, +1.0)
9325bd8deadSopenharmony_ci          C = (+0.8, -1.0, +0.5, +1.0)
9335bd8deadSopenharmony_ci
9345bd8deadSopenharmony_ci        Direct3D's coordinate transformations are functionally similar to
9355bd8deadSopenharmony_ci        OpenGL's, except that (a) the Y coordinate is inverted as part of the
9365bd8deadSopenharmony_ci        viewport transformation mapping normalized device coordinates (NDCs)
9375bd8deadSopenharmony_ci        to window coordinates and (b) the depth range transformation maps Z==0
9385bd8deadSopenharmony_ci        to the near value instead of halfway between near and far as in
9395bd8deadSopenharmony_ci        OpenGL:
9405bd8deadSopenharmony_ci
9415bd8deadSopenharmony_ci          http://msdn.microsoft.com/en-us/library/windows/desktop/
9425bd8deadSopenharmony_ci          bb206341%28v=vs.85%29.aspx
9435bd8deadSopenharmony_ci
9445bd8deadSopenharmony_ci        Because of the Y inversion from (a), vertices in Direct3D with a Y NDC
9455bd8deadSopenharmony_ci        of -1.0 map to the bottom of the viewport (larger Y window coordinates
9465bd8deadSopenharmony_ci        in the Direct3D coordinate system).  This is exactly like OpenGL
9475bd8deadSopenharmony_ci        windowed rendering, where a Y NDC of -1 maps to smaller Y window
9485bd8deadSopenharmony_ci        coordinates (bottom) in the OpenGL coordinate system.  Thanks to this
9495bd8deadSopenharmony_ci        inversion in the Direct3D viewport transformation, rendering a
9505bd8deadSopenharmony_ci        Direct3D scene with the same coordinates and matrices in OpenGL will
9515bd8deadSopenharmony_ci        produce an image with identical vertical orientation and winding
9525bd8deadSopenharmony_ci        (CW/CCW).  However, since the viewport rectangle itself is programmed
9535bd8deadSopenharmony_ci        in window coordinates, a Direct3D-centric viewport of (0,0,960,540)
9545bd8deadSopenharmony_ci        needs to be flipped to (0,540,960,540) to work in OpenGL.
9555bd8deadSopenharmony_ci        Additionally, to get identical near/far clipping and Z values, it's
9565bd8deadSopenharmony_ci        necessary to use the ZERO_TO_ONE mode in this extension to have OpenGL
9575bd8deadSopenharmony_ci        process Z coordinates identically to Direct3D.
9585bd8deadSopenharmony_ci
9595bd8deadSopenharmony_ci        When rendering to off-screen surfaces later used as textures, the
9605bd8deadSopenharmony_ci        issue is a little bit more complex.  A Direct3D application will use
9615bd8deadSopenharmony_ci        the texture coordinates (0,0) to refer to the upper left corner of the
9625bd8deadSopenharmony_ci        upper leftmost pixel of the image.  However, in OpenGL, texture
9635bd8deadSopenharmony_ci        coordinates of (0,0) refer to the lower-left corner of the
9645bd8deadSopenharmony_ci        lower-leftmost pixel of the image.  One way to compensate for this is
9655bd8deadSopenharmony_ci        to remap the <t> texture coordinate with:
9665bd8deadSopenharmony_ci
9675bd8deadSopenharmony_ci          t_OpenGL = 1.0 - t_Direct3D
9685bd8deadSopenharmony_ci
9695bd8deadSopenharmony_ci        Unfortunately, that requires a modification to shaders or other input
9705bd8deadSopenharmony_ci        data in the application.  Instead of doing this, the UPPER_LEFT mode
9715bd8deadSopenharmony_ci        in this extension provides a simple way to use Direct3D texture
9725bd8deadSopenharmony_ci        coordinate conventions -- by rendering the entire scene *upside-down*
9735bd8deadSopenharmony_ci        from the point of view of OpenGL.  The image we want to produce using
9745bd8deadSopenharmony_ci        this technique (below) is a vertically inverted version of the
9755bd8deadSopenharmony_ci        previous image, where OpenGL lower-left window coordinates are
9765bd8deadSopenharmony_ci        depicted in the figure.
9775bd8deadSopenharmony_ci
9785bd8deadSopenharmony_ci            (0,1080)                      (1920,1080)
9795bd8deadSopenharmony_ci            +----------------+----------------+
9805bd8deadSopenharmony_ci            |                |                |
9815bd8deadSopenharmony_ci            |                |                |
9825bd8deadSopenharmony_ci            |                |                |
9835bd8deadSopenharmony_ci            |                |                |
9845bd8deadSopenharmony_ci            |                |                |
9855bd8deadSopenharmony_ci            +-(B)--------(C)-+----------------+
9865bd8deadSopenharmony_ci            |v Y_c == -W_c v |                |
9875bd8deadSopenharmony_ci            |                |                |
9885bd8deadSopenharmony_ci            |                |                |
9895bd8deadSopenharmony_ci            |                |                |
9905bd8deadSopenharmony_ci            |^ Y_c == +W_c ^ |                |
9915bd8deadSopenharmony_ci            +------(A)-------+----------------+
9925bd8deadSopenharmony_ci            (0,0)         (960,0)          (1920,0)
9935bd8deadSopenharmony_ci
9945bd8deadSopenharmony_ci        In this example, the UPPER_LEFT mode in this extension inverts the
9955bd8deadSopenharmony_ci        geometry as part of the transformation from clip coordinates to NDCs,
9965bd8deadSopenharmony_ci        so that vertex A has a Y NDC of -1.0 instead of +1.0.  This puts A at
9975bd8deadSopenharmony_ci        the bottom of the viewport, while B and C remain at the top.  One
9985bd8deadSopenharmony_ci        thing to note is that the inversion changes the orientation of
9995bd8deadSopenharmony_ci        triangle ABC, which is now clockwise instead of counter-clockwise.  To
10005bd8deadSopenharmony_ci        compensate, this extension also inverts the value computed to compute
10015bd8deadSopenharmony_ci        face direction when in UPPER_LEFT mode.  The one other thing to note
10025bd8deadSopenharmony_ci        here is that when rendering this way, the Direct3D viewport should be
10035bd8deadSopenharmony_ci        used as-is in OpenGL.
10045bd8deadSopenharmony_ci
10055bd8deadSopenharmony_ci        Note that a similar inversion technique can be used to implement
10065bd8deadSopenharmony_ci        OpenGL FBO rendering on graphics hardware supporting only Direct3D
10075bd8deadSopenharmony_ci        coordinate systems.  If this technique is used on an implementation
10085bd8deadSopenharmony_ci        doing something like this, the two inversions cancel each other out.
10095bd8deadSopenharmony_ci
10105bd8deadSopenharmony_ci    35) Does this extension affect the primitive's winding order in tessellation
10115bd8deadSopenharmony_ci        evaluation shader when origin is changed to GL_UPPER_LEFT?
10125bd8deadSopenharmony_ci
10135bd8deadSopenharmony_ci        RESOLVED:  No, the winding order is not affected. If a change in winding
10145bd8deadSopenharmony_ci        order of the primitive is needed, it must be done from the tessellation
10155bd8deadSopenharmony_ci        shader explicitly.
10165bd8deadSopenharmony_ci
10175bd8deadSopenharmony_ciRevision History
10185bd8deadSopenharmony_ci
10195bd8deadSopenharmony_ci    Rev.    Date    Author     Changes
10205bd8deadSopenharmony_ci    ----  -------- ---------  ----------------------------------------------
10215bd8deadSopenharmony_ci    3     04/26/13 mjk        Add issues 15 to 21
10225bd8deadSopenharmony_ci                              Change CLIP_Z_MODE to CLIP_DEPTH_MODE
10235bd8deadSopenharmony_ci    4     04/30/13 mjk        Add issue 22
10245bd8deadSopenharmony_ci    5     05/01/13 mjk        Add issues 22 to 28, fix typos
10255bd8deadSopenharmony_ci    6     05/09/13 mjk        Add issue 29 to 31
10265bd8deadSopenharmony_ci    7     05/13/13 pdaniell   Internal revisions
10275bd8deadSopenharmony_ci    8     05/13/13 mjk        Valve feedback; change to KHR in issues
10285bd8deadSopenharmony_ci    9     05/13/13 mjk        Change to KHR in issues
10295bd8deadSopenharmony_ci    10    05/28/13 pdaniell   Fold in feedback from Mark Callow in bug 10245
10305bd8deadSopenharmony_ci    11    05/30/13 pdaniell   Internal revisions
10315bd8deadSopenharmony_ci    12    06/06/13 pdaniell   Internal revisions
10325bd8deadSopenharmony_ci    13    06/17/13 pdaniell   Fix the enum token values
10335bd8deadSopenharmony_ci    14    07/03/13 mjk        D3D off-screen discussion; issue 32 and 33
10345bd8deadSopenharmony_ci    15    04/16/14 pdaniell   Prepare spec for OpenGL 4.5
10355bd8deadSopenharmony_ci    16    04/17/14 pdaniell   Fixes "UPPER_RIGHT" typos to UPPER_LEFT
10365bd8deadSopenharmony_ci    17    07/30/14 pbrown     Fix incorrect language in the overview
10375bd8deadSopenharmony_ci                              describing when to use UPPER_LEFT and LOWER_LEFT
10385bd8deadSopenharmony_ci                              modes; add detailed examples in issue 34.
10395bd8deadSopenharmony_ci    18    09/17/15 Jon Leech  Correct typo in issue 7 and add contributor
10405bd8deadSopenharmony_ci                              Brano Kemen from that issue.
10415bd8deadSopenharmony_ci    19    04/06/18 Vikram     Add issue 35
1042