Original Post
Let's say I have 500 draw calls per frame and all 500 draw calls use the same shader and that shader uses one constant buffer. Let's also assume that the data in the constant buffer needs to be built dynamically for each draw call. What would be the most desirable way to update the constant buffers, in terms of efficiency?
A) Create a single constant buffer and call Map/Unmap on that same constant buffer before each draw call.
B) Create 500 constant buffers, one for each draw call, and call Map/Unmap on the draw call's own constant buffer.
C) Or, another idea?
I know that for (A) the driver will rename the buffer each time I Map it, discarding the previous contents which is fine. But is it ok to expect that the driver can handle hundreds or even thousands of renames per frame? And I assume the rename process consumes some time, too.
On the other hand, (B) avoids the renaming and any associated overhead at the expense of possibly more video memory being consumed (500 constant buffers, even if fewer draw calls are actually used) and more code complexity.
A) Create a single constant buffer and call Map/Unmap on that same constant buffer before each draw call.
B) Create 500 constant buffers, one for each draw call, and call Map/Unmap on the draw call's own constant buffer.
C) Or, another idea?
I know that for (A) the driver will rename the buffer each time I Map it, discarding the previous contents which is fine. But is it ok to expect that the driver can handle hundreds or even thousands of renames per frame? And I assume the rename process consumes some time, too.
On the other hand, (B) avoids the renaming and any associated overhead at the expense of possibly more video memory being consumed (500 constant buffers, even if fewer draw calls are actually used) and more code complexity.