Skip to main content
gamedev.net
🔒 Locked

Performance question

Started by tSG 4 replies 350+ views
Original Post
tSG
tSG
Hey, ad1. I''m wondering if you could show me the difference of the speed of a Display list, a vertex buffer and a locked vertex buffer. Which one is the fastest? Have you ever made any tests? Results? ad2. Is it possible to call glDrawElements with such an indexbuffer which is made from the c++ template class called std::vector<>? Is it guaranteed that it will work everywhere? If I know it correctly std::vector can result memory areas which aren''t continuous. And that''s not good for opengl. But what about if I make the vector with .resize() which allocates a continuous memory-area (in theory) for the vector? Thanks in advance -- tSG --
-- tSG --
Obelix
Obelix
What does ad1 and ad2 means?
Vertex buffer is used in Direct3D and OpenGL has vertex arrays. If you mix the terms can it be difficult to know what things like "locked vertex buffer" are referring to. The speed depends on the driver check out the manufacturers page for information. For example do I think that nvidias vertex arrays extension is the fastest on a GeForce.

I do not see the point in using STL vectors for this. You probably do not want to sort the array...
What is the disadvantage of using "raw" arrays?
Check the specification (not the implementation) for STL if you really want this.
Bad Monkey
Bad Monkey
I have used STL vectors frequently as vertex/normal/texcoord/index arrays and they have worked just fine. You can pass them like so:

glVertexPointer(..., &myVector[0]);

I believe (correct me if I''m wrong) that it is actually specified that an STL vector must be composed of a contiguous block of memory (hence the performance cost when adding more elements than the vector has room for... a new larger block must be allocated, and the current values copied over).
nitzan
nitzan
check out this article,
It should give you all the answers you seek.

http://developer.nvidia.com/view.asp?IO=ogl_performance_faq

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
tSG
tSG
obelix: sorry, I thought it is an english word. But never mind. It was just a enumeration.
Secondly I wanted to use STL vectors because then I don''t have to care about the size of the arrays...
Btw. sorry for the vertex-buffer but I used directx so far and remembered the wrong expression

Bad Monkey: yes, that''s my problem too. I am not absolutely sure that it must work that way...

nitzan: thanks for the link, it must be very interresting!


-- tSG --
-- tSG --
Bad Monkey
Bad Monkey
I meant to edit my post with more info last night, but stoopid Optus Cable in Oz lost the connection to America... again >:|

Anyho, I went and did some looking around... this little bit of info may help you rest easier

Also You can overcome the performance hit somewhat if you have a fair idea how many elements you may want to store... then you can call reserve(...) to allocate the space for them prior to using push_back(...) etc

Plus, you can set the number of extra element spaces it will allocate when it does happen to overflow the current space (e.g. get it to allocate space for 20 more vertices instead of 1 when it must resize itself) ... can''t remember exactly what the function call is off hand.

Hope that helps

Topic Locked

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

Sign in to reply to this topic.