vkCmdDrawIndirect.

Cool vkCmdDrawIndirect
We use VkBuffer. In VkBuffer store data for meshes

struct VkDrawIndirectCommand {
uint32_t vertexCount;
uint32_t instanceCount;
uint32_t firstVertex;
uint32_t firstInstance;
}

If i draw (use vkCmdDrawIndirect) pyramid and boxe and sphere and teapot i must set world poses for each mesh.
How do this ? Using instanceCount ? And in shader use instanceID ?
Why do not have matrix in VkBuffer for world position ?
I about struct VkDrawIndirectCommand

      • Updated - - -

If have matrix for pose struct VkDrawIndirectCommand {
uint32_t vertexCount;
uint32_t instanceCount;
uint32_t firstVertex;
uint32_t firstInstance;
mat4 Matrix;
}
Its be nice.

The VkDrawIndirectCommand is fixed and can’t be expanded with user data as the GPU expects exactly this format for issuing the indirect draw commands.

So preferably just use a second storage buffer containing your per-instance matrices or use per-instance vertex attributes to pass position, rotation, etc.

Second question.
Instance mean driver call according to the number of instance count.
I mean CPU driver do many Draw if we use instanceCount in vkCmdDrawIndirect.
Its right ?

No. The whole idea behind indirect drawing is to have the CPU not do any of the draw calls. The GPU is taking the draw calls from them indirect buffer (stored in device local memory), so no CPU is involved in draw calls.

Ok.
If i draw (use vkCmdDrawIndirect) pyramid and box and sphere and teapot i must set different texture for each mesh.
How do this in one draw call ?

How do this in one draw call ?

Basically, this would happen the same way you dealt with providing other per-mesh parameters like the model’s matrix. this thread covers the details and the various alternatives.