I'm wanting to draw a large number of rectangles (in the thousands), each of which displaying a particular texture from an upfront generated pool of textures(around 250, all of which are the same size/format). Whilst there are thousands of rectangles, there is only going to be around 10 - 20 different textures needed each frame, as many of the rectangles share the same texture. However, the 20 textures used in one frame could be completely different to the textures used in the next.
Currently I'm doing this using a draw call per rectangle, resulting in thousands of drawcalls per frame. I'd like to experiment with how it could be split up over fewer drawcalls. My plan is to have one giant dynamic buffer that [all/or some] of the rects get writtin to each frame, and store the textureID in the vertex data, for example each vertex would have the layout [Pos,UV, TexIndex]. I would then setup a Texture2DArray in the shader that will be updated each frame for the textures.
How do I update the Texture2DArray each frame though?
Do I really have to recreate the array each frame, resulting in passing the data of 20 textures from cpu to gpu? .. or is there a more efficient way to do it?
Ideally, it like to just load up the texture pool on the GPU, and then each frame, pluck out the ones I want to fill the texture array, is something like that possible?