Sign in to follow this  
Damocles

Quick Q about vertex buffers

Recommended Posts

Is it possible to point a vertex buffer to a region of memory? I know the normal method is to lock the buffer, then copy all the data in, then unlock. Is there a way to lock it, tell it the data starts at memory address X, then unlock it?

Share this post


Link to post
Share on other sites
Be aware that DPUP can not be actually *pointed* to a memory region (like you could do on some platforms where CPU and GPU share the same memory -- xbox360, wii, etc)
Actually, DPUP will copy the specified region to an area accessible by the GPU. This is usually inefficient.

Share this post


Link to post
Share on other sites
Yeah, I figured that was the case. Thanks guys. I can't use draw*UP because I'm looking to use geometry instancing, so I was hoping to use the features of std::vector to manage the data directly in the instancing vertex buffer. I guess I'll have to write my own std::vector-esque functions to manage the vb manually.

Share this post


Link to post
Share on other sites
Quote:
Original post by Damocles
Yeah, I figured that was the case. Thanks guys. I can't use draw*UP because I'm looking to use geometry instancing, so I was hoping to use the features of std::vector to manage the data directly in the instancing vertex buffer. I guess I'll have to write my own std::vector-esque functions to manage the vb manually.

Don't. There's a reason why the usual method is to lock the buffer, copy everything in, and unlock it again. It's because it's the most efficient method (unless your vertex generation is so trivial you can lock the buffer and generate your vertices directly into it).

To manipulate a VB like a vector, you would either have to:
1) constantly lock/unlock the buffer every time you want to modify the collection
2) keep the buffer constantly locked, and unlock only when you want to render.

Both these options are terrible performance-wise. Locking is not free. And you want to keep your lock for as short of a time as possible.

Generate/modify your vertices in your vector. Then copy them over when you want to render.

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