Skip to main content
GameDev.net gamedev.net
🔒 Locked

using D3DLOCK_NOOVERWRITE

Started by sipickles Jun 2, 2006 at 4:13 PM 5 replies 3.4k views
Original Post
sipickles
sipickles
Hello, I have been experimenting with using D3DLOCK_NOOVERWRITE in an attemp to boost performance. In my DX9 GUI, I allocate twice the number of vertices I want. First frame, I lock the GUIs Dynamic Vertex Buffer with D3DLOCK_NOOVERWRITE, then fill the first half, or at least part of it. Then I render it, next frame I lock the second half with D3DLOCK_NOOVERWRITE, then render that half. There is no performance improvement over using D3DLOCK_DISCARD. Is my methodology flawed? Thanks Simon
ET3D
ET3D
There are two reasons why you won't see a difference in performance.

First, I don't think that D3DLOCK_NOOVERWRITE is likely to provide any real performance boost over D3DLOCK_DISCARD. They are similar optimisations used for two different things. NOOVERWRITE should be used if you intend to use previous data in the buffer. DISCARD should be used if you don't. Since you don't seem to be reusing data, DISCARD should be the way to go.

Secondly, since you're not reusing the buffer in the same frame, there's less to optimise there in terms of locking, anyway.

If your UI is indeed slow, I'd suggest looking for bottlenecks other than your locking.
sipickles
sipickles
Its not that the UI is slow, I just remember this concept:

By using D3DLOCK_NOOVERWRITE, you are promising not to alter the data in the locked part of the buffer.

This means D3D can continue without waiting for the lock to return. (A lock operation momentarily stalls the GFX card no?)

My new theory is that I should be filling one half of the double vertex buffer and rendering the other, next frame swapping.

Make any sense?

Thx

Si
ET3D
ET3D
By using D3DLOCK_DISCARD you're telling Direct3D that you don't need the old data, which means that D3D can give you a completely different buffer which doesn't interfere with current rendering.

As you can see, it's not very different in what it does. Which is using one won't give you a real performance boost over the other.

So I think that your theory doesn't make sense. It just adds unnecessary complexity. You're discarding (not using again) older data but trying to use NOOVERWRITE for it, even though the natural thing would be to use DISCARD.

Besides, if your UI isn't slow, why try to optimise it? I'm sure there are more useful things you could spend your time on than optimising something that already works well.
sipickles
sipickles
Ok, I have this sorted in my head now.

I was using half a double sized VB each frame, with NOOVERWRITE. This has no advantage over DISCARD.

What I should have been doing is locking the first half of the normal sized VB with DISCARD, unlocking that, then locking the second half with NOOVERWRITE then unlocking that. This is the method used in particle systems.

Now to see if it works!

dave
dave
Out of curiosity, will ur vertex buffer never fill up?

Dave
Demus79
Demus79

According to the D3D sdk, the NOOVERWRITE flag is useful when you are filling just a little of vertex data. So this gives a hint that DISCARD flag is slightly more expensive.

I don't see any particular reason to have the size as double of the GUI size. Why no just make a buffer for let's say 4000-8000 vertices and use the NOOVERWRITE flag, and when it happens that the new vertices cannot fit anymore, just discard the buffer.

Best regards

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.