Sign in to follow this  

Vertex buffer resource locking

Recommended Posts

Hi, a question on getting the resource lock on a vertex buffer. Looking at this:


if you pass the D3DLOCK_DONOTWAIT flag to the lock function, then it can sometimes return D3DERR_WASSTILLDRAWING. In this case, should I still call the Unlock function? Reason I'm asking is because I know in many multithreading frameworks unlocking a mutex when its already unlocked can result in undefined behavior.


The documentation on the lock function doesn't seem mention anything:


I experimented a little bit with D3DLOCK_DONOTWAIT in my application but I never got it to return D3DERR_WASSTILLDRAWING (probably because I am doing all the d3d accesses in a single thread), so I don't plan on using it. But I still occasionally get problems in my app when I do things like hit ctrl+alt+delete, and the screen changes and so my device is lost and I have to re-initialize everything, and usually the re-initializing goes through fine but sometimes it appears to just deadlock, and just wondering if maybe something like this could be causing it.



Edited by garvey

Share this post

Link to post
Share on other sites

The documentation says it will return that error code if it couldn't obtain the lock immediately, ergo you don't have the lock and as such shouldn't have to unlock it.

Whether trying to unlock it when you don't have the lock is an invalid operation or not I do not know however. The safest bet is of course to not try to unlock it in this situation.

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