9 replies to this topic
#1 Members - Reputation: 357
Posted 09 August 2012 - 12:54 PM
Hello guys,
I do have some questions on Mapping/Updating dynamic buffers.
Right now, I do have one buffer for multiple instances of an object which I am updating for each object with map() and then draw it. However, that is slowing everything down at lot and rendering the instancing useless.
Thing is, for the real instancing I would have to have one buffer for every instance, right? But having so much buffers in memory doesn't seem pretty smart either.
I could use one buffer for all instances, but I have to update the instancebuffer every frame (parts of it).
How can I do that, and how can I do it fast?
Thanks in advantage!
I do have some questions on Mapping/Updating dynamic buffers.
Right now, I do have one buffer for multiple instances of an object which I am updating for each object with map() and then draw it. However, that is slowing everything down at lot and rendering the instancing useless.
Thing is, for the real instancing I would have to have one buffer for every instance, right? But having so much buffers in memory doesn't seem pretty smart either.
I could use one buffer for all instances, but I have to update the instancebuffer every frame (parts of it).
How can I do that, and how can I do it fast?
Thanks in advantage!
Sponsor:
#2 Moderators - Reputation: 5454
Posted 09 August 2012 - 05:18 PM
You need to use one buffer for all of your instance data, otherwise you won't be able to draw all of your instances in a single draw call (which kinda defeats the purpose). What you can do is put all of your instance data into a shared array in CPU memory, then whenever that changes you can update the entire instance data buffer with Map and DISCARD.
#3 Members - Reputation: 357
Posted 10 August 2012 - 01:26 AM
Thanks for your answer, a shared array is the way to go!
EDIT:
I just encountered a problem with this. The number of objects is changing! Can I use a buffer with the lenght of the maximum of objects and then just use the parts already filled?
EDIT:
I just encountered a problem with this. The number of objects is changing! Can I use a buffer with the lenght of the maximum of objects and then just use the parts already filled?
Edited by gnomgrol, 10 August 2012 - 03:53 AM.
#7 Members - Reputation: 357
Posted 11 August 2012 - 01:59 PM
I want to have two instancebuffers, one which applies per instance and one which applies per vertex (for each instance).
It's for my chunksystem. The mesh of every chunk is the same, but they are modified by a per vertex buffer for the height and one constantbuffer per chunk for the start X/Z coord.
It's for my chunksystem. The mesh of every chunk is the same, but they are modified by a per vertex buffer for the height and one constantbuffer per chunk for the start X/Z coord.
#8 Moderators - Reputation: 5454
Posted 11 August 2012 - 07:27 PM
I see now. Are you using D3D11? If you are, you can store your per-instance vertex data in a structured buffer. Otherwise you can store it in one or more typed buffers with the appropriate format. Then you can us SV_InstanceID and SV_VertexID in your vertex shader to fetch the appropriate vertex data, by doing index = SV_InstanceID * NumVertices + SV_VertexID.
#9 Members - Reputation: 357
Posted 12 August 2012 - 01:39 PM
I'm confused. I cut everything out and now I'm just drawing the x-z meshes with the instanced x-z offset per chunk. But the FPS are very very low (~10), drawing 256*256*6 * 30 indices for 30 chunks. Is it that a huge number that it is causing my application to drop that low in speed?? I am drawing it with DrawIndexedInstanced() and it's the only thing drawn. All vertices are visible and send to the GPU. How much indices per Frame are fine to send to GPU to remain good speed on a normal PC?
Structured Buffers seem to be fine for my problem.
Structured Buffers seem to be fine for my problem.
Edited by gnomgrol, 12 August 2012 - 01:39 PM.






