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

Reading from vertex buffer writeonly/discard

Started by dansteph Jan 7, 2002 at 4:06 PM 2 replies 400+ views
Original Post
dansteph
dansteph
This is probably a dumb question but I need to be sure not to make design mistake. (pseudo code example,notice that it actually work on tnt2) VB = WRITEONLY | POOL DEFAULT VB->Lock(&Myvertice, DISCARD) Myvertice.p.x*=10; Myvertice.p.Z*=10; if(Myvertice.p.Y>10.0f) Myvertice.p.Y=10.0f; VB->Unlock -this code READ from vertex buffer or did I miss something ? so its considering to be bad ? -does this code also work on hardware T&L ? -If it read I should more locking it at load time to get the value and maintain my hown array in sysmem that will be modified and memcopied at each lock during runtime ? I do this cause I load a mesh that I modify each frame the value (moving terrain) Many Thanks Dan
JonStelly
JonStelly
That MAY work on SOME cards / drivers, but I would almost guarantee that it won''t work on MOST cards / drivers. You can read from a vertex and index buffers allocated in D3DPOOL_DEFAULT.

Specifying D3DUSAGE_WRITEONLY encourages the driver to place the VB in the optimal place for WRITING, so even if technically, on one card with a given set of drivers you can read from a WRITEONLY VB, it may be slower than if you hadn''t specified WRITEONLY, and it will likely only work in that one scenario of card / driver.
dansteph
dansteph
this code work find at least on tnt2 ati rage pro and voodoo2
but after writing the question I realised this WAS a dumb question. Of course it''s reading and it''s considered to be bad.

I will keep a copy of the data in sysmem and actualise each frame with fresh data and Discard...
Sometime the doc isn''t very clear so imagine when your a non english reader :-)

Thanks for the reply

Dan
JonStelly
JonStelly
That sounds like a good idea. If I had a nickel for every time I misread something from MSDN, I would be a very rich man. And English IS my native language. =)

Topic Locked

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

Sign in to reply to this topic.