• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_tessellation_shader
4
5Name Strings
6
7    GL_EXT_tessellation_shader
8    GL_EXT_tessellation_point_size
9
10Contact
11
12    Jon Leech (oddhack 'at' sonic.net)
13    Daniel Koch, NVIDIA (dkoch 'at' nvidia.com)
14
15Contributors
16
17    Daniel Koch, NVIDIA (dkoch 'at' nvidia.com)
18    Pat Brown, NVIDIA (pbrown 'at' nvidia.com)
19    Bill Licea-Kane, Qualcomm (billl 'at' qti.qualcomm.com)
20    Jesse Hall, Google (jessehall 'at' google.com)
21    Dominik Witczak, Mobica
22    Jan-Harald Fredriksen, ARM
23    Maurice Ribble, Qualcomm
24    Vineet Goel, Qualcomm
25    Alex Chalfin, ARM
26    Graham Connor, Imagination
27    Ben Bowman, Imagination
28    Jonathan Putsman, Imagination
29    Slawomir Grajewski, Intel
30    Contributors to ARB_tessellation_shader
31
32Notice
33
34    Copyright (c) 2010-2016 The Khronos Group Inc. Copyright terms at
35        http://www.khronos.org/registry/speccopyright.html
36
37    Portions Copyright (c) 2013-2014 NVIDIA Corporation.
38
39Status
40
41    Complete.
42
43Version
44
45    Last Modified Date: February 3, 2017
46    Revision: 24
47
48Number
49
50    OpenGL ES Extension #181
51
52Dependencies
53
54    OpenGL ES 3.1 and OpenGL ES Shading Language 3.10 are required.
55
56    This specification is written against the OpenGL ES 3.1 (March 17, 2014)
57    and OpenGL ES 3.10 Shading Language (March 17, 2014) Specifications.
58
59    EXT_geometry_shader is required in order to share language modifying the
60    OpenGL ES 3.1 specifications, which would otherwise have to be repeated
61    here.
62
63    EXT_shader_io_blocks is required.
64
65    EXT_gpu_shader5 is required.
66
67    This extension interacts with OES_shader_multisample_interpolation.
68
69Overview
70
71    This extension introduces new tessellation stages and two new shader types
72    to the OpenGL ES primitive processing pipeline.  These pipeline stages
73    operate on a new basic primitive type, called a patch.  A patch consists
74    of a fixed-size collection of vertices, each with per-vertex attributes,
75    plus a number of associated per-patch attributes.  Tessellation control
76    shaders transform an input patch specified by the application, computing
77    per-vertex and per-patch attributes for a new output patch.  A
78    fixed-function tessellation primitive generator subdivides the patch, and
79    tessellation evaluation shaders are used to compute the position and
80    attributes of each vertex produced by the tessellator.
81
82    When tessellation is active, it begins by running the optional
83    tessellation control shader.  This shader consumes an input patch and
84    produces a new fixed-size output patch.  The output patch consists of an
85    array of vertices, and a set of per-patch attributes.  The per-patch
86    attributes include tessellation levels that control how finely the patch
87    will be tessellated.  For each patch processed, multiple tessellation
88    control shader invocations are performed -- one per output patch vertex.
89    Each tessellation control shader invocation writes all the attributes of
90    its corresponding output patch vertex.  A tessellation control shader may
91    also read the per-vertex outputs of other tessellation control shader
92    invocations, as well as read and write shared per-patch outputs.  The
93    tessellation control shader invocations for a single patch effectively run
94    as a group.  A built-in barrier() function is provided to allow
95    synchronization points where no shader invocation will continue until all
96    shader invocations have reached the barrier.
97
98    The tessellation primitive generator then decomposes a patch into a new
99    set of primitives using the tessellation levels to determine how finely
100    tessellated the output should be.  The primitive generator begins with
101    either a triangle or a quad, and splits each outer edge of the primitive
102    into a number of segments approximately equal to the corresponding element
103    of the outer tessellation level array.  The interior of the primitive is
104    tessellated according to elements of the inner tessellation level array.
105    The primitive generator has three modes:  "triangles" and "quads" split a
106    triangular or quad-shaped patch into a set of triangles that cover the
107    original patch; "isolines" splits a quad-shaped patch into a set of line
108    strips running across the patch horizontally.  Each vertex generated by
109    the tessellation primitive generator is assigned a (u,v) or (u,v,w)
110    coordinate indicating its relative location in the subdivided triangle or
111    quad.
112
113    For each vertex produced by the tessellation primitive generator, the
114    tessellation evaluation shader is run to compute its position and other
115    attributes of the vertex, using its (u,v) or (u,v,w) coordinate.  When
116    computing final vertex attributes, the tessellation evaluation shader can
117    also read the attributes of any of the vertices of the patch written by
118    the tessellation control shader.  Tessellation evaluation shader
119    invocations are completely independent, although all invocations for a
120    single patch share the same collection of input vertices and per-patch
121    attributes.
122
123    The tessellator operates on vertices after they have been transformed by a
124    vertex shader.  The primitives generated by the tessellator are passed
125    further down the OpenGL ES pipeline, where they can be used as inputs to
126    geometry shaders, transform feedback, and the rasterizer.
127
128    The tessellation control and evaluation shaders are both optional.  If
129    neither shader type is present, the tessellation stage has no effect.
130    However, if either a tessellation control or a tessellation evaluation
131    shader is present, the other must also be present.
132
133    Not all tessellation shader implementations have the ability to write the
134    point size from a tessellation shader. Thus a second extension string and
135    shading language enable are provided for implementations which do
136    support tessellation shader point size.
137
138    This extension relies on the EXT_shader_io_blocks extension to provide
139    the required functionality for declaring input and output blocks and
140    interfacing between shaders.
141
142    This extension relies on the EXT_gpu_shader5 extension to provide the
143    'precise' and 'fma' functionality which are necessary to ensure crack-free
144    tessellation.
145
146IP Status
147
148    No known IP claims.
149
150New Procedures and Functions
151
152      void PatchParameteriEXT(enum pname, int value);
153
154New Tokens
155
156    Accepted by the <mode> parameter of DrawArrays, DrawElements,
157    and other commands which draw primitives:
158
159        PATCHES_EXT                                         0xE
160
161    Accepted by the <pname> parameter of PatchParameteriEXT, GetBooleanv,
162    GetFloatv, GetIntegerv, and GetInteger64v:
163
164        PATCH_VERTICES_EXT                                  0x8E72
165
166    Accepted by the <pname> parameter of GetProgramiv:
167
168        TESS_CONTROL_OUTPUT_VERTICES_EXT                    0x8E75
169        TESS_GEN_MODE_EXT                                   0x8E76
170        TESS_GEN_SPACING_EXT                                0x8E77
171        TESS_GEN_VERTEX_ORDER_EXT                           0x8E78
172        TESS_GEN_POINT_MODE_EXT                             0x8E79
173
174    Returned by GetProgramiv when <pname> is TESS_GEN_MODE_EXT:
175
176        TRIANGLES
177        ISOLINES_EXT                                        0x8E7A
178        QUADS_EXT                                           0x0007
179
180    Returned by GetProgramiv when <pname> is TESS_GEN_SPACING_EXT:
181
182        EQUAL
183        FRACTIONAL_ODD_EXT                                  0x8E7B
184        FRACTIONAL_EVEN_EXT                                 0x8E7C
185
186    Returned by GetProgramiv when <pname> is TESS_GEN_VERTEX_ORDER_EXT:
187
188        CCW
189        CW
190
191    Returned by GetProgramiv when <pname> is TESS_GEN_POINT_MODE_EXT:
192
193        FALSE
194        TRUE
195
196    Accepted by the <pname> parameter of GetBooleanv, GetFloatv,
197    GetIntegerv, and GetInteger64v:
198
199        MAX_PATCH_VERTICES_EXT                              0x8E7D
200        MAX_TESS_GEN_LEVEL_EXT                              0x8E7E
201        MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT             0x8E7F
202        MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT          0x8E80
203        MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT            0x8E81
204        MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT         0x8E82
205        MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT              0x8E83
206        MAX_TESS_PATCH_COMPONENTS_EXT                       0x8E84
207        MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT        0x8E85
208        MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT           0x8E86
209        MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT                 0x8E89
210        MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT              0x8E8A
211        MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT               0x886C
212        MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT            0x886D
213        MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT    0x8E1E
214        MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F
215        MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT         0x92CD
216        MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT      0x92CE
217        MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT                0x92D3
218        MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT             0x92D4
219        MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT                 0x90CB
220        MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT              0x90CC
221        MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT          0x90D8
222        MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT       0x90D9
223        PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED             0x8221
224
225    Accepted by the <props> parameter of
226    GetProgramResourceiv:
227
228        IS_PER_PATCH_EXT                                    0x92E7
229        REFERENCED_BY_TESS_CONTROL_SHADER_EXT               0x9307
230        REFERENCED_BY_TESS_EVALUATION_SHADER_EXT            0x9308
231
232    Accepted by the <type> parameter of CreateShader, by the <pname>
233    parameter of GetProgramPipelineiv, and returned by the
234    <params> parameter of GetShaderiv:
235
236        TESS_EVALUATION_SHADER_EXT                          0x8E87
237        TESS_CONTROL_SHADER_EXT                             0x8E88
238
239    Accepted by the <stages> parameter of UseProgramStages:
240
241        TESS_CONTROL_SHADER_BIT_EXT                     0x00000008
242        TESS_EVALUATION_SHADER_BIT_EXT                  0x00000010
243
244Additions to the OpenGL ES 3.1 Specification
245
246    Modify chapter 3 "Dataflow Model"
247
248    Change the second paragraph, on p. 28:
249
250    ... In the next stage vertices may be transformed, followed by assembly
251    into geometric primitives. Tessellation and geometry shaders may then
252    optionally generate multiple new primitives from single input
253    primitives. Optionally, the results ...
254
255
256    Modify figure 3.1 "Block diagram of the OpenGL ES pipeline" as modified
257    by EXT_geometry_shader to insert new boxes "Tessellation Control
258    Shader", "Tessellation Primitive Generation", and "Tessellation
259    Evaluation Shader" in sequence following "Vertex Shader" and preceding
260    "Geometry Shader". Extend the arrows from the boxes "Image Load/Store"
261    .. "Uniform Block" to the right of "Vertex Shader" to connect to the new
262    "Control" and "Evaluation" boxes.
263
264
265    Replace the two paragraphs of chapter 7, "Programs and Shaders" on p. 64
266    starting "Shader stages including ..." with:
267
268    Shader stages including vertex, tessellation control, tessellation
269    evaluation, geometry, fragment, and compute shaders can be created,
270    compiled, and linked into program objects.
271
272    Vertex shaders describe the operations that occur on vertex attributes.
273    Tessellation control and evaluation shaders are used to control
274    the operation of the tessellator (see section 11.1ts). Geometry shaders
275    affect the processing of primitives assembled from vertices (see section
276    11.1gs). Fragment shaders affect the processing of fragments during
277    rasterization (see chapter 14). A single program object can contain all
278    of these shaders, or any subset thereof.
279
280    Compute shaders ...
281
282
283    Add to table 7.1 "CreateShader <type> values" on p. 65:
284
285        <type>                     Shader Stage
286        -------------------------- ------------------------------
287        TESS_CONTROL_SHADER_EXT    Tessellation control shader
288        TESS_EVALUATION_SHADER_EXT Tessellation evaluation shader
289
290
291    Add to the bullet list describing reasons for link failure below the
292    LinkProgram command on p. 70, as modified by EXT_geometry_shader:
293
294    * The program object contains an object to form a tessellation control
295      shader (see section 11.1ts.1), and
296      - the program is not separable and contains no object to form a
297        vertex shader; or
298      - the program is not separable and contains no object to form a
299        tessellation evaluation shader; or
300      - the output patch vertex count is not specified in the compiled
301        tessellation control shader object.
302    * The program object contains an object to form a tessellation
303      evaluation shader (see section 11.1ts.3), and
304      - the program is not separable and contains no object to form a
305        vertex shader; or
306      - the program is not separable and contains no object to form a
307        tessellation control shader; or
308      - the tessellation primitive mode is not specified in the compiled
309        tessellation evaluation shader object.
310
311
312    Modify section 7.3, "Program Objects", as modified by
313    EXT_geometry_shader:
314
315    Add to the second paragraph after UseProgram on p. 71:
316
317    The executable code ... the results of vertex and/or fragment processing
318    will be undefined. However, this is not an error. If there is no active
319    program for the tessellation control, tessellation evaluation, or
320    geometry shader stages, those stages are ignored. If there is no active
321    program for the compute shader stage ...
322
323
324    Modify section 7.3.1, Program Interfaces:
325
326    Modify table 7.2 "GetProgramResourceiv properties and supported
327    interfaces" on p. 81 to add "REFERENCED_BY_TESS_CONTROL_SHADER_EXT" and
328    "REFERENCED_BY_TESS_EVALUATION_SHADER_EXT" to the "Property" cell
329    already containing REFERENCED_BY_<stage>_SHADER for VERTEX, GEOMETRY,
330    FRAGMENT, and COMPUTE stages, with the same supported interfaces.
331
332    Add to table 7.2:
333
334      Property                                 Supported Interfaces
335      ---------------------------------------- -----------------------------
336      IS_PER_PATCH_EXT                         PROGRAM_INPUT, PROGRAM_OUTPUT
337
338    Add a new paragraph preceding the paragraph "For property IS_ROW_MAJOR"
339    on p. 83:
340
341    For the property IS_PER_PATCH_EXT, a single integer identifying whether
342    the input or output is a per-patch attribute is written to <params>. If
343    the active variable is a per-patch attribute (declared with the "patch"
344    qualifier), the value one is written to <params>; otherwise the value
345    zero is written to <params>.
346
347
348    Add tessellation shaders to the paragraph describing the REFERENCED_BY
349    properties, on p. 83:
350
351    For the properties REFERENCED_BY_VERTEX_SHADER,
352    REFERENCED_BY_TESS_CONTROL_SHADER_EXT,
353    REFERENCED_BY_TESS_EVALUATION_SHADER_EXT,
354    REFERENCED_BY_GEOMETRY_SHADER_EXT, REFERENCED_BY_FRAGMENT_SHADER, and
355    REFERENCED_BY_COMPUTE_SHADER, a single integer is written to <params>,
356    identifying whether the active resource is referenced by the vertex,
357    tessellation control, tessellation evaluation, geometry, fragment, or
358    compute shaders, respectively, in the program object. ...
359
360
361    Modify section 7.4, "Program Pipeline Objects" in the first
362    paragraph after UseProgramStages on p. 89:
363
364    ... These stages may include vertex, tessellation control, tessellation
365    evaluation, geometry, fragment, or compute, indicated respectively by
366    VERTEX_SHADER_BIT, TESS_CONTROL_SHADER_BIT_EXT, TESS_EVALUATION_BIT_EXT,
367    GEOMETRY_SHADER_BIT_EXT, FRAGMENT_SHADER_BIT, or COMPUTE_SHADER_BIT. ...
368
369
370    Modify section 7.4.1, "Shader Interface Matching" on p. 91, changing the
371    new paragraph starting "Geometry shader per-vertex ...":
372
373    Tessellation control shader per-vertex output variables and blocks and
374    tessellation control, tessellation evaluation, and geometry shader
375    per-vertex input variables are required to be declared as arrays...
376
377
378    Modify section 7.4.2 "Program Pipeline Object State" on p. 92,
379    replacing the first bullet point:
380
381    * Unsigned integers are required to hold the names of the active program
382      and each of the current vertex, tessellation control, tessellation
383      evaluation, geometry, fragment, and compute stage programs. Each
384      integer is initially zero.
385
386
387    Modify section 7.6, "Uniform Variables"
388
389    Add to table 7.4 "Query targets for default uniform block storage ..."
390    on p. 96:
391
392    Shader Stage                        <pname> for querying default uniform block
393                                        storage, in components
394    ----------------------------------  -------------------------------------------
395    Tess. control (see sec. 11.1ts.1.1) MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT
396    Tess. eval (see sec. 11.1ts.3.1)    MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT
397
398
399    Add to table 7.5 "Query targets for combined uniform block storage ..."
400    on p. 96:
401
402
403    Shader Stage                        <pname> for querying combined uniform block
404                                        storage, in components
405    ----------------------------------  ---------------------------------------------------
406    Tess. control                       MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT
407    Tess. eval                          MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT
408
409
410    Modify section 7.6.2, "Uniform Blocks" on p. 104, changing the second
411    paragraph of the section:
412
413    There is a set of implementation-dependent maximums for the number of
414    active uniform blocks used by each shader. If the number of uniform
415    blocks used by any shader in the program exceeds its corresponding
416    limit, the program will fail to link. The limits for vertex,
417    tessellation control, tessellation evaluation, geometry, fragment, and
418    compute shaders can be obtained by calling GetIntegerv with <pname>
419    values of MAX_VERTEX_UNIFORM_BLOCKS,
420    MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT,
421    MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT, MAX_GEOMETRY_UNIFORM_BLOCKS_EXT,
422    MAX_FRAGMENT_UNIFORM_BLOCKS, and MAX_COMPUTE_UNIFORM_BLOCKS,
423    respectively.
424
425
426    Modify section 7.7, "Atomic Counter Buffers" on p. 108, changing the
427    second paragraph of the section:
428
429    There is a set of implementation-dependent maximums for the number of
430    active atomic counter buffers referenced by each shader. If the number
431    of atomic counter buffers referenced by any shader in the program
432    exceeds its corresponding limit, the program will fail to link. The
433    limits for vertex, tessellation control, tessellation evaluation,
434    geometry, fragment, and compute shaders can be obtained by calling
435    GetIntegerv with <pname> values of MAX_VERTEX_ATOMIC_COUNTER_BUFFERS,
436    MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT,
437    MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT,
438    MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT,
439    MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, or
440    MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, respectively.
441
442
443    Modify section 7.8, "Shader Buffer Variables and Shader Storage Blocks"
444    on p. 110, changing the fourth paragraph:
445
446    If the number of active shader storage blocks referenced by the shaders
447    in a program exceeds implementation-dependent limits, the program will
448    fail to link. The limits for vertex, tessellation control, tessellation
449    evaluation, geometry, fragment, and compute shaders can be obtained by
450    calling GetIntegerv with pname values of
451    MAX_VERTEX_SHADER_STORAGE_BLOCKS,
452    MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT,
453    MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT,
454    MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT,
455    MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, and
456    MAX_COMPUTE_SHADER_STORAGE_BLOCKS, respectively. ...
457
458
459    Modify Section 7.11.1, "Shader Memory Access Ordering":
460
461    The order in which texture or buffer object memory is read or written by
462    shaders is largely undefined. For some shader types (vertex,
463    tessellation evaluation, and in some cases, fragment), even the number
464    of shader invocations that might perform loads and stores is undefined.
465
466    In particular, the following rules apply:
467
468    * While a vertex or tessellation evaluation shader will be executed at
469      least once for each unique vertex specified by the application (vertex
470      shaders) or generated by the tessellation primitive genertor
471      (tessellation evaluation shaders), it may be executed more than once
472      for implementation-dependent reasons. Additionally, ...
473
474
475    Modify section 7.12, "Shader, Program, and Program Pipeline Queries"
476    to add to the list of valid <pname>s for GetProgramiv on p. 120:
477
478    If <pname> is TESS_CONTROL_OUTPUT_VERTICES_EXT, the number of vertices
479    in the tessellation control shader output patch is returned.
480
481    If <pname> is TESS_GEN_MODE_EXT, QUADS_EXT, TRIANGLES, or ISOLINES_EXT
482    is returned, depending on the primitive mode declaration in the
483    tessellation evaluation shader. If <pname> is TESS_GEN_SPACING_EXT,
484    EQUAL, FRACTIONAL_EVEN_EXT, or FRACTIONAL_ODD_EXT is returned, depending
485    on the spacing declaration in the tessellation evaluation shader. If
486    <pname> is TESS_GEN_VERTEX_ORDER_EXT, CCW or CW is returned, depending
487    on the vertex order declaration in the tessellation evaluation shader.
488    If <pname> is TESS_GEN_POINT_MODE_EXT, TRUE is returned if point mode is
489    enabled in a tessellation evaluation shader declaration; FALSE is
490    returned otherwise.
491
492
493    Add to the Errors for GetProgramiv on p. 121:
494
495    An INVALID_OPERATION error is generated if TESS_CONTROL_OUTPUT_VERTICES
496    is queried for a program which has not been linked successfully, or
497    which does not contain objects to form a tessellation control shader.
498
499    An INVALID_OPERATION error is generated if TESS_GEN_MODE,
500    TESS_GEN_SPACING, TESS_GEN_VERTEX_ORDER, or TESS_GEN_POINT_MODE are
501    queried for a program which has not been linked successfully, or which
502    does not contain objects to form a tessellation evaluation shader,
503
504
505    Add new section 10.1.7sp following section 10.1.7, "Separate Triangles",
506    on p. 234:
507
508    Section 10.1.7sp, Separate Patches
509
510    Separate patches are specified with mode PATCHES_EXT. A patch is an
511    ordered collection of vertices used for primitive tessellation (see
512    section 11.1ts). The vertices comprising a patch have no implied
513    geometric ordering. The vertices of a patch are used by tessellation
514    shaders and the fixed-function tessellator to generate new point, line,
515    or triangle primitives.
516
517    Each patch in the series has a fixed number of vertices, which is
518    specified by calling
519
520      void PatchParameteriEXT(enum pname, int value);
521
522    with <pname> set to PATCH_VERTICES_EXT.
523
524    Errors
525
526    An INVALID_ENUM error is generated if <pname> is not PATCH_VERTICES_EXT.
527
528    An INVALID_VALUE error is generated if <value> is less than or equal to
529    zero, or is greater than the implementation-dependent maximum patch size
530    (the value of MAX_PATCH_VERTICES_EXT). The patch size is initially three
531    vertices.
532
533    If the number of vertices in a patch is given by <v>, the <v>*<i>+1st
534    through <v>*<i>+<v>th vertices (in that order) determine a patch for
535    each i = 0, 1, ..., n-1, where there are <v>*<n>+<k> vertices. <k> is in
536    the range [0,<v>-1]; if <k> is not zero, the final <k> vertices are
537    ignored.
538
539
540    Add to the end of section 10.3.4, "Primitive Restart" on p. 243:
541
542    Implementations are not required to support primitive restart for
543    separate patch primitives (primitive type PATCHES_EXT). Support can be
544    queried by calling GetBooleanv with the symbolic constant
545    PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_EXT. A value of FALSE indicates
546    that primitive restart is treated as disabled when drawing patches, no
547    matter the value of the enable. A value of TRUE indicates that primitive
548    restart behaves normally for patches.
549
550
551    Modify section 11.1.2.1, "Output Variables" on p. 262, starting with the
552    second paragraph of the section:
553
554    ... These output variables are used to communicate values to the next
555    active stage in the vertex processing pipeline; either the tessellation
556    control or geometry shader, or the fixed-function vertex processing
557    stages leading to rasterization.
558
559    ...
560
561    The number of components (individual scalar numeric values) of output
562    variables that can be written by the vertex shader, whether or not a
563    tessellation control or geometry shader is active, is given by the value
564    of the implementation-dependent constant MAX_VERTEX_OUTPUT_COMPONENTS.
565    For the purposes of counting ...
566
567    ...
568
569    Each program object can specify a set of output variables from one
570    shader to be recorded in transform feedback mode (see section 2.14). The
571    variables that can be recorded are those emitted by the first active
572    shader, in order, from the following list:
573
574    * geometry shader
575    * tessellation evaluation shader
576    * vertex shader
577
578    The set of variables to record is specified with the command
579
580    void TransformFeedbackVaryings ...
581
582
583    Modify the bullet point starting "the <count> specified" in the list of
584    TransformFeedbackVaryings link failures on p. 263:
585
586    * the <count> specified by TransformFeedbackVaryings is non-zero, but
587      the program object has no vertex, tessellation evaluation, or geometry
588      shader; ...
589
590
591    Modify Section 11.1.3, Shader Execution
592
593    Change the first paragraph and bullet list on p. 264:
594
595    If there is an active program object present for the vertex,
596    tessellation control, tessellation evaluation, or geometry shader
597    stages, the executable code for those active programs is used to process
598    incoming vertex values. The following sequence of operations is
599    performed:
600
601    * Vertices are processed by the vertex shader (see section 11.1) and
602      assembled into primitives as described in sections 10.1 through 10.3.
603    * If the current program contains a tessellation control shader, each
604      individual patch primitive is processed by the tessellation control
605      shader (section 11.1ts.1). Otherwise, primitives are passed through
606      unmodified. If active, the tessellation control shader consumes its
607      input patch and produces a new patch primitive, which is passed to
608      subsequent pipeline stages.
609    * If the current program contains a tessellation evaluation shader, each
610      individual patch primitive is processed by the tessellation primitive
611      generator (section 11.1ts.2) and tessellation evaluation shader (see
612      section 11.1ts.3). Otherwise, primitives are passed through unmodified.
613      When a tessellation evaluation shader is active, the tessellation
614      primitive generator produces a new collection of point, line, or
615      triangle primitives to be passed to subsequent pipeline stages. The
616      vertices of these primitives are processed by the tessellation
617      evaluation shader. The patch primitive passed to the tessellation
618      primitive generator is consumed by this process.
619    * If the current program contains a geometry shader, ...
620
621
622    Modify the bullet list in section 11.1.3.5 "Texture Access" on p. 266 to
623    add limits for tessellation shaders:
624
625    * MAX_VERTEX_TEXTURE_IMAGE_UNITS (for vertex shaders),
626    * MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT (for tessellation control
627      shaders),
628    * MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT (for tessellation
629      evaluation shaders),
630    * MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT (for geometry shaders), and
631    * MAX_TEXTURE_IMAGE_UNITS (for fragment shaders).
632
633
634    Modify the bullet list in section 11.1.3.6 "Atomic Counter Access" on p.
635    268 to add a limit for geometry shaders:
636
637    * MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT (for tessellation control
638      shaders),
639    * MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT (for tessellation evaluation
640      shaders),
641
642
643    Modify the bullet list in section 11.1.3.7 "Image Access" on p. 268 to
644    add a limit for geometry shaders:
645
646    * MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT (for tessellation control
647      shaders),
648    * MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT (for tessellation evaluation
649      shaders),
650
651
652    Modify the bullet list in section 11.1.3.8 "Shader Storage Buffer
653    Access" on p. 268 to add a limit for geometry shaders:
654
655    * MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT (for tessellation control
656      shaders),
657    * MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT (for tessellation
658      evaluation shaders),
659
660
661    Modify section 11.1.3.11, "Validation" to replace the bullet point
662    starting "There is an active program for the geometry stage ..." on p.
663    270:
664
665    * There is an active program for tessellation control, tessellation
666      evaluation, or geometry stages with corresponding executable shader,
667      but there is no active program with an executable vertex shader.
668
669
670    Add a new bullet point in the same section:
671
672    * One but not both of the tessellation control and tessellation
673      evaluation stages have an active program with corresponding executable
674      shader.
675
676
677    Insert new section 11.1ts, "Tessellation", between section 11.1 "Vertex
678    Shaders" and section 11.1gs "Geometry Shaders":
679
680    Tessellation is a process that reads a patch primitive and generates new
681    primitives used by subsequent pipeline stages. The generated primitives
682    are formed by subdividing a single triangle or quad primitive according
683    to fixed or shader-computed levels of detail and transforming each of
684    the vertices produced during this subdivision.
685
686    Tessellation functionality is controlled by two types of tessellation
687    shaders: tessellation control shaders and tessellation evaluation
688    shaders. Tessellation is considered active if and only if the active
689    program object or program pipeline object includes both a tessellation
690    control shader and a tessellation evaluation shader.
691
692    The tessellation control shader is used to read an input patch provided
693    by the application, and emit an output patch. The tessellation control
694    shader is run once for each vertex in the output patch and computes the
695    attributes of that vertex. Additionally, the tessellation control shader
696    may compute additional per-patch attributes of the output patch. The
697    most important per-patch outputs are the tessellation levels, which are
698    used to control the number of subdivisions performed by the tessellation
699    primitive generator. The tessellation control shader may also write
700    additional per-patch attributes for use by the tessellation evaluation
701    shader. If no tessellation control shader is active, patch primitives
702    may not be provided by the application.
703
704    If a tessellation evaluation shader is active, the tessellation
705    primitive generator subdivides a triangle or quad primitive into a
706    collection of points, lines, or triangles according to the tessellation
707    levels of the patch and the set of layout declarations specified in the
708    tessellation evaluation shader text.
709
710    When a tessellation evaluation shader is active, it is run on each
711    vertex generated by the tessellation primitive generator to compute the
712    final position and other attributes of the vertex. The tessellation
713    evaluation shader can read the relative location of the vertex in the
714    subdivided output primitive, given by an (u,v) or (u,v,w) coordinate, as
715    well as the position and attributes of any or all of the vertices in the
716    input patch.
717
718    Tessellation operates only on patch primitives.
719
720    Patch primitives are not supported by pipeline stages below the
721    tessellation evaluation shader.
722
723    A non-separable program object or program pipeline object that includes
724    a tessellation shader of any kind must also include a vertex shader.
725
726
727    Errors
728
729    An INVALID_OPERATION error is generated by any command that transfers
730    vertices to the GL if the current program state has one but not both of
731    a tessellation control shader and tessellation evaluation shader.
732
733    An INVALID_OPERATION error is generated by any command that transfers
734    vertices to the GL if tessellation is active and the primitive mode is
735    not PATCHES_EXT.
736
737    An INVALID_OPERATION error is generated by any command that transfers
738    vertices to the GL if tessellation is not active and the primitive mode
739    is PATCHES_EXT.
740
741    An INVALID_OPERATION error is generated by any command that transfers
742    vertices to the GL if the current program state has a tessellation
743    shader but no vertex shader.
744
745
746    Section 11.1ts.1, Tessellation Control Shaders
747
748    The tessellation control shader consumes an input patch provided by the
749    application and emits a new output patch. The input patch is an array of
750    vertices with attributes corresponding to output variables written by
751    the vertex shader. The output patch consists of an array of vertices
752    with attributes corresponding to per-vertex output variables written by
753    the tessellation control shader and a set of per-patch attributes
754    corresponding to per-patch output variables written by the tessellation
755    control shader. Tessellation control output variables are per-vertex by
756    default, but may be declared as per-patch using the "patch" qualifier.
757
758    The number of vertices in the output patch is fixed when the program is
759    linked, and is specified in tessellation control shader source code
760    using the output layout qualifier "vertices", as described in the OpenGL
761    ES Shading Language Specification. A program will fail to link if the
762    output patch vertex count is not specified by the tessellation control
763    shader object attached to the program, if it is less than or equal to
764    zero, or if it is greater than the implementation-dependent maximum
765    patch size. The output patch vertex count may be queried by calling
766    GetProgramiv with the symbolic constant
767    TESS_CONTROL_OUTPUT_VERTICES_EXT.
768
769    Tessellation control shaders are created as described in section 7.1,
770    using a <type> of TESS_CONTROL_SHADER_EXT. When a new input patch is
771    received, the tessellation control shader is run once for each vertex in
772    the output patch. The tessellation control shader invocations
773    collectively specify the per-vertex and per-patch attributes of the
774    output patch. The per-vertex attributes are obtained from the per-vertex
775    output variables written by each invocation. Each tessellation control
776    shader invocation may only write to per-vertex output variables
777    corresponding to its own output patch vertex. The output patch vertex
778    number corresponding to a given tessellation control point shader
779    invocation is given by the built-in variable gl_InvocationID. Per-patch
780    attributes are taken from the per-patch output variables, which may be
781    written by any tessellation control shader invocation. While
782    tessellation control shader invocations may read any per-vertex and
783    per-patch output variable and write any per-patch output variable,
784    reading or writing output variables also written by other invocations
785    has ordering hazards discussed below.
786
787
788    Section 11.1ts.1.1, Tessellation Control Shader Variables
789
790    Tessellation control shaders can access uniforms belonging to the
791    current program object. Limits on uniform storage and methods for
792    manipulating uniforms are described in section 7.6.
793
794    Tessellation control shaders also have access to samplers to perform
795    texturing operations, as described in section 7.9.
796
797    Tessellation control shaders can access the transformed attributes of
798    all vertices for their input primitive using input variables. A vertex
799    shader writing to output variables generates the values of these input
800    variables. Values for any inputs that are not written by a vertex shader
801    are undefined.
802
803    Additionally, tessellation control shaders can write to one or more
804    output variables, including per-vertex attributes for the vertices of
805    the output patch and per-patch attributes of the patch. Tessellation
806    control shaders can also write to a set of built-in per-vertex and
807    per-patch outputs defined in the OpenGL ES Shading Language. The
808    per-vertex and per-patch attributes of the output patch are used by the
809    tessellation primitive generator (section 11.1ts.2) and may be read by
810    tessellation evaluation shader (section 11.1ts.3).
811
812
813    Section 11.1ts.1.2, Tessellation Control Shader Execution Environment
814
815    If there is an active program for the tessellation control stage, the
816    executable version of the program's tessellation control shader is used
817    to process patches resulting from the primitive assembly stage. When
818    tessellation control shader execution completes, the input patch is
819    consumed. A new patch is assembled from the per-vertex and per-patch
820    output variables written by the shader and is passed to subsequent
821    pipeline stages.
822
823    There are several special considerations for tessellation control shader
824    execution described in the following sections.
825
826
827    Section 11.1ts.1.2.1, Texture Access
828
829    Section 11.1.3.1 describes texture lookup functionality accessible to a
830    vertex shader. The texel fetch and texture size query functionality
831    described there also applies to tessellation control shaders.
832
833
834    Section 11.1ts.1.2.2, Tessellation Control Shader Inputs
835
836    Section 7.1 ("Built-In Variables") of the OpenGL ES Shading Language
837    Specification describes the built-in variable array gl_in[] available as
838    input to a tessellation control shader. gl_in[] receives values from
839    equivalent built-in output variables written by the vertex shader. Each
840    array element of gl_in[] is a structure holding values for a specific
841    vertex of the input patch. The length of gl_in[] is equal to the
842    implementation-dependent maximum patch size (gl_MaxPatchVertices).
843    Behavior is undefined if gl_in[] is indexed with a vertex index greater
844    than or equal to the current patch size. The members of each element of
845    the gl_in[] array are gl_Position
846        [[ If EXT_tessellation_point_size is supported: ]]
847        and gl_PointSize.
848
849    Tessellation control shaders have available several other special input
850    variables not replicated per-vertex and not contained in gl_in[],
851    including:
852
853      * The variable gl_PatchVerticesIn holds the number of vertices in the
854        input patch being processed by the tessellation control shader.
855
856      * The variable gl_PrimitiveID is filled with the number of primitives
857        processed by the drawing command which generated the input vertices.
858        The first primitive generated by a drawing command is numbered zero,
859        and the primitive ID counter is incremented after every individual
860        point, line, or triangle primitive is processed. The counter is
861        reset to zero between each instance drawn. Restarting a primitive
862        topology using the primitive restart index has no effect on the
863        primitive ID counter.
864
865      * The variable gl_InvocationID holds an invocation number for the
866        current tessellation control shader invocation. Tessellation control
867        shaders are invoked once per output patch vertex, and invocations
868        are numbered beginning with zero.
869
870    Similarly to the built-in inputs, each user-defined input variable has a
871    value for each vertex and thus needs to be declared as arrays or inside
872    input blocks declared as arrays. Declaring an array size is optional. If
873    no size is specified, it will be taken from the implementation-dependent
874    maximum patch size (gl_MaxPatchVertices). If a size is specified, it must
875    match the maximum patch size; otherwise, a compile or link error will
876    occur. Since the array size may be larger than the number of vertices
877    found in the input patch, behavior is undefined if a per-vertex input
878    variable is accessed using an index greater than or equal to the number of
879    vertices in the input patch. The OpenGL ES Shading Language doesn't
880    support multi-dimensional arrays as shader inputs or outputs; therefore,
881    user-defined tessellation control shader inputs corresponding to vertex
882    shader outputs declared as arrays must be declared as array members of
883    an input block that is itself declared as an array.
884
885    Similarly to the limit on vertex shader output components (see section
886    11.1.2.1), there is a limit on the number of components of input
887    variables that can be read by the tessellation control shader, given by
888    the value of the implementation-dependent constant
889    MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT.
890
891    When a program is linked, all components of any input read by a
892    tessellation control shader will count against this limit. A program
893    whose tessellation control shader exceeds this limit may fail to link,
894    unless device-dependent optimizations are able to make the program fit
895    within available hardware resources.
896
897    Component counting rules for different variable types and variable
898    declarations are the same as for MAX_VERTEX_OUTPUT_COMPONENTS (see
899    section 11.1.2.1).
900
901
902    Section 11.1ts.1.2.3, Tessellation Control Shader Outputs
903
904    Section 7.1 ("Built-In Variables") of the OpenGL ES Shading Language
905    Specification describes the built-in variable array gl_out[] available
906    as an output for a tessellation control shader. gl_out[] passes values
907    to equivalent built-in input variables read by subsequent shader stages
908    or to subsequent fixed functionality vertex processing pipeline stages.
909    Each array element of gl_out[] is a structure holding values for a
910    specific vertex of the output patch. The length of gl_out[] is equal to
911    the output patch size specified in the tessellation control shader
912    output layout declaration. The members of each element of the gl_out[]
913    array are gl_Position
914        [[ If EXT_tessellation_point_size is supported: ]]
915        and gl_PointSize.
916    They behave identically to equivalently named vertex shader outputs
917    (see section 11.1.2.1).
918
919    Tessellation shaders additionally have two built-in per-patch output
920    arrays, gl_TessLevelOuter[] and gl_TessLevelInner[]. These arrays are not
921    replicated for each output patch vertices and are not members of gl_out[].
922    gl_TessLevelOuter[] is an array of four floating-point values specifying
923    the approximate number of segments that the tessellation primitive
924    generator should use when subdividing each outer edge of the primitive it
925    subdivides.  gl_TessLevelInner[] is an array of two floating-point values
926    specifying the approximate number of segments used to produce a
927    regularly-subdivided primitive interior.  The values written to
928    gl_TessLevelOuter and gl_TessLevelInner need not be integers, and their
929    interpretation depends on the type of primitive the tessellation
930    primitive generator will subdivide and other tessellation parameters, as
931    discussed in the following section.
932
933    A tessellation control shader may also declare user-defined per-vertex
934    output variables. User-defined per-vertex output variables are declared
935    with the qualifier "out" and have a value for each vertex in the output
936    patch. Such variables must be declared as arrays or inside output blocks
937    declared as arrays. Declaring an array size is optional. If no size is
938    specified, it will be taken from output patch size declared in the
939    shader. If a size is specified, it must match the maximum patch size;
940    otherwise, a compile or link error will occur. The OpenGL ES Shading
941    Language doesn't support multi-dimensional arrays as shader inputs or
942    outputs; therefore, user-defined per-vertex tessellation control shader
943    outputs with multiple elements per vertex must be declared as array members
944    of an output block that is itself declared as an array.
945
946    While per-vertex output variables are declared as arrays indexed by
947    vertex number, each tessellation control shader invocation may write
948    only to those outputs corresponding to its output patch vertex.
949    Tessellation control shaders must use the special variable
950    gl_InvocationID as the vertex number index when writing to per-vertex
951    output variables.
952
953    Additionally, a tessellation control shader may declare per-patch output
954    variables using the qualifier "patch out". Unlike per-vertex outputs,
955    per-patch outputs do not correspond to any specific vertex in the patch,
956    and are not indexed by vertex number. Per-patch outputs declared as
957    arrays have multiple values for the output patch; similarly declared
958    per-vertex outputs would indicate a single value for each vertex in the
959    output patch. User-defined per-patch outputs are not used by the
960    tessellation primitive generator, but may be read by tessellation
961    evaluation shaders.
962
963    There are several limits on the number of components of built-in and
964    user-defined output variables that can be written by the tessellation
965    control shader. The number of components of active per-vertex output
966    variables may not exceed the value of
967    MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT. The number of components of
968    active per-patch output variables may not exceed the value of
969    MAX_TESS_PATCH_COMPONENTS_EXT. The built-in outputs gl_TessLevelOuter[]
970    and gl_TessLevelInner[] are not counted against the per-patch limit. The
971    total number of components of active per-vertex and per-patch outputs is
972    derived by multiplying the per-vertex output component count by the output
973    patch size and then adding the per-patch output component count. The total
974    component count may not exceed
975    MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT.
976
977    When a program is linked, all components of any output variable written
978    by a tessellation control shader will count against this limit. A
979    program exceeding any of these limits may fail to link, unless
980    device-dependent optimizations are able to make the program fit within
981    available hardware resources.
982
983    Component counting rules for different variable types and variable
984    declarations are the same as for MAX_VERTEX_OUTPUT_COMPONENTS. (see
985    section 11.1.2.1).
986
987
988    Section 11.1ts.1.2.4, Tessellation Control Shader Execution Order
989
990    For tessellation control shaders with a declared output patch size
991    greater than one, the shader is invoked more than once for each input
992    patch. The order of execution of one tessellation control shader
993    invocation relative to the other invocations for the same input patch is
994    largely undefined. The built-in function barrier() provides some control
995    over relative execution order. When a tessellation control shader calls
996    the barrier() function, its execution pauses until all other invocations
997    have also called the same function. Output variable assignments
998    performed by any invocation executed prior to calling barrier() will be
999    visible to any other invocation after the call to barrier() returns.
1000    Shader output values read in one invocation but written by another may
1001    be undefined without proper use of barrier(); full rules are found in
1002    the OpenGL ES Shading Language Specification.
1003
1004    The barrier() function may only be called inside the main entry point of
1005    the tessellation control shader and may not be called in potentially
1006    divergent flow control. In particular, barrier() may not be called
1007    inside a switch statement, in either sub-statement of an if statement,
1008    inside a do, for, or while loop, or at any point after a return
1009    statement in the function main().
1010
1011
1012    Section 11.1ts.2, Tessellation Primitive Generation
1013
1014    The tessellation primitive generator consumes the input patch and
1015    produces a new set of basic primitives (points, lines, or triangles).
1016    These primitives are produced by subdividing a geometric primitive
1017    (rectangle or triangle) according to the per-patch tessellation levels
1018    written by the tessellation control shader. This subdivision is
1019    performed in an implementation- dependent manner.
1020
1021    The type of subdivision performed by the tessellation primitive
1022    generator is specified by an input layout declaration in the
1023    tessellation evaluation shader using one of the identifiers "triangles",
1024    "quads", and "isolines". For "triangles", the primitive generator
1025    subdivides a triangle primitive into smaller triangles. For "quads", the
1026    primitive generator subdivides a rectangle primitive into smaller
1027    triangles. For "isolines", the primitive generator subdivides a
1028    rectangle primitive into a collection of line segments arranged in
1029    strips stretching horizontally across the rectangle. Each vertex
1030    produced by the primitive generator has an associated (u,v,w) or (u,v)
1031    position in a normalized parameter space, with parameter values in the
1032    range [0,1], as illustrated in Figure 11.X1. For "triangles", the vertex
1033    position is a barycentric coordinate (u,v,w), where u+v+w==1, and
1034    indicates the relative influence of the three vertices of the triangle
1035    on the position of the vertex. For "quads" and "isolines", the position
1036    is a (u,v) coordinate indicating the relative horizontal and vertical
1037    position of the vertex relative to the subdivided rectangle. The
1038    subdivision process is explained in more detail in subsequent sections.
1039
1040        (0,1)   OL3   (1,1)          (0,1,0)         (0,1)          (1,1)
1041         +--------------+              +             ^  +  <no edge>   +
1042         |              |             / \            |
1043         |  +--------+  |            /   \           |  +--------------+
1044         |  |   IL0  |  |       OL0 /  +  \ OL2      |
1045      OL0|  |IL1     |  |OL2       /  / \  \         |  +--------------+
1046         |  |        |  |         /  /IL0\  \       OL0
1047         |  +--------+  |        /  +-----+  \       |  +--------------+
1048         |              |       /             \      |
1049         +--------------+      +---------------+     v  +--------------+
1050        (0,0)   OL1   (1,0) (0,0,1)   OL1   (1,0,0)   (0,0)   OL1   (1,0)
1051
1052              quads                triangles                isolines
1053
1054      Figure 11.X1: Domain parameterization for tessellation generator
1055      primitive modes (triangles, quads, or isolines). The coordinates
1056      illustrate the value of gl_TessCoord at the corners of the domain. The
1057      labels on the edges indicate the inner (IL0 and IL1) and outer (OL0
1058      through OL3) tessellation level values used to control the number of
1059      subdivisions along each edge of the domain.
1060
1061    A patch is discarded by the tessellation primitive generator if any
1062    relevant outer tessellation level is less than or equal to zero. Patches
1063    will also be discarded if any relevant outer tessellation level
1064    corresponds to a floating-point NaN (not a number) in implementations
1065    supporting NaN. When patches are discarded, no new primitives will be
1066    generated and the tessellation evaluation program will not be run. For
1067    "quads", all four outer levels are relevant. For "triangles" and
1068    "isolines", only the first three or two outer levels, respectively, are
1069    relevant. Negative inner levels will not cause a patch to be discarded;
1070    they will be clamped as described below.
1071
1072    Each of the tessellation levels is used to determine the number and
1073    spacing of segments used to subdivide a corresponding edge. The method
1074    used to derive the number and spacing of segments is specified by an
1075    input layout declaration in the tessellation evaluation shader using one
1076    of the identifiers "equal_spacing", "fractional_even_spacing", or
1077    "fractional_odd_spacing". If no spacing is specified in the tessellation
1078    evaluation shader, "equal_spacing" will be used.
1079
1080    If "equal_spacing" is used, the floating-point tessellation level is
1081    first clamped to the range [1,<max>], where <max> is the
1082    implementation-dependent maximum tessellation level (the value of
1083    MAX_TESS_GEN_LEVEL_EXT). The result is rounded up to the nearest integer
1084    <n>, and the corresponding edge is divided into <n> segments of equal
1085    length in (u,v) space.
1086
1087    If "fractional_even_spacing" is used, the tessellation level is first
1088    clamped to the range [2,<max>] and then rounded up to the nearest even
1089    integer <n>. If "fractional_odd_spacing" is used, the tessellation level
1090    is clamped to the range [1,<max>-1] and then rounded up to the nearest
1091    odd integer <n>. If <n> is one, the edge will not be subdivided.
1092    Otherwise, the corresponding edge will be divided into <n>-2 segments of
1093    equal length, and two additional segments of equal length that are
1094    typically shorter than the other segments. The length of the two
1095    additional segments relative to the others will decrease monotonically
1096    with the value of <n>-<f>, where <f> is the clamped floating-point
1097    tessellation level. When <n>-<f> is zero, the additional segments will
1098    have equal length to the other segments. As <n>-<f> approaches 2.0, the
1099    relative length of the additional segments approaches zero. The two
1100    additional segments should be placed symmetrically on opposite sides of
1101    the subdivided edge. The relative location of these two segments is
1102    undefined, but must be identical for any pair of subdivided edges with
1103    identical values of <f>.
1104
1105    When the tessellation primitive generator produces triangles (in the
1106    "triangles" or "quads" modes), the orientation of all triangles can be
1107    specified by an input layout declaration in the tessellation evaluation
1108    shader using the identifiers "cw" and "ccw". If the order is "cw", the
1109    vertices of all generated triangles will have a clockwise ordering in
1110    (u,v) or (u,v,w) space, as illustrated in Figure 11.X1. If the order is
1111    "ccw", the vertices will be specified in counter-clockwise order. If no
1112    layout is specified, "ccw" will be used.
1113
1114    For all primitive modes, the tessellation primitive generator is capable
1115    of generating points instead of lines or triangles. If an input layout
1116    declaration in the tessellation evaluation shader specifies the identifier
1117    "point_mode", the primitive generator will generate one point for each
1118    distinct vertex produced by tessellation.  Otherwise, the primitive
1119    generator will produce a collection of line segments or triangles
1120    according to the primitive mode.  When tessellating triangles or quads in
1121    point mode with fractional odd spacing, the tessellation primitive
1122    generator may produce "interior" vertices that are positioned on the edge
1123    of the patch if an inner tessellation level is less than or equal to one.
1124    Such vertices are considered distinct from vertices produced by
1125    subdividing the outer edge of the patch, even if there are pairs of
1126    vertices with identical coordinates.
1127
1128    The points, lines, or triangles produced by the tessellation primitive
1129    generator are passed to subsequent pipeline stages in an
1130    implementation-dependent order.
1131
1132
1133    Section 11.1ts.2.1, Triangle Tessellation
1134
1135    If the tessellation primitive mode is "triangles", an equilateral
1136    triangle is subdivided into a collection of triangles covering the area
1137    of the original triangle. First, the original triangle is subdivided
1138    into a collection of concentric equilateral triangles. The edges of each
1139    of these triangles are subdivided, and the area between each triangle
1140    pair is filled by triangles produced by joining the vertices on the
1141    subdivided edges. The number of concentric triangles and the number of
1142    subdivisions along each triangle except the outermost is derived from
1143    the first inner tessellation level. The edges of the outermost triangle
1144    are subdivided independently, using the first, second, and third outer
1145    tessellation levels to control the number of subdivisions of the u==0
1146    (left), v==0 (bottom), and w==0 (right) edges, respectively. The second
1147    inner tessellation level and the fourth outer tessellation level have no
1148    effect in this mode.
1149
1150    If the first inner tessellation level and all three outer tessellation
1151    levels are exactly one after clamping and rounding, only a single
1152    triangle with (u,v,w) coordinates of (0,0,1), (1,0,0), and (0,1,0) is
1153    generated. If the inner tessellation level is one and any of the outer
1154    tessellation levels is greater than one, the inner tessellation level is
1155    treated as though it were originally specified as 1+epsilon and will be
1156    rounded up to result in a two- or three-segment subdivision according to
1157    the tessellation spacing.
1158
1159    If any tessellation level is greater than one, tessellation begins by
1160    producing a set of concentric inner triangles and subdividing their
1161    edges. First, the three outer edges are temporarily subdivided using the
1162    clamped and rounded first inner tessellation level and the specified
1163    tessellation spacing, generating <n> segments. For the outermost inner
1164    triangle, the inner triangle is degenerate -- a single point at the
1165    center of the triangle -- if <n> is two. Otherwise, for each corner of
1166    the outer triangle, an inner triangle corner is produced at the
1167    intersection of two lines extended perpendicular to the corner's two
1168    adjacent edges running through the vertex of the subdivided outer edge
1169    nearest that corner. If <n> is three, the edges of the inner triangle
1170    are not subdivided and is the final triangle in the set of concentric
1171    triangles. Otherwise, each edge of the inner triangle is divided into
1172    <n>-2 segments, with the <n>-1 vertices of this subdivision produced by
1173    intersecting the inner edge with lines perpendicular to the edge running
1174    through the <n>-1 innermost vertices of the subdivision of the outer
1175    edge. Once the outermost inner triangle is subdivided, the previous
1176    subdivision process repeats itself, using the generated triangle as an
1177    outer triangle. This subdivision process is illustrated in Figure 11.X2.
1178
1179                                                   (0,1,0)
1180                                                      +
1181                                                     / \
1182                 (0,1,0)                            O. .O
1183                    +                              /  +  \
1184                   / \                            O. / \ .O
1185                  O. .O                          /  O. .O  \
1186                 /  +  \                        /  /  +  \  \
1187                O. / \ .O                      /  /  / \  \  \
1188               /  O. .O  \                    O. /  /   \  \ .O
1189              /  /  O  \  \                  /  O. /     \ .O  \
1190             O. /   .   \ .O                /  /  O-------O  \  \
1191            /  O----O----O  \              O. /   .       .   \ .O
1192           /   .    .    .   \            /  O----O-------O----O  \
1193          O----O----O----O----O          /   .    .       .    .   \
1194       (0,0,1)             (1,0,0)      O----O----O-------O----O----O
1195                                     (0,0,1)                     (1,0,0)
1196
1197      Figure 11.X2, Inner Triangle Tessellation with inner tessellation
1198      levels of four and five (not to scale). This figure depicts the
1199      vertices along the bottom edge of the concentric triangles. The edges
1200      of inner triangles are subdivided by intersecting the edge with
1201      segments perpendicular to the edge passing through each inner vertex
1202      of the subdivided outer edge.
1203
1204    Once all the concentric triangles are produced and their edges are
1205    subdivided, the area between each pair of adjacent inner triangles is
1206    filled completely with a set of non-overlapping triangles. In this
1207    subdivision, two of the three vertices of each triangle are taken from
1208    adjacent vertices on a subdivided edge of one triangle; the third is one
1209    of the vertices on the corresponding edge of the other triangle. If the
1210    innermost triangle is degenerate (i.e., a point), the triangle
1211    containing it is subdivided into six triangles by connecting each of the
1212    six vertices on that triangle with the center point. If the innermost
1213    triangle is not degenerate, that triangle is added to the set of
1214    generated triangles as-is.
1215
1216    After the area corresponding to any inner triangles is filled, the
1217    primitive generator generates triangles to cover area between the
1218    outermost triangle and the outermost inner triangle. To do this, the
1219    temporary subdivision of the outer triangle edge above is discarded.
1220    Instead, the u==0, v==0, and w==0 edges are subdivided according to the
1221    first, second, and third outer tessellation levels, respectively, and
1222    the tessellation spacing. The original subdivision of the first inner
1223    triangle is retained. The area between the outer and first inner
1224    triangles is completely filled by non-overlapping triangles as described
1225    above. If the first (and only) inner triangle is degenerate, a set of
1226    triangles is produced by connecting each vertex on the outer triangle
1227    edges with the center point.
1228
1229    After all triangles are generated, each vertex in the subdivided
1230    triangle is assigned a barycentric (u,v,w) coordinate based on its
1231    location relative to the three vertices of the outer triangle.
1232
1233    The algorithm used to subdivide the triangular domain in (u,v,w) space
1234    into individual triangles is implementation-dependent. However, the set
1235    of triangles produced will completely cover the domain, and no portion
1236    of the domain will be covered by multiple triangles. The order in which
1237    the generated triangles passed to subsequent pipeline stages and the
1238    order of the vertices in those triangles are both
1239    implementation-dependent. However, when depicted in a manner similar to
1240    Figure 11.X2, the order of the vertices in the generated triangles will
1241    be either all clockwise or all counter-clockwise, according to the
1242    vertex order layout declaration.
1243
1244
1245    Section 11.1ts.2.2, Quad Tessellation
1246
1247    If the tessellation primitive mode is "quads", a rectangle is subdivided
1248    into a collection of triangles covering the area of the original
1249    rectangle. First, the original rectangle is subdivided into a regular
1250    mesh of rectangles, where the number of rectangles along the u==0 and
1251    u==1 (vertical) and v==0 and v==1 (horizontal) edges are derived from
1252    the first and second inner tessellation levels, respectively. All
1253    rectangles, except those adjacent to one of the outer rectangle edges,
1254    are decomposed into triangle pairs. The outermost rectangle edges are
1255    subdivided independently, using the first, second, third, and fourth
1256    outer tessellation levels to control the number of subdivisions of the
1257    u==0 (left), v==0 (bottom), u==1 (right), and v==1 (top) edges,
1258    respectively. The area between the inner rectangles of the mesh and the
1259    outer rectangle edges are filled by triangles produced by joining the
1260    vertices on the subdivided outer edges to the vertices on the edge of
1261    the inner rectangle mesh.
1262
1263    If both clamped inner tessellation levels and all four clamped outer
1264    tessellation levels are exactly one, only a single triangle pair covering
1265    the outer rectangle is generated. Otherwise, if either clamped inner
1266    tessellation level is one, that tessellation level is treated as though it
1267    were originally specified as 1+epsilon and will result in a two- or
1268    three-segment subdivision depending on the tessellation spacing.  When
1269    used with fractional odd spacing, the three-segment subdivision may
1270    produce "inner" vertices positioned on the edge of the rectangle.
1271
1272    If any tessellation level is greater than one, tessellation begins by
1273    subdividing the u==0 and u==1 edges of the outer rectangle into <m>
1274    segments using the clamped and rounded first inner tessellation level
1275    and the tessellation spacing. The v==0 and v==1 edges are subdivided
1276    into <n> segments using using the second inner tessellation level. Each
1277    vertex on the u==0 and v==0 edges are joined with the corresponding
1278    vertex on the u==1 and v==1 edges to produce a set of vertical and
1279    horizontal lines that divide the rectangle into a grid of smaller
1280    rectangles. The primitive generator emits a pair of non-overlapping
1281    triangles covering each such rectangle not adjacent to an edge of the
1282    outer rectangle. The boundary of the region covered by these triangles
1283    forms an inner rectangle, the edges of which are subdivided by the grid
1284    vertices that lie on the edge. If either <m> or <n> is two, the inner
1285    rectangle is degenerate, and one or both of the rectangle's "edges"
1286    consist of a single point. This subdivision is illustrated in Figure
1287    11.X3.
1288
1289                                     (0,1)                (1,1)
1290                                       +--+--+--+--+--+--+--+
1291                                       |  .  .  .  .  .  .  |
1292              (0,1)       (1,1)        |  .  .  .  .  .  .  |
1293                +--+--+--+--+          +..O--O--O--O--O--O..+
1294                |  .  .  .  |          |  |**|**|**|**|**|  |
1295                |  .  .  .  |          |  |**|**|**|**|**|  |
1296                +..O--O--O..+          +..O--+--+--+--+--O..+
1297                |  .  .  .  |          |  |**|**|**|**|**|  |
1298                |  .  .  .  |          |  |**|**|**|**|**|  |
1299                +--+--+--+--+          +..O--O--O--O--O--O..+
1300              (0,0)       (1,0)        |  .  .  .  .  .  .  |
1301                                       |  .  .  .  .  .  .  |
1302                                       +--+--+--+--+--+--+--+
1303                                     (0,0)                (1,0)
1304
1305      Figure 11.X3, Inner Quad Tessellation with inner tessellation levels
1306      of (4,2) and (7,4). The areas labeled with "*" on the right depict the
1307      10 inner rectangles, each of which will be subdivided into two
1308      triangles. The points labeled "O" depict vertices on the boundary of
1309      the inner rectangle, where the inner rectangle on the left side is
1310      degenerate (a single line segment). The dotted lines (".") depict the
1311      horizontal and vertical edges connecting corresponding points on the
1312      outer rectangle edge.
1313
1314    After the area corresponding to the inner rectangle is filled, the
1315    primitive generator must produce triangles to cover area between the
1316    inner and outer rectangles. To do this, the subdivision of the outer
1317    rectangle edge above is discarded. Instead, the u==0, v==0, u==1, and
1318    v==1 edges are subdivided according to the first, second, third, and
1319    fourth outer tessellation levels, respectively, and the tessellation
1320    spacing. The original subdivision of the inner rectangle is retained.
1321    The area between the outer and inner rectangles is completely filled by
1322    non-overlapping triangles. Two of the three vertices of each triangle
1323    are adjacent vertices on a subdivided edge of one rectangle; the third
1324    is one of the vertices on the corresponding edge of the other triangle.
1325    If either edge of the innermost rectangle is degenerate, the area near
1326    the corresponding outer edges is filled by connecting each vertex on the
1327    outer edge with the single vertex making up the inner "edge".
1328
1329    The algorithm used to subdivide the rectangular domain in (u,v) space
1330    into individual triangles is implementation-dependent. However, the set
1331    of triangles produced will completely cover the domain, and no portion
1332    of the domain will be covered by multiple triangles. The order in which
1333    the generated triangles passed to subsequent pipeline stages and the
1334    order of the vertices in those triangles are both
1335    implementation-dependent. However, when depicted in a manner similar to
1336    Figure 11.X3, the order of the vertices in the generated triangles will
1337    be either all clockwise or all counter-clockwise, according to the
1338    vertex order layout declaration.
1339
1340
1341    Isoline Tessellation
1342
1343    If the tessellation primitive mode is "isolines", a set of independent
1344    horizontal line segments is drawn. The segments are arranged into
1345    connected strips called "isolines", where the vertices of each isoline
1346    have a constant v coordinate and u coordinates covering the full range
1347    [0,1]. The number of isolines generated is derived from the first outer
1348    tessellation level; the number of segments in each isoline is derived
1349    from the second outer tessellation level. Both inner tessellation levels
1350    and the third and fourth outer tessellation levels have no effect in
1351    this mode.
1352
1353    As with quad tessellation above, isoline tessellation begins with a
1354    rectangle. The u==0 and u==1 edges of the rectangle are subdivided
1355    according to the first outer tessellation level. For the purposes of
1356    this subdivision, the tessellation spacing mode is ignored and treated
1357    as "equal_spacing". A line is drawn connecting each vertex on the u==0
1358    rectangle edge to the corresponding vertex on the u==1 rectangle edge,
1359    except that no line is drawn between (0,1) and (1,1). If the number of
1360    segments on the subdivided u==0 and u==1 edges is <n>, this process will
1361    result in <n> equally spaced lines with constant v coordinates of 0,
1362    1/<n>, 2/<n>, ..., (<n>-1)/<n>.
1363
1364    Each of the <n> lines is then subdivided according to the second outer
1365    tessellation level and the tessellation spacing, resulting in <m> line
1366    segments. Each segment of each line is emitted by the tessellation
1367    primitive generator, as illustrated in Figure 11.X4.
1368
1369       (0,1)                   (1,1)
1370         +                       +          (0,1)             (1,1)
1371                                              +                 +
1372         O---O---O---O---O---O---O
1373
1374         O---O---O---O---O---O---O
1375
1376         O---O---O---O---O---O---O
1377                                              O-----O-----O-----O
1378         O---O---O---O---O---O---O          (0,0)             (1,0)
1379       (0,0)                   (1,0)
1380
1381      Figure 11.X4, Isoline Tessellation with the first two outer
1382      tessellation levels of (4,6) and (1,3), respectively. The lines
1383      connecting the vertices labeled "O" are emitted by the primitive
1384      generator. The vertices labeled "+" correspond to (u,v) coordinates of
1385      (0,1) and (1,1), where no line segments are generated.
1386
1387    The order in which the generated line segments are passed to subsequent
1388    pipeline stages and the order of the vertices in each generated line
1389    segment are both implementation-dependent.
1390
1391
1392    Section 11.1ts.3, Tessellation Evaluation Shaders
1393
1394    If active, the tessellation evaluation shader takes the (u,v) or (u,v,w)
1395    location of each vertex in the primitive subdivided by the tessellation
1396    primitive generator, and generates a vertex with a position and
1397    associated attributes. The tessellation evaluation shader can read any
1398    of the vertices of its input patch, which is the output patch produced
1399    by the tessellation control shader. Tessellation evaluation shaders are
1400    created as described in section 7.1, using a <type> of
1401    TESS_EVALUATION_SHADER_EXT.
1402
1403    Each invocation of the tessellation evaluation shader writes the
1404    attributes of exactly one vertex. The number of vertices evaluated per
1405    patch depends on the tessellation level values computed by the
1406    tessellation control shaders. Tessellation evaluation shader invocations
1407    run independently, and no invocation can access the variables belonging
1408    to another invocation. All invocations are capable of accessing all the
1409    vertices of their corresponding input patch.
1410
1411    The number of the vertices in the input patch is fixed and is equal to
1412    the tessellation control shader output patch size parameter in effect
1413    when the program was last linked.
1414
1415
1416    Section 11.1ts.3.1, Tessellation Evaluation Shader Variables
1417
1418    Tessellation evaluation shaders can access uniforms belonging to the
1419    current program object. The amount of storage available for uniform
1420    variables, except for atomic counters, in the default uniform block
1421    accessed by a tessellation evaluation shader is specified by the value
1422    of the implementation-dependent constant
1423    MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT. The total amount of combined
1424    storage available for uniform variables in all uniform blocks accessed
1425    by a tessellation evaluation shader (including the default uniform
1426    block) is specified by the value of the implementation-dependent
1427    constant MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT. These
1428    values represent the numbers of individual floating-point, integer, or
1429    boolean values that can be held in uniform variable storage for a
1430    tessellation evaluation shader. A uniform matrix in the default uniform
1431    block with single-precision components will consume no more than 4 x
1432    min(r,c) uniform components. A link error is generated if an attempt is
1433    made to utilize more than the space available for tessellation
1434    evaluation shader uniform variables. Uniforms are manipulated as
1435    described in section 2.11.6. Tessellation evaluation shaders also have
1436    access to samplers to perform texturing operations, as described in
1437    section 2.11.7.
1438
1439    Tessellation evaluation shaders can access the transformed attributes of
1440    all vertices for their input primitive using input variables. A
1441    tessellation control shader writing to output variables generates the
1442    values of these input varying variables, including values for built-in
1443    as well as user- defined varying variables. Values for any varying
1444    variables that are not written by a tessellation control shader are
1445    undefined.
1446
1447    Additionally, tessellation evaluation shaders can write to one or more
1448    output variables that will be passed to subsequent programmable shader
1449    stages or fixed functionality vertex pipeline stages.
1450
1451
1452    Section 11.1ts.3.2, Tessellation Evaluation Shader Execution Environment
1453
1454    If there is an active program for the tessellation evaluation stage, the
1455    executable version of the program's tessellation evaluation shader is
1456    used to process vertices produced by the tessellation primitive
1457    generator. During this processing, the shader may access the input patch
1458    processed by the primitive generator. When tessellation evaluation
1459    shader execution completes, a new vertex is assembled from the output
1460    variables written by the shader and is passed to subsequent pipeline
1461    stages.
1462
1463    There are several special considerations for tessellation evaluation
1464    shader execution described in the following sections.
1465
1466
1467    Section 11.1ts.3.2.1, Texture Access
1468
1469    Section 11.1.3.1 describes texture lookup functionality accessible to a
1470    vertex shader. The texel fetch and texture size query functionality
1471    described there also applies to tessellation evaluation shaders.
1472
1473
1474    Section 11.1ts.3.3, Tessellation Evaluation Shader Inputs
1475
1476    Section 7.1 ("Built-In Variables") of the OpenGL ES Shading Language
1477    Specification describes the built-in variable array gl_in[] available as
1478    input to a tessellation evaluation shader. gl_in[] receives values from
1479    equivalent built-in output variables written by a previous shader
1480    (section 11.1.3). Each array element of gl_in[] is a structure holding
1481    values for a specific vertex of the input patch. The length of gl_in[]
1482    is equal to the implementation- dependent maximum patch size
1483    (gl_MaxPatchVertices). Behavior is undefined if gl_in[] is indexed with
1484    a vertex index greater than or equal to the current patch size. The
1485    members of each element of the gl_in[] array are gl_Position
1486        [[ If EXT_tessellation_point_size is supported: ]]
1487        and gl_PointSize.
1488
1489    Tessellation evaluation shaders have available several other special
1490    input variables not replicated per-vertex and not contained in gl_in[],
1491    including:
1492
1493      * The variables gl_PatchVerticesIn and gl_PrimitiveID are filled with
1494        the number of the vertices in the input patch and a primitive
1495        number, respectively. They behave exactly as the identically named
1496        inputs for tessellation control shaders.
1497
1498      * The variable gl_TessCoord is a three-component floating-point vector
1499        consisting of the (u,v,w) coordinate of the vertex being processed
1500        by the tessellation evaluation shader. The values of u, v, and w are
1501        in the range [0,1], and vary linearly across the primitive being
1502        subdivided. For tessellation primitive modes of "quads" or
1503        "isolines", the w value is always zero. The (u,v,w) coordinates are
1504        generated by the tessellation primitive generator in a manner
1505        dependent on the primitive mode, as described in section 11.1ts.2.
1506        gl_TessCoord is not an array; it specifies the location of the
1507        vertex being processed by the tessellation evaluation shader, not of
1508        any vertex in the input patch.
1509
1510      * The variables gl_TessLevelOuter[] and gl_TessLevelInner[] are arrays
1511        holding outer and inner tessellation levels of the patch, as used by
1512        the tessellation primitive generator. Tessellation level values
1513        loaded in these variables will be prior to the clamping and rounding
1514        operations performed by the primitive generator as described in
1515        Section 11.1ts.2. For triangular tessellation, gl_TessLevelOuter[3]
1516        and gl_TessLevelInner[1] will be undefined. For isoline
1517        tessellation, gl_TessLevelOuter[2], gl_TessLevelOuter[3], and both
1518        values in gl_TessLevelInner[] are undefined.
1519
1520    A tessellation evaluation shader may also declare user-defined
1521    per-vertex input variables. User-defined per-vertex input variables are
1522    declared with the qualifier "in" and have a value for each vertex in the
1523    input patch. User-defined per-vertex input varying variables have a
1524    value for each vertex and thus need to be declared as arrays or inside
1525    input blocks declared as arrays. Declaring an array size is optional. If
1526    no size is specified, it will be taken from the implementation-dependent
1527    maximum patch size (gl_MaxPatchVertices). If a size is specified, it must
1528    match the maximum patch size; otherwise, a compile or link error will
1529    occur. Since the array size may be larger than the number of vertices
1530    found in the input patch, behavior is undefined if a per-vertex input
1531    variable is accessed using an index greater than or equal to the number of
1532    vertices in the input patch. The OpenGL ES Shading Language doesn't
1533    support multi-dimensional arrays as shader inputs or outputs; therefore,
1534    user-defined tessellation evaluation shader inputs corresponding to
1535    shader outputs declared as arrays must be declared as array members of
1536    an input block that is itself declared as an array.
1537
1538    Additionally, a tessellation evaluation shader may declare per-patch
1539    input variables using the qualifier "patch in". Unlike per-vertex
1540    inputs, per-patch inputs do not correspond to any specific vertex in the
1541    patch, and are not indexed by vertex number. Per-patch inputs declared
1542    as arrays have multiple values for the input patch; similarly declared
1543    per-vertex inputs would indicate a single value for each vertex in the
1544    output patch. User-defined per-patch input variables are filled with
1545    corresponding per-patch output values written by the tessellation
1546    control shader.
1547
1548    Similarly to the limit on vertex shader output components (see section
1549    11.1.2.1), there is a limit on the number of components of per-vertex
1550    and per-patch input variables that can be read by the tessellation
1551    evaluation shader, given by the values of the implementation-dependent
1552    constants MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT and
1553    MAX_TESS_PATCH_COMPONENTS_EXT, respectively. The built-in inputs
1554    gl_TessLevelOuter[] and gl_TessLevelInner[] are not counted against the
1555    per-patch limit.
1556
1557    When a program is linked, all components of any input variable read by a
1558    tessellation evaluation shader will count against this limit. A program
1559    whose tessellation evaluation shader exceeds this limit may fail to
1560    link, unless device-dependent optimizations are able to make the program
1561    fit within available hardware resources.
1562
1563    Component counting rules for different variable types and variable
1564    declarations are the same as for MAX_VERTEX_OUTPUT_COMPONENTS (see
1565    section 11.1.2.1).
1566
1567
1568    Section 11.1ts.3.4, Tessellation Evaluation Shader Outputs
1569
1570    Tessellation evaluation shaders have a number of built-in output
1571    variables used to pass values to equivalent built-in input variables
1572    read by subsequent shader stages or to subsequent fixed functionality
1573    vertex processing pipeline stages. These variables are gl_Position
1574        [[ If EXT_tessellation_point_size is supported: ]]
1575        and gl_PointSize,
1576    and behave identically to equivalently named vertex shader outputs (see
1577    section 11.1.3). A tessellation evaluation shader may also declare
1578    user-defined per-vertex output variables.
1579
1580    Similarly to the limit on vertex shader output components (see section
1581    11.1.2.1), there is a limit on the number of components of built-in and
1582    user-defined output variables that can be written by the tessellation
1583    evaluation shader, given by the values of the implementation-dependent
1584    constant MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT.
1585
1586    When a program is linked, all components of any output variable written
1587    by a tessellation evaluation shader will count against this limit. A
1588    program whose tessellation evaluation shader exceeds this limit may fail
1589    to link, unless device-dependent optimizations are able to make the
1590    program fit within available hardware resources.
1591
1592    Component counting rules for different variable types and variable
1593    declarations are the same as for MAX_VERTEX_OUTPUT_COMPONENTS. (see
1594    section 11.1.2.1).
1595
1596
1597    Modify section 12.1, "Transform Feedback"
1598
1599    Replace the second paragraph of the section on p. 274 (as modified
1600    by EXT_geometry_shader):
1601
1602    The data captured in transform feedback mode depends on the active
1603    programs on each of the shader stages. If a program is active for the
1604    geometry shader stage, transform feedback captures the vertices of each
1605    primitive emitted by the geometry shader. Otherwise, if a program is
1606    active for the tessellation evaluation shader stage, transform feedback
1607    captures each primitive produced by the tessellation primitive generator,
1608    whose vertices are processed by the tessellation evaluation shader.
1609    Otherwise, transform feedback captures each primitive processed by the
1610    vertex shader.
1611
1612    Modify the second paragraph following ResumeTransformFeedback on p. 277
1613    (as modified by EXT_geometry_shader):
1614
1615    When transform feedback is active and not paused ... If a tessellation
1616    evaluation or geometry shader is active, the type of primitive emitted
1617    by that shader is used instead of the <mode> parameter passed to drawing
1618    commands for the purposes of this error check. If tessellation
1619    evaluation and geometry shaders are both active, the output primitive
1620    type of the geometry shader will be used for the purposes of this error.
1621    Any primitive type may be used while transform feedback is paused.
1622
1623
1624    Modify the second paragraph of section 12.2, "Primitive Queries" on p.
1625    281:
1626
1627    When BeginQuery is called with a target of PRIMITIVES_GENERATED_EXT, ...
1628    This counter counts the number of primitives emitted by a geometry
1629    shader, if active, possibly further tessellated into separate primitives
1630    during the transform feedback stage, if active.
1631
1632
1633    Modify section 13.3, "Points"
1634
1635    Replace the text starting "The point size is determined ..." on p. 290:
1636
1637    The point size is determined by the last active stage before the
1638    rasterizer:
1639
1640    * the geometry shader, if active; or
1641    * the tessellation evaluation shader, if active and no geometry shader
1642      is active;
1643    * the vertex shader, otherwise.
1644
1645    If the last active stage is not a vertex shader and does not statically
1646    assign a value to gl_PointSize, the point size is 1.0. Otherwise, the
1647    point size is taken from the shader built-in gl_PointSize written by
1648    that stage.
1649      [[ Note that it is impossible to assign a value to gl_PointSize
1650         if EXT_geometry_point_size or EXT_tessellation_point_size is not
1651         supported and enabled in the relevant shader stages. ]]
1652
1653    If the last active stage is a vertex shader, the point size is taken
1654    from the shader built-in gl_PointSize written by the vertex shader.
1655
1656    In all cases, the point size is clamped to the implementation-dependent
1657    point size range. If the value written to gl_PointSize is less than or
1658    equal to zero, or if no value is written to gl_PointSize (except as
1659    noted above) the point size is undefined. The supported range ...
1660
1661
1662    Add new section A.3ts in Appendix A before section A.4, "Atomic Counter
1663    Invariance" on p. 405:
1664
1665    Section A.3ts, Tessellation Invariance
1666
1667    When using a program containing tessellation evaluation shaders, the
1668    fixed-function tessellation primitive generator consumes the input patch
1669    specified by an application and emits a new set of primitives. The
1670    following invariance rules are intended to provide repeatability
1671    guarantees. Additionally, they are intended to allow an application with
1672    a carefully crafted tessellation evaluation shader to ensure that the
1673    sets of triangles generated for two adjacent patches have identical
1674    vertices along shared patch edges, avoiding "cracks" caused by minor
1675    differences in the positions of vertices along shared edges.
1676
1677    Rule 1: When processing two patches with identical outer and inner
1678    tessellation levels, the tessellation primitive generator will emit an
1679    identical set of point, line, or triangle primitives as long as the
1680    active program used to process the patch primitives has tessellation
1681    evaluation shaders specifying the same tessellation mode, spacing,
1682    vertex order, and point mode input layout qualifiers. Two sets of
1683    primitives are considered identical if and only if they contain the same
1684    number and type of primitives and the generated tessellation coordinates
1685    for the vertex numbered <m> of the primitive numbered <n> are identical
1686    for all values of <m> and <n>.
1687
1688    Rule 2: The set of vertices generated along the outer edge of the
1689    subdivided primitive in triangle and quad tessellation, and the
1690    tessellation coordinates of each, depends only on the corresponding
1691    outer tessellation level and the spacing input layout qualifier in the
1692    tessellation evaluation shader of the active program.
1693
1694    Rule 3: The set of vertices generated when subdividing any outer
1695    primitive edge is always symmetric. For triangle tessellation, if the
1696    subdivision generates a vertex with tessellation coordinates of the form
1697    (0,x,1-x), (x,0,1-x), or (x,1-x,0), it will also generate a vertex with
1698    coordinates of exactly (0,1-x,x), (1-x,0,x), or (1-x,x,0), respectively.
1699    For quad tessellation, if the subdivision generates a vertex with
1700    coordinates of (x,0) or (0,x), it will also generate a vertex with
1701    coordinates of exactly (1-x,0) or (0,1-x), respectively. For isoline
1702    tessellation, if it generates vertices at (0,x) and (1,x) where <x> is
1703    not zero, it will also generate vertices at exactly (0,1-x) and (1,1-x),
1704    respectively.
1705
1706    Rule 4: The set of vertices generated when subdividing outer edges in
1707    triangular and quad tessellation must be independent of the specific
1708    edge subdivided, given identical outer tessellation levels and spacing.
1709    For example, if vertices at (x,1-x,0) and (1-x,x,0) are generated when
1710    subdividing the w==0 edge in triangular tessellation, vertices must be
1711    generated at (x,0,1-x) and (1-x,0,x) when subdividing an otherwise
1712    identical v==0 edge. For quad tessellation, if vertices at (x,0) and
1713    (1-x,0) are generated when subdividing the v==0 edge, vertices must be
1714    generated at (0,x) and (0,1-x) when subdividing an otherwise identical
1715    u==0 edge.
1716
1717    Rule 5: When processing two patches that are identical in all respects
1718    enumerated in rule 1 except for vertex order, the set of triangles
1719    generated for triangle and quad tessellation must be identical except
1720    for vertex and triangle order. For each triangle <n1> produced by
1721    processing the first patch, there must be a triangle <n2> produced when
1722    processing the second patch each of whose vertices has the same
1723    tessellation coordinates as one of the vertices in <n1>.
1724
1725    Rule 6: When processing two patches that are identical in all respects
1726    enumerated in rule 1 other than matching outer tessellation levels
1727    and/or vertex order, the set of interior triangles generated for
1728    triangle and quad tessellation must be identical in all respects except
1729    for vertex and triangle order. For each interior triangle <n1> produced
1730    by processing the first patch, there must be a triangle <n2> produced
1731    when processing the second patch each of whose vertices has the same
1732    tessellation coordinates as one of the vertices in <n1>. A triangle
1733    produced by the tessellator is considered an interior triangle if none
1734    of its vertices lie on an outer edge of the subdivided primitive.
1735
1736    Rule 7: For quad and triangle tessellation, the set of triangles
1737    connecting an inner and outer edge depends only on the inner and outer
1738    tessellation levels corresponding to that edge and the spacing input
1739    layout qualifier.
1740
1741    Rule 8: The value of all defined components of gl_TessCoord will be in
1742    the range [0,1]. Additionally, for any defined component <x> of
1743    gl_TessCoord, the results of computing (1.0-<x>) in a tessellation
1744    evaluation shader will be exact. Some floating-point values in the range
1745    [0,1] may fail to satisfy this property, but such values may never be
1746    used as tessellation coordinate components.
1747
1748
1749Dependencies on OES_shader_multisample_interpolation
1750
1751    If OES_shader_multisample_interpolation is not supported ignore all
1752    references to the "sample in" and "sample out" qualifiers.
1753
1754New State
1755
1756    Add new table 20.1ts "Current Values and Associated Data" preceding table
1757    20.2 on p. 354:
1758
1759                                                            Default
1760    Get Value                         Type  Get Command     Value     Description              Sec.
1761    ------------------------          ----  --------------  --------- ------------------------ ------------
1762    PATCH_VERTICES_EXT                Z+    GetIntegerv     3         Number of vertices in    10.1.7sp
1763                                                                      input patch
1764
1765    Add to table 20.19, "Program Pipeline Object State":
1766
1767                                                         Initial
1768    Get Value                  Type Get Command          Value    Description                      Sec
1769    -------------------------- ---- -------------------- -------  -------------------------------- ---
1770    TESS_CONTROL_SHADER_EXT    Z+   GetProgramPipelineiv 0        Name of current tess. control    7.4
1771                                                                  shader program object
1772    TESS_EVALUATION_SHADER_EXT Z+   GetProgramPipelineiv 0        Name of current tess. evaluation 7.4
1773                                                                  shader program object
1774
1775    Add new table 20.25ts, "Program Object State (cont.)":
1776
1777                                                         Default
1778    Get Value                        Type  Get Command   Value      Description                Sec.
1779    -------------------------------- ----  ------------  ---------  ------------------------   --------
1780    TESS_CONTROL_OUTPUT_VERTICES_EXT Z+    GetProgramiv  0          Output patch size          11.1ts.1
1781                                                                    for tess. control shader
1782    TESS_GEN_MODE_EXT                E     GetProgramiv  QUADS_EXT  Base primitive type for    11.1ts.2
1783                                                                    tess. prim. generator
1784    TESS_GEN_SPACING_EXT             E     GetProgramiv  EQUAL      Spacing of tess. prim.     11.1ts.2
1785                                                                    generator edge subdivision
1786    TESS_GEN_VERTEX_ORDER_EXT        E     GetProgramiv  CCW        Order of vertices in       11.1ts.2
1787                                                                    primitives generated by
1788                                                                    tess. prim generator
1789    TESS_GEN_POINT_MODE_EXT          B     GetProgramiv  FALSE      Tess prim. generator       11.1ts.2
1790                                                                    emits points?
1791
1792    Add to table 20.28, "Program Object Resource State (cont.)":
1793
1794                                                                        Initial
1795    Get Value                                Type  Get Command          Value   Description             Sec.
1796    ---------------------------------------- ----  -------------------- ------- ----------------------- -----
1797    REFERENCED_BY_TESS_CONTROL_SHADER_EXT    Z+    GetProgramResourceiv -       Active resource used by 7.3.1
1798                                                                                tess. control shader?
1799    REFERENCED_BY_TESS_EVALUATION_SHADER_EXT Z+    GetProgramResourceiv -       Active resource used by 7.3.1
1800                                                                                tess. eval. shader?
1801
1802New Implementation Dependent State
1803
1804    Add to table 20.39 "Implementation Dependent Values":
1805
1806                                                                  Minimum
1807    Get Value                                   Type  Get Command  Value  Description                  Sec.
1808    ------------------------------------------- ----  ----------- ------- ---------------------------- ------
1809    PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_EXT B     GetBooleanv   -     True if primitive restart is 10.3.4
1810                                                                          supported for patches
1811
1812    Add new table 20.43ts "Implementation Dependent Tessellation Shader Limits"
1813    following table 6.31 "Implementation Dependent Vertex Shader Limits":
1814
1815                                                                          Minimum
1816    Get Value                                           Type  Get Command  Value  Description                     Sec.
1817    -------------------------                           ----  ----------- ------- ------------------------------- ------
1818    MAX_TESS_GEN_LEVEL_EXT                              Z+    GetIntegerv   64    Max. level supported by         11.1ts.2
1819                                                                                  tess. primitive generator
1820    MAX_PATCH_VERTICES_EXT                              Z+    GetIntegerv   32    Maximum patch size              10.1
1821    MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT             Z+    GetIntegerv   1024  No. of words for TCS uniforms   11.1ts.1.1
1822    MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT          Z+    GetIntegerv   1024  No. of words for TES uniforms   11.1ts.3.1
1823    MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT            Z+    GetIntegerv   16    No. of tex. image units for TCS 11.1.3.5
1824    MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT         Z+    GetIntegerv   16    No. of tex. image units for TES 11.1.3.5
1825    MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT              Z+    GetIntegerv   64    No. components for per-patch    11.1ts.1.2
1826                                                                                  vertex outputs in TCS
1827    MAX_TESS_PATCH_COMPONENTS_EXT                       Z+    GetIntegerv   120   No. components for per-patch    11.1ts.1.2
1828                                                                                  output varyings for TCS
1829    MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT        Z+    GetIntegerv   2048  Total no. components for TCS    11.1ts.1.2
1830                                                                                  outputs
1831    MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT           Z+    GetIntegerv   64    No. components for per-vertex   11.1ts.3.2
1832                                                                                  outputs in TES
1833    MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT               Z+    GetIntegerv   64    No. components for per-vertex   11.1ts.1.2
1834                                                                                  inputs in TCS
1835    MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT            Z+    GetIntegerv   64    No. components for per-vertex   11.1ts.3.2
1836                                                                                  inputs in TES
1837    MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT                 Z+    GetIntegerv   12    No. of supported uniform        7.6.2
1838                                                                                  blocks for TCS
1839    MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT              Z+    GetIntegerv   12    No. of supported uniform        7.6.2
1840                                                                                  blocks for TES
1841    MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT         Z+    GetIntegerv   0     No. of AC (atomic counter)      7.7
1842                                                                                  buffers accessed by a TCS
1843    MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT      Z+    GetIntegerv   0     No. of AC (atomic counter)      7.7
1844                                                                                  buffers accessed by a TES
1845    MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT                Z+    GetIntegerv   0     Number of ACs accessed by a TCS 11.1.3.6
1846    MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT             Z+    GetIntegerv   0     Number of ACs accessed by a TES 11.1.3.6
1847    MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT          Z+    GetIntegerv   0     No. of shader storage blocks    7.8
1848                                                                                  accessed by a TCS
1849    MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT       Z+    GetIntegerv   0     No. of shader storage blocks    7.8
1850                                                                                  accessed by a TES
1851
1852
1853    Add to table 20.46 "Implementation Dependent Aggregate Shader Limits"
1854    ([fn] is a dagger mark referring to existing text in the table caption):
1855
1856
1857                                                                          Minimum
1858    Get Value                                           Type  Get Command Value   Description                   Sec.
1859    --------------------------------------------------- ----  ----------- ------- ----------------------------- ----------
1860    MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT                 Z+    GetIntegerv 0       No. of image variables in TCS 11.1.3.7
1861                                                                                  in TCS
1862    MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT              Z+    GetIntegerv 0       No. of image variables in TES 11.1.3.7
1863    MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT    Z+    GetIntegerv [fn]    No. of words for TCS uniform  11.1ts.1.1
1864                                                                                  variables in all uniform
1865                                                                                  blocks (including default)
1866    MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT Z+    GetIntegerv [fn]    No. of words for TES uniform  11.1ts.3.1
1867                                                                                  variables in all uniform
1868                                                                                  blocks (including default)
1869
1870    Modify existing entries in table 20.46:
1871
1872                                                                          Minimum
1873    Get Value                                           Type  Get Command Value   Description                Sec.
1874    --------------------------------------------        ----  ----------- ------- -------------------------- -------
1875    MAX_UNIFORM_BUFFER_BINDINGS                         Z+    GetIntegerv 72      Max. no. of uniform buffer 7.6.2
1876                                                                                  binding points
1877    MAX_COMBINED_UNIFORM_BLOCKS                         Z+    GetIntegerv 60      Max. no. of uniform        7.6.2
1878                                                                                  buffers per program
1879    MAX_COMBINED_TEXTURE_IMAGE_UNITS                    Z+    GetIntegerv 96      Total no. of tex. units    11.1.3.5
1880                                                                                  accessible by the GL
1881
1882Additions to the OpenGL ES Shading Language 3.10 Specification
1883
1884    Including the following line in a shader can be used to control the
1885    language features described in this extension:
1886
1887      #extension GL_EXT_tessellation_shader : <behavior>
1888      #extension GL_EXT_tessellation_point_size : <behavior>
1889
1890    where <behavior> is as specified in section 3.4.
1891
1892    A new preprocessor #define is added to the OpenGL ES Shading Language:
1893
1894      #define GL_EXT_tessellation_shader 1
1895      #define GL_EXT_tessellation_point_size 1
1896
1897    If the EXT_tessellation_shader extension is enabled, the
1898    EXT_shader_io_blocks extension is also implicitly enabled.
1899
1900
1901    Change the introduction to Chapter 2 "Overview of OpenGL ES Shading" as
1902    follows:
1903
1904    The OpenGL ES Shading Language is actually several closely related
1905    languages. These languages are used to create shaders for each of the
1906    programmable processors contained in the OpenGL ES processing pipeline.
1907    Currently, these processors are the compute, vertex, tessellation
1908    control, tessellation evaluation, geometry, and fragment processors.
1909
1910    Unless otherwise noted in this Specification, a language feature applies
1911    to all languages, and common usage will refer to these languages as a
1912    single language. The specific languages will be referred to by the name
1913    of the processor they target: compute, vertex, tessellation control,
1914    tessellation evalution, geometry, or fragment.
1915
1916
1917    Add new subsections 2.ts1 and 2.ts2 preceding subsection 2.gs "Geometry
1918    Processor":
1919
1920    Section 2.ts1, Tessellation Control Processor
1921
1922    The <tessellation control processor> is a programmable unit that
1923    operates on a patch of incoming vertices and their associated data,
1924    emitting a new output patch. Compilation units written in the OpenGL ES
1925    Shading Language to run on this processor are called tessellation
1926    control shaders. When a tessellation control shader is compiled and
1927    linked, it results in a tessellation control shader executable that runs
1928    on the tessellation control processor.
1929
1930    The tessellation control processor is invoked for each each vertex of
1931    the output patch. Each invocation can read the attributes of any vertex
1932    in the input or output patches, but can only write per-vertex attributes
1933    for the corresponding output patch vertex. The shader invocations
1934    collectively produce a set of per-patch attributes for the output patch.
1935    After all tessellation control shader invocations have completed, the
1936    output vertices and per-patch attributes are assembled to form a patch
1937    to be used by subsequent pipeline stages.
1938
1939    Tessellation control shader invocations run mostly independently, with
1940    undefined relative execution order. However, the built-in function
1941    barrier() can be used to control execution order by synchronizing
1942    invocations, effectively dividing tessellation control shader execution
1943    into a set of phases. Tessellation control shaders will get undefined
1944    results if one invocation reads a per-vertex or per-patch attribute
1945    written by another invocation at any point during the same phase, or if
1946    two invocations attempt to write different values to the same per-patch
1947    output in a single phase.
1948
1949    Section 2.ts2, Tessellation Evaluation Processor
1950
1951    The <tessellation evaluation processor> is a programmable unit that
1952    evaluates the position and other attributes of a vertex generated by the
1953    tessellation primitive generator, using a patch of incoming vertices and
1954    their associated data. Compilation units written in the OpenGL ES
1955    Shading Language to run on this processor are called tessellation
1956    evaluation shaders. When a tessellation evaluation shader is compiled
1957    and linked, it results in a tessellation evaluation shader executable
1958    that runs on the tessellation evaluation processor.
1959
1960    Each invocation of the tessellation evaluation executable computes the
1961    position and attributes of a single vertex generated by the tessellation
1962    primitive generator. The executable can read the attributes of any
1963    vertex in the input patch, plus the tessellation coordinate, which is
1964    the relative location of the vertex in the primitive being tessellated.
1965    The executable writes the position and other attributes of the vertex.
1966
1967
1968    Modifications to Section 3.7 (Keywords)
1969
1970    Remove "patch" from the list of reserved keywords and add it to the list
1971    of keywords.
1972
1973
1974    Modify Section 4.3, Storage Qualifiers
1975
1976    Add two new qualifiers to the storage qualifier table on p. 38:
1977
1978    Qualifier   Meaning
1979    ---------   -------------------------------------------------------------
1980    patch in    linkage of per-patch attributes into a shader from a previous
1981                stage (tessellation evaluation shaders only)
1982
1983    patch out   linkage out of a shader to a subsequent stage (tessellation
1984                control shaders only)
1985
1986
1987    Modify section 4.3.4, Input Variables
1988
1989    Replace the paragraphs starting with "Geometry shader input variables
1990    get ..." and ending with "Fragment shader inputs get ..." on p. 40:
1991
1992    Tessellation control, evaluation, and geometry shader input variables
1993    get the per-vertex values written out by output variables of the same
1994    names in the previous active (vertex) shader stage. For these inputs,
1995    "centroid in", "sample in", and interpolation qualifiers are allowed,
1996    but are equivalent to "in". Since these shader stages operate on a set
1997    of vertices, each input variable or input block (see section 4.3.9
1998    "Interface Blocks") needs to be declared as an array. For example,
1999
2000       in float foo[];    // geometry shader input for vertex "out float foo"
2001
2002    Each element of such an array corresponds to one vertex of the primitive
2003    being processed. Each array can optionally have a size declared. The
2004    array size will be set by (or if provided must be consistent with) the
2005    input layout declaration(s) establishing the type of input primitive, as
2006    described later in section 4.4.1 "Input Layout Qualifiers".
2007
2008    Some inputs and outputs are <arrayed>, meaning that for an interface
2009    between two shader stages either the input or output declaration
2010    requires an extra level of array indexing for the declarations to match.
2011    For example, with the interface between a vertex shader and a geometry
2012    shader, vertex shader output variables and geometry shader input
2013    variables of the same name must match in type and qualification (other
2014    than precision and "out" matching to "in"), except that the geometry
2015    shader will have one more array dimension than the vertex shader, to
2016    allow for vertex indexing. If such an arrayed interface variable is not
2017    declared with the necessary additional input or output array dimension,
2018    a link-time error will result.
2019
2020    For non-arrayed interfaces (meaning array dimensionally stays the same
2021    between stages), it is a link-time error if the input variable is not
2022    declared with the same type, including array dimensionality, and
2023    qualification (other than precision and "out" matching to "in") as the
2024    matching output variable.
2025
2026    Additionally, tessellation evaluation shaders support per-patch input
2027    variables declared with the "patch in" qualifier. Per-patch input
2028    variables are filled with the values of per-patch output variables
2029    written by the tessellation control shader. Per-patch inputs may be
2030    declared as one-dimensional arrays, but are not indexed by vertex
2031    number. Applying the "patch in" qualifier to inputs can only be done in
2032    tessellation evaluation shaders. As with other input variables,
2033    per-patch inputs must be declared using the same type and qualification
2034    (other than precision and "out" matching to "in") as per-patch outputs
2035    from the previous (tessellation control) shader stage.
2036
2037    It is a compile-time error to use the "patch in" qualifier with inputs
2038    in any type of shader other than tessellation evaluation.
2039
2040    Fragment shader inputs get ...
2041
2042
2043    Modify section 4.3.6 "Output Variables" starting with the third
2044    paragraph of the section, on p. 42:
2045
2046    Vertex, tessellation evaluation, and geometry output variables output
2047    per-vertex data and are declared using the "out", "centroid out", or
2048    "sample out" storage qualifiers. Applying the "patch out" qualifier to
2049    an output can only be done in tessellation control shaders. Output
2050    variables can only be floating-point scalars, floating-point vectors,
2051    matrices, signed or unsigned integers or integer vectors, or arrays or
2052    structures of any of these.
2053
2054    It is a compile-time error to use the "patch out" qualifier with outputs
2055    in any other type of shader other than tessellation control.
2056
2057    Individual vertex, tessellation control, tessellation evaluation, and
2058    geometry outputs are declared as in the following examples: ...
2059
2060
2061    Following this modified language and leading into the last paragraph of
2062    section 4.3.6 on p. 37 (starting "Fragment outputs output
2063    per-fragment"), add:
2064
2065    Tessellation control shader output variables are used to output
2066    per-vertex and per-patch data. Per-vertex output variables are arrayed
2067    (see "arrayed" in section 4.3.4, "Inputs") and declared using the "out",
2068    "centroid out", or "sample out" qualifiers; the "patch out" qualifier is
2069    not allowed. Per-patch output variables must be declared using the
2070    "patch out" qualifier. Per-vertex and per-patch output variables can
2071    only be floating-point scalars, vectors, or matrices, signed or unsigned
2072    integers or integer vectors, or arrays or structures of these. Since
2073    tessellation control shaders produce an arrayed primitive comprising
2074    multiple vertices, each per-vertex output variable (or output block, see
2075    interface blocks below) needs to be declared as an array. For example,
2076
2077        out float foo[];         // feeds next stage input "in float foo[]"
2078
2079    Each element of such an array corresponds to one vertex of the primitive
2080    being produced. Each array can optionally have a size declared. The
2081    array size will be set by (or if provided must be consistent with) the
2082    output layout declaration(s) establishing the number of vertices in the
2083    output patch, as described later in section 4.4.2.ts "Tessellation
2084    Control Outputs".
2085
2086    Each tessellation control shader invocation has a corresponding output
2087    patch vertex, and may assign values to per-vertex outputs only if they
2088    belong to that corresponding vertex. If a per-vertex output variable is
2089    used as an l-value, it is a compile- or link-time error if the expression
2090    indicating the vertex index is not the identifier gl_InvocationID.
2091
2092    The order of execution of a tessellation control shader invocation
2093    relative to the other invocations for the same input patch is undefined
2094    unless the built-in function barrier() is used. This provides some
2095    control over relative execution order. When a shader invocation calls
2096    barrier(), its execution pauses until all other invocations have reached
2097    the same point of execution. Output variable assignments performed by
2098    any invocation executed prior to calling barrier() will be visible to
2099    any other invocation after the call to barrier() returns.
2100
2101    Because tessellation control shader invocations execute in undefined
2102    order between barriers, the values of per-vertex or per-patch output
2103    variables will sometimes be undefined. Consider the beginning and end of
2104    shader execution and each call to barrier() as synchronization points.
2105    The value of an output variable will be undefined in any of the three
2106    following cases:
2107
2108    1. At the beginning of execution.
2109
2110    2. At each synchronization point, unless
2111      * the value was well-defined after the previous synchronization point
2112        and was not written by any invocation since, or
2113      * the value was written by exactly one shader invocation since the
2114        previous synchronization point, or
2115      * the value was written by multiple shader invocations since the
2116        previous synchronization point, and the last write performed by all
2117        such invocations wrote the same value.
2118    3. When read by a shader invocation, if
2119      * the value was undefined at the previous synchronization point and
2120        has not been writen by the same shader invocation since, or
2121      * the output variable is written to by any other shader invocation
2122        between the previous and next synchronization points, even if that
2123        assignment occurs in code following the read.
2124
2125    Fragment outputs output per-fragment data and are declared ...
2126
2127
2128    Modify section 4.4.1 "Input Layout Qualifiers" to add new subsections
2129    4.4.1.ts and 4.4.2.ts, preceding the new subsection 4.4.1.gs "Geometry
2130    Shader Inputs":
2131
2132    Section 4.4.1.ts, Tessellation Evaluation Inputs
2133
2134    Additional input layout qualifier identifiers allowed for tessellation
2135    evaluation shaders are:
2136
2137      <layout-qualifier-id>
2138        triangles
2139        quads
2140        isolines
2141        equal_spacing
2142        fractional_even_spacing
2143        fractional_odd_spacing
2144        cw
2145        ccw
2146        point_mode
2147
2148    One group of these identifiers, <primitive mode>, is used to specify a
2149    tessellation primitive mode to be used by the tessellation primitive
2150    generator. To specify a primitive mode, the identifier must be one of
2151    "triangles", "quads", or "isolines", which specify that the tessellation
2152    primitive generator should subdivide a triangle into smaller triangles,
2153    a quad into triangles, or a quad into a collection of lines,
2154    respectively.
2155
2156    A second group of these identifiers, <vertex spacing>, is used to
2157    specify the spacing used by the tessellation primitive generator when
2158    subdividing an edge. To specify vertex spacing, the identifier must be
2159    one of:
2160
2161      * "equal_spacing", signifying that edges should be divided into a
2162         collection of <N> equal-sized segments;
2163
2164      * "fractional_even_spacing", signifying that edges should be divided
2165        into an even number of equal-length segments plus two additional
2166        shorter "fractional" segments; or
2167
2168      * "fractional_odd_spacing", signifying that edges should be divided
2169        into an odd number of equal-length segments plus two additional
2170        shorter "fractional" segments.
2171
2172    A third subset of these identifiers, <ordering>, specifies whether the
2173    tessellation primitive generator produces triangles in clockwise or
2174    counter-clockwise order, according to the coordinate system depicted in
2175    the OpenGL ES Specification. The identifiers "cw" and "ccw" indicate
2176    clockwise and counter-clockwise triangles, respectively. If the
2177    tessellation primitive generator does not produce triangles, the order
2178    is ignored.
2179
2180    Finally, <point mode> is specified with the identifier "point_mode"
2181    indicating that the tessellation primitive generator should produce one
2182    point for each distinct vertex in the subdivided primitive, rather than
2183    generating lines or triangles.
2184
2185    Any or all of these identifiers may be specified one or more times in a
2186    single input layout declaration.
2187
2188    The tessellation evaluation shader object in a program must declare a
2189    primitive mode in its input layout. Declaring vertex spacing, ordering,
2190    or point mode identifiers is optional. If spacing or vertex order
2191    declarations are omitted, the tessellation primitive generator will use
2192    equal spacing or counter-clockwise vertex ordering, respectively. If a
2193    point mode declaration is omitted, the tessellation primitive generator
2194    will produce lines or triangles according to the primitive mode.
2195
2196
2197    Section 4.4.2.ts, Tessellation Control Outputs
2198
2199    Other than for the transform feedback layout qualifiers, tessellation
2200    control shaders allow output layout qualifiers only on the interface
2201    qualifier "out", not on an output block, block member, or variable
2202    declaration. The output layout qualifier identifiers allowed for
2203    tessellation control shaders are:
2204
2205      layout-qualifier-id
2206        vertices = integer-constant
2207
2208    The identifier "vertices" specifies the number of vertices in the output
2209    patch produced by the tessellation control shader, which also specifies
2210    the number of times the tessellation control shader is invoked. It is a
2211    compile- or link-time error for the output vertex count to be less than
2212    or equal to zero, or greater than the implementation-dependent maximum
2213    patch size.
2214
2215    The intrinsically declared tessellation control output array gl_out[]
2216    will also be sized by any output layout declaration. Hence, the
2217    expression
2218
2219      gl_out.length()
2220
2221    will return the output patch vertex count specified in a previous output
2222    layout qualifier. For outputs declared without an array size, including
2223    intrinsically declared outputs (i.e., gl_out), a layout must be declared
2224    before any use of the method length() or other array use that requires
2225    its size to be known.
2226
2227    It is a compile-time error if the output patch vertex count specified in
2228    an output layout qualifier does not match the array size specified in
2229    any output variable declaration in the same shader.
2230
2231    All tessellation control shader layout declarations in a program must
2232    specify the same output patch vertex count. There must be at least one
2233    layout qualifier specifying an output patch vertex count in any program
2234    containing a tessellation control shader.
2235
2236
2237    Modify section 7 to add new subsections 7.1ts1 and 7.1ts2 following
2238    section 7.1.1 "Vertex Shader Special Variables":
2239
2240    Section 7.1ts1, Tessellation Control Special Variables
2241
2242    In the tessellation control language, built-in variables are
2243    intrinsically declared as:
2244
2245        [[ If EXT_tessellation_point_size is supported and enabled: ]]
2246      in gl_PerVertex {
2247          highp vec4 gl_Position;
2248          hihgp float gl_PointSize;
2249      } gl_in[gl_MaxPatchVertices];
2250
2251        [[ Otherwise: ]]
2252      in gl_PerVertex {
2253          highp vec4 gl_Position;
2254      } gl_in[gl_MaxPatchVertices];
2255
2256      in highp int gl_PatchVerticesIn;
2257      in highp int gl_PrimitiveID;
2258      in highp int gl_InvocationID;
2259
2260        [[ If EXT_tessellation_point_size is supported and enabled: ]]
2261      out gl_PerVertex {
2262          highp vec4 gl_Position;
2263          highp float gl_PointSize;
2264      } gl_out[];
2265
2266        [[ Otherwise: ]]
2267      out gl_PerVertex {
2268          highp vec4 gl_Position;
2269      } gl_out[];
2270
2271      patch out highp float gl_TessLevelOuter[4];
2272      patch out highp float gl_TessLevelInner[2];
2273
2274
2275    Section 7.1ts1.1, Tessellation Control Input Variables
2276
2277    gl_Position contains the output written in the previous shader stage to
2278    gl_Position.
2279
2280      [[ If EXT_tessellation_point_size is supported: ]]
2281    gl_PointSize contains the output written in the previous shader stage to
2282    gl_PointSize.
2283
2284    gl_PatchVerticesIn contains the number of vertices in the input patch
2285    being processed by the shader. A single shader can read patches of
2286    differing sizes, so the value of gl_PatchVerticesIn may differ between
2287    patches.
2288
2289    gl_PrimitiveID contains the number of primitives processed by the
2290    shader since the current set of rendering primitives was started.
2291
2292    gl_InvocationID contains the number of the output patch vertex assigned
2293    to the tessellation control shader invocation. It is assigned integer
2294    values in the range [0, N-1], where N is the number of output patch
2295    vertices per primitive.
2296
2297
2298    Section 7.1ts1.2, Tessellation Control Output Variables
2299
2300    gl_Position is used in the same fashion as the
2301    corresponding output variable in the vertex shader.
2302
2303      [[ If EXT_tessellation_point_size is supported: ]]
2304    gl_PointSize is used in the same fashion as the corresponding output
2305    variable in the vertex shader.
2306
2307    The values written to gl_TessLevelOuter and gl_TessLevelInner are
2308    assigned to the corresponding outer and inner tessellation levels of the
2309    output patch. They are used by the tessellation primitive generator to
2310    control primitive tessellation, and may be read by tessellation
2311    evaluation shaders.
2312
2313
2314    Section 7.1ts2, Tessellation Evaluation Special Variables
2315
2316    In the tessellation evaluation language, built-in variables are
2317    intrinsically declared as:
2318
2319        [[ If EXT_tessellation_point_size is supported and enabled: ]]
2320      in gl_PerVertex {
2321          highp vec4 gl_Position;
2322          highp float gl_PointSize;
2323      } gl_in[gl_MaxPatchVertices];
2324
2325        [[ Otherwise: ]]
2326      in gl_PerVertex {
2327          highp vec4 gl_Position;
2328      } gl_in[gl_MaxPatchVertices];
2329
2330      in highp int gl_PatchVerticesIn;
2331      in highp int gl_PrimitiveID;
2332      in highp vec3 gl_TessCoord;
2333      patch in highp float gl_TessLevelOuter[4];
2334      patch in highp float gl_TessLevelInner[2];
2335
2336        [[ If EXT_tessellation_point_size is supported and enabled: ]]
2337      out gl_PerVertex {
2338          highp vec4 gl_Position;
2339          hihgp float gl_PointSize;
2340      };
2341
2342        [[ Otherwise: ]]
2343      out gl_PerVertex {
2344          highp vec4 gl_Position;
2345      };
2346
2347    Section 7.1ts2.1, Tessellation Evaluation Input Variables
2348
2349    gl_Position contains the output written in the previous shader stage to
2350    gl_Position.
2351
2352      [[ If EXT_tessellation_point_size is supported: ]]
2353    gl_PointSize contains the output written in the previous shader stage to
2354    gl_PointSize.
2355
2356    gl_PatchVerticesIn and gl_PrimitiveID are defined in the same fashion as
2357    the corresponding input variables in the tessellation control shader.
2358
2359    gl_TessCoord specifies a three-component (u,v,w) vector identifying the
2360    position of the vertex being processed by the shader relative to the
2361    primitive being tessellated. Its values will obey the properties
2362
2363      gl_TessCoord.x == 1.0 - (1.0 - gl_TessCoord.x) // two operations performed
2364      gl_TessCoord.y == 1.0 - (1.0 - gl_TessCoord.y) // two operations performed
2365      gl_TessCoord.z == 1.0 - (1.0 - gl_TessCoord.z) // two operations performed
2366
2367    gl_TessLevelOuter and gl_TessLevelInner are filled with the corresponding
2368    output variables written by the active tessellation control shader.
2369
2370
2371    Section 7.1ts2.2, Tessellation Evaluation Output Variables
2372
2373    gl_Position is used in the same fashion as the
2374    corresponding output variable in the vertex shader.
2375
2376      [[ If EXT_tessellation_point_size is supported: ]]
2377    gl_PointSize is used in the same fashion as the corresponding output
2378    variable in the vertex shader.
2379
2380
2381    Add to Section 7.2 "Built-In Constants", matching the
2382    corresponding API implementation-dependent limits:
2383
2384      const mediump int gl_MaxTessControlInputComponents = 64;
2385      const mediump int gl_MaxTessControlOutputComponents = 64;
2386      const mediump int gl_MaxTessControlTextureImageUnits = 16;
2387      const mediump int gl_MaxTessControlUniformComponents = 1024;
2388      const mediump int gl_MaxTessControlTotalOutputComponents = 2048;
2389
2390      const mediump int gl_MaxTessEvaluationInputComponents = 64;
2391      const mediump int gl_MaxTessEvaluationOutputComponents = 64;
2392      const mediump int gl_MaxTessEvaluationTextureImageUnits = 16;
2393      const mediump int gl_MaxTessEvaluationUniformComponents = 1024;
2394
2395      const mediump int gl_MaxTessPatchComponents = 120;
2396
2397      const mediump int gl_MaxPatchVertices = 32;
2398      const mediump int gl_MaxTessGenLevel = 64;
2399
2400    Modify gl_MaxCombinedTextureImageUnits to match the API:
2401
2402      const mediump int gl_MaxCombinedTextureImageUnits = 96;
2403
2404
2405    Modify section 8.15 "Shader Invocation Control Functions":
2406
2407    The shader invocation control function is only available in tessellation
2408    control and compute shaders. It is used to control the relative
2409    execution order of multiple shader invocations used to process a patch
2410    (in the case of tessellation control shaders) or a local work group (in
2411    the case of compute shaders), which are otherwise executed with an
2412    undefined order.
2413
2414    +------------------+---------------------------------------------------------------+
2415    | Syntax           | Description                                                   |
2416    +------------------+---------------------------------------------------------------+
2417    | void             | For any given static instance of barrier(), all               |
2418    | barrier(void)    | tessellation control shader invocations for a single input    |
2419    |                  | patch, or all compute shader invocations for a single work    |
2420    |                  | group must enter it before any will continue beyond it.       |
2421    +------------------+---------------------------------------------------------------+
2422
2423    The function barrier() provides a partially defined order of execution
2424    between shader invocations. This ensures that values written by one
2425    invocation prior to a given static instance of barrier() can be safely
2426    read by other invocations after their call to the same static instance
2427    barrier(). Because invocations may execute in an undefined order between
2428    these barrier calls, the values of a per-vertex or per-patch output
2429    variable for tessellation control shaders, or the values of shared
2430    variables for compute shaders will be undefined in a number of cases
2431    enumerated in section 4.3.6 "Output Variables" (for tessellation control
2432    shaders) and section 4.3.7 "Shared Variables" (for compute shaders).
2433
2434    For tessellation control shaders, the barrier() function may only be
2435    placed inside the function main() of the shader and may not be called
2436    within any control flow. Barriers are also disallowed after a return
2437    statement in the function main(). Any such misplaced barriers result in
2438    a compile-time error.
2439
2440    For compute shaders, the barrier() function ...
2441
2442
2443Issues
2444
2445    Note: These issues apply specifically to the definition of the
2446    EXT_tessellation_shader specification, which is based on the OpenGL
2447    extension ARB_tessellation_shader as updated in OpenGL 4.x. Resolved
2448    issues from ARB_tessellation_shader have been removed, but remain
2449    largely applicable to this extension. ARB_tessellation_shader can be
2450    found in the OpenGL Registry.
2451
2452    (1) What functionality was removed from ARB_tessellation_shader?
2453
2454        Very little. Tessellation shaders are largely self-contained
2455        functionality and the only removed interactions with features not
2456        supported by the underlying OpenGL ES 3.1 API and Shading Language
2457        were:
2458          * Fixed-function inputs and outputs present only in the GL
2459            compatibility profile.
2460          * gl_ClipDistance shader inputs and outputs.
2461          * While multi-dimensional arrays are supported by GLSL-ES 3.10,
2462            they are explicitly not supported as shader inputs and outputs,
2463            and that decision is respected here.
2464          * Using a tessellation evaluation shader without a tessellation
2465            control shader is not allowed. See issue 13.
2466          * PATCH_DEFAULT_*_LEVEL parameters (issue 13).
2467
2468    (2) What functionality was changed and added relative to
2469        ARB_tessellation_shader?
2470
2471      - EXT_tessellation_shader closely matches OpenGL 4.4 tessellation
2472        shader language, rather than ARB_tessellation_shader language.
2473      - Spec language is now based off of changes introduced by
2474        EXT_geometry_shader, especially with regard to input and output
2475        blocks.
2476      - Note that although this spec mentions quad primitives repeatedly,
2477        this is not inconsistent with the lack of support for QUADS drawing
2478        primitives in OpenGL ES. The quad primitives discussed here occur
2479        only during patch tessellation and are emitted as triangles to later
2480        stages of the pipeline.
2481      - Writing point size from tessellation shaders is optional functionality.
2482        If it's not supported or written, the point size of 1.0 is used.
2483      - Added precision qualifiers to builtins.
2484      - ARB_tessellation_shader required that the tessellation primitive
2485        generator reject a patch when any outer tessellation level contained a
2486        NaN, even if the outer tessellation level is irrelevant for the
2487        primitive type. As that was likely unintended (see Khronos bug 11484),
2488        EXT_tessellation_shader only rejects patches if relevant outer
2489        tessellation levels contain NaN.
2490      - Added program interface query properties relevant to tessellation
2491        shaders.
2492
2493    (3) Are any grammar additions required in chapter 9?
2494
2495    Probably, but such changes are not included in the original
2496    ARB_tessellation_shader extension, either. TBD.
2497
2498    (4) Should GetActiveUniformBlockiv
2499        support queries for uniform blocks and atomic counter buffers
2500        referenced by tessellation shaders?
2501
2502    RESOLVED: No. Use the new generic query interface supported by
2503    OpenGL ES 3.1, following the resolution for other features such as compute
2504    shaders, which also dropped these legacy tokens / queries.
2505
2506    (5) How are aggregate shader limits computed?
2507
2508    RESOLVED: Following the GL 4.4 model, but we restrict uniform
2509    buffer bindings to 12/stage instead of 14, this results in
2510
2511        MAX_UNIFORM_BUFFER_BINDINGS = 72
2512            This is 12 bindings/stage * 6 shader stages, allowing a static
2513            partitioning of the bindings even though at most 5 stages can
2514            appear in a program object).
2515        MAX_COMBINED_UNIFORM_BLOCKS = 60
2516            This is 12 blocks/stage * 5 stages, since compute shaders can't
2517            be mixed with other stages.
2518        MAX_COMBINED_TEXTURE_IMAGE_UNITS = 96
2519            This is 16 textures/stage * 6 stages.
2520
2521    Khronos internal bugs 5870, 8891, and 9424 cover the ARB's thinking on
2522    these limits for GL 4.0 and beyond.
2523
2524    (6) Are arrays supported as shader inputs and outputs?
2525
2526    RESOLVED: No. In several places in the tessellation and geometry API
2527    language based on GL 4.4, it says that "the OpenGL ES Shading Language
2528    doesn't support multi-dimensional arrays" and restricts declarations of
2529    inputs and outputs which are array members to blocks themselves declared
2530    as arrays.
2531
2532    Strictly speaking this is no longer true. GLSL-ES 3.10 supports
2533    multi-dimensional arrays, but also notes in issue 0 that "arrays of
2534    arrays are not allowed as shader inputs or outputs."
2535
2536    Given this constraint, and since the same constraint is in OpenGL 4.4, I
2537    propose we resolve this by continuing to limit array inputs and outputs
2538    in this fashion, and change the language to "...doesn't support
2539    multi-dimensional arrays as shader inputs or outputs".
2540
2541    (7) What component counting rules are used for inputs and outputs?
2542
2543    RESOLVED: In several places I've inserted language from OpenGL 4.4 to
2544    the effect of
2545
2546       "Component counting rules for different variable types and variable
2547        declarations are the same as for MAX_VERTEX_OUTPUT_COMPONENTS (see
2548        section 11.1.2.1)."
2549
2550    I think this is essentially cleaning up an oversight in the earlier ARB
2551    extension language but it is a bit orthogonal to the extension
2552    functionality and I'm bringing it up in case this is a potential issue.
2553
2554    (8) What component counting rules are used for the default
2555    uniform block?
2556
2557    RESOLVED: In several places I've inserted language from OpenGL 4.2 to
2558    the effect of
2559
2560       "A uniform matrix in the default uniform block with single-precision
2561        components will consume no more than 4 x min(r,c) uniform
2562        components."
2563
2564    This is based on bug 5432 and is language that was later expanded in
2565    OpenGL 4.4 and refactored into the generic "Uniform Variables" section,
2566    which is something we should consider in the EXT extensions as well to
2567    avoid duplication. I believe it is what we want but am noting it for the
2568    same reason as the language in issue (8). I'm hoping to be able to
2569    include this refactored language into the OpenGL ES 3.1 Specification,
2570    so we can refer to it more easily here. Tracking bug 11192 has been
2571    opened for this and this language was approved there.
2572
2573    (9) The edits on section 4.4.1.ts (Tessellation Evaluation Inputs)
2574    says that "Any or all of these identifiers may be specified one or more
2575    times in a single input layout declaration." Do we need to add in the
2576    language from GLSL 4.40 Section 4.4 "Layout Qualifiers" that defines this?
2577
2578    RESOLVED: ES 3.1 will be picking up the relaxed qualifier ordering
2579    and it is presumed that this language will be coming along with it.
2580    In any case, the EXT_shader_io_blocks extension clarifies this.
2581
2582    (10) Due to HW limitations, some vendors may not be able
2583    to support writing gl_PointSize from tessellation shaders, how should we
2584    accomodate this?
2585
2586    RESOLVED: There are two extensions described in this document. The
2587    base extension does not support writing to gl_PointSize from tessellation
2588    shaders and the gl_PerVertex block does not include gl_PointSize.
2589    Additionally there is a layered extension which provides the ability
2590    to write to gl_PointSize from tessellation shaders.  When this extension
2591    is enabled, the gl_PerVertex block does include gl_PointSize and it
2592    can be written from a tessellation control or evaluation shader as normal.
2593
2594    If the point-size extension is not supported, all points written
2595    from a tessellation shader will have size of one. If the point-size
2596    extension is supported but not enabled, or if it's enabled but
2597    gl_PointSize is not written, it as if a point size of one was written.
2598    Otherwise, if you statically assign gl_PointSize in the last stage
2599    before the rasterizer, the (potentially clamped) value written will
2600    determine the size of the point for rasterization.
2601
2602    (11) Do we need a separate point_size extension from the one included
2603    in EXT_geometry_shader or can we use the some one?
2604
2605    RESOLVED. We will use a separate extension to allow for maximum
2606    implementation flexibility.
2607
2608    (12) Can a tessellation evaluation shader be used without a tessellation
2609    control shader?
2610
2611    RESULT: No. This isn't allowed in other graphics APIs, and some vendors
2612    designed hardware based on those APIs. Attempts to draw with only one of the
2613    two tessellation shaders active results in an INVALID_OPERATION error.
2614    Vendors that designed hardware for ARB_tessellation_shader or versions of
2615    OpenGL that included it may choose to relax this restriction via extension.
2616    One implication of this is that the default tessellation levels are useless,
2617    since an active tessellation control shader always overrides them, so they
2618    are not included in this spec.
2619
2620    (13) What happens if you use "patch out" in a tessellation evaluation
2621    shader or "patch in" in a tessellation control shader?
2622
2623    RESOLVED.  GLSL 4.40 spec only says "Applying the patch qualifier to
2624    inputs can only be done in tessellation evaluation shaders." and
2625    "Applying patch to an output can only be done in a tessellation control
2626    shader."  There is also a statement that says "It is a compile-time error
2627    to use patch in a fragment shader."  In Bug 11527 the ARB decided this
2628    should be a compile-time error as this can be determined by solely by
2629    looking at variable declaration.
2630
2631    (14) Do we need to make accommodations for tile-based implementations?
2632
2633    RESOLVED.  Yes, but it will be done as a separate extension as it is
2634    applicable to more than just tessellation shaders.
2635
2636    (15) Can inputs and outputs from tessellation shaders be arrays of
2637    structures?
2638
2639    RESOLVED. Yes they can.  OpenGL ES 3.1 disallows passing arrays of
2640    structures between stages. However, since vertex shader outputs
2641    can be structures we need to add the extra level of
2642    array-ness when these are accessed from a tessellation control shader.
2643    Similarly this applies to outputs from a tessellation control shader
2644    and inputs to a tessellation evaluation shader. However as in GL,
2645    arrays of arrays are not supported.
2646
2647    (16) Tessellation using "point_mode" is supposed to emit each distinct
2648    vertex produced by the tessellation primitive generator exactly once.
2649    Are there cases where this can produce multiple vertices with the same
2650    position?
2651
2652    RESOLVED:  Yes.  If fractional odd spacing is used, we have outer
2653    tessellation levels that are greater than 1.0, and inner tessellation
2654    levels less than or equal to 1.0, this can occur.  If any outer level is
2655    greater than 1.0, we will subdivide the outer edges of the patch, and
2656    will need a subdivided patch interior to connect to.  We handle this by
2657    treating inner levels less than or equal to 1.0 as though they were
2658    slightly greater than 1.0 ("1+epsilon").
2659
2660    With fractional odd spacing, inner levels between 1.0 and 3.0 will
2661    produce a three-segment subdivision, with one full-size interior segment
2662    and two smaller ones on the outside.  The following figure illustrates
2663    what happens to quad tessellation if the horizontal inner LOD (IL0) goes
2664    from 3.0 toward 1.0 in fractional odd mode:
2665
2666             IL0==3         IL0==2         IL0=1.5       IL0=1.2
2667          +-----------+  +-----------+  +-----------+  +-----------+
2668          |           |  |           |  |           |  |           |
2669          |   +---+   |  |  +-----+  |  | +-------+ |  |+---------+|
2670          |   |   |   |  |  |     |  |  | |       | |  ||         ||
2671          |   |   |   |  |  |     |  |  | |       | |  ||         ||
2672          |   +---+   |  |  +-----+  |  | +-------+ |  |+---------+|
2673          |           |  |           |  |           |  |           |
2674          +-----------+  +-----------+  +-----------+  +-----------+
2675
2676    As the inner level approaches 1.0, the vertical inner edges in this
2677    example get closer and closer to the outer edge.  The distance between
2678    the inner and outer vertical edges approaches zero for an inner level of
2679    1+epsilon, and the positions of vertices produced by subdividing such
2680    edges may be numerically indistinguishable.
2681
2682    (17) Why does this extension not support GLSL built-in constants for the
2683    following limits?
2684
2685        - gl_MaxTessControlAtomicCounters
2686        - gl_MaxTessEvaluationAtomicCounters
2687        - gl_MaxTessControlAtomicCounterBuffers
2688        - gl_MaxTessEvaluationAtomicCounterBuffers
2689        - gl_MaxTessControlImageUniforms
2690        - gl_MaxTessEvaluationImageUniforms
2691
2692    RESOLVED: These were accidentally left out when drafting the extension,
2693    and cannot be added now because shipping implementations don't support
2694    them. This was fixed when these extensions were promoted into OpenGL ES
2695    Shading Language 3.20.
2696
2697Revision History
2698
2699    Rev.    Date    Author    Changes
2700    ----  --------  --------- -------------------------------------------------
2701     24   02/03/17  Jon Leech Add issue 17 noting missing GLSL built-in constants
2702                              (public bug 1427).
2703
2704     23   05/31/16  Jon Leech Note that primitive ID counters are reset to zero
2705                              after each instance drawn (Bug 14024).
2706
2707     22   04/29/16  Jon Leech Fix GLSL-ES built-in constants to match API
2708                              limits (Bug 12823).
2709
2710     21   04/27/16  Jon Leech Reduce minimum value of
2711                              MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT        Z+    GetIntegerv   2048  Total no. components for TCS    11.1ts.1.2
2712                              from 4096 to 2048 (Bug 12823)
2713
2714     20   07/23/15  Jon Leech Reduce minimum value of
2715                              MAX_TESS_{CONTROL,EVALUATION}_{IN,OUT}PUT_COMPONENTS
2716                              to 64 (Bug 12823)
2717
2718     19   05/05/15  dkoch     Allow arrays for both per-patch and per-vertex
2719                              TCS outputs (Bug 13658).
2720                              Fix typo in issue 15 suggesting that VS outputs
2721                              could be an array of structures (Bug 13824).
2722
2723     18   04/20/15  Jon Leech Remove "per-patch" part of description of
2724                              MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS
2725                              (Bug 13765).
2726
2727     17   04/29/14  dkoch     Add missing edits to Section 12.1 for XFB
2728
2729     16   04/25/14  dkoch     Allow compile-time error for improperly sized
2730                              per-vertex inputs/outputs (Bug 12185).
2731                              Allow link-time error for TCS per-vertex outputs
2732                              not indexed by gl_InvocationID (Bug 12112).
2733                              Add issue 15 clarifying arrays of structs.
2734                              Clarify that the tessellation primitive
2735                              generator may produce multiple vertices with
2736                              the same gl_TessCoord values in point mode when
2737                              fractional odd spacing is used with an inner
2738                              tessellation level less than or equal to 1.0
2739                              (bug 11979) (Issue 16).
2740
2741     15   04/01/14  dkoch     Update contributors, removed duplicated line.
2742
2743     14   03/28/14  dkoch     Fix typo in Isoline tessellation: lines are sub-
2744                              divided based on second outer tessellation level
2745                              not the first (from ARB_ts v.19 and GL 4.4)
2746
2747     13   03/26/14  Jon Leech Sync with released ES 3.1 specs. Reflow text.
2748
2749     12   03/21/14  dkoch     Update contributors, remove bounding box.
2750
2751     11   03/10/14  Jon Leech Rebase on OpenGL ES 3.1 and change suffix to EXT.
2752
2753     10   02/27/14  dkoch     Add API edits for bounding box. Issue 15, 16.
2754
2755      9   02/24/14  dkoch     Add missing entry point augmentation.
2756
2757      8   02/20/14  dkoch
2758        - resolved issue 14, added language to make it a compile-time error
2759
2760      7   02/12/14  dkoch
2761        - Resolve issues 6, 7, and 12. Add issues 14 and 15.
2762        - Add IS_PER_PATCH program interface query.
2763        - require EXT_gpu_shader5 for 'precise' functionality.
2764        - Add error condition for 'patch in' in fragment shader.
2765
2766      6   01/20/14  dkoch
2767        - Edits to require both TCS and TES.
2768        - Remove unnecessary PatchParameterfv and default tessellation levels params.
2769        - Fix typo in enum name.
2770        - Update link error for duplicate locations.
2771
2772      5   12/19/13  dkoch
2773        - remove legacy NV_primitive_restart interaction
2774        - add PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED from GL 4.4 (Bug 10364)
2775        - require EXT_shader_io_blocks
2776        - add optional EXT_tessellation_point_size extension
2777        - various minor editorial changes
2778
2779      4   11/28/13  dkoch     Minor updates
2780        - Added missing TESS_*_BIT_EXT to overview.
2781        - Explicitly mention INVALID_ENUM errors as in GL 4.4.
2782        - clarify that a PO or PPO using Tess needs a vertex shader (per GL 4.4).
2783        - Add uniform matrix counting rule for TCS to match TES (per Issue 9).
2784        - remove dangling reference to gl_VerticesOut.
2785        - fix a couple remaining references to multiple shaders.
2786        - fix a few typos, grammar and formatting issues.
2787        - added interaction with OES_shader_multisample_interpolation.
2788
2789      3   11/20/13  Jon Leech Minor updates
2790        - Refer to ES 3.1 instead of ES 3plus.
2791
2792      2   11/06/13  Jon Leech Updates based on Daniel Koch's feedback.
2793        - Remove references from desktop language allowing multiple shader
2794          objects per stage.
2795        - Disallow multi-dimensional arrays as shader inputs & outputs,
2796          consistent with OpenGL ES 3.1 and issue 7.
2797        - Modified sections 4.3.4 / 4.3.6 to treat "centroid in" and "sample
2798          in" as storage qualifiers on par with "in", in keeping with ESSL
2799          3.00 not having yet refactored storage qualifiers as GLSL 4.40 has
2800          already done. Reverted input / output matching to require matches
2801          in everything except in/out and precision, also based on ESSL
2802          3.00. Add "sample in" / "sample out" from
2803          OES_shader_multisample_interpolation.
2804
2805      1   11/03/13  Jon Leech Initial version based on ARB_tessellation_shader.
2806