15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_tessellation_shader
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_tessellation_shader
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Barthold Lichtenbelt, NVIDIA
165bd8deadSopenharmony_ci    Bill Licea-Kane, AMD
175bd8deadSopenharmony_ci    Bruce Merry, ARM
185bd8deadSopenharmony_ci    Chris Dodd, NVIDIA
195bd8deadSopenharmony_ci    Eric Werness, NVIDIA
205bd8deadSopenharmony_ci    Graham Sellers, AMD
215bd8deadSopenharmony_ci    Greg Roth, NVIDIA
225bd8deadSopenharmony_ci    Ignacio Castano, NVIDIA
235bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA
245bd8deadSopenharmony_ci    Nick Haemel, AMD
255bd8deadSopenharmony_ci    Pierre Boudier, AMD
265bd8deadSopenharmony_ci    Piers Daniell, NVIDIA
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciNotice
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    Copyright (c) 2010-2019 The Khronos Group Inc. Copyright terms at
315bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciSpecification Update Policy
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
365bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
375bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
385bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
395bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
405bd8deadSopenharmony_ci    described in more detail at
415bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ciStatus
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ci    Complete. Approved by the ARB at the 2010/01/22 F2F meeting.
465bd8deadSopenharmony_ci    Approved by the Khronos Board of Promoters on March 10, 2010.
475bd8deadSopenharmony_ci    
485bd8deadSopenharmony_ciVersion
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    Last Modified Date: September 17, 2019
515bd8deadSopenharmony_ci    Revision: 23
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ciNumber
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    ARB Extension #91
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ciDependencies
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    This extension is written against the OpenGL 3.2 (Compatibility Profile)
605bd8deadSopenharmony_ci    Specification.
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    This extension is written against Version 1.50 (Revision 09) of the OpenGL
635bd8deadSopenharmony_ci    Shading Language Specification.
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ci    OpenGL 3.2 and GLSL 1.50 are required.
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    This specification interacts with the core profile of OpenGL 3.2.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci    This specification interacts with ARB_gpu_shader5.
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    This specification interacts with ARB_gpu_shader_fp64.
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    This specification interacts with NV_gpu_shader5.
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci    This specification interacts with NV_primitive_restart.
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ciOverview
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci    This extension introduces new tessellation stages and two new shader types
805bd8deadSopenharmony_ci    to the OpenGL primitive processing pipeline.  These pipeline stages
815bd8deadSopenharmony_ci    operate on a new basic primitive type, called a patch.  A patch consists
825bd8deadSopenharmony_ci    of a fixed-size collection of vertices, each with per-vertex attributes,
835bd8deadSopenharmony_ci    plus a number of associated per-patch attributes.  Tessellation control
845bd8deadSopenharmony_ci    shaders transform an input patch specified by the application, computing
855bd8deadSopenharmony_ci    per-vertex and per-patch attributes for a new output patch.  A
865bd8deadSopenharmony_ci    fixed-function tessellation primitive generator subdivides the patch, and
875bd8deadSopenharmony_ci    tessellation evaluation shaders are used to compute the position and
885bd8deadSopenharmony_ci    attributes of each vertex produced by the tessellator.
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    When tessellation is active, it begins by running the optional
915bd8deadSopenharmony_ci    tessellation control shader.  This shader consumes an input patch and
925bd8deadSopenharmony_ci    produces a new fixed-size output patch.  The output patch consists of an
935bd8deadSopenharmony_ci    array of vertices, and a set of per-patch attributes.  The per-patch
945bd8deadSopenharmony_ci    attributes include tessellation levels that control how finely the patch
955bd8deadSopenharmony_ci    will be tessellated.  For each patch processed, multiple tessellation
965bd8deadSopenharmony_ci    control shader invocations are performed -- one per output patch vertex.
975bd8deadSopenharmony_ci    Each tessellation control shader invocation writes all the attributes of
985bd8deadSopenharmony_ci    its corresponding output patch vertex.  A tessellation control shader may
995bd8deadSopenharmony_ci    also read the per-vertex outputs of other tessellation control shader
1005bd8deadSopenharmony_ci    invocations, as well as read and write shared per-patch outputs.  The
1015bd8deadSopenharmony_ci    tessellation control shader invocations for a single patch effectively run
1025bd8deadSopenharmony_ci    as a group.  A built-in barrier() function is provided to allow
1035bd8deadSopenharmony_ci    synchronization points where no shader invocation will continue until all
1045bd8deadSopenharmony_ci    shader invocations have reached the barrier.
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci    The tessellation primitive generator then decomposes a patch into a new
1075bd8deadSopenharmony_ci    set of primitives using the tessellation levels to determine how finely
1085bd8deadSopenharmony_ci    tessellated the output should be.  The primitive generator begins with
1095bd8deadSopenharmony_ci    either a triangle or a quad, and splits each outer edge of the primitive
1105bd8deadSopenharmony_ci    into a number of segments approximately equal to the corresponding element
1115bd8deadSopenharmony_ci    of the outer tessellation level array.  The interior of the primitive is
1125bd8deadSopenharmony_ci    tessellated according to elements of the inner tessellation level array.
1135bd8deadSopenharmony_ci    The primitive generator has three modes:  "triangles" and "quads" split a
1145bd8deadSopenharmony_ci    triangular or quad-shaped patch into a set of triangles that cover the
1155bd8deadSopenharmony_ci    original patch; "isolines" splits a quad-shaped patch into a set of line
1165bd8deadSopenharmony_ci    strips running across the patch horizontally.  Each vertex generated by
1175bd8deadSopenharmony_ci    the tessellation primitive generator is assigned a (u,v) or (u,v,w)
1185bd8deadSopenharmony_ci    coordinate indicating its relative location in the subdivided triangle or
1195bd8deadSopenharmony_ci    quad.
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci    For each vertex produced by the tessellation primitive generator, the
1225bd8deadSopenharmony_ci    tessellation evaluation shader is run to compute its position and other
1235bd8deadSopenharmony_ci    attributes of the vertex, using its (u,v) or (u,v,w) coordinate.  When
1245bd8deadSopenharmony_ci    computing final vertex attributes, the tessellation evaluation shader can
1255bd8deadSopenharmony_ci    also read the attributes of any of the vertices of the patch written by
1265bd8deadSopenharmony_ci    the tessellation control shader.  Tessellation evaluation shader
1275bd8deadSopenharmony_ci    invocations are completely independent, although all invocations for a
1285bd8deadSopenharmony_ci    single patch share the same collection of input vertices and per-patch
1295bd8deadSopenharmony_ci    attributes.
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci    The tessellator operates on vertices after they have been transformed by a
1325bd8deadSopenharmony_ci    vertex shader.  The primitives generated by the tessellator are passed
1335bd8deadSopenharmony_ci    further down the OpenGL pipeline, where they can be used as inputs to
1345bd8deadSopenharmony_ci    geometry shaders, transform feedback, and the rasterizer.
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    The tessellation control and evaluation shaders are both optional.  If
1375bd8deadSopenharmony_ci    neither shader type is present, the tessellation stage has no effect.  If
1385bd8deadSopenharmony_ci    no tessellation control shader is present, the input patch provided by the
1395bd8deadSopenharmony_ci    application is passed directly to the tessellation primitive generator,
1405bd8deadSopenharmony_ci    and a set of default tessellation level parameters is used to control
1415bd8deadSopenharmony_ci    primitive generation.  In this extension, patches may not be passed beyond
1425bd8deadSopenharmony_ci    the tessellation evaluation shader, and an error is generated if an
1435bd8deadSopenharmony_ci    application provides patches and the current program object contains no
1445bd8deadSopenharmony_ci    tessellation evaluation shader.
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ciIP Status
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci    No known IP claims.
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ciNew Procedures and Functions
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci      void PatchParameteri(enum pname, int value);
1535bd8deadSopenharmony_ci      void PatchParameterfv(enum pname, const float *values);
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ciNew Tokens
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    Accepted by the <mode> parameter of Begin and all vertex array functions
1585bd8deadSopenharmony_ci    that implicitly call Begin:
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci        PATCHES                                         0xE
1615bd8deadSopenharmony_ci
1625bd8deadSopenharmony_ci    Accepted by the <pname> parameter of PatchParameteri, GetBooleanv,
1635bd8deadSopenharmony_ci    GetDoublev, GetFloatv, GetIntegerv, and GetInteger64v:
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci        PATCH_VERTICES                                 0x8E72
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    Accepted by the <pname> parameter of PatchParameterfv, GetBooleanv,
1685bd8deadSopenharmony_ci    GetDoublev, GetFloatv, and GetIntegerv, and GetInteger64v:
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci        PATCH_DEFAULT_INNER_LEVEL                       0x8E73
1715bd8deadSopenharmony_ci        PATCH_DEFAULT_OUTER_LEVEL                       0x8E74
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetProgramiv:
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci        TESS_CONTROL_OUTPUT_VERTICES                    0x8E75
1765bd8deadSopenharmony_ci        TESS_GEN_MODE                                   0x8E76
1775bd8deadSopenharmony_ci        TESS_GEN_SPACING                                0x8E77
1785bd8deadSopenharmony_ci        TESS_GEN_VERTEX_ORDER                           0x8E78
1795bd8deadSopenharmony_ci        TESS_GEN_POINT_MODE                             0x8E79
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ci    Returned by GetProgramiv when <pname> is TESS_GEN_MODE:
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ci        TRIANGLES
1845bd8deadSopenharmony_ci        QUADS
1855bd8deadSopenharmony_ci        ISOLINES                                        0x8E7A
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci    Returned by GetProgramiv when <pname> is TESS_GEN_SPACING:
1885bd8deadSopenharmony_ci
1895bd8deadSopenharmony_ci        EQUAL
1905bd8deadSopenharmony_ci        FRACTIONAL_ODD                                  0x8E7B
1915bd8deadSopenharmony_ci        FRACTIONAL_EVEN                                 0x8E7C
1925bd8deadSopenharmony_ci
1935bd8deadSopenharmony_ci    Returned by GetProgramiv when <pname> is TESS_GEN_VERTEX_ORDER:
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci        CCW
1965bd8deadSopenharmony_ci        CW
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci    Returned by GetProgramiv when <pname> is TESS_GEN_POINT_MODE:
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci        FALSE
2015bd8deadSopenharmony_ci        TRUE
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetDoublev, GetFloatv,
2045bd8deadSopenharmony_ci    GetIntegerv, and GetInteger64v:
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci        MAX_PATCH_VERTICES                              0x8E7D
2075bd8deadSopenharmony_ci        MAX_TESS_GEN_LEVEL                              0x8E7E
2085bd8deadSopenharmony_ci        MAX_TESS_CONTROL_UNIFORM_COMPONENTS             0x8E7F
2095bd8deadSopenharmony_ci        MAX_TESS_EVALUATION_UNIFORM_COMPONENTS          0x8E80
2105bd8deadSopenharmony_ci        MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS            0x8E81
2115bd8deadSopenharmony_ci        MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS         0x8E82
2125bd8deadSopenharmony_ci        MAX_TESS_CONTROL_OUTPUT_COMPONENTS              0x8E83
2135bd8deadSopenharmony_ci        MAX_TESS_PATCH_COMPONENTS                       0x8E84
2145bd8deadSopenharmony_ci        MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS        0x8E85
2155bd8deadSopenharmony_ci        MAX_TESS_EVALUATION_OUTPUT_COMPONENTS           0x8E86
2165bd8deadSopenharmony_ci        MAX_TESS_CONTROL_UNIFORM_BLOCKS                 0x8E89
2175bd8deadSopenharmony_ci        MAX_TESS_EVALUATION_UNIFORM_BLOCKS              0x8E8A
2185bd8deadSopenharmony_ci        MAX_TESS_CONTROL_INPUT_COMPONENTS               0x886C
2195bd8deadSopenharmony_ci        MAX_TESS_EVALUATION_INPUT_COMPONENTS            0x886D
2205bd8deadSopenharmony_ci        MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS    0x8E1E
2215bd8deadSopenharmony_ci        MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetActiveUniformBlockiv:
2245bd8deadSopenharmony_ci    
2255bd8deadSopenharmony_ci        UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER     0x84F0
2265bd8deadSopenharmony_ci        UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER  0x84F1
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    Accepted by the <type> parameter of CreateShader and returned by the
2295bd8deadSopenharmony_ci    <params> parameter of GetShaderiv:
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ci        TESS_EVALUATION_SHADER                          0x8E87
2325bd8deadSopenharmony_ci        TESS_CONTROL_SHADER                             0x8E88
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.2 (Compatibility Profile) Specification (OpenGL
2365bd8deadSopenharmony_ciOperation)
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci    Modify Section 2.6.1, Begin and End, p. 22
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci    (insert before the last paragraph, p. 27)
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    Separate Patches
2435bd8deadSopenharmony_ci
2445bd8deadSopenharmony_ci    Separate patches are specified with mode PATCHES.  A patch is an ordered
2455bd8deadSopenharmony_ci    collection of vertices used for primitive tessellation (section 2.X).  The
2465bd8deadSopenharmony_ci    vertices comprising a patch have no implied geometric ordering.  The
2475bd8deadSopenharmony_ci    vertices of a patch are used by tessellation shaders and a fixed-function
2485bd8deadSopenharmony_ci    tessellator to generate new point, line, or triangle primitives.
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    Each patch in the series has a fixed number of vertices, which is
2515bd8deadSopenharmony_ci    specified by calling
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci      void PatchParameteri(enum pname, int value);
2545bd8deadSopenharmony_ci
2555bd8deadSopenharmony_ci    with <pname> set to PATCH_VERTICES.  The error INVALID_VALUE is generated
2565bd8deadSopenharmony_ci    if <value> is less than or equal to zero or is greater than the
2575bd8deadSopenharmony_ci    implementation-dependent maximum patch size, MAX_PATCH_VERTICES.  The
2585bd8deadSopenharmony_ci    patch size is initially three vertices.
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    If the number of vertices in a patch is given by <v>, the <v>*<i>+1st
2615bd8deadSopenharmony_ci    through <v>*<i>+<v>th vertices (in that order) determine a patch for each
2625bd8deadSopenharmony_ci    i = 0, 1, ..., n-1, where there are <v>*<n>+<k> vertices.  <k> is in the
2635bd8deadSopenharmony_ci    range [0,<v>-1]; if <k> is not zero, the final <k> vertices are ignored.
2645bd8deadSopenharmony_ci
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    (modify second paragraph, p. 29)  The state required for Begin and End
2675bd8deadSopenharmony_ci    consists of a sixteen-valued integer indicating either one of the fifteen
2685bd8deadSopenharmony_ci    possible Begin/End modes, or that no Begin/End mode is being processed.
2695bd8deadSopenharmony_ci
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci    Modify Section 2.14, Vertex Shaders, p. 82
2725bd8deadSopenharmony_ci
2735bd8deadSopenharmony_ci    (modify fourth paragraph, p. 82) In addition to vertex shaders,
2745bd8deadSopenharmony_ci    tessellation control shaders, tessellation evaluation shaders, geometry
2755bd8deadSopenharmony_ci    shaders, and fragment shaders can be created, compiled, and linked into
2765bd8deadSopenharmony_ci    program objects.  Tessellation control and evaluation shaders are used to
2775bd8deadSopenharmony_ci    control the operation of the tessellator, and are described in section
2785bd8deadSopenharmony_ci    2.X.  Geometry shaders affect the processing of primitives assembled from
2795bd8deadSopenharmony_ci    vertices (see section 2.15). Fragment shaders affect the processing of
2805bd8deadSopenharmony_ci    fragments during rasterization (see section 3.12).  A single program
2815bd8deadSopenharmony_ci    object can contain vertex, tessellation control, tessellation evaluation,
2825bd8deadSopenharmony_ci    geometry, and fragment shaders.
2835bd8deadSopenharmony_ci
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci    Modify Section 2.14.2, Program Objects, p. 84
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci    (insert before third paragraph, p. 85)
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci    Linking will fail if the program object contains objects to form a
2905bd8deadSopenharmony_ci    tessellation control shader (see section 2.X.1), and
2915bd8deadSopenharmony_ci
2925bd8deadSopenharmony_ci      * the program contains no objects to form a vertex shader;
2935bd8deadSopenharmony_ci
2945bd8deadSopenharmony_ci      * the output patch vertex count is not specified in any compiled
2955bd8deadSopenharmony_ci        tessellation control shader object; or
2965bd8deadSopenharmony_ci
2975bd8deadSopenharmony_ci      * the output patch vertex count is specified differently in multiple
2985bd8deadSopenharmony_ci        tessellation control shader objects.
2995bd8deadSopenharmony_ci
3005bd8deadSopenharmony_ci    Linking will fail if the program object contains objects to form a
3015bd8deadSopenharmony_ci    tessellation evaluation shader (see section 2.X.3), and
3025bd8deadSopenharmony_ci
3035bd8deadSopenharmony_ci      * the program contains no objects to form a vertex shader;
3045bd8deadSopenharmony_ci
3055bd8deadSopenharmony_ci      * the tessellation primitive mode is not specified in any compiled
3065bd8deadSopenharmony_ci        tessellation evaluation shader object; or
3075bd8deadSopenharmony_ci
3085bd8deadSopenharmony_ci      * the tessellation primitive mode, spacing, vertex order, or point mode
3095bd8deadSopenharmony_ci        is specified differently in multiple tessellation evaluation shader
3105bd8deadSopenharmony_ci        objects.
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci
3135bd8deadSopenharmony_ci    Modify Section 2.14.4, Uniform Variables, p, 89
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci    (modify sixth paragraph, p. 93) If <pname> is
3165bd8deadSopenharmony_ci    UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
3175bd8deadSopenharmony_ci    UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER,
3185bd8deadSopenharmony_ci    UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER,
3195bd8deadSopenharmony_ci    UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, or
3205bd8deadSopenharmony_ci    UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, then a boolean value
3215bd8deadSopenharmony_ci    indicating whether the uniform block identified by <uniformBlockIndex> is
3225bd8deadSopenharmony_ci    referenced by the vertex, tessellation control, tessellation evaluation,
3235bd8deadSopenharmony_ci    geometry, or fragment shaders of <program>, respectively, is returned.
3245bd8deadSopenharmony_ci
3255bd8deadSopenharmony_ci    (modify next-to-last paragraph, p. 101) There is a set of
3265bd8deadSopenharmony_ci    implementation-dependent maximums for the number of active uniform blocks
3275bd8deadSopenharmony_ci    used by each shader.  If the number of uniform blocks used by any shader
3285bd8deadSopenharmony_ci    in the program exceeds its corresponding limit, the program will fail to
3295bd8deadSopenharmony_ci    link. The limits for vertex, tessellation control, tessellation
3305bd8deadSopenharmony_ci    evaluation, geometry, and fragment shaders can be obtained by calling
3315bd8deadSopenharmony_ci    GetIntegerv with pname values of MAX_VERTEX_UNIFORM_BLOCKS,
3325bd8deadSopenharmony_ci    MAX_TESS_CONTROL_UNIFORM_BLOCKS, MAX_TESS_EVALUATION_UNIFORM_BLOCKS,
3335bd8deadSopenharmony_ci    MAX_GEOMETRY_UNIFORM_BLOCKS, and MAX_FRAGMENT_UNIFORM_BLOCKS,
3345bd8deadSopenharmony_ci    respectively.
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci
3375bd8deadSopenharmony_ci    Modify Section 2.14.6, Varying Variables, p. 106
3385bd8deadSopenharmony_ci
3395bd8deadSopenharmony_ci    (modify three paragraphs starting with the last paragraph, p. 106, to
3405bd8deadSopenharmony_ci    refer less specifically to geometry shaders) ...  These varying variables
3415bd8deadSopenharmony_ci    are used as the mechanism to communicate values to the next active stage
3425bd8deadSopenharmony_ci    in the vertex processing pipeline:  either the tessellation control
3435bd8deadSopenharmony_ci    shader, the tessellation evaluation shader, the geometry shader, or the
3445bd8deadSopenharmony_ci    fixed-function vertex processing stages leading to rasterization.
3455bd8deadSopenharmony_ci
3465bd8deadSopenharmony_ci    If the varying variables are passed directly to the vertex processing
3475bd8deadSopenharmony_ci    stages leading to rasterization, the values of all varying and special
3485bd8deadSopenharmony_ci    variables are expected to be interpolated across the primitive being
3495bd8deadSopenharmony_ci    rendered, unless flatshaded.  Otherwise, the values of all varying and
3505bd8deadSopenharmony_ci    special variables are collected by the primitive assembly stage and passed
3515bd8deadSopenharmony_ci    on to the subsequent pipeline stage once enough data for one primitive has
3525bd8deadSopenharmony_ci    been collected
3535bd8deadSopenharmony_ci
3545bd8deadSopenharmony_ci    The number of components (individual scalar numeric values) of varying and
3555bd8deadSopenharmony_ci    special variables that can be written by the vertex shader, whether or not
3565bd8deadSopenharmony_ci    a tessellation control, tessellation evaluation, or geometry shader is
3575bd8deadSopenharmony_ci    active, is given by the value of the implementation-dependent constant
3585bd8deadSopenharmony_ci    MAX_VERTEX_OUTPUT_COMPONENTS.  Outputs declared as vectors, matrices, and
3595bd8deadSopenharmony_ci    arrays will all consume multiple components.
3605bd8deadSopenharmony_ci
3615bd8deadSopenharmony_ci    (modify next-to-last paragraph, p. 107) Each program object can specify a
3625bd8deadSopenharmony_ci    set of output variables from one shader to be recorded in transform
3635bd8deadSopenharmony_ci    feedback mode (see section 2.19).  If a geometry shader is active, its
3645bd8deadSopenharmony_ci    output variables are the ones that can be recorded.  Otherwise,
3655bd8deadSopenharmony_ci    tessellation evaluation shader outputs will be recorded, if that shader is
3665bd8deadSopenharmony_ci    active.  Otherwise, tessellation control shader outputs will be recorded,
3675bd8deadSopenharmony_ci    if that shader is active.  Otherwise, vertex shader outputs will be
3685bd8deadSopenharmony_ci    recorded.  The values to record are specified with the command ...
3695bd8deadSopenharmony_ci
3705bd8deadSopenharmony_ci    (modify bullet list, p. 108)
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci      * the count specified by TransformFeedbackVaryings is non-zero, but the
3735bd8deadSopenharmony_ci        program object has no vertex, tessellation control, tessellation
3745bd8deadSopenharmony_ci        evaluation, or geometry shader;
3755bd8deadSopenharmony_ci
3765bd8deadSopenharmony_ci      * any variable name specified in the varyings array is not declared as
3775bd8deadSopenharmony_ci        an output in the shader stage whose outputs can be recorded;
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci      ...
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci
3825bd8deadSopenharmony_ci    Modify Section 2.14.7, Shader Execution, p. 109
3835bd8deadSopenharmony_ci
3845bd8deadSopenharmony_ci    (Modify the part of the section describing what is and is not done for
3855bd8deadSopenharmony_ci    processing vertices when vertex shaders are active, p. 109 and 110.  This
3865bd8deadSopenharmony_ci    rewrite is intended to apply to all programmable vertex processing
3875bd8deadSopenharmony_ci    pipeline stages.  Ideally, we should refactor the spec to first have a
3885bd8deadSopenharmony_ci    general programmable shading section describing common shader
3895bd8deadSopenharmony_ci    functionality and this pipeline, followed by sections containing
3905bd8deadSopenharmony_ci    domain-specific items.)
3915bd8deadSopenharmony_ci
3925bd8deadSopenharmony_ci    If a successfully linked program object that contains a vertex,
3935bd8deadSopenharmony_ci    tessellation control, tessellation evaluation, or geometry shader is made
3945bd8deadSopenharmony_ci    current by calling UseProgram, the executable version of these shaders are
3955bd8deadSopenharmony_ci    used to process incoming vertex values, rather than the fixed-function
3965bd8deadSopenharmony_ci    vertex processing described in sections 2.16 through 2.13.  In particular,
3975bd8deadSopenharmony_ci
3985bd8deadSopenharmony_ci      (keep list of fixed-function operations that are not performed)
3995bd8deadSopenharmony_ci
4005bd8deadSopenharmony_ci    Instead, the following sequence of operations is performed:
4015bd8deadSopenharmony_ci
4025bd8deadSopenharmony_ci      * Vertices are processed by the vertex shader (section 2.14) and
4035bd8deadSopenharmony_ci        assembled into primitives as described in sections 2.6 through 2.10.
4045bd8deadSopenharmony_ci
4055bd8deadSopenharmony_ci      * If the current program contains a tessellation control shader, each
4065bd8deadSopenharmony_ci        individual patch primitive is processed by the tessellation control
4075bd8deadSopenharmony_ci        shader (section 2.X.1).  Otherwise, primitives are passed through
4085bd8deadSopenharmony_ci        unmodified.  If active, the tessellation control shader consumes its
4095bd8deadSopenharmony_ci        input patch and produces a new patch primitive, which is passed to
4105bd8deadSopenharmony_ci        subsequent pipeline stages.
4115bd8deadSopenharmony_ci
4125bd8deadSopenharmony_ci      * If the current program contains a tessellation evaluation shader, each
4135bd8deadSopenharmony_ci        individual patch primitive is processed by the tessellation primitive
4145bd8deadSopenharmony_ci        generator (section 2.X.2) and tessellation evaluation shader (section
4155bd8deadSopenharmony_ci        2.X.3).  Otherwise, primitives are passed through unmodified.  When a
4165bd8deadSopenharmony_ci        tessellation evaluation shader is active, the tessellation primitive
4175bd8deadSopenharmony_ci        generator produces a new collection of point, line, or triangle
4185bd8deadSopenharmony_ci        primitives to be passed to subsequent pipeline stages.  The vertices
4195bd8deadSopenharmony_ci        of these primitives are processed by the tessellation evaluation
4205bd8deadSopenharmony_ci        shader.  The patch primitive passed to the tessellation primitive
4215bd8deadSopenharmony_ci        generator is consumed by this process.
4225bd8deadSopenharmony_ci
4235bd8deadSopenharmony_ci      * If the current program contains a geometry shader, each individual
4245bd8deadSopenharmony_ci        primitive is processed by the geometry shader (section 2.15).
4255bd8deadSopenharmony_ci        Otherwise, primitives are passed through unmodified.  If active, the
4265bd8deadSopenharmony_ci        geometry shader consumes its input patch.  However, each geometry
4275bd8deadSopenharmony_ci        shader invocation may emit new vertices, which are arranged into
4285bd8deadSopenharmony_ci        primitives and passed to subsequent pipeline stages.
4295bd8deadSopenharmony_ci
4305bd8deadSopenharmony_ci      * The primitives reaching this stage in the pipeline are then processed
4315bd8deadSopenharmony_ci        by the following fixed-function operations:
4325bd8deadSopenharmony_ci
4335bd8deadSopenharmony_ci        (NOTE:  This change rearranges the order of some of the operations,
4345bd8deadSopenharmony_ci         and adds explicit references to transform feedback and rasterization.
4355bd8deadSopenharmony_ci         The pipeline stages have been in the wrong order since OpenGL 2.0 --
4365bd8deadSopenharmony_ci         in particular, clipping logically happens before perspective division
4375bd8deadSopenharmony_ci         and viewport transformations.)
4385bd8deadSopenharmony_ci
4395bd8deadSopenharmony_ci        * Color clamping or masking (section 2.13.6).
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci        * Transform feedback (section 2.19).
4425bd8deadSopenharmony_ci
4435bd8deadSopenharmony_ci        * Flatshading (section 2.21).
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ci        * Clipping, including client-defined clip planes (section 2.22).
4465bd8deadSopenharmony_ci
4475bd8deadSopenharmony_ci        * Perspective division on clip coordinates (section 2.16).
4485bd8deadSopenharmony_ci
4495bd8deadSopenharmony_ci        * Viewport mapping, including depth range scaling (section 2.16.1).
4505bd8deadSopenharmony_ci
4515bd8deadSopenharmony_ci        * Front face determination (section 2.13.1).
4525bd8deadSopenharmony_ci
4535bd8deadSopenharmony_ci        * Color, texture coordinate, fog, point-size and generic attribute
4545bd8deadSopenharmony_ci          clipping (section 2.22.1).
4555bd8deadSopenharmony_ci
4565bd8deadSopenharmony_ci        * Final color processing (section 2.23).
4575bd8deadSopenharmony_ci
4585bd8deadSopenharmony_ci        * Rasterization (chapter 3).
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ci
4615bd8deadSopenharmony_ci    Modify Section 2.14.7, Shader Execution, p. 109
4625bd8deadSopenharmony_ci
4635bd8deadSopenharmony_ci    (modify last paragraph, p. 110) This section describes texture
4645bd8deadSopenharmony_ci    functionality that is only accessible through vertex, tessellation
4655bd8deadSopenharmony_ci    control, tessellation evaluation, geometry, or fragment shaders. ...
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ci    (modify first paragraph under "Texture Access", p. 112) Shaders have the
4685bd8deadSopenharmony_ci    ability to do a lookup into a texture map.  The maximum number of texture
4695bd8deadSopenharmony_ci    image units available to vertex, tessellation control, tessellation
4705bd8deadSopenharmony_ci    evaluation, geometry, or fragment shaders are the values of
4715bd8deadSopenharmony_ci    the implementation-dependent constants 
4725bd8deadSopenharmony_ci
4735bd8deadSopenharmony_ci      * MAX_VERTEX_TEXTURE_IMAGE_UNITS (vertex),
4745bd8deadSopenharmony_ci      * MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS (tessellation control),
4755bd8deadSopenharmony_ci      * MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS (tessellation evaluation),
4765bd8deadSopenharmony_ci      * MAX_GEOMETRY_TEXTURE_IMAGE_UNITS (geometry), and
4775bd8deadSopenharmony_ci      * MAX_TEXTURE_IMAGE_UNITS (fragment).
4785bd8deadSopenharmony_ci
4795bd8deadSopenharmony_ci    The vertex shader, tessellation control and evaluation shader, geometry
4805bd8deadSopenharmony_ci    shader, and fragment processing combined cannot use more than the value of
4815bd8deadSopenharmony_ci    MAX_COMBINED_TEXTURE_IMAGE_UNITS texture image units. If more than one
4825bd8deadSopenharmony_ci    pipeline stage accesses the same texture image unit, each such access
4835bd8deadSopenharmony_ci    counts separately against the MAX_COMBINED_TEXTURE_IMAGE_UNITS limit.
4845bd8deadSopenharmony_ci
4855bd8deadSopenharmony_ci    (modify next-to-last paragraph p. 112) When a texture lookup is performed
4865bd8deadSopenharmony_ci    in a shader, the filtered ...
4875bd8deadSopenharmony_ci
4885bd8deadSopenharmony_ci    (modify last paragraph p. 112) In shaders other than fragment shaders, it
4895bd8deadSopenharmony_ci    is not possible...
4905bd8deadSopenharmony_ci
4915bd8deadSopenharmony_ci    (modify last paragraph before "Shader Inputs", p. 113) If a shader uses a
4925bd8deadSopenharmony_ci    sampler where the associated ...
4935bd8deadSopenharmony_ci
4945bd8deadSopenharmony_ci
4955bd8deadSopenharmony_ci    Insert a new section immediately after Section 2.14, Vertex Shaders.
4965bd8deadSopenharmony_ci
4975bd8deadSopenharmony_ci    Section 2.X, Tessellation
4985bd8deadSopenharmony_ci
4995bd8deadSopenharmony_ci    Tessellation is a process that reads a patch primitive and generates new
5005bd8deadSopenharmony_ci    primitives used by subsequent pipeline stages.  The generated primitives
5015bd8deadSopenharmony_ci    are formed by subdividing a single triangle or quad primitive according to
5025bd8deadSopenharmony_ci    fixed or shader-computed levels of detail and transforming each of the
5035bd8deadSopenharmony_ci    vertices produced during this subdivision.
5045bd8deadSopenharmony_ci
5055bd8deadSopenharmony_ci    Tessellation functionality is controlled by two types of tessellation
5065bd8deadSopenharmony_ci    shaders:  tessellation control shaders and tessellation evaluation
5075bd8deadSopenharmony_ci    shaders.  Tessellation is considered active if and only if there is an
5085bd8deadSopenharmony_ci    active program object, and that program object contains a tessellation
5095bd8deadSopenharmony_ci    control or evaluation shader.
5105bd8deadSopenharmony_ci
5115bd8deadSopenharmony_ci    The tessellation control shader is used to read an input patch provided by
5125bd8deadSopenharmony_ci    the application, and emit an output patch.  The tessellation control
5135bd8deadSopenharmony_ci    shader is run once for each vertex in the output patch and computes the
5145bd8deadSopenharmony_ci    attributes of that vertex.  Additionally, the tessellation control shader
5155bd8deadSopenharmony_ci    may compute additional per-patch attributes of the output patch.  The most
5165bd8deadSopenharmony_ci    important per-patch outputs are the tessellation levels, which are used to
5175bd8deadSopenharmony_ci    control the number of subdivisions performed by the tessellation primitive
5185bd8deadSopenharmony_ci    generator.  The tessellation control shader may also write additional
5195bd8deadSopenharmony_ci    per-patch attributes for use by the tessellation evaluation shader.  If no
5205bd8deadSopenharmony_ci    tessellation control shader is active, the patch provided is passed
5215bd8deadSopenharmony_ci    through to the tessellation primitive generator stage unmodified.
5225bd8deadSopenharmony_ci
5235bd8deadSopenharmony_ci    If a tessellation evaluation shader is active, the tessellation primitive
5245bd8deadSopenharmony_ci    generator subdivides a triangle or quad primitive into a collection of
5255bd8deadSopenharmony_ci    points, lines, or triangles according to the tessellation levels of the
5265bd8deadSopenharmony_ci    patch and the set of layout declarations specified in the tessellation
5275bd8deadSopenharmony_ci    evaluation shader text.  The tessellation levels used to control
5285bd8deadSopenharmony_ci    subdivision are normally written by the tessellation control shader.  If
5295bd8deadSopenharmony_ci    no tessellation control shader is active, default tessellation levels are
5305bd8deadSopenharmony_ci    instead used.
5315bd8deadSopenharmony_ci
5325bd8deadSopenharmony_ci    When a tessellation evaluation shader is active, it is run on each vertex
5335bd8deadSopenharmony_ci    generated by the tessellation primitive generator to compute the final
5345bd8deadSopenharmony_ci    position and other attributes of the vertex.  The tessellation evaluation
5355bd8deadSopenharmony_ci    shader can read the relative location of the vertex in the subdivided
5365bd8deadSopenharmony_ci    output primitive, given by an (u,v) or (u,v,w) coordinate, as well as the
5375bd8deadSopenharmony_ci    position and attributes of any or all of the vertices in the input patch.
5385bd8deadSopenharmony_ci
5395bd8deadSopenharmony_ci    Tessellation operates only on patch primitives.  If tessellation is
5405bd8deadSopenharmony_ci    active, the error INVALID_OPERATION is generated by Begin (or vertex array
5415bd8deadSopenharmony_ci    commands that implicitly call Begin) if the primitive mode is not
5425bd8deadSopenharmony_ci    PATCHES.
5435bd8deadSopenharmony_ci
5445bd8deadSopenharmony_ci    Patch primitives are not supported by pipeline stages below the
5455bd8deadSopenharmony_ci    tessellation evaluation shader.  If there is no active program object or
5465bd8deadSopenharmony_ci    the active program object does not contain a tessellation evaluation
5475bd8deadSopenharmony_ci    shader, the error INVALID_OPERATION is generated by Begin (or vertex array
5485bd8deadSopenharmony_ci    commands that implicitly call Begin) if the primitive mode is PATCHES.
5495bd8deadSopenharmony_ci
5505bd8deadSopenharmony_ci    A program object that includes a tessellation shader of any kind must also
5515bd8deadSopenharmony_ci    include a vertex shader, and will fail to link if no vertex shader is
5525bd8deadSopenharmony_ci    provided.
5535bd8deadSopenharmony_ci
5545bd8deadSopenharmony_ci
5555bd8deadSopenharmony_ci    Section 2.X.1, Tessellation Control Shaders
5565bd8deadSopenharmony_ci
5575bd8deadSopenharmony_ci    The tessellation control shader consumes an input patch provided by the
5585bd8deadSopenharmony_ci    application and emits a new output patch.  The input patch is an array of
5595bd8deadSopenharmony_ci    vertices with attributes corresponding to output variables written by the
5605bd8deadSopenharmony_ci    vertex shader.  The output patch consists of an array of vertices with
5615bd8deadSopenharmony_ci    attributes corresponding to per-vertex output variables written by the
5625bd8deadSopenharmony_ci    tessellation control shader and a set of per-patch attributes
5635bd8deadSopenharmony_ci    corresponding to per-patch output variables written by the tessellation
5645bd8deadSopenharmony_ci    control shader.  Tessellation control output variables are per-vertex by
5655bd8deadSopenharmony_ci    default, but may be declared as per-patch using the "patch" qualifier.
5665bd8deadSopenharmony_ci
5675bd8deadSopenharmony_ci    The number of vertices in the output patch is fixed when the program is
5685bd8deadSopenharmony_ci    linked, and is specified in tessellation control shader source code using
5695bd8deadSopenharmony_ci    the output layout qualifier "vertices", as described in the OpenGL Shading
5705bd8deadSopenharmony_ci    Language Specification.  A program will fail to link if the output patch
5715bd8deadSopenharmony_ci    vertex count is not specified by any tessellation control shader object
5725bd8deadSopenharmony_ci    attached to the program, if it is specified differently by multiple
5735bd8deadSopenharmony_ci    tessellation control shader objects, if it is less than or equal to zero,
5745bd8deadSopenharmony_ci    or if it is greater than the implementation-dependent maximum patch
5755bd8deadSopenharmony_ci    size. The output patch vertex count may be queried by calling GetProgramiv
5765bd8deadSopenharmony_ci    with the symbolic constant TESS_CONTROL_OUTPUT_VERTICES.
5775bd8deadSopenharmony_ci
5785bd8deadSopenharmony_ci    Tessellation control shaders are created as described in section 2.14.1,
5795bd8deadSopenharmony_ci    using a <type> of TESS_CONTROL_SHADER.  When a new input patch is
5805bd8deadSopenharmony_ci    received, the tessellation control shader is run once for each vertex in
5815bd8deadSopenharmony_ci    the output patch.  The tessellation control shader invocations
5825bd8deadSopenharmony_ci    collectively specify the per-vertex and per-patch attributes of the output
5835bd8deadSopenharmony_ci    patch.  The per-vertex attributes are obtained from the per-vertex output
5845bd8deadSopenharmony_ci    variables written by each invocation.  Each tessellation control shader
5855bd8deadSopenharmony_ci    invocation may only write to per-vertex output variables corresponding to
5865bd8deadSopenharmony_ci    its own output patch vertex.  The output patch vertex number corresponding
5875bd8deadSopenharmony_ci    to a given tessellation control point shader invocation is given by the
5885bd8deadSopenharmony_ci    built-in variable gl_InvocationID.  Per-patch attributes are taken from
5895bd8deadSopenharmony_ci    the per-patch output variables, which may be written by any tessellation
5905bd8deadSopenharmony_ci    control shader invocation.  While tessellation control shader invocations
5915bd8deadSopenharmony_ci    may read any per-vertex and per-patch output variable and write any
5925bd8deadSopenharmony_ci    per-patch output variable, reading or writing output variables also
5935bd8deadSopenharmony_ci    written by other invocations has ordering hazards discussed below.
5945bd8deadSopenharmony_ci
5955bd8deadSopenharmony_ci
5965bd8deadSopenharmony_ci    Section 2.X.1.1, Tessellation Control Shader Variables
5975bd8deadSopenharmony_ci
5985bd8deadSopenharmony_ci    Tessellation control shaders can access uniforms belonging to the current
5995bd8deadSopenharmony_ci    program object.  The amount of storage available for uniform variables in
6005bd8deadSopenharmony_ci    the default uniform block accessed by a tessellation control shader is
6015bd8deadSopenharmony_ci    specified by the value of the implementation-dependent constant
6025bd8deadSopenharmony_ci    MAX_TESS_CONTROL_UNIFORM_COMPONENTS.  The total amount of combined storage
6035bd8deadSopenharmony_ci    available for uniform variables in all uniform blocks accessed by a
6045bd8deadSopenharmony_ci    tessellation control shader (including the default uniform block) is
6055bd8deadSopenharmony_ci    specified by the value of the implementation-dependent constant
6065bd8deadSopenharmony_ci    MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS.  These values represent the
6075bd8deadSopenharmony_ci    numbers of individual floating-point, integer, or boolean values that can
6085bd8deadSopenharmony_ci    be held in uniform variable storage for a tessellation evaluation shader.
6095bd8deadSopenharmony_ci    A link error is generated if an attempt is made to utilize more than the
6105bd8deadSopenharmony_ci    space available for tessellation control shader uniform variables.
6115bd8deadSopenharmony_ci    Uniforms are manipulated as described in section 2.14.4.  Tessellation
6125bd8deadSopenharmony_ci    control shaders also have access to samplers to perform texturing
6135bd8deadSopenharmony_ci    operations, as described in sections 2.14.5.
6145bd8deadSopenharmony_ci
6155bd8deadSopenharmony_ci    Tessellation control shaders can access the transformed attributes of all
6165bd8deadSopenharmony_ci    vertices for their input primitive using input variables.  A vertex shader
6175bd8deadSopenharmony_ci    writing to output variables generates the values of these input varying
6185bd8deadSopenharmony_ci    variables, including values for built-in as well as user-defined varying
6195bd8deadSopenharmony_ci    variables.  Values for any varying variables that are not written by a
6205bd8deadSopenharmony_ci    vertex shader are undefined.
6215bd8deadSopenharmony_ci
6225bd8deadSopenharmony_ci    Additionally, tessellation control shaders can write to one or more output
6235bd8deadSopenharmony_ci    variables, including per-vertex attributes for the vertices of the output
6245bd8deadSopenharmony_ci    patch and per-patch attributes of the patch.  Tessellation control shaders
6255bd8deadSopenharmony_ci    can also write to a set of built-in per-vertex and per-patch outputs
6265bd8deadSopenharmony_ci    defined in the OpenGL Shading Language.  The per-vertex and per-patch
6275bd8deadSopenharmony_ci    attributes of the output patch are used by the tessellation primitive
6285bd8deadSopenharmony_ci    generator (section 2.X.2) and may be read by tessellation evaluation
6295bd8deadSopenharmony_ci    shader (section 2.X.3).
6305bd8deadSopenharmony_ci
6315bd8deadSopenharmony_ci
6325bd8deadSopenharmony_ci    Section 2.X.1.2, Tessellation Control Shader Execution Environment
6335bd8deadSopenharmony_ci
6345bd8deadSopenharmony_ci    If a successfully linked program object that contains a tessellation
6355bd8deadSopenharmony_ci    control shader is made current by calling UseProgram, the executable
6365bd8deadSopenharmony_ci    version of the tessellation control shader is used to process patches
6375bd8deadSopenharmony_ci    resulting from the primitive assembly stage.  When tessellation control
6385bd8deadSopenharmony_ci    shader execution completes, the input patch is consumed.  A new patch is
6395bd8deadSopenharmony_ci    assembled from the per-vertex and per-patch output variables written by
6405bd8deadSopenharmony_ci    the shader and is passed to subsequent pipeline stages.
6415bd8deadSopenharmony_ci
6425bd8deadSopenharmony_ci    There are several special considerations for tessellation control shader
6435bd8deadSopenharmony_ci    execution described in the following sections.
6445bd8deadSopenharmony_ci
6455bd8deadSopenharmony_ci    Texture Access
6465bd8deadSopenharmony_ci
6475bd8deadSopenharmony_ci    The Shader-Only Texturing subsection of section 2.14.7 describes texture
6485bd8deadSopenharmony_ci    lookup functionality accessible to a vertex shader.  The texel fetch and
6495bd8deadSopenharmony_ci    texture size query functionality described there also applies to
6505bd8deadSopenharmony_ci    tessellation control shaders.
6515bd8deadSopenharmony_ci
6525bd8deadSopenharmony_ci    Tessellation Control Shader Inputs
6535bd8deadSopenharmony_ci
6545bd8deadSopenharmony_ci    Section 7.1 of the OpenGL Shading Language Specification describes the
6555bd8deadSopenharmony_ci    built-in variable array gl_in[] available as input to a tessellation
6565bd8deadSopenharmony_ci    control shader.  gl_in[] receives values from equivalent built-in output
6575bd8deadSopenharmony_ci    variables written by the vertex shader (section 2.14.7).  Each array
6585bd8deadSopenharmony_ci    element of gl_in[] is a structure holding values for a specific vertex of
6595bd8deadSopenharmony_ci    the input patch.  The length of gl_in[] is equal to the
6605bd8deadSopenharmony_ci    implementation-dependent maximum patch size (gl_MaxPatchVertices).
6615bd8deadSopenharmony_ci    Behavior is undefined if gl_in[] is indexed with a vertex index greater
6625bd8deadSopenharmony_ci    than or equal to the current patch size.  The members of each element of
6635bd8deadSopenharmony_ci    the gl_in[] array are gl_Position, gl_PointSize, gl_ClipDistance[],
6645bd8deadSopenharmony_ci    gl_ClipVertex, gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor,
6655bd8deadSopenharmony_ci    gl_BackSecondaryColor, gl_TexCoord[], and gl_FogFragCoord[].
6665bd8deadSopenharmony_ci
6675bd8deadSopenharmony_ci    Tessellation control shaders have available several other special input
6685bd8deadSopenharmony_ci    variables not replicated per-vertex and not contained in gl_in[],
6695bd8deadSopenharmony_ci    including:
6705bd8deadSopenharmony_ci
6715bd8deadSopenharmony_ci      * The variable gl_PatchVerticesIn holds the number of vertices in the
6725bd8deadSopenharmony_ci        input patch being processed by the tessellation control shader.
6735bd8deadSopenharmony_ci
6745bd8deadSopenharmony_ci      * The variable gl_PrimitiveID is filled with the number of primitives
6755bd8deadSopenharmony_ci        processed since the last time Begin was called (directly or indirectly
6765bd8deadSopenharmony_ci        via vertex array functions).  The first primitive generated after a
6775bd8deadSopenharmony_ci        Begin is numbered zero, and the primitive ID counter is incremented
6785bd8deadSopenharmony_ci        after every individual point, line, or triangle primitive is
6795bd8deadSopenharmony_ci        processed.  Restarting a primitive topology using the primitive
6805bd8deadSopenharmony_ci        restart index has no effect on the primitive ID counter.
6815bd8deadSopenharmony_ci
6825bd8deadSopenharmony_ci      * The variable gl_InvocationID holds an invocation number for the
6835bd8deadSopenharmony_ci        current tessellation control shader invocation.  Tessellation control
6845bd8deadSopenharmony_ci        shaders are invoked once per output patch vertex, and invocations are
6855bd8deadSopenharmony_ci        numbered beginning with zero.
6865bd8deadSopenharmony_ci
6875bd8deadSopenharmony_ci    Similarly to the built-in varying variables, each user-defined input
6885bd8deadSopenharmony_ci    varying variable has a value for each vertex and thus needs to be declared
6895bd8deadSopenharmony_ci    as arrays or inside input blocks declared as arrays.  Declaring an array
6905bd8deadSopenharmony_ci    size is optional.  If no size is specified, it will be taken from the
6915bd8deadSopenharmony_ci    implementation-dependent maximum patch size (gl_MaxPatchVertices).  If a
6925bd8deadSopenharmony_ci    size is specified, it must match the maximum patch size; otherwise, a
6935bd8deadSopenharmony_ci    compile or link
6945bd8deadSopenharmony_ci    error will occur.  Since the array size may be larger than the number of
6955bd8deadSopenharmony_ci    vertices found in the input patch, behavior is undefined if a per-vertex
6965bd8deadSopenharmony_ci    input variable is accessed using an index greater than or equal to the
6975bd8deadSopenharmony_ci    number of vertices in the input patch.  The OpenGL Shading Language
6985bd8deadSopenharmony_ci    doesn't support multi-dimensional arrays; therefore, user-defined
6995bd8deadSopenharmony_ci    tessellation control shader inputs corresponding to vertex shader outputs
7005bd8deadSopenharmony_ci    declared as arrays must be declared as array members of an input block
7015bd8deadSopenharmony_ci    that is itself declared as an array.
7025bd8deadSopenharmony_ci
7035bd8deadSopenharmony_ci    (Note:  minor restructuring in the following paragraph relative to the
7045bd8deadSopenharmony_ci    equivalent geometry shader language.)
7055bd8deadSopenharmony_ci
7065bd8deadSopenharmony_ci    Similarly to the limit on vertex shader output components (see section
7075bd8deadSopenharmony_ci    2.14.6), there is a limit on the number of components of built-in and
7085bd8deadSopenharmony_ci    user-defined input varying variables that can be read by the tessellation
7095bd8deadSopenharmony_ci    control shader, given by the value of the implementation-dependent
7105bd8deadSopenharmony_ci    constant MAX_TESS_CONTROL_INPUT_COMPONENTS.  When a program is linked, all
7115bd8deadSopenharmony_ci    components of any varying and special variable read by a tessellation
7125bd8deadSopenharmony_ci    control shader will count against this limit.  A program whose
7135bd8deadSopenharmony_ci    tessellation control shader exceeds this limit may fail to link, unless
7145bd8deadSopenharmony_ci    device-dependent optimizations are able to make the program fit within
7155bd8deadSopenharmony_ci    available hardware resources.
7165bd8deadSopenharmony_ci
7175bd8deadSopenharmony_ci
7185bd8deadSopenharmony_ci    Tessellation Control Shader Outputs
7195bd8deadSopenharmony_ci
7205bd8deadSopenharmony_ci    Section 7.1 of the OpenGL Shading Language Specification describes the
7215bd8deadSopenharmony_ci    built-in variable array gl_out[] available as an output for a tessellation
7225bd8deadSopenharmony_ci    control shader.  gl_out[] passes values to equivalent built-in input
7235bd8deadSopenharmony_ci    variables read by subsequent shader stages or to subsequent fixed
7245bd8deadSopenharmony_ci    functionality vertex processing pipeline stages.  Each array element of
7255bd8deadSopenharmony_ci    gl_out[] is a structure holding values for a specific vertex of the output
7265bd8deadSopenharmony_ci    patch. The length of gl_out[] is equal to the output patch size specified
7275bd8deadSopenharmony_ci    in the tessellation control shader output layout declaration
7285bd8deadSopenharmony_ci    (gl_VerticesOut).  The members of each element of the gl_out[] array are
7295bd8deadSopenharmony_ci    gl_Position, gl_PointSize, gl_ClipDistance[], gl_ClipVertex,
7305bd8deadSopenharmony_ci    gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor,
7315bd8deadSopenharmony_ci    gl_BackSecondaryColor, gl_TexCoord[], and gl_FogFragCoord[], and behave
7325bd8deadSopenharmony_ci    identically to equivalently named vertex shader outputs (section 2.14.7).
7335bd8deadSopenharmony_ci
7345bd8deadSopenharmony_ci    Tessellation shaders additionally have two built-in per-patch output
7355bd8deadSopenharmony_ci    arrays, gl_TessLevelOuter[] and gl_TessLevelInner[].  These arrays are not
7365bd8deadSopenharmony_ci    replicated for each output patch vertices and are not members of gl_out[].
7375bd8deadSopenharmony_ci    gl_TessLevelOuter[] is an array of four floating-point values specifying
7385bd8deadSopenharmony_ci    the approximate number of segments that the tessellation primitive
7395bd8deadSopenharmony_ci    generator should use when subdividing each outer edge of the primitive it
7405bd8deadSopenharmony_ci    subdivides.  gl_TessLevelInner[] is an array of two floating-point values
7415bd8deadSopenharmony_ci    specifying the approximate number of segments used to produce a
7425bd8deadSopenharmony_ci    regularly-subdivided primitive interior.  The values written to
7435bd8deadSopenharmony_ci    gl_TessLevelOuter and gl_TessLevelInner need not be integers, and their
7445bd8deadSopenharmony_ci    interpretation depends on the type of primitive the tessellation primitive
7455bd8deadSopenharmony_ci    generator will subdivide and other tessellation parameters, as discussed
7465bd8deadSopenharmony_ci    in the following section.
7475bd8deadSopenharmony_ci
7485bd8deadSopenharmony_ci    A tessellation control shader may also declare user-defined per-vertex
7495bd8deadSopenharmony_ci    output variables.  User-defined per-vertex output variables are declared
7505bd8deadSopenharmony_ci    with the qualifier "out" and have a value for each vertex in the output
7515bd8deadSopenharmony_ci    patch.  Such variables must be declared as arrays or inside output blocks
7525bd8deadSopenharmony_ci    declared as arrays.  Declaring an array size is optional.  If no size is
7535bd8deadSopenharmony_ci    specified, it will be taken from the output patch size (gl_VerticesOut)
7545bd8deadSopenharmony_ci    declared in the shader.  If a size is specified, it must match the maximum
7555bd8deadSopenharmony_ci    patch size; otherwise, a compile or link link error will occur.  The OpenGL Shading
7565bd8deadSopenharmony_ci    Language doesn't support multi-dimensional arrays; therefore, user-defined
7575bd8deadSopenharmony_ci    per-vertex tessellation control shader outputs with multiple elements per
7585bd8deadSopenharmony_ci    vertex must be declared as array members of an output block that is itself
7595bd8deadSopenharmony_ci    declared as an array.
7605bd8deadSopenharmony_ci
7615bd8deadSopenharmony_ci    While per-vertex output variables are declared as arrays indexed by vertex
7625bd8deadSopenharmony_ci    number, each tessellation control shader invocation may write only to
7635bd8deadSopenharmony_ci    those outputs corresponding to its output patch vertex.  Tessellation
7645bd8deadSopenharmony_ci    control shaders must use the special variable gl_InvocationID as the
7655bd8deadSopenharmony_ci    vertex number index when writing to per-vertex output variables.
7665bd8deadSopenharmony_ci
7675bd8deadSopenharmony_ci    Additionally, a tessellation control shader may declare per-patch output
7685bd8deadSopenharmony_ci    variables using the qualifier "patch out".  Unlike per-vertex outputs,
7695bd8deadSopenharmony_ci    per-patch outputs do not correspond to any specific vertex in the patch,
7705bd8deadSopenharmony_ci    and are not indexed by vertex number.  Per-patch outputs declared as
7715bd8deadSopenharmony_ci    arrays have multiple values for the output patch; similarly declared
7725bd8deadSopenharmony_ci    per-vertex outputs would indicate a single value for each vertex in the
7735bd8deadSopenharmony_ci    output patch.  User-defined per-patch outputs are not used by the
7745bd8deadSopenharmony_ci    tessellation primitive generator, but may be read by tessellation
7755bd8deadSopenharmony_ci    evaluation shaders.
7765bd8deadSopenharmony_ci
7775bd8deadSopenharmony_ci    There are several limits on the number of components of built-in and
7785bd8deadSopenharmony_ci    user-defined output variables that can be written by the tessellation
7795bd8deadSopenharmony_ci    control shader.  The number of components of active per-vertex output
7805bd8deadSopenharmony_ci    variables may not exceed the value of MAX_TESS_CONTROL_OUTPUT_COMPONENTS.
7815bd8deadSopenharmony_ci    The number of components of active per-patch output variables may not
7825bd8deadSopenharmony_ci    exceed the value of MAX_TESS_PATCH_COMPONENTS.  The built-in outputs
7835bd8deadSopenharmony_ci    gl_TessLevelOuter[] and gl_TessLevelInner[] are not counted against the
7845bd8deadSopenharmony_ci    per-patch limit.  The total number of components of active per-vertex and
7855bd8deadSopenharmony_ci    per-patch outputs is derived by multiplying the per-vertex output
7865bd8deadSopenharmony_ci    component count by the output patch size and then adding the per-patch
7875bd8deadSopenharmony_ci    output component count.  The total component count may not exceed
7885bd8deadSopenharmony_ci    MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS.  When a program is linked, all
7895bd8deadSopenharmony_ci    components of any varying and special variables written by a tessellation
7905bd8deadSopenharmony_ci    control shader will count against this limit.  A program exceeding any of
7915bd8deadSopenharmony_ci    these limits may fail to link, unless device-dependent optimizations are
7925bd8deadSopenharmony_ci    able to make the program fit within available hardware resources.
7935bd8deadSopenharmony_ci
7945bd8deadSopenharmony_ci
7955bd8deadSopenharmony_ci    Tessellation Control Shader Execution Order
7965bd8deadSopenharmony_ci
7975bd8deadSopenharmony_ci    For tessellation control shaders with a declared output patch size greater
7985bd8deadSopenharmony_ci    than one, the shader is invoked more than once for each input patch.  The
7995bd8deadSopenharmony_ci    order of execution of one tessellation control shader invocation relative
8005bd8deadSopenharmony_ci    to the other invocations for the same input patch is largely undefined.
8015bd8deadSopenharmony_ci    The built-in function barrier() provides some control over relative
8025bd8deadSopenharmony_ci    execution order.  When a tessellation control shader calls the barrier()
8035bd8deadSopenharmony_ci    function, its execution pauses until all other invocations have also
8045bd8deadSopenharmony_ci    called the same function.  Output variable assignments performed by any
8055bd8deadSopenharmony_ci    invocation executed prior to calling barrier() will be visible to any
8065bd8deadSopenharmony_ci    other invocation after the call to barrier() returns.  Shader output
8075bd8deadSopenharmony_ci    values read in one invocation but written by another may be undefined
8085bd8deadSopenharmony_ci    without proper use of barrier(); full rules are found in the OpenGL
8095bd8deadSopenharmony_ci    Shading Language Specification.
8105bd8deadSopenharmony_ci
8115bd8deadSopenharmony_ci    The barrier() function may only be called inside the main entry point of
8125bd8deadSopenharmony_ci    the tessellation control shader and may not be called in potentially
8135bd8deadSopenharmony_ci    divergent flow control.  In particular, barrier() may not be called inside
8145bd8deadSopenharmony_ci    a switch statement, in either sub-statement of an if statement, inside a
8155bd8deadSopenharmony_ci    do, for, or while loop, or at any point after a return statement in the
8165bd8deadSopenharmony_ci    function main().
8175bd8deadSopenharmony_ci
8185bd8deadSopenharmony_ci
8195bd8deadSopenharmony_ci    Section 2.X.2, Tessellation Primitive Generation
8205bd8deadSopenharmony_ci
8215bd8deadSopenharmony_ci    If a tessellation evaluation shader is present, the tessellation primitive
8225bd8deadSopenharmony_ci    generator consumes the input patch and produces a new set of basic
8235bd8deadSopenharmony_ci    primitives (points, lines, or triangles).  These primitives are produced
8245bd8deadSopenharmony_ci    by subdividing a geometric primitive (rectangle or triangle) according to
8255bd8deadSopenharmony_ci    the per-patch tessellation levels written by the tessellation control
8265bd8deadSopenharmony_ci    shader, if present, or taken from default patch parameter values.  This
8275bd8deadSopenharmony_ci    subdivision is performed in an implementation-dependent manner.  If no
8285bd8deadSopenharmony_ci    tessellation evaluation shader is present, the tessellation primitive
8295bd8deadSopenharmony_ci    generator passes incoming primitives through without modification.
8305bd8deadSopenharmony_ci
8315bd8deadSopenharmony_ci    The type of subdivision performed by the tessellation primitive generator
8325bd8deadSopenharmony_ci    is specified by an input layout declaration in the tessellation evaluation
8335bd8deadSopenharmony_ci    shader using one of the identifiers "triangles", "quads", and "isolines".
8345bd8deadSopenharmony_ci    For "triangles", the primitive generator subdivides a triangle primitive
8355bd8deadSopenharmony_ci    into smaller triangles.  For "quads", the primitive generator subdivides a
8365bd8deadSopenharmony_ci    rectangle primitive into smaller triangles.  For "isolines", the primitive
8375bd8deadSopenharmony_ci    generator subdivides a rectangle primitive into a collection of line
8385bd8deadSopenharmony_ci    segments arranged in strips stretching horizontally across the rectangle.
8395bd8deadSopenharmony_ci    Each vertex produced by the primitive generator has an associated (u,v,w)
8405bd8deadSopenharmony_ci    or (u,v) position in a normalized parameter space, with parameter values
8415bd8deadSopenharmony_ci    in the range [0,1], as illustrated in Figure X.1.  For "triangles", the
8425bd8deadSopenharmony_ci    vertex position is a barycentric coordinate (u,v,w), where u+v+w==1, and
8435bd8deadSopenharmony_ci    indicates the relative influence of the three vertices of the triangle on
8445bd8deadSopenharmony_ci    the position of the vertex.  For "quads" and "isolines", the position is a
8455bd8deadSopenharmony_ci    (u,v) coordinate indicating the relative horizontal and vertical position
8465bd8deadSopenharmony_ci    of the vertex relative to the subdivided rectangle.  The subdivision
8475bd8deadSopenharmony_ci    process is explained in more detail in subsequent sections.
8485bd8deadSopenharmony_ci
8495bd8deadSopenharmony_ci        (0,1)   OL3   (1,1)          (0,1,0)         (0,1)          (1,1)
8505bd8deadSopenharmony_ci         +--------------+              +             ^  +  <no edge>   +  
8515bd8deadSopenharmony_ci         |              |             / \            |                
8525bd8deadSopenharmony_ci         |  +--------+  |            /   \           |  +--------------+  
8535bd8deadSopenharmony_ci         |  |   IL0  |  |       OL0 /  +  \ OL2      |                  
8545bd8deadSopenharmony_ci      OL0|  |IL1     |  |OL2       /  / \  \         |  +--------------+  
8555bd8deadSopenharmony_ci         |  |        |  |         /  /IL0\  \       OL0                  
8565bd8deadSopenharmony_ci         |  +--------+  |        /  +-----+  \       |  +--------------+  
8575bd8deadSopenharmony_ci         |              |       /             \      |                 
8585bd8deadSopenharmony_ci         +--------------+      +---------------+     v  +--------------+  
8595bd8deadSopenharmony_ci        (0,0)   OL1   (1,0) (0,0,1)   OL1   (1,0,0)   (0,0)   OL1   (1,0)
8605bd8deadSopenharmony_ci
8615bd8deadSopenharmony_ci              quads                triangles                isolines
8625bd8deadSopenharmony_ci           
8635bd8deadSopenharmony_ci      Figure X.1:  Domain parameterization for tessellation generator
8645bd8deadSopenharmony_ci      primitive modes (triangles, quads, or isolines).  The coordinates
8655bd8deadSopenharmony_ci      illustrate the value of gl_TessCoord at the corners of the domain.  The
8665bd8deadSopenharmony_ci      labels on the edges indicate the inner (IL0 and IL1) and outer (OL0
8675bd8deadSopenharmony_ci      through OL3) tessellation level values used to control the number of
8685bd8deadSopenharmony_ci      subdivisions along each edge of the domain.
8695bd8deadSopenharmony_ci
8705bd8deadSopenharmony_ci    When no tessellation control shader is present, the tessellation levels
8715bd8deadSopenharmony_ci    are taken from default patch tessellation levels.  These default levels
8725bd8deadSopenharmony_ci    are set by calling
8735bd8deadSopenharmony_ci
8745bd8deadSopenharmony_ci      void PatchParameterfv(enum pname, const float *values);
8755bd8deadSopenharmony_ci
8765bd8deadSopenharmony_ci    If <pname> is PATCH_DEFAULT_OUTER_LEVEL, <values> specifies an array of
8775bd8deadSopenharmony_ci    four floating-point values corresponding to the four outer tessellation
8785bd8deadSopenharmony_ci    levels for each subsequent patch.  If <pname> is
8795bd8deadSopenharmony_ci    PATCH_DEFAULT_INNER_LEVEL, <values> specifies an array of two
8805bd8deadSopenharmony_ci    floating-point values corresponding to the two inner tessellation levels.
8815bd8deadSopenharmony_ci
8825bd8deadSopenharmony_ci    A patch is discarded by the tessellation primitive generator if any
8835bd8deadSopenharmony_ci    relevant outer tessellation level is less than or equal to zero.  Patches
8845bd8deadSopenharmony_ci    will also be discarded if any outer tessellation level corresponds to a
8855bd8deadSopenharmony_ci    floating-point NaN (not a number) in implementations supporting NaN.
8865bd8deadSopenharmony_ci    When patches are discarded, no new primitives will be generated and the
8875bd8deadSopenharmony_ci    tessellation evaluation program will not be run.  For "quads", all four
8885bd8deadSopenharmony_ci    outer levels are relevant.  For "triangles" and "isolines", only the first
8895bd8deadSopenharmony_ci    three or two outer levels, respectively, are relevant.  Negative inner
8905bd8deadSopenharmony_ci    levels will not cause a patch to be discarded; they will be clamped as
8915bd8deadSopenharmony_ci    described below.
8925bd8deadSopenharmony_ci
8935bd8deadSopenharmony_ci    Each of the tessellation levels is used to determine the number and
8945bd8deadSopenharmony_ci    spacing of segments used to subdivide a corresponding edge.  The method
8955bd8deadSopenharmony_ci    used to derive the number and spacing of segments is specified by an input
8965bd8deadSopenharmony_ci    layout declaration in the tessellation evaluation shader using one of the
8975bd8deadSopenharmony_ci    identifiers "equal_spacing", "fractional_even_spacing", or
8985bd8deadSopenharmony_ci    "fractional_odd_spacing".  If no spacing is specified in the tessellation
8995bd8deadSopenharmony_ci    evaluation shader, "equal_spacing" will be used.
9005bd8deadSopenharmony_ci
9015bd8deadSopenharmony_ci    If "equal_spacing" is used, the floating-point tessellation level is first
9025bd8deadSopenharmony_ci    clamped to the range [1,<max>], where <max> is implementation-dependent
9035bd8deadSopenharmony_ci    maximum tessellation level (MAX_TESS_GEN_LEVEL).  The result is rounded up
9045bd8deadSopenharmony_ci    to the nearest integer <n>, and the corresponding edge is divided into <n>
9055bd8deadSopenharmony_ci    segments of equal length in (u,v) space.
9065bd8deadSopenharmony_ci
9075bd8deadSopenharmony_ci    If "fractional_even_spacing" is used, the tessellation level is first
9085bd8deadSopenharmony_ci    clamped to the range [2,<max>] and then rounded up to the nearest even
9095bd8deadSopenharmony_ci    integer <n>.  If "fractional_odd_spacing" is used, the tessellation level
9105bd8deadSopenharmony_ci    is clamped to the range [1,<max>-1] and then rounded up to the nearest odd
9115bd8deadSopenharmony_ci    integer <n>.  If <n> is one, the edge will not be subdivided.  Otherwise,
9125bd8deadSopenharmony_ci    the corresponding edge will be divided into <n>-2 segments of equal
9135bd8deadSopenharmony_ci    length, and two additional segments of equal length that are typically
9145bd8deadSopenharmony_ci    shorter than the other segments.  The length of the two additional
9155bd8deadSopenharmony_ci    segments relative to the others will decrease monotonically with the value
9165bd8deadSopenharmony_ci    of <n>-<f>, where <f> is the clamped floating-point tessellation level.
9175bd8deadSopenharmony_ci    When <n>-<f> is zero, the additional segments will have equal length to
9185bd8deadSopenharmony_ci    the other segments.  As <n>-<f> approaches 2.0, the relative length of the
9195bd8deadSopenharmony_ci    additional segments approaches zero.  The two additional segments should
9205bd8deadSopenharmony_ci    be placed symmetrically on opposite sides of the subdivided edge.  The
9215bd8deadSopenharmony_ci    relative location of these two segments is undefined, but must be
9225bd8deadSopenharmony_ci    identical for any pair of subdivided edges with identical values of <f>.
9235bd8deadSopenharmony_ci
9245bd8deadSopenharmony_ci    When the tessellation primitive generator produces triangles (in the
9255bd8deadSopenharmony_ci    "triangles" or "quads" modes), the orientation of all triangles can be
9265bd8deadSopenharmony_ci    specified by an input layout declaration in the tessellation evaluation
9275bd8deadSopenharmony_ci    shader using the identifiers "cw" and "ccw".  If the order is "cw", the
9285bd8deadSopenharmony_ci    vertices of all generated triangles will have a clockwise ordering in
9295bd8deadSopenharmony_ci    (u,v) or (u,v,w) space, as illustrated in Figure X.1.  If the order is
9305bd8deadSopenharmony_ci    "ccw", the vertices will be specified in counter-clockwise order.  If no
9315bd8deadSopenharmony_ci    layout is specified, "ccw" will be used.
9325bd8deadSopenharmony_ci
9335bd8deadSopenharmony_ci    For all primitive modes, the tessellation primitive generator is capable
9345bd8deadSopenharmony_ci    of generating points instead of lines or triangles.  If an input layout
9355bd8deadSopenharmony_ci    declaration in the tessellation evaluation shader specifies the identifier
9365bd8deadSopenharmony_ci    "point_mode", the primitive generator will generate one point for each
9375bd8deadSopenharmony_ci    distinct vertex produced by tessellation.  Otherwise, the primitive
9385bd8deadSopenharmony_ci    generator will produce a collection of line segments or triangles
9395bd8deadSopenharmony_ci    according to the primitive mode.  When tessellating triangles or quads in
9405bd8deadSopenharmony_ci    point mode with fractional odd spacing, the tessellation primitive
9415bd8deadSopenharmony_ci    generator may produce "interior" vertices that are positioned on the edge
9425bd8deadSopenharmony_ci    of the patch if an inner tessellation level is less than or equal to one.
9435bd8deadSopenharmony_ci    Such vertices are considered distinct from vertices produced by
9445bd8deadSopenharmony_ci    subdividing the outer edge of the patch, even if there are pairs of
9455bd8deadSopenharmony_ci    vertices with identical coordinates.
9465bd8deadSopenharmony_ci
9475bd8deadSopenharmony_ci    The points, lines, or triangles produced by the tessellation primitive
9485bd8deadSopenharmony_ci    generator are passed to subsequent pipeline stages in an
9495bd8deadSopenharmony_ci    implementation-dependent order.
9505bd8deadSopenharmony_ci
9515bd8deadSopenharmony_ci
9525bd8deadSopenharmony_ci    Section 2.X.2.1, Triangle Tessellation
9535bd8deadSopenharmony_ci
9545bd8deadSopenharmony_ci    If the tessellation primitive mode is "triangles", an equilateral triangle
9555bd8deadSopenharmony_ci    is subdivided into a collection of triangles covering the area of the
9565bd8deadSopenharmony_ci    original triangle.  First, the original triangle is subdivided into a
9575bd8deadSopenharmony_ci    collection of concentric equilateral triangles.  The edges of each of
9585bd8deadSopenharmony_ci    these triangles are subdivided, and the area between each triangle pair is
9595bd8deadSopenharmony_ci    filled by triangles produced by joining the vertices on the subdivided
9605bd8deadSopenharmony_ci    edges.  The number of concentric triangles and the number of subdivisions
9615bd8deadSopenharmony_ci    along each triangle except the outermost is derived from the first inner
9625bd8deadSopenharmony_ci    tessellation level.  The edges of the outermost triangle are subdivided
9635bd8deadSopenharmony_ci    independently, using the first, second, and third outer tessellation
9645bd8deadSopenharmony_ci    levels to control the number of subdivisions of the u==0 (left), v==0
9655bd8deadSopenharmony_ci    (bottom), and w==0 (right) edges, respectively.  The second inner
9665bd8deadSopenharmony_ci    tessellation level and the fourth outer tessellation level have no effect
9675bd8deadSopenharmony_ci    in this mode.
9685bd8deadSopenharmony_ci
9695bd8deadSopenharmony_ci    If the first inner tessellation level and all three outer tessellation
9705bd8deadSopenharmony_ci    levels are exactly one after clamping and rounding, only a single triangle
9715bd8deadSopenharmony_ci    with (u,v,w) coordinates of (0,0,1), (1,0,0), and (0,1,0) is generated.
9725bd8deadSopenharmony_ci    If the inner tessellation level is one and any of the outer tessellation
9735bd8deadSopenharmony_ci    levels is greater than one, the inner tessellation level is treated as
9745bd8deadSopenharmony_ci    though it were originally specified as 1+epsilon and will result in a two-
9755bd8deadSopenharmony_ci    or three-segment subdivision depending on the tessellation spacing.  When
9765bd8deadSopenharmony_ci    used with fractional odd spacing, the three-segment subdivision may
9775bd8deadSopenharmony_ci    produce "inner" vertices positioned on the edge of the triangle.
9785bd8deadSopenharmony_ci
9795bd8deadSopenharmony_ci    If any tessellation level is greater than one, tessellation begins by
9805bd8deadSopenharmony_ci    producing a set of concentric inner triangles and subdividing their edges.
9815bd8deadSopenharmony_ci    First, the three outer edges are temporarily subdivided using the clamped
9825bd8deadSopenharmony_ci    and rounded first inner tessellation level and the specified tessellation
9835bd8deadSopenharmony_ci    spacing, generating <n> segments.  For the outermost inner triangle, the
9845bd8deadSopenharmony_ci    inner triangle is degenerate -- a single point at the center of the
9855bd8deadSopenharmony_ci    triangle -- if <n> is two.  Otherwise, for each corner of the outer
9865bd8deadSopenharmony_ci    triangle, an inner triangle corner is produced at the intersection of two
9875bd8deadSopenharmony_ci    lines extended perpendicular to the corner's two adjacent edges running
9885bd8deadSopenharmony_ci    through the vertex of the subdivided outer edge nearest that corner.  If
9895bd8deadSopenharmony_ci    <n> is three, the edges of the inner triangle are not subdivided and is
9905bd8deadSopenharmony_ci    the final triangle in the set of concentric triangles.  Otherwise, each
9915bd8deadSopenharmony_ci    edge of the inner triangle is divided into <n>-2 segments, with the <n>-1
9925bd8deadSopenharmony_ci    vertices of this subdivision produced by intersecting the inner edge with
9935bd8deadSopenharmony_ci    lines perpendicular to the edge running through the <n>-1 innermost
9945bd8deadSopenharmony_ci    vertices of the subdivision of the outer edge.  Once the outermost inner
9955bd8deadSopenharmony_ci    triangle is subdivided, the previous subdivision process repeats itself,
9965bd8deadSopenharmony_ci    using the generated triangle as an outer triangle.  This subdivision
9975bd8deadSopenharmony_ci    process is illustrated in Figure X.2.
9985bd8deadSopenharmony_ci
9995bd8deadSopenharmony_ci                                                   (0,1,0)
10005bd8deadSopenharmony_ci                                                      +
10015bd8deadSopenharmony_ci                                                     / \
10025bd8deadSopenharmony_ci                 (0,1,0)                            O. .O
10035bd8deadSopenharmony_ci                    +                              /  +  \
10045bd8deadSopenharmony_ci                   / \                            O. / \ .O
10055bd8deadSopenharmony_ci                  O. .O                          /  O. .O  \
10065bd8deadSopenharmony_ci                 /  +  \                        /  /  +  \  \
10075bd8deadSopenharmony_ci                O. / \ .O                      /  /  / \  \  \
10085bd8deadSopenharmony_ci               /  O. .O  \                    O. /  /   \  \ .O
10095bd8deadSopenharmony_ci              /  /  O  \  \                  /  O. /     \ .O  \
10105bd8deadSopenharmony_ci             O. /   .   \ .O                /  /  O-------O  \  \
10115bd8deadSopenharmony_ci            /  O----O----O  \              O. /   .       .   \ .O
10125bd8deadSopenharmony_ci           /   .    .    .   \            /  O----O-------O----O  \
10135bd8deadSopenharmony_ci          O----O----O----O----O          /   .    .       .    .   \
10145bd8deadSopenharmony_ci       (0,0,1)             (1,0,0)      O----O----O-------O----O----O
10155bd8deadSopenharmony_ci                                     (0,0,1)                     (1,0,0)
10165bd8deadSopenharmony_ci        
10175bd8deadSopenharmony_ci      Figure X.2, Inner Triangle Tessellation with inner tessellation levels
10185bd8deadSopenharmony_ci      of four and five (not to scale).  This figure depicts the vertices along
10195bd8deadSopenharmony_ci      the bottom edge of the concentric triangles.  The edges of inner
10205bd8deadSopenharmony_ci      triangles are subdivided by intersecting the edge with segments
10215bd8deadSopenharmony_ci      perpendicular to the edge passing through each inner vertex of the
10225bd8deadSopenharmony_ci      subdivided outer edge.
10235bd8deadSopenharmony_ci
10245bd8deadSopenharmony_ci    Once all the concentric triangles are produced and their edges are
10255bd8deadSopenharmony_ci    subdivided, the area between each pair of adjacent inner triangles is
10265bd8deadSopenharmony_ci    filled completely with a set of non-overlapping triangles.  In this
10275bd8deadSopenharmony_ci    subdivision, two of the three vertices of each triangle are taken from
10285bd8deadSopenharmony_ci    adjacent vertices on a subdivided edge of one triangle; the third is one
10295bd8deadSopenharmony_ci    of the vertices on the corresponding edge of the other triangle.  If the
10305bd8deadSopenharmony_ci    innermost triangle is degenerate (i.e., a point), the triangle containing
10315bd8deadSopenharmony_ci    it is subdivided into six triangles by connecting each of the six vertices
10325bd8deadSopenharmony_ci    on that triangle with the center point.  If the innermost triangle is not
10335bd8deadSopenharmony_ci    degenerate, that triangle is added to the set of generated triangles
10345bd8deadSopenharmony_ci    as-is.
10355bd8deadSopenharmony_ci
10365bd8deadSopenharmony_ci    After the area corresponding to any inner triangles is filled, the
10375bd8deadSopenharmony_ci    primitive generator generates triangles to cover area between the
10385bd8deadSopenharmony_ci    outermost triangle and the outermost inner triangle.  To do this, the
10395bd8deadSopenharmony_ci    temporary subdivision of the outer triangle edge above is discarded.
10405bd8deadSopenharmony_ci    Instead, the u==0, v==0, and w==0 edges are subdivided according to the
10415bd8deadSopenharmony_ci    first, second, and third outer tessellation levels, respectively, and the
10425bd8deadSopenharmony_ci    tessellation spacing.  The original subdivision of the first inner
10435bd8deadSopenharmony_ci    triangle is retained.  The area between the outer and first inner
10445bd8deadSopenharmony_ci    triangles is completely filled by non-overlapping triangles as described
10455bd8deadSopenharmony_ci    above.  If the first (and only) inner triangle is degenerate, a set of
10465bd8deadSopenharmony_ci    triangles is produced by connecting each vertex on the outer triangle
10475bd8deadSopenharmony_ci    edges with the center point.
10485bd8deadSopenharmony_ci
10495bd8deadSopenharmony_ci    After all triangles are generated, each vertex in the subdivided triangle
10505bd8deadSopenharmony_ci    is assigned a barycentric (u,v,w) coordinate based on its location
10515bd8deadSopenharmony_ci    relative to the three vertices of the outer triangle.
10525bd8deadSopenharmony_ci
10535bd8deadSopenharmony_ci    The algorithm used to subdivide the triangular domain in (u,v,w) space
10545bd8deadSopenharmony_ci    into individual triangles is implementation-dependent.  However, the set
10555bd8deadSopenharmony_ci    of triangles produced will completely cover the domain, and no portion of
10565bd8deadSopenharmony_ci    the domain will be covered by multiple triangles.  The order in which the
10575bd8deadSopenharmony_ci    generated triangles passed to subsequent pipeline stages and the order of
10585bd8deadSopenharmony_ci    the vertices in those triangles are both implementation-dependent.
10595bd8deadSopenharmony_ci    However, when depicted in a manner similar to Figure X.2, the order of the
10605bd8deadSopenharmony_ci    vertices in the generated triangles will be either all clockwise or all
10615bd8deadSopenharmony_ci    counter-clockwise, according to the vertex order layout declaration.
10625bd8deadSopenharmony_ci
10635bd8deadSopenharmony_ci
10645bd8deadSopenharmony_ci    Section 2.X.2.2, Quad Tessellation
10655bd8deadSopenharmony_ci
10665bd8deadSopenharmony_ci    If the tessellation primitive mode is "quads", a rectangle is subdivided
10675bd8deadSopenharmony_ci    into a collection of triangles covering the area of the original
10685bd8deadSopenharmony_ci    rectangle.  First, the original rectangle is subdivided into a regular
10695bd8deadSopenharmony_ci    mesh of rectangles, where the number of rectangles along the u==0 and u==1
10705bd8deadSopenharmony_ci    (vertical) and v==0 and v==1 (horizontal) edges are derived from the first
10715bd8deadSopenharmony_ci    and second inner tessellation levels, respectively.  All rectangles,
10725bd8deadSopenharmony_ci    except those adjacent to one of the outer rectangle edges, are decomposed
10735bd8deadSopenharmony_ci    into triangle pairs.  The outermost rectangle edges are subdivided
10745bd8deadSopenharmony_ci    independently, using the first, second, third, and fourth outer
10755bd8deadSopenharmony_ci    tessellation levels to control the number of subdivisions of the u==0
10765bd8deadSopenharmony_ci    (left), v==0 (bottom), u==1 (right), and v==1 (top) edges, respectively.
10775bd8deadSopenharmony_ci    The area between the inner rectangles of the mesh and the outer rectangle
10785bd8deadSopenharmony_ci    edges are filled by triangles produced by joining the vertices on the
10795bd8deadSopenharmony_ci    subdivided outer edges to the vertices on the edge of the inner rectangle
10805bd8deadSopenharmony_ci    mesh.
10815bd8deadSopenharmony_ci
10825bd8deadSopenharmony_ci    If both clamped inner tessellation levels and all four clamped outer
10835bd8deadSopenharmony_ci    tessellation levels are exactly one, only a single triangle pair covering
10845bd8deadSopenharmony_ci    the outer rectangle is generated.  Otherwise, if either clamped inner
10855bd8deadSopenharmony_ci    tessellation level is one, that tessellation level is treated as though it
10865bd8deadSopenharmony_ci    were originally specified as 1+epsilon and will result in a two- or
10875bd8deadSopenharmony_ci    three-segment subdivision depending on the tessellation spacing.  When
10885bd8deadSopenharmony_ci    used with fractional odd spacing, the three-segment subdivision may
10895bd8deadSopenharmony_ci    produce "inner" vertices positioned on the edge of the rectangle.
10905bd8deadSopenharmony_ci
10915bd8deadSopenharmony_ci    If any tessellation level is greater than one, tessellation begins by
10925bd8deadSopenharmony_ci    subdividing the u==0 and u==1 edges of the outer rectangle into <m>
10935bd8deadSopenharmony_ci    segments using the clamped and rounded first inner tessellation level and
10945bd8deadSopenharmony_ci    the tessellation spacing.  The v==0 and v==1 edges are subdivided into <n>
10955bd8deadSopenharmony_ci    segments using using the second inner tessellation level.  Each vertex on
10965bd8deadSopenharmony_ci    the u==0 and v==0 edges are joined with the corresponding vertex on the
10975bd8deadSopenharmony_ci    u==1 and v==1 edges to produce a set of vertical and horizontal lines that
10985bd8deadSopenharmony_ci    divide the rectangle into a grid of smaller rectangles.  The primitive
10995bd8deadSopenharmony_ci    generator emits a pair of non-overlapping triangles covering each such
11005bd8deadSopenharmony_ci    rectangle not adjacent to an edge of the outer rectangle.  The boundary of
11015bd8deadSopenharmony_ci    the region covered by these triangles forms an inner rectangle, the edges
11025bd8deadSopenharmony_ci    of which are subdivided by the grid vertices that lie on the edge.  If
11035bd8deadSopenharmony_ci    either <m> or <n> is two, the inner rectangle is degenerate, and one or
11045bd8deadSopenharmony_ci    both of the rectangle's "edges" consist of a single point.  This
11055bd8deadSopenharmony_ci    subdivision is illustrated in Figure X.3.
11065bd8deadSopenharmony_ci
11075bd8deadSopenharmony_ci                                     (0,1)                (1,1)
11085bd8deadSopenharmony_ci                                       +--+--+--+--+--+--+--+
11095bd8deadSopenharmony_ci                                       |  .  .  .  .  .  .  |
11105bd8deadSopenharmony_ci              (0,1)       (1,1)        |  .  .  .  .  .  .  |
11115bd8deadSopenharmony_ci                +--+--+--+--+          +..O--O--O--O--O--O..+
11125bd8deadSopenharmony_ci                |  .  .  .  |          |  |**|**|**|**|**|  |
11135bd8deadSopenharmony_ci                |  .  .  .  |          |  |**|**|**|**|**|  |
11145bd8deadSopenharmony_ci                +..O--O--O..+          +..O--+--+--+--+--O..+
11155bd8deadSopenharmony_ci                |  .  .  .  |          |  |**|**|**|**|**|  |
11165bd8deadSopenharmony_ci                |  .  .  .  |          |  |**|**|**|**|**|  |
11175bd8deadSopenharmony_ci                +--+--+--+--+          +..O--O--O--O--O--O..+
11185bd8deadSopenharmony_ci              (0,0)       (1,0)        |  .  .  .  .  .  .  |
11195bd8deadSopenharmony_ci                                       |  .  .  .  .  .  .  |
11205bd8deadSopenharmony_ci                                       +--+--+--+--+--+--+--+
11215bd8deadSopenharmony_ci                                     (0,0)                (1,0)
11225bd8deadSopenharmony_ci
11235bd8deadSopenharmony_ci      Figure X.3, Inner Quad Tessellation with inner tessellation levels of
11245bd8deadSopenharmony_ci      (4,2) and (7,4).  The areas labeled with "*" on the right depict the 10
11255bd8deadSopenharmony_ci      inner rectangles, each of which will be subdivided into two triangles.
11265bd8deadSopenharmony_ci      The points labeled "O" depict vertices on the boundary of the inner
11275bd8deadSopenharmony_ci      rectangle, where the inner rectangle on the left side is degenerate (a
11285bd8deadSopenharmony_ci      single line segment).  The dotted lines (".") depict the horizontal and
11295bd8deadSopenharmony_ci      vertical edges connecting corresponding points on the outer rectangle
11305bd8deadSopenharmony_ci      edge.
11315bd8deadSopenharmony_ci
11325bd8deadSopenharmony_ci    After the area corresponding to the inner rectangle is filled, the
11335bd8deadSopenharmony_ci    primitive generator must produce triangles to cover area between the inner
11345bd8deadSopenharmony_ci    and outer rectangles.  To do this, the subdivision of the outer rectangle
11355bd8deadSopenharmony_ci    edge above is discarded.  Instead, the u==0, v==0, u==1, and v==1 edges
11365bd8deadSopenharmony_ci    are subdivided according to the first, second, third, and fourth outer
11375bd8deadSopenharmony_ci    tessellation levels, respectively, and the tessellation spacing.  The
11385bd8deadSopenharmony_ci    original subdivision of the inner rectangle is retained.  The area between
11395bd8deadSopenharmony_ci    the outer and inner rectangles is completely filled by non-overlapping
11405bd8deadSopenharmony_ci    triangles.  Two of the three vertices of each triangle are adjacent
11415bd8deadSopenharmony_ci    vertices on a subdivided edge of one rectangle; the third is one of the
11425bd8deadSopenharmony_ci    vertices on the corresponding edge of the other rectangle.  If either edge
11435bd8deadSopenharmony_ci    of the innermost rectangle is degenerate, the area near the corresponding
11445bd8deadSopenharmony_ci    outer edges is filled by connecting each vertex on the outer edge with the
11455bd8deadSopenharmony_ci    single vertex making up the inner "edge".
11465bd8deadSopenharmony_ci
11475bd8deadSopenharmony_ci    The algorithm used to subdivide the rectangular domain in (u,v) space into
11485bd8deadSopenharmony_ci    individual triangles is implementation-dependent.  However, the set of
11495bd8deadSopenharmony_ci    triangles produced will completely cover the domain, and no portion of the
11505bd8deadSopenharmony_ci    domain will be covered by multiple triangles.  The order in which the
11515bd8deadSopenharmony_ci    generated triangles passed to subsequent pipeline stages and the order of
11525bd8deadSopenharmony_ci    the vertices in those triangles are both implementation-dependent.
11535bd8deadSopenharmony_ci    However, when depicted in a manner similar to Figure X.3, the order of the
11545bd8deadSopenharmony_ci    vertices in the generated triangles will be either all clockwise or all
11555bd8deadSopenharmony_ci    counter-clockwise, according to the vertex order layout declaration.
11565bd8deadSopenharmony_ci
11575bd8deadSopenharmony_ci
11585bd8deadSopenharmony_ci    Isoline Tessellation
11595bd8deadSopenharmony_ci
11605bd8deadSopenharmony_ci    If the tessellation primitive mode is "isolines", a set of independent
11615bd8deadSopenharmony_ci    horizontal line segments is drawn.  The segments are arranged into
11625bd8deadSopenharmony_ci    connected strips called "isolines", where the vertices of each isoline
11635bd8deadSopenharmony_ci    have a constant v coordinate and u coordinates covering the full range
11645bd8deadSopenharmony_ci    [0,1].  The number of isolines generated is derived from the first outer
11655bd8deadSopenharmony_ci    tessellation level; the number of segments in each isoline is derived from
11665bd8deadSopenharmony_ci    the second outer tessellation level.  Both inner tessellation levels and
11675bd8deadSopenharmony_ci    the third and fourth outer tessellation levels have no effect in this
11685bd8deadSopenharmony_ci    mode.
11695bd8deadSopenharmony_ci
11705bd8deadSopenharmony_ci    As with quad tessellation above, isoline tessellation begins with a
11715bd8deadSopenharmony_ci    rectangle.  The u==0 and u==1 edges of the rectangle are subdivided
11725bd8deadSopenharmony_ci    according to the first outer tessellation level.  For the purposes of this
11735bd8deadSopenharmony_ci    subdivision, the tessellation spacing mode is ignored and treated as
11745bd8deadSopenharmony_ci    equal_spacing.  An isoline is drawn connecting each vertex on the u==0
11755bd8deadSopenharmony_ci    rectangle edge to the corresponding vertex on the u==1 rectangle edge,
11765bd8deadSopenharmony_ci    except that no line is drawn between (0,1) and (1,1).  If the number of
11775bd8deadSopenharmony_ci    isolines on the subdivided u==0 and u==1 edges is <n>, this process will
11785bd8deadSopenharmony_ci    result in <n> equally spaced lines with constant v coordinates of 0,
11795bd8deadSopenharmony_ci    1/<n>, 2/<n>, ..., and (<n>-1)/<n>.
11805bd8deadSopenharmony_ci
11815bd8deadSopenharmony_ci    Each of the <n> isolines is then subdivided according to the second outer
11825bd8deadSopenharmony_ci    tessellation level and the tessellation spacing, resulting in <m> line
11835bd8deadSopenharmony_ci    segments.  Each segment of each line is emitted by the tessellation
11845bd8deadSopenharmony_ci    primitive generator, as illustrated in Figure X.4.
11855bd8deadSopenharmony_ci
11865bd8deadSopenharmony_ci       (0,1)                   (1,1)
11875bd8deadSopenharmony_ci         +                       +          (0,1)             (1,1)
11885bd8deadSopenharmony_ci                                              +                 +
11895bd8deadSopenharmony_ci         O---O---O---O---O---O---O
11905bd8deadSopenharmony_ci
11915bd8deadSopenharmony_ci         O---O---O---O---O---O---O
11925bd8deadSopenharmony_ci
11935bd8deadSopenharmony_ci         O---O---O---O---O---O---O
11945bd8deadSopenharmony_ci                                              O-----O-----O-----O
11955bd8deadSopenharmony_ci         O---O---O---O---O---O---O          (0,0)             (1,0)
11965bd8deadSopenharmony_ci       (0,0)                   (1,0)
11975bd8deadSopenharmony_ci
11985bd8deadSopenharmony_ci      Figure X.4, Isoline Tessellation with the first two outer tessellation
11995bd8deadSopenharmony_ci      levels of (4,6) and (1,3), respectively.  The lines connecting the
12005bd8deadSopenharmony_ci      vertices labeled "O" are emitted by the primitive generator.  The
12015bd8deadSopenharmony_ci      vertices labeled "+" correspond to (u,v) coordinates of (0,1) and (1,1),
12025bd8deadSopenharmony_ci      where no line segments are generated.
12035bd8deadSopenharmony_ci
12045bd8deadSopenharmony_ci    The order in which the generated line segments are passed to subsequent
12055bd8deadSopenharmony_ci    pipeline stages and the order of the vertices in each generated line
12065bd8deadSopenharmony_ci    segment are both implementation-dependent.
12075bd8deadSopenharmony_ci
12085bd8deadSopenharmony_ci
12095bd8deadSopenharmony_ci    Section 2.X.3, Tessellation Evaluation Shaders
12105bd8deadSopenharmony_ci
12115bd8deadSopenharmony_ci    If active, the tessellation evaluation shader takes the (u,v) or (u,v,w)
12125bd8deadSopenharmony_ci    location of each vertex in the primitive subdivided by the tessellation
12135bd8deadSopenharmony_ci    primitive generator, and generates a vertex with a position and associated
12145bd8deadSopenharmony_ci    attributes.  The tessellation evaluation shader can read any of the
12155bd8deadSopenharmony_ci    vertices of its input patch, which is the output patch produced by the
12165bd8deadSopenharmony_ci    tessellation control shader (if present) or provided by the application
12175bd8deadSopenharmony_ci    and transformed by the vertex shader (if no control shader is used).
12185bd8deadSopenharmony_ci    Evaluating the bivariate polynomials described in Section 5.1 (Evaluators)
12195bd8deadSopenharmony_ci    using the vertices of the provided patch as control points is one example
12205bd8deadSopenharmony_ci    of the type of computations that a tessellation evaluation shader might be
12215bd8deadSopenharmony_ci    expected to perform.  Tessellation evaluation shaders are created as
12225bd8deadSopenharmony_ci    described in section 2.14.1, using a <type> of TESS_EVALUATION_SHADER.
12235bd8deadSopenharmony_ci
12245bd8deadSopenharmony_ci    Each invocation of the tessellation evaluation shader writes the
12255bd8deadSopenharmony_ci    attributes of exactly one vertex.  The number of vertices evaluated per
12265bd8deadSopenharmony_ci    patch depends on the tessellation level values computed by the
12275bd8deadSopenharmony_ci    tessellation control shaders (if present) or specified as patch
12285bd8deadSopenharmony_ci    parameters.  Tessellation evaluation shader invocations run independently,
12295bd8deadSopenharmony_ci    and no invocation can access the variables belonging to another
12305bd8deadSopenharmony_ci    invocation.  All invocations are capable of accessing all the vertices of
12315bd8deadSopenharmony_ci    their corresponding input patch.
12325bd8deadSopenharmony_ci
12335bd8deadSopenharmony_ci    If a tessellation control shader is present, the number of the vertices in
12345bd8deadSopenharmony_ci    the input patch is fixed and is equal to the tessellation control shader
12355bd8deadSopenharmony_ci    output patch size parameter in effect when the program was last linked.
12365bd8deadSopenharmony_ci    If no tessellation control shader is present, the input patch is provided
12375bd8deadSopenharmony_ci    by the application can have a variable number of vertices, as specified by
12385bd8deadSopenharmony_ci    the PatchParameteri function.
12395bd8deadSopenharmony_ci
12405bd8deadSopenharmony_ci
12415bd8deadSopenharmony_ci    Section 2.X.3.1, Tessellation Evaluation Shader Variables
12425bd8deadSopenharmony_ci
12435bd8deadSopenharmony_ci    Tessellation evaluation shaders can access uniforms belonging to the
12445bd8deadSopenharmony_ci    current program object.  The amount of storage available for uniform
12455bd8deadSopenharmony_ci    variables in the default uniform block accessed by a tessellation
12465bd8deadSopenharmony_ci    evaluation shader is specified by the value of the
12475bd8deadSopenharmony_ci    implementation-dependent constant MAX_TESS_EVALUATION_UNIFORM_COMPONENTS.
12485bd8deadSopenharmony_ci    The total amount of combined storage available for uniform variables in
12495bd8deadSopenharmony_ci    all uniform blocks accessed by a tessellation evaluation shader (including
12505bd8deadSopenharmony_ci    the default uniform block) is specified by the value of the
12515bd8deadSopenharmony_ci    implementation-dependent constant
12525bd8deadSopenharmony_ci    MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS.  These values represent
12535bd8deadSopenharmony_ci    the numbers of individual floating-point, integer, or boolean values that
12545bd8deadSopenharmony_ci    can be held in uniform variable storage for a tessellation evaluation
12555bd8deadSopenharmony_ci    shader.  A link error is generated if an attempt is made to utilize more
12565bd8deadSopenharmony_ci    than the space available for tessellation evaluation shader uniform
12575bd8deadSopenharmony_ci    variables.  Uniforms are manipulated as described in section 2.14.4.
12585bd8deadSopenharmony_ci    Tessellation evaluation shaders also have access to samplers to perform
12595bd8deadSopenharmony_ci    texturing operations, as described in sections 2.14.5.
12605bd8deadSopenharmony_ci
12615bd8deadSopenharmony_ci    Tessellation evaluation shaders can access the transformed attributes of
12625bd8deadSopenharmony_ci    all vertices for their input primitive using input variables.  If active,
12635bd8deadSopenharmony_ci    a tessellation control shader writing to output variables generates the
12645bd8deadSopenharmony_ci    values of these input varying variables, including values for built-in as
12655bd8deadSopenharmony_ci    well as user-defined varying variables.  If no tessellation control shader
12665bd8deadSopenharmony_ci    is active, input variables will be obtained from vertex shader outputs.
12675bd8deadSopenharmony_ci    Values for any varying variables that are not written by a vertex or
12685bd8deadSopenharmony_ci    tessellation control shader are undefined.
12695bd8deadSopenharmony_ci
12705bd8deadSopenharmony_ci    Additionally, tessellation evaluation shaders can write to one or more
12715bd8deadSopenharmony_ci    built-in or user-defined output variables that will be passed to
12725bd8deadSopenharmony_ci    subsequent programmable shader stages or fixed functionality vertex
12735bd8deadSopenharmony_ci    pipeline stages.
12745bd8deadSopenharmony_ci
12755bd8deadSopenharmony_ci
12765bd8deadSopenharmony_ci    Section 2.X.3.2, Tessellation Evaluation Shader Execution Environment
12775bd8deadSopenharmony_ci
12785bd8deadSopenharmony_ci    If a successfully linked program object that contains a tessellation
12795bd8deadSopenharmony_ci    evaluation shader is made current by calling UseProgram, the executable
12805bd8deadSopenharmony_ci    version of the tessellation evaluation shader is used to process vertices
12815bd8deadSopenharmony_ci    produced by the tessellation primitive generator.  During this processing,
12825bd8deadSopenharmony_ci    the shader may access the input patch processed by the primitive
12835bd8deadSopenharmony_ci    generator.  When tessellation evaluation shader execution completes, a new
12845bd8deadSopenharmony_ci    vertex is assembled from the output variables written by the shader and is
12855bd8deadSopenharmony_ci    passed to subsequent pipeline stages.
12865bd8deadSopenharmony_ci
12875bd8deadSopenharmony_ci    There are several special considerations for tessellation evaluation
12885bd8deadSopenharmony_ci    shader execution described in the following sections.
12895bd8deadSopenharmony_ci
12905bd8deadSopenharmony_ci    Texture Access
12915bd8deadSopenharmony_ci
12925bd8deadSopenharmony_ci    The Shader-Only Texturing subsection of section 2.14.7 describes texture
12935bd8deadSopenharmony_ci    lookup functionality accessible to a vertex shader.  The texel fetch and
12945bd8deadSopenharmony_ci    texture size query functionality described there also applies to
12955bd8deadSopenharmony_ci    tessellation evaluation shaders.
12965bd8deadSopenharmony_ci
12975bd8deadSopenharmony_ci    Tessellation Evaluation Shader Inputs
12985bd8deadSopenharmony_ci
12995bd8deadSopenharmony_ci    Section 7.1 of the OpenGL Shading Language Specification describes the
13005bd8deadSopenharmony_ci    built-in variable array gl_in[] available as input to a tessellation
13015bd8deadSopenharmony_ci    evaluation shader.  gl_in[] receives values from equivalent built-in
13025bd8deadSopenharmony_ci    output variables written by a previous shader (section 2.14.7).  If a
13035bd8deadSopenharmony_ci    tessellation control shader active, the values of gl_in[] will be taken
13045bd8deadSopenharmony_ci    from tessellation control shader outputs.  Otherwise, they will be taken
13055bd8deadSopenharmony_ci    from vertex shader outputs.  Each array element of gl_in[] is a structure
13065bd8deadSopenharmony_ci    holding values for a specific vertex of the input patch.  The length of
13075bd8deadSopenharmony_ci    gl_in[] is equal to the implementation-dependent maximum patch size
13085bd8deadSopenharmony_ci    (gl_MaxPatchVertices).  Behavior is undefined if gl_in[] is indexed with a
13095bd8deadSopenharmony_ci    vertex index greater than or equal to the current patch size.  The members
13105bd8deadSopenharmony_ci    of each element of the gl_in[] array are gl_Position, gl_PointSize,
13115bd8deadSopenharmony_ci    gl_ClipDistance[], gl_ClipVertex, gl_FrontColor, gl_BackColor,
13125bd8deadSopenharmony_ci    gl_FrontSecondaryColor, gl_BackSecondaryColor, gl_TexCoord[], and
13135bd8deadSopenharmony_ci    gl_FogFragCoord[].
13145bd8deadSopenharmony_ci
13155bd8deadSopenharmony_ci    Tessellation evaluation shaders have available several other special input
13165bd8deadSopenharmony_ci    variables not replicated per-vertex and not contained in gl_in[],
13175bd8deadSopenharmony_ci    including:
13185bd8deadSopenharmony_ci
13195bd8deadSopenharmony_ci      * The variables gl_PatchVerticesIn and gl_PrimitiveID are filled with
13205bd8deadSopenharmony_ci        the number of the vertices in the input patch and a primitive number,
13215bd8deadSopenharmony_ci        respectively.  They behave exactly as the identically named inputs for
13225bd8deadSopenharmony_ci        tessellation control shaders.
13235bd8deadSopenharmony_ci
13245bd8deadSopenharmony_ci      * The variable gl_TessCoord is a three-component floating-point vector
13255bd8deadSopenharmony_ci        consisting of the (u,v,w) coordinate of the vertex being processed by
13265bd8deadSopenharmony_ci        the tessellation evaluation shader.  The values of u, v, and w are in
13275bd8deadSopenharmony_ci        the range [0,1], and vary linearly across the primitive being
13285bd8deadSopenharmony_ci        subdivided.  For tessellation primitive modes of "quads" or
13295bd8deadSopenharmony_ci        "isolines", the w value is always zero.  The (u,v,w) coordinates are
13305bd8deadSopenharmony_ci        generated by the tessellation primitive generator in a manner
13315bd8deadSopenharmony_ci        dependent on the primitive mode, as described in section 2.X.2.
13325bd8deadSopenharmony_ci        gl_TessCoord is not an array; it specifies the location of the vertex
13335bd8deadSopenharmony_ci        being processed by the tessellation evaluation shader, not of any
13345bd8deadSopenharmony_ci        vertex in the input patch.
13355bd8deadSopenharmony_ci
13365bd8deadSopenharmony_ci      * The variables gl_TessLevelOuter[] and gl_TessLevelInner[] are arrays
13375bd8deadSopenharmony_ci        holding outer and inner tessellation levels of the patch, as used by
13385bd8deadSopenharmony_ci        the tessellation primitive generator.  If a tessellation control
13395bd8deadSopenharmony_ci        shader is active, the tessellation levels will be taken from the
13405bd8deadSopenharmony_ci        corresponding outputs of the tessellation control shader.  Otherwise,
13415bd8deadSopenharmony_ci        the default levels provided as patch parameters are used.
13425bd8deadSopenharmony_ci        Tessellation level values loaded in these variables will be prior to
13435bd8deadSopenharmony_ci        the clamping and rounding operations performed by the primitive
13445bd8deadSopenharmony_ci        generator as described in Section 2.X.2.  For triangular tessellation,
13455bd8deadSopenharmony_ci        gl_TessLevelOuter[3] and gl_TessLevelInner[1] will be undefined.  For
13465bd8deadSopenharmony_ci        isoline tessellation, gl_TessLevelOuter[2], gl_TessLevelOuter[3], and
13475bd8deadSopenharmony_ci        both values in gl_TessLevelInner[] are undefined.
13485bd8deadSopenharmony_ci
13495bd8deadSopenharmony_ci    A tessellation evaluation shader may also declare user-defined per-vertex
13505bd8deadSopenharmony_ci    input variables.  User-defined per-vertex input variables are declared
13515bd8deadSopenharmony_ci    with the qualifier "in" and have a value for each vertex in the input
13525bd8deadSopenharmony_ci    patch.  User-defined per-vertex input varying variables have a value for
13535bd8deadSopenharmony_ci    each vertex and thus need to be declared as arrays or inside input blocks
13545bd8deadSopenharmony_ci    declared as arrays.  Declaring an array size is optional.  If no size is
13555bd8deadSopenharmony_ci    specified, it will be taken from the implementation-dependent maximum
13565bd8deadSopenharmony_ci    patch size (gl_MaxPatchVertices).  If a size is specified, it must match
13575bd8deadSopenharmony_ci    the maximum patch size; otherwise, a compile or link error will occur.  Since the
13585bd8deadSopenharmony_ci    array size may be larger than the number of vertices found in the input
13595bd8deadSopenharmony_ci    patch, behavior is undefined if a per-vertex input variable is accessed
13605bd8deadSopenharmony_ci    using an index greater than or equal to the number of vertices in the
13615bd8deadSopenharmony_ci    input patch.  The OpenGL Shading Language doesn't support
13625bd8deadSopenharmony_ci    multi-dimensional arrays; therefore, user-defined tessellation evaluation
13635bd8deadSopenharmony_ci    shader inputs corresponding to vertex shader outputs declared as arrays
13645bd8deadSopenharmony_ci    must be declared as array members of an input block that is itself
13655bd8deadSopenharmony_ci    declared as an array.
13665bd8deadSopenharmony_ci
13675bd8deadSopenharmony_ci    Additionally, a tessellation evaluation shader may declare per-patch input
13685bd8deadSopenharmony_ci    variables using the qualifier "patch in".  Unlike per-vertex inputs,
13695bd8deadSopenharmony_ci    per-patch inputs do not correspond to any specific vertex in the patch,
13705bd8deadSopenharmony_ci    and are not indexed by vertex number.  Per-patch inputs declared as arrays
13715bd8deadSopenharmony_ci    have multiple values for the input patch; similarly declared per-vertex
13725bd8deadSopenharmony_ci    inputs would indicate a single value for each vertex in the output patch.
13735bd8deadSopenharmony_ci    User-defined per-patch input variables are filled with corresponding
13745bd8deadSopenharmony_ci    per-patch output values written by the tessellation control shader.  If no
13755bd8deadSopenharmony_ci    tessellation control shader is active, all such variables are undefined.
13765bd8deadSopenharmony_ci
13775bd8deadSopenharmony_ci    (Note:  minor restructuring in the following paragraph relative to the
13785bd8deadSopenharmony_ci    equivalent geometry shader language.)
13795bd8deadSopenharmony_ci
13805bd8deadSopenharmony_ci    Similarly to the limit on vertex shader output components (see section
13815bd8deadSopenharmony_ci    2.14.6), there is a limit on the number of components of built-in and
13825bd8deadSopenharmony_ci    user-defined per-vertex and per-patch input variables that can be read by
13835bd8deadSopenharmony_ci    the tessellation evaluation shader, given by the values of the
13845bd8deadSopenharmony_ci    implementation-dependent constants MAX_TESS_EVALUATION_INPUT_COMPONENTS
13855bd8deadSopenharmony_ci    and MAX_TESS_PATCH_COMPONENTS, respectively.  The built-in inputs
13865bd8deadSopenharmony_ci    gl_TessLevelOuter[] and gl_TessLevelInner[] are not counted against the
13875bd8deadSopenharmony_ci    per-patch limit.  When a program is linked, all components of any varying
13885bd8deadSopenharmony_ci    and special variable read by a tessellation evaluation shader will count
13895bd8deadSopenharmony_ci    against this limit.  A program whose tessellation evaluation shader
13905bd8deadSopenharmony_ci    exceeds this limit may fail to link, unless device-dependent optimizations
13915bd8deadSopenharmony_ci    are able to make the program fit within available hardware resources.
13925bd8deadSopenharmony_ci
13935bd8deadSopenharmony_ci
13945bd8deadSopenharmony_ci    Tessellation Evaluation Shader Outputs
13955bd8deadSopenharmony_ci
13965bd8deadSopenharmony_ci    Tessellation evaluation shaders have a number of built-in output variables
13975bd8deadSopenharmony_ci    used to pass values to equivalent built-in input variables read by
13985bd8deadSopenharmony_ci    subsequent shader stages or to subsequent fixed functionality vertex
13995bd8deadSopenharmony_ci    processing pipeline stages.  These variables are gl_Position,
14005bd8deadSopenharmony_ci    gl_PointSize, gl_ClipDistance[], gl_ClipVertex, gl_FrontColor,
14015bd8deadSopenharmony_ci    gl_BackColor, gl_FrontSecondaryColor, gl_BackSecondaryColor,
14025bd8deadSopenharmony_ci    gl_TexCoord[], and gl_FogFragCoord[], and all behave identically to
14035bd8deadSopenharmony_ci    equivalently named vertex shader outputs (section 2.14.7).  A tessellation
14045bd8deadSopenharmony_ci    evaluation shader may also declare user-defined per-vertex output
14055bd8deadSopenharmony_ci    variables.
14065bd8deadSopenharmony_ci
14075bd8deadSopenharmony_ci    (Note:  minor restructuring in the following paragraph relative to the
14085bd8deadSopenharmony_ci    equivalent geometry shader language.)
14095bd8deadSopenharmony_ci
14105bd8deadSopenharmony_ci    Similarly to the limit on vertex shader output components (see section
14115bd8deadSopenharmony_ci    2.14.6), there is a limit on the number of components of built-in and
14125bd8deadSopenharmony_ci    user-defined output variables that can be written by the tessellation
14135bd8deadSopenharmony_ci    evaluation shader, given by the values of the implementation-dependent
14145bd8deadSopenharmony_ci    constant MAX_TESS_EVALUATION_OUTPUT_COMPONENTS.  When a program is linked,
14155bd8deadSopenharmony_ci    all components of any varying and special variable written by a
14165bd8deadSopenharmony_ci    tessellation evaluation shader will count against this limit.  A program
14175bd8deadSopenharmony_ci    whose tessellation evaluation shader exceeds this limit may fail to link,
14185bd8deadSopenharmony_ci    unless device-dependent optimizations are able to make the program fit
14195bd8deadSopenharmony_ci    within available hardware resources.
14205bd8deadSopenharmony_ci
14215bd8deadSopenharmony_ci
14225bd8deadSopenharmony_ci    Modify Section 2.19, Transform Feedback, p. 130
14235bd8deadSopenharmony_ci
14245bd8deadSopenharmony_ci    (modify fourth paragraph, p. 131) When transform feedback is active, all
14255bd8deadSopenharmony_ci    geometric primitives generated must be compatible with the value of
14265bd8deadSopenharmony_ci    <primitiveMode> ...  If a tessellation evaluation or geometry shader is
14275bd8deadSopenharmony_ci    active, the type of primitive emitted by that shader is used instead of
14285bd8deadSopenharmony_ci    the <mode> parameter passed to drawing commands.  If tessellation
14295bd8deadSopenharmony_ci    evaluation and geometry shaders are both active, the output primitive type
14305bd8deadSopenharmony_ci    of the geometry shader will be used for the purposes of this error.
14315bd8deadSopenharmony_ci
14325bd8deadSopenharmony_ci
14335bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 3.2 (Compatibility Profile) Specification (Rasterization)
14345bd8deadSopenharmony_ci
14355bd8deadSopenharmony_ci    None.
14365bd8deadSopenharmony_ci
14375bd8deadSopenharmony_ci
14385bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 3.2 (Compatibility Profile) Specification (Per-Fragment
14395bd8deadSopenharmony_ciOperations and the Frame Buffer)
14405bd8deadSopenharmony_ci
14415bd8deadSopenharmony_ci    None.
14425bd8deadSopenharmony_ci
14435bd8deadSopenharmony_ci
14445bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 3.2 (Compatibility Profile) Specification (Special Functions)
14455bd8deadSopenharmony_ci
14465bd8deadSopenharmony_ci    None.
14475bd8deadSopenharmony_ci
14485bd8deadSopenharmony_ci
14495bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 3.2 (Compatibility Profile) Specification (State and State
14505bd8deadSopenharmony_ciRequests)
14515bd8deadSopenharmony_ci
14525bd8deadSopenharmony_ci    Modify Section 6.1.16, Shader and Program Queries, p. 384
14535bd8deadSopenharmony_ci
14545bd8deadSopenharmony_ci    (modify second paragraph, p. 385) If <pname> is SHADER TYPE, VERTEX
14555bd8deadSopenharmony_ci    SHADER, TESS_CONTROL_SHADER, TESS_EVALUATION_SHADER, GEOMETRY_SHADER, or
14565bd8deadSopenharmony_ci    FRAGMENT_SHADER is returned if <shader> is a vertex, tessellation control,
14575bd8deadSopenharmony_ci    tessellation evaluation, geometry, or fragment shader, respectively.  ...
14585bd8deadSopenharmony_ci
14595bd8deadSopenharmony_ci    (modify the next-to-last paragraph, p. 385) The command
14605bd8deadSopenharmony_ci
14615bd8deadSopenharmony_ci      void GetProgramiv(uint program, enum pname, int *params);
14625bd8deadSopenharmony_ci
14635bd8deadSopenharmony_ci    returns integer-valued properties of the program object...
14645bd8deadSopenharmony_ci
14655bd8deadSopenharmony_ci    (add two paragraphs after the first paragraph, p. 385) 
14665bd8deadSopenharmony_ci
14675bd8deadSopenharmony_ci    If <pname> is TESS_CONTROL_OUTPUT_VERTICES, the number of vertices in the
14685bd8deadSopenharmony_ci    tessellation control shader output patch is returned.  If
14695bd8deadSopenharmony_ci    TESS_CONTROL_OUTPUT_VERTICES is queried for a program which has not been
14705bd8deadSopenharmony_ci    linked successfully, or which does not contain objects to form a
14715bd8deadSopenharmony_ci    tessellation control shader, then an INVALID_OPERATION error is generated.
14725bd8deadSopenharmony_ci
14735bd8deadSopenharmony_ci    If <pname> is TESS_GEN_MODE, QUADS, TRIANGLES, or ISOLINES is returned,
14745bd8deadSopenharmony_ci    depending on the primitive mode declaration in the tessellation evaluation
14755bd8deadSopenharmony_ci    shader.  If <pname> is TESS_GEN_SPACING, EQUAL, FRACTIONAL_EVEN, or
14765bd8deadSopenharmony_ci    FRACTIONAL_ODD is returned, depending on the spacing declaration in the
14775bd8deadSopenharmony_ci    tessellation evaluation shader.  If <pname> is TESS_GEN_VERTEX_ORDER, CCW
14785bd8deadSopenharmony_ci    or CW is returned, depending on the vertex order declaration in the
14795bd8deadSopenharmony_ci    tessellation evaluation shader.  If <pname> is TESS_GEN_POINT_MODE, TRUE
14805bd8deadSopenharmony_ci    is returned if point mode is enabled in a tessellation evaluation shader
14815bd8deadSopenharmony_ci    declaration; FALSE is returned otherwise.  If any of the <pname> values in
14825bd8deadSopenharmony_ci    this paragraph are queried for a program which has not been linked
14835bd8deadSopenharmony_ci    successfully, or which does not contain objects to form a tessellation
14845bd8deadSopenharmony_ci    evaluation shader, then an INVALID_OPERATION error is generated.
14855bd8deadSopenharmony_ci
14865bd8deadSopenharmony_ci
14875bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 3.2 (Compatibility Profile) Specification (Invariance)
14885bd8deadSopenharmony_ci
14895bd8deadSopenharmony_ci    Insert new section before Section A.4, What this All Means (p. 457)
14905bd8deadSopenharmony_ci
14915bd8deadSopenharmony_ci    Section A.X, Tessellation Invariance
14925bd8deadSopenharmony_ci
14935bd8deadSopenharmony_ci    When using a program containing tessellation evaluation shaders, the
14945bd8deadSopenharmony_ci    fixed-function tessellation primitive generator consumes the input patch
14955bd8deadSopenharmony_ci    specified by an application and emits a new set of primitives.  The
14965bd8deadSopenharmony_ci    following invariance rules are intended to provide repeatability
14975bd8deadSopenharmony_ci    guarantees.  Additionally, they are intended to allow an application with
14985bd8deadSopenharmony_ci    a carefully crafted tessellation evaluation shader to ensure that the sets
14995bd8deadSopenharmony_ci    of triangles generated for two adjacent patches have identical vertices
15005bd8deadSopenharmony_ci    along shared patch edges, avoiding "cracks" caused by minor differences in
15015bd8deadSopenharmony_ci    the positions of vertices along shared edges.
15025bd8deadSopenharmony_ci
15035bd8deadSopenharmony_ci    Rule 1:  When processing two patches with identical outer and inner
15045bd8deadSopenharmony_ci    tessellation levels, the tessellation primitive generator will emit an
15055bd8deadSopenharmony_ci    identical set of point, line, or triangle primitives as long as the active
15065bd8deadSopenharmony_ci    program used to process the patch primitives has tessellation evaluation
15075bd8deadSopenharmony_ci    shaders specifying the same tessellation mode, spacing, vertex order, and
15085bd8deadSopenharmony_ci    point mode input layout qualifiers.  Two sets of primitives are considered
15095bd8deadSopenharmony_ci    identical if and only if they contain the same number and type of
15105bd8deadSopenharmony_ci    primitives and the generated tessellation coordinates for the vertex
15115bd8deadSopenharmony_ci    numbered <m> of the primitive numbered <n> are identical for all values of
15125bd8deadSopenharmony_ci    <m> and <n>.
15135bd8deadSopenharmony_ci
15145bd8deadSopenharmony_ci    Rule 2:  The set of vertices generated along the outer edge of the
15155bd8deadSopenharmony_ci    subdivided primitive in triangle and quad tessellation, and the
15165bd8deadSopenharmony_ci    tessellation coordinates of each, depends only on the corresponding outer
15175bd8deadSopenharmony_ci    tessellation level and the spacing input layout qualifier in the
15185bd8deadSopenharmony_ci    tessellation evaluation shader of the active program.
15195bd8deadSopenharmony_ci
15205bd8deadSopenharmony_ci    Rule 3:  The set of vertices generated when subdividing any outer
15215bd8deadSopenharmony_ci    primitive edge is always symmetric.  For triangle tessellation, if the
15225bd8deadSopenharmony_ci    subdivision generates a vertex with tessellation coordinates of the form
15235bd8deadSopenharmony_ci    (0,x,1-x), (x,0,1-x), or (x,1-x,0), it will also generate a vertex with
15245bd8deadSopenharmony_ci    coordinates of exactly (0,1-x,x), (1-x,0,x), or (1-x,x,0), respectively.
15255bd8deadSopenharmony_ci    For quad tessellation, if the subdivision generates a vertex with
15265bd8deadSopenharmony_ci    coordinates of (x,0) or (0,x), it will also generate a vertex with
15275bd8deadSopenharmony_ci    coordinates of exactly (1-x,0) or (0,1-x), respectively.  For isoline
15285bd8deadSopenharmony_ci    tessellation, if it generates vertices at (0,x) and (1,x) where <x> is
15295bd8deadSopenharmony_ci    not zero, it will also generate vertices at exactly (0,1-x) and (1,1-x),
15305bd8deadSopenharmony_ci    respectively.
15315bd8deadSopenharmony_ci
15325bd8deadSopenharmony_ci    Rule 4:  The set of vertices generated when subdividing outer edges in
15335bd8deadSopenharmony_ci    triangular and quad tessellation must be independent of the specific edge
15345bd8deadSopenharmony_ci    subdivided, given identical outer tessellation levels and spacing.  For
15355bd8deadSopenharmony_ci    example, if vertices at (x,1-x,0) and (1-x,x,0) are generated when
15365bd8deadSopenharmony_ci    subdividing the w==0 edge in triangular tessellation, vertices must be
15375bd8deadSopenharmony_ci    generated at (x,0,1-x) and (1-x,0,x) when subdividing an otherwise
15385bd8deadSopenharmony_ci    identical v==0 edge.  For quad tessellation, if vertices at (x,0) and
15395bd8deadSopenharmony_ci    (1-x,0) are generated when subdividing the v==0 edge, vertices must be
15405bd8deadSopenharmony_ci    generated at (0,x) and (0,1-x) when subdividing an otherwise identical
15415bd8deadSopenharmony_ci    u==0 edge.
15425bd8deadSopenharmony_ci
15435bd8deadSopenharmony_ci    Rule 5:  When processing two patches that are identical in all respects
15445bd8deadSopenharmony_ci    enumerated in rule 1 except for vertex order, the set of triangles
15455bd8deadSopenharmony_ci    generated for triangle and quad tessellation must be identical except for
15465bd8deadSopenharmony_ci    vertex and triangle order.  For each triangle <n1> produced by processing
15475bd8deadSopenharmony_ci    the first patch, there must be a triangle <n2> produced when processing
15485bd8deadSopenharmony_ci    the second patch each of whose vertices has the same tessellation
15495bd8deadSopenharmony_ci    coordinates as one of the vertices in <n1>.
15505bd8deadSopenharmony_ci
15515bd8deadSopenharmony_ci    Rule 6:  When processing two patches that are identical in all respects
15525bd8deadSopenharmony_ci    enumerated in rule 1 other than matching outer tessellation levels and/or
15535bd8deadSopenharmony_ci    vertex order, the set of interior triangles generated for triangle and
15545bd8deadSopenharmony_ci    quad tessellation must be identical in all respects except for vertex and
15555bd8deadSopenharmony_ci    triangle order.  For each interior triangle <n1> produced by processing
15565bd8deadSopenharmony_ci    the first patch, there must be a triangle <n2> produced when processing
15575bd8deadSopenharmony_ci    the second patch each of whose vertices has the same tessellation
15585bd8deadSopenharmony_ci    coordinates as one of the vertices in <n1>.  A triangle produced by the
15595bd8deadSopenharmony_ci    tessellator is considered an interior triangle if none of its vertices lie
15605bd8deadSopenharmony_ci    on an outer edge of the subdivided primitive.
15615bd8deadSopenharmony_ci
15625bd8deadSopenharmony_ci    Rule 7:  For quad and triangle tessellation, the set of triangles
15635bd8deadSopenharmony_ci    connecting an inner and outer edge depends only on the inner and outer
15645bd8deadSopenharmony_ci    tessellation levels corresponding to that edge and the spacing input
15655bd8deadSopenharmony_ci    layout qualifier.
15665bd8deadSopenharmony_ci
15675bd8deadSopenharmony_ci    Rule 8:  The value of all defined components of gl_TessCoord will be in
15685bd8deadSopenharmony_ci    the range [0,1].  Additionally, for any defined component <x> of
15695bd8deadSopenharmony_ci    gl_TessCoord, the results of computing (1.0-<x>) in a tessellation
15705bd8deadSopenharmony_ci    evaluation shader will be exact.  Some floating-point values in the range
15715bd8deadSopenharmony_ci    [0,1] may fail to satisfy this property, but such values may never be used
15725bd8deadSopenharmony_ci    as tessellation coordinate components.
15735bd8deadSopenharmony_ci
15745bd8deadSopenharmony_ci
15755bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
15765bd8deadSopenharmony_ci
15775bd8deadSopenharmony_ci    None.
15785bd8deadSopenharmony_ci
15795bd8deadSopenharmony_ci
15805bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language Specification, version 1.50 (Revision
15815bd8deadSopenharmony_ci09)
15825bd8deadSopenharmony_ci
15835bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
15845bd8deadSopenharmony_ci    language features described in this extension:
15855bd8deadSopenharmony_ci
15865bd8deadSopenharmony_ci      #extension GL_ARB_tessellation_shader : <behavior>
15875bd8deadSopenharmony_ci
15885bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.3.
15895bd8deadSopenharmony_ci
15905bd8deadSopenharmony_ci    A new preprocessor #define is added to the OpenGL Shading Language:
15915bd8deadSopenharmony_ci
15925bd8deadSopenharmony_ci      #define GL_ARB_tessellation_shader 1
15935bd8deadSopenharmony_ci
15945bd8deadSopenharmony_ci
15955bd8deadSopenharmony_ci    Modify Chapter 2, Overview of OpenGL Shading, p. 5
15965bd8deadSopenharmony_ci
15975bd8deadSopenharmony_ci    (modify first two introductory paragraphs)
15985bd8deadSopenharmony_ci
15995bd8deadSopenharmony_ci    The OpenGL Shading Language is actually several closely related languages.
16005bd8deadSopenharmony_ci    These languages are used to create shaders for the programmable processors
16015bd8deadSopenharmony_ci    contained in the OpenGL processing pipeline.  Currently, these processors
16025bd8deadSopenharmony_ci    are the vertex, tessellation control, tessellation evaluation, geometry,
16035bd8deadSopenharmony_ci    and fragment processors.
16045bd8deadSopenharmony_ci
16055bd8deadSopenharmony_ci    Unless otherwise noted in this paper, a language feature applies to all
16065bd8deadSopenharmony_ci    languages, and common usage will refer to these languages as a single
16075bd8deadSopenharmony_ci    language.  The specific languages will be referred to by the name of the
16085bd8deadSopenharmony_ci    processor they target:  vertex, tessellation control, tessellation
16095bd8deadSopenharmony_ci    evalution, geometry, or fragment.
16105bd8deadSopenharmony_ci
16115bd8deadSopenharmony_ci    (Insert two new sections after Section 2.1, Vertex Processor, p. 5.)
16125bd8deadSopenharmony_ci
16135bd8deadSopenharmony_ci
16145bd8deadSopenharmony_ci    Section 2.X, Tessellation Control Processor
16155bd8deadSopenharmony_ci
16165bd8deadSopenharmony_ci    The tessellation control processor is a programmable unit that operates on
16175bd8deadSopenharmony_ci    a patch of incoming vertices and their associated data, emitting a new
16185bd8deadSopenharmony_ci    output patch.  Compilation units written in the OpenGL Shading Language to
16195bd8deadSopenharmony_ci    run on this processor are called tessellation control shaders.  When a
16205bd8deadSopenharmony_ci    complete set of tessellation control shaders are compiled and linked, they
16215bd8deadSopenharmony_ci    result in a tessellation control shader executable that runs on the
16225bd8deadSopenharmony_ci    tessellation control processor.
16235bd8deadSopenharmony_ci
16245bd8deadSopenharmony_ci    The tessellation control processor spawns a separate shader invocation for
16255bd8deadSopenharmony_ci    each vertex of the output patch.  Each invocation can read the attributes
16265bd8deadSopenharmony_ci    of any vertex in the input or output patches, but can only write
16275bd8deadSopenharmony_ci    per-vertex attributes for the corresponding output patch vertex.  The
16285bd8deadSopenharmony_ci    shader invocations collectively produce a set of per-patch attributes for
16295bd8deadSopenharmony_ci    the output patch.  After all tessellation control shader invocations have
16305bd8deadSopenharmony_ci    completed, the output vertices and per-patch attributes are assembled to
16315bd8deadSopenharmony_ci    form a patch to be used by subsequent pipeline stages.
16325bd8deadSopenharmony_ci
16335bd8deadSopenharmony_ci    Tessellation control shader invocations run mostly independently, with
16345bd8deadSopenharmony_ci    undefined relative execution order.  However, the built-in function
16355bd8deadSopenharmony_ci    barrier() can be used to control execution order by synchronizing
16365bd8deadSopenharmony_ci    invocations, effectively dividing tessellation control shader execution
16375bd8deadSopenharmony_ci    into a set of phases.  Tessellation control shaders will get undefined
16385bd8deadSopenharmony_ci    results if one invocation reads a per-vertex or per-patch attribute
16395bd8deadSopenharmony_ci    written by another invocation at any point during the same phase, or if
16405bd8deadSopenharmony_ci    two invocations attempt to write different values to the same per-patch
16415bd8deadSopenharmony_ci    output in a single phase.
16425bd8deadSopenharmony_ci
16435bd8deadSopenharmony_ci
16445bd8deadSopenharmony_ci    Section 2.Y, Tessellation Evaluation Processor
16455bd8deadSopenharmony_ci
16465bd8deadSopenharmony_ci    The tessellation evaluation processor is a programmable unit that
16475bd8deadSopenharmony_ci    evaluates the position and other attributes of a vertex generated by the
16485bd8deadSopenharmony_ci    tessellation primitive generator, using a patch of incoming vertices and
16495bd8deadSopenharmony_ci    their associated data.  Compilation units written in the OpenGL Shading
16505bd8deadSopenharmony_ci    Language to run on this processor are called tessellation evaluation
16515bd8deadSopenharmony_ci    shaders.  When a complete set of tessellation evaluation shaders are
16525bd8deadSopenharmony_ci    compiled and linked, they result in a tessellation evaluation shader
16535bd8deadSopenharmony_ci    executable that runs on the tessellation evaluation processor.
16545bd8deadSopenharmony_ci
16555bd8deadSopenharmony_ci    The tessellation evaluation processor operates to compute the position and
16565bd8deadSopenharmony_ci    attributes of a single vertex generated by the tessellation primitive
16575bd8deadSopenharmony_ci    generator.  The executable can read the attributes of any vertex in the
16585bd8deadSopenharmony_ci    input patch, plus the tessellation coordinate, which is the relative
16595bd8deadSopenharmony_ci    location of the vertex in the primitive being tessellated.  The executable
16605bd8deadSopenharmony_ci    writes the position and other attributes of the vertex.
16615bd8deadSopenharmony_ci
16625bd8deadSopenharmony_ci
16635bd8deadSopenharmony_ci    Modify Section 3.6, Keywords, p. 14
16645bd8deadSopenharmony_ci
16655bd8deadSopenharmony_ci    (add the following to the keyword list)
16665bd8deadSopenharmony_ci
16675bd8deadSopenharmony_ci      patch
16685bd8deadSopenharmony_ci
16695bd8deadSopenharmony_ci
16705bd8deadSopenharmony_ci    Modify Section 4.2, Scoping, p. 27
16715bd8deadSopenharmony_ci
16725bd8deadSopenharmony_ci    (remove "(vertex, geometry, or fragment)" from the last paragraph of p. 28)
16735bd8deadSopenharmony_ci
16745bd8deadSopenharmony_ci
16755bd8deadSopenharmony_ci    Modify Section 4.3, Storage Qualifiers, p. 29
16765bd8deadSopenharmony_ci
16775bd8deadSopenharmony_ci    (add two new qualifiers to the first table, p. 29)
16785bd8deadSopenharmony_ci
16795bd8deadSopenharmony_ci    Qualifier   Meaning
16805bd8deadSopenharmony_ci    ---------   -------------------------------------------------------------
16815bd8deadSopenharmony_ci    patch in    linkage of per-patch attributes into a shader from a previous
16825bd8deadSopenharmony_ci                stage (tessellation evaluation shaders only)
16835bd8deadSopenharmony_ci
16845bd8deadSopenharmony_ci    patch out   linkage out of a shader to a subsequent stage (tessellation 
16855bd8deadSopenharmony_ci                control shaders only)
16865bd8deadSopenharmony_ci
16875bd8deadSopenharmony_ci
16885bd8deadSopenharmony_ci    Modify Section 4.3.4, Inputs, p. 31
16895bd8deadSopenharmony_ci
16905bd8deadSopenharmony_ci    (modify second paragraph, p. 31) Shader input variables are declared with
16915bd8deadSopenharmony_ci    the "in", "centroid in", or "patch in" storage qualifiers.  They form the
16925bd8deadSopenharmony_ci    input interface between previous stages of the OpenGL pipeline and the
16935bd8deadSopenharmony_ci    declaring shader.  ...
16945bd8deadSopenharmony_ci
16955bd8deadSopenharmony_ci    (modify third paragraph, p. 31) Vertex shader input variables (or
16965bd8deadSopenharmony_ci    attributes) ... It is an error to use "centroid in" or "patch in" in a
16975bd8deadSopenharmony_ci    vertex shader. ...
16985bd8deadSopenharmony_ci
16995bd8deadSopenharmony_ci    (modify next-to-last paragraph, p. 31, and subsequent paragraphs, making
17005bd8deadSopenharmony_ci    geometry shader language apply to tessellation control and evaluation
17015bd8deadSopenharmony_ci    shaders as well)
17025bd8deadSopenharmony_ci
17035bd8deadSopenharmony_ci    Tessellation control, evaluation, and geometry shader input variables get
17045bd8deadSopenharmony_ci    the per-vertex values written out to output variables of the same names in
17055bd8deadSopenharmony_ci    the previous active shader stage.  They are typically declared with the
17065bd8deadSopenharmony_ci    "in" or "centroid in" storage qualifier.  For these inputs, "centroid in"
17075bd8deadSopenharmony_ci    and interpolation qualifiers are allowed, but have no effect.  Since
17085bd8deadSopenharmony_ci    tessellation control, tessellation evaluation, and geometry shaders
17095bd8deadSopenharmony_ci    operate on a primitive comprising multiple vertices, each input varying
17105bd8deadSopenharmony_ci    variable (or input block, see interface blocks below) needs to be declared
17115bd8deadSopenharmony_ci    as an array. For example,
17125bd8deadSopenharmony_ci
17135bd8deadSopenharmony_ci      in float foo[]; // input for previous-stage output "out float foo"
17145bd8deadSopenharmony_ci
17155bd8deadSopenharmony_ci    Each element of such an array corresponds to one vertex of the primitive
17165bd8deadSopenharmony_ci    being processed. Each array can optionally have a size declared. The array
17175bd8deadSopenharmony_ci    size will be set by, (or if provided must be consistent with) the input
17185bd8deadSopenharmony_ci    layout declaration(s) establishing the type of input primitive, as
17195bd8deadSopenharmony_ci    described later in section 4.3.8.1 Input Layout Qualifiers.
17205bd8deadSopenharmony_ci
17215bd8deadSopenharmony_ci    For the interface from a previous shader stage to a tessellation control,
17225bd8deadSopenharmony_ci    tessellation evaluation, or geometry shader, output variables from the
17235bd8deadSopenharmony_ci    previous stage must match input variables of the same name in type and
17245bd8deadSopenharmony_ci    qualification, except perhaps that the inputs must be declared as an array
17255bd8deadSopenharmony_ci    indexed by vertex number.  If any variables fail to match, a link error
17265bd8deadSopenharmony_ci    will occur.
17275bd8deadSopenharmony_ci
17285bd8deadSopenharmony_ci    If the output of the previous shader is itself an array with multiple
17295bd8deadSopenharmony_ci    values per vertex, it must appear in an output block (see interface blocks
17305bd8deadSopenharmony_ci    below) in the previous shader and in an input block in the tessellation
17315bd8deadSopenharmony_ci    control, evaluation, or geometry shader with a block instance name
17325bd8deadSopenharmony_ci    declared as an array.  Use of blocks are required because two-dimensional
17335bd8deadSopenharmony_ci    arrays are not supported.
17345bd8deadSopenharmony_ci
17355bd8deadSopenharmony_ci    Additionally, tessellation evaluation shaders support per-patch input
17365bd8deadSopenharmony_ci    variables declared with the "patch in" qualifier.  Per-patch input
17375bd8deadSopenharmony_ci    variables are filled with the values of per-patch output variables written
17385bd8deadSopenharmony_ci    by the tessellation control shader.  Per-patch inputs may be declared as
17395bd8deadSopenharmony_ci    one-dimensional arrays, but are not indexed by vertex number.  Input
17405bd8deadSopenharmony_ci    variables may not be declared using the "patch in" qualifier in
17415bd8deadSopenharmony_ci    tessellation control or geometry shaders.  As with other input variables,
17425bd8deadSopenharmony_ci    per-patch inputs must be declared using the same type and qualifiers as
17435bd8deadSopenharmony_ci    per-patch outputs from the previous (tessellation control) shader stage.
17445bd8deadSopenharmony_ci
17455bd8deadSopenharmony_ci    (modify third paragraph, p. 32) Fragment shader ... deprecated "varying"
17465bd8deadSopenharmony_ci    and "centroid varying" modifiers.  It is an error to use "patch in" in a
17475bd8deadSopenharmony_ci    fragment shader. ...
17485bd8deadSopenharmony_ci
17495bd8deadSopenharmony_ci    (modify last paragraph of the section) The fragment shader inputs form an
17505bd8deadSopenharmony_ci    interface with the last active shader in the vertex processing pipeline.
17515bd8deadSopenharmony_ci    For this interface, the prior stage shader output variables and fragment
17525bd8deadSopenharmony_ci    shader input variables of the same name must match in type and
17535bd8deadSopenharmony_ci    qualification (other than out matching to in).
17545bd8deadSopenharmony_ci
17555bd8deadSopenharmony_ci
17565bd8deadSopenharmony_ci    Modify Section 4.3.6, Outputs, p. 33
17575bd8deadSopenharmony_ci
17585bd8deadSopenharmony_ci    (modify first paragraph of the section, p. 33) Shader output variables are
17595bd8deadSopenharmony_ci    declared with the "out", "centroid out", or "patch out" storage
17605bd8deadSopenharmony_ci    qualifiers. ...
17615bd8deadSopenharmony_ci
17625bd8deadSopenharmony_ci    (modify third paragraph of the section, p. 33) Vertex, tessellation
17635bd8deadSopenharmony_ci    evaluation, and geometry shader output variables output per-vertex data
17645bd8deadSopenharmony_ci    ...  deprecated varying storage qualifier.  It is an error to use "patch
17655bd8deadSopenharmony_ci    out" in a vertex, tessellation evaluation, or geometry shader. ...
17665bd8deadSopenharmony_ci
17675bd8deadSopenharmony_ci    (modify the fourth paragraph of the section, p. 33)  Individual vertex,
17685bd8deadSopenharmony_ci    tessellation evaluation, and geometry outputs are ...
17695bd8deadSopenharmony_ci
17705bd8deadSopenharmony_ci    (insert prior to the last paragraph, p. 33)
17715bd8deadSopenharmony_ci
17725bd8deadSopenharmony_ci    Tessellation control shader output variables may be used to output
17735bd8deadSopenharmony_ci    per-vertex and per-patch data.  Per-vertex output variables are declared
17745bd8deadSopenharmony_ci    using the "out" or "centroid out" storage qualifiers; per-patch output
17755bd8deadSopenharmony_ci    variables are declared using the "patch out" storage qualifier.
17765bd8deadSopenharmony_ci    Per-vertex and per-patch output variables can only be float,
17775bd8deadSopenharmony_ci    floating-point vectors, matrices, signed or unsigned integers or integer
17785bd8deadSopenharmony_ci    vectors, or arrays or structures of any these.  Since tessellation control
17795bd8deadSopenharmony_ci    shaders produce a primitive comprising multiple vertices, each per-vertex
17805bd8deadSopenharmony_ci    output variable (or output block, see interface blocks below) needs to be
17815bd8deadSopenharmony_ci    declared as an array. For example,
17825bd8deadSopenharmony_ci
17835bd8deadSopenharmony_ci      out float foo[]; // feeds next-stage input "in float foo[]"
17845bd8deadSopenharmony_ci
17855bd8deadSopenharmony_ci    Each element of such an array corresponds to one vertex of the primitive
17865bd8deadSopenharmony_ci    being produced.  Each array can optionally have a size declared.  The
17875bd8deadSopenharmony_ci    array size will be set by (or if provided must be consistent with) the
17885bd8deadSopenharmony_ci    output layout declaration(s) establishing the number of vertices in the
17895bd8deadSopenharmony_ci    output patch, as described later in section 4.3.8.2, Output Layout
17905bd8deadSopenharmony_ci    Qualifiers.
17915bd8deadSopenharmony_ci
17925bd8deadSopenharmony_ci    If a per-vertex output of the tessellation control shader is itself an
17935bd8deadSopenharmony_ci    array with multiple values per vertex, it must appear in an output block
17945bd8deadSopenharmony_ci    (see interface blocks below) in the tessellation control shader with a
17955bd8deadSopenharmony_ci    block instance name declared as an array.  Use of blocks are required
17965bd8deadSopenharmony_ci    because two-dimensional arrays are not supported.
17975bd8deadSopenharmony_ci
17985bd8deadSopenharmony_ci    Each tessellation control shader invocation has a corresponding output
17995bd8deadSopenharmony_ci    patch vertex, and may assign values to per-vertex outputs only if they
18005bd8deadSopenharmony_ci    belong to that corresponding vertex.  If a per-vertex output variable is
18015bd8deadSopenharmony_ci    used as an l-value, it is an error if the expression indicating the vertex
18025bd8deadSopenharmony_ci    number is not the identifier "gl_InvocationID".
18035bd8deadSopenharmony_ci
18045bd8deadSopenharmony_ci    The order of execution of a tessellation control shader invocation
18055bd8deadSopenharmony_ci    relative to the other invocations for the same input patch is undefined
18065bd8deadSopenharmony_ci    unless the built-in function barrier() is used.  This provides some
18075bd8deadSopenharmony_ci    control over relative execution order.  When a shader invocation calls the
18085bd8deadSopenharmony_ci    barrier() function, its execution pauses until all other invocations have
18095bd8deadSopenharmony_ci    called the same function.  Output variable assignments performed by any
18105bd8deadSopenharmony_ci    invocation executed prior to calling barrier() will be visible to any
18115bd8deadSopenharmony_ci    other invocation after the call to barrier() returns.
18125bd8deadSopenharmony_ci
18135bd8deadSopenharmony_ci    Because tessellation control shader invocations may execute in undefined
18145bd8deadSopenharmony_ci    order between barriers, the values of per-vertex or per-patch output
18155bd8deadSopenharmony_ci    variables will sometimes be undefined.  If the beginning and end of shader
18165bd8deadSopenharmony_ci    execution and each call to barrier() are considered synchronization
18175bd8deadSopenharmony_ci    points, the value of an output variable will be undefined in any of the
18185bd8deadSopenharmony_ci    three following cases:
18195bd8deadSopenharmony_ci
18205bd8deadSopenharmony_ci      (1) at the beginning of execution;
18215bd8deadSopenharmony_ci
18225bd8deadSopenharmony_ci      (2) at each synchronization point, unless:
18235bd8deadSopenharmony_ci
18245bd8deadSopenharmony_ci          * the value was well-defined after the previous synchronization
18255bd8deadSopenharmony_ci            point and was not written by any invocation since;
18265bd8deadSopenharmony_ci
18275bd8deadSopenharmony_ci          * the value was written by exactly one shader invocation since the
18285bd8deadSopenharmony_ci            previous synchronization point; or
18295bd8deadSopenharmony_ci
18305bd8deadSopenharmony_ci          * the value was written by multiple shader invocations since the
18315bd8deadSopenharmony_ci            previous synchronization point, and the last write performed by
18325bd8deadSopenharmony_ci            all such invocations wrote the same value; or
18335bd8deadSopenharmony_ci
18345bd8deadSopenharmony_ci      (3) when read by a shader invocation, if:
18355bd8deadSopenharmony_ci
18365bd8deadSopenharmony_ci          * the value was undefined at the previous synchronization point and
18375bd8deadSopenharmony_ci            has not been writen by the same shader invocation since; or
18385bd8deadSopenharmony_ci
18395bd8deadSopenharmony_ci          * the output variable is written to by any other shader invocation
18405bd8deadSopenharmony_ci            between the previous and next synchronization points, even if that
18415bd8deadSopenharmony_ci            assignment occurs in code following the read.
18425bd8deadSopenharmony_ci
18435bd8deadSopenharmony_ci    If the value of an output variable is undefined at the end of shader
18445bd8deadSopenharmony_ci    execution, the value passed to subsequent pipeline stages will be likewise
18455bd8deadSopenharmony_ci    undefined.
18465bd8deadSopenharmony_ci
18475bd8deadSopenharmony_ci
18485bd8deadSopenharmony_ci    (modify last paragraph, p. 33) Fragment outputs ... "out" storage
18495bd8deadSopenharmony_ci    qualifier.  It is an error to use "centroid out" or "patch out" in a
18505bd8deadSopenharmony_ci    fragment shader. ...
18515bd8deadSopenharmony_ci
18525bd8deadSopenharmony_ci
18535bd8deadSopenharmony_ci    Modify Section 4.3.8.1, Input Layout Qualifiers, p. 37
18545bd8deadSopenharmony_ci
18555bd8deadSopenharmony_ci    (modify first paragraph of the section) Vertex and tessellation control
18565bd8deadSopenharmony_ci    shaders do not have any input layout qualifiers.
18575bd8deadSopenharmony_ci
18585bd8deadSopenharmony_ci    (insert after first paragraph of the section)
18595bd8deadSopenharmony_ci    
18605bd8deadSopenharmony_ci    Tessellation evaluation shaders allow input layout qualifiers only on the
18615bd8deadSopenharmony_ci    interface qualifier in, not on an input block, block member, or variable
18625bd8deadSopenharmony_ci    declarations.  The input layout qualifier identifiers allowed for
18635bd8deadSopenharmony_ci    tessellation evaluation shaders are:
18645bd8deadSopenharmony_ci
18655bd8deadSopenharmony_ci      layout-qualifier-id
18665bd8deadSopenharmony_ci        triangles
18675bd8deadSopenharmony_ci        quads
18685bd8deadSopenharmony_ci        isolines
18695bd8deadSopenharmony_ci        equal_spacing
18705bd8deadSopenharmony_ci        fractional_even_spacing
18715bd8deadSopenharmony_ci        fractional_odd_spacing
18725bd8deadSopenharmony_ci        cw
18735bd8deadSopenharmony_ci        ccw
18745bd8deadSopenharmony_ci        point_mode
18755bd8deadSopenharmony_ci
18765bd8deadSopenharmony_ci    One group of identifiers is used to specify a tessellation primitive mode
18775bd8deadSopenharmony_ci    to be used by the tessellation primitive generator.  To specify a
18785bd8deadSopenharmony_ci    primitive mode, the identifier must be one of "triangles", "quads", or
18795bd8deadSopenharmony_ci    "isolines", which specify that the tessellation primitive generator should
18805bd8deadSopenharmony_ci    subdivide a triangle into smaller triangles, a quad into triangles, or a
18815bd8deadSopenharmony_ci    quad into a collection of lines, respectively.
18825bd8deadSopenharmony_ci
18835bd8deadSopenharmony_ci    A second group of identifiers is used to specify the vertex spacing used
18845bd8deadSopenharmony_ci    by the tessellation primitive generator when subdividing an edge.  To
18855bd8deadSopenharmony_ci    specify vertex spacing, the identifier must be one of:
18865bd8deadSopenharmony_ci
18875bd8deadSopenharmony_ci      * "equal_spacing", signifying that edges should be divided into a
18885bd8deadSopenharmony_ci         collection of <N> equal-sized segments;
18895bd8deadSopenharmony_ci
18905bd8deadSopenharmony_ci      * "fractional_even_spacing", signifying that edges should be divided
18915bd8deadSopenharmony_ci        into an even number of equal-length segments plus two additional
18925bd8deadSopenharmony_ci        shorter "fractional" segments; or
18935bd8deadSopenharmony_ci
18945bd8deadSopenharmony_ci      * "fractional_odd_spacing", signifying that edges should be divided into
18955bd8deadSopenharmony_ci        an odd number of equal-length segments plus two additional shorter
18965bd8deadSopenharmony_ci        "fractional" segments.
18975bd8deadSopenharmony_ci
18985bd8deadSopenharmony_ci    A third group of identifiers specifies whether the tessellation primitive
18995bd8deadSopenharmony_ci    generator produces triangles in clockwise or counter-clockwise order,
19005bd8deadSopenharmony_ci    according to the coordinate system depicted in the OpenGL specification.
19015bd8deadSopenharmony_ci    The identifiers "cw" and "ccw" indicate clockwise and counter-clockwise
19025bd8deadSopenharmony_ci    triangles, respectively.  If the tessellation primitive generator does not
19035bd8deadSopenharmony_ci    produce triangles, the order is ignored.
19045bd8deadSopenharmony_ci
19055bd8deadSopenharmony_ci    The identifier "point_mode" specifies that the tessellation primitive
19065bd8deadSopenharmony_ci    generator should produce one point for each distinct vertex in the
19075bd8deadSopenharmony_ci    subdivided primitive, rather than generating lines or triangles.
19085bd8deadSopenharmony_ci
19095bd8deadSopenharmony_ci    Any or all of these identifiers may be specified one or more times in a
19105bd8deadSopenharmony_ci    single input layout declaration.
19115bd8deadSopenharmony_ci
19125bd8deadSopenharmony_ci    At least one tessellation evaluation shader (compilation unit) in a
19135bd8deadSopenharmony_ci    program must declare a primitive mode in its input layout; declarations
19145bd8deadSopenharmony_ci    spacing, vertex order, and point mode qualifiers are optional.  It is not
19155bd8deadSopenharmony_ci    required that all tessellation evaluation shaders in a program declare a
19165bd8deadSopenharmony_ci    primitive mode.  If spacing or vertex order declarations are omitted, the
19175bd8deadSopenharmony_ci    tessellation primitive generator will use equal spacing or
19185bd8deadSopenharmony_ci    counter-clockwise vertex ordering, respectively.  If a point mode
19195bd8deadSopenharmony_ci    declaration is omitted, the tessellation primitive generator will produce
19205bd8deadSopenharmony_ci    lines or triangles according to the primitive mode.  If primitive mode,
19215bd8deadSopenharmony_ci    spacing, or vertex order is declared more than once in the tessellation
19225bd8deadSopenharmony_ci    evaluation shaders of a program, all such declarations must use the same
19235bd8deadSopenharmony_ci    identifier.
19245bd8deadSopenharmony_ci
19255bd8deadSopenharmony_ci    (modify third paragraph, p. 38)  All unsized tessellation control and
19265bd8deadSopenharmony_ci    evaluation shader input array declations will be sized to match the
19275bd8deadSopenharmony_ci    implementation-dependent maximum patch size (gl_MaxPatchVertices).  All
19285bd8deadSopenharmony_ci    unsized geometry shader input declarations ...
19295bd8deadSopenharmony_ci
19305bd8deadSopenharmony_ci    (modify fourth paragraph, p. 38) The intrinsically declared input array
19315bd8deadSopenharmony_ci    gl_in[] will also be sized according to the maximum patch size or a
19325bd8deadSopenharmony_ci    geometry shader input layout declaration.  Hence, the expression
19335bd8deadSopenharmony_ci
19345bd8deadSopenharmony_ci      gl_in.length()
19355bd8deadSopenharmony_ci
19365bd8deadSopenharmony_ci    will return the maximum patch size or a value from the table above.
19375bd8deadSopenharmony_ci
19385bd8deadSopenharmony_ci
19395bd8deadSopenharmony_ci    Modify Section 4.3.8.2, Output Layout Qualifiers, p. 40
19405bd8deadSopenharmony_ci
19415bd8deadSopenharmony_ci    (modify first paragraph, p. 40) Vertex, tessellation evaluation, and
19425bd8deadSopenharmony_ci    fragment shaders cannot have output layout qualifiers.
19435bd8deadSopenharmony_ci
19445bd8deadSopenharmony_ci    (insert after first paragraph of the section)
19455bd8deadSopenharmony_ci    
19465bd8deadSopenharmony_ci    Tessellation control shaders allow output layout qualifiers only on the
19475bd8deadSopenharmony_ci    interface qualifier out, not on an output block, block member, or variable
19485bd8deadSopenharmony_ci    declarations.  The output layout qualifier identifiers allowed for
19495bd8deadSopenharmony_ci    tessellation control shaders are:
19505bd8deadSopenharmony_ci
19515bd8deadSopenharmony_ci      layout-qualifier-id
19525bd8deadSopenharmony_ci        vertices = integer-constant
19535bd8deadSopenharmony_ci
19545bd8deadSopenharmony_ci    The identifier "vertices" specifies the number of vertices in the output
19555bd8deadSopenharmony_ci    patch produced by the tessellation control shader, which also specifies
19565bd8deadSopenharmony_ci    the number of times the tessellation control shader is invoked.  It is an
19575bd8deadSopenharmony_ci    error for the output vertex count to be less than or equal to zero, or
19585bd8deadSopenharmony_ci    greater than the implementation-dependent maximum patch size.
19595bd8deadSopenharmony_ci
19605bd8deadSopenharmony_ci    The intrinsically declared tessellation control output array gl_out[] will
19615bd8deadSopenharmony_ci    also be sized by any output layout declaration. Hence, the expression
19625bd8deadSopenharmony_ci
19635bd8deadSopenharmony_ci      gl_out.length()
19645bd8deadSopenharmony_ci
19655bd8deadSopenharmony_ci    will return the output patch vertex count specified in a previous output
19665bd8deadSopenharmony_ci    layout qualifier.  For outputs declared without an array size, including
19675bd8deadSopenharmony_ci    intrinsically declared outputs (i.e., gl_out), a layout must be declared
19685bd8deadSopenharmony_ci    before any use of the method length() or other array use that requires its
19695bd8deadSopenharmony_ci    size to be known.
19705bd8deadSopenharmony_ci
19715bd8deadSopenharmony_ci    It is a compile-time error if the output patch vertex count specified in
19725bd8deadSopenharmony_ci    an output layout qualifier does not match the array size specified in any
19735bd8deadSopenharmony_ci    output variable declaration in the same shader.
19745bd8deadSopenharmony_ci
19755bd8deadSopenharmony_ci    All tessellation control shader layout declarations in a program must
19765bd8deadSopenharmony_ci    specify the same output patch vertex count.  There must be at least one
19775bd8deadSopenharmony_ci    layout qualifier specifying an output patch vertex count in any program
19785bd8deadSopenharmony_ci    containing tessellation control shaders; however, such a declaration is
19795bd8deadSopenharmony_ci    not required in all tessellation control shader compilation units.
19805bd8deadSopenharmony_ci    
19815bd8deadSopenharmony_ci
19825bd8deadSopenharmony_ci    (Coalesce Sections 7.1., 7.2, and 7.6 into a single section, as described
19835bd8deadSopenharmony_ci     below.)
19845bd8deadSopenharmony_ci
19855bd8deadSopenharmony_ci    Section 7.1, Built-In Shader Special Inputs and Outputs
19865bd8deadSopenharmony_ci
19875bd8deadSopenharmony_ci    Some OpenGL operations occur in fixed functionality and need to provide
19885bd8deadSopenharmony_ci    values to or receive values from shader executables.  Shaders communicate
19895bd8deadSopenharmony_ci    with fixed-function OpenGL pipeline stages, and optionally with other
19905bd8deadSopenharmony_ci    shaders, through the use of built-in input and output variables.
19915bd8deadSopenharmony_ci
19925bd8deadSopenharmony_ci
19935bd8deadSopenharmony_ci    In the vertex language, built-in input and output variables are
19945bd8deadSopenharmony_ci    intrinsically declared as:
19955bd8deadSopenharmony_ci
19965bd8deadSopenharmony_ci      in int gl_VertexID;
19975bd8deadSopenharmony_ci      in int gl_InstanceID;
19985bd8deadSopenharmony_ci
19995bd8deadSopenharmony_ci      out gl_PerVertex {
20005bd8deadSopenharmony_ci        vec4 gl_Position;
20015bd8deadSopenharmony_ci        float gl_PointSize;
20025bd8deadSopenharmony_ci        float gl_ClipDistance[];
20035bd8deadSopenharmony_ci      };
20045bd8deadSopenharmony_ci
20055bd8deadSopenharmony_ci    The variable gl_VertexID is a vertex shader input variable that holds an
20065bd8deadSopenharmony_ci    integer index for the vertex, as defined under Shader Inputs in section
20075bd8deadSopenharmony_ci    2.11.7 in the OpenGL Graphics System Specification. While the variable
20085bd8deadSopenharmony_ci    gl_VertexID is always present, its value is not always defined.
20095bd8deadSopenharmony_ci
20105bd8deadSopenharmony_ci    The variable gl_InstanceID is a vertex shader input variable that holds
20115bd8deadSopenharmony_ci    the integer index of the current primitive in an instanced draw call (see
20125bd8deadSopenharmony_ci    Shader Inputs in section 2.11.7 in the OpenGL Graphics System
20135bd8deadSopenharmony_ci    Specification). If the current primitive does not come from an instanced
20145bd8deadSopenharmony_ci    draw call, the value of gl_InstanceID is zero.
20155bd8deadSopenharmony_ci
20165bd8deadSopenharmony_ci    The variable gl_Position is intended for writing the homogeneous vertex
20175bd8deadSopenharmony_ci    position. It can be written at any time during shader execution. This
20185bd8deadSopenharmony_ci    value will be used by primitive assembly, clipping, culling, and other
20195bd8deadSopenharmony_ci    fixed functionality operations, if present, that operate on primitives
20205bd8deadSopenharmony_ci    after vertex processing has occurred.  Its value is undefined after the
20215bd8deadSopenharmony_ci    vertex processing stage if the vertex shader executable does not write
20225bd8deadSopenharmony_ci    gl_Position, and it is undefined after geometry processing if the geometry
20235bd8deadSopenharmony_ci    executable calls EmitVertex() without having written gl_Position since the
20245bd8deadSopenharmony_ci    last EmitVertex() (or hasn't written it at all).
20255bd8deadSopenharmony_ci
20265bd8deadSopenharmony_ci    The variable gl_PointSize is intended for a shader to write the size of
20275bd8deadSopenharmony_ci    the point to be rasterized. It is measured in pixels. If gl_PointSize is
20285bd8deadSopenharmony_ci    not written to, its value is undefined in subsequent pipe stages.
20295bd8deadSopenharmony_ci
20305bd8deadSopenharmony_ci    (note:  Changed the wording of this a bit from 1.50, to remove the mention
20315bd8deadSopenharmony_ci     of maintaining clip planes and computing distances, which isn't required
20325bd8deadSopenharmony_ci     to use the feature.  Also tweaked a reference to gl_MaxVaryingComponents
20335bd8deadSopenharmony_ci     in the following paragraph.)
20345bd8deadSopenharmony_ci
20355bd8deadSopenharmony_ci    The variable gl_ClipDistance provides the forward compatible mechanism for
20365bd8deadSopenharmony_ci    controlling user clipping.  gl_ClipDistance[i] specifies a clip distance
20375bd8deadSopenharmony_ci    for each plane i. A distance of 0 means the vertex is on the plane, a
20385bd8deadSopenharmony_ci    positive distance means the vertex is inside the clip plane, and a
20395bd8deadSopenharmony_ci    negative distance means the point is outside the clip plane. The clip
20405bd8deadSopenharmony_ci    distances will be linearly interpolated across the primitive and the
20415bd8deadSopenharmony_ci    portion of the primitive with interpolated distances less than 0 will be
20425bd8deadSopenharmony_ci    clipped.
20435bd8deadSopenharmony_ci
20445bd8deadSopenharmony_ci    The gl_ClipDistance array is predeclared as unsized and must be sized by
20455bd8deadSopenharmony_ci    the shader either redeclaring it with a size or indexing it only with
20465bd8deadSopenharmony_ci    integral constant expressions. This needs to size the array to include all
20475bd8deadSopenharmony_ci    the clip planes that are enabled via the OpenGL API; if the size does not
20485bd8deadSopenharmony_ci    include all enabled planes, results are undefined. The size can be at most
20495bd8deadSopenharmony_ci    gl_MaxClipDistances. The number of input or output components consumed by
20505bd8deadSopenharmony_ci    gl_ClipDistance will match the size of the array, no matter how many
20515bd8deadSopenharmony_ci    planes are enabled. The shader must also set all values in gl_ClipDistance
20525bd8deadSopenharmony_ci    that have been enabled via the OpenGL API, or results are
20535bd8deadSopenharmony_ci    undefined. Values written into gl_ClipDistance for planes that are not
20545bd8deadSopenharmony_ci    enabled have no effect.
20555bd8deadSopenharmony_ci
20565bd8deadSopenharmony_ci
20575bd8deadSopenharmony_ci    In the tessellation control language, built-in input and output variables
20585bd8deadSopenharmony_ci    are intrinsically declared as:
20595bd8deadSopenharmony_ci
20605bd8deadSopenharmony_ci      in gl_PerVertex {
20615bd8deadSopenharmony_ci        vec4 gl_Position;
20625bd8deadSopenharmony_ci        float gl_PointSize;
20635bd8deadSopenharmony_ci        float gl_ClipDistance[];
20645bd8deadSopenharmony_ci      } gl_in[gl_MaxPatchVertices];
20655bd8deadSopenharmony_ci      in int gl_PatchVerticesIn;
20665bd8deadSopenharmony_ci      in int gl_PrimitiveID;
20675bd8deadSopenharmony_ci      in int gl_InvocationID;
20685bd8deadSopenharmony_ci
20695bd8deadSopenharmony_ci      out gl_PerVertex {
20705bd8deadSopenharmony_ci        vec4 gl_Position;
20715bd8deadSopenharmony_ci        float gl_PointSize;
20725bd8deadSopenharmony_ci        float gl_ClipDistance[];
20735bd8deadSopenharmony_ci      } gl_out[gl_VerticesOut];
20745bd8deadSopenharmony_ci
20755bd8deadSopenharmony_ci      patch out float gl_TessLevelOuter[4];
20765bd8deadSopenharmony_ci      patch out float gl_TessLevelInner[2];
20775bd8deadSopenharmony_ci
20785bd8deadSopenharmony_ci    The input variables gl_Position, gl_PointSize, and gl_ClipDistance read
20795bd8deadSopenharmony_ci    corresponding outputs written by the vertex shader.  The output variables
20805bd8deadSopenharmony_ci    of the same names behave as described for the identical vertex shader
20815bd8deadSopenharmony_ci    outputs.
20825bd8deadSopenharmony_ci
20835bd8deadSopenharmony_ci    The variable gl_PatchVerticesIn is available only in the tessellation
20845bd8deadSopenharmony_ci    control and evaluation languages.  It is an integer specifying the number
20855bd8deadSopenharmony_ci    of vertices in the input patch being processed by the shader.  A single
20865bd8deadSopenharmony_ci    tessellation control or evaluation shader can read patches of differening
20875bd8deadSopenharmony_ci    sizes, so the value of gl_PatchVerticesIn may differ between patches.
20885bd8deadSopenharmony_ci
20895bd8deadSopenharmony_ci    The input variable gl_PrimitiveID is available only in the tessellation
20905bd8deadSopenharmony_ci    control, tessellation evaluation, and fragment languages.  For
20915bd8deadSopenharmony_ci    tessellation control and evaluation shaders, it is filled with the number
20925bd8deadSopenharmony_ci    of primitives processed by the shader since the current set of rendering
20935bd8deadSopenharmony_ci    primitives was started.  For fragment shaders, it is filled with the value
20945bd8deadSopenharmony_ci    written to the gl_PrimitiveID geometry shader output if a geometry shader
20955bd8deadSopenharmony_ci    is present.  Otherwise, it is assigned in the same manner as with
20965bd8deadSopenharmony_ci    tessellation control and evaluation shaders.
20975bd8deadSopenharmony_ci
20985bd8deadSopenharmony_ci    The input variable gl_InvocationID is available only in the tessellation
20995bd8deadSopenharmony_ci    control and geometry language.  In the tessellation control shader, it
21005bd8deadSopenharmony_ci    identifies the number of the output patch vertex assigned to the
21015bd8deadSopenharmony_ci    tessellation control shader invocation.  In the geometry shader, it
21025bd8deadSopenharmony_ci    identifies the invocation number assigned to the geometry shader
21035bd8deadSopenharmony_ci    invocation.  In both cases, gl_InvocationID is assigned integer values in
21045bd8deadSopenharmony_ci    the range [0, <N>-1], where <N> is the number of output patch vertices or
21055bd8deadSopenharmony_ci    geometry shader invocations per primitive.
21065bd8deadSopenharmony_ci
21075bd8deadSopenharmony_ci    The output variables gl_TessLevelOuter[] and gl_TessLevelInner[] are
21085bd8deadSopenharmony_ci    available only in the tessellation control language.  The values written
21095bd8deadSopenharmony_ci    to these variables are assigned to the corresponding outer and inner
21105bd8deadSopenharmony_ci    tessellation levels of the output patch.  They are used by the
21115bd8deadSopenharmony_ci    tessellation primitive generator to control primitive tessellation and may
21125bd8deadSopenharmony_ci    be read by tessellation evaluation shaders.
21135bd8deadSopenharmony_ci
21145bd8deadSopenharmony_ci
21155bd8deadSopenharmony_ci    In the tessellation evaluation language, built-in input and output
21165bd8deadSopenharmony_ci    variables are intrinsically declared as:
21175bd8deadSopenharmony_ci
21185bd8deadSopenharmony_ci      in gl_PerVertex {
21195bd8deadSopenharmony_ci        vec4 gl_Position;
21205bd8deadSopenharmony_ci        float gl_PointSize;
21215bd8deadSopenharmony_ci        float gl_ClipDistance[];
21225bd8deadSopenharmony_ci      } gl_in[gl_MaxPatchVertices];
21235bd8deadSopenharmony_ci      in int gl_PatchVerticesIn;
21245bd8deadSopenharmony_ci      in int gl_PrimitiveID;
21255bd8deadSopenharmony_ci      in vec3 gl_TessCoord;
21265bd8deadSopenharmony_ci      patch in float gl_TessLevelOuter[4];
21275bd8deadSopenharmony_ci      patch in float gl_TessLevelInner[2];
21285bd8deadSopenharmony_ci
21295bd8deadSopenharmony_ci      out gl_PerVertex {
21305bd8deadSopenharmony_ci        vec4 gl_Position;
21315bd8deadSopenharmony_ci        float gl_PointSize;
21325bd8deadSopenharmony_ci        float gl_ClipDistance[];
21335bd8deadSopenharmony_ci      };
21345bd8deadSopenharmony_ci
21355bd8deadSopenharmony_ci    The input variables gl_Position, gl_PointSize, gl_ClipDistance read
21365bd8deadSopenharmony_ci    corresponding outputs written by the previous shader (vertex or
21375bd8deadSopenharmony_ci    tessellation control).  The output variables of the same names behave as
21385bd8deadSopenharmony_ci    described for the identical vertex shader outputs.
21395bd8deadSopenharmony_ci
21405bd8deadSopenharmony_ci    The input variables gl_PatchVerticesIn and gl_PrimitiveID behave as in the
21415bd8deadSopenharmony_ci    identically-named tessellation control shader inputs.
21425bd8deadSopenharmony_ci
21435bd8deadSopenharmony_ci    The variable gl_TessCoord is available only in the tessellation evaluation
21445bd8deadSopenharmony_ci    language.  It specifies a three-component (u,v,w) vector identifying the
21455bd8deadSopenharmony_ci    position of the vertex being processed by the shader relative to the
21465bd8deadSopenharmony_ci    primitive being tessellated.
21475bd8deadSopenharmony_ci
21485bd8deadSopenharmony_ci    The input variables gl_TessLevelOuter[] and gl_TessLevelInner[] are
21495bd8deadSopenharmony_ci    available only in the tessellation evaluation shader.  If a tessellation
21505bd8deadSopenharmony_ci    control shader is active, these variables are filled with corresponding
21515bd8deadSopenharmony_ci    outputs written by the tessellation control shader.  Otherwise, they are
21525bd8deadSopenharmony_ci    assigned with default tessellation levels specified in the OpenGL API.
21535bd8deadSopenharmony_ci
21545bd8deadSopenharmony_ci
21555bd8deadSopenharmony_ci    In the geometry language, built-in input and output variables are
21565bd8deadSopenharmony_ci    intrinsically declared as:
21575bd8deadSopenharmony_ci
21585bd8deadSopenharmony_ci      in gl_PerVertex {
21595bd8deadSopenharmony_ci        vec4 gl_Position;
21605bd8deadSopenharmony_ci        float gl_PointSize;
21615bd8deadSopenharmony_ci        float gl_ClipDistance[];
21625bd8deadSopenharmony_ci      } gl_in[];
21635bd8deadSopenharmony_ci      in int gl_PrimitiveIDIn;
21645bd8deadSopenharmony_ci
21655bd8deadSopenharmony_ci      out gl_PerVertex {
21665bd8deadSopenharmony_ci        vec4 gl_Position;
21675bd8deadSopenharmony_ci        float gl_PointSize;
21685bd8deadSopenharmony_ci        float gl_ClipDistance[];
21695bd8deadSopenharmony_ci      };
21705bd8deadSopenharmony_ci      out int gl_PrimitiveID;
21715bd8deadSopenharmony_ci      out int gl_Layer;
21725bd8deadSopenharmony_ci
21735bd8deadSopenharmony_ci    The input variables gl_Position, gl_PointSize, gl_ClipDistance read
21745bd8deadSopenharmony_ci    corresponding outputs written by the previous shader (vertex or
21755bd8deadSopenharmony_ci    tessellation control).  The output variables of the same names behave as
21765bd8deadSopenharmony_ci    described for the identical vertex shader outputs.
21775bd8deadSopenharmony_ci
21785bd8deadSopenharmony_ci    The input variable gl_PrimitiveIDIn behaves identically to the
21795bd8deadSopenharmony_ci    tessellation control and evaluation shader input variable gl_PrimitiveID.
21805bd8deadSopenharmony_ci
21815bd8deadSopenharmony_ci    The output variable gl_PrimitiveID is available only in the geometry
21825bd8deadSopenharmony_ci    language and provides a single integer that serves as a primitive
21835bd8deadSopenharmony_ci    identifier. This is then available to fragment shaders as the fragment
21845bd8deadSopenharmony_ci    input gl_PrimitiveID, which will select the written primitive ID from the
21855bd8deadSopenharmony_ci    provoking vertex in the primitive being shaded. If a fragment shader using
21865bd8deadSopenharmony_ci    gl_PrimitiveID is active and a geometry shader is also active, the
21875bd8deadSopenharmony_ci    geometry shader must write to gl_PrimitiveID or the fragment shader input
21885bd8deadSopenharmony_ci    gl_PrimitiveID is undefined. See section 2.12.4 (under Geometry Shader
21895bd8deadSopenharmony_ci    Outputs) and section 3.9.2 (under Shader Inputs) of the OpenGL Graphics
21905bd8deadSopenharmony_ci    System Specification for more information.
21915bd8deadSopenharmony_ci
21925bd8deadSopenharmony_ci    The output variable gl_Layer is available only in the geometry language,
21935bd8deadSopenharmony_ci    and is used to select a specific layer of a multi-layer framebuffer
21945bd8deadSopenharmony_ci    attachment. The actual layer used will come from one of vertices in the
21955bd8deadSopenharmony_ci    primitive being shaded. Which vertex the layer comes from is undefined, so
21965bd8deadSopenharmony_ci    it is best to write the same layer value for all vertices of a
21975bd8deadSopenharmony_ci    primitive. If a shader statically assigns a value to gl_Layer, layered
21985bd8deadSopenharmony_ci    rendering mode is enabled. See section 2.12.4 (under Geometry Shader
21995bd8deadSopenharmony_ci    Outputs) and section 4.4.7 Layered Framebuffers of the OpenGL Graphics
22005bd8deadSopenharmony_ci    System Specification for more information. If a shader statically assigns
22015bd8deadSopenharmony_ci    a value to gl_Layer, and there is an execution path through the shader
22025bd8deadSopenharmony_ci    that does not set gl_Layer, then the value of gl_Layer is undefined for
22035bd8deadSopenharmony_ci    executions of the shader that take that path.
22045bd8deadSopenharmony_ci
22055bd8deadSopenharmony_ci
22065bd8deadSopenharmony_ci    In the fragment language, built-in input and output variables are
22075bd8deadSopenharmony_ci    intrinsically declared as:
22085bd8deadSopenharmony_ci
22095bd8deadSopenharmony_ci      in vec4 gl_FragCoord;
22105bd8deadSopenharmony_ci      in bool gl_FrontFacing;
22115bd8deadSopenharmony_ci      in float gl_ClipDistance[];
22125bd8deadSopenharmony_ci      in vec2 gl_PointCoord;
22135bd8deadSopenharmony_ci      in int gl_PrimitiveID;
22145bd8deadSopenharmony_ci
22155bd8deadSopenharmony_ci      out vec4 gl_FragColor;                    // deprecated
22165bd8deadSopenharmony_ci      out vec4 gl_FragData[gl_MaxDrawBuffers];  // deprecated
22175bd8deadSopenharmony_ci      out float gl_FragDepth;
22185bd8deadSopenharmony_ci
22195bd8deadSopenharmony_ci    (copy the variable descriptions verbatim from Section 7.2)
22205bd8deadSopenharmony_ci
22215bd8deadSopenharmony_ci
22225bd8deadSopenharmony_ci    Section 7.1.1, Compatibility Profile Built-In Shader Special Variables
22235bd8deadSopenharmony_ci
22245bd8deadSopenharmony_ci    When using the compatibility profile, the GL can provide fixed
22255bd8deadSopenharmony_ci    functionality behavior for the vertex and fragment programmable pipeline
22265bd8deadSopenharmony_ci    stages. For example, mixing a fixed functionality vertex stage with a
22275bd8deadSopenharmony_ci    programmable fragment stage.
22285bd8deadSopenharmony_ci
22295bd8deadSopenharmony_ci    The following built-in vertex, tessellation control, tessellation
22305bd8deadSopenharmony_ci    evaluation, and geometry output variables are available to specify inputs
22315bd8deadSopenharmony_ci    for the subsequent programmable shader stage or the fixed functionality
22325bd8deadSopenharmony_ci    fragment stage.  A particular one should be written to if any
22335bd8deadSopenharmony_ci    functionality in a corresponding shader or fixed pipeline uses it or state
22345bd8deadSopenharmony_ci    derived from it.  Otherwise, behavior is undefined.  The following members
22355bd8deadSopenharmony_ci    are added to the output gl_PerVertex block in these languages:
22365bd8deadSopenharmony_ci
22375bd8deadSopenharmony_ci      out gl_PerVertex {
22385bd8deadSopenharmony_ci        // in addition to other gl_PerVertex members...
22395bd8deadSopenharmony_ci        vec4 gl_ClipVertex;
22405bd8deadSopenharmony_ci        vec4 gl_FrontColor;
22415bd8deadSopenharmony_ci        vec4 gl_BackColor;
22425bd8deadSopenharmony_ci        vec4 gl_FrontSecondaryColor;
22435bd8deadSopenharmony_ci        vec4 gl_BackSecondaryColor;
22445bd8deadSopenharmony_ci        vec4 gl_TexCoord[];
22455bd8deadSopenharmony_ci        float gl_FogFragCoord;
22465bd8deadSopenharmony_ci      };
22475bd8deadSopenharmony_ci
22485bd8deadSopenharmony_ci    The variable gl_ClipVertex provides a place for vertex and geometry
22495bd8deadSopenharmony_ci    shaders to write the coordinate to be used with the user clipping planes.
22505bd8deadSopenharmony_ci    
22515bd8deadSopenharmony_ci    The user must ensure the clip vertex and user clipping planes are defined
22525bd8deadSopenharmony_ci    in the same coordinate space.  User clip planes work properly only under
22535bd8deadSopenharmony_ci    linear transform. It is undefined what happens under nonlinear transform.
22545bd8deadSopenharmony_ci
22555bd8deadSopenharmony_ci    If a linked set of shaders forming a program contains no static write to
22565bd8deadSopenharmony_ci    gl_ClipVertex or gl_ClipDistance, but the application has requested
22575bd8deadSopenharmony_ci    clipping against user clip planes through the API, then the coordinate
22585bd8deadSopenharmony_ci    written to gl_Position is used for comparison against the user clip
22595bd8deadSopenharmony_ci    planes.  Writing to gl_ClipDistance is the preferred method for user
22605bd8deadSopenharmony_ci    clipping. It is an error for the set of shaders forming a program to
22615bd8deadSopenharmony_ci    statically read or write both gl_ClipVertex and gl_ClipDistance.
22625bd8deadSopenharmony_ci
22635bd8deadSopenharmony_ci    gl_FrontColor, glFrontSecondaryColor, gl_BackColor, and
22645bd8deadSopenharmony_ci    glBackSecondaryColor assigns primary and secondary colors for front and
22655bd8deadSopenharmony_ci    back faces of primitives containing the vertex being processed.
22665bd8deadSopenharmony_ci    gl_TexCoord assigns texture coordinates for the vertex being processed.
22675bd8deadSopenharmony_ci
22685bd8deadSopenharmony_ci    For gl_FogFragCoord, the value written will be used as the "c" value in
22695bd8deadSopenharmony_ci    section 3.11 of the OpenGL Graphics System Specification, by the fixed
22705bd8deadSopenharmony_ci    functionality pipeline. For example, if the z-coordinate of the fragment
22715bd8deadSopenharmony_ci    in eye space is desired as "c", then that's what the vertex shader
22725bd8deadSopenharmony_ci    executable should write into gl_FogFragCoord.
22735bd8deadSopenharmony_ci
22745bd8deadSopenharmony_ci    As with all arrays, indices used to subscript gl_TexCoord must either be
22755bd8deadSopenharmony_ci    an integral constant expressions, or this array must be re-declared by the
22765bd8deadSopenharmony_ci    shader with a size. The size can be at most gl_MaxTextureCoords. Using
22775bd8deadSopenharmony_ci    indexes close to 0 may aid the implementation in preserving varying
22785bd8deadSopenharmony_ci    resources.
22795bd8deadSopenharmony_ci
22805bd8deadSopenharmony_ci    In the tessellation control, evaluation, and geometry shaders, the outputs
22815bd8deadSopenharmony_ci    of the previous stage described above are also available in the input
22825bd8deadSopenharmony_ci    gl_PerVertex block in these languages.
22835bd8deadSopenharmony_ci
22845bd8deadSopenharmony_ci      in gl_PerVertex {
22855bd8deadSopenharmony_ci        // in addition to other gl_PerVertex members...
22865bd8deadSopenharmony_ci        vec4 gl_ClipVertex;
22875bd8deadSopenharmony_ci        vec4 gl_FrontColor;
22885bd8deadSopenharmony_ci        vec4 gl_BackColor;
22895bd8deadSopenharmony_ci        vec4 gl_FrontSecondaryColor;
22905bd8deadSopenharmony_ci        vec4 gl_BackSecondaryColor;
22915bd8deadSopenharmony_ci        vec4 gl_TexCoord[];
22925bd8deadSopenharmony_ci        float gl_FogFragCoord;
22935bd8deadSopenharmony_ci      } gl_in[];
22945bd8deadSopenharmony_ci
22955bd8deadSopenharmony_ci    The following fragment inputs are also available in a fragment shader when
22965bd8deadSopenharmony_ci    using the compatibility profile:
22975bd8deadSopenharmony_ci
22985bd8deadSopenharmony_ci      in vec4 gl_Color;
22995bd8deadSopenharmony_ci      in vec4 gl_SecondaryColor;
23005bd8deadSopenharmony_ci      in vec4 gl_TexCoord[];
23015bd8deadSopenharmony_ci      in float gl_FogFragCoord;
23025bd8deadSopenharmony_ci
23035bd8deadSopenharmony_ci    The values in gl_Color and gl_SecondaryColor will be derived automatically
23045bd8deadSopenharmony_ci    by the system from gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor,
23055bd8deadSopenharmony_ci    and gl_BackSecondaryColor based on which face is visible in the primitive
23065bd8deadSopenharmony_ci    producing the fragment.  If fixed functionality is used for vertex
23075bd8deadSopenharmony_ci    processing, then gl_FogFragCoord will either be the z-coordinate of the
23085bd8deadSopenharmony_ci    fragment in eye space, or the interpolation of the fog coordinate, as
23095bd8deadSopenharmony_ci    described in section 3.11 of the OpenGL Graphics System Specification. The
23105bd8deadSopenharmony_ci    gl_TexCoord[] values are the interpolated gl_TexCoord[] values from a
23115bd8deadSopenharmony_ci    vertex shader or the texture coordinates of any fixed pipeline based
23125bd8deadSopenharmony_ci    vertex functionality.
23135bd8deadSopenharmony_ci
23145bd8deadSopenharmony_ci    Indices to the fragment shader gl_TexCoord array are as described above in
23155bd8deadSopenharmony_ci    the vertex shader text.
23165bd8deadSopenharmony_ci
23175bd8deadSopenharmony_ci
23185bd8deadSopenharmony_ci    Modify Section 7.4, Built-In Constants, p. 74
23195bd8deadSopenharmony_ci
23205bd8deadSopenharmony_ci    (add to the list of constants at the bottom of p. 74)
23215bd8deadSopenharmony_ci
23225bd8deadSopenharmony_ci      const int gl_MaxTessControlInputComponents = 128;
23235bd8deadSopenharmony_ci      const int gl_MaxTessControlOutputComponents = 128;
23245bd8deadSopenharmony_ci      const int gl_MaxTessControlTextureImageUnits = 16;
23255bd8deadSopenharmony_ci      const int gl_MaxTessControlUniformComponents = 1024;
23265bd8deadSopenharmony_ci      const int gl_MaxTessControlTotalOutputComponents = 4096;
23275bd8deadSopenharmony_ci
23285bd8deadSopenharmony_ci      const int gl_MaxTessEvaluationInputComponents = 128;
23295bd8deadSopenharmony_ci      const int gl_MaxTessEvaluationOutputComponents = 128;
23305bd8deadSopenharmony_ci      const int gl_MaxTessEvaluationTextureImageUnits = 16;
23315bd8deadSopenharmony_ci      const int gl_MaxTessEvaluationUniformComponents = 1024;
23325bd8deadSopenharmony_ci
23335bd8deadSopenharmony_ci      const int gl_MaxTessPatchComponents = 120;
23345bd8deadSopenharmony_ci
23355bd8deadSopenharmony_ci      const int gl_MaxPatchVertices = 32;
23365bd8deadSopenharmony_ci      const int gl_MaxTessGenLevel = 64;
23375bd8deadSopenharmony_ci
23385bd8deadSopenharmony_ci    (modify the minimum value for one other constant)
23395bd8deadSopenharmony_ci
23405bd8deadSopenharmony_ci      const int gl_MaxCombinedTextureImageUnits = 80;
23415bd8deadSopenharmony_ci
23425bd8deadSopenharmony_ci
23435bd8deadSopenharmony_ci    Modify Section 8.7, Texture Lookup Functions, p. 90
23445bd8deadSopenharmony_ci
23455bd8deadSopenharmony_ci    (modify first paragraph, accounting for all the new shader types) Texture
23465bd8deadSopenharmony_ci    lookup functions are available to all shaders.  However, automatic level
23475bd8deadSopenharmony_ci    of detail computations are only performed for fragment shaders; other
23485bd8deadSopenharmony_ci    shaders operate as though the base level of detail were computed as zero.
23495bd8deadSopenharmony_ci    The functions in the table below ...
23505bd8deadSopenharmony_ci
23515bd8deadSopenharmony_ci    (modify first paragraph, p. 91) In all functions below, the bias parameter
23525bd8deadSopenharmony_ci    is optional for fragment shaders.  The bias parameter is not accepted in
23535bd8deadSopenharmony_ci    any other shader type.  For ...
23545bd8deadSopenharmony_ci
23555bd8deadSopenharmony_ci    (Also, make miscellaneous modifications elsewhere in the spec to account
23565bd8deadSopenharmony_ci    for the fact that vertex and fragment shaders are not the only two
23575bd8deadSopenharmony_ci    supported shader types.)
23585bd8deadSopenharmony_ci
23595bd8deadSopenharmony_ci
23605bd8deadSopenharmony_ci    Insert a new section after Section 8.10, Geometry Shader Functions,
23615bd8deadSopenharmony_ci    p. 103.
23625bd8deadSopenharmony_ci    
23635bd8deadSopenharmony_ci    Section 8.X, Shader Invocation Control Functions
23645bd8deadSopenharmony_ci
23655bd8deadSopenharmony_ci    Shader invocation control functions are available only in tessellation
23665bd8deadSopenharmony_ci    control shaders.  These functions are used to control the relative
23675bd8deadSopenharmony_ci    execution order of the multiple shader invocations used to process a
23685bd8deadSopenharmony_ci    patch, which are otherwise executed with an undefined relative order.
23695bd8deadSopenharmony_ci
23705bd8deadSopenharmony_ci    The function barrier() provides a partially defined order of execution
23715bd8deadSopenharmony_ci    between shader invocations.  This ensures that values written by one
23725bd8deadSopenharmony_ci    invocation prior to the call to barrier() can be safely read by other
23735bd8deadSopenharmony_ci    invocations after the call to barrier().  Because invocations may execute
23745bd8deadSopenharmony_ci    in undefined order between barriers, the values of a per-vertex or
23755bd8deadSopenharmony_ci    per-patch output variable will be undefined in a number of cases
23765bd8deadSopenharmony_ci    enumerated in Section 4.3.6.
23775bd8deadSopenharmony_ci
23785bd8deadSopenharmony_ci    The barrier() function may only be called inside the main entry point of
23795bd8deadSopenharmony_ci    the tessellation control shader and may not be called within any control
23805bd8deadSopenharmony_ci    flow.  Barriers are also disallowed after a return statement in function
23815bd8deadSopenharmony_ci    main().
23825bd8deadSopenharmony_ci
23835bd8deadSopenharmony_ci      Syntax              Description
23845bd8deadSopenharmony_ci      -------------       --------------------------------------------------
23855bd8deadSopenharmony_ci      void barrier(void)  For any given static instance of barrier(), all
23865bd8deadSopenharmony_ci                          tessellation control shader invocations for a single
23875bd8deadSopenharmony_ci                          input patch must enter it before any will be allowed
23885bd8deadSopenharmony_ci                          to continue beyond it.
23895bd8deadSopenharmony_ci
23905bd8deadSopenharmony_ci    Modify Section 9, Shading Language Grammar, p. 105
23915bd8deadSopenharmony_ci
23925bd8deadSopenharmony_ci    !!! TBD
23935bd8deadSopenharmony_ci
23945bd8deadSopenharmony_ci
23955bd8deadSopenharmony_ciGLX Protocol
23965bd8deadSopenharmony_ci
23975bd8deadSopenharmony_ci    None.
23985bd8deadSopenharmony_ci
23995bd8deadSopenharmony_ci
24005bd8deadSopenharmony_ciErrors
24015bd8deadSopenharmony_ci
24025bd8deadSopenharmony_ci    The error INVALID_VALUE is generated by PatchParameteri if <pname> is
24035bd8deadSopenharmony_ci    PATCH_VERTICES and <value> is less than or equal to zero or is greater
24045bd8deadSopenharmony_ci    than the implementation-dependent maximum patch size.
24055bd8deadSopenharmony_ci
24065bd8deadSopenharmony_ci    The error INVALID_OPERATION is generated by Begin (or vertex array
24075bd8deadSopenharmony_ci    commands that implicitly call Begin) if the active program contains a
24085bd8deadSopenharmony_ci    tessellation control or evaluation shader and the primitive mode is not
24095bd8deadSopenharmony_ci    PATCHES.
24105bd8deadSopenharmony_ci
24115bd8deadSopenharmony_ci    The error INVALID_OPERATION is generated by Begin (or vertex array
24125bd8deadSopenharmony_ci    commands that implicitly call Begin) if the primitive mode is PATCHES if
24135bd8deadSopenharmony_ci    either:
24145bd8deadSopenharmony_ci
24155bd8deadSopenharmony_ci      *  the active program contains no tessellation evaluation shader, or
24165bd8deadSopenharmony_ci      *  no program is active.
24175bd8deadSopenharmony_ci
24185bd8deadSopenharmony_ci    The error INVALID_OPERATION is generated by GetProgramiv if <pname>
24195bd8deadSopenharmony_ci    identifies a tessellation control or evaluation shader-specific property
24205bd8deadSopenharmony_ci    and <program> has not been linked successfully, or does not contain
24215bd8deadSopenharmony_ci    objects to form a shader whose type corresponds to <pname>.
24225bd8deadSopenharmony_ci
24235bd8deadSopenharmony_ci
24245bd8deadSopenharmony_ciDependencies on OpenGL 3.2 (Core Profile)
24255bd8deadSopenharmony_ci
24265bd8deadSopenharmony_ci    If only the core profile of OpenGL 3.2 is supported, references to
24275bd8deadSopenharmony_ci    functionality deprecated by OpenGL 3.0 (built-in input/output variables
24285bd8deadSopenharmony_ci    corresponding to fixed-function vertex attributes, glBegin, fixed-function
24295bd8deadSopenharmony_ci    vertex processing) should be removed and/or replaced with functionality
24305bd8deadSopenharmony_ci    supported in the core profile.  In such an environment, the PATCHES
24315bd8deadSopenharmony_ci    primitive type is not supported by the deleted Begin() function but will
24325bd8deadSopenharmony_ci    still be supported by vertex array draw calls such as DrawArrays() and
24335bd8deadSopenharmony_ci    DrawElements().
24345bd8deadSopenharmony_ci
24355bd8deadSopenharmony_ciDependencies on ARB_gpu_shader5
24365bd8deadSopenharmony_ci
24375bd8deadSopenharmony_ci    If ARB_gpu_shader5 is not supported, references to the input variable
24385bd8deadSopenharmony_ci    gl_InvocationID in the geometry shader language should be deleted.  This
24395bd8deadSopenharmony_ci    spec references gl_InvocationID in order to provide a complete set of
24405bd8deadSopenharmony_ci    language for implementations supporting GLSL 1.50 and both extensions.
24415bd8deadSopenharmony_ci
24425bd8deadSopenharmony_ciDependencies on ARB_gpu_shader_fp64
24435bd8deadSopenharmony_ci
24445bd8deadSopenharmony_ci    If ARB_gpu_shader_fp64 is supported, discussion of the maximum number of
24455bd8deadSopenharmony_ci    input, output, and uniform components supported by the implementation for
24465bd8deadSopenharmony_ci    tessellation control and evaluation shaders should note each
24475bd8deadSopenharmony_ci    double-precision floating-point value is counted as two components.
24485bd8deadSopenharmony_ci
24495bd8deadSopenharmony_ciDependencies on NV_gpu_shader5
24505bd8deadSopenharmony_ci
24515bd8deadSopenharmony_ci    If NV_gpu_shader5 is supported, discussion of the maximum number of input,
24525bd8deadSopenharmony_ci    output, and uniform components supported by the implementation for
24535bd8deadSopenharmony_ci    tessellation control and evaluation shaders should note each 64-bit
24545bd8deadSopenharmony_ci    integer value is counted as two components.
24555bd8deadSopenharmony_ci
24565bd8deadSopenharmony_ciDependencies on NV_primitive_restart
24575bd8deadSopenharmony_ci
24585bd8deadSopenharmony_ci    If primitive restart is enabled, sending a vertex with the restart index
24595bd8deadSopenharmony_ci    will start a new patch at the beginning.  Any vertices specified prior to
24605bd8deadSopenharmony_ci    the restart index that form a partial patch will be discarded.
24615bd8deadSopenharmony_ci
24625bd8deadSopenharmony_ciNew State
24635bd8deadSopenharmony_ci
24645bd8deadSopenharmony_ci    Add the following state to Table 6.5, Current Values and Associated Data,
24655bd8deadSopenharmony_ci    p. 343
24665bd8deadSopenharmony_ci
24675bd8deadSopenharmony_ci                                                   Default
24685bd8deadSopenharmony_ci    Get Value                Type  Get Command     Value     Description                Sec.    Attr.
24695bd8deadSopenharmony_ci    ------------------------ ----  --------------  --------- ------------------------   ------  -------
24705bd8deadSopenharmony_ci    PATCH_VERTICES           Z+    GetIntegerv     3         Number of vertices in      2.6.1   current
24715bd8deadSopenharmony_ci                                                             input patch         
24725bd8deadSopenharmony_ci    PATCH_DEFAULT_OUTER_     4xR   GetFloatv       4 x 1.0   Default outer tessellation 2.X.2    -
24735bd8deadSopenharmony_ci      LEVEL                                                  level w/o control shader
24745bd8deadSopenharmony_ci    PATCH_DEFAULT_INNER_     2xR   GetFloatv       2 x 1.0   Default outer tessellation 2.X.2    -
24755bd8deadSopenharmony_ci      LEVEL                                                  level w/o control shader
24765bd8deadSopenharmony_ci
24775bd8deadSopenharmony_ci    Add the following state to Table 6.40, Program Object State, p. 378
24785bd8deadSopenharmony_ci
24795bd8deadSopenharmony_ci                                                   Default
24805bd8deadSopenharmony_ci    Get Value                Type  Get Command     Value     Description                Sec.    Attr.
24815bd8deadSopenharmony_ci    ------------------------ ----  --------------  --------- ------------------------   ------  -----
24825bd8deadSopenharmony_ci    TESS_CONTROL_OUTPUT_     Z+    GetProgramiv      0       Output patch size          2.X.1    -
24835bd8deadSopenharmony_ci      VERTICES                                               for tess. control shader
24845bd8deadSopenharmony_ci    TESS_GEN_MODE            Z+    GetProgramiv     QUADS    Base primitive type for    2.X.2    -
24855bd8deadSopenharmony_ci                                                             tess. prim. generator
24865bd8deadSopenharmony_ci    TESS_GEN_SPACING         Z+    GetProgramiv     EQUAL    Spacing of tess. prim.     2.X.2    -
24875bd8deadSopenharmony_ci                                                             generator edge subdivision
24885bd8deadSopenharmony_ci    TESS_GEN_VERTEX_ORDER    Z+    GetProgramiv     CCW      Order of vertices in       2.X.2    -
24895bd8deadSopenharmony_ci                                                             primitives generated by
24905bd8deadSopenharmony_ci                                                             tess. prim generator
24915bd8deadSopenharmony_ci    TESS_GEN_POINT_MODE      Z+    GetProgramiv     FALSE    Tess prim. generator       2.X.2    -
24925bd8deadSopenharmony_ci                                                             emits points?
24935bd8deadSopenharmony_ci    UNIFORM_BLOCK_REF-       B     GetActive-       0        True if uniform block is   
24945bd8deadSopenharmony_ci      ERENCED_BY_TESS_              UniformBlockiv           actively referenced by     2.14.4   -
24955bd8deadSopenharmony_ci      CONTROL_SHADER                                         tess. control stage
24965bd8deadSopenharmony_ci    UNIFORM_BLOCK_REF-       B     GetActive-       0        True if uniform block is   2.14.4   -
24975bd8deadSopenharmony_ci      ERENCED_BY_TESS_              UniformBlockiv           actively referenced by
24985bd8deadSopenharmony_ci      EVALUTION_SHADER                                       tess evaluation stage
24995bd8deadSopenharmony_ci
25005bd8deadSopenharmony_ciNew Implementation Dependent State
25015bd8deadSopenharmony_ci
25025bd8deadSopenharmony_ci                                                 Minimum
25035bd8deadSopenharmony_ci    Get Value                  Type  Get Command  Value  Description                  Sec.
25045bd8deadSopenharmony_ci    -------------------------  ----  ----------- ------- --------------------------   ------
25055bd8deadSopenharmony_ci    MAX_TESS_GEN_LEVEL         Z+    GetIntegerv   64    maximum tessellation level   2.X.2
25065bd8deadSopenharmony_ci                                                         supported by tessellation
25075bd8deadSopenharmony_ci                                                         primitive generator
25085bd8deadSopenharmony_ci    MAX_PATCH_VERTICES         Z+    GetIntegerv   32    maximum patch size           2.6.1
25095bd8deadSopenharmony_ci    MAX_TESS_CONTROL_          Z+    GetIntegerv   1024  number of words for tess.    2.X.1.1
25105bd8deadSopenharmony_ci      UNIFORM_COMPONENTS                                 control shader uniforms
25115bd8deadSopenharmony_ci    MAX_TESS_EVALUATION_       Z+    GetIntegerv   1024  number of words for tess.    2.X.3.1
25125bd8deadSopenharmony_ci      UNIFORM_COMPONENTS                                 evaluation shader uniforms
25135bd8deadSopenharmony_ci    MAX_TESS_CONTROL_TEXTURE_  Z+    GetIntegerv   16    number of tex. image units   2.14.7
25145bd8deadSopenharmony_ci      IMAGE_UNITS                                        for tess. control shaders
25155bd8deadSopenharmony_ci    MAX_TESS_EVALUATION_       Z+    GetIntegerv   16    number of tex. image units   2.14.7
25165bd8deadSopenharmony_ci      TEXTURE_IMAGE_UNITS                                for tess. eval. shaders
25175bd8deadSopenharmony_ci    MAX_TESS_CONTROL_          Z+    GetIntegerv   128   num. components for per-     2.X.1.2
25185bd8deadSopenharmony_ci      OUTPUT_COMPONENTS                                  vertex outputs in tess. 
25195bd8deadSopenharmony_ci                                                         control shaders
25205bd8deadSopenharmony_ci    MAX_TESS_PATCH_            Z+    GetIntegerv   120   num. components for per-     2.X.1.2
25215bd8deadSopenharmony_ci      COMPONENTS                                         patch output varyings
25225bd8deadSopenharmony_ci                                                         for tess. control shaders
25235bd8deadSopenharmony_ci    MAX_TESS_CONTROL_TOTAL_    Z+    GetIntegerv   4096  Total num components for     2.X.1.2
25245bd8deadSopenharmony_ci      OUTPUT_COMPONENTS                                  tess. control shader
25255bd8deadSopenharmony_ci                                                         outputs
25265bd8deadSopenharmony_ci    MAX_TESS_EVALUATION_       Z+    GetIntegerv   128   num. components for per-     2.X.3.2
25275bd8deadSopenharmony_ci      OUTPUT_COMPONENTS                                  vertex outputs in tess. 
25285bd8deadSopenharmony_ci                                                         evaluation shaders
25295bd8deadSopenharmony_ci    MAX_TESS_CONTROL_          Z+    GetIntegerv   128   num. components for per-     2.X.1.2
25305bd8deadSopenharmony_ci      INPUT_COMPONENTS                                   vertex inputs in tess.
25315bd8deadSopenharmony_ci                                                         control shaders
25325bd8deadSopenharmony_ci    MAX_TESS_EVALUATION_       Z+    GetIntegerv   128   num. components for per-     2.X.3.2
25335bd8deadSopenharmony_ci      INPUT_COMPONENTS                                   vertex inputs in tess.
25345bd8deadSopenharmony_ci                                                         evaluation shaders
25355bd8deadSopenharmony_ci    MAX_TESS_CONTROL_          Z+    GetIntegerv   12    num. of supported uniform    2.14.4
25365bd8deadSopenharmony_ci      UNIFORM_BLOCKS                                     blocks for tess. control
25375bd8deadSopenharmony_ci                                                         shaders
25385bd8deadSopenharmony_ci    MAX_TESS_EVALUATION_       Z+    GetIntegerv   12    num. of supported uniform    2.14.4
25395bd8deadSopenharmony_ci      UNIFORM_BLOCKS                                     blocks for tess. evaluation
25405bd8deadSopenharmony_ci                                                         shaders
25415bd8deadSopenharmony_ci    MAX_COMBINED_TESS_         Z+    GetIntegerv   *     number of words for tess.    2.X.1.1
25425bd8deadSopenharmony_ci      CONTROL_UNIFORM_                                   control uniform variables
25435bd8deadSopenharmony_ci      COMPONENTS                                         in all uniform blocks
25445bd8deadSopenharmony_ci                                                         (including default) 
25455bd8deadSopenharmony_ci    MAX_COMBINED_TESS_         Z+    GetIntegerv   *     number of words for tess.    2.X.3.1
25465bd8deadSopenharmony_ci      EVALUATION_UNIFORM_                                evaluation uniform vari-
25475bd8deadSopenharmony_ci      COMPONENTS                                         ables in all uniform
25485bd8deadSopenharmony_ci                                                         blocks (including default) 
25495bd8deadSopenharmony_ci
25505bd8deadSopenharmony_ci    The minimum values for MAX_COMBINED_*_UNIFORM_COMPONENTS by computing the
25515bd8deadSopenharmony_ci    value of:
25525bd8deadSopenharmony_ci
25535bd8deadSopenharmony_ci      MAX_*_UNIFORM_COMPONENTS + MAX_*_UNIFORM_BLOCKS * (MAX_UNIFORM_BLOCK_SIZE/4)
25545bd8deadSopenharmony_ci
25555bd8deadSopenharmony_ci    using the minimum values of the corresponding terms.
25565bd8deadSopenharmony_ci
25575bd8deadSopenharmony_ci    Also, increase the minimum for MAX_COMBINED_UNIFORM_BLOCKS to 60 (12
25585bd8deadSopenharmony_ci    blocks per stage, five stages) and MAX_COMBINED_TEXTURE_IMAGE_UNITS to 80
25595bd8deadSopenharmony_ci    (16 image units per stage, five stages).
25605bd8deadSopenharmony_ci
25615bd8deadSopenharmony_ci
25625bd8deadSopenharmony_ciIssues
25635bd8deadSopenharmony_ci
25645bd8deadSopenharmony_ci    (1) How does tessellation fit into the existing GL pipeline?
25655bd8deadSopenharmony_ci
25665bd8deadSopenharmony_ci      RESOLVED:  The following diagram illustrates how tessellation shaders
25675bd8deadSopenharmony_ci      fit into the "vertex processing" portion of the GL (Chapter 2 of the
25685bd8deadSopenharmony_ci      OpenGL 3.2 Specification).
25695bd8deadSopenharmony_ci
25705bd8deadSopenharmony_ci      First, vertex attributes are specified via immediate-mode commands or
25715bd8deadSopenharmony_ci      through vertex arrays.  They can be conventional attributes (e.g.,
25725bd8deadSopenharmony_ci      glVertex, glColor, glTexCoord) or generic (numbered) attributes.
25735bd8deadSopenharmony_ci
25745bd8deadSopenharmony_ci      Vertices are then transformed, either using a vertex shader or
25755bd8deadSopenharmony_ci      fixed-function vertex processing.  Fixed-function vertex processing
25765bd8deadSopenharmony_ci      includes position transformation (modelview and projection matrices),
25775bd8deadSopenharmony_ci      lighting, texture coordinate generation, and other calculations.  The
25785bd8deadSopenharmony_ci      results of either method are a "transformed vertex", which has a
25795bd8deadSopenharmony_ci      position (in clip coordinates), front and back colors, texture
25805bd8deadSopenharmony_ci      coordinates, generic attributes (vertex shader only), and so on.  Note
25815bd8deadSopenharmony_ci      that on many current GL implementations, vertex processing is performed
25825bd8deadSopenharmony_ci      by executing a "fixed function vertex shader" generated by the driver.
25835bd8deadSopenharmony_ci
25845bd8deadSopenharmony_ci      After vertex transformation, vertices are assembled into primitives,
25855bd8deadSopenharmony_ci      according to the topology (e.g., TRIANGLES, QUAD_STRIP) provided by the
25865bd8deadSopenharmony_ci      call to glBegin().  Primitives are points, lines, triangles, quads,
25875bd8deadSopenharmony_ci      polygons, lines or triangles with adjacency, or patches.  Many GL
25885bd8deadSopenharmony_ci      implementations do not directly support quads or polygons, but instead
25895bd8deadSopenharmony_ci      decompose them into triangles as permitted by the spec.
25905bd8deadSopenharmony_ci
25915bd8deadSopenharmony_ci      After initial primitive assembly, patch primitives are processed by the
25925bd8deadSopenharmony_ci      tessellation control shader, if present.  The tessellation control
25935bd8deadSopenharmony_ci      shader reads the vertices of the incoming patch and generates a new
25945bd8deadSopenharmony_ci      patch, consisting of a set of vertices and per-patch data.  The
25955bd8deadSopenharmony_ci      tessellation control shader runs with multiple invocations, one per
25965bd8deadSopenharmony_ci      vertex in the output patch.  Each invocation computes the properties of
25975bd8deadSopenharmony_ci      its own vertex; the invocations collectively compute any per-patch data.
25985bd8deadSopenharmony_ci      The vertices and per-patch data are then assembled into a new patch
25995bd8deadSopenharmony_ci      primitive.
26005bd8deadSopenharmony_ci
26015bd8deadSopenharmony_ci      If a tessellation evaluation shader is present, the tessellation
26025bd8deadSopenharmony_ci      primitive generator and the tessellation evaluation shader will convert
26035bd8deadSopenharmony_ci      an incoming patch into a new set of point, line, or triangle primitives.
26045bd8deadSopenharmony_ci      The tessellation primitive generator uses the per-patch tessellation
26055bd8deadSopenharmony_ci      levels and output layout qualifiers to appropriately subdivide a
26065bd8deadSopenharmony_ci      triangle or quadrilateral into point, line, or triangle primitives.  For
26075bd8deadSopenharmony_ci      each vertex in the subdivided surface, the tessellation evaluation
26085bd8deadSopenharmony_ci      shader is run to compute its position and other attributes, given a
26095bd8deadSopenharmony_ci      (u,v) or (u,v,w) location within the subdivided primitive, the vertices
26105bd8deadSopenharmony_ci      of the patch, and any per-patch data produced by the tessellation
26115bd8deadSopenharmony_ci      control shader.  The results are assembled into primitives for
26125bd8deadSopenharmony_ci      processing by subsequent stages.
26135bd8deadSopenharmony_ci
26145bd8deadSopenharmony_ci      After vertex transformation and tessellation, a geometry shader is
26155bd8deadSopenharmony_ci      executed on each individual point, line, triangle, or patch primitive,
26165bd8deadSopenharmony_ci      if one is active.  It can read the attributes of each transformed vertex
26175bd8deadSopenharmony_ci      in the primitive, perform arbitrary computations, and emit new
26185bd8deadSopenharmony_ci      transformed vertices.  These emitted vertices are themselves assembled
26195bd8deadSopenharmony_ci      into primitives according to the output primitive type of the geometry
26205bd8deadSopenharmony_ci      shader.
26215bd8deadSopenharmony_ci
26225bd8deadSopenharmony_ci      Then, the colors of the vertices of each primitive are clamped to [0,1]
26235bd8deadSopenharmony_ci      (if color clamping is enabled), and flat shading may be performed by
26245bd8deadSopenharmony_ci      taking the color from the provoking vertex of the primitive.
26255bd8deadSopenharmony_ci
26265bd8deadSopenharmony_ci      Each primitive is clipped to the view volume, and to any enabled
26275bd8deadSopenharmony_ci      user-defined clip planes.  Color, texture coordinate, and other
26285bd8deadSopenharmony_ci      attribute values are computed for each new vertex introduced by
26295bd8deadSopenharmony_ci      clipping.
26305bd8deadSopenharmony_ci
26315bd8deadSopenharmony_ci      After clipping, the position of each vertex (in clip coordinates) is
26325bd8deadSopenharmony_ci      converted to normalized device coordinates in the perspective division
26335bd8deadSopenharmony_ci      (divide by w) step, and to window coordinates in the viewport
26345bd8deadSopenharmony_ci      transformation step.
26355bd8deadSopenharmony_ci
26365bd8deadSopenharmony_ci      At the same time, color values may be converted to normalized
26375bd8deadSopenharmony_ci      fixed-point values according to the "Final Color Processing" portion of
26385bd8deadSopenharmony_ci      the specification.
26395bd8deadSopenharmony_ci
26405bd8deadSopenharmony_ci      After the vertices of the primitive are transformed to window
26415bd8deadSopenharmony_ci      coordinate, the GL determines if the primitive is front- or back-facing.
26425bd8deadSopenharmony_ci      That information is used for two-sided color selection, where a single
26435bd8deadSopenharmony_ci      set of colors is selected from either the front or back colors
26445bd8deadSopenharmony_ci      associated with each transformed vertex.
26455bd8deadSopenharmony_ci
26465bd8deadSopenharmony_ci      When all this is done, the final transformed position, colors (primary
26475bd8deadSopenharmony_ci      and secondary), and other attributes are used for rasterization (Chapter
26485bd8deadSopenharmony_ci      3 in the OpenGL 2.0 Specification).
26495bd8deadSopenharmony_ci
26505bd8deadSopenharmony_ci      When the raster position is specified (via glRasterPos), it goes through
26515bd8deadSopenharmony_ci      the entire vertex processing pipeline as though it were a point.
26525bd8deadSopenharmony_ci      However, tessellation and geometry shaders are never run on the raster
26535bd8deadSopenharmony_ci      position.
26545bd8deadSopenharmony_ci
26555bd8deadSopenharmony_ci
26565bd8deadSopenharmony_ci                        |generic              |conventional
26575bd8deadSopenharmony_ci                        |vertex               |vertex
26585bd8deadSopenharmony_ci                        |attributes           |attributes
26595bd8deadSopenharmony_ci                        |                     |
26605bd8deadSopenharmony_ci                        | +-------------------+
26615bd8deadSopenharmony_ci                        | |                   |
26625bd8deadSopenharmony_ci                        V V                   V
26635bd8deadSopenharmony_ci                      vertex            fixed-function
26645bd8deadSopenharmony_ci                      shader              vertex
26655bd8deadSopenharmony_ci                         |               processing
26665bd8deadSopenharmony_ci                         |                    |
26675bd8deadSopenharmony_ci                         |                    |
26685bd8deadSopenharmony_ci                         +<-------------------+                
26695bd8deadSopenharmony_ci                         |
26705bd8deadSopenharmony_ci                         |position, color,
26715bd8deadSopenharmony_ci                         |other vertex data
26725bd8deadSopenharmony_ci                         |
26735bd8deadSopenharmony_ci                         V
26745bd8deadSopenharmony_ci         Begin/      primitive   patch    tessellation      (control point,
26755bd8deadSopenharmony_ci          End -----> assembly ----------->  control          parallel patch,
26765bd8deadSopenharmony_ci         State           |                  shaders          final patch)
26775bd8deadSopenharmony_ci                         |                   |  |
26785bd8deadSopenharmony_ci                         |           vertices|  |per-patch
26795bd8deadSopenharmony_ci                         |                   |  |data
26805bd8deadSopenharmony_ci                         |                   |  |
26815bd8deadSopenharmony_ci                         |                   |  |
26825bd8deadSopenharmony_ci                         V    patch          V  V
26835bd8deadSopenharmony_ci                         +<-------------  primitive
26845bd8deadSopenharmony_ci                         |                assembly
26855bd8deadSopenharmony_ci                         |
26865bd8deadSopenharmony_ci                         |     patch
26875bd8deadSopenharmony_ci                         +-------+-+---------------+            output
26885bd8deadSopenharmony_ci                         |       | |               |tess        layout
26895bd8deadSopenharmony_ci                         |  vert-| |per-patch      |levels     qualifiers
26905bd8deadSopenharmony_ci                         |  ices | |data           |               |
26915bd8deadSopenharmony_ci                         |       | |               V               |
26925bd8deadSopenharmony_ci                         |       | | (u,v,w)  tessellation         |
26935bd8deadSopenharmony_ci                         |       | |  +------  primitive  <--------+
26945bd8deadSopenharmony_ci                         |       | |  |        generator
26955bd8deadSopenharmony_ci                         |       V V  V             |
26965bd8deadSopenharmony_ci                         |      tessellation        |
26975bd8deadSopenharmony_ci                         |       evaluation         |connectivity
26985bd8deadSopenharmony_ci                         |         shader           |
26995bd8deadSopenharmony_ci                         |           |              V
27005bd8deadSopenharmony_ci                         |           +--------> primitive
27015bd8deadSopenharmony_ci                         |            vertex    assembly
27025bd8deadSopenharmony_ci                         V                          |
27035bd8deadSopenharmony_ci                         +<-------------------------+
27045bd8deadSopenharmony_ci                         |                                     Output
27055bd8deadSopenharmony_ci                         |position, color,                   Primitive
27065bd8deadSopenharmony_ci                         |other vertex data                     Type
27075bd8deadSopenharmony_ci                         |                                       |
27085bd8deadSopenharmony_ci                         |            geometry       primitive   |
27095bd8deadSopenharmony_ci                         +----------> shader ------> assembly  <-+
27105bd8deadSopenharmony_ci                         |                               |
27115bd8deadSopenharmony_ci                         V                               |
27125bd8deadSopenharmony_ci                         +<------------------------------+
27135bd8deadSopenharmony_ci                         |
27145bd8deadSopenharmony_ci                         |
27155bd8deadSopenharmony_ci                         |             color           flat
27165bd8deadSopenharmony_ci                         +----------> clamping -----> shading
27175bd8deadSopenharmony_ci                         |                               |
27185bd8deadSopenharmony_ci                         V                               |
27195bd8deadSopenharmony_ci                         +<------------------------------+
27205bd8deadSopenharmony_ci                         |
27215bd8deadSopenharmony_ci                      clipping
27225bd8deadSopenharmony_ci                         |        perspective       viewport
27235bd8deadSopenharmony_ci                         +------>   divide    ----> transform
27245bd8deadSopenharmony_ci                         |                              |
27255bd8deadSopenharmony_ci                         |                          +---+-----+
27265bd8deadSopenharmony_ci                         |                          V         |
27275bd8deadSopenharmony_ci                         |           final        facing      |
27285bd8deadSopenharmony_ci                         +------>    color     determination  |
27295bd8deadSopenharmony_ci                         |         processing       |         |
27305bd8deadSopenharmony_ci                         |             |            |         |
27315bd8deadSopenharmony_ci                         |             |            |         |
27325bd8deadSopenharmony_ci                         |             +-----+ +----+         |
27335bd8deadSopenharmony_ci                         |                   | |              |
27345bd8deadSopenharmony_ci                         |                   V V              |
27355bd8deadSopenharmony_ci                         |                two-sided           |
27365bd8deadSopenharmony_ci                         |                 coloring           |
27375bd8deadSopenharmony_ci                         |                    |               |
27385bd8deadSopenharmony_ci                         |                    |               |
27395bd8deadSopenharmony_ci                         +------------------+ | +-------------+
27405bd8deadSopenharmony_ci                                            | | |
27415bd8deadSopenharmony_ci                                            V V V
27425bd8deadSopenharmony_ci                                        rasterization 
27435bd8deadSopenharmony_ci                                              |
27445bd8deadSopenharmony_ci                                              |
27455bd8deadSopenharmony_ci                                              V
27465bd8deadSopenharmony_ci
27475bd8deadSopenharmony_ci    (2) Should we introduce new "patch" primitive types, or should
27485bd8deadSopenharmony_ci        tessellation be allowed to operate on patches assembled from a point
27495bd8deadSopenharmony_ci        list or other primitive types?
27505bd8deadSopenharmony_ci
27515bd8deadSopenharmony_ci      RESOLVED:  Provide new patch primitives.
27525bd8deadSopenharmony_ci
27535bd8deadSopenharmony_ci    (3) Unlike other primitive types, patches don't have a definite number of
27545bd8deadSopenharmony_ci        vertices.  How should the number of vertices in a patch be specified?
27555bd8deadSopenharmony_ci
27565bd8deadSopenharmony_ci      RESOLVED:  Use a piece of "patch parameter" context state specified by
27575bd8deadSopenharmony_ci      the PatchParameteri entry point to indicate a patch size.
27585bd8deadSopenharmony_ci
27595bd8deadSopenharmony_ci      Several other options were considered, including creating a new set of
27605bd8deadSopenharmony_ci      APIs to draw patches, having the input patch size be a (GLSL) program
27615bd8deadSopenharmony_ci      parameter, or providing a separate "patch" enum for each supported patch
27625bd8deadSopenharmony_ci      size (e.g., "PATCH16" for a 16-vertex patch).  The new API was rejected
27635bd8deadSopenharmony_ci      because the new calls may need to interact with a wide variety of vertex
27645bd8deadSopenharmony_ci      APIs (e.g., multi-draw array calls, instancing, ranged element arrays);
27655bd8deadSopenharmony_ci      a patch size parameter is orthogonal to all of these.  Having a fixed
27665bd8deadSopenharmony_ci      input patch size in a GLSL program may be fine in some cases.  We expect
27675bd8deadSopenharmony_ci      that some tessellation control shaders may want handle input patches
27685bd8deadSopenharmony_ci      with a variable number of extraordinary vertices, which would be
27695bd8deadSopenharmony_ci      incompatible with a fixed patch size in the program.  Handling many
27705bd8deadSopenharmony_ci      different "patch" enums in a frequently invoked draw calls didn't seem
27715bd8deadSopenharmony_ci      to make sense, either.
27725bd8deadSopenharmony_ci
27735bd8deadSopenharmony_ci    (4) Should we support "overlap" of patches -- strips where some points in
27745bd8deadSopenharmony_ci        one patch are reused in neighboring ones?  If so, how should the
27755bd8deadSopenharmony_ci        overlap be specified?  Using a separate GL call?  Using a parameter in
27765bd8deadSopenharmony_ci        the program specifying a strip?  Using an overlap parameter that says
27775bd8deadSopenharmony_ci        how many vertices from one patch are carried over to the next one?
27785bd8deadSopenharmony_ci        Something else?
27795bd8deadSopenharmony_ci
27805bd8deadSopenharmony_ci      RESOLVED:  We will not support patch strips in this extension.  Regular
27815bd8deadSopenharmony_ci      strips of patches can be drawn efficiently using DrawElements and an
27825bd8deadSopenharmony_ci      index buffer.
27835bd8deadSopenharmony_ci
27845bd8deadSopenharmony_ci    (5) May patches be specified in immediate mode, and if so, how?
27855bd8deadSopenharmony_ci
27865bd8deadSopenharmony_ci      RESOLVED:  Yes; this support falls out of the API definition.  Immediate
27875bd8deadSopenharmony_ci      mode may be useful in the compatibility profile to allow Begin/End-based
27885bd8deadSopenharmony_ci      applications to use tessellation without changing the way they specify
27895bd8deadSopenharmony_ci      vertices.
27905bd8deadSopenharmony_ci
27915bd8deadSopenharmony_ci      For the core profile, immediate mode is not supported for any primitive
27925bd8deadSopenharmony_ci      type, including patches.
27935bd8deadSopenharmony_ci
27945bd8deadSopenharmony_ci    (6) How are the vertices of patch primitives interpreted when compiled
27955bd8deadSopenharmony_ci        into display lists (compatibility profile)?
27965bd8deadSopenharmony_ci
27975bd8deadSopenharmony_ci      RESOLVED:  During compilation, the vertices are simply stored into the
27985bd8deadSopenharmony_ci      display list as-is.  During execution, they are interpreted according to
27995bd8deadSopenharmony_ci      the current patch size values specified by PatchParameteri.  To
28005bd8deadSopenharmony_ci      interpret patches according to values determined at display list compile
28015bd8deadSopenharmony_ci      time, compile PatchParameteri calls to set the size and stride into the
28025bd8deadSopenharmony_ci      display list.
28035bd8deadSopenharmony_ci
28045bd8deadSopenharmony_ci      One downside of this choice is that making the interpretation of patch
28055bd8deadSopenharmony_ci      vertices dependent on run-time state means that the display list
28065bd8deadSopenharmony_ci      compiler may not be able to determine the number of vertices in a patch
28075bd8deadSopenharmony_ci      primitive, and would be unable to perform any operations that require
28085bd8deadSopenharmony_ci      knowing the patch structure.
28095bd8deadSopenharmony_ci
28105bd8deadSopenharmony_ci    (7) What should these shaders be called?
28115bd8deadSopenharmony_ci
28125bd8deadSopenharmony_ci      RESOLVED:  The shader that converts an input patch to an output patch is
28135bd8deadSopenharmony_ci      called a "tessellation control shader" (TCS).  The use of "control" has
28145bd8deadSopenharmony_ci      several connotations -- the vertices of the input and output patches are
28155bd8deadSopenharmony_ci      often called "control points" and the tessellation levels computed are
28165bd8deadSopenharmony_ci      used to control the tessellation primitive generator.  The shader that
28175bd8deadSopenharmony_ci      takes the (u,v,w) or (u,v) points generated by the tessellation
28185bd8deadSopenharmony_ci      primitive generator are called tessellation evaluation shaders (TES), as
28195bd8deadSopenharmony_ci      they evaluate the position and other attributes of all the vertices of
28205bd8deadSopenharmony_ci      the tessellated primitive.
28215bd8deadSopenharmony_ci
28225bd8deadSopenharmony_ci      Other options considered for TCS include "patch shaders" or "primitive
28235bd8deadSopenharmony_ci      shaders".  These choices seemed too general; the existing geometry
28245bd8deadSopenharmony_ci      shaders are arguably already primitive shaders.  The term "tessellation
28255bd8deadSopenharmony_ci      shader" was also considered for TES, but that choice also seemed too
28265bd8deadSopenharmony_ci      general -- TCS is strongly related to tessellation as well.
28275bd8deadSopenharmony_ci
28285bd8deadSopenharmony_ci      Other APIs may refer to the tessellation control and evaluation shaders
28295bd8deadSopenharmony_ci      as "hull shaders" and "domain shaders", respectively.
28305bd8deadSopenharmony_ci
28315bd8deadSopenharmony_ci    (8) Should coupling of tessellation control and evaluation shaders be
28325bd8deadSopenharmony_ci        required?
28335bd8deadSopenharmony_ci
28345bd8deadSopenharmony_ci      RESOLVED:  No.  A tessellation control shader without an evaluation
28355bd8deadSopenharmony_ci      shader might be used in conjunction with transform feedback to generate
28365bd8deadSopenharmony_ci      regular transformed patches.  Also, if the set of patches provided by
28375bd8deadSopenharmony_ci      the application is already in a form usable by the tessellator, the
28385bd8deadSopenharmony_ci      tessellation control shader may be bypassed.  In this use case, the
28395bd8deadSopenharmony_ci      application would be required to provide default tessellation levels via
28405bd8deadSopenharmony_ci      the PatchParameterfv API, since no shader would be available to compute
28415bd8deadSopenharmony_ci      them.
28425bd8deadSopenharmony_ci
28435bd8deadSopenharmony_ci      It may be useful to have a patch produced by a tessellation control
28445bd8deadSopenharmony_ci      shader to be fed directly to a geometry shader that performs some
28455bd8deadSopenharmony_ci      operation on full patches, rather than individual triangles of a
28465bd8deadSopenharmony_ci      tessellated patch.  However, such capability is not provided in this
28475bd8deadSopenharmony_ci      extension.
28485bd8deadSopenharmony_ci
28495bd8deadSopenharmony_ci    (9) What measures are provided to ensure crack-free tessellation, where
28505bd8deadSopenharmony_ci        the results of tessellating multiple adjacent meshes produce the same
28515bd8deadSopenharmony_ci        vertices along the edges?
28525bd8deadSopenharmony_ci
28535bd8deadSopenharmony_ci      RESOLVED:  The most likely cause of cracking is due to shared patch
28545bd8deadSopenharmony_ci      edges being subdivided differently.  In order to get consistent
28555bd8deadSopenharmony_ci      tessellation along shared edges, the tessellation control shaders (or
28565bd8deadSopenharmony_ci      default levels) must be constructed so that outer tessellation level
28575bd8deadSopenharmony_ci      corresponding to the shared edge must be exactly the same in both
28585bd8deadSopenharmony_ci      patches.
28595bd8deadSopenharmony_ci
28605bd8deadSopenharmony_ci      Hardware implementations should guarantee that the same set of vertices
28615bd8deadSopenharmony_ci      is produced when subdividing a shared patch edge where the corresponding
28625bd8deadSopenharmony_ci      outer tessellation level matches.  Hardware implementations of this
28635bd8deadSopenharmony_ci      extension should also guarantee that the (u,v,w) parameters generated
28645bd8deadSopenharmony_ci      are complementary.  Walking along a shared patch edge may take you from
28655bd8deadSopenharmony_ci      a u/v/w coordinate of 0.0 to 1.0 in one patch, and from 1.0 to 0.0.  In
28665bd8deadSopenharmony_ci      this case, the u/v/w coordinates generated for any given vertex along
28675bd8deadSopenharmony_ci      this edge should sum to *exactly* 1.0.  
28685bd8deadSopenharmony_ci
28695bd8deadSopenharmony_ci      Even with proper hardware support, tessellation evaluation shaders need
28705bd8deadSopenharmony_ci      to be crafted carefully to avoid arithmetic errors caused by the order
28715bd8deadSopenharmony_ci      of operations.  For example, errors in floating-point math mean that
28725bd8deadSopenharmony_ci      it's not always the case that:
28735bd8deadSopenharmony_ci
28745bd8deadSopenharmony_ci        ((A + B) + C) + D = A + (B + (C + D))
28755bd8deadSopenharmony_ci
28765bd8deadSopenharmony_ci      An evaluation shader walking a shared edge in opposite directions
28775bd8deadSopenharmony_ci      could easily run into errors such as this.
28785bd8deadSopenharmony_ci
28795bd8deadSopenharmony_ci      The "precise" qualifier provided by the ARB_gpu_shader5 extension can be
28805bd8deadSopenharmony_ci      used to reduce the risk of cracking due to compiler optimizations.
28815bd8deadSopenharmony_ci
28825bd8deadSopenharmony_ci      The full details of how to guarantee crack-free tessellation are beyond
28835bd8deadSopenharmony_ci      the scope of this specification.
28845bd8deadSopenharmony_ci
28855bd8deadSopenharmony_ci    (10) Should we provide special built-ins or other mechanisms to assist in
28865bd8deadSopenharmony_ci         crack-free tessellation or other common tessellation shader usages?
28875bd8deadSopenharmony_ci         If so, what should be provided?
28885bd8deadSopenharmony_ci
28895bd8deadSopenharmony_ci      RESOLVED:  Options considered include:
28905bd8deadSopenharmony_ci
28915bd8deadSopenharmony_ci        * a test if a vertex is at the edge of a patch (for some common patch
28925bd8deadSopenharmony_ci          topologies);
28935bd8deadSopenharmony_ci
28945bd8deadSopenharmony_ci        * a special directive to ensure that certain math operations requiring
28955bd8deadSopenharmony_ci          precise results are not adversely affected by compiler optimizations
28965bd8deadSopenharmony_ci          (e.g, reordering of operations, using asymmetric floating-point
28975bd8deadSopenharmony_ci          multiply-add operations);
28985bd8deadSopenharmony_ci
28995bd8deadSopenharmony_ci        * special "lerp" intrinsics to ensure exact results for
29005bd8deadSopenharmony_ci          "complementary" weights; and
29015bd8deadSopenharmony_ci
29025bd8deadSopenharmony_ci        * special built-ins for commonly used attribute evaluations (e.g.,
29035bd8deadSopenharmony_ci          linear, bicubic, and other polynomial evaluations)
29045bd8deadSopenharmony_ci
29055bd8deadSopenharmony_ci      This extension doesn't provide any such mechanisms; however, the
29065bd8deadSopenharmony_ci      "precise" qualifier in ARB_gpu_shader5 addresses the second issue.
29075bd8deadSopenharmony_ci
29085bd8deadSopenharmony_ci    (11) Should we provide specific invariance guarantees to ensure crack-free
29095bd8deadSopenharmony_ci         tessellation?  If so, what would they be?
29105bd8deadSopenharmony_ci
29115bd8deadSopenharmony_ci      RESOLVED:  Formulating guarantees of this sort is difficult.  The
29125bd8deadSopenharmony_ci      "precise" qualifier can be used to guarantee that expressions are
29135bd8deadSopenharmony_ci      evaluated in the manner specified in the shader code.
29145bd8deadSopenharmony_ci
29155bd8deadSopenharmony_ci    (12) In what domain should position parameters for tessellation shaders be
29165bd8deadSopenharmony_ci         provided?
29175bd8deadSopenharmony_ci
29185bd8deadSopenharmony_ci      RESOLVED:  We will provide tessellation coordinates in a standard [0,1]
29195bd8deadSopenharmony_ci      parameterization.  Two-dimensional (u,v) coordinates with components in
29205bd8deadSopenharmony_ci      [0,1] is a standard parameterization; for example, it is what is used
29215bd8deadSopenharmony_ci      for OpenGL evaluators.
29225bd8deadSopenharmony_ci
29235bd8deadSopenharmony_ci      A [-1,+1] parameterization has some advantages; in particular, the
29245bd8deadSopenharmony_ci      equivalent of "1-u" in this scheme is simply "-u".  Floating-point
29255bd8deadSopenharmony_ci      calculations involving these terms would result in values of identical
29265bd8deadSopenharmony_ci      magnitude, but opposite sign.  This advantage is not particularly
29275bd8deadSopenharmony_ci      important if the [0,1] parameterization is computed in a way that
29285bd8deadSopenharmony_ci      ensures that u+(1-u) == 1.0, with no floating-point rounding error.
29295bd8deadSopenharmony_ci
29305bd8deadSopenharmony_ci      Three-dimensional barycentric coordinates are provided for triangular
29315bd8deadSopenharmony_ci      patches, where each coordinate is a linear weight for one of the corners
29325bd8deadSopenharmony_ci      of the subdivided primitive.  Four-dimensional barycentric coordinates
29335bd8deadSopenharmony_ci      may be useful quad patches, but can be computed easily enough by a
29345bd8deadSopenharmony_ci      tessellation evaluation shader if required.
29355bd8deadSopenharmony_ci
29365bd8deadSopenharmony_ci    (13) What type of patches are supported by the tessellation primitive
29375bd8deadSopenharmony_ci    generator?
29385bd8deadSopenharmony_ci
29395bd8deadSopenharmony_ci      RESOLVED:  The primitive generator will subdivide triangular and
29405bd8deadSopenharmony_ci      rectangular patches into triangles, and will also subdivide a
29415bd8deadSopenharmony_ci      rectangular patch into line strips (called "isolines").  Triangular and
29425bd8deadSopenharmony_ci      rectangular patches are useful for direct rendering of higher-order
29435bd8deadSopenharmony_ci      surfaces; isolines are useful for a number of things, including
29445bd8deadSopenharmony_ci      realistic hair rendering.
29455bd8deadSopenharmony_ci
29465bd8deadSopenharmony_ci      Note that the notion of a patch in the tessellation API is simply an
29475bd8deadSopenharmony_ci      ordered collection of vertices of a fixed size.  There is no requirement
29485bd8deadSopenharmony_ci      that the vertices of the patch be arranged in a triangular or
29495bd8deadSopenharmony_ci      rectangular pattern at all.  Even for "normal" patches, there is no
29505bd8deadSopenharmony_ci      required vertex ordering.  Applications should be careful that the
29515bd8deadSopenharmony_ci      vertices of the patches they provide are ordered in the manner expected
29525bd8deadSopenharmony_ci      by the tessellation shaders they use.
29535bd8deadSopenharmony_ci
29545bd8deadSopenharmony_ci    (14) Should the tessellation control and evaluation shaders be provided in
29555bd8deadSopenharmony_ci         a single compliation unit, or in multiple units?
29565bd8deadSopenharmony_ci
29575bd8deadSopenharmony_ci      RESOLVED:  Separate units.  While tessellation control and evaluation
29585bd8deadSopenharmony_ci      shaders might often be tightly coupled, they can exist separately.  With
29595bd8deadSopenharmony_ci      the current GLSL program object API, all shader types are linked
29605bd8deadSopenharmony_ci      together into a single "program" unit, regardless.  A future API may
29615bd8deadSopenharmony_ci      allow decoupled shaders, in which case the tessellation control and
29625bd8deadSopenharmony_ci      evaluation shaders may want to be packaged separately.
29635bd8deadSopenharmony_ci
29645bd8deadSopenharmony_ci    (15) Should the tessellation control shader be provided in a single
29655bd8deadSopenharmony_ci         compilation unit with a single entry point, a single compilation unit
29665bd8deadSopenharmony_ci         with multiple entry points, or in multiple compilation units?
29675bd8deadSopenharmony_ci
29685bd8deadSopenharmony_ci      RESOLVED:  The extension packages the tessellation control shader into a
29695bd8deadSopenharmony_ci      single entry point that is run once per output vertex.  The barrier()
29705bd8deadSopenharmony_ci      function is provided to divide the tessellation control shader into
29715bd8deadSopenharmony_ci      execution phases that allow the separate threads to communicate via
29725bd8deadSopenharmony_ci      shared output variables.
29735bd8deadSopenharmony_ci
29745bd8deadSopenharmony_ci      We considered an approach that explicitly packages the different phases
29755bd8deadSopenharmony_ci      of execution into separate functions.  Such a shader might have a
29765bd8deadSopenharmony_ci      "control point entrypoint" run independently in parallel and would be
29775bd8deadSopenharmony_ci      responsible for computing per-vertex attributes for each control point
29785bd8deadSopenharmony_ci      of the output patch.  The shader might also have one or more "patch
29795bd8deadSopenharmony_ci      entrypoints" run independently that would be responsible for per-patch
29805bd8deadSopenharmony_ci      attributes.  Restrictions on the capabilities might also be provided to
29815bd8deadSopenharmony_ci      limit the communication between threads and entrypoints to specific
29825bd8deadSopenharmony_ci      well-defined points.  For example, the control point entrypoint might be
29835bd8deadSopenharmony_ci      allowed to write per-vertex outputs, but could be forbidden to read
29845bd8deadSopenharmony_ci      outputs written by other threads.  Patch entrypoints could be guaranteed
29855bd8deadSopenharmony_ci      to run after control point entrypoints, forbidden from writing
29865bd8deadSopenharmony_ci      per-vertex outputs, and restricted to reading and writing disjoint
29875bd8deadSopenharmony_ci      per-patch outputs.  Because shader outputs are defined at global scope
29885bd8deadSopenharmony_ci      in GLSL, enforcing such restrictions in a single shader executable would
29895bd8deadSopenharmony_ci      be difficult.  For example, the compiler might be required to forbid
29905bd8deadSopenharmony_ci      calls to utility functions reading/writing global outputs in a specific
29915bd8deadSopenharmony_ci      manner.  Such a restriction might need to apply to a lengthy call chain
29925bd8deadSopenharmony_ci      (i.e., an entrypoint calls function A, which calls function B, which
29935bd8deadSopenharmony_ci      calls function C, which performs specific operations on an output).
29945bd8deadSopenharmony_ci
29955bd8deadSopenharmony_ci      We also considered an approach with completely separate shader types in
29965bd8deadSopenharmony_ci      separate compilation units.  For example, we might provide separate
29975bd8deadSopenharmony_ci      "tessellation control point shaders" and one or more types of
29985bd8deadSopenharmony_ci      "tessellation control patch shaders".  The linker would build a single
29995bd8deadSopenharmony_ci      tessellation control executable from one or more of these shaders.  The
30005bd8deadSopenharmony_ci      languages for these different shader types could be constrained to
30015bd8deadSopenharmony_ci      enforce restrictions.  For example, tessellation control point shaders
30025bd8deadSopenharmony_ci      could be forbidden from declaring per-patch outputs, and per-vertex
30035bd8deadSopenharmony_ci      outputs would be non-arrays to prevent threads from reading the outputs
30045bd8deadSopenharmony_ci      of other control point shaders.  Per-vertex attributes of the output
30055bd8deadSopenharmony_ci      patch could be declared as inputs to the tessellation control patch
30065bd8deadSopenharmony_ci      shaders to forbid writes.
30075bd8deadSopenharmony_ci
30085bd8deadSopenharmony_ci      Another option considered provided a single shader entry point called
30095bd8deadSopenharmony_ci      once per patch and have an optimizing compiler extract the same sort of
30105bd8deadSopenharmony_ci      parallel execution units provided by the explicitly parallel shader
30115bd8deadSopenharmony_ci      model.  However, we didn't want to depend on "compiler magic" to get
30125bd8deadSopenharmony_ci      acceptable performance.
30135bd8deadSopenharmony_ci
30145bd8deadSopenharmony_ci    (17) Tessellation control shaders have a shared output patch, where
30155bd8deadSopenharmony_ci         individual threads can read and write these shared outputs.  Should
30165bd8deadSopenharmony_ci         we do anything to prevent multiple theads from reading and writing
30175bd8deadSopenharmony_ci         the same output?  If not, what should happen if they do?
30185bd8deadSopenharmony_ci
30195bd8deadSopenharmony_ci      RESOLVED:  We are currently enforcing no compile-time restrictions on
30205bd8deadSopenharmony_ci      these cases.  The built-in function barrier() can be used by the shader
30215bd8deadSopenharmony_ci      writer to segregate shader execution into phases.  No problems should
30225bd8deadSopenharmony_ci      arise as long as no two threads access the same shared output in the
30235bd8deadSopenharmony_ci      same phase.  Reading outputs written by other threads would not be a
30245bd8deadSopenharmony_ci      problem as long as the output was written in a previous phase.
30255bd8deadSopenharmony_ci
30265bd8deadSopenharmony_ci      The relative execution order of the shader threads within a single phase
30275bd8deadSopenharmony_ci      is undefined; a single phase may be run fully in parallel or fully
30285bd8deadSopenharmony_ci      serially.  If multiple threads write different values to the same output
30295bd8deadSopenharmony_ci      in the same phase, the thread that "wins" is undefined -- and for
30305bd8deadSopenharmony_ci      vectors, different components may have a different "winning thread".  If
30315bd8deadSopenharmony_ci      one thread reads an output written by another thread in the same phase,
30325bd8deadSopenharmony_ci      the newly written value may or may not be available at the time the read
30335bd8deadSopenharmony_ci      is executed.
30345bd8deadSopenharmony_ci
30355bd8deadSopenharmony_ci      In some of the alternate programming models considered in the discussion
30365bd8deadSopenharmony_ci      of the previous issue, it might be possible for the compiler to avoid
30375bd8deadSopenharmony_ci      read/write and write/write hazards.  For example, the compiler might
30385bd8deadSopenharmony_ci      allow an output variable to be written by only a single entrypoint, and
30395bd8deadSopenharmony_ci      could allow only those entrypoints logically "after" the entry point to
30405bd8deadSopenharmony_ci      read it.  Such enforcement would prevent undefined behavior, but would
30415bd8deadSopenharmony_ci      have some drawbacks of its own.  In particular, it doesn't solve the
30425bd8deadSopenharmony_ci      problem of multiple threads computing a single per-patch attribute.  One
30435bd8deadSopenharmony_ci      very natural use would be to use a patch entrypoint to compute the four
30445bd8deadSopenharmony_ci      outer tessellation levels in parallel.  If all threads only write to
30455bd8deadSopenharmony_ci      gl_TessLevelOuter[gl_InvocationID], there are no hazards.  However,
30465bd8deadSopenharmony_ci      detecting and preventing hazards are problematic if more complicated
30475bd8deadSopenharmony_ci      array indexing is used.  Also, there would be a problem if a parallel
30485bd8deadSopenharmony_ci      shader was structured in such a way that one output might be written by
30495bd8deadSopenharmony_ci      exactly one thread, but it wasn't obvious to the compiler which thread
30505bd8deadSopenharmony_ci      actually would write it.
30515bd8deadSopenharmony_ci
30525bd8deadSopenharmony_ci    (19) How should we name the parameters that control the degree of
30535bd8deadSopenharmony_ci        tessellation along edges of a given patch and the (u,v) or (u,v,w)
30545bd8deadSopenharmony_ci        parameter driving the tessellation shader evaluation?
30555bd8deadSopenharmony_ci
30565bd8deadSopenharmony_ci      RESOLVED:  The parameters controlling subdivision are called
30575bd8deadSopenharmony_ci      "tessellation levels".  The ones controlling subdivision of the outer
30585bd8deadSopenharmony_ci      edges of the patch are called "outer tessellation levels"; the ones
30595bd8deadSopenharmony_ci      controlling the interior are called "inner tessellation levels".  The
30605bd8deadSopenharmony_ci      built-in variables are called "gl_TessLevelOuter[]" and
30615bd8deadSopenharmony_ci      "gl_TessLevelInner[]".  Both are declared as arrays of floating-point
30625bd8deadSopenharmony_ci      scalars, rather than vectors, so they can be accessed with indexing.
30635bd8deadSopenharmony_ci      The (u,v) or (u,v,w) coordinate used by the tessellation evaluation
30645bd8deadSopenharmony_ci      shader is referred to as the "tessellation coordinate", giving the
30655bd8deadSopenharmony_ci      relative coordinates of the vertex in the primitive being tessellated.
30665bd8deadSopenharmony_ci      The built-in input variable holding this value is called "gl_TessCoord".
30675bd8deadSopenharmony_ci
30685bd8deadSopenharmony_ci    (20) How would applications handle attributes that may want to be sampled
30695bd8deadSopenharmony_ci         with different frequency?  For example, OpenGL evaluators can specify
30705bd8deadSopenharmony_ci         evaluator maps of different order for different attributes?  For
30715bd8deadSopenharmony_ci         example, evaluating (u,v) with a cubic 2D map (order == 4) requires
30725bd8deadSopenharmony_ci         16 control points, while a linear map (order == 2) only requires 4.
30735bd8deadSopenharmony_ci
30745bd8deadSopenharmony_ci      RESOLVED:  Tessellation evaluation shaders can read from any vertex or
30755bd8deadSopenharmony_ci      per-patch attribute, so they can read whatever the tessellation control
30765bd8deadSopenharmony_ci      shader throws at them.  Tessellation control shaders may choose to
30775bd8deadSopenharmony_ci      compute attributes sampled at a different frequency than per-control
30785bd8deadSopenharmony_ci      point in one of several ways:
30795bd8deadSopenharmony_ci
30805bd8deadSopenharmony_ci        * Compute and output the attribute in only a subset of the
30815bd8deadSopenharmony_ci          tessellation control shader threads; for example, only compute the
30825bd8deadSopenharmony_ci          "linear" attributes in threads 0-3.
30835bd8deadSopenharmony_ci
30845bd8deadSopenharmony_ci        * Encode the attribute across multiple control points.  For example,
30855bd8deadSopenharmony_ci          four vec4 values could be passed out as a float for each vertex if
30865bd8deadSopenharmony_ci          16 control point shader threads were used.  Doing this may be tricky
30875bd8deadSopenharmony_ci          in some cases.
30885bd8deadSopenharmony_ci
30895bd8deadSopenharmony_ci        * Compute the "linear" attributes as four-element per-patch outputs.
30905bd8deadSopenharmony_ci          If using this technique, it would be desirable to compute these
30915bd8deadSopenharmony_ci          independently in the tessellation control shader, if possible.
30925bd8deadSopenharmony_ci
30935bd8deadSopenharmony_ci    (21) To what level should we enforce that different shader types in a
30945bd8deadSopenharmony_ci         program match exactly, and to what level does the current program
30955bd8deadSopenharmony_ci         need to match the topology enums (e.g., GL_POINTS) provided by the
30965bd8deadSopenharmony_ci         application?
30975bd8deadSopenharmony_ci
30985bd8deadSopenharmony_ci      RESOLVED:  If the tessellator is being used, we will require a patch
30995bd8deadSopenharmony_ci      primitive as input and throw an INVALID_OPERATION error if any other
31005bd8deadSopenharmony_ci      primitive type is provided.  This is consistent with geometry shaders
31015bd8deadSopenharmony_ci      requiring primitives consistent with their input topology.  
31025bd8deadSopenharmony_ci
31035bd8deadSopenharmony_ci      If no tessellation evaluation shader is present, a patch primitive would
31045bd8deadSopenharmony_ci      need to be passed through to the geometry shader, or potentially
31055bd8deadSopenharmony_ci      transform feedback and rasterization.  That capability will not be
31065bd8deadSopenharmony_ci      provided by this extension, but may be provided in the future or in a
31075bd8deadSopenharmony_ci      vendor-specific extension.
31085bd8deadSopenharmony_ci
31095bd8deadSopenharmony_ci    (22) If we have a notion of a "patch" as a random (though possibly
31105bd8deadSopenharmony_ci         fixed-size) blob of vertices, should we extend this concept to
31115bd8deadSopenharmony_ci         encompass geometry shaders as well?
31125bd8deadSopenharmony_ci
31135bd8deadSopenharmony_ci      RESOLVED:  No, we will not allow geometry shaders to receive patches in
31145bd8deadSopenharmony_ci      this extension.  That limitation may be relaxed in a future extension.
31155bd8deadSopenharmony_ci
31165bd8deadSopenharmony_ci      Such a mechanism would allow patches to be used by geometry shaders in
31175bd8deadSopenharmony_ci      settings other than tessellation.  For example, QUADS primitives are
31185bd8deadSopenharmony_ci      subdivided into two triangles when passed to geometry shaders.  However,
31195bd8deadSopenharmony_ci      this mechanism allows applications to pass 4-vertex PATCHES primitives
31205bd8deadSopenharmony_ci      to geometry shaders, which can treat the four vertices as a quad.  Note
31215bd8deadSopenharmony_ci      also that the only way one could get patches to geometry shaders is if
31225bd8deadSopenharmony_ci      no tessellation evaluation shader is present, because the tessellation
31235bd8deadSopenharmony_ci      primitive generator will consume an input patch.
31245bd8deadSopenharmony_ci
31255bd8deadSopenharmony_ci    (23) Should we support a programming model where the tessellation control
31265bd8deadSopenharmony_ci         shader can be written serially rather than explicitly requiring
31275bd8deadSopenharmony_ci         parallel execution?
31285bd8deadSopenharmony_ci
31295bd8deadSopenharmony_ci      RESOLVED:  Not in this extension.  The parallel programming model allows
31305bd8deadSopenharmony_ci      for improved efficiency.  While an optimizing compiler could refactor
31315bd8deadSopenharmony_ci      the code to execute in parallel, depending on this refactoring would run
31325bd8deadSopenharmony_ci      the risk of major performance pitfalls.
31335bd8deadSopenharmony_ci
31345bd8deadSopenharmony_ci    (24) Should the use of tessellation shaders be allowed with fixed-function
31355bd8deadSopenharmony_ci         vertex processing, or should we require the use of a vertex shader?
31365bd8deadSopenharmony_ci
31375bd8deadSopenharmony_ci      RESOLVED:  When using tessellation control or evaluation shaders,
31385bd8deadSopenharmony_ci      programmable vertex shaders will be required.  This follows the
31395bd8deadSopenharmony_ci      precedent established by EXT_geometry_shader4 that requires that if you
31405bd8deadSopenharmony_ci      use a programmable shader for any stage prior to rasterization, you
31415bd8deadSopenharmony_ci      can't mix that with fixed-function vertex processing.
31425bd8deadSopenharmony_ci
31435bd8deadSopenharmony_ci    (25) Should we support variable-size input patches in the tessellation
31445bd8deadSopenharmony_ci         control or evaluation shaders?  If so, how can one get at the number
31455bd8deadSopenharmony_ci         of vertices in the input patch?
31465bd8deadSopenharmony_ci
31475bd8deadSopenharmony_ci      RESOLVED:  Yes, variable-size input patches are supported, though the
31485bd8deadSopenharmony_ci      input size can not be changed within a single draw call or Begin/End
31495bd8deadSopenharmony_ci      pair.  The vertex count for a specific input patch can be obtained in a
31505bd8deadSopenharmony_ci      shader using the input variable "gl_PatchVerticesIn".  Additionally, the
31515bd8deadSopenharmony_ci      maximum patch size supported by the implementation, used for sizing
31525bd8deadSopenharmony_ci      unsigned per-vertex input arrays, is given by the constant
31535bd8deadSopenharmony_ci      "gl_MaxPatchVertices".
31545bd8deadSopenharmony_ci
31555bd8deadSopenharmony_ci      The EXT_geometry_shader4 provided a constant "gl_VerticesIn"
31565bd8deadSopenharmony_ci      corresponding to the fixed input primitive size set by the input
31575bd8deadSopenharmony_ci      primitive type.  This variable was dropped when geometry shaders were
31585bd8deadSopenharmony_ci      included in GLSL 1.50 because the value of this constant couldn't be
31595bd8deadSopenharmony_ci      known at CompileShader() time.  Using GLSL 1.50, a shader could extract
31605bd8deadSopenharmony_ci      the same value using "gl_in.length()" as long as the input primitive
31615bd8deadSopenharmony_ci      type was declared prior to the use of "length()".
31625bd8deadSopenharmony_ci
31635bd8deadSopenharmony_ci      This spec initially repurposed "gl_VerticesIn" for tessellation shaders
31645bd8deadSopenharmony_ci      to refer to the input "gl_PatchVerticesIn", but having a variable that
31655bd8deadSopenharmony_ci      was a constant in some shaders/#extension configurations and an input in
31665bd8deadSopenharmony_ci      others was confusing.
31675bd8deadSopenharmony_ci
31685bd8deadSopenharmony_ci    (26) Must per-vertex input variables be declared as arrays indexed by
31695bd8deadSopenharmony_ci         vertex number?  What syntax should be used in the declaration?
31705bd8deadSopenharmony_ci
31715bd8deadSopenharmony_ci      RESOLVED:  Yes, they must be declared as arrays or members of blocks
31725bd8deadSopenharmony_ci      declared as arrays.  We strongly recommend that shaders simply omit the
31735bd8deadSopenharmony_ci      vertex size; a default size will be injected automatically by the
31745bd8deadSopenharmony_ci      compiler.  For example, if each input patch vertex a vec3 named position
31755bd8deadSopenharmony_ci      an array of four vec2 values called "texcoords" and the implementation's
31765bd8deadSopenharmony_ci      maximum patch size is 32, any of the following declarations are legal.
31775bd8deadSopenharmony_ci
31785bd8deadSopenharmony_ci            in vec3 position[];
31795bd8deadSopenharmony_ci            in vec3 position[gl_MaxPatchVertices];
31805bd8deadSopenharmony_ci            in vec3 position[32];
31815bd8deadSopenharmony_ci            in TexCoords {
31825bd8deadSopenharmony_ci              vec2 coords[4];
31835bd8deadSopenharmony_ci            } tex[];
31845bd8deadSopenharmony_ci            in TexCoords {
31855bd8deadSopenharmony_ci              vec2 coords[4];
31865bd8deadSopenharmony_ci            } tex[gl_MaxPatchVertices];
31875bd8deadSopenharmony_ci            in TexCoords {
31885bd8deadSopenharmony_ci              vec2 coords[4];
31895bd8deadSopenharmony_ci            } tex[32];
31905bd8deadSopenharmony_ci
31915bd8deadSopenharmony_ci      Shaders using the "32" form won't be portable; they will break when run
31925bd8deadSopenharmony_ci      on any implementation that has a different patch size limit.  Shaders
31935bd8deadSopenharmony_ci      using "gl_MaxPatchVertices" will be portable, but there's no point in
31945bd8deadSopenharmony_ci      specifying a vertex count.  Just say no.
31955bd8deadSopenharmony_ci
31965bd8deadSopenharmony_ci    (27) Can tessellation shaders be run on primitives such as triangles or
31975bd8deadSopenharmony_ci         triangle strips?
31985bd8deadSopenharmony_ci
31995bd8deadSopenharmony_ci      RESOLVED:  Not directly.  However, if an application is drawing
32005bd8deadSopenharmony_ci      independent triangles using DrawElements, it can pass the same set of
32015bd8deadSopenharmony_ci      indices using PATCHES and a patch size of 3 vertices and use the
32025bd8deadSopenharmony_ci      tessellator normally.
32035bd8deadSopenharmony_ci
32045bd8deadSopenharmony_ci    (29) How does tessellation interact with PolygonMode?  Edge flags?
32055bd8deadSopenharmony_ci
32065bd8deadSopenharmony_ci      RESOLVED:  When the tessellation primitive generator decomposes a patch
32075bd8deadSopenharmony_ci      and emits triangles, each triangle will be drawn with all edge flags set
32085bd8deadSopenharmony_ci      to TRUE (as with regular TRIANGLE_STRIP primitives).  If the polygon
32095bd8deadSopenharmony_ci      mode is not FILL, each triangle will be drawn using points or lines, as
32105bd8deadSopenharmony_ci      with any other primitive.  PolygonMode and edge flags have no effect on
32115bd8deadSopenharmony_ci      point or line primitives, and will thus have no effect if a patch is
32125bd8deadSopenharmony_ci      used to generate points or isolines, or if the patch makes it to the
32135bd8deadSopenharmony_ci      rasterizer.
32145bd8deadSopenharmony_ci
32155bd8deadSopenharmony_ci    (30) Are any of the clamped/filtered gl_TessLevel values computed by the
32165bd8deadSopenharmony_ci         tessellation primitive generator available to tessellation evaluation
32175bd8deadSopenharmony_ci         shaders?
32185bd8deadSopenharmony_ci
32195bd8deadSopenharmony_ci      RESOLVED:  No, the only tessellation levels directly available to the
32205bd8deadSopenharmony_ci      tessellation evaluation shaders will be the raw values written by the
32215bd8deadSopenharmony_ci      tessellation control shaders or taken from default tessellation
32225bd8deadSopenharmony_ci      levels.  
32235bd8deadSopenharmony_ci
32245bd8deadSopenharmony_ci      If a tessellation evaluation shader requires clamped or rounded levels,
32255bd8deadSopenharmony_ci      it can perform the clamping itself.  Alternately, the clamped levels can
32265bd8deadSopenharmony_ci      be computed in the tessellation control patch shaders and passed to the
32275bd8deadSopenharmony_ci      evaluation shader using a per-patch output declared as "patch out".
32285bd8deadSopenharmony_ci
32295bd8deadSopenharmony_ci    (31) Should any of the patch parameters or the maximum input patch size
32305bd8deadSopenharmony_ci         parameter have a "TESS_" prefix?  
32315bd8deadSopenharmony_ci
32325bd8deadSopenharmony_ci      RESOLVED:  No.  These are properties of patches, not any tessellation
32335bd8deadSopenharmony_ci      units.  While patches may be commonly used for tessellation, they might
32345bd8deadSopenharmony_ci      also be used in the future by geometry shaders or transform feedback
32355bd8deadSopenharmony_ci      with no tessellation shaders present.
32365bd8deadSopenharmony_ci
32375bd8deadSopenharmony_ci    (32) How are primitives generated by the tessellator wound in (u,v) space?
32385bd8deadSopenharmony_ci         Can we wind in either direction, or is only one way supported?  At
32395bd8deadSopenharmony_ci         the very least, we should guarantee that the winding is internally
32405bd8deadSopenharmony_ci         consistent.
32415bd8deadSopenharmony_ci
32425bd8deadSopenharmony_ci      RESOLVED:  We will support both clockwise and counter-clockwise winding
32435bd8deadSopenharmony_ci      in the normalized (u,v) space, where the winding can be specified using
32445bd8deadSopenharmony_ci      a layout qualifier.  Note that the final position of the vertices are
32455bd8deadSopenharmony_ci      computed in the tessellation evaluation shader, and a triangle that is
32465bd8deadSopenharmony_ci      counter-clockwise in (u,v) space may end up clockwise in screen space.
32475bd8deadSopenharmony_ci
32485bd8deadSopenharmony_ci    (35) Tessellation evaluation shaders have a fixed input patch size if a
32495bd8deadSopenharmony_ci         tessellation control shader is present, but a variable input patch
32505bd8deadSopenharmony_ci         size otherwise.  Is that a problem?
32515bd8deadSopenharmony_ci
32525bd8deadSopenharmony_ci      RESOLVED:  No, we don't think so.
32535bd8deadSopenharmony_ci
32545bd8deadSopenharmony_ci    (36) How do patches interact with primitive restart indices?
32555bd8deadSopenharmony_ci
32565bd8deadSopenharmony_ci      RESOLVED:  Primitive restart terminates the existing patch and start a
32575bd8deadSopenharmony_ci      new one, just like any other primitive.  Since we only support
32585bd8deadSopenharmony_ci      independent patch primitives, primtive restart with patches is every bit
32595bd8deadSopenharmony_ci      as pointless as it is with independent point, line, triangle, and quad
32605bd8deadSopenharmony_ci      primitives.
32615bd8deadSopenharmony_ci
32625bd8deadSopenharmony_ci    (37) Should the default tessellation levels be used automatically if they
32635bd8deadSopenharmony_ci         are not written by the tessellation control shader?
32645bd8deadSopenharmony_ci
32655bd8deadSopenharmony_ci      RESOLVED:  No.  If you don't write tessellation levels in a tessellation
32665bd8deadSopenharmony_ci      control patch shader, they will be undefined.  If an application really
32675bd8deadSopenharmony_ci      want a "default" tessellation level in conjunction with the tessellation
32685bd8deadSopenharmony_ci      control shader, it can simply copy one from a uniform.
32695bd8deadSopenharmony_ci
32705bd8deadSopenharmony_ci    (40) How does tessellation interact with rasterization features such as
32715bd8deadSopenharmony_ci         flat shading and stippled lines?  How are the vertices produced by
32725bd8deadSopenharmony_ci         the tessellator presented to the geometry shader, if one is present?
32735bd8deadSopenharmony_ci
32745bd8deadSopenharmony_ci      RESOLVED:  For quad and triangle tessellation, a set of independent
32755bd8deadSopenharmony_ci      triangles is generated by the tessellation primitive generator.  For
32765bd8deadSopenharmony_ci      isoline tessellation, a set of independent lines is generated.  In both
32775bd8deadSopenharmony_ci      cases, the order in which the triangles or lines are drawn is undefined.
32785bd8deadSopenharmony_ci      Additionally, the order of vertices in the triangles or lines are also
32795bd8deadSopenharmony_ci      undefined.  The only thing that is defined is that when triangles are
32805bd8deadSopenharmony_ci      generated, their winding will be consistent with the "cw" or "ccw"
32815bd8deadSopenharmony_ci      layout qualifer.
32825bd8deadSopenharmony_ci
32835bd8deadSopenharmony_ci      As a result, using flat shading and line stipple with tessellation
32845bd8deadSopenharmony_ci      shaders may not produce regular results given that the first vertex
32855bd8deadSopenharmony_ci      (resetting stipple) and last vertex (provoking vertex for flat shading)
32865bd8deadSopenharmony_ci      of each primitive are undefined.  Additionally, the order of vertices
32875bd8deadSopenharmony_ci      presented to a geometry shader will not be predictable.  All of these
32885bd8deadSopenharmony_ci      features will work with tessellation; they just won't produce results
32895bd8deadSopenharmony_ci      that are as regular as what you'd get decomposing a patch into a set of
32905bd8deadSopenharmony_ci      triangle strips.
32915bd8deadSopenharmony_ci
32925bd8deadSopenharmony_ci      Note that for the isoline tessellation, while the line segments appear
32935bd8deadSopenharmony_ci      to be arranged in strips, they are rendered as independent segments and
32945bd8deadSopenharmony_ci      have their stipple reset at the beginning of each segment.
32955bd8deadSopenharmony_ci
32965bd8deadSopenharmony_ci    (41) Tessellation control shaders declare per-vertex outputs as arrays or
32975bd8deadSopenharmony_ci         members of block arrays indexed by vertex number.  However, we only
32985bd8deadSopenharmony_ci         allow each thread to write per-vertex outputs for its own vertex.
32995bd8deadSopenharmony_ci         How should we impose this restriction?
33005bd8deadSopenharmony_ci
33015bd8deadSopenharmony_ci       RESOLVED:  The current specification requires that the value of the
33025bd8deadSopenharmony_ci       expression used as a vertex input must be the identifier
33035bd8deadSopenharmony_ci       "gl_InvocationID".  This does mean that even trivially equivalent
33045bd8deadSopenharmony_ci       expressions such as "(gl_InvocationID)" or "glInvocationID + 0" should
33055bd8deadSopenharmony_ci       not be accepted by the compiler.
33065bd8deadSopenharmony_ci
33075bd8deadSopenharmony_ci       We considered allowing compilers to accept equivalent expressions like
33085bd8deadSopenharmony_ci       "(gl_InvocationID)", "(gl_InvocationID + 0)", or a temporary variable
33095bd8deadSopenharmony_ci       assigned the value of "gl_InvocationID".  We also considered allowing
33105bd8deadSopenharmony_ci       any expression, with undefined behavior if the value of the index
33115bd8deadSopenharmony_ci       turned out to not be equal to "gl_InvocationID".  We chose to have a
33125bd8deadSopenharmony_ci       stronger restriction to avoid undefined behavior and errors that
33135bd8deadSopenharmony_ci       depending on specific compiler behavior.
33145bd8deadSopenharmony_ci
33155bd8deadSopenharmony_ci       Applications not wishing to use the string "gl_InvocationID" can use
33165bd8deadSopenharmony_ci       the #define preprocessor feature to define an alternate name.
33175bd8deadSopenharmony_ci
33185bd8deadSopenharmony_ci    (42) What restrictions should apply to the barrier() built-in?
33195bd8deadSopenharmony_ci
33205bd8deadSopenharmony_ci      RESOLVED:  Given that the barrier() function must be reached by all
33215bd8deadSopenharmony_ci      threads before any thread continues, it would be possible for shader
33225bd8deadSopenharmony_ci      thread groups to hang if any thread in the group never reaches the
33235bd8deadSopenharmony_ci      barrier because of conditional flow control.
33245bd8deadSopenharmony_ci
33255bd8deadSopenharmony_ci      We would prefer not to provide a mechanism allowing improperly-coded
33265bd8deadSopenharmony_ci      shaders to hang, so it would be necessary to rely on compiler analysis
33275bd8deadSopenharmony_ci      to prevent the use of barrier() in places where it isn't safe, which
33285bd8deadSopenharmony_ci      would include:
33295bd8deadSopenharmony_ci
33305bd8deadSopenharmony_ci        * calls within "if" or "else" substatements of an if statement,
33315bd8deadSopenharmony_ci
33325bd8deadSopenharmony_ci        * calls within "do", "for", or "while" loops if the number of loop
33335bd8deadSopenharmony_ci          iterations is not known to be uniform, or if any thread may execute
33345bd8deadSopenharmony_ci          a "continue" or "break" statement,
33355bd8deadSopenharmony_ci
33365bd8deadSopenharmony_ci        * calls within functions called directly or indirectly by main() in
33375bd8deadSopenharmony_ci          cases any call in the chain is in conditional code, and
33385bd8deadSopenharmony_ci
33395bd8deadSopenharmony_ci        * calls within the main() entrypoint issued after one or more threads
33405bd8deadSopenharmony_ci          have executed a "return" statement.
33415bd8deadSopenharmony_ci
33425bd8deadSopenharmony_ci      Relying on such analysis on fully general shader code may be fragile and
33435bd8deadSopenharmony_ci      difficult to replicate uniformly across all compiler implementations.
33445bd8deadSopenharmony_ci      As a result, we choose a heavy-handed approach in which we only allow
33455bd8deadSopenharmony_ci      calls to barrier() inside main().  Even within main, barrier() calls are
33465bd8deadSopenharmony_ci      forbidden inside loops (even those that turn out to have constant loop
33475bd8deadSopenharmony_ci      counts and don't execute "break" or "continue" statements), if
33485bd8deadSopenharmony_ci      statements, or after a return statement.
33495bd8deadSopenharmony_ci
33505bd8deadSopenharmony_ci    (43) Why provide a limit on the maximum number of components (both
33515bd8deadSopenharmony_ci         per-vertex and per-patch) emitted by a tessellation control shader,
33525bd8deadSopenharmony_ci         i.e.  MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS?
33535bd8deadSopenharmony_ci
33545bd8deadSopenharmony_ci      RESOLVED:  We expect that some implementations of this extension might
33555bd8deadSopenharmony_ci      have a fixed limit on output buffering that may not not allow the
33565bd8deadSopenharmony_ci      combined use of a maximum number of per-patch and per-vertex attributes.
33575bd8deadSopenharmony_ci
33585bd8deadSopenharmony_ci    (44) What is the meaning of a "vertex shader" inside a pipeline with
33595bd8deadSopenharmony_ci         tessellation enabled?
33605bd8deadSopenharmony_ci
33615bd8deadSopenharmony_ci      RESOLVED:  There are two different types of "vertex" when tessellation
33625bd8deadSopenharmony_ci      is involved.  We have the vertices of the input patch, and we have the
33635bd8deadSopenharmony_ci      vertices generated by the tessellation primitive generator.  If one
33645bd8deadSopenharmony_ci      considers "vertices" to be points used to control rasterized primitives,
33655bd8deadSopenharmony_ci      the former may be more reasonably considered "control points", since
33665bd8deadSopenharmony_ci      they typically won't be used as-in in primitives sent to the rasterizer.
33675bd8deadSopenharmony_ci      Additionally, operations typically performed in a vertex shader
33685bd8deadSopenharmony_ci      (lighting, texture coordinate generation) may instead be performed by a
33695bd8deadSopenharmony_ci      after evaluating the position and normal in the tessellation evaluation
33705bd8deadSopenharmony_ci      shader.  In such a world view, one might rename the pipeline stage
33715bd8deadSopenharmony_ci      typically called "vertex shader" when tessellation is disabled to be a
33725bd8deadSopenharmony_ci      "control point shader" stage.  A logically separate pipeline stage with
33735bd8deadSopenharmony_ci      a lot in common with existing vertex shaders would be run after the
33745bd8deadSopenharmony_ci      tessellation evaluation shader.
33755bd8deadSopenharmony_ci
33765bd8deadSopenharmony_ci      This extension chooses not to adopt the above approach, however.  While
33775bd8deadSopenharmony_ci      a post-tessellation vertex shader may have a lot in common with the
33785bd8deadSopenharmony_ci      vertex shader used without tessellation, it's not likely that the shader
33795bd8deadSopenharmony_ci      code used in these two cases will be completely identical.  In
33805bd8deadSopenharmony_ci      particular, the vertex positions and normals computed by the
33815bd8deadSopenharmony_ci      tessellation coordinate shader will likely be in a different coordinate
33825bd8deadSopenharmony_ci      system than the "object space" positions and normals used for vanilla
33835bd8deadSopenharmony_ci      vertex shaders.  The linkage between the two types of vertex shader and
33845bd8deadSopenharmony_ci      the previous stage are also very different -- post-tessellation vertex
33855bd8deadSopenharmony_ci      shaders would get their inputs from the outputs of the tessellation
33865bd8deadSopenharmony_ci      evaluation shader; "normal" vertex shaders get their inputs from vertex
33875bd8deadSopenharmony_ci      attribute arrays specified with the OpenGL API.  Additionally, allowing
33885bd8deadSopenharmony_ci      a vertex shader to live at the beginning or middle of the pipeline would
33895bd8deadSopenharmony_ci      have problems if/when OpenGL releases the monolithic single program
33905bd8deadSopenharmony_ci      model in the current GLSL API.  In such an API, it would be necessary to
33915bd8deadSopenharmony_ci      generate code for a vertex shader without knowledge of whether it would
33925bd8deadSopenharmony_ci      be run with or without tessellation.  
33935bd8deadSopenharmony_ci
33945bd8deadSopenharmony_ci      In the model we do expose, developers need to keep in mind that with
33955bd8deadSopenharmony_ci      tessellation:
33965bd8deadSopenharmony_ci
33975bd8deadSopenharmony_ci        * vertex shaders are run on control points, not post-tessellation
33985bd8deadSopenharmony_ci          vertices, and
33995bd8deadSopenharmony_ci
34005bd8deadSopenharmony_ci        * many of the vertex processing operations typically performed by the
34015bd8deadSopenharmony_ci          vertex shader will be performed by the tessellation evaluation
34025bd8deadSopenharmony_ci          shader.
34035bd8deadSopenharmony_ci
34045bd8deadSopenharmony_ci      It may be possible to share some or all portions of existing vertex
34055bd8deadSopenharmony_ci      shader code verbatim with the tessellation evaluation shaders via clever
34065bd8deadSopenharmony_ci      use of #ifdefs or multiple shader objects.  Additionally, higher-level
34075bd8deadSopenharmony_ci      shader or effects libraries may be able to expose a different pipeline
34085bd8deadSopenharmony_ci      configuration as long as they generate code and shader/program objects
34095bd8deadSopenharmony_ci      that fit the existing pipeline.
34105bd8deadSopenharmony_ci
34115bd8deadSopenharmony_ci    (45) Should we provide the ability for the implementation to automatically
34125bd8deadSopenharmony_ci         generate a "pass-through" vertex shader, effectively making vertex
34135bd8deadSopenharmony_ci         shaders optional when tessellating.  In some tessellation algorithms,
34145bd8deadSopenharmony_ci         the bulk of the work will be done in the tessellation control and
34155bd8deadSopenharmony_ci         evaluation shaders, and the vertex shader will have little or no
34165bd8deadSopenharmony_ci         interesting work to do.
34175bd8deadSopenharmony_ci
34185bd8deadSopenharmony_ci      RESOLVED:  Not in this extension.  This functionality might be useful,
34195bd8deadSopenharmony_ci      but making such a change would have significant impact.  First, there
34205bd8deadSopenharmony_ci      would be quite a bit of text to rewrite regarding vertex attributes, all
34215bd8deadSopenharmony_ci      of which is now in the "vertex shader" section but might want to be done
34225bd8deadSopenharmony_ci      more neutrally.  Additionally, the input variables for
34235bd8deadSopenharmony_ci      tessellation/geometry shaders would presumably now receive vertex
34245bd8deadSopenharmony_ci      attributes.  However, TCS/TES/GS can have inputs that are not supported
34255bd8deadSopenharmony_ci      as equivalent vertex shader inputs.  In particular, structures are
34265bd8deadSopenharmony_ci      allowed as inputs in TCS/TES/GS, but not in VS.  This probably has
34275bd8deadSopenharmony_ci      further impact on the vertex attribute language.  We chose to leave out
34285bd8deadSopenharmony_ci      this functionality for simplicity.
34295bd8deadSopenharmony_ci
34305bd8deadSopenharmony_ci    (46) Should we reserve "patch" as a keyword for per-patch input
34315bd8deadSopenharmony_ci         qualifiers, or use something more obscure, such as "per_patch"?
34325bd8deadSopenharmony_ci         Whatever keyword we choose, should it be reserved in all languages or
34335bd8deadSopenharmony_ci         just tessellation control and evaluation?
34345bd8deadSopenharmony_ci
34355bd8deadSopenharmony_ci      RESOLVED:  This extension uses "patch".
34365bd8deadSopenharmony_ci
34375bd8deadSopenharmony_ci    (47) Should we allow tessellation control or evaluation inputs and outputs
34385bd8deadSopenharmony_ci         to be declared as "centroid in" or "centroid out", or with
34395bd8deadSopenharmony_ci         interpolation modifiers, even if those variables aren't being
34405bd8deadSopenharmony_ci         interpolated?
34415bd8deadSopenharmony_ci
34425bd8deadSopenharmony_ci      RESOLVED:  Yes.  This allows for mix-and-match linkage where you can
34435bd8deadSopenharmony_ci      feed an output from a single vertex shader to a fragment shader in one
34445bd8deadSopenharmony_ci      program and a tessellation/geometry shader in another.  The shading
34455bd8deadSopenharmony_ci      language requires that variables on each interface match in type and
34465bd8deadSopenharmony_ci      qualification.  Therefore, if a fragment shader input is declared as
34475bd8deadSopenharmony_ci      "centroid in", the vertex shader output must be declared similarly.
34485bd8deadSopenharmony_ci      When used on inputs in tessellation control, tessellation evaluation,
34495bd8deadSopenharmony_ci      and geometry shaders, "centroid" and any other interpolation modifiers
34505bd8deadSopenharmony_ci      have no effect.
34515bd8deadSopenharmony_ci
34525bd8deadSopenharmony_ci    (48) Should we provide a tessellation spacing mode where the tessellation
34535bd8deadSopenharmony_ci         levels are snapped to powers of two?
34545bd8deadSopenharmony_ci
34555bd8deadSopenharmony_ci      RESOLVED:  No.  Such a mode would be useful to avoid motion of generated
34565bd8deadSopenharmony_ci      vertices as the tessellation levels change.  When using a power of two,
34575bd8deadSopenharmony_ci      an increasing tessellation level snaps from 2 to 4 to 8 to 16.  In each
34585bd8deadSopenharmony_ci      transition, the <n> existing points generated by the tessellator on each
34595bd8deadSopenharmony_ci      edge don't move -- new vertices are introduced at the midpoint of each
34605bd8deadSopenharmony_ci      old edge in the subdivision.
34615bd8deadSopenharmony_ci
34625bd8deadSopenharmony_ci      Applications can implement this behavior themselves by manually snapping
34635bd8deadSopenharmony_ci      the levels of detail they compute in the tessellation control shader.
34645bd8deadSopenharmony_ci
34655bd8deadSopenharmony_ci    (49) Should we make clockwise/counter-clockwise winding of tessellation
34665bd8deadSopenharmony_ci         output program state or context state?
34675bd8deadSopenharmony_ci
34685bd8deadSopenharmony_ci      RESOLVED:  Program state, for simplicity.  Making it program state means
34695bd8deadSopenharmony_ci      that if an application wants to use the same tessellation evaluation
34705bd8deadSopenharmony_ci      shader with different winding orders, it would need to generate two
34715bd8deadSopenharmony_ci      separate programs/tessellation evaluation shaders.  This doesn't seem to
34725bd8deadSopenharmony_ci      be a significant enough usage case to justify the overhead of having to
34735bd8deadSopenharmony_ci      program a separate piece of tessellation state.
34745bd8deadSopenharmony_ci
34755bd8deadSopenharmony_ci      Note that applications that want to use the same program with different
34765bd8deadSopenharmony_ci      windings can work around this limitation by toggling the FrontFace API
34775bd8deadSopenharmony_ci      state as required.  Counter-clockwise primitives with FrontFace set to
34785bd8deadSopenharmony_ci      CCW will generally be indistinguishable from clockwise primitives with
34795bd8deadSopenharmony_ci      FrontFace set to CW.  The only limitation of this approach is that it
34805bd8deadSopenharmony_ci      doesn't affect the winding of primitives captured by transform feedback.
34815bd8deadSopenharmony_ci
34825bd8deadSopenharmony_ci   (50) Tessellation using "point_mode" is supposed to emit each distinct
34835bd8deadSopenharmony_ci        vertex produced by the tessellation primitive generator exactly once.
34845bd8deadSopenharmony_ci        Are there cases where this can produce multiple vertices with the same
34855bd8deadSopenharmony_ci        position?
34865bd8deadSopenharmony_ci
34875bd8deadSopenharmony_ci      RESOLVED:  Yes.  If fractional odd spacing is used, we have outer
34885bd8deadSopenharmony_ci      tessellation levels that are greater than 1.0, and inner tessellation
34895bd8deadSopenharmony_ci      levels less than or equal to 1.0, this can occur.  If any outer level is
34905bd8deadSopenharmony_ci      greater than 1.0, we will subdivide the outer edges of the patch, and
34915bd8deadSopenharmony_ci      will need a subdivided patch interior to connect to.  We handle this by
34925bd8deadSopenharmony_ci      treating inner levels less than or equal to 1.0 as though they were
34935bd8deadSopenharmony_ci      slightly greater than 1.0 ("1+epsilon").
34945bd8deadSopenharmony_ci
34955bd8deadSopenharmony_ci      With fractional odd spacing, inner levels between 1.0 and 3.0 will
34965bd8deadSopenharmony_ci      produce a three-segment subdivision, with one full-size interior segment
34975bd8deadSopenharmony_ci      and two smaller ones on the outside.  The following figure illustrates
34985bd8deadSopenharmony_ci      what happens to quad tessellation if the horizontal inner LOD (IL0) goes
34995bd8deadSopenharmony_ci      from 3.0 toward 1.0 in fractional odd mode:
35005bd8deadSopenharmony_ci
35015bd8deadSopenharmony_ci             IL0==3         IL0==2         IL0=1.5       IL0=1.2
35025bd8deadSopenharmony_ci          +-----------+  +-----------+  +-----------+  +-----------+
35035bd8deadSopenharmony_ci          |           |  |           |  |           |  |           |
35045bd8deadSopenharmony_ci          |   +---+   |  |  +-----+  |  | +-------+ |  |+---------+|
35055bd8deadSopenharmony_ci          |   |   |   |  |  |     |  |  | |       | |  ||         ||
35065bd8deadSopenharmony_ci          |   |   |   |  |  |     |  |  | |       | |  ||         ||
35075bd8deadSopenharmony_ci          |   +---+   |  |  +-----+  |  | +-------+ |  |+---------+|
35085bd8deadSopenharmony_ci          |           |  |           |  |           |  |           |
35095bd8deadSopenharmony_ci          +-----------+  +-----------+  +-----------+  +-----------+
35105bd8deadSopenharmony_ci
35115bd8deadSopenharmony_ci      As the inner level approaches 1.0, the vertical inner edges in this
35125bd8deadSopenharmony_ci      example get closer and closer to the outer edge.  The distance between
35135bd8deadSopenharmony_ci      the inner and outer vertical edges approaches zero for an inner level of
35145bd8deadSopenharmony_ci      1+epsilon, and the positions of vertices produced by subdividing such
35155bd8deadSopenharmony_ci      edges may be numerically indistinguishable.
35165bd8deadSopenharmony_ci
35175bd8deadSopenharmony_ciRevision History
35185bd8deadSopenharmony_ci
35195bd8deadSopenharmony_ci    Rev.    Date    Author    Changes
35205bd8deadSopenharmony_ci    ----  --------  --------- -----------------------------------------
35215bd8deadSopenharmony_ci     23   09/17/19  Jon Leech Fix typo in quad tessellation language
35225bd8deadSopenharmony_ci                              (internal API issue 113).
35235bd8deadSopenharmony_ci     22   04/21/15  Jon Leech Allow user-defined TCS input and output,
35245bd8deadSopenharmony_ci                              and TES input variable array size mismatches
35255bd8deadSopenharmony_ci                              to be detected at compile as well as link time
35265bd8deadSopenharmony_ci                              (Bug 12185).
35275bd8deadSopenharmony_ci
35285bd8deadSopenharmony_ci     21   04/20/15  Jon Leech Remove "per-patch" part of description of
35295bd8deadSopenharmony_ci                              MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS
35305bd8deadSopenharmony_ci                              (Bug 13765).
35315bd8deadSopenharmony_ci
35325bd8deadSopenharmony_ci     20   04/25/14  pbrown    Clarify that the tessellation primitive
35335bd8deadSopenharmony_ci                              generator may produce multiple vertices with 
35345bd8deadSopenharmony_ci                              the same gl_TessCoord values in point mode when
35355bd8deadSopenharmony_ci                              fractional odd spacing is used with an inner
35365bd8deadSopenharmony_ci                              tessellation level less than or equal to 1.0
35375bd8deadSopenharmony_ci                              (bug 11979).
35385bd8deadSopenharmony_ci
35395bd8deadSopenharmony_ci     19   10/25/12  pbrown    Update spec language describing tessellation of
35405bd8deadSopenharmony_ci                              isolines.  Fix the inconsistent/incorrect
35415bd8deadSopenharmony_ci                              language describing the handling of tessellation
35425bd8deadSopenharmony_ci                              levels -- outer level 0 controls the number of
35435bd8deadSopenharmony_ci                              isolines generated and outer level 1 controls
35445bd8deadSopenharmony_ci                              the number of segements in each isoline (bug
35455bd8deadSopenharmony_ci                              9195/9607).  Minor isoline tessellation wording
35465bd8deadSopenharmony_ci                              fixes for improved clarity.
35475bd8deadSopenharmony_ci
35485bd8deadSopenharmony_ci     18   03/29/10  pbrown    Update issues (42), (46), and (47).
35495bd8deadSopenharmony_ci
35505bd8deadSopenharmony_ci     17   03/22/10  pbrown    Minor corrections to the Dependencies section.
35515bd8deadSopenharmony_ci
35525bd8deadSopenharmony_ci     16   01/29/10  pbrown    Updates from ARB review (bug 5905).  In
35535bd8deadSopenharmony_ci                              particular, we again allow only the token
35545bd8deadSopenharmony_ci                              "gl_Invocation" for indexing TCS outputs,
35555bd8deadSopenharmony_ci                              reversing changes in version 7.  Added some
35565bd8deadSopenharmony_ci                              clarifications to barrier().  Increased minimum
35575bd8deadSopenharmony_ci                              value of gl_MaxCombinedTextureImageUnits.
35585bd8deadSopenharmony_ci
35595bd8deadSopenharmony_ci     15   01/26/10  pbrown    Reflow some ragged paragraphs.
35605bd8deadSopenharmony_ci
35615bd8deadSopenharmony_ci     14   01/20/10  Jon Leech Make behavior, not just results undefined
35625bd8deadSopenharmony_ci                              when reading gl_in beyond the number of
35635bd8deadSopenharmony_ci                              vertices in the input patch (Bug 5880).
35645bd8deadSopenharmony_ci
35655bd8deadSopenharmony_ci     13   01/20/10  pbrown    Clarify the required minimum values for
35665bd8deadSopenharmony_ci                              MAX_COMBINED_*_UNIFORM_COMPONENTS (bug 5919).
35675bd8deadSopenharmony_ci
35685bd8deadSopenharmony_ci     12   01/14/10  Jon Leech Remove erroneous reference to triangles from
35695bd8deadSopenharmony_ci                              tesselation control shader input language
35705bd8deadSopenharmony_ci                              (Bug 5881).
35715bd8deadSopenharmony_ci
35725bd8deadSopenharmony_ci     11   01/14/10  pbrown    Minor clarifications from spec reviews.  Add
35735bd8deadSopenharmony_ci                              missing edits for gl_InvocationID changes from
35745bd8deadSopenharmony_ci                              version 7.
35755bd8deadSopenharmony_ci
35765bd8deadSopenharmony_ci     10   12/14/09  pbrown    Rename "gl_VerticesIn" to "gl_PatchVerticesIn"
35775bd8deadSopenharmony_ci                              to avoid collision with the EXT_geometry_shader4
35785bd8deadSopenharmony_ci                              variable of the same name.  Add language
35795bd8deadSopenharmony_ci                              clarifying the size applied to unsized input
35805bd8deadSopenharmony_ci                              arrays for tessellation control and evaluation
35815bd8deadSopenharmony_ci                              shaders.
35825bd8deadSopenharmony_ci
35835bd8deadSopenharmony_ci      9   12/10/09  pbrown    Rename the layout qualifiers for vertex order to 
35845bd8deadSopenharmony_ci                              "cw" and "ccw".  Minor changes to invariance
35855bd8deadSopenharmony_ci                              rules, including addition of a rule guaranteeing
35865bd8deadSopenharmony_ci                              that <x> + (1-<x>) is exactly 1.0 for
35875bd8deadSopenharmony_ci                              gl_TessCoord components.
35885bd8deadSopenharmony_ci
35895bd8deadSopenharmony_ci      8   12/10/09  pbrown    Convert from EXT to ARB.
35905bd8deadSopenharmony_ci
35915bd8deadSopenharmony_ci      7   12/09/09  pbrown    Miscellaneous fixes from spec review:  Added a
35925bd8deadSopenharmony_ci                              new invariance section describing a set of
35935bd8deadSopenharmony_ci                              hopefully useful rules for tessellation.
35945bd8deadSopenharmony_ci                              Slightly relaxed the rules requiring
35955bd8deadSopenharmony_ci                              gl_InvocationID for TCS per-vertex outputs.
35965bd8deadSopenharmony_ci                              Cleaned up language on primitive generation and
35975bd8deadSopenharmony_ci                              when outputs are defined in TCS w.r.t. barrier.
35985bd8deadSopenharmony_ci                              General typo fixes and language clarifications.
35995bd8deadSopenharmony_ci
36005bd8deadSopenharmony_ci      6   11/02/09  pbrown    Fix cut-and-paste error in the definition of
36015bd8deadSopenharmony_ci                              gl_PrimitiveID.
36025bd8deadSopenharmony_ci
36035bd8deadSopenharmony_ci      5   10/23/09  pbrown    Change the name of one GLSL constant to
36045bd8deadSopenharmony_ci                              gl_MaxTessPatchComponents (was "TessControl")
36055bd8deadSopenharmony_ci                              to match the API constant name.  This limit
36065bd8deadSopenharmony_ci                              also applies to evaluation shaders.
36075bd8deadSopenharmony_ci
36085bd8deadSopenharmony_ci      4   10/13/09  pbrown    Minor typo fixes.
36095bd8deadSopenharmony_ci
36105bd8deadSopenharmony_ci      3   10/01/09  pbrown    Renamed some of the tessellation evaluation
36115bd8deadSopenharmony_ci                              shader input layout qualifiers to more closely
36125bd8deadSopenharmony_ci                              match geometry shader conventions.  Renamed
36135bd8deadSopenharmony_ci                              gl_ThreadID to gl_InvocationID.  Fixed one 
36145bd8deadSopenharmony_ci                              reference to an old layout qualifier name.
36155bd8deadSopenharmony_ci
36165bd8deadSopenharmony_ci      2   09/28/09  pbrown    Typo fix.
36175bd8deadSopenharmony_ci
36185bd8deadSopenharmony_ci      1             pbrown    Internal revisions.
36195bd8deadSopenharmony_ci
3620