Skip to main content
gamedev.net
🔒 Locked

Reading from managed buffer

Started by dietepiet Mar 6, 2009 at 5:39 AM 1 replies 650+ views
Original Post
dietepiet
dietepiet
Hi all, I use a static vertex/index buffer(DX9), but once in a while, I need the vertex data on the CPU for calculations (decal generation etc.). Now, it is in general adviced to use the D3DUSAGE_WRITEONLY as it would be faster. Also, locking would be expencive. When creating a static buffer with the D3DPOOL_MANAGED flag, i understood that directX will always keep a copy in system memory. So, I was thinking, why would locking such a buffer for reading cause a performance penalty? DirectX could simply pass me the pointer to the system memory because I promised not to change the content. I am asking, because it would be a waste of system memory to store the vertex data one extra time, if directX already has a system copy somewhere. So, if it does not reduce the performance, i rather just read from this copy. Regards, Dietger
Evil Steve
Evil Steve
Quote:
Original post by dietepiet
Hi all,

I use a static vertex/index buffer(DX9), but once in a while, I need the vertex data on the CPU for calculations (decal generation etc.).
Now, it is in general adviced to use the D3DUSAGE_WRITEONLY as it would be faster. Also, locking would be expencive.

When creating a static buffer with the D3DPOOL_MANAGED flag, i understood that directX will always keep a copy in system memory. So, I was thinking, why would locking such a buffer for reading cause a performance penalty? DirectX could simply pass me the pointer to the system memory because I promised not to change the content.

I am asking, because it would be a waste of system memory to store the vertex data one extra time, if directX already has a system copy somewhere. So, if it does not reduce the performance, i rather just read from this copy.

Regards,
Dietger
The performance penalty is only for buffers in D3DPOOL_DEFAULT as far as I understand. Although the managed pool might do something else under the hood if you create it with D3DUSAGE_WRITEONLY.
dietepiet
dietepiet
Thanx, that was what i assumed. Of course I would not use the D3DUSAGE_WRITEONLY if I was going to read from the buffer. The DX documentation says:

Quote:

Buffers created with D3DPOOL_DEFAULT that do not specify D3DUSAGE_WRITEONLY might suffer a severe performance penalty.


Altough the inverse is not necessarily true, I assume that not specifiing D3DUSAGE_WRITEONLY for D3DPOOL_MANAGED will not give a 'severe performance penalty'.

Topic Locked

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

Sign in to reply to this topic.