Skip to main content
gamedev.net
🔒 Locked

VBO performance

Started by fear4ever 6 replies 1.7k views
Original Post
fear4ever
fear4ever
Hi all, I am experimenting with VBO's to see if it can help me speed up my app. I use a triangle fan with 8 triangles and draw it for 1000 times each frame. I get the same fps whether i use VBO or just use glVertex3f. So my question is, is it the way i use the VBO that causes no improvement in fps or are VBO's not suitable for ~10 vertices of data?

GLfloat data[] = {0.0f, 0.0f, 0.0f, 
		1.0f, 1.0f, 0.0f,
		0.0f, 1.0f, 0.0f,
		-1.0f, 1.0f, 0.0f,
		-1.0f, 0.0f, 0.0f,
		-1.0f, -1.0f, 0.0f,
		0.0f, -1.0f, 0.0f,
		1.0f, -1.0f, 0.0f,
		1.0f, 0.0f, 0.0f,
		1.0f, 1.0f, 0.0f };



int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();									// Reset The View
	glTranslatef(0.0f,1.0f,z);

	glRotatef(xrot,1.0f,0.0f,0.0f);
	glRotatef(yrot,0.0f,1.0f,0.0f);

	if( GetTickCount() - g_dwLastFPS >= 1000 )					// When A Second Has Passed...
	{
		g_dwLastFPS = GetTickCount();							// Update Our Time Variable
		g_nFPS = g_nFrames;										// Save The FPS
		g_nFrames = 0;
	//	sprintf(title,"triangles= %d fps=%d throughput:%.2g MT/s vbo=%d",triangles,g_nFPS,(float)g_nFPS*triangles/1000000,vbo);
		sprintf(title,"fps=%d",g_nFPS);
		SetWindowText( hWnd, title );	
	}


	
	g_nFrames++;
	triangles=0;
	
	if(vbo)
	{
		for(int i=0;i<1000;i++)
		{
			glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);	
			glVertexPointer(3, GL_FLOAT, 0, 0);	
			glDrawArrays(GL_TRIANGLE_FAN, 0, 10);
		}
	}
	else
	{	
		for(int i=0;i<1000;i++)
		{
			glBegin(GL_TRIANGLE_FAN);
				for(int i=0;i<3*10;i+=3)
					glVertex3f(data,data[i+1],data[i+2]);
			glEnd();
		}
	}
	triangles+=8;

	xrot+=xspeed;
	yrot+=yspeed;
	return TRUE;										// Keep Going
}


fear4ever
fear4ever
I am already drawing 8k triangles/frame
ff8
ff8
the performance (or FPS) isn't linear(function) so small increasing u won't notice the differnt only when u have large data size .
search on the forums i remeber there was post about FPS
take care.
Taharez
Taharez
Quote:
Original post by fear4ever
I am already drawing 8k triangles/frame


Yes, but only 8 at a time, so the overhead of VBO and glVertex-calls is probably pretty similar. If you hade 8k tris in a single VBO and rendered that with one call vs glVertex in a loop, that'd most likely give you a bigger difference
fear4ever
fear4ever
Quote:
Original post by Taharez
Quote:
Original post by fear4ever
I am already drawing 8k triangles/frame


Yes, but only 8 at a time, so the overhead of VBO and glVertex-calls is probably pretty similar. If you hade 8k tris in a single VBO and rendered that with one call vs glVertex in a loop, that'd most likely give you a bigger difference


Yes that is what i have been asking about. My application has a large datum but it is drawn with numerous small triangle fans. Also these fans are dynamic (losing some vertices or regaining them in runtime). So in that case should i stick to immediate mode? Is there still a way to improve performance here?

For anyone interested, i am drawing a large terrain with dynamic lod.

_the_phantom_
_the_phantom_
how often does the data set change?
Can it be segmented into groups which tend to change together?
Can you use a better triangle layout? (fans aren't great, indexed lists or strips would be better)
Fingers_
Fingers_
When you say losing and regaining vertices, do you mean that the locations of the vertices change or only that a given vertex may or may not be used by any of the triangles? In the latter case you could statically store all the vertices, and only the index buffer needs to be dynamic.

Topic Locked

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

Sign in to reply to this topic.