Jump to content
  • Advertisement
Sign in to follow this  
SparkyFlooner

What's the point of D3DUSAGE_WRITEONLY

This topic is 4828 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'm not sure what it means to 'read from the vertex buffer.' I create a vertex buffer with the attribute D3DUSAGE_WRITEONLY. If I lock the vertex buffer, the pointer is initialized with the data inside the buffer. That implies a read. I assumed garbage would have been returned instead. I'm obviously missing something.

Share this post


Link to post
Share on other sites
Advertisement
When you specify the write only flag, you give d3d a permission to place the memory in a place where it may not be available to read from. This does not mean that it is required to make it write-only, though - but if you requested it, you can't assume that you can read from the buffer then.

The buses involved in a graphics system are usually much faster in uploading (writing) than in downloading (reading) from the card. This is why it is beneficial to hint d3d about the intended usage of the data, so it can allocate the memory from the most suitable place. Write only static buffers are likely to be allocated in video memory, so that the performance is as high as possible when rendering the data.

Share this post


Link to post
Share on other sites
So far, the only way I know to read from a buffer involves locking the buffer and receiving a pointer to its contents. The documentation hints that when using WRITEONLY, reads shouldn't just 'maybe return buffer data or not'..but that it should be an error. (evil documentation. it's awful)

Using WRITEONLY, the documentation hints that it allows the driver to store the data in the most effecient way. So when you lock the buffer, it has to transfer the data to the storage structures that you used...

Aside from locking the buffer, what other way exists to read the memory?

Share this post


Link to post
Share on other sites
None. Lock is the only way to read a buffer on the CPU.

WRITEONLY allows (not forces) the card to use video memory, rather than AGP memory, which is faster for the card to access. Some cards may return valid data when you attempt to read the locked data, but you cannot rely on it. Other cards, or even the same card with a different driver may return invalid data. Reading from a WRITEONLY buffer, while it may work, is an error... just not one that throws up a big assert box.

If you use a MANAGED buffer, D3D keeps a system memory copy around anyway for device loss management, and you can likely read it. If you use a DEFAULT buffer, the odds are higher that a read attempt is going to fail.

Share this post


Link to post
Share on other sites
Thanks, that clears it up pretty well. So basically if I specify WRITEONLY, I should assume the pointer points to garbage even if it doesn't look like garbage. Gotcha.


Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!