Advertisement Jump to content
Sign in to follow this  

OpenGL DirectX equivalent to glBufferSubData()???

This topic is 4972 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was doing some research on caching systems for vertex data on the graphics card, and came across several posts by YannL talking about his sliding slot allocation system. It seemed that he was using one massive VBO on the graphics card, and then *somehow* updating only parts of it at a time. Now I see there is a way to update parts of a VBO using glBufferSubData() in OpenGL, is there an equivalent way of doing this in DirectX? If you follow the DirectX best practices, then you should lock a dynamic buffer with D3DLOCK_DISCARD or D3DLOCK_NOOVERWRITE. Now, using D3DLOCK_DISCARD won't work because it blows away everything in the buffer, and we only want to update part of the buffer. D3DLOCK_NOOVERWRITE doesn't work either because (as I understand it) you should treat it as a write-once type of flag. Once a section of the vertex buffer is written to, then you can't write over it again (until the next D3DLOCK_DISCARD call). Now, maybe glBufferSubData() isn't as performant as I think it is. Maybe it takes the same hit as locking a directx vertex buffer with no flags, and stalling the GPU (which I believe keeps the data in the buffer, and then would do what you want). I just don't know. Any help/guidance is appreciated. Thanks.

Share this post

Link to post
Share on other sites

Perhaps I dont understand the question, but you can lock a vertex buffer w/o passing in any usage flags. In this way the vertex buffer is neither discarded nor flagged as read-only.

The prototype for the glBufferSubData() and the d3ddevice::lock() functions are:

void glBufferSubData(GLenum target,
GLintptr offset,
GLsizeiptr size,
const GLvoid * data);

HRESULT Lock( UINT OffsetToLock,
UINT SizeToLock,
VOID **ppbData,

As you can see both functions provide an offset parameter, a size parameter, and an "out" pointer to the data. They are, for the most part, identical in purpose and behavior.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!