why lock Vertex buffers?

Started by
5 comments, last by Dwiel 22 years, 1 month ago
My question is very basic.... I want to say, edit a few of the verticies in my VB, now why do I need to call the VB->lock and VB->unlock ? Why cant I just acces the VB directly? Also what would be the easiest way to change for ex. just one vertex in the Buffer? Thanx SOOOOOOOOOOOOOOOOO much for the help.... Zach Dwiel
Advertisement
It may not be stored in system mem. So the locking process copies it to system ram.
Also, the lock/unlock process lets the card know it can precompute vertex transforms so it can do less work later. That way processing is done only when things change, not every time vertexes are displayed.
locking the vertex buffer IS accessing the vertex buffer directly. The act of locking it gives you a pointer to the vertex buffer memory... and unlocking it gives the pointer back. This gives DX the freedom to do lots of things you can't see... like changing where the vertex buffer is located in memory, buffering that vertex memory (a common case), etc. It also protects the system from concurrency conflicts (you trying to write to the buffer while DX is trying to render from it... imagine the mess :o )

But anonymous... I don't think there's any precomputing of vertex transforms... that doesn't happen till you start pushing triangles.

[edited by - sorrow on March 19, 2002 12:51:30 PM]
unless you''re talking about vertex caching, but it doesn''t sound like it.
i have heard that locking and unlocking the VB is a slow proccess, and if I wanted to change one vertex, then I would still have to use this prosecc?

Well... unhappy news but thatnx for info!!

Tazzel3d ~ Zach Dwiel
quote:Original post by Sorrow


But anonymous... I don''t think there''s any precomputing of vertex transforms... that doesn''t happen till you start pushing triangles.



If you''re rendering the same stuff every frame, and directX knows this, then it doesn''t have to recompute some of the math every frame.

At least, if the underlying drivers have been written to take advantage it''ll do that.

This topic is closed to new replies.

Advertisement