When and Why to use Extensions -- VK_KHR_draw_indirect_count

张开发
2026/4/14 19:58:11 15 分钟阅读

分享文章

When and Why to use Extensions -- VK_KHR_draw_indirect_count
VK_KHR_draw_indirect_count已晋升为 Vulkan 1.2 核心功能每次调用vkCmdDraw都会使用一组描述绘制命令的参数。为了批量执行绘制命令相同的参数会以VkDrawIndirectCommand为单位存储在VkBuffer中。使用vkCmdDrawIndirect可以发起drawCount次绘制但drawCount的值需要在命令缓冲录制时确定。新增的vkCmdDrawIndirectCount允许将drawCount也存放在VkBuffer中使得drawCount可以动态确定并在绘制命令执行时才决定具体数值。如果支持该扩展或者VkPhysicalDeviceVulkan12Features::drawIndirectCount特性位为true则可以使用vkCmdDrawIndirectCount和vkCmdDrawIndexedIndirectCount函数。下图用于直观展示vkCmdDraw、vkCmdDrawIndirect和vkCmdDrawIndirectCount之间的区别。

更多文章