Sign in to follow this  

Correct lock for the job in hand.

This topic is 4748 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

Hi all, This post is not so much after an answer but more towards advice on this subject. Vertex, Index, Texture and Attribute locking. I know about each lock type (well as much as you can know from the SDK) but I want to ask for advice from more experienced people about what locks I should use and when. If you could read over each Scenario and let me know what you think. Scenario 1 (Just wanting to read the data but don’t plan to update or return it) Use Lock.None Do I need to unlock after?? Scenario 2 (Just writing data into the buffer. We don’t care what data use to be in it, Ie we never read it) Use Lock.Discard Scenario 3 (Reading the data that’s in the buffer and changing it) Use Lock.Discard That’s is. Please comment as much as you like, I want to know details about what each lock REALY douse and If I am using the correct lock flags. Thanks

Share this post


Link to post
Share on other sites
When you lock data, you are taking control of data owned by the video driver. If the data is using in a waiting render, then the driver will wait for that render to complete before returning from the lock to avoid you messing it all up (or it may have to convert the data from another format or something). The flags override this by telling the driver that you are not going to mess up anything it's using, or not going to read the contents etc.

So,
1) (Why do you need to do this? It's better not to) Use Readonly and Nooverwrite to tell it you aren't going to change anything.

2) Discard only if you are overwriting everything (which the driver will probably optimise anyway and not wait for a render), but you might just want to add stuff (like a circular buffer), in which case use Nooverwrite.

3) Don't use discard because the data won't be valid to read from. There are no specific flags here as it's the worst option to use.

Share this post


Link to post
Share on other sites

This topic is 4748 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.

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