• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2018-2020 NVIDIA Corporation
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5[[drawing-mesh-shading]]
6== Programmable Mesh Shading
7
8In this drawing approach, primitives are assembled by the mesh shader stage.
9<<mesh, Mesh shading>> operates similarly to <<dispatch, dispatching
10compute>> as the shaders make use of workgroups.
11
12ifdef::VK_NV_mesh_shader[]
13[open,refpage='vkCmdDrawMeshTasksNV',desc='Draw mesh task work items',type='protos']
14--
15:refpage: vkCmdDrawMeshTasksNV
16
17To record a mesh tasks drawing command, call:
18
19include::{generated}/api/protos/vkCmdDrawMeshTasksNV.adoc[]
20
21  * pname:commandBuffer is the command buffer into which the command will be
22    recorded.
23  * pname:taskCount is the number of local workgroups to dispatch in the X
24    dimension.
25    Y and Z dimension are implicitly set to one.
26  * pname:firstTask is the X component of the first workgroup ID.
27
28When the command is executed, a global workgroup consisting of
29pname:taskCount local workgroups is assembled.
30
31.Valid Usage
32****
33include::{chapters}/commonvalidity/draw_common.adoc[]
34include::{chapters}/commonvalidity/draw_mesh_common.adoc[]
35  * [[VUID-vkCmdDrawMeshTasksNV-taskCount-02119]]
36    pname:taskCount must: be less than or equal to
37    sname:VkPhysicalDeviceMeshShaderPropertiesNV::pname:maxDrawMeshTasksCount
38  * [[VUID-vkCmdDrawMeshTasksNV-MeshNV-07080]]
39    The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
40    must: contain a shader stage using the code:MeshNV {ExecutionModel}
41****
42
43include::{generated}/validity/protos/vkCmdDrawMeshTasksNV.adoc[]
44--
45
46[open,refpage='vkCmdDrawMeshTasksIndirectNV',desc='Issue an indirect mesh tasks draw into a command buffer',type='protos']
47--
48:refpage: vkCmdDrawMeshTasksIndirectNV
49
50To record an indirect mesh tasks drawing command, call:
51
52include::{generated}/api/protos/vkCmdDrawMeshTasksIndirectNV.adoc[]
53
54  * pname:commandBuffer is the command buffer into which the command is
55    recorded.
56  * pname:buffer is the buffer containing draw parameters.
57  * pname:offset is the byte offset into pname:buffer where parameters
58    begin.
59  * pname:drawCount is the number of draws to execute, and can: be zero.
60  * pname:stride is the byte stride between successive sets of draw
61    parameters.
62
63fname:vkCmdDrawMeshTasksIndirectNV behaves similarly to
64flink:vkCmdDrawMeshTasksNV except that the parameters are read by the device
65from a buffer during execution.
66pname:drawCount draws are executed by the command, with parameters taken
67from pname:buffer starting at pname:offset and increasing by pname:stride
68bytes for each successive draw.
69The parameters of each draw are encoded in an array of
70slink:VkDrawMeshTasksIndirectCommandNV structures.
71If pname:drawCount is less than or equal to one, pname:stride is ignored.
72
73.Valid Usage
74****
75include::{chapters}/commonvalidity/draw_common.adoc[]
76include::{chapters}/commonvalidity/draw_mesh_common.adoc[]
77include::{chapters}/commonvalidity/draw_dispatch_indirect_common.adoc[]
78include::{chapters}/commonvalidity/draw_indirect_drawcount.adoc[]
79  * [[VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146]]
80    If pname:drawCount is greater than `1`, pname:stride must: be a multiple
81    of `4` and must: be greater than or equal to
82    code:sizeof(sname:VkDrawMeshTasksIndirectCommandNV)
83  * [[VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02156]]
84    If pname:drawCount is equal to `1`, [eq]#(pname:offset {plus}
85    code:sizeof(slink:VkDrawMeshTasksIndirectCommandNV))# must: be less than
86    or equal to the size of pname:buffer
87  * [[VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02157]]
88    If pname:drawCount is greater than `1`, [eq]#(pname:stride {times}
89    (pname:drawCount - 1) {plus} pname:offset {plus}
90    code:sizeof(slink:VkDrawMeshTasksIndirectCommandNV))# must: be less than
91    or equal to the size of pname:buffer
92  * [[VUID-vkCmdDrawMeshTasksIndirectNV-MeshNV-07081]]
93    The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
94    must: contain a shader stage using the code:MeshNV {ExecutionModel}
95****
96
97include::{generated}/validity/protos/vkCmdDrawMeshTasksIndirectNV.adoc[]
98--
99
100[open,refpage='VkDrawMeshTasksIndirectCommandNV',desc='Structure specifying a mesh tasks draw indirect command',type='structs',xrefs='vkCmdDrawMeshTasksIndirectNV']
101--
102The sname:VkDrawMeshTasksIndirectCommandNV structure is defined as:
103
104include::{generated}/api/structs/VkDrawMeshTasksIndirectCommandNV.adoc[]
105
106  * pname:taskCount is the number of local workgroups to dispatch in the X
107    dimension.
108    Y and Z dimension are implicitly set to one.
109  * pname:firstTask is the X component of the first workgroup ID.
110
111The members of sname:VkDrawMeshTasksIndirectCommandNV have the same meaning
112as the similarly named parameters of flink:vkCmdDrawMeshTasksNV.
113
114.Valid Usage
115****
116  * [[VUID-VkDrawMeshTasksIndirectCommandNV-taskCount-02175]]
117    pname:taskCount must: be less than or equal to
118    sname:VkPhysicalDeviceMeshShaderPropertiesNV::pname:maxDrawMeshTasksCount
119****
120
121include::{generated}/validity/structs/VkDrawMeshTasksIndirectCommandNV.adoc[]
122--
123
124[open,refpage='vkCmdDrawMeshTasksIndirectCountNV',desc='Perform an indirect mesh tasks draw with the draw count sourced from a buffer',type='protos']
125--
126:refpage: vkCmdDrawMeshTasksIndirectCountNV
127
128To record an indirect mesh tasks drawing command with the draw count sourced
129from a buffer, call:
130
131include::{generated}/api/protos/vkCmdDrawMeshTasksIndirectCountNV.adoc[]
132
133  * pname:commandBuffer is the command buffer into which the command is
134    recorded.
135  * pname:buffer is the buffer containing draw parameters.
136  * pname:offset is the byte offset into pname:buffer where parameters
137    begin.
138  * pname:countBuffer is the buffer containing the draw count.
139  * pname:countBufferOffset is the byte offset into pname:countBuffer where
140    the draw count begins.
141  * pname:maxDrawCount specifies the maximum number of draws that will be
142    executed.
143    The actual number of executed draw calls is the minimum of the count
144    specified in pname:countBuffer and pname:maxDrawCount.
145  * pname:stride is the byte stride between successive sets of draw
146    parameters.
147
148fname:vkCmdDrawMeshTasksIndirectCountNV behaves similarly to
149flink:vkCmdDrawMeshTasksIndirectNV except that the draw count is read by the
150device from a buffer during execution.
151The command will read an unsigned 32-bit integer from pname:countBuffer
152located at pname:countBufferOffset and use this as the draw count.
153
154.Valid Usage
155****
156include::{chapters}/commonvalidity/draw_common.adoc[]
157include::{chapters}/commonvalidity/draw_mesh_common.adoc[]
158include::{chapters}/commonvalidity/draw_dispatch_indirect_common.adoc[]
159include::{chapters}/commonvalidity/draw_indirect_count_common.adoc[]
160  * [[VUID-vkCmdDrawMeshTasksIndirectCountNV-stride-02182]]
161    pname:stride must: be a multiple of `4` and must: be greater than or
162    equal to code:sizeof(sname:VkDrawMeshTasksIndirectCommandNV)
163  * [[VUID-vkCmdDrawMeshTasksIndirectCountNV-maxDrawCount-02183]]
164    If pname:maxDrawCount is greater than or equal to `1`,
165    [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset
166    {plus} code:sizeof(sname:VkDrawMeshTasksIndirectCommandNV))# must: be
167    less than or equal to the size of pname:buffer
168  * [[VUID-vkCmdDrawMeshTasksIndirectCountNV-countBuffer-02191]]
169    If the count stored in pname:countBuffer is equal to `1`,
170    [eq]#(pname:offset {plus}
171    code:sizeof(sname:VkDrawMeshTasksIndirectCommandNV))# must: be less than
172    or equal to the size of pname:buffer
173  * [[VUID-vkCmdDrawMeshTasksIndirectCountNV-countBuffer-02192]]
174    If the count stored in pname:countBuffer is greater than `1`,
175    [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset
176    {plus} code:sizeof(sname:VkDrawMeshTasksIndirectCommandNV))# must: be
177    less than or equal to the size of pname:buffer
178  * [[VUID-vkCmdDrawMeshTasksIndirectCountNV-MeshNV-07082]]
179    The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
180    must: contain a shader stage using the code:MeshNV {ExecutionModel}
181****
182
183include::{generated}/validity/protos/vkCmdDrawMeshTasksIndirectCountNV.adoc[]
184
185--
186endif::VK_NV_mesh_shader[]
187ifdef::VK_EXT_mesh_shader[]
188[open,refpage='vkCmdDrawMeshTasksEXT',desc='Draw mesh task work items',type='protos']
189--
190:refpage: vkCmdDrawMeshTasksEXT
191
192To record a mesh tasks drawing command, call:
193
194include::{generated}/api/protos/vkCmdDrawMeshTasksEXT.adoc[]
195
196  * pname:commandBuffer is the command buffer into which the command will be
197    recorded.
198  * pname:groupCountX is the number of local workgroups to dispatch in the X
199    dimension.
200  * pname:groupCountY is the number of local workgroups to dispatch in the Y
201    dimension.
202  * pname:groupCountZ is the number of local workgroups to dispatch in the Z
203    dimension.
204
205When the command is executed, a global workgroup consisting of
206[eq]#pname:groupCountX {times} pname:groupCountY {times} pname:groupCountZ#
207local workgroups is assembled.
208
209.Valid Usage
210****
211include::{chapters}/commonvalidity/draw_common.adoc[]
212include::{chapters}/commonvalidity/draw_mesh_common.adoc[]
213include::{chapters}/commonvalidity/draw_mesh_limits_common.adoc[]
214  * [[VUID-vkCmdDrawMeshTasksEXT-MeshEXT-07087]]
215    The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
216    must: contain a shader stage using the code:MeshEXT {ExecutionModel}
217****
218
219include::{generated}/validity/protos/vkCmdDrawMeshTasksEXT.adoc[]
220--
221
222[open,refpage='vkCmdDrawMeshTasksIndirectEXT',desc='Issue an indirect mesh tasks draw into a command buffer',type='protos']
223--
224:refpage: vkCmdDrawMeshTasksIndirectEXT
225
226To record an indirect mesh tasks drawing command, call:
227
228include::{generated}/api/protos/vkCmdDrawMeshTasksIndirectEXT.adoc[]
229
230  * pname:commandBuffer is the command buffer into which the command is
231    recorded.
232  * pname:buffer is the buffer containing draw parameters.
233  * pname:offset is the byte offset into pname:buffer where parameters
234    begin.
235  * pname:drawCount is the number of draws to execute, and can: be zero.
236  * pname:stride is the byte stride between successive sets of draw
237    parameters.
238
239fname:vkCmdDrawMeshTasksIndirectEXT behaves similarly to
240flink:vkCmdDrawMeshTasksEXT except that the parameters are read by the
241device from a buffer during execution.
242pname:drawCount draws are executed by the command, with parameters taken
243from pname:buffer starting at pname:offset and increasing by pname:stride
244bytes for each successive draw.
245The parameters of each draw are encoded in an array of
246slink:VkDrawMeshTasksIndirectCommandEXT structures.
247If pname:drawCount is less than or equal to one, pname:stride is ignored.
248
249.Valid Usage
250****
251include::{chapters}/commonvalidity/draw_common.adoc[]
252include::{chapters}/commonvalidity/draw_mesh_common.adoc[]
253include::{chapters}/commonvalidity/draw_dispatch_indirect_common.adoc[]
254include::{chapters}/commonvalidity/draw_indirect_drawcount.adoc[]
255  * [[VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-07088]]
256    If pname:drawCount is greater than `1`, pname:stride must: be a multiple
257    of `4` and must: be greater than or equal to
258    code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT)
259  * [[VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-07089]]
260    If pname:drawCount is equal to `1`, [eq]#(pname:offset {plus}
261    code:sizeof(slink:VkDrawMeshTasksIndirectCommandEXT))# must: be less
262    than or equal to the size of pname:buffer
263  * [[VUID-vkCmdDrawMeshTasksIndirectEXT-drawCount-07090]]
264    If pname:drawCount is greater than `1`, [eq]#(pname:stride {times}
265    (pname:drawCount - 1) {plus} pname:offset {plus}
266    code:sizeof(slink:VkDrawMeshTasksIndirectCommandEXT))# must: be less
267    than or equal to the size of pname:buffer
268  * [[VUID-vkCmdDrawMeshTasksIndirectEXT-MeshEXT-07091]]
269    The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
270    must: contain a shader stage using the code:MeshEXT {ExecutionModel}
271****
272
273include::{generated}/validity/protos/vkCmdDrawMeshTasksIndirectEXT.adoc[]
274--
275
276[open,refpage='VkDrawMeshTasksIndirectCommandEXT',desc='Structure specifying a mesh tasks draw indirect command',type='structs',xrefs='vkCmdDrawMeshTasksIndirectEXT']
277--
278:refpage: VkDrawMeshTasksIndirectCommandEXT
279
280The sname:VkDrawMeshTasksIndirectCommandEXT structure is defined as:
281
282include::{generated}/api/structs/VkDrawMeshTasksIndirectCommandEXT.adoc[]
283
284  * pname:groupCountX is the number of local workgroups to dispatch in the X
285    dimension.
286  * pname:groupCountY is the number of local workgroups to dispatch in the Y
287    dimension.
288  * pname:groupCountZ is the number of local workgroups to dispatch in the Z
289    dimension.
290
291The members of sname:VkDrawMeshTasksIndirectCommandEXT have the same meaning
292as the similarly named parameters of flink:vkCmdDrawMeshTasksEXT.
293
294.Valid Usage
295****
296include::{chapters}/commonvalidity/draw_mesh_limits_common.adoc[]
297****
298
299include::{generated}/validity/structs/VkDrawMeshTasksIndirectCommandEXT.adoc[]
300--
301
302[open,refpage='vkCmdDrawMeshTasksIndirectCountEXT',desc='Perform an indirect mesh tasks draw with the draw count sourced from a buffer',type='protos']
303--
304:refpage: vkCmdDrawMeshTasksIndirectCountEXT
305
306To record an indirect mesh tasks drawing command with the draw count sourced
307from a buffer, call:
308
309include::{generated}/api/protos/vkCmdDrawMeshTasksIndirectCountEXT.adoc[]
310
311  * pname:commandBuffer is the command buffer into which the command is
312    recorded.
313  * pname:buffer is the buffer containing draw parameters.
314  * pname:offset is the byte offset into pname:buffer where parameters
315    begin.
316  * pname:countBuffer is the buffer containing the draw count.
317  * pname:countBufferOffset is the byte offset into pname:countBuffer where
318    the draw count begins.
319  * pname:maxDrawCount specifies the maximum number of draws that will be
320    executed.
321    The actual number of executed draw calls is the minimum of the count
322    specified in pname:countBuffer and pname:maxDrawCount.
323  * pname:stride is the byte stride between successive sets of draw
324    parameters.
325
326fname:vkCmdDrawMeshTasksIndirectCountEXT behaves similarly to
327flink:vkCmdDrawMeshTasksIndirectEXT except that the draw count is read by
328the device from a buffer during execution.
329The command will read an unsigned 32-bit integer from pname:countBuffer
330located at pname:countBufferOffset and use this as the draw count.
331
332.Valid Usage
333****
334include::{chapters}/commonvalidity/draw_common.adoc[]
335include::{chapters}/commonvalidity/draw_mesh_common.adoc[]
336include::{chapters}/commonvalidity/draw_dispatch_indirect_common.adoc[]
337include::{chapters}/commonvalidity/draw_indirect_count_common.adoc[]
338  * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-stride-07096]]
339    pname:stride must: be a multiple of `4` and must: be greater than or
340    equal to code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT)
341  * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-maxDrawCount-07097]]
342    If pname:maxDrawCount is greater than or equal to `1`,
343    [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset
344    {plus} code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT))# must: be
345    less than or equal to the size of pname:buffer
346  * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-07098]]
347    If the count stored in pname:countBuffer is equal to `1`,
348    [eq]#(pname:offset {plus}
349    code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT))# must: be less
350    than or equal to the size of pname:buffer
351  * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-07099]]
352    If the count stored in pname:countBuffer is greater than `1`,
353    [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset
354    {plus} code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT))# must: be
355    less than or equal to the size of pname:buffer
356  * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-MeshEXT-07100]]
357    The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS
358    must: contain a shader stage using the code:MeshEXT {ExecutionModel}
359****
360
361include::{generated}/validity/protos/vkCmdDrawMeshTasksIndirectCountEXT.adoc[]
362
363--
364endif::VK_EXT_mesh_shader[]
365