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-- 278The sname:VkDrawMeshTasksIndirectCommandEXT structure is defined as: 279 280include::{generated}/api/structs/VkDrawMeshTasksIndirectCommandEXT.adoc[] 281 282 * pname:groupCountX is the number of local workgroups to dispatch in the X 283 dimension. 284 * pname:groupCountY is the number of local workgroups to dispatch in the Y 285 dimension. 286 * pname:groupCountZ is the number of local workgroups to dispatch in the Z 287 dimension. 288 289The members of sname:VkDrawMeshTasksIndirectCommandEXT have the same meaning 290as the similarly named parameters of flink:vkCmdDrawMeshTasksEXT. 291 292.Valid Usage 293**** 294include::{chapters}/commonvalidity/draw_mesh_limits_common.adoc[] 295**** 296 297include::{generated}/validity/structs/VkDrawMeshTasksIndirectCommandEXT.adoc[] 298-- 299 300[open,refpage='vkCmdDrawMeshTasksIndirectCountEXT',desc='Perform an indirect mesh tasks draw with the draw count sourced from a buffer',type='protos'] 301-- 302:refpage: vkCmdDrawMeshTasksIndirectCountEXT 303 304To record an indirect mesh tasks drawing command with the draw count sourced 305from a buffer, call: 306 307include::{generated}/api/protos/vkCmdDrawMeshTasksIndirectCountEXT.adoc[] 308 309 * pname:commandBuffer is the command buffer into which the command is 310 recorded. 311 * pname:buffer is the buffer containing draw parameters. 312 * pname:offset is the byte offset into pname:buffer where parameters 313 begin. 314 * pname:countBuffer is the buffer containing the draw count. 315 * pname:countBufferOffset is the byte offset into pname:countBuffer where 316 the draw count begins. 317 * pname:maxDrawCount specifies the maximum number of draws that will be 318 executed. 319 The actual number of executed draw calls is the minimum of the count 320 specified in pname:countBuffer and pname:maxDrawCount. 321 * pname:stride is the byte stride between successive sets of draw 322 parameters. 323 324fname:vkCmdDrawMeshTasksIndirectCountEXT behaves similarly to 325flink:vkCmdDrawMeshTasksIndirectEXT except that the draw count is read by 326the device from a buffer during execution. 327The command will read an unsigned 32-bit integer from pname:countBuffer 328located at pname:countBufferOffset and use this as the draw count. 329 330.Valid Usage 331**** 332include::{chapters}/commonvalidity/draw_common.adoc[] 333include::{chapters}/commonvalidity/draw_mesh_common.adoc[] 334include::{chapters}/commonvalidity/draw_dispatch_indirect_common.adoc[] 335include::{chapters}/commonvalidity/draw_indirect_count_common.adoc[] 336 * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-stride-07096]] 337 pname:stride must: be a multiple of `4` and must: be greater than or 338 equal to code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT) 339 * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-maxDrawCount-07097]] 340 If pname:maxDrawCount is greater than or equal to `1`, 341 [eq]#(pname:stride {times} (pname:maxDrawCount - 1) {plus} pname:offset 342 {plus} code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT))# must: be 343 less than or equal to the size of pname:buffer 344 * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-07098]] 345 If the count stored in pname:countBuffer is equal to `1`, 346 [eq]#(pname:offset {plus} 347 code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT))# must: be less 348 than or equal to the size of pname:buffer 349 * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-countBuffer-07099]] 350 If the count stored in pname:countBuffer is greater than `1`, 351 [eq]#(pname:stride {times} (pname:drawCount - 1) {plus} pname:offset 352 {plus} code:sizeof(sname:VkDrawMeshTasksIndirectCommandEXT))# must: be 353 less than or equal to the size of pname:buffer 354 * [[VUID-vkCmdDrawMeshTasksIndirectCountEXT-MeshEXT-07100]] 355 The current pipeline bound to ename:VK_PIPELINE_BIND_POINT_GRAPHICS 356 must: contain a shader stage using the code:MeshEXT {ExecutionModel} 357**** 358 359include::{generated}/validity/protos/vkCmdDrawMeshTasksIndirectCountEXT.adoc[] 360 361-- 362endif::VK_EXT_mesh_shader[] 363