• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015-2023 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5[[tessellation]]
6= Tessellation
7
8Tessellation involves three pipeline stages.
9First, a <<shaders-tessellation-control,tessellation control shader>>
10transforms control points of a patch and can: produce per-patch data.
11Second, a fixed-function tessellator generates multiple primitives
12corresponding to a tessellation of the patch in (u,v) or (u,v,w) parameter
13space.
14Third, a <<shaders-tessellation-evaluation,tessellation evaluation shader>>
15transforms the vertices of the tessellated patch, for example to compute
16their positions and attributes as part of the tessellated surface.
17The tessellator is enabled when the pipeline contains both a tessellation
18control shader and a tessellation evaluation shader.
19
20
21== Tessellator
22
23If a pipeline includes both tessellation shaders (control and evaluation),
24the tessellator consumes each input patch (after vertex shading) and
25produces a new set of independent primitives (points, lines, or triangles).
26These primitives are logically produced by subdividing a geometric primitive
27(rectangle or triangle) according to the per-patch outer and inner
28tessellation levels written by the tessellation control shader.
29These levels are specified using the <<interfaces-builtin-variables,built-in
30variables>> code:TessLevelOuter and code:TessLevelInner, respectively.
31This subdivision is performed in an implementation-dependent manner.
32If no tessellation shaders are present in the pipeline, the tessellator is
33disabled and incoming primitives are passed through without modification.
34
35The type of subdivision performed by the tessellator is specified by an
36code:OpExecutionMode instruction using one of the code:Triangles,
37code:Quads, or code:IsoLines execution modes.
38ifdef::VK_EXT_shader_object[]
39When using <<shaders-objects, shader objects>>, this instruction must: be
40specified in the tessellation evaluation shader, and may: also be specified
41in the tessellation control shader.
42When using pipelines, this
43endif::VK_EXT_shader_object[]
44ifndef::VK_EXT_shader_object[This]
45instruction may: be specified in either the tessellation evaluation or
46tessellation control shader.
47ifdef::VK_EXT_shader_object[]
48When using shader objects, tessellation-related modes that are required:
49must: be specified in the tessellation evaluation shader, and may: also be
50specified in the tessellation control shader.
51Other tessellation-related modes may: be specified in the tessellation
52evaluation shader.
53When using pipelines, other
54endif::VK_EXT_shader_object[]
55ifndef::VK_EXT_shader_object[Other]
56tessellation-related execution modes can: also be specified in either the
57tessellation control or tessellation evaluation shaders.
58
59Any tessellation-related modes specified in both the tessellation control
60and tessellation evaluation shaders must: be the same.
61
62Tessellation execution modes include:
63
64  * code:Triangles, code:Quads, and code:IsoLines.
65    These control the type of subdivision and topology of the output
66    primitives.
67ifdef::VK_EXT_shader_object[]
68    When using <<shaders-objects, shader objects>>, one mode must: be set in
69    at least the tessellation evaluation stage.
70    When using pipelines, one
71endif::VK_EXT_shader_object[]
72ifndef::VK_EXT_shader_object[One]
73    mode must: be set in at least one of the tessellation shader stages.
74ifdef::VK_KHR_portability_subset[]
75    If the `apiext:VK_KHR_portability_subset` extension is enabled, and
76    slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:tessellationIsolines
77    is ename:VK_FALSE, then isoline tessellation is not supported by the
78    implementation, and code:IsoLines must: not be used in either
79    tessellation shader stage.
80endif::VK_KHR_portability_subset[]
81  * code:VertexOrderCw and code:VertexOrderCcw.
82    These control the orientation of triangles generated by the tessellator.
83ifdef::VK_EXT_shader_object[]
84    When using <<shaders-objects, shader objects>>, one mode must: be set in
85    at least the tessellation evaluation stage.
86    When using pipelines, one
87endif::VK_EXT_shader_object[]
88ifndef::VK_EXT_shader_object[One]
89    mode must: be set in at least one of the tessellation shader stages.
90  * code:PointMode.
91    Controls generation of points rather than triangles or lines.
92    This functionality defaults to disabled, and is enabled if either shader
93    stage includes the execution mode.
94ifdef::VK_EXT_shader_object[]
95    When using <<shaders-objects, shader objects>>, if code:PointMode is set
96    in the tessellation control stage, it must: be identically set in the
97    tessellation evaluation stage.
98endif::VK_EXT_shader_object[]
99ifdef::VK_KHR_portability_subset[]
100    If the `apiext:VK_KHR_portability_subset` extension is enabled, and
101    slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:tessellationPointMode
102    is ename:VK_FALSE, then point mode tessellation is not supported by the
103    implementation, and code:PointMode must: not be used in either
104    tessellation shader stage.
105endif::VK_KHR_portability_subset[]
106  * code:SpacingEqual, code:SpacingFractionalEven, and
107    code:SpacingFractionalOdd.
108    Controls the spacing of segments on the edges of tessellated primitives.
109ifdef::VK_EXT_shader_object[]
110    When using <<shaders-objects, shader objects>>, one mode must: be set in
111    at least the tessellation evaluation stage.
112    When using pipelines, one
113endif::VK_EXT_shader_object[]
114ifndef::VK_EXT_shader_object[One]
115    mode must: be set in at least one of the tessellation shader stages.
116  * code:OutputVertices.
117    Controls the size of the output patch of the tessellation control
118    shader.
119ifdef::VK_EXT_shader_object[]
120    When using <<shaders-objects, shader objects>>, one value must: be set
121    in at least the tessellation control stage.
122    When using pipelines, one
123endif::VK_EXT_shader_object[]
124ifndef::VK_EXT_shader_object[One]
125    value must: be set in at least one of the tessellation shader stages.
126
127For triangles, the tessellator subdivides a triangle primitive into smaller
128triangles.
129For quads, the tessellator subdivides a rectangle primitive into smaller
130triangles.
131For isolines, the tessellator subdivides a rectangle primitive into a
132collection of line segments arranged in strips stretching across the
133rectangle in the [eq]#u# dimension (i.e. the coordinates in code:TessCoord
134are of the form [eq]#(0,x)# through [eq]#(1,x)# for all tessellation
135evaluation shader invocations that share a line).
136
137Each vertex produced by the tessellator has an associated (u,v,w) or (u,v)
138position in a normalized parameter space, with parameter values in the range
139[eq]#[0,1]#, as illustrated
140ifdef::VK_VERSION_1_1,VK_KHR_maintenance2[]
141in figures <<img-tessellation-topology-ul>> and
142<<img-tessellation-topology-ll>>.
143The domain space can: have either an upper-left or lower-left origin,
144selected by the pname:domainOrigin member of
145slink:VkPipelineTessellationDomainOriginStateCreateInfo.
146endif::VK_VERSION_1_1,VK_KHR_maintenance2[]
147ifndef::VK_VERSION_1_1,VK_KHR_maintenance2[]
148in figure <<img-tessellation-topology-ul>>.
149The domain space has an upper-left origin.
150endif::VK_VERSION_1_1,VK_KHR_maintenance2[]
151
152[[img-tessellation-topology-ul]]
153image::{images}/tessparamUL.svg[align="center",title="Domain parameterization for tessellation primitive modes (upper-left origin)",opts="{imageopts}"]
154
155ifdef::VK_VERSION_1_1,VK_KHR_maintenance2[]
156[[img-tessellation-topology-ll]]
157image::{images}/tessparam.svg[align="center",title="Domain parameterization for tessellation primitive modes (lower-left origin)",opts="{imageopts}"]
158endif::VK_VERSION_1_1,VK_KHR_maintenance2[]
159
160.Caption
161****
162In the domain parameterization diagrams, the coordinates illustrate the
163value of code:TessCoord at the corners of the domain.
164The labels on the edges indicate the inner (IL0 and IL1) and outer (OL0
165through OL3) tessellation level values used to control the number of
166subdivisions along each edge of the domain.
167****
168
169For triangles, the vertex's position is a barycentric coordinate
170[eq]#(u,v,w)#, where [eq]#u {plus} v {plus} w = 1.0#, and indicates the
171relative influence of the three vertices of the triangle on the position of
172the vertex.
173For quads and isolines, the position is a [eq]#(u,v)# coordinate indicating
174the relative horizontal and vertical position of the vertex relative to the
175subdivided rectangle.
176The subdivision process is explained in more detail in subsequent sections.
177
178
179== Tessellator Patch Discard
180
181A patch is discarded by the tessellator if any relevant outer tessellation
182level is less than or equal to zero.
183
184Patches will also be discarded if any relevant outer tessellation level
185corresponds to a floating-point [eq]#NaN# (not a number) in implementations
186supporting [eq]#NaN#.
187
188No new primitives are generated and the tessellation evaluation shader is
189not executed for patches that are discarded.
190For code:Quads, all four outer levels are relevant.
191For code:Triangles and code:IsoLines, only the first three or two outer
192levels, respectively, are relevant.
193Negative inner levels will not cause a patch to be discarded; they will be
194clamped as described below.
195
196
197[[tessellation-tessellator-spacing]]
198== Tessellator Spacing
199
200Each of the tessellation levels is used to determine the number and spacing
201of segments used to subdivide a corresponding edge.
202The method used to derive the number and spacing of segments is specified by
203an code:OpExecutionMode in the tessellation control or tessellation
204evaluation shader using one of the identifiers code:SpacingEqual,
205code:SpacingFractionalEven, or code:SpacingFractionalOdd.
206
207If code:SpacingEqual is used, the floating-point tessellation level is first
208clamped to [eq]#[1, pname:maxLevel]#, where [eq]#pname:maxLevel# is the
209implementation-dependent maximum tessellation level
210(sname:VkPhysicalDeviceLimits::pname:maxTessellationGenerationLevel).
211The result is rounded up to the nearest integer [eq]#n#, and the
212corresponding edge is divided into [eq]#n# segments of equal length in (u,v)
213space.
214
215If code:SpacingFractionalEven is used, the tessellation level is first
216clamped to [eq]#[2, pname:maxLevel]# and then rounded up to the nearest even
217integer [eq]#n#.
218If code:SpacingFractionalOdd is used, the tessellation level is clamped to
219[eq]#[1, pname:maxLevel - 1]# and then rounded up to the nearest odd integer
220[eq]#n#.
221If [eq]#n# is one, the edge will not be subdivided.
222Otherwise, the corresponding edge will be divided into [eq]#n - 2# segments
223of equal length, and two additional segments of equal length that are
224typically shorter than the other segments.
225The length of the two additional segments relative to the others will
226decrease monotonically with [eq]#n - f#, where [eq]#f# is the clamped
227floating-point tessellation level.
228When [eq]#n - f# is zero, the additional segments will have equal length to
229the other segments.
230As [eq]#n - f# approaches 2.0, the relative length of the additional
231segments approaches zero.
232The two additional segments must: be placed symmetrically on opposite sides
233of the subdivided edge.
234The relative location of these two segments is implementation-dependent, but
235must: be identical for any pair of subdivided edges with identical values of
236[eq]#f#.
237
238When tessellating triangles or quads using <<tessellation-point-mode, point
239mode>> with fractional odd spacing, the tessellator may: produce _interior
240vertices_ that are positioned on the edge of the patch if an inner
241tessellation level is less than or equal to one.
242Such vertices are considered distinct from vertices produced by subdividing
243the outer edge of the patch, even if there are pairs of vertices with
244identical coordinates.
245
246
247[[tessellation-primitive-order]]
248== Tessellation Primitive Ordering
249
250Few guarantees are provided for the relative ordering of primitives produced
251by tessellation, as they pertain to <<drawing-primitive-order, primitive
252order>>.
253
254  * The output primitives generated from each input primitive are passed to
255    subsequent pipeline stages in an implementation-dependent order.
256  * All output primitives generated from a given input primitive are passed
257    to subsequent pipeline stages before any output primitives generated
258    from subsequent input primitives.
259
260
261[[tessellation-vertex-winding-order]]
262== Tessellator Vertex Winding Order
263
264When the tessellator produces triangles (in the code:Triangles or code:Quads
265modes), the orientation of all triangles is specified with an
266code:OpExecutionMode of code:VertexOrderCw or code:VertexOrderCcw in the
267tessellation control or tessellation evaluation shaders.
268If the order is code:VertexOrderCw, the vertices of all generated triangles
269will have clockwise ordering in (u,v) or (u,v,w) space.
270If the order is code:VertexOrderCcw, the vertices will have
271counter-clockwise ordering in that space.
272
273If the tessellation domain has an upper-left origin, the vertices of a
274triangle have counter-clockwise ordering if
275
276  {empty}:: [eq]#a = u~0~ v~1~ - u~1~ v~0~ {plus} u~1~ v~2~ - u~2~ v~1~
277            {plus} u~2~ v~0~ - u~0~ v~2~#
278
279is negative, and clockwise ordering if [eq]#a# is positive.
280[eq]#u~i~# and [eq]#v~i~# are the [eq]#u# and [eq]#v# coordinates in
281normalized parameter space of the [eq]##i##th vertex of the triangle.
282ifdef::VK_VERSION_1_1,VK_KHR_maintenance2[]
283If the tessellation domain has a lower-left origin, the vertices of a
284triangle have counter-clockwise ordering if [eq]#a# is positive, and
285clockwise ordering if [eq]#a# is negative.
286endif::VK_VERSION_1_1,VK_KHR_maintenance2[]
287
288[NOTE]
289.Note
290====
291The value [eq]#a# is proportional (with a positive factor) to the signed
292area of the triangle.
293
294In code:Triangles mode, even though the vertex coordinates have a [eq]#w#
295value, it does not participate directly in the computation of [eq]#a#, being
296an affine combination of [eq]#u# and [eq]#v#.
297====
298
299
300[[tessellation-triangle-tessellation]]
301== Triangle Tessellation
302
303If the tessellation primitive mode is code:Triangles, an equilateral
304triangle is subdivided into a collection of triangles covering the area of
305the original triangle.
306First, the original triangle is subdivided into a collection of concentric
307equilateral triangles.
308The edges of each of these triangles are subdivided, and the area between
309each triangle pair is filled by triangles produced by joining the vertices
310on the subdivided edges.
311The number of concentric triangles and the number of subdivisions along each
312triangle except the outermost is derived from the first inner tessellation
313level.
314The edges of the outermost triangle are subdivided independently, using the
315first, second, and third outer tessellation levels to control the number of
316subdivisions of the [eq]#u = 0# (left), [eq]#v = 0# (bottom), and [eq]#w =
3170# (right) edges, respectively.
318The second inner tessellation level and the fourth outer tessellation level
319have no effect in this mode.
320
321If the first inner tessellation level and all three outer tessellation
322levels are exactly one after clamping and rounding, only a single triangle
323with [eq]#(u,v,w)# coordinates of [eq]#(0,0,1)#, [eq]#(1,0,0)#, and
324[eq]#(0,1,0)# is generated.
325If the inner tessellation level is one and any of the outer tessellation
326levels is greater than one, the inner tessellation level is treated as
327though it were originally specified as [eq]#1 {plus} {epsilon}# and will
328result in a two- or three-segment subdivision depending on the tessellation
329spacing.
330When used with fractional odd spacing, the three-segment subdivision may:
331produce _inner vertices_ positioned on the edge of the triangle.
332
333If any tessellation level is greater than one, tessellation begins by
334producing a set of concentric inner triangles and subdividing their edges.
335First, the three outer edges are temporarily subdivided using the clamped
336and rounded first inner tessellation level and the specified tessellation
337spacing, generating [eq]#n# segments.
338For the outermost inner triangle, the inner triangle is degenerate -- a
339single point at the center of the triangle -- if [eq]#n# is two.
340Otherwise, for each corner of the outer triangle, an inner triangle corner
341is produced at the intersection of two lines extended perpendicular to the
342corner's two adjacent edges running through the vertex of the subdivided
343outer edge nearest that corner.
344If [eq]#n# is three, the edges of the inner triangle are not subdivided and
345it is the final triangle in the set of concentric triangles.
346Otherwise, each edge of the inner triangle is divided into [eq]#n - 2#
347segments, with the [eq]#n - 1# vertices of this subdivision produced by
348intersecting the inner edge with lines perpendicular to the edge running
349through the [eq]#n - 1# innermost vertices of the subdivision of the outer
350edge.
351Once the outermost inner triangle is subdivided, the previous subdivision
352process repeats itself, using the generated triangle as an outer triangle.
353This subdivision process is illustrated in <<img-innertri,Inner Triangle
354Tessellation>>.
355
356[[img-innertri]]
357image::{images}/innertri.svg[align="center",title="Inner Triangle Tessellation",opts="{imageopts}"]
358
359.Caption
360****
361In the <<img-innertri,Inner Triangle Tessellation>> diagram, inner
362tessellation levels of (a) four and (b) five are shown (not to scale).
363Solid black circles depict vertices along the edges of the concentric
364triangles.
365The edges of inner triangles are subdivided by intersecting the edge with
366segments perpendicular to the edge passing through each inner vertex of the
367subdivided outer edge.
368Dotted lines depict edges connecting corresponding vertices on the inner and
369outer triangle edges.
370****
371
372Once all the concentric triangles are produced and their edges are
373subdivided, the area between each pair of adjacent inner triangles is filled
374completely with a set of non-overlapping triangles.
375In this subdivision, two of the three vertices of each triangle are taken
376from adjacent vertices on a subdivided edge of one triangle; the third is
377one of the vertices on the corresponding edge of the other triangle.
378If the innermost triangle is degenerate (i.e., a point), the triangle
379containing it is subdivided into six triangles by connecting each of the six
380vertices on that triangle with the center point.
381If the innermost triangle is not degenerate, that triangle is added to the
382set of generated triangles as-is.
383
384After the area corresponding to any inner triangles is filled, the
385tessellator generates triangles to cover the area between the outermost
386triangle and the outermost inner triangle.
387To do this, the temporary subdivision of the outer triangle edge above is
388discarded.
389Instead, the [eq]#u = 0#, [eq]#v = 0#, and [eq]#w = 0# edges are subdivided
390according to the first, second, and third outer tessellation levels,
391respectively, and the tessellation spacing.
392The original subdivision of the first inner triangle is retained.
393The area between the outer and first inner triangles is completely filled by
394non-overlapping triangles as described above.
395If the first (and only) inner triangle is degenerate, a set of triangles is
396produced by connecting each vertex on the outer triangle edges with the
397center point.
398
399After all triangles are generated, each vertex in the subdivided triangle is
400assigned a barycentric (u,v,w) coordinate based on its location relative to
401the three vertices of the outer triangle.
402
403The algorithm used to subdivide the triangular domain in (u,v,w) space into
404individual triangles is implementation-dependent.
405However, the set of triangles produced will completely cover the domain, and
406no portion of the domain will be covered by multiple triangles.
407
408Output triangles are generated with a topology similar to
409<<drawing-triangle-lists, triangle lists>>, except that the order in which
410each triangle is generated, and the order in which the vertices are
411generated for each triangle, are implementation-dependent.
412However, the order of vertices in each triangle is consistent across the
413domain as described in <<tessellation-vertex-winding-order>>.
414
415
416[[tessellation-quad-tessellation]]
417== Quad Tessellation
418
419If the tessellation primitive mode is code:Quads, a rectangle is subdivided
420into a collection of triangles covering the area of the original rectangle.
421First, the original rectangle is subdivided into a regular mesh of
422rectangles, where the number of rectangles along the [eq]#u = 0# and [eq]#u
423= 1# (vertical) and [eq]#v = 0# and [eq]#v = 1# (horizontal) edges are
424derived from the first and second inner tessellation levels, respectively.
425All rectangles, except those adjacent to one of the outer rectangle edges,
426are decomposed into triangle pairs.
427The outermost rectangle edges are subdivided independently, using the first,
428second, third, and fourth outer tessellation levels to control the number of
429subdivisions of the [eq]#u = 0# (left), [eq]#v = 0# (bottom), [eq]#u = 1#
430(right), and [eq]#v = 1# (top) edges, respectively.
431The area between the inner rectangles of the mesh and the outer rectangle
432edges are filled by triangles produced by joining the vertices on the
433subdivided outer edges to the vertices on the edge of the inner rectangle
434mesh.
435
436If both clamped inner tessellation levels and all four clamped outer
437tessellation levels are exactly one, only a single triangle pair covering
438the outer rectangle is generated.
439Otherwise, if either clamped inner tessellation level is one, that
440tessellation level is treated as though it was originally specified as
441[eq]#1 {plus} {epsilon}# and will result in a two- or three-segment
442subdivision depending on the tessellation spacing.
443When used with fractional odd spacing, the three-segment subdivision may:
444produce _inner vertices_ positioned on the edge of the rectangle.
445
446If any tessellation level is greater than one, tessellation begins by
447subdividing the [eq]#u = 0# and [eq]#u = 1# edges of the outer rectangle
448into [eq]#m# segments using the clamped and rounded first inner tessellation
449level and the tessellation spacing.
450The [eq]#v = 0# and [eq]#v = 1# edges are subdivided into [eq]#n# segments
451using the second inner tessellation level.
452Each vertex on the [eq]#u = 0# and [eq]#v = 0# edges are joined with the
453corresponding vertex on the [eq]#u = 1# and [eq]#v = 1# edges to produce a
454set of vertical and horizontal lines that divide the rectangle into a grid
455of smaller rectangles.
456The primitive generator emits a pair of non-overlapping triangles covering
457each such rectangle not adjacent to an edge of the outer rectangle.
458The boundary of the region covered by these triangles forms an inner
459rectangle, the edges of which are subdivided by the grid vertices that lie
460on the edge.
461If either [eq]#m# or [eq]#n# is two, the inner rectangle is degenerate, and
462one or both of the rectangle's _edges_ consist of a single point.
463This subdivision is illustrated in Figure <<img-innerquad,Inner Quad
464Tessellation>>.
465
466[[img-innerquad]]
467image::{images}/innerquad.svg[align="center",title="Inner Quad Tessellation",opts="{imageopts}"]
468
469.Caption
470****
471In the <<img-innerquad,Inner Quad Tessellation>> diagram, inner quad
472tessellation levels of (a) [eq]#(4,2)# and (b) [eq]#(7,4)# are shown.
473The regions highlighted in red in figure (b) depict the 10 inner rectangles,
474each of which will be subdivided into two triangles.
475Solid black circles depict vertices on the boundary of the outer and inner
476rectangles, where the inner rectangle of figure (a) is degenerate (a single
477line segment).
478Dotted lines depict the horizontal and vertical edges connecting
479corresponding vertices on the inner and outer rectangle edges.
480****
481
482After the area corresponding to the inner rectangle is filled, the
483tessellator must: produce triangles to cover the area between the inner and
484outer rectangles.
485To do this, the subdivision of the outer rectangle edge above is discarded.
486Instead, the [eq]#u = 0#, [eq]#v = 0#, [eq]#u = 1#, and [eq]#v = 1# edges
487are subdivided according to the first, second, third, and fourth outer
488tessellation levels, respectively, and the tessellation spacing.
489The original subdivision of the inner rectangle is retained.
490The area between the outer and inner rectangles is completely filled by
491non-overlapping triangles.
492Two of the three vertices of each triangle are adjacent vertices on a
493subdivided edge of one rectangle; the third is one of the vertices on the
494corresponding edge of the other rectangle.
495If either edge of the innermost rectangle is degenerate, the area near the
496corresponding outer edges is filled by connecting each vertex on the outer
497edge with the single vertex making up the _inner edge_.
498
499The algorithm used to subdivide the rectangular domain in (u,v) space into
500individual triangles is implementation-dependent.
501However, the set of triangles produced will completely cover the domain, and
502no portion of the domain will be covered by multiple triangles.
503
504Output triangles are generated with a topology similar to
505<<drawing-triangle-lists, triangle lists>>, except that the order in which
506each triangle is generated, and the order in which the vertices are
507generated for each triangle, are implementation-dependent.
508However, the order of vertices in each triangle is consistent across the
509domain as described in <<tessellation-vertex-winding-order>>.
510
511
512[[tessellation-isoline-tessellation]]
513== Isoline Tessellation
514
515If the tessellation primitive mode is code:IsoLines, a set of independent
516horizontal line segments is drawn.
517The segments are arranged into connected strips called _isolines_, where the
518vertices of each isoline have a constant v coordinate and u coordinates
519covering the full range [eq]#[0,1]#.
520The number of isolines generated is derived from the first outer
521tessellation level; the number of segments in each isoline is derived from
522the second outer tessellation level.
523Both inner tessellation levels and the third and fourth outer tessellation
524levels have no effect in this mode.
525
526As with quad tessellation above, isoline tessellation begins with a
527rectangle.
528The [eq]#u = 0# and [eq]#u = 1# edges of the rectangle are subdivided
529according to the first outer tessellation level.
530For the purposes of this subdivision, the tessellation spacing mode is
531ignored and treated as equal_spacing.
532An isoline is drawn connecting each vertex on the [eq]#u = 0# rectangle edge
533to the corresponding vertex on the [eq]#u = 1# rectangle edge, except that
534no line is drawn between [eq]#(0,1)# and [eq]#(1,1)#.
535If the number of isolines on the subdivided [eq]#u = 0# and [eq]#u = 1#
536edges is [eq]#n#, this process will result in [eq]#n# equally spaced lines
537with constant v coordinates of 0, latexmath:[\frac{1}{n}, \frac{2}{n},
538\ldots, \frac{n-1}{n}].
539
540Each of the [eq]#n# isolines is then subdivided according to the second
541outer tessellation level and the tessellation spacing, resulting in [eq]#m#
542line segments.
543Each segment of each line is emitted by the tessellator.
544These line segments are generated with a topology similar to
545<<drawing-line-lists, line lists>>, except that the order in which each line
546is generated, and the order in which the vertices are generated for each
547line segment, are implementation-dependent.
548
549ifdef::VK_KHR_portability_subset[]
550[NOTE]
551.Note
552====
553If the `apiext:VK_KHR_portability_subset` extension is enabled, and
554slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:tessellationIsolines
555is ename:VK_FALSE, then isoline tessellation is not supported by the
556implementation.
557====
558endif::VK_KHR_portability_subset[]
559
560
561[[tessellation-point-mode]]
562== Tessellation Point Mode
563
564For all primitive modes, the tessellator is capable of generating points
565instead of lines or triangles.
566If the tessellation control or tessellation evaluation shader specifies the
567code:OpExecutionMode code:PointMode, the primitive generator will generate
568one point for each distinct vertex produced by tessellation, rather than
569emitting triangles or lines.
570Otherwise, the tessellator will produce a collection of line segments or
571triangles according to the primitive mode.
572These points are generated with a topology similar to <<drawing-point-lists,
573point lists>>, except the order in which the points are generated for each
574input primitive is undefined:.
575
576ifdef::VK_KHR_portability_subset[]
577[NOTE]
578.Note
579====
580If the `apiext:VK_KHR_portability_subset` extension is enabled, and
581slink:VkPhysicalDevicePortabilitySubsetFeaturesKHR::pname:tessellationPointMode
582is ename:VK_FALSE, then tessellation point mode is not supported by the
583implementation.
584====
585endif::VK_KHR_portability_subset[]
586
587
588== Tessellation Pipeline State
589
590The pname:pTessellationState member of slink:VkGraphicsPipelineCreateInfo is
591a pointer to a sname:VkPipelineTessellationStateCreateInfo structure.
592
593[open,refpage='VkPipelineTessellationStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline tessellation state',type='structs']
594--
595The sname:VkPipelineTessellationStateCreateInfo structure is defined as:
596
597include::{generated}/api/structs/VkPipelineTessellationStateCreateInfo.adoc[]
598
599  * pname:sType is a elink:VkStructureType value identifying this structure.
600  * pname:pNext is `NULL` or a pointer to a structure extending this
601    structure.
602  * pname:flags is reserved for future use.
603  * pname:patchControlPoints is the number of control points per patch.
604
605.Valid Usage
606****
607  * [[VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214]]
608    pname:patchControlPoints must: be greater than zero and less than or
609    equal to sname:VkPhysicalDeviceLimits::pname:maxTessellationPatchSize
610****
611
612include::{generated}/validity/structs/VkPipelineTessellationStateCreateInfo.adoc[]
613--
614
615[open,refpage='VkPipelineTessellationStateCreateFlags',desc='Reserved for future use',type='flags']
616--
617include::{generated}/api/flags/VkPipelineTessellationStateCreateFlags.adoc[]
618
619tname:VkPipelineTessellationStateCreateFlags is a bitmask type for setting a
620mask, but is currently reserved for future use.
621--
622
623ifdef::VK_VERSION_1_1,VK_KHR_maintenance2[]
624[open,refpage='VkPipelineTessellationDomainOriginStateCreateInfo',desc='Structure specifying the orientation of the tessellation domain',type='structs']
625--
626The sname:VkPipelineTessellationDomainOriginStateCreateInfo structure is
627defined as:
628
629include::{generated}/api/structs/VkPipelineTessellationDomainOriginStateCreateInfo.adoc[]
630
631ifdef::VK_KHR_maintenance2[]
632or the equivalent
633
634include::{generated}/api/structs/VkPipelineTessellationDomainOriginStateCreateInfoKHR.adoc[]
635endif::VK_KHR_maintenance2[]
636
637  * pname:sType is a elink:VkStructureType value identifying this structure.
638  * pname:pNext is `NULL` or a pointer to a structure extending this
639    structure.
640  * pname:domainOrigin is a elink:VkTessellationDomainOrigin value
641    controlling the origin of the tessellation domain space.
642
643If the sname:VkPipelineTessellationDomainOriginStateCreateInfo structure is
644included in the pname:pNext chain of
645slink:VkPipelineTessellationStateCreateInfo, it controls the origin of the
646tessellation domain.
647If this structure is not present, it is as if pname:domainOrigin was
648ename:VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT.
649
650include::{generated}/validity/structs/VkPipelineTessellationDomainOriginStateCreateInfo.adoc[]
651--
652
653[open,refpage='VkTessellationDomainOrigin',desc='Enum describing tessellation domain origin',type='enums']
654--
655The possible tessellation domain origins are specified by the
656elink:VkTessellationDomainOrigin enumeration:
657
658include::{generated}/api/enums/VkTessellationDomainOrigin.adoc[]
659
660ifdef::VK_KHR_maintenance2[]
661or the equivalent
662
663include::{generated}/api/enums/VkTessellationDomainOriginKHR.adoc[]
664endif::VK_KHR_maintenance2[]
665
666  * ename:VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT specifies that the origin
667    of the domain space is in the upper left corner, as shown in figure
668    <<img-tessellation-topology-ul>>.
669  * ename:VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT specifies that the origin
670    of the domain space is in the lower left corner, as shown in figure
671    <<img-tessellation-topology-ll>>.
672
673This enum affects how the code:VertexOrderCw and code:VertexOrderCcw
674tessellation execution modes are interpreted, since the winding is defined
675relative to the orientation of the domain.
676--
677endif::VK_VERSION_1_1,VK_KHR_maintenance2[]
678
679ifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
680
681[open,refpage='vkCmdSetTessellationDomainOriginEXT',desc='Specify the origin of the tessellation domain space dynamically for a command buffer',type='protos']
682--
683To <<pipelines-dynamic-state, dynamically set>> the origin of the
684tessellation domain space, call:
685
686include::{generated}/api/protos/vkCmdSetTessellationDomainOriginEXT.adoc[]
687
688  * pname:commandBuffer is the command buffer into which the command will be
689    recorded.
690  * pname:domainOrigin specifies the origin of the tessellation domain
691    space.
692
693This command sets the origin of the tessellation domain space for subsequent
694drawing commands
695ifdef::VK_EXT_shader_object[]
696ifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or]
697ifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.]
698endif::VK_EXT_shader_object[]
699ifdef::VK_EXT_extended_dynamic_state3[]
700when the graphics pipeline is created with
701ename:VK_DYNAMIC_STATE_TESSELLATION_DOMAIN_ORIGIN_EXT set in
702slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
703endif::VK_EXT_extended_dynamic_state3[]
704Otherwise, this state is specified by the
705slink:VkPipelineTessellationDomainOriginStateCreateInfo::pname:domainOrigin
706value used to create the currently active pipeline.
707
708:refpage: vkCmdSetTessellationDomainOriginEXT
709:requiredfeature: extendedDynamicState3TessellationDomainOrigin
710
711.Valid Usage
712****
713include::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[]
714****
715
716include::{generated}/validity/protos/vkCmdSetTessellationDomainOriginEXT.adoc[]
717--
718
719endif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
720