1e5c31af7Sopenharmony_ci// Copyright 2015-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ci[[vertexpostproc]]
6e5c31af7Sopenharmony_ci= Fixed-Function Vertex Post-Processing
7e5c31af7Sopenharmony_ci
8e5c31af7Sopenharmony_ciAfter <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization
9e5c31af7Sopenharmony_cishader stages>>, the following fixed-function operations are applied to
10e5c31af7Sopenharmony_civertices of the resulting primitives:
11e5c31af7Sopenharmony_ci
12e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[]
13e5c31af7Sopenharmony_ci  * Transform feedback (see <<vertexpostproc-transform-feedback,Transform
14e5c31af7Sopenharmony_ci    Feedback>>)
15e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[]
16e5c31af7Sopenharmony_ciifdef::VK_NV_viewport_swizzle[]
17e5c31af7Sopenharmony_ci  * Viewport swizzle (see <<vertexpostproc-viewport-swizzle,Viewport
18e5c31af7Sopenharmony_ci    Swizzle>>)
19e5c31af7Sopenharmony_ciendif::VK_NV_viewport_swizzle[]
20e5c31af7Sopenharmony_ci  * Flat shading (see <<vertexpostproc-flatshading>>).
21e5c31af7Sopenharmony_ci  * Primitive clipping, including client-defined half-spaces (see
22e5c31af7Sopenharmony_ci    <<vertexpostproc-clipping,Primitive Clipping>>).
23e5c31af7Sopenharmony_ci  * Shader output attribute clipping (see
24e5c31af7Sopenharmony_ci    <<vertexpostproc-clipping-shader-outputs,Clipping Shader Outputs>>).
25e5c31af7Sopenharmony_ciifdef::VK_NV_clip_space_w_scaling[]
26e5c31af7Sopenharmony_ci  * Clip space W scaling (see <<vertexpostproc-viewportwscaling,Controlling
27e5c31af7Sopenharmony_ci    Viewport W Scaling>>).
28e5c31af7Sopenharmony_ciendif::VK_NV_clip_space_w_scaling[]
29e5c31af7Sopenharmony_ci  * Perspective division on clip coordinates (see
30e5c31af7Sopenharmony_ci    <<vertexpostproc-coord-transform,Coordinate Transformations>>).
31e5c31af7Sopenharmony_ci  * Viewport mapping, including depth range scaling (see
32e5c31af7Sopenharmony_ci    <<vertexpostproc-viewport,Controlling the Viewport>>).
33e5c31af7Sopenharmony_ci  * Front face determination for polygon primitives (see
34e5c31af7Sopenharmony_ci    <<primsrast-polygons-basic,Basic Polygon Rasterization>>).
35e5c31af7Sopenharmony_ci
36e5c31af7Sopenharmony_ciifdef::editing-notes[]
37e5c31af7Sopenharmony_ci[NOTE]
38e5c31af7Sopenharmony_ci.editing-note
39e5c31af7Sopenharmony_ci====
40e5c31af7Sopenharmony_ciTODO:Odd that this one link to a different chapter is in this list.
41e5c31af7Sopenharmony_ci====
42e5c31af7Sopenharmony_ciendif::editing-notes[]
43e5c31af7Sopenharmony_ci
44e5c31af7Sopenharmony_ciNext, rasterization is performed on primitives as described in chapter
45e5c31af7Sopenharmony_ci<<primsrast,Rasterization>>.
46e5c31af7Sopenharmony_ci
47e5c31af7Sopenharmony_ci
48e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[]
49e5c31af7Sopenharmony_ci[[vertexpostproc-transform-feedback]]
50e5c31af7Sopenharmony_ci== Transform Feedback
51e5c31af7Sopenharmony_ci
52e5c31af7Sopenharmony_ciBefore any other fixed-function vertex post-processing, vertex outputs from
53e5c31af7Sopenharmony_cithe last shader in the
54e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
55e5c31af7Sopenharmony_cistage>> can: be written out to one or more transform feedback buffers bound
56e5c31af7Sopenharmony_cito the command buffer.
57e5c31af7Sopenharmony_ciTo capture vertex outputs the last
58e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
59e5c31af7Sopenharmony_cistage>> shader must: be declared with the code:Xfb execution mode.
60e5c31af7Sopenharmony_ciOutputs decorated with code:XfbBuffer will be written out to the
61e5c31af7Sopenharmony_cicorresponding transform feedback buffers bound to the command buffer when
62e5c31af7Sopenharmony_citransform feedback is active.
63e5c31af7Sopenharmony_ciTransform feedback buffers are bound to the command buffer by using
64e5c31af7Sopenharmony_ciflink:vkCmdBindTransformFeedbackBuffersEXT.
65e5c31af7Sopenharmony_ciTransform feedback is made active by calling
66e5c31af7Sopenharmony_ciflink:vkCmdBeginTransformFeedbackEXT and made inactive by calling
67e5c31af7Sopenharmony_ciflink:vkCmdEndTransformFeedbackEXT.
68e5c31af7Sopenharmony_ciAfter vertex data is written it is possible to use
69e5c31af7Sopenharmony_ciflink:vkCmdDrawIndirectByteCountEXT to start a new draw where the
70e5c31af7Sopenharmony_cipname:vertexCount is derived from the number of bytes written by a previous
71e5c31af7Sopenharmony_citransform feedback.
72e5c31af7Sopenharmony_ci
73e5c31af7Sopenharmony_ciWhen an individual point, line, or triangle primitive reaches the transform
74e5c31af7Sopenharmony_cifeedback stage while transform feedback is active, the values of the
75e5c31af7Sopenharmony_cispecified output variables are assembled into primitives and appended to the
76e5c31af7Sopenharmony_cibound transform feedback buffers.
77e5c31af7Sopenharmony_ciAfter activating transform feedback, the values of the first assembled
78e5c31af7Sopenharmony_ciprimitive are written at the starting offsets of the bound transform
79e5c31af7Sopenharmony_cifeedback buffers, and subsequent primitives are appended to the buffer.
80e5c31af7Sopenharmony_ciIf the optional pname:pCounterBuffers and pname:pCounterBufferOffsets
81e5c31af7Sopenharmony_ciparameters are specified, the starting points within the transform feedback
82e5c31af7Sopenharmony_cibuffers are adjusted so data is appended to the previously written values
83e5c31af7Sopenharmony_ciindicated by the value stored by the implementation in the counter buffer.
84e5c31af7Sopenharmony_ci
85e5c31af7Sopenharmony_ciFor multi-vertex primitives, all values for a given vertex are written
86e5c31af7Sopenharmony_cibefore writing values for any other vertex.
87e5c31af7Sopenharmony_ciifdef::VK_EXT_provoking_vertex[]
88e5c31af7Sopenharmony_ciWhen <<features-transformFeedbackPreservesProvokingVertex,
89e5c31af7Sopenharmony_cipname:transformFeedbackPreservesProvokingVertex>> is not enabled,
90e5c31af7Sopenharmony_ciimplementations
91e5c31af7Sopenharmony_ciendif::VK_EXT_provoking_vertex[]
92e5c31af7Sopenharmony_ciifndef::VK_EXT_provoking_vertex[]
93e5c31af7Sopenharmony_ciImplementations
94e5c31af7Sopenharmony_ciendif::VK_EXT_provoking_vertex[]
95e5c31af7Sopenharmony_cimay: write out any vertex within the primitive first, but all subsequent
96e5c31af7Sopenharmony_civertices for that primitive must: be written out in a consistent winding
97e5c31af7Sopenharmony_ciorder defined as follows:
98e5c31af7Sopenharmony_ci
99e5c31af7Sopenharmony_ci  * If neither <<geometry,geometry>> or <<tessellation,tessellation
100e5c31af7Sopenharmony_ci    shading>> is active, vertices within a primitive are appended according
101e5c31af7Sopenharmony_ci    to the winding order described by the <<drawing-primitive-topologies,
102e5c31af7Sopenharmony_ci    primitive topology>> defined by the
103e5c31af7Sopenharmony_ci    slink:VkPipelineInputAssemblyStateCreateInfo:pname:topology used to
104e5c31af7Sopenharmony_ci    execute the <<drawing,drawing command>>.
105e5c31af7Sopenharmony_ci  * If <<geometry,geometry shading>> is active, vertices within a primitive
106e5c31af7Sopenharmony_ci    are appended according to the winding order described by the
107e5c31af7Sopenharmony_ci    <<drawing-primitive-topologies, primitive topology>> defined by the
108e5c31af7Sopenharmony_ci    <<drawing-point-lists, code:OutputPoints>>, <<drawing-line-strips,
109e5c31af7Sopenharmony_ci    code:OutputLineStrip>>, or <<drawing-triangle-strips,
110e5c31af7Sopenharmony_ci    code:OutputTriangleStrip>> execution mode.
111e5c31af7Sopenharmony_ci  * If <<tessellation,tessellation shading>> is active but
112e5c31af7Sopenharmony_ci    <<geometry,geometry shading>> is not, vertices within a primitive are
113e5c31af7Sopenharmony_ci    appended according to the winding order defined by
114e5c31af7Sopenharmony_ci    <<tessellation-triangle-tessellation, triangle tessellation>>,
115e5c31af7Sopenharmony_ci    <<tessellation-quad-tessellation, quad tessellation>>, and
116e5c31af7Sopenharmony_ci    <<tessellation-isoline-tessellation, isoline tessellation>>.
117e5c31af7Sopenharmony_ci
118e5c31af7Sopenharmony_ciifdef::VK_EXT_provoking_vertex[]
119e5c31af7Sopenharmony_ciWhen <<features-transformFeedbackPreservesProvokingVertex,
120e5c31af7Sopenharmony_cipname:transformFeedbackPreservesProvokingVertex>> is enabled, then in
121e5c31af7Sopenharmony_ciaddition to writing vertices with a consistent winding order, the vertex
122e5c31af7Sopenharmony_ciorder must: preserve the <<vertexpostproc-flatshading, provoking vertex>> of
123e5c31af7Sopenharmony_cieach primitive:
124e5c31af7Sopenharmony_ci
125e5c31af7Sopenharmony_ci  * When the
126e5c31af7Sopenharmony_ci    <<VkPipelineRasterizationProvokingVertexStateCreateInfoEXT,pipeline's
127e5c31af7Sopenharmony_ci    provoking vertex mode>> is
128e5c31af7Sopenharmony_ci    ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, the primitive's
129e5c31af7Sopenharmony_ci    provoking vertex must be the first vertex written.
130e5c31af7Sopenharmony_ci  * When the
131e5c31af7Sopenharmony_ci    <<VkPipelineRasterizationProvokingVertexStateCreateInfoEXT,pipeline's
132e5c31af7Sopenharmony_ci    provoking vertex mode>> is
133e5c31af7Sopenharmony_ci    ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, the primitive's
134e5c31af7Sopenharmony_ci    provoking vertex must be the last vertex written.
135e5c31af7Sopenharmony_ci
136e5c31af7Sopenharmony_ciIf <<limits-transformFeedbackPreservesTriangleFanProvokingVertex,
137e5c31af7Sopenharmony_cipname:transformFeedbackPreservesTriangleFanProvokingVertex>> is
138e5c31af7Sopenharmony_ciename:VK_FALSE, neither <<geometry, geometry>> nor <<tessellation,
139e5c31af7Sopenharmony_citessellation>> shading is active, and the <<drawing-primitive-topologies,
140e5c31af7Sopenharmony_ciprimitive topology>> is ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN, then the
141e5c31af7Sopenharmony_cifirst vertex written from each primitive is implementation-defined even when
142e5c31af7Sopenharmony_ci<<features-transformFeedbackPreservesProvokingVertex,
143e5c31af7Sopenharmony_cipname:transformFeedbackPreservesProvokingVertex>> is enabled.
144e5c31af7Sopenharmony_ci
145e5c31af7Sopenharmony_ciendif::VK_EXT_provoking_vertex[]
146e5c31af7Sopenharmony_ci
147e5c31af7Sopenharmony_ciWhen capturing vertices, the stride associated with each transform feedback
148e5c31af7Sopenharmony_cibuffer, as indicated by the code:XfbStride decoration, indicates the number
149e5c31af7Sopenharmony_ciof bytes of storage reserved for each vertex in the transform feedback
150e5c31af7Sopenharmony_cibuffer.
151e5c31af7Sopenharmony_ciFor every vertex captured, each output attribute with a code:Offset
152e5c31af7Sopenharmony_cidecoration will be written to the storage reserved for the vertex at the
153e5c31af7Sopenharmony_ciassociated transform feedback buffer.
154e5c31af7Sopenharmony_ciWhen writing output variables that are arrays or structures, individual
155e5c31af7Sopenharmony_ciarray elements or structure members are written tightly packed in order.
156e5c31af7Sopenharmony_ciFor vector types, individual components are written in order.
157e5c31af7Sopenharmony_ciFor matrix types, outputs are written as an array of column vectors.
158e5c31af7Sopenharmony_ci
159e5c31af7Sopenharmony_ciIf any component of an output with an assigned transform feedback offset was
160e5c31af7Sopenharmony_cinot written to by its shader, the value recorded for that component is
161e5c31af7Sopenharmony_ciundefined:.
162e5c31af7Sopenharmony_ciAll components of an output variable must: be written at an offset aligned
163e5c31af7Sopenharmony_cito the size of the component.
164e5c31af7Sopenharmony_ciThe size of each component of an output variable must: be at least 32-bits.
165e5c31af7Sopenharmony_ciWhen capturing a vertex, any portion of the reserved storage not associated
166e5c31af7Sopenharmony_ciwith an output variable with an assigned transform feedback offset will be
167e5c31af7Sopenharmony_ciunmodified.
168e5c31af7Sopenharmony_ci
169e5c31af7Sopenharmony_ciWhen transform feedback is inactive, no vertices are recorded.
170e5c31af7Sopenharmony_ciIf there is a valid counter buffer handle and counter buffer offset in the
171e5c31af7Sopenharmony_cipname:pCounterBuffers and pname:pCounterBufferOffsets arrays, writes to the
172e5c31af7Sopenharmony_cicorresponding transform feedback buffer will start at the byte offset
173e5c31af7Sopenharmony_cirepresented by the value stored in the counter buffer location.
174e5c31af7Sopenharmony_ci
175e5c31af7Sopenharmony_ciIndividual lines or triangles of a strip or fan primitive will be extracted
176e5c31af7Sopenharmony_ciand recorded separately.
177e5c31af7Sopenharmony_ciIncomplete primitives are not recorded.
178e5c31af7Sopenharmony_ci
179e5c31af7Sopenharmony_ciWhen using a geometry shader that emits vertices to multiple vertex streams,
180e5c31af7Sopenharmony_cia primitive will be assembled and output for each stream when there are
181e5c31af7Sopenharmony_cienough vertices emitted for the output primitive type.
182e5c31af7Sopenharmony_ciAll outputs assigned to a given transform feedback buffer are required to
183e5c31af7Sopenharmony_cicome from a single vertex stream.
184e5c31af7Sopenharmony_ci
185e5c31af7Sopenharmony_ciThe sizes of the transform feedback buffers are defined by the
186e5c31af7Sopenharmony_ciflink:vkCmdBindTransformFeedbackBuffersEXT pname:pSizes parameter for each
187e5c31af7Sopenharmony_ciof the bound buffers, or the size of the bound buffer, whichever is the
188e5c31af7Sopenharmony_cilesser.
189e5c31af7Sopenharmony_ciIf there is less space remaining in any of the transform feedback buffers
190e5c31af7Sopenharmony_cithan the size of all of the vertex data for that primitive based on the
191e5c31af7Sopenharmony_cicode:XfbStride for that code:XfbBuffer then no vertex data of that primitive
192e5c31af7Sopenharmony_ciis recorded in any transform feedback buffer, and the value for the number
193e5c31af7Sopenharmony_ciof primitives written in the corresponding
194e5c31af7Sopenharmony_ciename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT query for all transform
195e5c31af7Sopenharmony_cifeedback buffers is no longer incremented.
196e5c31af7Sopenharmony_ci
197e5c31af7Sopenharmony_ciAny outputs made to a code:XfbBuffer that is not bound to a transform
198e5c31af7Sopenharmony_cifeedback buffer is ignored.
199e5c31af7Sopenharmony_ci
200e5c31af7Sopenharmony_ci[open,refpage='vkCmdBindTransformFeedbackBuffersEXT',desc='Bind transform feedback buffers to a command buffer',type='protos']
201e5c31af7Sopenharmony_ci--
202e5c31af7Sopenharmony_ciTo bind transform feedback buffers to a command buffer for use in subsequent
203e5c31af7Sopenharmony_cidrawing commands, call:
204e5c31af7Sopenharmony_ci
205e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdBindTransformFeedbackBuffersEXT.adoc[]
206e5c31af7Sopenharmony_ci
207e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command is
208e5c31af7Sopenharmony_ci    recorded.
209e5c31af7Sopenharmony_ci  * pname:firstBinding is the index of the first transform feedback binding
210e5c31af7Sopenharmony_ci    whose state is updated by the command.
211e5c31af7Sopenharmony_ci  * pname:bindingCount is the number of transform feedback bindings whose
212e5c31af7Sopenharmony_ci    state is updated by the command.
213e5c31af7Sopenharmony_ci  * pname:pBuffers is a pointer to an array of buffer handles.
214e5c31af7Sopenharmony_ci  * pname:pOffsets is a pointer to an array of buffer offsets.
215e5c31af7Sopenharmony_ci  * pname:pSizes is `NULL` or a pointer to an array of basetype:VkDeviceSize
216e5c31af7Sopenharmony_ci    buffer sizes, specifying the maximum number of bytes to capture to the
217e5c31af7Sopenharmony_ci    corresponding transform feedback buffer.
218e5c31af7Sopenharmony_ci    If pname:pSizes is `NULL`, or the value of the pname:pSizes array
219e5c31af7Sopenharmony_ci    element is ename:VK_WHOLE_SIZE, then the maximum number of bytes
220e5c31af7Sopenharmony_ci    captured will be the size of the corresponding buffer minus the buffer
221e5c31af7Sopenharmony_ci    offset.
222e5c31af7Sopenharmony_ci
223e5c31af7Sopenharmony_ciThe values taken from elements [eq]#i# of pname:pBuffers, pname:pOffsets and
224e5c31af7Sopenharmony_cipname:pSizes replace the current state for the transform feedback binding
225e5c31af7Sopenharmony_ci[eq]#pname:firstBinding {plus} i#, for [eq]#i# in [eq]#[0,
226e5c31af7Sopenharmony_cipname:bindingCount)#.
227e5c31af7Sopenharmony_ciThe transform feedback binding is updated to start at the offset indicated
228e5c31af7Sopenharmony_ciby pname:pOffsets[i] from the start of the buffer pname:pBuffers[i].
229e5c31af7Sopenharmony_ci
230e5c31af7Sopenharmony_ci.Valid Usage
231e5c31af7Sopenharmony_ci****
232e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-transformFeedback-02355]]
233e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackFeaturesEXT::pname:transformFeedback
234e5c31af7Sopenharmony_ci    must: be enabled
235e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356]]
236e5c31af7Sopenharmony_ci    pname:firstBinding must: be less than
237e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBuffers
238e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357]]
239e5c31af7Sopenharmony_ci    The sum of pname:firstBinding and pname:bindingCount must: be less than
240e5c31af7Sopenharmony_ci    or equal to
241e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBuffers
242e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02358]]
243e5c31af7Sopenharmony_ci    All elements of pname:pOffsets must: be less than the size of the
244e5c31af7Sopenharmony_ci    corresponding element in pname:pBuffers
245e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359]]
246e5c31af7Sopenharmony_ci    All elements of pname:pOffsets must: be a multiple of 4
247e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02360]]
248e5c31af7Sopenharmony_ci    All elements of pname:pBuffers must: have been created with the
249e5c31af7Sopenharmony_ci    ename:VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT flag
250e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361]]
251e5c31af7Sopenharmony_ci    If the optional pname:pSize array is specified, each element of
252e5c31af7Sopenharmony_ci    pname:pSizes must: either be ename:VK_WHOLE_SIZE, or be less than or
253e5c31af7Sopenharmony_ci    equal to
254e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBufferSize
255e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pSizes-02362]]
256e5c31af7Sopenharmony_ci    All elements of pname:pSizes must: be either ename:VK_WHOLE_SIZE, or
257e5c31af7Sopenharmony_ci    less than or equal to the size of the corresponding buffer in
258e5c31af7Sopenharmony_ci    pname:pBuffers
259e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02363]]
260e5c31af7Sopenharmony_ci    All elements of pname:pOffsets plus pname:pSizes, where the
261e5c31af7Sopenharmony_ci    pname:pSizes, element is not ename:VK_WHOLE_SIZE, must: be less than or
262e5c31af7Sopenharmony_ci    equal to the size of the corresponding buffer in pname:pBuffers
263e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-pBuffers-02364]]
264e5c31af7Sopenharmony_ci    Each element of pname:pBuffers that is non-sparse must: be bound
265e5c31af7Sopenharmony_ci    completely and contiguously to a single sname:VkDeviceMemory object
266e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBindTransformFeedbackBuffersEXT-None-02365]]
267e5c31af7Sopenharmony_ci    Transform feedback must: not be active when the
268e5c31af7Sopenharmony_ci    fname:vkCmdBindTransformFeedbackBuffersEXT command is recorded
269e5c31af7Sopenharmony_ci****
270e5c31af7Sopenharmony_ci
271e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdBindTransformFeedbackBuffersEXT.adoc[]
272e5c31af7Sopenharmony_ci--
273e5c31af7Sopenharmony_ci
274e5c31af7Sopenharmony_ci[open,refpage='vkCmdBeginTransformFeedbackEXT',desc='Make transform feedback active in the command buffer',type='protos']
275e5c31af7Sopenharmony_ci--
276e5c31af7Sopenharmony_ciTransform feedback for specific transform feedback buffers is made active by
277e5c31af7Sopenharmony_cicalling:
278e5c31af7Sopenharmony_ci
279e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdBeginTransformFeedbackEXT.adoc[]
280e5c31af7Sopenharmony_ci
281e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command is
282e5c31af7Sopenharmony_ci    recorded.
283e5c31af7Sopenharmony_ci  * pname:firstCounterBuffer is the index of the first transform feedback
284e5c31af7Sopenharmony_ci    buffer corresponding to pname:pCounterBuffers[0] and
285e5c31af7Sopenharmony_ci    pname:pCounterBufferOffsets[0].
286e5c31af7Sopenharmony_ci  * pname:counterBufferCount is the size of the pname:pCounterBuffers and
287e5c31af7Sopenharmony_ci    pname:pCounterBufferOffsets arrays.
288e5c31af7Sopenharmony_ci  * pname:pCounterBuffers is `NULL` or a pointer to an array of
289e5c31af7Sopenharmony_ci    slink:VkBuffer handles to counter buffers.
290e5c31af7Sopenharmony_ci    Each buffer contains a 4 byte integer value representing the byte offset
291e5c31af7Sopenharmony_ci    from the start of the corresponding transform feedback buffer from where
292e5c31af7Sopenharmony_ci    to start capturing vertex data.
293e5c31af7Sopenharmony_ci    If the byte offset stored to the counter buffer location was done using
294e5c31af7Sopenharmony_ci    flink:vkCmdEndTransformFeedbackEXT it can be used to resume transform
295e5c31af7Sopenharmony_ci    feedback from the previous location.
296e5c31af7Sopenharmony_ci    If pname:pCounterBuffers is `NULL`, then transform feedback will start
297e5c31af7Sopenharmony_ci    capturing vertex data to byte offset zero in all bound transform
298e5c31af7Sopenharmony_ci    feedback buffers.
299e5c31af7Sopenharmony_ci    For each element of pname:pCounterBuffers that is dlink:VK_NULL_HANDLE,
300e5c31af7Sopenharmony_ci    transform feedback will start capturing vertex data to byte zero in the
301e5c31af7Sopenharmony_ci    corresponding bound transform feedback buffer.
302e5c31af7Sopenharmony_ci  * pname:pCounterBufferOffsets is `NULL` or a pointer to an array of
303e5c31af7Sopenharmony_ci    basetype:VkDeviceSize values specifying offsets within each of the
304e5c31af7Sopenharmony_ci    pname:pCounterBuffers where the counter values were previously written.
305e5c31af7Sopenharmony_ci    The location in each counter buffer at these offsets must: be large
306e5c31af7Sopenharmony_ci    enough to contain 4 bytes of data.
307e5c31af7Sopenharmony_ci    This data is the number of bytes captured by the previous transform
308e5c31af7Sopenharmony_ci    feedback to this buffer.
309e5c31af7Sopenharmony_ci    If pname:pCounterBufferOffsets is `NULL`, then it is assumed the offsets
310e5c31af7Sopenharmony_ci    are zero.
311e5c31af7Sopenharmony_ci
312e5c31af7Sopenharmony_ciThe active transform feedback buffers will capture primitives emitted from
313e5c31af7Sopenharmony_cithe corresponding code:XfbBuffer in the bound graphics pipeline.
314e5c31af7Sopenharmony_ciAny code:XfbBuffer emitted that does not output to an active transform
315e5c31af7Sopenharmony_cifeedback buffer will not be captured.
316e5c31af7Sopenharmony_ci
317e5c31af7Sopenharmony_ci.Valid Usage
318e5c31af7Sopenharmony_ci****
319e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-transformFeedback-02366]]
320e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackFeaturesEXT::pname:transformFeedback
321e5c31af7Sopenharmony_ci    must: be enabled
322e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-None-02367]]
323e5c31af7Sopenharmony_ci    Transform feedback must: not be active
324e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368]]
325e5c31af7Sopenharmony_ci    pname:firstCounterBuffer must: be less than
326e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBuffers
327e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369]]
328e5c31af7Sopenharmony_ci    The sum of pname:firstCounterBuffer and pname:counterBufferCount must:
329e5c31af7Sopenharmony_ci    be less than or equal to
330e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBuffers
331e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-counterBufferCount-02607]]
332e5c31af7Sopenharmony_ci    If pname:counterBufferCount is not `0`, and pname:pCounterBuffers is not
333e5c31af7Sopenharmony_ci    `NULL`, pname:pCounterBuffers must: be a valid pointer to an array of
334e5c31af7Sopenharmony_ci    pname:counterBufferCount sname:VkBuffer handles that are either valid or
335e5c31af7Sopenharmony_ci    dlink:VK_NULL_HANDLE
336e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-pCounterBufferOffsets-02370]]
337e5c31af7Sopenharmony_ci    For each buffer handle in the array, if it is not dlink:VK_NULL_HANDLE
338e5c31af7Sopenharmony_ci    it must: reference a buffer large enough to hold 4 bytes at the
339e5c31af7Sopenharmony_ci    corresponding offset from the pname:pCounterBufferOffsets array
340e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-pCounterBuffer-02371]]
341e5c31af7Sopenharmony_ci    If pname:pCounterBuffer is `NULL`, then pname:pCounterBufferOffsets
342e5c31af7Sopenharmony_ci    must: also be `NULL`
343e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-pCounterBuffers-02372]]
344e5c31af7Sopenharmony_ci    For each buffer handle in the pname:pCounterBuffers array that is not
345e5c31af7Sopenharmony_ci    dlink:VK_NULL_HANDLE it must: have been created with a pname:usage value
346e5c31af7Sopenharmony_ci    containing
347e5c31af7Sopenharmony_ci    ename:VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT
348e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-None-06233]]
349e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
350e5c31af7Sopenharmony_ci    If the <<features-shaderObject, pname:shaderObject>> feature is not
351e5c31af7Sopenharmony_ci    enabled, a
352e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
353e5c31af7Sopenharmony_ciifndef::VK_EXT_shader_object[]
354e5c31af7Sopenharmony_ci    A
355e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
356e5c31af7Sopenharmony_ci    valid graphics pipeline must: be bound to
357e5c31af7Sopenharmony_ci    ename:VK_PIPELINE_BIND_POINT_GRAPHICS
358e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-None-04128]]
359e5c31af7Sopenharmony_ci    The last
360e5c31af7Sopenharmony_ci    <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
361e5c31af7Sopenharmony_ci    stage>> of the bound graphics pipeline must: have been declared with the
362e5c31af7Sopenharmony_ci    code:Xfb execution mode
363e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[]
364e5c31af7Sopenharmony_ci  * [[VUID-vkCmdBeginTransformFeedbackEXT-None-02373]]
365e5c31af7Sopenharmony_ci    Transform feedback must: not be made active in a render pass instance
366e5c31af7Sopenharmony_ci    with multiview enabled
367e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[]
368e5c31af7Sopenharmony_ci****
369e5c31af7Sopenharmony_ci
370e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdBeginTransformFeedbackEXT.adoc[]
371e5c31af7Sopenharmony_ci--
372e5c31af7Sopenharmony_ci
373e5c31af7Sopenharmony_ci[open,refpage='vkCmdEndTransformFeedbackEXT',desc='Make transform feedback inactive in the command buffer',type='protos']
374e5c31af7Sopenharmony_ci--
375e5c31af7Sopenharmony_ciTransform feedback for specific transform feedback buffers is made inactive
376e5c31af7Sopenharmony_ciby calling:
377e5c31af7Sopenharmony_ci
378e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdEndTransformFeedbackEXT.adoc[]
379e5c31af7Sopenharmony_ci
380e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command is
381e5c31af7Sopenharmony_ci    recorded.
382e5c31af7Sopenharmony_ci  * pname:firstCounterBuffer is the index of the first transform feedback
383e5c31af7Sopenharmony_ci    buffer corresponding to pname:pCounterBuffers[0] and
384e5c31af7Sopenharmony_ci    pname:pCounterBufferOffsets[0].
385e5c31af7Sopenharmony_ci  * pname:counterBufferCount is the size of the pname:pCounterBuffers and
386e5c31af7Sopenharmony_ci    pname:pCounterBufferOffsets arrays.
387e5c31af7Sopenharmony_ci  * pname:pCounterBuffers is `NULL` or a pointer to an array of
388e5c31af7Sopenharmony_ci    slink:VkBuffer handles to counter buffers.
389e5c31af7Sopenharmony_ci    The counter buffers are used to record the current byte positions of
390e5c31af7Sopenharmony_ci    each transform feedback buffer where the next vertex output data would
391e5c31af7Sopenharmony_ci    be captured.
392e5c31af7Sopenharmony_ci    This can: be used by a subsequent flink:vkCmdBeginTransformFeedbackEXT
393e5c31af7Sopenharmony_ci    call to resume transform feedback capture from this position.
394e5c31af7Sopenharmony_ci    It can also be used by flink:vkCmdDrawIndirectByteCountEXT to determine
395e5c31af7Sopenharmony_ci    the vertex count of the draw call.
396e5c31af7Sopenharmony_ci  * pname:pCounterBufferOffsets is `NULL` or a pointer to an array of
397e5c31af7Sopenharmony_ci    basetype:VkDeviceSize values specifying offsets within each of the
398e5c31af7Sopenharmony_ci    pname:pCounterBuffers where the counter values can be written.
399e5c31af7Sopenharmony_ci    The location in each counter buffer at these offsets must: be large
400e5c31af7Sopenharmony_ci    enough to contain 4 bytes of data.
401e5c31af7Sopenharmony_ci    The data stored at this location is the byte offset from the start of
402e5c31af7Sopenharmony_ci    the transform feedback buffer binding where the next vertex data would
403e5c31af7Sopenharmony_ci    be written.
404e5c31af7Sopenharmony_ci    If pname:pCounterBufferOffsets is `NULL`, then it is assumed the offsets
405e5c31af7Sopenharmony_ci    are zero.
406e5c31af7Sopenharmony_ci
407e5c31af7Sopenharmony_ci.Valid Usage
408e5c31af7Sopenharmony_ci****
409e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-transformFeedback-02374]]
410e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackFeaturesEXT::pname:transformFeedback
411e5c31af7Sopenharmony_ci    must: be enabled
412e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-None-02375]]
413e5c31af7Sopenharmony_ci    Transform feedback must: be active
414e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376]]
415e5c31af7Sopenharmony_ci    pname:firstCounterBuffer must: be less than
416e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBuffers
417e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377]]
418e5c31af7Sopenharmony_ci    The sum of pname:firstCounterBuffer and pname:counterBufferCount must:
419e5c31af7Sopenharmony_ci    be less than or equal to
420e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackBuffers
421e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-counterBufferCount-02608]]
422e5c31af7Sopenharmony_ci    If pname:counterBufferCount is not `0`, and pname:pCounterBuffers is not
423e5c31af7Sopenharmony_ci    `NULL`, pname:pCounterBuffers must: be a valid pointer to an array of
424e5c31af7Sopenharmony_ci    pname:counterBufferCount sname:VkBuffer handles that are either valid or
425e5c31af7Sopenharmony_ci    dlink:VK_NULL_HANDLE
426e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-pCounterBufferOffsets-02378]]
427e5c31af7Sopenharmony_ci    For each buffer handle in the array, if it is not dlink:VK_NULL_HANDLE
428e5c31af7Sopenharmony_ci    it must: reference a buffer large enough to hold 4 bytes at the
429e5c31af7Sopenharmony_ci    corresponding offset from the pname:pCounterBufferOffsets array
430e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-pCounterBuffer-02379]]
431e5c31af7Sopenharmony_ci    If pname:pCounterBuffer is `NULL`, then pname:pCounterBufferOffsets
432e5c31af7Sopenharmony_ci    must: also be `NULL`
433e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEndTransformFeedbackEXT-pCounterBuffers-02380]]
434e5c31af7Sopenharmony_ci    For each buffer handle in the pname:pCounterBuffers array that is not
435e5c31af7Sopenharmony_ci    dlink:VK_NULL_HANDLE it must: have been created with a pname:usage value
436e5c31af7Sopenharmony_ci    containing
437e5c31af7Sopenharmony_ci    ename:VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT
438e5c31af7Sopenharmony_ci****
439e5c31af7Sopenharmony_ci
440e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdEndTransformFeedbackEXT.adoc[]
441e5c31af7Sopenharmony_ci--
442e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[]
443e5c31af7Sopenharmony_ci
444e5c31af7Sopenharmony_ci
445e5c31af7Sopenharmony_ciifdef::VK_NV_viewport_swizzle[]
446e5c31af7Sopenharmony_ci[[vertexpostproc-viewport-swizzle]]
447e5c31af7Sopenharmony_ci== Viewport Swizzle
448e5c31af7Sopenharmony_ci
449e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportSwizzleStateCreateInfoNV',desc='Structure specifying swizzle applied to primitive clip coordinates',type='structs']
450e5c31af7Sopenharmony_ci--
451e5c31af7Sopenharmony_ciEach primitive sent to a given viewport has a swizzle and optional: negation
452e5c31af7Sopenharmony_ciapplied to its clip coordinates.
453e5c31af7Sopenharmony_ciThe swizzle that is applied depends on the viewport index, and is controlled
454e5c31af7Sopenharmony_ciby the sname:VkPipelineViewportSwizzleStateCreateInfoNV pipeline state:
455e5c31af7Sopenharmony_ci
456e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineViewportSwizzleStateCreateInfoNV.adoc[]
457e5c31af7Sopenharmony_ci
458e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
459e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
460e5c31af7Sopenharmony_ci    structure.
461e5c31af7Sopenharmony_ci  * pname:flags is reserved for future use.
462e5c31af7Sopenharmony_ci  * pname:viewportCount is the number of viewport swizzles used by the
463e5c31af7Sopenharmony_ci    pipeline.
464e5c31af7Sopenharmony_ci  * pname:pViewportSwizzles is a pointer to an array of
465e5c31af7Sopenharmony_ci    slink:VkViewportSwizzleNV structures, defining the viewport swizzles.
466e5c31af7Sopenharmony_ci
467e5c31af7Sopenharmony_ci.Valid Usage
468e5c31af7Sopenharmony_ci****
469e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215]]
470e5c31af7Sopenharmony_ci    pname:viewportCount must: be greater than or equal to the
471e5c31af7Sopenharmony_ci    pname:viewportCount set in sname:VkPipelineViewportStateCreateInfo
472e5c31af7Sopenharmony_ci****
473e5c31af7Sopenharmony_ci
474e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineViewportSwizzleStateCreateInfoNV.adoc[]
475e5c31af7Sopenharmony_ci--
476e5c31af7Sopenharmony_ci
477e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportSwizzleStateCreateFlagsNV',desc='Reserved for future use',type='flags']
478e5c31af7Sopenharmony_ci--
479e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineViewportSwizzleStateCreateFlagsNV.adoc[]
480e5c31af7Sopenharmony_ci
481e5c31af7Sopenharmony_citname:VkPipelineViewportSwizzleStateCreateFlagsNV is a bitmask type for
482e5c31af7Sopenharmony_cisetting a mask, but is currently reserved for future use.
483e5c31af7Sopenharmony_ci--
484e5c31af7Sopenharmony_ci
485e5c31af7Sopenharmony_ciThe sname:VkPipelineViewportSwizzleStateCreateInfoNV state is set by adding
486e5c31af7Sopenharmony_cithis structure to the pname:pNext chain of a
487e5c31af7Sopenharmony_cisname:VkPipelineViewportStateCreateInfo structure and setting the graphics
488e5c31af7Sopenharmony_cipipeline state with flink:vkCreateGraphicsPipelines.
489e5c31af7Sopenharmony_ci
490e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
491e5c31af7Sopenharmony_ci
492e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetViewportSwizzleNV',desc='Specify the viewport swizzle state dynamically for a command buffer',type='protos']
493e5c31af7Sopenharmony_ci--
494e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the viewport swizzle state,
495e5c31af7Sopenharmony_cicall:
496e5c31af7Sopenharmony_ci
497e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetViewportSwizzleNV.adoc[]
498e5c31af7Sopenharmony_ci
499e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
500e5c31af7Sopenharmony_ci    recorded.
501e5c31af7Sopenharmony_ci  * pname:firstViewport is the index of the first viewport whose parameters
502e5c31af7Sopenharmony_ci    are updated by the command.
503e5c31af7Sopenharmony_ci  * pname:viewportCount is the number of viewports whose parameters are
504e5c31af7Sopenharmony_ci    updated by the command.
505e5c31af7Sopenharmony_ci  * pname:pViewportSwizzles is a pointer to an array of
506e5c31af7Sopenharmony_ci    slink:VkViewportSwizzleNV structures specifying viewport swizzles.
507e5c31af7Sopenharmony_ci
508e5c31af7Sopenharmony_ciThis command sets the viewport swizzle state for subsequent drawing commands
509e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
510e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or]
511e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.]
512e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
513e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[]
514e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
515e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_VIEWPORT_SWIZZLE_NV set in
516e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
517e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[]
518e5c31af7Sopenharmony_ciOtherwise, this state is specified by the
519e5c31af7Sopenharmony_cislink:VkPipelineViewportSwizzleStateCreateInfoNV::pname:viewportCount, and
520e5c31af7Sopenharmony_cislink:VkPipelineViewportSwizzleStateCreateInfoNV::pname:pViewportSwizzles
521e5c31af7Sopenharmony_civalues used to create the currently active pipeline.
522e5c31af7Sopenharmony_ci
523e5c31af7Sopenharmony_ci:refpage: vkCmdSetViewportSwizzleNV
524e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3ViewportSwizzle
525e5c31af7Sopenharmony_ci
526e5c31af7Sopenharmony_ci.Valid Usage
527e5c31af7Sopenharmony_ci****
528e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[]
529e5c31af7Sopenharmony_ci****
530e5c31af7Sopenharmony_ci
531e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetViewportSwizzleNV.adoc[]
532e5c31af7Sopenharmony_ci--
533e5c31af7Sopenharmony_ci
534e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
535e5c31af7Sopenharmony_ci
536e5c31af7Sopenharmony_ciEach viewport specified from 0 to pname:viewportCount - 1 has its x,y,z,w
537e5c31af7Sopenharmony_ciswizzle state set to the corresponding pname:x, pname:y, pname:z and pname:w
538e5c31af7Sopenharmony_ciin the slink:VkViewportSwizzleNV structure.
539e5c31af7Sopenharmony_ciEach component is of type elink:VkViewportCoordinateSwizzleNV, which
540e5c31af7Sopenharmony_cidetermines the type of swizzle for that component.
541e5c31af7Sopenharmony_ciThe value of pname:x computes the new x component of the position as:
542e5c31af7Sopenharmony_ci
543e5c31af7Sopenharmony_ci[source,c]
544e5c31af7Sopenharmony_ci----
545e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV) x' = x;
546e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_X_NV) x' = -x;
547e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Y_NV) x' = y;
548e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Y_NV) x' = -y;
549e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Z_NV) x' = z;
550e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Z_NV) x' = -z;
551e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_W_NV) x' = w;
552e5c31af7Sopenharmony_ciif (x == VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV) x' = -w;
553e5c31af7Sopenharmony_ci----
554e5c31af7Sopenharmony_ci
555e5c31af7Sopenharmony_ciSimilar selections are performed for the pname:y, pname:z, and pname:w
556e5c31af7Sopenharmony_cicoordinates.
557e5c31af7Sopenharmony_ciThis swizzling is applied before clipping and perspective divide.
558e5c31af7Sopenharmony_ciIf the swizzle for an active viewport index is not specified, the swizzle
559e5c31af7Sopenharmony_cifor pname:x is ename:VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV, pname:y
560e5c31af7Sopenharmony_ciis ename:VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Y_NV, pname:z is
561e5c31af7Sopenharmony_ciename:VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Z_NV and pname:w is
562e5c31af7Sopenharmony_ciename:VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_W_NV.
563e5c31af7Sopenharmony_ci
564e5c31af7Sopenharmony_ciViewport swizzle parameters are specified by setting the pname:pNext pointer
565e5c31af7Sopenharmony_ciof sname:VkGraphicsPipelineCreateInfo to point to a
566e5c31af7Sopenharmony_cisname:VkPipelineViewportSwizzleStateCreateInfoNV structure.
567e5c31af7Sopenharmony_cislink:VkPipelineViewportSwizzleStateCreateInfoNV uses
568e5c31af7Sopenharmony_cisname:VkViewportSwizzleNV to set the viewport swizzle parameters.
569e5c31af7Sopenharmony_ci
570e5c31af7Sopenharmony_ci[open,refpage='VkViewportSwizzleNV',desc='Structure specifying a viewport swizzle',type='structs']
571e5c31af7Sopenharmony_ci--
572e5c31af7Sopenharmony_ciThe sname:VkViewportSwizzleNV structure is defined as:
573e5c31af7Sopenharmony_ci
574e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkViewportSwizzleNV.adoc[]
575e5c31af7Sopenharmony_ci
576e5c31af7Sopenharmony_ci  * pname:x is a elink:VkViewportCoordinateSwizzleNV value specifying the
577e5c31af7Sopenharmony_ci    swizzle operation to apply to the x component of the primitive
578e5c31af7Sopenharmony_ci  * pname:y is a elink:VkViewportCoordinateSwizzleNV value specifying the
579e5c31af7Sopenharmony_ci    swizzle operation to apply to the y component of the primitive
580e5c31af7Sopenharmony_ci  * pname:z is a elink:VkViewportCoordinateSwizzleNV value specifying the
581e5c31af7Sopenharmony_ci    swizzle operation to apply to the z component of the primitive
582e5c31af7Sopenharmony_ci  * pname:w is a elink:VkViewportCoordinateSwizzleNV value specifying the
583e5c31af7Sopenharmony_ci    swizzle operation to apply to the w component of the primitive
584e5c31af7Sopenharmony_ci
585e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkViewportSwizzleNV.adoc[]
586e5c31af7Sopenharmony_ci--
587e5c31af7Sopenharmony_ci
588e5c31af7Sopenharmony_ci[open,refpage='VkViewportCoordinateSwizzleNV',desc='Specify how a viewport coordinate is swizzled',type='enums']
589e5c31af7Sopenharmony_ci--
590e5c31af7Sopenharmony_ciPossible values of the slink:VkViewportSwizzleNV::pname:x, pname:y, pname:z,
591e5c31af7Sopenharmony_ciand pname:w members, specifying swizzling of the corresponding components of
592e5c31af7Sopenharmony_ciprimitives, are:
593e5c31af7Sopenharmony_ci
594e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkViewportCoordinateSwizzleNV.adoc[]
595e5c31af7Sopenharmony_ci
596e5c31af7Sopenharmony_ciThese values are described in detail in <<vertexpostproc-viewport-swizzle,
597e5c31af7Sopenharmony_ciViewport Swizzle>>.
598e5c31af7Sopenharmony_ci--
599e5c31af7Sopenharmony_ciendif::VK_NV_viewport_swizzle[]
600e5c31af7Sopenharmony_ci
601e5c31af7Sopenharmony_ci
602e5c31af7Sopenharmony_ci[[vertexpostproc-flatshading]]
603e5c31af7Sopenharmony_ci== Flat Shading
604e5c31af7Sopenharmony_ci
605e5c31af7Sopenharmony_ci_Flat shading_ a vertex output attribute means to assign all vertices of the
606e5c31af7Sopenharmony_ciprimitive the same value for that output.
607e5c31af7Sopenharmony_ciThe output values assigned are those of the _provoking vertex_ of the
608e5c31af7Sopenharmony_ciprimitive.
609e5c31af7Sopenharmony_ciFlat shading is applied to those vertex attributes that
610e5c31af7Sopenharmony_ci<<interfaces-iointerfaces-matching,match>> fragment input attributes which
611e5c31af7Sopenharmony_ciare decorated as code:Flat.
612e5c31af7Sopenharmony_ci
613e5c31af7Sopenharmony_ciIf neither
614e5c31af7Sopenharmony_ciifdef::VK_EXT_mesh_shader,VK_NV_mesh_shader[]
615e5c31af7Sopenharmony_ci<<mesh, mesh>>,
616e5c31af7Sopenharmony_ciendif::VK_EXT_mesh_shader,VK_NV_mesh_shader[]
617e5c31af7Sopenharmony_ci<<geometry,geometry>> nor <<tessellation,tessellation shading>> is active,
618e5c31af7Sopenharmony_cithe provoking vertex is determined by the <<drawing-primitive-topologies,
619e5c31af7Sopenharmony_ciprimitive topology>> defined by
620e5c31af7Sopenharmony_cislink:VkPipelineInputAssemblyStateCreateInfo:pname:topology used to execute
621e5c31af7Sopenharmony_cithe <<drawing,drawing command>>.
622e5c31af7Sopenharmony_ci
623e5c31af7Sopenharmony_ciifdef::VK_NV_mesh_shader[]
624e5c31af7Sopenharmony_ciIf a shader using code:MeshNV {ExecutionModel} is active, the provoking
625e5c31af7Sopenharmony_civertex is determined by the <<drawing-primitive-topologies, primitive
626e5c31af7Sopenharmony_citopology>> defined by the <<drawing-point-lists, code:OutputPoints>>,
627e5c31af7Sopenharmony_ci<<drawing-line-lists, code:OutputLinesNV>>, or <<drawing-triangle-lists,
628e5c31af7Sopenharmony_cicode:OutputTrianglesNV>> execution mode.
629e5c31af7Sopenharmony_ciendif::VK_NV_mesh_shader[]
630e5c31af7Sopenharmony_ci
631e5c31af7Sopenharmony_ciifdef::VK_EXT_mesh_shader[]
632e5c31af7Sopenharmony_ciIf a shader using code:MeshEXT {ExecutionModel} is active, the provoking
633e5c31af7Sopenharmony_civertex is determined by the <<drawing-primitive-topologies, primitive
634e5c31af7Sopenharmony_citopology>> defined by the <<drawing-point-lists, code:OutputPoints>>,
635e5c31af7Sopenharmony_ci<<drawing-line-lists, code:OutputLinesEXT>>, or <<drawing-triangle-lists,
636e5c31af7Sopenharmony_cicode:OutputTrianglesEXT>> execution mode.
637e5c31af7Sopenharmony_ciendif::VK_EXT_mesh_shader[]
638e5c31af7Sopenharmony_ci
639e5c31af7Sopenharmony_ciIf <<geometry,geometry shading>> is active, the provoking vertex is
640e5c31af7Sopenharmony_cidetermined by the <<drawing-primitive-topologies, primitive topology>>
641e5c31af7Sopenharmony_cidefined by the <<drawing-point-lists, code:OutputPoints>>,
642e5c31af7Sopenharmony_ci<<drawing-line-strips, code:OutputLineStrip>>, or <<drawing-triangle-strips,
643e5c31af7Sopenharmony_cicode:OutputTriangleStrip>> execution mode.
644e5c31af7Sopenharmony_ci
645e5c31af7Sopenharmony_ciIf <<tessellation,tessellation shading>> is active but <<geometry,geometry
646e5c31af7Sopenharmony_cishading>> is not, the provoking vertex may: be any of the vertices in each
647e5c31af7Sopenharmony_ciprimitive.
648e5c31af7Sopenharmony_ci
649e5c31af7Sopenharmony_ciifdef::VK_EXT_provoking_vertex[]
650e5c31af7Sopenharmony_ci[open,refpage='VkPipelineRasterizationProvokingVertexStateCreateInfoEXT',desc='Structure specifying provoking vertex mode used by a graphics pipeline',type='structs']
651e5c31af7Sopenharmony_ci--
652e5c31af7Sopenharmony_ciFor a given primitive topology, the pipeline's provoking vertex mode
653e5c31af7Sopenharmony_cidetermines which vertex is the provoking vertex.
654e5c31af7Sopenharmony_ciTo specify the provoking vertex mode, include a
655e5c31af7Sopenharmony_cisname:VkPipelineRasterizationProvokingVertexStateCreateInfoEXT structure in
656e5c31af7Sopenharmony_cithe slink:VkPipelineRasterizationStateCreateInfo::pname:pNext chain when
657e5c31af7Sopenharmony_cicreating the pipeline.
658e5c31af7Sopenharmony_ci
659e5c31af7Sopenharmony_ciThe sname:VkPipelineRasterizationProvokingVertexStateCreateInfoEXT structure
660e5c31af7Sopenharmony_ciis defined as:
661e5c31af7Sopenharmony_ci
662e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineRasterizationProvokingVertexStateCreateInfoEXT.adoc[]
663e5c31af7Sopenharmony_ci
664e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
665e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
666e5c31af7Sopenharmony_ci    structure.
667e5c31af7Sopenharmony_ci  * pname:provokingVertexMode is a elink:VkProvokingVertexModeEXT value
668e5c31af7Sopenharmony_ci    selecting the provoking vertex mode.
669e5c31af7Sopenharmony_ci
670e5c31af7Sopenharmony_ciIf this struct is not provided when creating the pipeline, the pipeline will
671e5c31af7Sopenharmony_ciuse the ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT mode.
672e5c31af7Sopenharmony_ci
673e5c31af7Sopenharmony_ciIf the <<limits-provokingVertexModePerPipeline,
674e5c31af7Sopenharmony_cipname:provokingVertexModePerPipeline>> limit is ename:VK_FALSE, then all
675e5c31af7Sopenharmony_cipipelines bound within a render pass instance must: have the same
676e5c31af7Sopenharmony_cipname:provokingVertexMode.
677e5c31af7Sopenharmony_ci
678e5c31af7Sopenharmony_ci.Valid Usage
679e5c31af7Sopenharmony_ci****
680e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineRasterizationProvokingVertexStateCreateInfoEXT-provokingVertexMode-04883]]
681e5c31af7Sopenharmony_ci    If pname:provokingVertexMode is
682e5c31af7Sopenharmony_ci    ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, then the
683e5c31af7Sopenharmony_ci    <<features-provokingVertexLast, pname:provokingVertexLast>> feature
684e5c31af7Sopenharmony_ci    must: be enabled
685e5c31af7Sopenharmony_ci****
686e5c31af7Sopenharmony_ci
687e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineRasterizationProvokingVertexStateCreateInfoEXT.adoc[]
688e5c31af7Sopenharmony_ci--
689e5c31af7Sopenharmony_ci
690e5c31af7Sopenharmony_ci[open,refpage='VkProvokingVertexModeEXT',desc='Specify which vertex in a primitive is the provoking vertex',type='enums']
691e5c31af7Sopenharmony_ci--
692e5c31af7Sopenharmony_ciPossible values of
693e5c31af7Sopenharmony_cislink:VkPipelineRasterizationProvokingVertexStateCreateInfoEXT::pname:provokingVertexMode
694e5c31af7Sopenharmony_ciare:
695e5c31af7Sopenharmony_ci
696e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkProvokingVertexModeEXT.adoc[]
697e5c31af7Sopenharmony_ci
698e5c31af7Sopenharmony_ci  * ename:VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT specifies that the
699e5c31af7Sopenharmony_ci    provoking vertex is the first non-adjacency vertex in the list of
700e5c31af7Sopenharmony_ci    vertices used by a primitive.
701e5c31af7Sopenharmony_ci  * ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT specifies that the
702e5c31af7Sopenharmony_ci    provoking vertex is the last non-adjacency vertex in the list of
703e5c31af7Sopenharmony_ci    vertices used by a primitive.
704e5c31af7Sopenharmony_ci
705e5c31af7Sopenharmony_ciThese modes are described more precisely in
706e5c31af7Sopenharmony_ci<<drawing-primitive-topologies,Primitive Topologies>>.
707e5c31af7Sopenharmony_ci--
708e5c31af7Sopenharmony_ci
709e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
710e5c31af7Sopenharmony_ci
711e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetProvokingVertexModeEXT',desc='Specify the provoking vertex mode dynamically for a command buffer',type='protos']
712e5c31af7Sopenharmony_ci--
713e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the
714e5c31af7Sopenharmony_cipname:provokingVertexMode state, call:
715e5c31af7Sopenharmony_ci
716e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetProvokingVertexModeEXT.adoc[]
717e5c31af7Sopenharmony_ci
718e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
719e5c31af7Sopenharmony_ci    recorded.
720e5c31af7Sopenharmony_ci  * pname:provokingVertexMode specifies the pname:provokingVertexMode state.
721e5c31af7Sopenharmony_ci
722e5c31af7Sopenharmony_ciThis command sets the pname:provokingVertexMode state for subsequent drawing
723e5c31af7Sopenharmony_cicommands
724e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
725e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or]
726e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.]
727e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
728e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[]
729e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
730e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_PROVOKING_VERTEX_MODE_EXT set in
731e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
732e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[]
733e5c31af7Sopenharmony_ciOtherwise, this state is specified by the
734e5c31af7Sopenharmony_cislink:VkPipelineRasterizationProvokingVertexStateCreateInfoEXT::pname:provokingVertexMode
735e5c31af7Sopenharmony_civalue used to create the currently active pipeline.
736e5c31af7Sopenharmony_ci
737e5c31af7Sopenharmony_ci:refpage: vkCmdSetProvokingVertexModeEXT
738e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3ProvokingVertexMode
739e5c31af7Sopenharmony_ci
740e5c31af7Sopenharmony_ci.Valid Usage
741e5c31af7Sopenharmony_ci****
742e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[]
743e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetProvokingVertexModeEXT-provokingVertexMode-07447]]
744e5c31af7Sopenharmony_ci    If pname:provokingVertexMode is
745e5c31af7Sopenharmony_ci    ename:VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, then the
746e5c31af7Sopenharmony_ci    <<features-provokingVertexLast, pname:provokingVertexLast>> feature
747e5c31af7Sopenharmony_ci    must: be enabled
748e5c31af7Sopenharmony_ci****
749e5c31af7Sopenharmony_ci
750e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetProvokingVertexModeEXT.adoc[]
751e5c31af7Sopenharmony_ci--
752e5c31af7Sopenharmony_ci
753e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
754e5c31af7Sopenharmony_ci
755e5c31af7Sopenharmony_ciendif::VK_EXT_provoking_vertex[]
756e5c31af7Sopenharmony_ci
757e5c31af7Sopenharmony_ci
758e5c31af7Sopenharmony_ci[[vertexpostproc-clipping]]
759e5c31af7Sopenharmony_ci== Primitive Clipping
760e5c31af7Sopenharmony_ci
761e5c31af7Sopenharmony_ciPrimitives are culled against the _cull volume_ and then clipped to the
762e5c31af7Sopenharmony_ci_clip volume_.
763e5c31af7Sopenharmony_ciIn clip coordinates, the _view volume_ is defined by:
764e5c31af7Sopenharmony_ci
765e5c31af7Sopenharmony_ci[latexmath]
766e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
767e5c31af7Sopenharmony_ci\begin{array}{c}
768e5c31af7Sopenharmony_ci-w_c \leq x_c \leq w_c \\
769e5c31af7Sopenharmony_ci-w_c \leq y_c \leq w_c \\
770e5c31af7Sopenharmony_ciz_m \leq z_c \leq w_c
771e5c31af7Sopenharmony_ci\end{array}
772e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
773e5c31af7Sopenharmony_ci
774e5c31af7Sopenharmony_ciwhere
775e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_control[]
776e5c31af7Sopenharmony_ciif
777e5c31af7Sopenharmony_cislink:VkPipelineViewportDepthClipControlCreateInfoEXT::pname:negativeOneToOne
778e5c31af7Sopenharmony_ciis ename:VK_TRUE [eq]#z~m~# is equal to [eq]#-w~c~# otherwise
779e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_control[]
780e5c31af7Sopenharmony_ci[eq]#z~m~# is equal to zero.
781e5c31af7Sopenharmony_ci
782e5c31af7Sopenharmony_ciThis view volume can: be further restricted by as many as
783e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits::pname:maxClipDistances client-defined
784e5c31af7Sopenharmony_cihalf-spaces.
785e5c31af7Sopenharmony_ci
786e5c31af7Sopenharmony_ciThe cull volume is the intersection of up to
787e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits::pname:maxCullDistances client-defined
788e5c31af7Sopenharmony_cihalf-spaces (if no client-defined cull half-spaces are enabled, culling
789e5c31af7Sopenharmony_ciagainst the cull volume is skipped).
790e5c31af7Sopenharmony_ci
791e5c31af7Sopenharmony_ciA shader must: write a single cull distance for each enabled cull half-space
792e5c31af7Sopenharmony_cito elements of the code:CullDistance array.
793e5c31af7Sopenharmony_ciIf the cull distance for any enabled cull half-space is negative for all of
794e5c31af7Sopenharmony_cithe vertices of the primitive under consideration, the primitive is
795e5c31af7Sopenharmony_cidiscarded.
796e5c31af7Sopenharmony_ciOtherwise the primitive is clipped against the clip volume as defined below.
797e5c31af7Sopenharmony_ci
798e5c31af7Sopenharmony_ciThe clip volume is the intersection of up to
799e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits::pname:maxClipDistances client-defined
800e5c31af7Sopenharmony_cihalf-spaces with the view volume (if no client-defined clip half-spaces are
801e5c31af7Sopenharmony_cienabled, the clip volume is the view volume).
802e5c31af7Sopenharmony_ci
803e5c31af7Sopenharmony_ciA shader must: write a single clip distance for each enabled clip half-space
804e5c31af7Sopenharmony_cito elements of the code:ClipDistance array.
805e5c31af7Sopenharmony_ciClip half-space [eq]#i# is then given by the set of points satisfying the
806e5c31af7Sopenharmony_ciinequality
807e5c31af7Sopenharmony_ci
808e5c31af7Sopenharmony_ci  {empty}:: [eq]#c~i~(**P**) {geq} 0#
809e5c31af7Sopenharmony_ci
810e5c31af7Sopenharmony_ciwhere [eq]#c~i~(**P**)# is the clip distance [eq]#i# at point [eq]#**P**#.
811e5c31af7Sopenharmony_ciFor point primitives, [eq]#c~i~(**P**)# is simply the clip distance for the
812e5c31af7Sopenharmony_civertex in question.
813e5c31af7Sopenharmony_ciFor line and triangle primitives, per-vertex clip distances are interpolated
814e5c31af7Sopenharmony_ciusing a weighted mean, with weights derived according to the algorithms
815e5c31af7Sopenharmony_cidescribed in sections <<primsrast-lines-basic,Basic Line Segment
816e5c31af7Sopenharmony_ciRasterization>> and <<primsrast-polygons-basic,Basic Polygon
817e5c31af7Sopenharmony_ciRasterization>>, using the perspective interpolation equations.
818e5c31af7Sopenharmony_ci
819e5c31af7Sopenharmony_ciThe number of client-defined clip and cull half-spaces that are enabled is
820e5c31af7Sopenharmony_cidetermined by the explicit size of the built-in arrays code:ClipDistance and
821e5c31af7Sopenharmony_cicode:CullDistance, respectively, declared as an output in the interface of
822e5c31af7Sopenharmony_cithe entry point of the final shader stage before clipping.
823e5c31af7Sopenharmony_ci
824e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_enable[]
825e5c31af7Sopenharmony_ciIf slink:VkPipelineRasterizationDepthClipStateCreateInfoEXT is present in
826e5c31af7Sopenharmony_cithe graphics pipeline state then depth clipping is disabled if
827e5c31af7Sopenharmony_cislink:VkPipelineRasterizationDepthClipStateCreateInfoEXT::pname:depthClipEnable
828e5c31af7Sopenharmony_ciis ename:VK_FALSE.
829e5c31af7Sopenharmony_ciOtherwise, if slink:VkPipelineRasterizationDepthClipStateCreateInfoEXT is
830e5c31af7Sopenharmony_cinot present, depth clipping is disabled when
831e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:depthClampEnable is
832e5c31af7Sopenharmony_ciename:VK_TRUE.
833e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_enable[]
834e5c31af7Sopenharmony_ciifndef::VK_EXT_depth_clip_enable[]
835e5c31af7Sopenharmony_ciDepth clamping is enabled or disabled via the pname:depthClampEnable enable
836e5c31af7Sopenharmony_ciof the slink:VkPipelineRasterizationStateCreateInfo structure.
837e5c31af7Sopenharmony_ciDepth clipping is disabled when pname:depthClampEnable is ename:VK_TRUE.
838e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_enable[]
839e5c31af7Sopenharmony_ci
840e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
841e5c31af7Sopenharmony_ci
842e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetDepthClampEnableEXT',desc='Specify dynamically whether depth clamping is enabled in the command buffer',type='protos']
843e5c31af7Sopenharmony_ci--
844e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> enable or disable depth
845e5c31af7Sopenharmony_ciclamping, call:
846e5c31af7Sopenharmony_ci
847e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthClampEnableEXT.adoc[]
848e5c31af7Sopenharmony_ci
849e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
850e5c31af7Sopenharmony_ci    recorded.
851e5c31af7Sopenharmony_ci  * pname:depthClampEnable specifies whether depth clamping is enabled.
852e5c31af7Sopenharmony_ci
853e5c31af7Sopenharmony_ciThis command sets whether depth clamping is enabled or disabled for
854e5c31af7Sopenharmony_cisubsequent drawing commands
855e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
856e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or]
857e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.]
858e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
859e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[]
860e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
861e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT set in
862e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
863e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[]
864e5c31af7Sopenharmony_ciOtherwise, this state is specified by the
865e5c31af7Sopenharmony_cislink:VkPipelineRasterizationStateCreateInfo::pname:depthClampEnable value
866e5c31af7Sopenharmony_ciused to create the currently active pipeline.
867e5c31af7Sopenharmony_ci
868e5c31af7Sopenharmony_ciIf the depth clamping state is changed dynamically, and the pipeline was not
869e5c31af7Sopenharmony_cicreated with ename:VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT enabled, then
870e5c31af7Sopenharmony_cidepth clipping is enabled when depth clamping is disabled and vice versa.
871e5c31af7Sopenharmony_ci
872e5c31af7Sopenharmony_ci:refpage: vkCmdSetDepthClampEnableEXT
873e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3DepthClampEnable
874e5c31af7Sopenharmony_ci
875e5c31af7Sopenharmony_ci.Valid Usage
876e5c31af7Sopenharmony_ci****
877e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[]
878e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetDepthClampEnableEXT-depthClamp-07449]]
879e5c31af7Sopenharmony_ci    If the <<features-depthClamp, pname:depthClamp>> feature is not enabled,
880e5c31af7Sopenharmony_ci    pname:depthClampEnable must be ename:VK_FALSE
881e5c31af7Sopenharmony_ci****
882e5c31af7Sopenharmony_ci
883e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetDepthClampEnableEXT.adoc[]
884e5c31af7Sopenharmony_ci--
885e5c31af7Sopenharmony_ci
886e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_enable[]
887e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetDepthClipEnableEXT',desc='Specify dynamically whether depth clipping is enabled in the command buffer',type='protos']
888e5c31af7Sopenharmony_ci--
889e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> enable or disable depth
890e5c31af7Sopenharmony_ciclipping, call:
891e5c31af7Sopenharmony_ci
892e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthClipEnableEXT.adoc[]
893e5c31af7Sopenharmony_ci
894e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
895e5c31af7Sopenharmony_ci    recorded.
896e5c31af7Sopenharmony_ci  * pname:depthClipEnable specifies whether depth clipping is enabled.
897e5c31af7Sopenharmony_ci
898e5c31af7Sopenharmony_ciThis command sets whether depth clipping is enabled or disabled for
899e5c31af7Sopenharmony_cisubsequent drawing commands
900e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
901e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or]
902e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.]
903e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
904e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[]
905e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
906e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT set in
907e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
908e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[]
909e5c31af7Sopenharmony_ciOtherwise, this state is specified by the
910e5c31af7Sopenharmony_cislink:VkPipelineRasterizationDepthClipStateCreateInfoEXT::pname:depthClipEnable
911e5c31af7Sopenharmony_civalue used to create the currently active pipeline, or is set to the inverse
912e5c31af7Sopenharmony_ciof slink:VkPipelineRasterizationStateCreateInfo::pname:depthClampEnable if
913e5c31af7Sopenharmony_cisname:VkPipelineRasterizationDepthClipStateCreateInfoEXT is not specified.
914e5c31af7Sopenharmony_ci
915e5c31af7Sopenharmony_ci:refpage: vkCmdSetDepthClipEnableEXT
916e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3DepthClipEnable
917e5c31af7Sopenharmony_ci
918e5c31af7Sopenharmony_ci.Valid Usage
919e5c31af7Sopenharmony_ci****
920e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[]
921e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetDepthClipEnableEXT-depthClipEnable-07451]]
922e5c31af7Sopenharmony_ci    The <<features-depthClipEnable, pname:depthClipEnable>> feature must: be
923e5c31af7Sopenharmony_ci    enabled
924e5c31af7Sopenharmony_ci****
925e5c31af7Sopenharmony_ci
926e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetDepthClipEnableEXT.adoc[]
927e5c31af7Sopenharmony_ci--
928e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_enable[]
929e5c31af7Sopenharmony_ci
930e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
931e5c31af7Sopenharmony_ci
932e5c31af7Sopenharmony_ciWhen depth clipping is disabled, the plane equation
933e5c31af7Sopenharmony_ci
934e5c31af7Sopenharmony_ci  {empty}:: [eq]#z~m~ {leq} z~c~ {leq} w~c~#
935e5c31af7Sopenharmony_ci
936e5c31af7Sopenharmony_ci(see the clip volume definition above) is ignored by view volume clipping
937e5c31af7Sopenharmony_ci(effectively, there is no near or far plane clipping).
938e5c31af7Sopenharmony_ci
939e5c31af7Sopenharmony_ciIf the primitive under consideration is a point or line segment, then
940e5c31af7Sopenharmony_ciclipping passes it unchanged if its vertices lie entirely within the clip
941e5c31af7Sopenharmony_civolume.
942e5c31af7Sopenharmony_ci
943e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_1,VK_KHR_maintenance2[]
944e5c31af7Sopenharmony_ciIf a point's vertex lies outside of the clip volume, the entire primitive
945e5c31af7Sopenharmony_cimay: be discarded.
946e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance2[]
947e5c31af7Sopenharmony_ci
948e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance2[]
949e5c31af7Sopenharmony_ci[open,refpage='VkPointClippingBehavior',desc='Enum specifying the point clipping behavior',type='enums']
950e5c31af7Sopenharmony_ci--
951e5c31af7Sopenharmony_ciPossible values of
952e5c31af7Sopenharmony_cislink:VkPhysicalDevicePointClippingProperties::pname:pointClippingBehavior,
953e5c31af7Sopenharmony_cispecifying clipping behavior of a point primitive whose vertex lies outside
954e5c31af7Sopenharmony_cithe clip volume, are:
955e5c31af7Sopenharmony_ci
956e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkPointClippingBehavior.adoc[]
957e5c31af7Sopenharmony_ci
958e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance2[]
959e5c31af7Sopenharmony_cior the equivalent
960e5c31af7Sopenharmony_ci
961e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkPointClippingBehaviorKHR.adoc[]
962e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance2[]
963e5c31af7Sopenharmony_ci
964e5c31af7Sopenharmony_ci  * ename:VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES specifies that the
965e5c31af7Sopenharmony_ci    primitive is discarded if the vertex lies outside any clip plane,
966e5c31af7Sopenharmony_ci    including the planes bounding the view volume.
967e5c31af7Sopenharmony_ci  * ename:VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY specifies that
968e5c31af7Sopenharmony_ci    the primitive is discarded only if the vertex lies outside any user clip
969e5c31af7Sopenharmony_ci    plane.
970e5c31af7Sopenharmony_ci--
971e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance2[]
972e5c31af7Sopenharmony_ci
973e5c31af7Sopenharmony_ciIf either of a line segment's vertices lie outside of the clip volume, the
974e5c31af7Sopenharmony_ciline segment may: be clipped, with new vertex coordinates computed for each
975e5c31af7Sopenharmony_civertex that lies outside the clip volume.
976e5c31af7Sopenharmony_ciA clipped line segment endpoint lies on both the original line segment and
977e5c31af7Sopenharmony_cithe boundary of the clip volume.
978e5c31af7Sopenharmony_ci
979e5c31af7Sopenharmony_ciThis clipping produces a value, [eq]#0 {leq} t {leq} 1#, for each clipped
980e5c31af7Sopenharmony_civertex.
981e5c31af7Sopenharmony_ciIf the coordinates of a clipped vertex are [eq]#**P**# and the unclipped
982e5c31af7Sopenharmony_ciline segment's vertex coordinates are [eq]#**P**~1~# and [eq]#**P**~2~#,
983e5c31af7Sopenharmony_cithen [eq]#t# satisfies the following equation
984e5c31af7Sopenharmony_ci
985e5c31af7Sopenharmony_ci  {empty}:: [eq]#**P** = t **P**~1~ {plus} (1-t) **P**~2~#.
986e5c31af7Sopenharmony_ci
987e5c31af7Sopenharmony_ci[eq]#t# is used to clip vertex output attributes as described in
988e5c31af7Sopenharmony_ci<<vertexpostproc-clipping-shader-outputs,Clipping Shader Outputs>>.
989e5c31af7Sopenharmony_ci
990e5c31af7Sopenharmony_ciIf the primitive is a polygon, it passes unchanged if every one of its edges
991e5c31af7Sopenharmony_cilies entirely inside the clip volume, and is either clipped or discarded
992e5c31af7Sopenharmony_ciotherwise.
993e5c31af7Sopenharmony_ciIf the edges of the polygon intersect the boundary of the clip volume, the
994e5c31af7Sopenharmony_ciintersecting edges are reconnected by new edges that lie along the boundary
995e5c31af7Sopenharmony_ciof the clip volume - in some cases requiring the introduction of new
996e5c31af7Sopenharmony_civertices into a polygon.
997e5c31af7Sopenharmony_ci
998e5c31af7Sopenharmony_ciIf a polygon intersects an edge of the clip volume's boundary, the clipped
999e5c31af7Sopenharmony_cipolygon must: include a point on this boundary edge.
1000e5c31af7Sopenharmony_ci
1001e5c31af7Sopenharmony_ciPrimitives rendered with user-defined half-spaces must: satisfy a
1002e5c31af7Sopenharmony_cicomplementarity criterion.
1003e5c31af7Sopenharmony_ciSuppose a series of primitives is drawn where each vertex [eq]#i# has a
1004e5c31af7Sopenharmony_cisingle specified clip distance [eq]#d~i~# (or a number of similarly
1005e5c31af7Sopenharmony_cispecified clip distances, if multiple half-spaces are enabled).
1006e5c31af7Sopenharmony_ciNext, suppose that the same series of primitives are drawn again with each
1007e5c31af7Sopenharmony_cisuch clip distance replaced by [eq]#-d~i~# (and the graphics pipeline is
1008e5c31af7Sopenharmony_ciotherwise the same).
1009e5c31af7Sopenharmony_ciIn this case, primitives must: not be missing any pixels, and pixels must:
1010e5c31af7Sopenharmony_cinot be drawn twice in regions where those primitives are cut by the clip
1011e5c31af7Sopenharmony_ciplanes.
1012e5c31af7Sopenharmony_ci
1013e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_control[]
1014e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportDepthClipControlCreateInfoEXT',desc='Structure specifying parameters of a newly created pipeline depth clip control state',type='structs']
1015e5c31af7Sopenharmony_ci--
1016e5c31af7Sopenharmony_ciThe sname:VkPipelineViewportDepthClipControlCreateInfoEXT structure is
1017e5c31af7Sopenharmony_cidefined as:
1018e5c31af7Sopenharmony_ci
1019e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineViewportDepthClipControlCreateInfoEXT.adoc[]
1020e5c31af7Sopenharmony_ci
1021e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
1022e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
1023e5c31af7Sopenharmony_ci    structure.
1024e5c31af7Sopenharmony_ci  * pname:negativeOneToOne sets the [eq]#z~m~# in the _view volume_ to
1025e5c31af7Sopenharmony_ci    [eq]#-w~c~#
1026e5c31af7Sopenharmony_ci
1027e5c31af7Sopenharmony_ci.Valid Usage
1028e5c31af7Sopenharmony_ci****
1029e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportDepthClipControlCreateInfoEXT-negativeOneToOne-06470]]
1030e5c31af7Sopenharmony_ci    If <<features-depthClipControl, pname:depthClipControl>> is not enabled,
1031e5c31af7Sopenharmony_ci    pname:negativeOneToOne must: be ename:VK_FALSE
1032e5c31af7Sopenharmony_ci****
1033e5c31af7Sopenharmony_ci
1034e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineViewportDepthClipControlCreateInfoEXT.adoc[]
1035e5c31af7Sopenharmony_ci--
1036e5c31af7Sopenharmony_ci
1037e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
1038e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetDepthClipNegativeOneToOneEXT',desc='Specify the negative one to one depth clip mode dynamically for a command buffer',type='protos']
1039e5c31af7Sopenharmony_ci--
1040e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> pname:negativeOneToOne,
1041e5c31af7Sopenharmony_cicall:
1042e5c31af7Sopenharmony_ci
1043e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetDepthClipNegativeOneToOneEXT.adoc[]
1044e5c31af7Sopenharmony_ci
1045e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
1046e5c31af7Sopenharmony_ci    recorded.
1047e5c31af7Sopenharmony_ci  * pname:negativeOneToOne specifies the pname:negativeOneToOne state.
1048e5c31af7Sopenharmony_ci
1049e5c31af7Sopenharmony_ciThis command sets the pname:negativeOneToOne state for subsequent drawing
1050e5c31af7Sopenharmony_cicommands
1051e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
1052e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>, or]
1053e5c31af7Sopenharmony_ciifndef::VK_EXT_extended_dynamic_state3[when drawing using <<shaders-objects, shader objects>>.]
1054e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
1055e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state3[]
1056e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
1057e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT set in
1058e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
1059e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3[]
1060e5c31af7Sopenharmony_ciOtherwise, this state is specified by the
1061e5c31af7Sopenharmony_cislink:VkPipelineViewportDepthClipControlCreateInfoEXT::pname:negativeOneToOne
1062e5c31af7Sopenharmony_civalue used to create the currently active pipeline.
1063e5c31af7Sopenharmony_ci
1064e5c31af7Sopenharmony_ci:refpage: vkCmdSetDepthClipNegativeOneToOneEXT
1065e5c31af7Sopenharmony_ci:requiredfeature: extendedDynamicState3DepthClipNegativeOneToOne
1066e5c31af7Sopenharmony_ci
1067e5c31af7Sopenharmony_ci.Valid Usage
1068e5c31af7Sopenharmony_ci****
1069e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state3_feature_common.adoc[]
1070e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetDepthClipNegativeOneToOneEXT-depthClipControl-07453]]
1071e5c31af7Sopenharmony_ci    The <<features-depthClipControl, pname:depthClipControl>> feature must:
1072e5c31af7Sopenharmony_ci    be enabled
1073e5c31af7Sopenharmony_ci****
1074e5c31af7Sopenharmony_ci
1075e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetDepthClipNegativeOneToOneEXT.adoc[]
1076e5c31af7Sopenharmony_ci--
1077e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state3,VK_EXT_shader_object[]
1078e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_control[]
1079e5c31af7Sopenharmony_ci
1080e5c31af7Sopenharmony_ci
1081e5c31af7Sopenharmony_ci[[vertexpostproc-clipping-shader-outputs]]
1082e5c31af7Sopenharmony_ci== Clipping Shader Outputs
1083e5c31af7Sopenharmony_ci
1084e5c31af7Sopenharmony_ciNext, vertex output attributes are clipped.
1085e5c31af7Sopenharmony_ciThe output values associated with a vertex that lies within the clip volume
1086e5c31af7Sopenharmony_ciare unaffected by clipping.
1087e5c31af7Sopenharmony_ciIf a primitive is clipped, however, the output values assigned to vertices
1088e5c31af7Sopenharmony_ciproduced by clipping are clipped.
1089e5c31af7Sopenharmony_ci
1090e5c31af7Sopenharmony_ciLet the output values assigned to the two vertices [eq]#**P**~1~# and
1091e5c31af7Sopenharmony_ci[eq]#**P**~2~# of an unclipped edge be [eq]#**c**~1~# and [eq]#**c**~2~#.
1092e5c31af7Sopenharmony_ciThe value of [eq]#t# (see <<vertexpostproc-clipping,Primitive Clipping>>)
1093e5c31af7Sopenharmony_cifor a clipped point [eq]#**P**# is used to obtain the output value
1094e5c31af7Sopenharmony_ciassociated with [eq]#**P**# as
1095e5c31af7Sopenharmony_ci
1096e5c31af7Sopenharmony_ci  {empty}:: [eq]#**c** = t **c**~1~ {plus} (1-t) **c**~2~#.
1097e5c31af7Sopenharmony_ci
1098e5c31af7Sopenharmony_ci(Multiplying an output value by a scalar means multiplying each of _x_, _y_,
1099e5c31af7Sopenharmony_ci_z_, and _w_ by the scalar.)
1100e5c31af7Sopenharmony_ci
1101e5c31af7Sopenharmony_ciSince this computation is performed in clip space before division by
1102e5c31af7Sopenharmony_ci[eq]#w~c~#, clipped output values are perspective-correct.
1103e5c31af7Sopenharmony_ci
1104e5c31af7Sopenharmony_ciPolygon clipping creates a clipped vertex along an edge of the clip volume's
1105e5c31af7Sopenharmony_ciboundary.
1106e5c31af7Sopenharmony_ciThis situation is handled by noting that polygon clipping proceeds by
1107e5c31af7Sopenharmony_ciclipping against one half-space at a time.
1108e5c31af7Sopenharmony_ciOutput value clipping is done in the same way, so that clipped points always
1109e5c31af7Sopenharmony_cioccur at the intersection of polygon edges (possibly already clipped) with
1110e5c31af7Sopenharmony_cithe clip volume's boundary.
1111e5c31af7Sopenharmony_ci
1112e5c31af7Sopenharmony_ciFor vertex output attributes whose matching fragment input attributes are
1113e5c31af7Sopenharmony_cidecorated with code:NoPerspective, the value of [eq]#t# used to obtain the
1114e5c31af7Sopenharmony_cioutput value associated with [eq]#**P**# will be adjusted to produce results
1115e5c31af7Sopenharmony_cithat vary linearly in framebuffer space.
1116e5c31af7Sopenharmony_ci
1117e5c31af7Sopenharmony_ciOutput attributes of integer or unsigned integer type must: always be flat
1118e5c31af7Sopenharmony_cishaded.
1119e5c31af7Sopenharmony_ciFlat shaded attributes are constant over the primitive being rasterized (see
1120e5c31af7Sopenharmony_ci<<primsrast-lines-basic,Basic Line Segment Rasterization>> and
1121e5c31af7Sopenharmony_ci<<primsrast-polygons-basic,Basic Polygon Rasterization>>), and no
1122e5c31af7Sopenharmony_ciinterpolation is performed.
1123e5c31af7Sopenharmony_ciThe output value [eq]#**c**# is taken from either [eq]#**c**~1~# or
1124e5c31af7Sopenharmony_ci[eq]#**c**~2~#, since flat shading has already occurred and the two values
1125e5c31af7Sopenharmony_ciare identical.
1126e5c31af7Sopenharmony_ci
1127e5c31af7Sopenharmony_ciifdef::VK_NV_clip_space_w_scaling[]
1128e5c31af7Sopenharmony_ciinclude::{chapters}/VK_NV_clip_space_w_scaling/vertexpostproc.adoc[]
1129e5c31af7Sopenharmony_ciendif::VK_NV_clip_space_w_scaling[]
1130e5c31af7Sopenharmony_ci
1131e5c31af7Sopenharmony_ci
1132e5c31af7Sopenharmony_ci[[vertexpostproc-coord-transform]]
1133e5c31af7Sopenharmony_ci== Coordinate Transformations
1134e5c31af7Sopenharmony_ci
1135e5c31af7Sopenharmony_ci_Clip coordinates_ for a vertex result from shader execution, which yields a
1136e5c31af7Sopenharmony_civertex coordinate code:Position.
1137e5c31af7Sopenharmony_ci
1138e5c31af7Sopenharmony_ciPerspective division on clip coordinates yields _normalized device
1139e5c31af7Sopenharmony_cicoordinates_, followed by a _viewport_ transformation (see
1140e5c31af7Sopenharmony_ci<<vertexpostproc-viewport,Controlling the Viewport>>) to convert these
1141e5c31af7Sopenharmony_cicoordinates into _framebuffer coordinates_.
1142e5c31af7Sopenharmony_ci
1143e5c31af7Sopenharmony_ciIf a vertex in clip coordinates has a position given by
1144e5c31af7Sopenharmony_ci
1145e5c31af7Sopenharmony_ci[latexmath]
1146e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1147e5c31af7Sopenharmony_ci\left(\begin{array}{c}
1148e5c31af7Sopenharmony_cix_c \\
1149e5c31af7Sopenharmony_ciy_c \\
1150e5c31af7Sopenharmony_ciz_c \\
1151e5c31af7Sopenharmony_ciw_c
1152e5c31af7Sopenharmony_ci\end{array}\right)
1153e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1154e5c31af7Sopenharmony_ci
1155e5c31af7Sopenharmony_cithen the vertex's normalized device coordinates are
1156e5c31af7Sopenharmony_ci[latexmath]
1157e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1158e5c31af7Sopenharmony_ci\left(
1159e5c31af7Sopenharmony_ci        \begin{array}{c}
1160e5c31af7Sopenharmony_ci                x_d \\
1161e5c31af7Sopenharmony_ci                y_d \\
1162e5c31af7Sopenharmony_ci                z_d
1163e5c31af7Sopenharmony_ci        \end{array}
1164e5c31af7Sopenharmony_ci\right) =
1165e5c31af7Sopenharmony_ci\left(
1166e5c31af7Sopenharmony_ci        \begin{array}{c}
1167e5c31af7Sopenharmony_ci                \frac{x_c}{w_c} \\
1168e5c31af7Sopenharmony_ci                \frac{y_c}{w_c} \\
1169e5c31af7Sopenharmony_ci                \frac{z_c}{w_c}
1170e5c31af7Sopenharmony_ci        \end{array}
1171e5c31af7Sopenharmony_ci\right)
1172e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1173e5c31af7Sopenharmony_ci
1174e5c31af7Sopenharmony_ci
1175e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[]
1176e5c31af7Sopenharmony_ci[[vertexpostproc-renderpass-transform]]
1177e5c31af7Sopenharmony_ci== Render Pass Transform
1178e5c31af7Sopenharmony_ci
1179e5c31af7Sopenharmony_ciA _render pass transform_ can: be enabled for render pass instances.
1180e5c31af7Sopenharmony_ciThe clip coordinates [eq]#(x~c~, y~c~)# that result from vertex shader
1181e5c31af7Sopenharmony_ciexecution are transformed by a rotation of 0, 90, 180, or 270 degrees in the
1182e5c31af7Sopenharmony_ciXY plane, centered at the origin.
1183e5c31af7Sopenharmony_ci
1184e5c31af7Sopenharmony_ciWhen _Render pass transform_ is enabled, the transform applies to all
1185e5c31af7Sopenharmony_ciprimitives for all subpasses of the render pass.
1186e5c31af7Sopenharmony_ciThe transformed vertex in clip coordinates has a position given by
1187e5c31af7Sopenharmony_ci
1188e5c31af7Sopenharmony_ci[latexmath]
1189e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1190e5c31af7Sopenharmony_ci\left(
1191e5c31af7Sopenharmony_ci        \begin{array}{c}
1192e5c31af7Sopenharmony_ci                x_{c_{trans}} \\
1193e5c31af7Sopenharmony_ci                y_{c_{trans}} \\
1194e5c31af7Sopenharmony_ci                z_{c_{trans}}
1195e5c31af7Sopenharmony_ci        \end{array}
1196e5c31af7Sopenharmony_ci\right) =
1197e5c31af7Sopenharmony_ci\left(
1198e5c31af7Sopenharmony_ci        \begin{array}{c}
1199e5c31af7Sopenharmony_ci                x_{c} \cos \theta - y_{c} \sin \theta \\
1200e5c31af7Sopenharmony_ci                x_{c} \sin \theta + y_{c} \cos \theta \\
1201e5c31af7Sopenharmony_ci                z_c
1202e5c31af7Sopenharmony_ci        \end{array}
1203e5c31af7Sopenharmony_ci\right)
1204e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1205e5c31af7Sopenharmony_ci
1206e5c31af7Sopenharmony_ciwhere
1207e5c31af7Sopenharmony_ci
1208e5c31af7Sopenharmony_ci  * _[eq]#{theta}#_ is 0 degrees for
1209e5c31af7Sopenharmony_ci    ename:VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR
1210e5c31af7Sopenharmony_ci  * _[eq]#{theta}#_ is 90 degrees for
1211e5c31af7Sopenharmony_ci    ename:VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR
1212e5c31af7Sopenharmony_ci  * _[eq]#{theta}#_ is 180 degrees for
1213e5c31af7Sopenharmony_ci    ename:VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR
1214e5c31af7Sopenharmony_ci  * _[eq]#{theta}#_ is 270 degrees for
1215e5c31af7Sopenharmony_ci    ename:VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR
1216e5c31af7Sopenharmony_ci
1217e5c31af7Sopenharmony_ci
1218e5c31af7Sopenharmony_ciThe transformed vertex's normalized device coordinates are
1219e5c31af7Sopenharmony_ci[latexmath]
1220e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1221e5c31af7Sopenharmony_ci\left(
1222e5c31af7Sopenharmony_ci        \begin{array}{c}
1223e5c31af7Sopenharmony_ci                x_d \\
1224e5c31af7Sopenharmony_ci                y_d \\
1225e5c31af7Sopenharmony_ci                z_d
1226e5c31af7Sopenharmony_ci        \end{array}
1227e5c31af7Sopenharmony_ci\right) =
1228e5c31af7Sopenharmony_ci\left(
1229e5c31af7Sopenharmony_ci        \begin{array}{c}
1230e5c31af7Sopenharmony_ci                \frac{x_{c_{trans}}}{w_c} \\
1231e5c31af7Sopenharmony_ci                \frac{y_{c_{trans}}}{w_c} \\
1232e5c31af7Sopenharmony_ci                \frac{z_{c_{trans}}}{w_c}
1233e5c31af7Sopenharmony_ci        \end{array}
1234e5c31af7Sopenharmony_ci\right)
1235e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1236e5c31af7Sopenharmony_ci
1237e5c31af7Sopenharmony_ci
1238e5c31af7Sopenharmony_ciWhen render pass transform is enabled for a render pass instance, the
1239e5c31af7Sopenharmony_cifollowing additional features are enabled:
1240e5c31af7Sopenharmony_ci
1241e5c31af7Sopenharmony_ci  * Each slink:VkViewport specified by either
1242e5c31af7Sopenharmony_ci    slink:VkPipelineViewportStateCreateInfo::pname:pViewports or
1243e5c31af7Sopenharmony_ci    flink:vkCmdSetViewport will have its width/height [eq]#(p~x~, p~y~)# and
1244e5c31af7Sopenharmony_ci    its center [eq]#(o~x~, o~y~)# similarly transformed by the
1245e5c31af7Sopenharmony_ci    implementation.
1246e5c31af7Sopenharmony_ci  * Each scissor specified by
1247e5c31af7Sopenharmony_ci    slink:VkPipelineViewportStateCreateInfo::pname:pScissors or
1248e5c31af7Sopenharmony_ci    flink:vkCmdSetScissor will have its [eq]#(offset~x~, offset~y~)# and
1249e5c31af7Sopenharmony_ci    [eq]#(extent~x~, extent~y~)# similarly transformed by the
1250e5c31af7Sopenharmony_ci    implementation.
1251e5c31af7Sopenharmony_ci  * The pname:renderArea specified in
1252e5c31af7Sopenharmony_ci    slink:VkCommandBufferInheritanceRenderPassTransformInfoQCOM and
1253e5c31af7Sopenharmony_ci    slink:VkRenderPassBeginInfo will be similarly transformed by the
1254e5c31af7Sopenharmony_ci    implementation.
1255e5c31af7Sopenharmony_ci  * The [eq]#(x, y)# components of shader variables with built-in
1256e5c31af7Sopenharmony_ci    decorations code:FragCoord, code:SamplePosition, or code:PointCoord will
1257e5c31af7Sopenharmony_ci    be similarly transformed by the implementation.
1258e5c31af7Sopenharmony_ci  * The [eq]#(x,y)# components of the code:offset operand of the
1259e5c31af7Sopenharmony_ci    code:InterpolateAtOffset extended instruction will be similarly
1260e5c31af7Sopenharmony_ci    transformed by the implementation.
1261e5c31af7Sopenharmony_ci  * The values returned by SPIR-V <<shaders-derivative-operations,
1262e5c31af7Sopenharmony_ci    derivative instructions>> code:OpDPdx, code:OpDPdy, code:OpDPdxCourse,
1263e5c31af7Sopenharmony_ci    code:OpDPdyCourse, code:OpDPdxFine, code:OpDPdyFine will be similarly
1264e5c31af7Sopenharmony_ci    transformed by the implementation.
1265e5c31af7Sopenharmony_ci
1266e5c31af7Sopenharmony_ci
1267e5c31af7Sopenharmony_ciThe net result of the above, is that applications can: act as if rendering
1268e5c31af7Sopenharmony_cito a framebuffer oriented with the
1269e5c31af7Sopenharmony_cislink:VkSurfaceCapabilitiesKHR::pname:currentTransform.
1270e5c31af7Sopenharmony_ciIn other words, applications can: act as if the presentation engine will be
1271e5c31af7Sopenharmony_ciperforming the transformation of the swapchain image after rendering and
1272e5c31af7Sopenharmony_ciprior to presentation to the user.
1273e5c31af7Sopenharmony_ciIn fact, the transformation of the various items cited above are being
1274e5c31af7Sopenharmony_cihandled by the implementation as the rendering takes place.
1275e5c31af7Sopenharmony_ci
1276e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[]
1277e5c31af7Sopenharmony_ci
1278e5c31af7Sopenharmony_ci
1279e5c31af7Sopenharmony_ci[[vertexpostproc-viewport]]
1280e5c31af7Sopenharmony_ci== Controlling the Viewport
1281e5c31af7Sopenharmony_ci
1282e5c31af7Sopenharmony_ciThe viewport transformation is determined by the selected viewport's width
1283e5c31af7Sopenharmony_ciand height in pixels, [eq]#p~x~# and [eq]#p~y~#, respectively, and its
1284e5c31af7Sopenharmony_cicenter [eq]#(o~x~, o~y~)# (also in pixels), as well as its depth range min
1285e5c31af7Sopenharmony_ciand max determining a depth range scale value [eq]#p~z~# and a depth range
1286e5c31af7Sopenharmony_cibias value [eq]#o~z~# (defined below).
1287e5c31af7Sopenharmony_ciThe vertex's framebuffer coordinates [eq]#(x~f~, y~f~, z~f~)# are given by
1288e5c31af7Sopenharmony_ci
1289e5c31af7Sopenharmony_ci  {empty}:: [eq]#x~f~ = (p~x~ / 2) x~d~ {plus} o~x~#
1290e5c31af7Sopenharmony_ci  {empty}:: [eq]#y~f~ = (p~y~ / 2) y~d~ {plus} o~y~#
1291e5c31af7Sopenharmony_ci  {empty}:: [eq]#z~f~ = p~z~ {times} z~d~ {plus} o~z~#
1292e5c31af7Sopenharmony_ci
1293e5c31af7Sopenharmony_ciMultiple viewports are available, numbered zero up to
1294e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits::pname:maxViewports minus one.
1295e5c31af7Sopenharmony_ciThe number of viewports used by a pipeline is controlled by the
1296e5c31af7Sopenharmony_cipname:viewportCount member of the sname:VkPipelineViewportStateCreateInfo
1297e5c31af7Sopenharmony_cistructure used in pipeline creation.
1298e5c31af7Sopenharmony_ci
1299e5c31af7Sopenharmony_ci[eq]#x~f~# and [eq]#y~f~# have limited precision, where the number of
1300e5c31af7Sopenharmony_cifractional bits retained is specified by
1301e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits::pname:subPixelPrecisionBits.
1302e5c31af7Sopenharmony_ciifdef::VK_EXT_line_rasterization[]
1303e5c31af7Sopenharmony_ciWhen rasterizing <<primsrast-lines,line segments>>, the number of fractional
1304e5c31af7Sopenharmony_cibits is specified by
1305e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLineRasterizationPropertiesEXT::pname:lineSubPixelPrecisionBits.
1306e5c31af7Sopenharmony_ciendif::VK_EXT_line_rasterization[]
1307e5c31af7Sopenharmony_ci
1308e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportStateCreateInfo',desc='Structure specifying parameters of a newly created pipeline viewport state',type='structs']
1309e5c31af7Sopenharmony_ci--
1310e5c31af7Sopenharmony_ciThe sname:VkPipelineViewportStateCreateInfo structure is defined as:
1311e5c31af7Sopenharmony_ci
1312e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPipelineViewportStateCreateInfo.adoc[]
1313e5c31af7Sopenharmony_ci
1314e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
1315e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
1316e5c31af7Sopenharmony_ci    structure.
1317e5c31af7Sopenharmony_ci  * pname:flags is reserved for future use.
1318e5c31af7Sopenharmony_ci  * pname:viewportCount is the number of viewports used by the pipeline.
1319e5c31af7Sopenharmony_ci  * pname:pViewports is a pointer to an array of slink:VkViewport
1320e5c31af7Sopenharmony_ci    structures, defining the viewport transforms.
1321e5c31af7Sopenharmony_ci    If the viewport state is dynamic, this member is ignored.
1322e5c31af7Sopenharmony_ci  * pname:scissorCount is the number of <<fragops-scissor,scissors>> and
1323e5c31af7Sopenharmony_ci    must: match the number of viewports.
1324e5c31af7Sopenharmony_ci  * pname:pScissors is a pointer to an array of slink:VkRect2D structures
1325e5c31af7Sopenharmony_ci    defining the rectangular bounds of the scissor for the corresponding
1326e5c31af7Sopenharmony_ci    viewport.
1327e5c31af7Sopenharmony_ci    If the scissor state is dynamic, this member is ignored.
1328e5c31af7Sopenharmony_ci
1329e5c31af7Sopenharmony_ci.Valid Usage
1330e5c31af7Sopenharmony_ci****
1331e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216]]
1332e5c31af7Sopenharmony_ci    If the <<features-multiViewport, pname:multiViewport>> feature is not
1333e5c31af7Sopenharmony_ci    enabled, pname:viewportCount must: not be greater than `1`
1334e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217]]
1335e5c31af7Sopenharmony_ci    If the <<features-multiViewport, pname:multiViewport>> feature is not
1336e5c31af7Sopenharmony_ci    enabled, pname:scissorCount must: not be greater than `1`
1337e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218]]
1338e5c31af7Sopenharmony_ci    pname:viewportCount must: be less than or equal to
1339e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceLimits::pname:maxViewports
1340e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219]]
1341e5c31af7Sopenharmony_ci    pname:scissorCount must: be less than or equal to
1342e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceLimits::pname:maxViewports
1343e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-x-02821]]
1344e5c31af7Sopenharmony_ci    The pname:x and pname:y members of pname:offset member of any element of
1345e5c31af7Sopenharmony_ci    pname:pScissors must: be greater than or equal to `0`
1346e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-offset-02822]]
1347e5c31af7Sopenharmony_ci    Evaluation of [eq]#(pname:offset.x {plus} pname:extent.width)# must: not
1348e5c31af7Sopenharmony_ci    cause a signed integer addition overflow for any element of
1349e5c31af7Sopenharmony_ci    pname:pScissors
1350e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-offset-02823]]
1351e5c31af7Sopenharmony_ci    Evaluation of [eq]#(pname:offset.y {plus} pname:extent.height)# must:
1352e5c31af7Sopenharmony_ci    not cause a signed integer addition overflow for any element of
1353e5c31af7Sopenharmony_ci    pname:pScissors
1354e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-scissorCount-04134]]
1355e5c31af7Sopenharmony_ci    If pname:scissorCount and pname:viewportCount are both not dynamic, then
1356e5c31af7Sopenharmony_ci    pname:scissorCount and pname:viewportCount must: be identical
1357e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-viewportCount-04135]]
1358e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1359e5c31af7Sopenharmony_ci    If the graphics pipeline is being created with
1360e5c31af7Sopenharmony_ci    ename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT set then pname:viewportCount
1361e5c31af7Sopenharmony_ci    must: be `0`, otherwise
1362e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1363e5c31af7Sopenharmony_ci    pname:viewportCount must: be greater than `0`
1364e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-scissorCount-04136]]
1365e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1366e5c31af7Sopenharmony_ci    If the graphics pipeline is being created with
1367e5c31af7Sopenharmony_ci    ename:VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT set then pname:scissorCount
1368e5c31af7Sopenharmony_ci    must: be `0`, otherwise
1369e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1370e5c31af7Sopenharmony_ci    pname:scissorCount must: be greater than `0`
1371e5c31af7Sopenharmony_ciifdef::VK_NV_clip_space_w_scaling[]
1372e5c31af7Sopenharmony_ci  * [[VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726]]
1373e5c31af7Sopenharmony_ci    If the pname:viewportWScalingEnable member of a
1374e5c31af7Sopenharmony_ci    slink:VkPipelineViewportWScalingStateCreateInfoNV structure included in
1375e5c31af7Sopenharmony_ci    the pname:pNext chain is ename:VK_TRUE, the pname:viewportCount member
1376e5c31af7Sopenharmony_ci    of the slink:VkPipelineViewportWScalingStateCreateInfoNV structure must:
1377e5c31af7Sopenharmony_ci    be greater than or equal to
1378e5c31af7Sopenharmony_ci    slink:VkPipelineViewportStateCreateInfo::pname:viewportCount
1379e5c31af7Sopenharmony_ciendif::VK_NV_clip_space_w_scaling[]
1380e5c31af7Sopenharmony_ci****
1381e5c31af7Sopenharmony_ci
1382e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPipelineViewportStateCreateInfo.adoc[]
1383e5c31af7Sopenharmony_ci--
1384e5c31af7Sopenharmony_ci
1385e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[]
1386e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetViewportWithCount',desc='Set the viewport count and viewports dynamically for a command buffer',type='protos',alias='vkCmdSetViewportWithCountEXT']
1387e5c31af7Sopenharmony_ci--
1388e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the viewport count and
1389e5c31af7Sopenharmony_civiewports, call:
1390e5c31af7Sopenharmony_ci
1391e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3[]
1392e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetViewportWithCount.adoc[]
1393e5c31af7Sopenharmony_ci
1394e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[or the equivalent command]
1395e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3[]
1396e5c31af7Sopenharmony_ci
1397e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[]
1398e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetViewportWithCountEXT.adoc[]
1399e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[]
1400e5c31af7Sopenharmony_ci
1401e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
1402e5c31af7Sopenharmony_ci    recorded.
1403e5c31af7Sopenharmony_ci  * pname:viewportCount specifies the viewport count.
1404e5c31af7Sopenharmony_ci  * pname:pViewports specifies the viewports to use for drawing.
1405e5c31af7Sopenharmony_ci
1406e5c31af7Sopenharmony_ciThis command sets the viewport count and viewports state for subsequent
1407e5c31af7Sopenharmony_cidrawing commands
1408e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
1409e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>, or]
1410e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>.]
1411e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
1412e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1413e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
1414e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT set in
1415e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
1416e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1417e5c31af7Sopenharmony_ciOtherwise, this state is specified by the corresponding
1418e5c31af7Sopenharmony_cislink:VkPipelineViewportStateCreateInfo::pname:viewportCount and
1419e5c31af7Sopenharmony_cipname:pViewports values used to create the currently active pipeline.
1420e5c31af7Sopenharmony_ci
1421e5c31af7Sopenharmony_ci:refpage: vkCmdSetViewportWithCount
1422e5c31af7Sopenharmony_ci
1423e5c31af7Sopenharmony_ci.Valid Usage
1424e5c31af7Sopenharmony_ci****
1425e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state_feature_common.adoc[]
1426e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewportWithCount-viewportCount-03394]]
1427e5c31af7Sopenharmony_ci    pname:viewportCount must: be between `1` and
1428e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceLimits::pname:maxViewports, inclusive
1429e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewportWithCount-viewportCount-03395]]
1430e5c31af7Sopenharmony_ci    If the <<features-multiViewport, pname:multiViewport>> feature is not
1431e5c31af7Sopenharmony_ci    enabled, pname:viewportCount must: be `1`
1432e5c31af7Sopenharmony_ciifdef::VK_NV_inherited_viewport_scissor[]
1433e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewportWithCount-commandBuffer-04819]]
1434e5c31af7Sopenharmony_ci    pname:commandBuffer must: not have
1435e5c31af7Sopenharmony_ci    slink:VkCommandBufferInheritanceViewportScissorInfoNV::pname:viewportScissor2D
1436e5c31af7Sopenharmony_ci    enabled
1437e5c31af7Sopenharmony_ciendif::VK_NV_inherited_viewport_scissor[]
1438e5c31af7Sopenharmony_ci****
1439e5c31af7Sopenharmony_ci
1440e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetViewportWithCount.adoc[]
1441e5c31af7Sopenharmony_ci--
1442e5c31af7Sopenharmony_ci
1443e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetScissorWithCount',desc='Set the scissor count and scissor rectangular bounds dynamically for a command buffer',type='protos',alias='vkCmdSetScissorWithCountEXT']
1444e5c31af7Sopenharmony_ci--
1445e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the scissor count and
1446e5c31af7Sopenharmony_ciscissor rectangular bounds, call:
1447e5c31af7Sopenharmony_ci
1448e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3[]
1449e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetScissorWithCount.adoc[]
1450e5c31af7Sopenharmony_ci
1451e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[or the equivalent command]
1452e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3[]
1453e5c31af7Sopenharmony_ci
1454e5c31af7Sopenharmony_ciifdef::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[]
1455e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetScissorWithCountEXT.adoc[]
1456e5c31af7Sopenharmony_ciendif::VK_EXT_extended_dynamic_state,VK_EXT_shader_object[]
1457e5c31af7Sopenharmony_ci
1458e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
1459e5c31af7Sopenharmony_ci    recorded.
1460e5c31af7Sopenharmony_ci  * pname:scissorCount specifies the scissor count.
1461e5c31af7Sopenharmony_ci  * pname:pScissors specifies the scissors to use for drawing.
1462e5c31af7Sopenharmony_ci
1463e5c31af7Sopenharmony_ciThis command sets the scissor count and scissor rectangular bounds state for
1464e5c31af7Sopenharmony_cisubsequent drawing commands
1465e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
1466e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>, or]
1467e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[when drawing using <<shaders-objects, shader objects>>.]
1468e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
1469e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1470e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with
1471e5c31af7Sopenharmony_ciename:VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT set in
1472e5c31af7Sopenharmony_cislink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
1473e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state[]
1474e5c31af7Sopenharmony_ciOtherwise, this state is specified by the corresponding
1475e5c31af7Sopenharmony_cislink:VkPipelineViewportStateCreateInfo::pname:scissorCount and
1476e5c31af7Sopenharmony_cipname:pScissors values used to create the currently active pipeline.
1477e5c31af7Sopenharmony_ci
1478e5c31af7Sopenharmony_ci:refpage: vkCmdSetScissorWithCount
1479e5c31af7Sopenharmony_ci
1480e5c31af7Sopenharmony_ci.Valid Usage
1481e5c31af7Sopenharmony_ci****
1482e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/dynamic_state_feature_common.adoc[]
1483e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetScissorWithCount-scissorCount-03397]]
1484e5c31af7Sopenharmony_ci    pname:scissorCount must: be between `1` and
1485e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceLimits::pname:maxViewports, inclusive
1486e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetScissorWithCount-scissorCount-03398]]
1487e5c31af7Sopenharmony_ci    If the <<features-multiViewport, pname:multiViewport>> feature is not
1488e5c31af7Sopenharmony_ci    enabled, pname:scissorCount must: be `1`
1489e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetScissorWithCount-x-03399]]
1490e5c31af7Sopenharmony_ci    The pname:x and pname:y members of pname:offset member of any element of
1491e5c31af7Sopenharmony_ci    pname:pScissors must: be greater than or equal to `0`
1492e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetScissorWithCount-offset-03400]]
1493e5c31af7Sopenharmony_ci    Evaluation of [eq]#(pname:offset.x {plus} pname:extent.width)# must: not
1494e5c31af7Sopenharmony_ci    cause a signed integer addition overflow for any element of
1495e5c31af7Sopenharmony_ci    pname:pScissors
1496e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetScissorWithCount-offset-03401]]
1497e5c31af7Sopenharmony_ci    Evaluation of [eq]#(pname:offset.y {plus} pname:extent.height)# must:
1498e5c31af7Sopenharmony_ci    not cause a signed integer addition overflow for any element of
1499e5c31af7Sopenharmony_ci    pname:pScissors
1500e5c31af7Sopenharmony_ciifdef::VK_NV_inherited_viewport_scissor[]
1501e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetScissorWithCount-commandBuffer-04820]]
1502e5c31af7Sopenharmony_ci    pname:commandBuffer must: not have
1503e5c31af7Sopenharmony_ci    slink:VkCommandBufferInheritanceViewportScissorInfoNV::pname:viewportScissor2D
1504e5c31af7Sopenharmony_ci    enabled
1505e5c31af7Sopenharmony_ciendif::VK_NV_inherited_viewport_scissor[]
1506e5c31af7Sopenharmony_ci****
1507e5c31af7Sopenharmony_ci
1508e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetScissorWithCount.adoc[]
1509e5c31af7Sopenharmony_ci--
1510e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_extended_dynamic_state,VK_EXT_shader_object[]
1511e5c31af7Sopenharmony_ci
1512e5c31af7Sopenharmony_ci[open,refpage='VkPipelineViewportStateCreateFlags',desc='Reserved for future use',type='flags']
1513e5c31af7Sopenharmony_ci--
1514e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPipelineViewportStateCreateFlags.adoc[]
1515e5c31af7Sopenharmony_ci
1516e5c31af7Sopenharmony_citname:VkPipelineViewportStateCreateFlags is a bitmask type for setting a
1517e5c31af7Sopenharmony_cimask, but is currently reserved for future use.
1518e5c31af7Sopenharmony_ci--
1519e5c31af7Sopenharmony_ci
1520e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[]
1521e5c31af7Sopenharmony_ciIf a geometry shader is active and has an output variable decorated with
1522e5c31af7Sopenharmony_cicode:ViewportIndex, the viewport transformation uses the viewport
1523e5c31af7Sopenharmony_cicorresponding to the value assigned to code:ViewportIndex taken from an
1524e5c31af7Sopenharmony_ciimplementation-dependent vertex of each primitive.
1525e5c31af7Sopenharmony_ciIf code:ViewportIndex is outside the range zero to pname:viewportCount minus
1526e5c31af7Sopenharmony_cione for a primitive, or if the geometry shader did not assign a value to
1527e5c31af7Sopenharmony_cicode:ViewportIndex for all vertices of a primitive due to flow control, the
1528e5c31af7Sopenharmony_civalues resulting from the viewport transformation of the vertices of such
1529e5c31af7Sopenharmony_ciprimitives are undefined:.
1530e5c31af7Sopenharmony_ciIf no geometry shader is active, or if the geometry shader does not have an
1531e5c31af7Sopenharmony_cioutput decorated with code:ViewportIndex, the viewport numbered zero is used
1532e5c31af7Sopenharmony_ciby the viewport transformation.
1533e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[]
1534e5c31af7Sopenharmony_ci
1535e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[]
1536e5c31af7Sopenharmony_ciifdef::VK_NV_viewport_array2[]
1537e5c31af7Sopenharmony_ciA _<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
1538e5c31af7Sopenharmony_cistage>>_ can: direct each primitive to zero or more viewports.
1539e5c31af7Sopenharmony_ciThe destination viewports for a primitive are selected by the last active
1540e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
1541e5c31af7Sopenharmony_cistage>> that has an output variable decorated with code:ViewportIndex
1542e5c31af7Sopenharmony_ci(selecting a single viewport) or code:ViewportMaskNV (selecting multiple
1543e5c31af7Sopenharmony_civiewports).
1544e5c31af7Sopenharmony_ciThe viewport transform uses the viewport corresponding to either the value
1545e5c31af7Sopenharmony_ciassigned to code:ViewportIndex or one of the bits set in
1546e5c31af7Sopenharmony_cicode:ViewportMaskNV, and taken from an implementation-dependent vertex of
1547e5c31af7Sopenharmony_cieach primitive.
1548e5c31af7Sopenharmony_ciIf code:ViewportIndex or any of the bits in code:ViewportMaskNV are outside
1549e5c31af7Sopenharmony_cithe range zero to pname:viewportCount minus one for a primitive, or if the
1550e5c31af7Sopenharmony_cilast active <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization
1551e5c31af7Sopenharmony_cishader stage>> did not assign a value to either code:ViewportIndex or
1552e5c31af7Sopenharmony_cicode:ViewportMaskNV for all vertices of a primitive due to flow control, the
1553e5c31af7Sopenharmony_civalues resulting from the viewport transformation of the vertices of such
1554e5c31af7Sopenharmony_ciprimitives are undefined:.
1555e5c31af7Sopenharmony_ciIf the last <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization
1556e5c31af7Sopenharmony_cishader stage>> does not have an output decorated with code:ViewportIndex or
1557e5c31af7Sopenharmony_cicode:ViewportMaskNV, the viewport numbered zero is used by the viewport
1558e5c31af7Sopenharmony_citransformation.
1559e5c31af7Sopenharmony_ciendif::VK_NV_viewport_array2[]
1560e5c31af7Sopenharmony_ciifndef::VK_NV_viewport_array2[]
1561e5c31af7Sopenharmony_ciA _<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
1562e5c31af7Sopenharmony_cistage>>_ can: direct each primitive to one of several viewports.
1563e5c31af7Sopenharmony_ciThe destination viewport for a primitive is selected by the last active
1564e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
1565e5c31af7Sopenharmony_cistage>> that has an output variable decorated with code:ViewportIndex.
1566e5c31af7Sopenharmony_ciThe viewport transform uses the viewport corresponding to the value assigned
1567e5c31af7Sopenharmony_cito code:ViewportIndex, and taken from an implementation-dependent vertex of
1568e5c31af7Sopenharmony_cieach primitive.
1569e5c31af7Sopenharmony_ciIf code:ViewportIndex is outside the range zero to pname:viewportCount minus
1570e5c31af7Sopenharmony_cione for a primitive, or if the last active
1571e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
1572e5c31af7Sopenharmony_cistage>> did not assign a value to code:ViewportIndex for all vertices of a
1573e5c31af7Sopenharmony_ciprimitive due to flow control, the values resulting from the viewport
1574e5c31af7Sopenharmony_citransformation of the vertices of such primitives are undefined:.
1575e5c31af7Sopenharmony_ciIf the last <<pipelines-graphics-subsets-pre-rasterization,pre-rasterization
1576e5c31af7Sopenharmony_cishader stage>> does not have an output decorated with code:ViewportIndex,
1577e5c31af7Sopenharmony_cithe viewport numbered zero is used by the viewport transformation.
1578e5c31af7Sopenharmony_ciendif::VK_NV_viewport_array2[]
1579e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_shader_viewport_index_layer,VK_NV_viewport_array2[]
1580e5c31af7Sopenharmony_ci
1581e5c31af7Sopenharmony_ciA single vertex can: be used in more than one individual primitive, in
1582e5c31af7Sopenharmony_ciprimitives such as ename:VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP.
1583e5c31af7Sopenharmony_ciIn this case, the viewport transformation is applied separately for each
1584e5c31af7Sopenharmony_ciprimitive.
1585e5c31af7Sopenharmony_ci
1586e5c31af7Sopenharmony_ci[open,refpage='vkCmdSetViewport',desc='Set the viewport dynamically for a command buffer',type='protos']
1587e5c31af7Sopenharmony_ci--
1588e5c31af7Sopenharmony_ciTo <<pipelines-dynamic-state, dynamically set>> the viewport transformation
1589e5c31af7Sopenharmony_ciparameters, call:
1590e5c31af7Sopenharmony_ci
1591e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdSetViewport.adoc[]
1592e5c31af7Sopenharmony_ci
1593e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer into which the command will be
1594e5c31af7Sopenharmony_ci    recorded.
1595e5c31af7Sopenharmony_ci  * pname:firstViewport is the index of the first viewport whose parameters
1596e5c31af7Sopenharmony_ci    are updated by the command.
1597e5c31af7Sopenharmony_ci  * pname:viewportCount is the number of viewports whose parameters are
1598e5c31af7Sopenharmony_ci    updated by the command.
1599e5c31af7Sopenharmony_ci  * pname:pViewports is a pointer to an array of slink:VkViewport structures
1600e5c31af7Sopenharmony_ci    specifying viewport parameters.
1601e5c31af7Sopenharmony_ci
1602e5c31af7Sopenharmony_ciThis command sets the viewport transformation parameters state for
1603e5c31af7Sopenharmony_cisubsequent drawing commands
1604e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[when drawing using <<shaders-objects, shader objects>>, or]
1605e5c31af7Sopenharmony_ciwhen the graphics pipeline is created with ename:VK_DYNAMIC_STATE_VIEWPORT
1606e5c31af7Sopenharmony_ciset in slink:VkPipelineDynamicStateCreateInfo::pname:pDynamicStates.
1607e5c31af7Sopenharmony_ciOtherwise, this state is specified by the
1608e5c31af7Sopenharmony_cisname:VkPipelineViewportStateCreateInfo::pname:pViewports values used to
1609e5c31af7Sopenharmony_cicreate the currently active pipeline.
1610e5c31af7Sopenharmony_ci
1611e5c31af7Sopenharmony_ciThe viewport parameters taken from element [eq]#i# of pname:pViewports
1612e5c31af7Sopenharmony_cireplace the current state for the viewport index [eq]#pname:firstViewport
1613e5c31af7Sopenharmony_ci{plus} i#, for [eq]#i# in [eq]#[0, pname:viewportCount)#.
1614e5c31af7Sopenharmony_ci
1615e5c31af7Sopenharmony_ci.Valid Usage
1616e5c31af7Sopenharmony_ci****
1617e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewport-firstViewport-01223]]
1618e5c31af7Sopenharmony_ci    The sum of pname:firstViewport and pname:viewportCount must: be between
1619e5c31af7Sopenharmony_ci    `1` and sname:VkPhysicalDeviceLimits::pname:maxViewports, inclusive
1620e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewport-firstViewport-01224]]
1621e5c31af7Sopenharmony_ci    If the <<features-multiViewport, pname:multiViewport>> feature is not
1622e5c31af7Sopenharmony_ci    enabled, pname:firstViewport must: be `0`
1623e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewport-viewportCount-01225]]
1624e5c31af7Sopenharmony_ci    If the <<features-multiViewport, pname:multiViewport>> feature is not
1625e5c31af7Sopenharmony_ci    enabled, pname:viewportCount must: be `1`
1626e5c31af7Sopenharmony_ciifdef::VK_NV_inherited_viewport_scissor[]
1627e5c31af7Sopenharmony_ci  * [[VUID-vkCmdSetViewport-commandBuffer-04821]]
1628e5c31af7Sopenharmony_ci    pname:commandBuffer must: not have
1629e5c31af7Sopenharmony_ci    slink:VkCommandBufferInheritanceViewportScissorInfoNV::pname:viewportScissor2D
1630e5c31af7Sopenharmony_ci    enabled
1631e5c31af7Sopenharmony_ciendif::VK_NV_inherited_viewport_scissor[]
1632e5c31af7Sopenharmony_ci****
1633e5c31af7Sopenharmony_ci
1634e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdSetViewport.adoc[]
1635e5c31af7Sopenharmony_ci--
1636e5c31af7Sopenharmony_ci
1637e5c31af7Sopenharmony_ciBoth slink:VkPipelineViewportStateCreateInfo and flink:vkCmdSetViewport use
1638e5c31af7Sopenharmony_cisname:VkViewport to set the viewport transformation parameters.
1639e5c31af7Sopenharmony_ci
1640e5c31af7Sopenharmony_ci[open,refpage='VkViewport',desc='Structure specifying a viewport',type='structs']
1641e5c31af7Sopenharmony_ci--
1642e5c31af7Sopenharmony_ciThe sname:VkViewport structure is defined as:
1643e5c31af7Sopenharmony_ci
1644e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkViewport.adoc[]
1645e5c31af7Sopenharmony_ci
1646e5c31af7Sopenharmony_ci  * pname:x and pname:y are the viewport's upper left corner [eq]#(x,y)#.
1647e5c31af7Sopenharmony_ci  * pname:width and pname:height are the viewport's width and height,
1648e5c31af7Sopenharmony_ci    respectively.
1649e5c31af7Sopenharmony_ci  * pname:minDepth and pname:maxDepth are the depth range for the viewport.
1650e5c31af7Sopenharmony_ci
1651e5c31af7Sopenharmony_ci[NOTE]
1652e5c31af7Sopenharmony_ci.Note
1653e5c31af7Sopenharmony_ci====
1654e5c31af7Sopenharmony_ciDespite their names, pname:minDepth can: be less than, equal to, or greater
1655e5c31af7Sopenharmony_cithan pname:maxDepth.
1656e5c31af7Sopenharmony_ci====
1657e5c31af7Sopenharmony_ci
1658e5c31af7Sopenharmony_ciThe framebuffer depth coordinate [eq]#pname:z~f~# may: be represented using
1659e5c31af7Sopenharmony_cieither a fixed-point or floating-point representation.
1660e5c31af7Sopenharmony_ciHowever, a floating-point representation must: be used if the depth/stencil
1661e5c31af7Sopenharmony_ciattachment has a floating-point depth component.
1662e5c31af7Sopenharmony_ciIf an [eq]#m#-bit fixed-point representation is used, we assume that it
1663e5c31af7Sopenharmony_cirepresents each value latexmath:[\frac{k}{2^m - 1}], where [eq]#k {elem} {
1664e5c31af7Sopenharmony_ci0, 1, ..., 2^m^-1 }#, as [eq]#k# (e.g. 1.0 is represented in binary as a
1665e5c31af7Sopenharmony_cistring of all ones).
1666e5c31af7Sopenharmony_ci
1667e5c31af7Sopenharmony_ciThe viewport parameters shown in the above equations are found from these
1668e5c31af7Sopenharmony_civalues as
1669e5c31af7Sopenharmony_ci
1670e5c31af7Sopenharmony_ci  {empty}:: [eq]#o~x~ = pname:x {plus} pname:width / 2#
1671e5c31af7Sopenharmony_ci  {empty}:: [eq]#o~y~ = pname:y {plus} pname:height / 2#
1672e5c31af7Sopenharmony_ci  {empty}:: [eq]#o~z~ = pname:minDepth#
1673e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_control[]
1674e5c31af7Sopenharmony_ci            (or [eq]#(pname:maxDepth + pname:minDepth) / 2# if
1675e5c31af7Sopenharmony_ci            slink:VkPipelineViewportDepthClipControlCreateInfoEXT::pname:negativeOneToOne
1676e5c31af7Sopenharmony_ci            is ename:VK_TRUE)
1677e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_control[]
1678e5c31af7Sopenharmony_ci  {empty}:: [eq]#p~x~ = pname:width#
1679e5c31af7Sopenharmony_ci  {empty}:: [eq]#p~y~ = pname:height#
1680e5c31af7Sopenharmony_ci  {empty}:: [eq]#p~z~ = pname:maxDepth - pname:minDepth#
1681e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_clip_control[]
1682e5c31af7Sopenharmony_ci            (or [eq]#(pname:maxDepth - pname:minDepth) / 2# if
1683e5c31af7Sopenharmony_ci            slink:VkPipelineViewportDepthClipControlCreateInfoEXT::pname:negativeOneToOne
1684e5c31af7Sopenharmony_ci            is ename:VK_TRUE)
1685e5c31af7Sopenharmony_ciendif::VK_EXT_depth_clip_control[]
1686e5c31af7Sopenharmony_ci
1687e5c31af7Sopenharmony_ciifdef::VK_QCOM_render_pass_transform[]
1688e5c31af7Sopenharmony_ciIf a render pass transform is enabled, the values [eq]#(p~x~,p~y~)# and
1689e5c31af7Sopenharmony_ci[eq]#(o~x~, o~y~)# defining the viewport are transformed as described in
1690e5c31af7Sopenharmony_ci<<vertexpostproc-renderpass-transform, render pass transform>> before
1691e5c31af7Sopenharmony_ciparticipating in the viewport transform.
1692e5c31af7Sopenharmony_ciendif::VK_QCOM_render_pass_transform[]
1693e5c31af7Sopenharmony_ci
1694e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
1695e5c31af7Sopenharmony_ciThe application can: specify a negative term for pname:height, which has the
1696e5c31af7Sopenharmony_cieffect of negating the y coordinate in clip space before performing the
1697e5c31af7Sopenharmony_citransform.
1698e5c31af7Sopenharmony_ciWhen using a negative pname:height, the application should: also adjust the
1699e5c31af7Sopenharmony_cipname:y value to point to the lower left corner of the viewport instead of
1700e5c31af7Sopenharmony_cithe upper left corner.
1701e5c31af7Sopenharmony_ciUsing the negative pname:height allows the application to avoid having to
1702e5c31af7Sopenharmony_cinegate the y component of the code:Position output from the last
1703e5c31af7Sopenharmony_ci<<pipelines-graphics-subsets-pre-rasterization,pre-rasterization shader
1704e5c31af7Sopenharmony_cistage>>.
1705e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1[]
1706e5c31af7Sopenharmony_ci
1707e5c31af7Sopenharmony_ciThe width and height of the <<limits-maxViewportDimensions,
1708e5c31af7Sopenharmony_ciimplementation-dependent maximum viewport dimensions>> must: be greater than
1709e5c31af7Sopenharmony_cior equal to the width and height of the largest image which can: be created
1710e5c31af7Sopenharmony_ciand attached to a framebuffer.
1711e5c31af7Sopenharmony_ci
1712e5c31af7Sopenharmony_ciThe floating-point viewport bounds are represented with an
1713e5c31af7Sopenharmony_ci<<limits-viewportSubPixelBits, implementation-dependent precision>>.
1714e5c31af7Sopenharmony_ci
1715e5c31af7Sopenharmony_ci.Valid Usage
1716e5c31af7Sopenharmony_ci****
1717e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-width-01770]]
1718e5c31af7Sopenharmony_ci    pname:width must: be greater than `0.0`
1719e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-width-01771]]
1720e5c31af7Sopenharmony_ci    pname:width must: be less than or equal to
1721e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceLimits::pname:maxViewportDimensions[0]
1722e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
1723e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-apiVersion-07917]]
1724e5c31af7Sopenharmony_ci    If the apiext:VK_KHR_maintenance1 extension is not enabled, the
1725e5c31af7Sopenharmony_ci    apiext:VK_AMD_negative_viewport_height extension is not enabled, and
1726e5c31af7Sopenharmony_ci    slink:VkPhysicalDeviceProperties::pname:apiVersion is less than Vulkan
1727e5c31af7Sopenharmony_ci    1.1, pname:height must: be greater than `0.0`
1728e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
1729e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-height-01773]]
1730e5c31af7Sopenharmony_ci    The absolute value of pname:height must: be less than or equal to
1731e5c31af7Sopenharmony_ci    sname:VkPhysicalDeviceLimits::pname:maxViewportDimensions[1]
1732e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-x-01774]]
1733e5c31af7Sopenharmony_ci    pname:x must: be greater than or equal to pname:viewportBoundsRange[0]
1734e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-x-01232]]
1735e5c31af7Sopenharmony_ci    [eq]#(pname:x {plus} pname:width)# must: be less than or equal to
1736e5c31af7Sopenharmony_ci    pname:viewportBoundsRange[1]
1737e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-y-01775]]
1738e5c31af7Sopenharmony_ci    pname:y must: be greater than or equal to pname:viewportBoundsRange[0]
1739e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1,VK_AMD_negative_viewport_height[]
1740e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-y-01776]]
1741e5c31af7Sopenharmony_ci    pname:y must: be less than or equal to pname:viewportBoundsRange[1]
1742e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-y-01777]]
1743e5c31af7Sopenharmony_ci    [eq]#(pname:y {plus} pname:height)# must: be greater than or equal to
1744e5c31af7Sopenharmony_ci    pname:viewportBoundsRange[0]
1745e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1,VK_AMD_negative_viewport_height[]
1746e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-y-01233]]
1747e5c31af7Sopenharmony_ci    [eq]#(pname:y {plus} pname:height)# must: be less than or equal to
1748e5c31af7Sopenharmony_ci    pname:viewportBoundsRange[1]
1749e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-minDepth-01234]]
1750e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_range_unrestricted[]
1751e5c31af7Sopenharmony_ci    If the `apiext:VK_EXT_depth_range_unrestricted` extension is not
1752e5c31af7Sopenharmony_ci    enabled,
1753e5c31af7Sopenharmony_ciendif::VK_EXT_depth_range_unrestricted[]
1754e5c31af7Sopenharmony_ci    pname:minDepth must: be between `0.0` and `1.0`, inclusive
1755e5c31af7Sopenharmony_ci  * [[VUID-VkViewport-maxDepth-01235]]
1756e5c31af7Sopenharmony_ciifdef::VK_EXT_depth_range_unrestricted[]
1757e5c31af7Sopenharmony_ci    If the `apiext:VK_EXT_depth_range_unrestricted` extension is not
1758e5c31af7Sopenharmony_ci    enabled,
1759e5c31af7Sopenharmony_ciendif::VK_EXT_depth_range_unrestricted[]
1760e5c31af7Sopenharmony_ci    pname:maxDepth must: be between `0.0` and `1.0`, inclusive
1761e5c31af7Sopenharmony_ci****
1762e5c31af7Sopenharmony_ci
1763e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkViewport.adoc[]
1764e5c31af7Sopenharmony_ci--
1765