Vertex Buffer structure

Started by
2 comments, last by mattnewport 19 years ago
Hi. I cant remember where i heard this but anyway. If i have the following index buffer 0, 200, 400, all of the vertices between 0 and 400 will be transformed. Is this true? if so is it a good idea to try and keep the difference between indexes as small as possible by aranging the vertex buffer accordingly. So one doesnt transform unwanted vertices. I ask this because in my terrain engine i store my vertices in the same way i store my heightmap, a 2d array. If my worries are correct i am doing millions of unnecessary transforms. Also, are the vertices in the graphics card memory accessed by reference or by value? Can i point to other vertices? Thank you
--------------------------------Dr Cox: "People are ***tard coated ***tards with ***tard filling."
Advertisement
hi,

I don't think ALL the vertices will be transformed.

I think that there's a certain amount of cache in the graphic card, and when transforming vertex 1, the card may transform the following vertices (it loads the 1 vertex and the following ones in one cache update) that fit in the cache. So by using indexes like 1, 200, 400, you might do some unnecessary transform, but I don't think I would be that bad, compared to the problem cost of re-organizing your vertex buffers each frame.

But in a general way, it's a good point to "cache-optimize" the vertex buffer which means, organize your VB so that the vertex are stored in the order they are used by the IB.

Just my 2 cents (just discovered this expression last week ^^)


.:: Paic Citron ::.
Just a random stab in the dark (hope i dont get anyone) but wont this just use vertices o, 200 and 400?

ace
That's partially true for software vertex processing (where the vertices are transformed on the CPU rather than the GPU) but not for hardware vertex processing.

I say partially because what actually happens with software vertex processing is that in a single draw call, every vertex between the lowest and highest indices referenced in the call will be transformed once, regardless of whether that vertex is referenced by any actual triangles. In your example of a heightmap that's not a problem if you render the whole thing in one go since every vertex has to be transformed anyway but it is a problem if you render small rectangular subregions of the heightmap since for each row of the heightmap the subregion crosses you will have to transform the entire row. If you are only targeting hardware vertex processing you don't have to worry though, the GPU will only transform vertices that are actually referenced in the index buffer.

Game Programming Blog: www.mattnewport.com/blog

This topic is closed to new replies.

Advertisement