15bd8deadSopenharmony_ciName 
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_provoking_vertex
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_provoking_vertex
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Cynthia Allison, NVIDIA
125bd8deadSopenharmony_ci    Gregory Roth, NVIDIA
135bd8deadSopenharmony_ci    Daniel Koch, TransGaming
145bd8deadSopenharmony_ci    Gavriel State, TransGaming
155bd8deadSopenharmony_ci    Jason Green, TransGaming
165bd8deadSopenharmony_ci    Ian Romanick, Intel
175bd8deadSopenharmony_ci    Marcus Steyer, NVIDIA
185bd8deadSopenharmony_ci    Pat Brown, NVIDIA
195bd8deadSopenharmony_ci    Stefan Dosinger, CodeWeavers
205bd8deadSopenharmony_ci    Henri Verbeet, CodeWeavers
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciContact
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Mark Kilgard, NVIDIA (mjk 'at' nvidia.com)
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ciStatus
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ci    Implemented by NVIDIA, March 2009
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ciVersion
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ci    Last Modified Date:  May 11, 2009
335bd8deadSopenharmony_ci    Version:             12
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ciNumber
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    364
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ciDependencies
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ci    This extension is written against the OpenGL 2.1 Specification but
425bd8deadSopenharmony_ci    can apply to any prior specification.
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    ARB_geometry_shader4, EXT_geometry_shader4, NV_geometry_shader4,
455bd8deadSopenharmony_ci    and NV_gpu_program4 interact with this extension
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    EXT_transform_feedback, NV_transform_feedback, and the transform
485bd8deadSopenharmony_ci    feedback functionality made core by OpenGL 3.0 are clarified by
495bd8deadSopenharmony_ci    this extension.
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ciOverview
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    This extension provides an alternative provoking vertex convention
545bd8deadSopenharmony_ci    for rendering lines, triangles, and (optionally depending on the
555bd8deadSopenharmony_ci    implementation) quads.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    The provoking vertex of a primitive is the vertex that determines the
585bd8deadSopenharmony_ci    constant primary and secondary colors when flat shading is enabled.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci    In OpenGL, the provoking vertex for triangle, quad, line, and
615bd8deadSopenharmony_ci    (trivially) point primitives is the last vertex used to assemble
625bd8deadSopenharmony_ci    the primitive.  The polygon primitive is an exception in OpenGL where
635bd8deadSopenharmony_ci    the first vertex of a polygon primitive determines the color of the
645bd8deadSopenharmony_ci    polygon, even if actually broken into triangles and/or quads.
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    See section 2.14.7 (Flatshading) of the OpenGL 2.1 specification,
675bd8deadSopenharmony_ci    particularly Table 2.12 for more details.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci    Alternatively the provoking vertex could be the first vertex of
705bd8deadSopenharmony_ci    the primitive.  Other APIs with flat-shading functionality such
715bd8deadSopenharmony_ci    as Reality Lab and Direct3D have adopted the "first vertex of the
725bd8deadSopenharmony_ci    primitive" convention to determine the provoking vertex.  However,
735bd8deadSopenharmony_ci    these APIs lack quads so do not have a defined provoking vertex
745bd8deadSopenharmony_ci    convention for quads.
755bd8deadSopenharmony_ci
765bd8deadSopenharmony_ci    The motivation for this extension is to allow applications developed
775bd8deadSopenharmony_ci    for APIs with a "first vertex of the primitive" provoking vertex to
785bd8deadSopenharmony_ci    be easily converted to OpenGL.
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ciNew Procedures and Functions
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ci    void ProvokingVertexEXT(enum mode);
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ciNew Tokens
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ci    Accepted by the <mode> parameter of ProvokingVertexEXT:
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci        FIRST_VERTEX_CONVENTION_EXT                   0x8E4D
895bd8deadSopenharmony_ci        LAST_VERTEX_CONVENTION_EXT                    0x8E4E
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
925bd8deadSopenharmony_ci    GetFloatv, and GetDoublev:
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ci        PROVOKING_VERTEX_EXT                          0x8E4F
955bd8deadSopenharmony_ci        QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT  0x8E4C
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.1 Specification (OpenGL Operation)
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci -- Section 2.14.7 "Flatshading" (page 69)
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci    Replace the entire section with:
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci    "A primitive may be flatshaded, meaning that all vertices of the
1045bd8deadSopenharmony_ci    primitive are assigned the same color index or the same primary or
1055bd8deadSopenharmony_ci    secondary colors.  These colors are the colors of the vertex that
1065bd8deadSopenharmony_ci    spawned the primitive.  Table 2.12 summaries the possibilities.
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci    Flatshading is controlled by
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci       void ShadeModel(enum shadeMode);
1115bd8deadSopenharmony_ci       void ProvokingVertexEXT(enum provokeMode);
1125bd8deadSopenharmony_ci    
1135bd8deadSopenharmony_ci    shadeMode value must be either the symbolic constants SMOOTH or FLAT.
1145bd8deadSopenharmony_ci    If shadeMode is SMOOTH (the initial state), the vertex colors are
1155bd8deadSopenharmony_ci    treated individually.  If shadeMode is FLAT, flatshading is turned on.
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci    provokeMode value must be either FIRST_VERTEX_CONVENTION_EXT
1185bd8deadSopenharmony_ci    or LAST_VERTEX_CONVENTION_EXT.  If provokeMode is
1195bd8deadSopenharmony_ci    LAST_VERTEX_CONVENTION_EXT (the initial state), the "last vertex
1205bd8deadSopenharmony_ci    convention" column of table 2.12 applies when flat shading; otherwise,
1215bd8deadSopenharmony_ci    the "first vertex convention" column applies when flat shading.
1225bd8deadSopenharmony_ci    The provoking vertex behavior of quad primitives is implementation
1235bd8deadSopenharmony_ci    dependent.  Implementations can choose to either respect (follow)
1245bd8deadSopenharmony_ci    the state set by ProvokingVertexEXT for quad primitives (and, in
1255bd8deadSopenharmony_ci    this case, return true for the QUADS_FOLLOW_PROVOKING_VERTEX_EXT
1265bd8deadSopenharmony_ci    implementation-dependent state) or unconditionally implement the
1275bd8deadSopenharmony_ci    last vertex convention for quad primitives (and, in this case,
1285bd8deadSopenharmony_ci    return false for QUADS_FOLLOW_PROVOKING_VERTEX_EXT).
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci    ShadeModel and ProvokingVertexEXT each require one bit of state.
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci                                     First vertex  Last vertex
1335bd8deadSopenharmony_ci        Primitive type of polygon i  convention    convention
1345bd8deadSopenharmony_ci        ===========================  ============  ==================================================
1355bd8deadSopenharmony_ci        point                             i        i                                                   <- same
1365bd8deadSopenharmony_ci
1375bd8deadSopenharmony_ci        independent line                  2i-1     2i 
1385bd8deadSopenharmony_ci        line loop                         i        i+1, if i<n
1395bd8deadSopenharmony_ci                                                   1,   if i==n
1405bd8deadSopenharmony_ci        line strip                        i        i+1
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci        independent triangle              3i-2     3i
1435bd8deadSopenharmony_ci        triangle strip                    i        i+2
1445bd8deadSopenharmony_ci        triangle fan                      i+1      i+2
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci        independent quad                  4i-3     4i,   if QUADS_FOLLOW_PROVOKING_VERTEX_EXT = true
1475bd8deadSopenharmony_ci                                          4i       4i,   if QUADS_FOLLOW_PROVOKING_VERTEX_EXT = false  <- same
1485bd8deadSopenharmony_ci        quad strip                        2i-1     2i+2, if QUADS_FOLLOW_PROVOKING_VERTEX_EXT = true
1495bd8deadSopenharmony_ci                                          2i+2     2i+2, if QUADS_FOLLOW_PROVOKING_VERTEX_EXT = false  <- same
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci        single polygon (i=1)              1        1                                                   <- same
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci        line adjacency                    4i-2     4i-1
1545bd8deadSopenharmony_ci        line strip adjacency              i+1      i+2
1555bd8deadSopenharmony_ci        triangle adjacency                6i-5     6i-1
1565bd8deadSopenharmony_ci        triangle strip adjacency          2i-1     2i+3
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci    Table 2.12: Polygon flatshading color selection.  The color used for
1595bd8deadSopenharmony_ci    flat shading the ith polygon generated by the indicated Begin/End
1605bd8deadSopenharmony_ci    type are derived from the current color (if lighting is disabled)
1615bd8deadSopenharmony_ci    in effect when the indicated vertex is specified.  If lighting
1625bd8deadSopenharmony_ci    is enabled or a vertex shader is used, the colors are produced
1635bd8deadSopenharmony_ci    by lighting or vertex shading (respectively) the indicated vertex.
1645bd8deadSopenharmony_ci    Vertices are numbered 1 through n, where n is the number of vertices
1655bd8deadSopenharmony_ci    between the Begin/End pair."
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.1 Specification (Rasterization)
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci    None
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.1 Specification (Per-Fragment
1725bd8deadSopenharmony_ciOperations and the Frame Buffer)
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci    None
1755bd8deadSopenharmony_ci
1765bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.1 Specification (Special
1775bd8deadSopenharmony_ciFunctions)
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    None
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.1 Specification (State and
1825bd8deadSopenharmony_ciState Requests)
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ci    None
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    None
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    None
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ciDependencies on ARB_geometry_shader4, EXT_geometry_shader4,
1955bd8deadSopenharmony_ciNV_geometry_shader4, and/or NV_gpu_program4:
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    If none of ARB_geometry_shader4, EXT_geometry_shader4,
1985bd8deadSopenharmony_ci    NV_geometry_shader4, or NV_gpu_program4 are supported, ignore
1995bd8deadSopenharmony_ci    the rows of table 2.12 for line adjacency, line strip adjacency,
2005bd8deadSopenharmony_ci    triangle adjacency, and triangle strip adjacency.
2015bd8deadSopenharmony_ci
2025bd8deadSopenharmony_ciDependencies on EXT_transform_feedback, NV_transform_feedback, and/or the
2035bd8deadSopenharmony_citransform feedback functionality integrated into the core by OpenGL 3.0:
2045bd8deadSopenharmony_ci    
2055bd8deadSopenharmony_ci    Clarify the statement describing when transform feedback occurs
2065bd8deadSopenharmony_ci    (in section 2.18 of the OpenGL 3.1 specification) to read:
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci    "The vertices are fed back after vertex color clamping, but before
2095bd8deadSopenharmony_ci    flatshading and clipping."
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci    (The "flatshading and" phrase is newly clarifying.)
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ciGLX Protocol
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci    A new GL rendering command is added. The following command is sent to the 
2165bd8deadSopenharmony_ci    server as part of a glXRender request:
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ci        ProvokingVertexEXT
2195bd8deadSopenharmony_ci            2           8          rendering command length
2205bd8deadSopenharmony_ci            2           4227       rendering command opcode
2215bd8deadSopenharmony_ci            4           ENUM       provokeMode
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ciErrors
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    INVALID_ENUM is generated when ProvokingVertexEXT is called with
2265bd8deadSopenharmony_ci    a <provokeMode> that is not either FIRST_VERTEX_CONVENTION_EXT or
2275bd8deadSopenharmony_ci    LAST_VERTEX_CONVENTION_EXT.
2285bd8deadSopenharmony_ci
2295bd8deadSopenharmony_ciNew State
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ci(table 6.11, page 276) add the following entry:
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ciGet Value             Type  Get Command  Initial Value               Description       Sec     Attribute
2345bd8deadSopenharmony_ci--------------------  ----  -----------  --------------------------  ----------------  ------  ---------
2355bd8deadSopenharmony_ciPROVOKING_VERTEX_EXT  Z2    GetIntegerv  LAST_VERTEX_CONVENTION_EXT  Provoking vertex  2.14.7  lighting
2365bd8deadSopenharmony_ci                                                                     convention
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci(table 6.36, page 301) add the following entry:
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ciGet Value                          Type  Get Command  Initial Value  Description        Sec     Attribute
2415bd8deadSopenharmony_ci---------------------------------  ----  -----------  -------------  -----------------  ------  ---------
2425bd8deadSopenharmony_ciQUADS_FOLLOW_PROVOKING_VERTEX_EXT  B     GetBooleanv  -              True if quad       2.14.7  -
2435bd8deadSopenharmony_ci                                                                     primitives follow
2445bd8deadSopenharmony_ci                                                                     provoking vertex
2455bd8deadSopenharmony_ci                                                                     convention
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ciNew Implementation Dependent State
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci    None
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ciNVIDIA Implementation Details
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci    GeForce 8 (G8x, G9x, GT1xx) and up GPUs report true for
2545bd8deadSopenharmony_ci    QUADS_FOLLOW_PROVOKING_VERTEX_EXT.
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci    GeForce 6 and 7 (NV4x, G7x) GPUs report false for
2575bd8deadSopenharmony_ci    QUADS_FOLLOW_PROVOKING_VERTEX_EXT.
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ciIssues
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci    1.  What should this extension be called?
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci        RESOLVED:  EXT_provoking_vertex
2645bd8deadSopenharmony_ci
2655bd8deadSopenharmony_ci        The phrase "provoking vertex" is not used in the core OpenGL
2665bd8deadSopenharmony_ci        specification but it is the accepted jargon for the functionality
2675bd8deadSopenharmony_ci        in question.
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    2.  How should quads be handled?
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci        RESOLVED:  Ideally, quadrilateral primitives (GL_QUADS and
2725bd8deadSopenharmony_ci        GL_QUAD_STRIP) would follow the provoking vertex mode.
2735bd8deadSopenharmony_ci
2745bd8deadSopenharmony_ci        Other existing APIs with different flatshading conventions do
2755bd8deadSopenharmony_ci        not support quads.
2765bd8deadSopenharmony_ci
2775bd8deadSopenharmony_ci        Rather than force support for both the first and last convention
2785bd8deadSopenharmony_ci        for quads (which no other API supports), instead this extension
2795bd8deadSopenharmony_ci        provides implementations the flexibility to advertise whether
2805bd8deadSopenharmony_ci        or not quads respect the provoking vertex or not.
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ci        This resolution ensures more hardware vendors can support
2835bd8deadSopenharmony_ci        this extension.  Hardware vendors which support both OpenGL and
2845bd8deadSopenharmony_ci        Direct3D's provoking vertex conventions must have support for
2855bd8deadSopenharmony_ci        "first vertex" for triangles and lines because Direct3D demands
2865bd8deadSopenharmony_ci        these conventions.  Direct3D does not demand a convention for
2875bd8deadSopenharmony_ci        quads.  However every vendor supporting OpenGL can support the
2885bd8deadSopenharmony_ci        "last vertex" mode for quads.  Leaving the quad behavior up
2895bd8deadSopenharmony_ci        to the OpenGL implementation means hardware can simply always
2905bd8deadSopenharmony_ci        switch to the OpenGL quad behavior when emitting quads.
2915bd8deadSopenharmony_ci
2925bd8deadSopenharmony_ci        See issue #12 for more details about how the
2935bd8deadSopenharmony_ci        implementation-dependent handling of quads is advertised.
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci    3.  How should the specification language be written for this
2965bd8deadSopenharmony_ci        extension?
2975bd8deadSopenharmony_ci
2985bd8deadSopenharmony_ci        RESOLVED:  Update table 2.12 for all supported primitives.
2995bd8deadSopenharmony_ci
3005bd8deadSopenharmony_ci        The current language describes how points and lines are handled
3015bd8deadSopenharmony_ci        in prose but the behavior for triangles, quads, and polygons is
3025bd8deadSopenharmony_ci        specified in table 2.12.
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci        Put all the Begin/End batch types in a single table with two
3055bd8deadSopenharmony_ci        columns specifying the "first vertex convention" and "last vertex
3065bd8deadSopenharmony_ci        convention" provoking vertex modes respectively.
3075bd8deadSopenharmony_ci
3085bd8deadSopenharmony_ci        A unified table is less ambiguous than a combination of a table
3095bd8deadSopenharmony_ci        and prose.
3105bd8deadSopenharmony_ci
3115bd8deadSopenharmony_ci    4.  What token names for the provoking vertex conventions should
3125bd8deadSopenharmony_ci        be used?
3135bd8deadSopenharmony_ci
3145bd8deadSopenharmony_ci        RESOLVED:  GL_FIRST_VERTEX_CONVENTION_EXT and
3155bd8deadSopenharmony_ci        GL_LAST_VERTEX_CONVENTION_EXT (the initial state, consistent
3165bd8deadSopenharmony_ci        with OpenGL's unextended operation).
3175bd8deadSopenharmony_ci
3185bd8deadSopenharmony_ci        The word "convention" is used because (see issue #2), the "first
3195bd8deadSopenharmony_ci        vertex" or "last vertex" rules are not iron-clad as they may or
3205bd8deadSopenharmony_ci        may do not apply to quads.
3215bd8deadSopenharmony_ci
3225bd8deadSopenharmony_ci        The provoking vertex behavior for polygons and triangle fans
3235bd8deadSopenharmony_ci        also isn't strictly first or last vertex:  Polygons always use
3245bd8deadSopenharmony_ci        the first vertex (no matter the provoking vertex convention).
3255bd8deadSopenharmony_ci        Triangle fans don't really use the first vertex (the spoke vertex)
3265bd8deadSopenharmony_ci        when using the "first vertex" provoking vertex rule; see issue #7.
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci    5.  IRIS GL had a provoking vertex convention for polygons where the
3295bd8deadSopenharmony_ci        last vertex of a polygon primitive determined the flat shaded
3305bd8deadSopenharmony_ci        color of the polygon.  Should we support this convention?
3315bd8deadSopenharmony_ci
3325bd8deadSopenharmony_ci        RESOLVED:  No.
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci        Interesting IRIS GL applications relying on this convention
3355bd8deadSopenharmony_ci        are assuredly non-existent at this point.  This convention
3365bd8deadSopenharmony_ci        also requires waiting until all the vertices for a polygon
3375bd8deadSopenharmony_ci        (which OpenGL does not bound) are specified before the polygon
3385bd8deadSopenharmony_ci        can begin being rasterized.  The IRIS GL convention was dubious
3395bd8deadSopenharmony_ci        for this reason and OpenGL's designers were correct to abandon
3405bd8deadSopenharmony_ci        IRIS GL's polygon provoking vertex convention.
3415bd8deadSopenharmony_ci
3425bd8deadSopenharmony_ci    6.  How should line loops behave?
3435bd8deadSopenharmony_ci
3445bd8deadSopenharmony_ci        RESOLVED:  Line loops in GL_FIRST_VERTEX_CONVENTION_EXT mode
3455bd8deadSopenharmony_ci        should behave as though it were a line strip with the first
3465bd8deadSopenharmony_ci        vertex repeated at the end.  In other words, the first vertex
3475bd8deadSopenharmony_ci        of the line loop provokes the color for the line primitive that
3485bd8deadSopenharmony_ci        closes the line loop.
3495bd8deadSopenharmony_ci
3505bd8deadSopenharmony_ci        Direct3D does not support line loops.
3515bd8deadSopenharmony_ci
3525bd8deadSopenharmony_ci    7.  How are triangle fans handled?
3535bd8deadSopenharmony_ci
3545bd8deadSopenharmony_ci        RESOLVED:  The first vertex of a triangle fan is the spoke vertex.
3555bd8deadSopenharmony_ci        Triangle fans in GL_FIRST_VERTEX_CONVENTION_EXT mode should use
3565bd8deadSopenharmony_ci        the first non-spoke vertex of the primitive as the provoking
3575bd8deadSopenharmony_ci        vertex.  In other words, the spoke vertex is never the provoking
3585bd8deadSopenharmony_ci        vertex (in either convention).
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci        The rationale for this is to match DirectX 9's triangle
3615bd8deadSopenharmony_ci        fan behavior.  The rationale for the DirectX 9 behavior is
3625bd8deadSopenharmony_ci        (presumably) that if the spoke vertex was considered the "first
3635bd8deadSopenharmony_ci        vertex" of every primitive in a triangle fan, every flat shaded
3645bd8deadSopenharmony_ci        primitive in a triangle fan would necessarily have the spoke
3655bd8deadSopenharmony_ci        vertex's color, which isn't very interesting.
3665bd8deadSopenharmony_ci
3675bd8deadSopenharmony_ci        (DirectX 10 does not support triangle fans.)
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci    8.  How does the provoking vertex convention affect primitives
3705bd8deadSopenharmony_ci        generated by a geometry shader?
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci        RESOLVED:  The provoking vertex convention affects primitives
3735bd8deadSopenharmony_ci        whether they are generated by geometry shaders or conventional
3745bd8deadSopenharmony_ci        (non-geometry shader) primitive assembly.
3755bd8deadSopenharmony_ci
3765bd8deadSopenharmony_ci        Geometry shaders only generate point, line strips, and triangle
3775bd8deadSopenharmony_ci        strips (not line loops, triangle fans, polygons, or quads).
3785bd8deadSopenharmony_ci        (So the GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT is
3795bd8deadSopenharmony_ci        irrelevant when a geometry program or shader is active.)
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci        This makes the supporting the first and last vertex conventions
3825bd8deadSopenharmony_ci        for primitives generated by geometry shaders "simple" because in
3835bd8deadSopenharmony_ci        the points, line strip, and triangle strip cases, the convention
3845bd8deadSopenharmony_ci        really is to use either first or last vertex to define the
3855bd8deadSopenharmony_ci        provoking vertex (no caveats).
3865bd8deadSopenharmony_ci
3875bd8deadSopenharmony_ci        There's no special specification language to support the fact that
3885bd8deadSopenharmony_ci        the provoking vertex convention applies to primitives generated
3895bd8deadSopenharmony_ci        by geometry shaders because flat shading behavior is described
3905bd8deadSopenharmony_ci        in Chapter 3's rasterization discussion which is all subsequent
3915bd8deadSopenharmony_ci        to the geometry shader processing inserted into Chapter 2.
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci        DirectX 10 geometry shaders can output flat attributes according
3945bd8deadSopenharmony_ci        to Direct3D's "first vertex provokes" convention for line and
3955bd8deadSopenharmony_ci        triangle output primitives from a geometry shader.  So matching
3965bd8deadSopenharmony_ci        the DirectX 10 geometry shader behavior for flat shading requires
3975bd8deadSopenharmony_ci        setting the provoking vertex to GL_FIRST_VERTEX_CONVENTION_EXT.
3985bd8deadSopenharmony_ci
3995bd8deadSopenharmony_ci        This said, the OpenGL default convention of "last vertex" for the
4005bd8deadSopenharmony_ci        provoking vertex tends to be more useful for geometry shaders.
4015bd8deadSopenharmony_ci        By deferring the computation of the flat shaded color to the
4025bd8deadSopenharmony_ci        last vertex of every primitive, that tends to give the geometry
4035bd8deadSopenharmony_ci        shader compiler the maximum allowance for scheduling computation
4045bd8deadSopenharmony_ci        and texturing operations required to compute the flat shaded
4055bd8deadSopenharmony_ci        color as long as possible (that is, until the last vertex of
4065bd8deadSopenharmony_ci        the primitive).
4075bd8deadSopenharmony_ci
4085bd8deadSopenharmony_ci    9.  Should there be an OPTION or #pragma for geometry shader assembly
4095bd8deadSopenharmony_ci        and GLSL respectively to request the specific provoking vertex
4105bd8deadSopenharmony_ci        convention for the shader?
4115bd8deadSopenharmony_ci
4125bd8deadSopenharmony_ci        RESOLVED:  No.
4135bd8deadSopenharmony_ci
4145bd8deadSopenharmony_ci        The provoking vertex is context state that doesn't belong within
4155bd8deadSopenharmony_ci        a shader as a pragma anymore than the stencil state belongs
4165bd8deadSopenharmony_ci        within the shader.  Overriding context state based on a pragma
4175bd8deadSopenharmony_ci        in a shader introduces unfortunate validation interactions that
4185bd8deadSopenharmony_ci        will slow down shader binds.
4195bd8deadSopenharmony_ci
4205bd8deadSopenharmony_ci        Geometry shaders written for DirectX 10 and using flat attributes
4215bd8deadSopenharmony_ci        expect the "first vertex" provoking vertex convention but the
4225bd8deadSopenharmony_ci        application is better off specifying the proper provoking vertex
4235bd8deadSopenharmony_ci        convention for shaders just as is done with other context state.
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci        TransGaming supports this resolution to not support a pragma.
4265bd8deadSopenharmony_ci
4275bd8deadSopenharmony_ci    10. How do geometry shader input primitives interact with this
4285bd8deadSopenharmony_ci        extension?
4295bd8deadSopenharmony_ci
4305bd8deadSopenharmony_ci        RESOLVED:  Table 2.12 includes the new primitives types
4315bd8deadSopenharmony_ci        introduced by geometry shaders (GL_LINES_ADJACENCY_ARB,
4325bd8deadSopenharmony_ci        GL_LINE_STRIP_ADJACENCY_ARB, GL_TRIANGLES_ADJACENCY_ARB, and
4335bd8deadSopenharmony_ci        GL_TRIANGLE_STRIP_ADJACENCY_ARB).  However the entries for these
4345bd8deadSopenharmony_ci        primitive types are only relevant when these new primitive types
4355bd8deadSopenharmony_ci        are used with NO geometry shader enabled.
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ci        When a geometry shader is enabled, the only primitive output types
4385bd8deadSopenharmony_ci        are points, line strips, and triangle strips.
4395bd8deadSopenharmony_ci
4405bd8deadSopenharmony_ci    11. To what attribute set should the provoking vertex belong?
4415bd8deadSopenharmony_ci
4425bd8deadSopenharmony_ci        RESOLVED:  Lighting (GL_LIGHTING_BIT).
4435bd8deadSopenharmony_ci
4445bd8deadSopenharmony_ci        This is because the provoking vertex bit is described in the
4455bd8deadSopenharmony_ci        same context as the shade model (GL_SHADE_MODEL) setting, and
4465bd8deadSopenharmony_ci        the shade model state is part of the lighting attribute set.
4475bd8deadSopenharmony_ci
4485bd8deadSopenharmony_ci    12. How should the allowance for handling quadrilateral primitives
4495bd8deadSopenharmony_ci        be advertised?
4505bd8deadSopenharmony_ci
4515bd8deadSopenharmony_ci        RESOLVED:  Because this extension is intended to facilitate
4525bd8deadSopenharmony_ci        supporting Direct3D content that depends on the Direct3D's
4535bd8deadSopenharmony_ci        provoking vertex convention yet Direct3D does not support quad
4545bd8deadSopenharmony_ci        primitives (as OpenGL provides with GL_QUAD_STRIP and GL_QUADS),
4555bd8deadSopenharmony_ci        the particular provoking vertex behavior of quads is not crucial
4565bd8deadSopenharmony_ci        to this extension's intended application.
4575bd8deadSopenharmony_ci
4585bd8deadSopenharmony_ci        In the interest of making this extension's functionality for
4595bd8deadSopenharmony_ci        triangle and line primitives broadly available (the primitives
4605bd8deadSopenharmony_ci        Direct3D does support with a first vertex provoking vertex
4615bd8deadSopenharmony_ci        convention), this extension does not mandate a single uniform
4625bd8deadSopenharmony_ci        behavior for quad primitives.  Mandating a particular behavior
4635bd8deadSopenharmony_ci        for quad primitives would, for some implementations, encumber the
4645bd8deadSopenharmony_ci        performance of this extension in the non-quad case or make this
4655bd8deadSopenharmony_ci        implementation of this extension needlessly complex to implement.
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ci        Instead the GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT
4685bd8deadSopenharmony_ci        implementation-dependent boolean indicates whether or not quads
4695bd8deadSopenharmony_ci        (generated by GL_QUADS or GL_QUAD_STRIP) should abide by the
4705bd8deadSopenharmony_ci        provoking vertex convention or not.
4715bd8deadSopenharmony_ci
4725bd8deadSopenharmony_ci        Whether or not the GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT
4735bd8deadSopenharmony_ci        state is true or false, the provoking vertex behavior of quads
4745bd8deadSopenharmony_ci        is well-defined in either case.
4755bd8deadSopenharmony_ci
4765bd8deadSopenharmony_ci        The recommended, though implementation-dependent, value for
4775bd8deadSopenharmony_ci        GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT is true because
4785bd8deadSopenharmony_ci        this means quads, will like lines and triangles, follow the
4795bd8deadSopenharmony_ci        GL_PROVOKING_VERTEX_EXT state as indicated.
4805bd8deadSopenharmony_ci
4815bd8deadSopenharmony_ci    13. How does the provoking vertex state interact with primitive
4825bd8deadSopenharmony_ci        restart?
4835bd8deadSopenharmony_ci
4845bd8deadSopenharmony_ci        RESOLVED:  Orthogonally so no specific specification language
4855bd8deadSopenharmony_ci        describing the interaction is required.
4865bd8deadSopenharmony_ci
4875bd8deadSopenharmony_ci        Specifically a primitive restart acts as a glEnd/glBegin
4885bd8deadSopenharmony_ci        sequence so it restarts the primitive numbering to 1 for the
4895bd8deadSopenharmony_ci        vertex immediately following the restart index.
4905bd8deadSopenharmony_ci
4915bd8deadSopenharmony_ci    14. Should the provoking vertex behavior apply to both the primary
4925bd8deadSopenharmony_ci        and secondary color?
4935bd8deadSopenharmony_ci
4945bd8deadSopenharmony_ci        RESOLVED:  Yes, the provoking vertex decides both the primary and
4955bd8deadSopenharmony_ci        secondary color of a flat-shaded primitive.  That's consistent
4965bd8deadSopenharmony_ci        with Direct3D's provoking vertex convention as well as OpenGL's
4975bd8deadSopenharmony_ci        current behavior.
4985bd8deadSopenharmony_ci
4995bd8deadSopenharmony_ci    15. Should the provoking vertex behavior be specified with a
5005bd8deadSopenharmony_ci        glEnable/glDisable token instead of glProvokingVertexEXT?
5015bd8deadSopenharmony_ci
5025bd8deadSopenharmony_ci        RESOLVED:  The provoking vertex API is closely related
5035bd8deadSopenharmony_ci        to glShadeModel which uses an enumerated mode rather than
5045bd8deadSopenharmony_ci        glEnable/glDisable to specify flat or smooth shading so the API
5055bd8deadSopenharmony_ci        mimics the glShadeModel approach.
5065bd8deadSopenharmony_ci
5075bd8deadSopenharmony_ci        This results in a fairly readable API usage that is more easily
5085bd8deadSopenharmony_ci        groaked by unfamiliar programmers:
5095bd8deadSopenharmony_ci
5105bd8deadSopenharmony_ci            glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT);
5115bd8deadSopenharmony_ci
5125bd8deadSopenharmony_ci        instead of:
5135bd8deadSopenharmony_ci
5145bd8deadSopenharmony_ci             glEnable(GL_FIRST_VERTEX_CONVENTION_EXT);
5155bd8deadSopenharmony_ci
5165bd8deadSopenharmony_ci        It is also not clear that the provoking vertex convention is
5175bd8deadSopenharmony_ci        really a single enable.  The convention behaves differently
5185bd8deadSopenharmony_ci        depending on the primitive type.  For example, GL_POLYGON always
5195bd8deadSopenharmony_ci        uses the first vertex as the provoking vertex regardless of the
5205bd8deadSopenharmony_ci        provoking vertex state.
5215bd8deadSopenharmony_ci
5225bd8deadSopenharmony_ci    16. Does the OpenGL Shading Language (GLSL) 1.30 "flat" varying
5235bd8deadSopenharmony_ci        qualifier respect the provoking vertex state?
5245bd8deadSopenharmony_ci
5255bd8deadSopenharmony_ci        RESOLVED:  Yes.
5265bd8deadSopenharmony_ci
5275bd8deadSopenharmony_ci        The GLSL 1.30 specification says "This variable [qualified as
5285bd8deadSopenharmony_ci        flat] will come from a single provoking vertex, as described by
5295bd8deadSopenharmony_ci        the OpenGL Graphics System Specification."  This extension amends
5305bd8deadSopenharmony_ci        how the provoking vertex is described so no GLSL specification
5315bd8deadSopenharmony_ci        update is required.  This does imply that user-declared varyings
5325bd8deadSopenharmony_ci        in a GLSL shader declared with "flat" will have the provoking
5335bd8deadSopenharmony_ci        vertex convention applied to determine their value.
5345bd8deadSopenharmony_ci
5355bd8deadSopenharmony_ci    17. How does the provoking vertex apply to Direct3D 10?
5365bd8deadSopenharmony_ci
5375bd8deadSopenharmony_ci        RESOLVED:  Direct3D 10 has deprecated the D3DSHADEMODE state for
5385bd8deadSopenharmony_ci        controlling flat or smooth (Gouraud) shading.  However there is
5395bd8deadSopenharmony_ci        still the concept of a provoking vertex (called the "leading
5405bd8deadSopenharmony_ci        vertex" by Direct3D 10) which still corresponds to this
5415bd8deadSopenharmony_ci        extension's "first vertex" convention.
5425bd8deadSopenharmony_ci
5435bd8deadSopenharmony_ci        Use of the leading (provoking) vertex for constant (flat)
5445bd8deadSopenharmony_ci        interpolation is indicated by Direct3D 10's "nointerpolation"
5455bd8deadSopenharmony_ci        variable storage class (sometimes called an interpolation
5465bd8deadSopenharmony_ci        modifier).
5475bd8deadSopenharmony_ci
5485bd8deadSopenharmony_ci    18. Does the NV_gpu_program4 "FLAT" attribute modifier respect the
5495bd8deadSopenharmony_ci        provoking vertex state?
5505bd8deadSopenharmony_ci
5515bd8deadSopenharmony_ci        RESOLVED:  Yes.  NVIDIA's NV_gpu_program4 extension, describing
5525bd8deadSopenharmony_ci        an OpenGL assembly for Shader Model 4.0, allows a FLAT modifier
5535bd8deadSopenharmony_ci        to be specified for fragment program inputs.  The NV_gpu_program4
5545bd8deadSopenharmony_ci        specification says "If an attribute is flat-shaded, it will be
5555bd8deadSopenharmony_ci        taken from the output attribute of the provoking vertex of the
5565bd8deadSopenharmony_ci        primitive using the same data type." This extension amends
5575bd8deadSopenharmony_ci        how the provoking vertex is described so no NV_gpu_program4
5585bd8deadSopenharmony_ci        specification update is required.
5595bd8deadSopenharmony_ci
5605bd8deadSopenharmony_ci    19. How does this extension interact with transform feedback?
5615bd8deadSopenharmony_ci
5625bd8deadSopenharmony_ci        RESOLVED:  Attribute components written out by transform feedback
5635bd8deadSopenharmony_ci        are NOT affected by the flatshading or provoking vertex state.
5645bd8deadSopenharmony_ci
5655bd8deadSopenharmony_ci        While this specification is written against OpenGL 2.1, transform
5665bd8deadSopenharmony_ci        feedback was made core functionality with OpenGL 3.0 and then
5675bd8deadSopenharmony_ci        the order of the transform feedback was moved in the OpenGL
5685bd8deadSopenharmony_ci        3.1 specification.  Therefore the subsequent discussion uses
5695bd8deadSopenharmony_ci        the more recent 3.1 sectioning.
5705bd8deadSopenharmony_ci
5715bd8deadSopenharmony_ci        Specifically the OpenGL 3.1 specification (section 2.18: Transform
5725bd8deadSopenharmony_ci        Feedback) says "The vertices are fed back after vertex color
5735bd8deadSopenharmony_ci        clamping, but before clipping."
5745bd8deadSopenharmony_ci
5755bd8deadSopenharmony_ci        This statement is unclear because flatshading (section 2.13.7:
5765bd8deadSopenharmony_ci        Flatshading) happens inbetween vertex color clamping (section
5775bd8deadSopenharmony_ci        2.13.6: Clamping or Masking) and primitive clipping (section 2.20:
5785bd8deadSopenharmony_ci        Primitive Clipping).
5795bd8deadSopenharmony_ci
5805bd8deadSopenharmony_ci        Base on this issue the sentence is clarified to read: "The
5815bd8deadSopenharmony_ci        vertices are fed back after vertex color clamping, but before
5825bd8deadSopenharmony_ci        [flatshading and] clipping."
5835bd8deadSopenharmony_ci
5845bd8deadSopenharmony_ci        For reference, the original EXT_transform_feedback extension has
5855bd8deadSopenharmony_ci        this same language ("The vertices are fed back after vertex color
5865bd8deadSopenharmony_ci        clamping, but before clipping.") but follows that sentence with:
5875bd8deadSopenharmony_ci        "If a geometry shader is active, the vertices recorded are those
5885bd8deadSopenharmony_ci        emitted from the geometry shader."  Technically geometry shading
5895bd8deadSopenharmony_ci        takes place prior to even vertex color clamping.
5905bd8deadSopenharmony_ci
5915bd8deadSopenharmony_ci        Clearly flat shading needs to happen prior to clipping so that
5925bd8deadSopenharmony_ci        clipped vertices can share the flat shaded attributes of the
5935bd8deadSopenharmony_ci        primitive prior to any potential clipping.
5945bd8deadSopenharmony_ci
5955bd8deadSopenharmony_ci        This resolution is consistent with DirectX 10's behavior.
5965bd8deadSopenharmony_ci        Technically, DirectX 10 says that vertices output through
5975bd8deadSopenharmony_ci        transform feedback (which DirectX 10 calls "stream output")
5985bd8deadSopenharmony_ci        only have to be defined for constant attributes of the primitive's
5995bd8deadSopenharmony_ci        leading vertex (constant attributes are those that OpenGL would
6005bd8deadSopenharmony_ci        call flatshaded).  Other constant attributes for non-leading
6015bd8deadSopenharmony_ci        vertices may be undefined.  Leaving such constant attributes
6025bd8deadSopenharmony_ci        undefined is undesirable, particularly given how OpenGL operates.
6035bd8deadSopenharmony_ci        It is well-defined and more useful to simply output the value
6045bd8deadSopenharmony_ci        of the vertex's attribute prior to any flatshading.  This is
6055bd8deadSopenharmony_ci        particularly desirable for OpenGL because with this extension
6065bd8deadSopenharmony_ci        (and even prior to supporting this extension), the provoking
6075bd8deadSopenharmony_ci        vertex is not always the leading vertex.
6085bd8deadSopenharmony_ci
6095bd8deadSopenharmony_ci        To clarify further, while this resolution is consistent with
6105bd8deadSopenharmony_ci        DirectX 10, an OpenGL implementation that supports transform
6115bd8deadSopenharmony_ci        feedback has no undefined behavior specified.  The simplest way
6125bd8deadSopenharmony_ci        to describe what happens is that attribute components written
6135bd8deadSopenharmony_ci        out by transform feedback are the attribute component values
6145bd8deadSopenharmony_ci        of vertices AFTER (optional) geometry shading and vertex color
6155bd8deadSopenharmony_ci        clamping but PRIOR to flatshading and primitive clipping.
6165bd8deadSopenharmony_ci
6175bd8deadSopenharmony_ciRevision History
6185bd8deadSopenharmony_ci
6195bd8deadSopenharmony_ci    Rev.    Date    Author     Changes
6205bd8deadSopenharmony_ci    ----  -------- ---------  ---------------------------------------------
6215bd8deadSopenharmony_ci     12   5/11/09  mjk        Resolve issue 12 with feedback from
6225bd8deadSopenharmony_ci                              Daniel Koch
6235bd8deadSopenharmony_ci     11   4/17/09  mjk        grammar and typo fixes
6245bd8deadSopenharmony_ci     10   3/26/09  mjk        typo fixes, more contributors listed, clarify
6255bd8deadSopenharmony_ci                              transform feedback interaction
6265bd8deadSopenharmony_ci      9   3/12/09  mjk        dependencies on geometry shading extensions
6275bd8deadSopenharmony_ci      8   3/11/09  mjk        Fix issues 2, 4 & 7, add issues 16, 17, & 18
6285bd8deadSopenharmony_ci      7   3/7/09   mjk        Fix line adj typo, re-order table
6295bd8deadSopenharmony_ci      6   3/3/09   mjk        Assign enums, add issues 11-15
6305bd8deadSopenharmony_ci      5   1/16/08  mjk        Geometry shader interactions
6315bd8deadSopenharmony_ci      4   1/6/08   mjk        Add line loop behavior,
6325bd8deadSopenharmony_ci                              change triangle fan
6335bd8deadSopenharmony_ci      3   1/31/07  mjk        Jamie review feedback
6345bd8deadSopenharmony_ci      2   1/24/07  mjk        Fix quad entries in table
6355bd8deadSopenharmony_ci      1   1/11/07  mjk        Initial version
6365bd8deadSopenharmony_ci
637