PDA

View Full Version : More than 60K triangles per second?



Cwhizard
05-24-2017, 01:13 AM
I am using the following code , which is slightly modified from the Code::Blocks opengl default project. The problem Im having is that I cant get more than 1000 triangles without falling below 60 fps. I'm not sure what the triangles per second rating is, as radeon doesn't specify for the 200, only 230 and up, but I'm sure 60K is very low. I think my VooDoo5 can do more than that. So I'm assuming I'm not optimizing the code right or something. please help :)



glBegin(GL_TRIANGLES);


for(int z = 0;z<1000 ;z++){
//x = (rand() % 1000)/50 - 1.0f;
//y = (rand() % 100)/50 - 1.0f;

glColor3f(1.0f, 0.0f, 0.0f); glVertex3f((float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex3f((float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex3f((float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f,(float)(rand() % 1000)/500.0f - 1.0f);

}//*/

theta += 0.1f;
glEnd();

mhagain
05-24-2017, 01:41 AM
Two things:

1) glBegin/glEnd code is slow; it will never be able to achieve full triangle throughput.

2) Triangle count isn't the only arbiter of performance. Depending on the size of those triangles you may well end up being fillrate-bound. If you wish to measure triangle count in isolation then you should draw them as small as possible (or not draw them at all).

GClements
05-24-2017, 06:07 AM
If you want performance, you should be using glDrawArrays/glDrawElements/etc with the data in VBOs.

Using glBegin/glEnd means half a dozen function calls per triangle. The GPU is spending 1% of its time actually working and the the other 99% waiting for the CPU to send it more data.

Dark Photon
05-24-2017, 07:04 AM
Cwhizard, once you rework your drawing to use glDraw* and VBOs, there's lots more you can do if you still need more performance. The goal becomes minimizing the number of state changes and draw calls, and reducing the CPU time spent per draw. Lots of interesting techniques to learn here when you're ready.

Cwhizard
05-24-2017, 12:42 PM
Two things:

1) glBegin/glEnd code is slow; it will never be able to achieve full triangle throughput.

2) Triangle count isn't the only arbiter of performance. Depending on the size of those triangles you may well end up being fillrate-bound. If you wish to measure triangle count in isolation then you should draw them as small as possible (or not draw them at all).

Fillrate was an issue. making them smaller increased the TPS to 1.2M+. I tried to upload a screenshot, but all 3 methods, including posting a link, failed.




for(int z = 0;z<20000 ;z++){
float x = (float)(rand() % 1000)/600.0f - 0.9f;
float y = (float)(rand() % 1000)/600.0f - 0.9f;

glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(x,y,(x+y)/2.0f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(x+0.1f,y,(x+y)/2.0f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(x,y+0.1f,(x+y)/2.0f);

}//*/

larryl
05-25-2017, 12:20 AM
I tried to upload a screenshot, but all 3 methods, including posting a link, failed.

I've tried everything to post screenshots I could think of, including links to images uploaded to Imgur and Gyazo, with no luck.

The only thing that seems to work was uploading them to my web site. A link to those images displayed properly.

I'm interested in knowing of another way to post an image.

Dark Photon
05-25-2017, 06:07 AM
Just post the URL with a space or two in/after the http:// and we'll fix up the link for you.

Cwhizard
05-25-2017, 11:17 AM
Just post the URL with a space or two in/after the *snip* and we'll fix up the link for you.

It is literally denying even posting the url if http is removed. So I dont know It's still denying me. Here it is without the hypertext transport protocol thingy:

http://steamcommunity.com/sharedfiles/filedetails/?id=932086498

Cwhizard
05-25-2017, 11:19 AM
I think perhaps myu account may not have permissions?

Dark Photon
05-26-2017, 06:38 AM
Ok. I fixed up your URL for you above. Next time just put some spaces in the URL (and make a comment about removing the spaces).

Sorry for the inconvenience. For spam prevention, new users can't post URLs until they have a certain small number of posts under-their-belt. It won't be long and you should be able to post URLs.