Sign in to follow this  
Harmyder

How to update vertex buffer on every frame

Recommended Posts

I have a vertex buffer and i need to update it on almost every frame, it is a cloth. I have pool of upload heaps, so creating intermediate buffer isn't costly. But if i will wirte data to the same vertex buffer on every frame, then i will tie CPU and GPU together. Should i create several copies of the same vertex buffer? I that the case where i need to use ring buffer for all my buffers for deformables?

Share this post


Link to post
Share on other sites

...

L. Spiro

Thank you for this valuable answer. could you please tell me two next things:

1. Do i need to implement one ring buffer for all my deformables or one ring buffer per every deformable? I believe you mean one for all of them, but just to be sure. And if one for all, which size approximately should i choose?

2. How it should correlate with number of back buffers?

---

Third question just came up. Do you mean ring buffer for upload or default heap? Because now i have linear allocator for upload heaps, which i use as intermediates to copy into my vertex buffers.

Edited by Harmyder

Share this post


Link to post
Share on other sites

It does not really matter which option you choose.

1.One ring buffer of size = Number of meshes * Number of vertices per mesh * Number of back buffers or

2.Ring buffer per mesh 1 of size = Number of vertices per mesh * Number of back buffers

   ....

  Ring buffer per mesh N of size = Number of vertices per mesh * Number of back buffers

If you read the data directly from upload heap this would suffice. In case you decide to copy the data to default heap from upload heap before reading, you would need to duplicate them in the default heap as well. 

Edited by _void_

Share this post


Link to post
Share on other sites

Unless you won't ever be adding or removing these objects from your scene (in which case either option is fine), you'll most likely want one ring buffer per object who's buffer changes per frame. If you think about it, with one giant buffer for all of them, its going to be a lot less efficient adding and removing objects from your scene. Every time you add a new object, you'll have to resize that buffer, which would include creating a new buffer of the correct size, copying all the stuff over from the previous buffer (might not have to do this if you know your updating each objects entire buffer every frame), then finally freeing the old buffer. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this