Vulkan | Batch Rendering

Batch rendering is a technique that basically combines multiple draw calls into one.--alubin

Intro

I have implemented a basic renderer that can render 3D objects and textures, but the problem is, I can't maintain good FPS when I'm trying to render a lot of them.
I was wondering is there a way to reduce the unecessary performence cost, then I found this "Batch Rendering".
The idea is
Instead of using single vkCmdDraw or vkCmdDrawIndexed for one object, it can decrease both CPU&GPU usages.

How

We can actually put the indices and vertices together into batches, and soon after I've got some problems, how I am going to deal with textures and model transforms!
I was using storage/uniform buffers to store the transformation of each object, and instanceIndex to represent transform index, and texture will be re-bind before each draw call.
And I was thinking like can I just get rid of vertex buffer and put them all in storage buffer, then use a compute shader to calculate the position of each vertex
But I decided to do an odinary way for now.
Removed storage buffers, and calculate all the position in CPU side, the performance really depends on how much things are moving(I'll probably move the calculation into GPU later)
And I made a Queue for it
for (auto& range : updateQueue)
{
  for (auto i = 0; i < range.size; i++)
  {
    vertexBufferData[i + range.offset] = newTranform * originalVertex;
  }
}
For Textures, I see people would use some dynamic descriptor count, samplers indexing features to bind them dynamically, usually you can bind a lot of samplers at once. To do so, I have to bring back the object index, but in the vertex buffer, keep a big amount of vertex buffers can slow down the rendering process very much (I've learnt that one from When Your Game Is Bad But Your Optimisation Is Genius , very inspiring video, shout out to Vercidium), so I removed vertex color to make me feel better.

layout(location = 0) in vec3 position;

layout(location = 1) in vec3 normal;

layout(location = 2) in uint texIndex;

Screenshots

image image