Archived

This topic is now archived and is closed to further replies.

MorTyR

Help with Vertex Arrays, CVA'S, GL_ATI_vertex_array_object

Recommended Posts

Hi...I need some advice regarding a few issues. I''m a newbie at this, so bare with me... I''m using opengl in c++. This is in my brother''s Pc, a Duron 800 mhz with a Radeon 8500. I''ve done a cloth demo a few days ago and started coding my first terrain demo. So far so good, everything''s working fine, except performance. I''m basically rendering a 128*128 vertex grid. So that gives me about 127*127*2 triangles=32258 triangles. My problem is this. At first i was only using imediat mode just to make sure everything was loading fine, and i had my heightmap values correctly (i do scaling and repositioning when i create the vertex array). Now , this is what i found out. Not using any kind of frustum culling, just tossin all those 32k triangles to the card in imediate mode (with single texturing, no lighting), i was getting: 85 fps using GL_TRIANGLES 110 fps using GL_QUADS So i thought that with vertex arrays things would go faster. I normally use interleaved arrays, but as i was going to use multitexture, i would have 2 texture coord arrays, therefore to make things easier and cleaner i made everything in separate arrays. And as i never used indexed arrays, i wanted to try them, so... So i created a VertexArray with all the coord of all the vertex in the heightmap, and a IndexArray with the indices for each triangle. When rendering , i got ..45 fps..... :[ Then i tried CVA''s, i now it''s only good for multiple passes, but what the heck...i gained about 5 fps... Then i started thinking..I''m sending all the data to the card each frame, right...SO what if i placed the data on vid mem?... Since then i''ve read just about everything i could find about that, including several (and do mean SEVERAL) messages in many many foruns. So i learned about VAR''s and NV extensions..But i have a Radeon 8500, therefore i can not use VAR nor fences. Finally i learned about GL_ATI_vertex_array_object and GL_ATI_element_array. So i tried using them.I finally got them working. The problem is...the performance stays the same..... :[ So let me be more detailed, after i create the arrays i make: arrayObjectID=glNewObjectBufferATI(sizeof(VertexArray2),VertexArray2,(GLenum)GL_STATIC_ATI); if (!glIsObjectBufferATI(arrayObjectID )){ DB::write ("\n\n VERTEX ARRAY NOT PLACED IN VID MEM!!! \n\n"); }; IarrayObjectID=glNewObjectBufferATI(sizeof(IndexArray ),IndexArray ,(GLenum)GL_STATIC_ATI); if (!glIsObjectBufferATI(IarrayObjectID )){ DB::write ("\n\n INDEX ARRAY NOT PLACED IN VID MEM!!! \n\n"); }; this DB::write is for my debug function, and for what i see, thee are no problems at this point. during rendering i do: glEnableClientState ((GLenum)GL_ELEMENT_ARRAY_ATI); glEnableClientState(GL_VERTEX_ARRAY); glArrayObjectATI(GL_VERTEX_ARRAY,3, GL_FLOAT, sizeof(Vertex3f), arrayObjectID,0 ); glArrayObjectATI((GLenum)GL_ELEMENT_ARRAY_ATI,1, GL_FLOAT, sizeof(unsigned int), IarrayObjectID, 0); glDrawElements(GL_TRIANGLES,MAP_SIZE*MAP_SIZE*6,GL_UNSIGNED_INT, IndexArray); /*or glDrawElementArrayATI(GL_TRIANGLES,MAP_SIZE*MAP_SIZE*6); if using index in ATI object buffer */ The thing is..when using glArrayObjectATI instead of the regular glVertexPointer , i get the same 45 fps. Isnt it suposed to use the values i stored before in vid card mem? therefore making it faster? Now if i want to use the index values i placed in the object buffer, i have to use glDrawElementArrayATI. Now there''s another problem, because although i DO have the GL_ATI_element_array extension, its functions ARE NOT loaded..therefore i cannot use this command (i tried, it does not render anything...). So, what i needed was...Am i using ATI object buffer correctly? If so, why is the performance the same as using the regular vertex array? If not....what''s wrong? i error check the buffer and it says it''s fine... Is there any other way to render this in a fast way? I mean... 32 K tris is....should be...easy for a Radeon 8500...I know it''s not a fillrate issue, cause I''ve rendered in 80*80 and it kept the 45 fps. Also..what''s wrong with the GL_ATI_element_array? It exists, i suport it (i write the GL_EXTENSIONS to the debug file and it''s there, i check for it in the program, it''s there, but the functions don''t work), but the functions are not loaded. if(strstr(glExtensions, "GL_ATI_element_array")){ DB::write("ATI Element Array Exists\n"); glElementPointerATI= (PFNGLELEMENTPOINTERATIPROC) wglGetProcAddress("glElementPointerATI"); glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC) wglGetProcAddress("glDrawElementArrayATI"); glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC) wglGetProcAddress("glDrawRangeElementArrayATI"); if(!glElementPointerATI || !glDrawElementArrayATI || !glDrawRangeElementArrayATI);{ DB::write("\nError Activating ATI Element Array Functions !!!\n"); }; }; Anyone? Sorry for the big post and i hope you don''t mind helping a newbie.. MorTyR

Share this post


Link to post
Share on other sites
Ok..forget it..i fixed it.....

I was trying diferent things, and remembered to place the textcoord in vid mem too.

So i did, and ..voilá..I''m getting 60-200 fps depending on the geometry I''m looking at....

Incredibly enough, glDrawElementArrayATI is working, even though after i load it, i test it, and it doesn''t exist..oh welll

So...Everything was down to a crawl just beacause of the text coord....

weird....

Anyway..Extensions rock...I only wish somebody makes a extension to put data on vid mem that works on ALL cards for a change...

Share this post


Link to post
Share on other sites
Also, glDrawElementArrayATI is MUCH faster than glDrawElements under lower poly conditions...in my case, its TWICE as fast...Worse case cenary,under high poly scenes, its as fast as your regular glDrawElements.

glDraw VS glDrawATI (low poly)
160 fps VS 300 fps

glDraw VS glDrawATI (high poly)
85 fps VS 85 fps

Now i have to make it work with VAR''s for ppl with NVIDIA cards...

Share this post


Link to post
Share on other sites