GFXBufferTypeDynamic questions
by Tom Spilman · in Torque Game Engine Advanced · 09/03/2005 (2:50 pm) · 3 replies
I'm looking at one of the bounties and i've noticed that GFXBufferTypeDynamic seems to be unsupported for vertex buffers at the moment. In the past any particle systems would use dynamic buffers with discarded locking. Is this a temporary thing or is there another recommended way to do this now?
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
#2
Under the hood the volitile buffer is just a dynamic VB... so i guess it's just as good. The only limitation is that you cannot have more than 8192 verts in a volitile buffer. I guess i could change my usage from stuffing everything into one buffer into two seperate volitile VB allocations in order to allow for more verts.
Also I went ahead and quickly fixed the dynamic VB stuff and was really surprised to see that the performance seemed no different than using a static VB. Most likely there is another bottleneck that was keeping that from appearing as a problem.
09/03/2005 (7:17 pm)
Yea i looked that the volitile type for a bit. It seems to just pull them out of a pool as needed and as long as you don't ask for volitile buffer while your still using the last one you're good.Under the hood the volitile buffer is just a dynamic VB... so i guess it's just as good. The only limitation is that you cannot have more than 8192 verts in a volitile buffer. I guess i could change my usage from stuffing everything into one buffer into two seperate volitile VB allocations in order to allow for more verts.
Also I went ahead and quickly fixed the dynamic VB stuff and was really surprised to see that the performance seemed no different than using a static VB. Most likely there is another bottleneck that was keeping that from appearing as a problem.
#3
I did notice that MAX_DYNAMIC_VERTS is defined in gfxD3DDevice.h ... it would be nice if there was a MAX_VOLATILE_VERTS defined in a common header.
09/03/2005 (8:30 pm)
FYI. I switch over to a volatile buffer. I create one at 8000 verts, start filling it, once it's filled i render it out, and go back to filling the buffer. This seems to perform a bit better than a single 28,000 vert buffer even though i have to do a few more drawprims. It's also probably a bit more scalable and i think tunable. I seem to remember there was a sweet spot for VB/drawprim size.I did notice that MAX_DYNAMIC_VERTS is defined in gfxD3DDevice.h ... it would be nice if there was a MAX_VOLATILE_VERTS defined in a common header.
Torque 3D Owner Pat Wilson
I think that there was a little dance done with the naming of "dynamic" versus "volitile". Volitile vertex buffers are named as such because there is no assurance that buffer will be good as soon as you go out of scope...or any time, really, if you don't be careful doing multi-threading. Anyway, a volitile is a chunk of a larger vertex buffer that gets locked with a 'no overwrite' flag and it will get discarded when the buffer fills up and start at index 0 again.
There is a (I think) 2000 ct vertex buffer for each vertex type which is allocated when GFXD3D is initialized. If you request a volitile vertex buffer of size 15 and type PCT (for example). It will check to see if n (current-index) + 15 (size of requested buffer) > 2000, if so, it will clear that vertex buffer, and lock 0-14 and pass that back to you. Otherwise it will lock n-(n+15) for you, and increment n by 15.
I think it does what you want to, but you were just thrown by the dynamic vs volitile thing. I know I was when vertex buffers got re-written from the original implementation. If this isn't what you mean, post and I'll try to answer as best I can.