🔒 Locked
OpenGL performance question
Advertisement
Original Post
Hi guys: I am trying to test the performance of opengl on my computer. But some strange things happened. I have tried to draw n triangles and the fps keep at 60. but when I trying to draw 1 more ( which means n+1 triangles) the fps dropes to 45. I am not using texture mapping, extra light and display list, so I think this shouldn't be the problem of out of graphic memory. By the way , in the DX9 SDK there is some example, can draw more than 300,000 triangles and keep fps at 60, but I tried in opengl, max would be 80,000. does it mean opengl not that efficent under winodows?(I used Display list in this case) Anyone has any idea? Thanks
Yes, I think I disabled Vsync. But not that sure.
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
void setVSync(int interval=1)
{
const unsigned char *extensions = glGetString( GL_EXTENSIONS );
if( strstr( (const char *)extensions, "WGL_EXT_swap_control" ) == 0 )
return;
supported on your computer.\n");
else
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" );
if( wglSwapIntervalEXT )
wglSwapIntervalEXT(interval);
}
}
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
void setVSync(int interval=1)
{
const unsigned char *extensions = glGetString( GL_EXTENSIONS );
if( strstr( (const char *)extensions, "WGL_EXT_swap_control" ) == 0 )
return;
supported on your computer.\n");
else
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" );
if( wglSwapIntervalEXT )
wglSwapIntervalEXT(interval);
}
}
It seemed works, because now it dropes slower Thanks.
Would you like tell what is VSync? I just heard about it but do not have anyidea about it.
And why would DX9 can draw more than 250,000 triangles(It uses texture. In dx9sdk enhanced mesh example ) but in opengl I only can drap less then 800,000 triangles at 60fps?
Would you like tell what is VSync? I just heard about it but do not have anyidea about it.
And why would DX9 can draw more than 250,000 triangles(It uses texture. In dx9sdk enhanced mesh example ) but in opengl I only can drap less then 800,000 triangles at 60fps?
Hi,
vsync is the vertical synchronization of the displayed image on your monitor and the update on your graphics hardware.
Turning vsync off tells the graphics hardware : Show the images as fast as possible and don't synchronize with the refresh rate of the monitor.
If you turn the vsync on, the graphics hardware synchronizes the image output with the refresh rate of the monitor. If your monitor has a refresh rate of 70Hz then you would get 70 images from your graphics hardware. This implies that every display call stalls your whole computer because it waits until it can display the image.
I hope this helps.
And to be honest : I didn't quite understand your second question...
Best regards,
Metron
vsync is the vertical synchronization of the displayed image on your monitor and the update on your graphics hardware.
Turning vsync off tells the graphics hardware : Show the images as fast as possible and don't synchronize with the refresh rate of the monitor.
If you turn the vsync on, the graphics hardware synchronizes the image output with the refresh rate of the monitor. If your monitor has a refresh rate of 70Hz then you would get 70 images from your graphics hardware. This implies that every display call stalls your whole computer because it waits until it can display the image.
I hope this helps.
And to be honest : I didn't quite understand your second question...
Best regards,
Metron
it all depends on how you are drawing those triangles, post the code you use to setup and then call the Display lists and we should be able to point out the issue :)
Following is the display list code. Because 220 * 220 = 48400
thus there are 48400 quads and 48400 * 3 vertex.In this case fps keep at 60. And if I try 230*230 then fps drops. But in dx9 example, it draws 250,000 faces and still can keep at 60 fps.
void genList()
{
listName = glGenLists(1);
glNewList(listName, GL_COMPILE);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glBegin(GL_QUADS);
for(register int i = 0; i< 220; i++)
{
for(register int j = 0; j< 220; j++)
{
glNormal3f(0,0,1);
glVertex3f(-150 + i , -150 + j,-900);
glVertex3f(-150 + i , -149 + j,-900);
glVertex3f(-149 + i , -149 + j,-900);
glVertex3f(-149 + i , -150 + j,-900);
}
}
glEnd();
glEndList();
}
thus there are 48400 quads and 48400 * 3 vertex.In this case fps keep at 60. And if I try 230*230 then fps drops. But in dx9 example, it draws 250,000 faces and still can keep at 60 fps.
void genList()
{
listName = glGenLists(1);
glNewList(listName, GL_COMPILE);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glBegin(GL_QUADS);
for(register int i = 0; i< 220; i++)
{
for(register int j = 0; j< 220; j++)
{
glNormal3f(0,0,1);
glVertex3f(-150 + i , -150 + j,-900);
glVertex3f(-150 + i , -149 + j,-900);
glVertex3f(-149 + i , -149 + j,-900);
glVertex3f(-149 + i , -150 + j,-900);
}
}
glEnd();
glEndList();
}
That is most likely because of depth buffering. I would guess it is enabled in the DirectX example, but not this OpenGL example. The ZBuffer/Depth Buffer keeps track of what has already been drawn on the screen and how far into it. For example. Let's say you draw an opaque pixel 2 units deep "into" the screen at screen location 5,5. If you later try to draw another opaque pixel at the same location but 10 units deep "into" the screen, then your renderer can discard that pixel. That is because the original pixel should be drawn over it anyhow.
Now that means that if you draw a triangle in a certain spot and then draw 299,999 more triangles at the exact same spot - DirectX should be able to completely drop the other 299,999 triangles if ZBuffering is enabled. Thus since the other 299,999 triangles can be discarded, you get good performance.
Make sense?
Now that means that if you draw a triangle in a certain spot and then draw 299,999 more triangles at the exact same spot - DirectX should be able to completely drop the other 299,999 triangles if ZBuffering is enabled. Thus since the other 299,999 triangles can be discarded, you get good performance.
Make sense?
Quote:
Original post by wlb2001
Thanks for help me about this problem.
But unfortunate, All these QUADS are at same plan and the "eye" is at (0,0,0). Thus, no quads will overlap each other. So z-buffer test will not discard any QUAD in this case. :( And I already enabled GL_DEPTH_TEST.
Actually, you must set how the depth buffer handles incoming data.
In OpenGL:
glDepthFunc( type );
It can be one of:
GL_NEVER
Never passes.
GL_LESS
Passes if the incoming z value is less than the stored z value.
GL_EQUAL
Passes if the incoming z value is equal to the stored z value.
GL_LEQUAL
Passes if the incoming z value is less than or equal to the stored z value.
GL_GREATER
Passes if the incoming z value is greater than the stored z value.
GL_NOTEQUAL
Passes if the incoming z value is not equal to the stored z value.
GL_GEQUAL
Passes if the incoming z value is greater than or equal to the stored z value.
GL_ALWAYS
Always passes.
Immediate mode?
I think I am using dispaly list amn't I? Or may be display list call is also treated as immediate mode?
And by the way, I think when a display list has been compiled, all Opengl commands are stored in graphic memory and if I use vertex array, all commands are in the RAM, and when excution, these commands have to be send to graphic memory. Am I right?(I think not:))
I think I am using dispaly list amn't I? Or may be display list call is also treated as immediate mode?
And by the way, I think when a display list has been compiled, all Opengl commands are stored in graphic memory and if I use vertex array, all commands are in the RAM, and when excution, these commands have to be send to graphic memory. Am I right?(I think not:))
Quote:
Original post by wlb2001
Immediate mode?
I think I am using dispaly list amn't I? Or may be display list call is also treated as immediate mode?
And by the way, I think when a display list has been compiled, all Opengl commands are stored in graphic memory and if I use vertex array, all commands are in the RAM, and when excution, these commands have to be send to graphic memory. Am I right?(I think not:))
Nope, you're right. I did not notice you were generating a list at first. Assuming the depth buffer turns out not to be the issue ( IE - DirectX fails depth tests with equal depths ), could you simply post the complete code for each test?
I am also curious now what the problem is. I can assure you that OpenGL is not 4 times slower than DirectX though.
EDIT: Actually I'm going to head to bed soon. I will take a look at the source tommorow if nobody else has solved the problem yet.
>> I am trying to test the performance of opengl on my computer. But some strange things happened. I have tried to draw
n triangles and the fps keep at 60. but when I trying to draw 1 more ( which means n+1 triangles) the fps dropes to 45.<<
vsync
>> in the DX9 SDK there is some example, can draw more than 300,000 triangles and keep fps at 60, but I tried in opengl, max would be 80,000. does it mean opengl not that efficent under winodows?(I used Display list in this case)<<
youre comparing oranges with apples , thus its likely there will be a (large) difference between the two.
rewrite the d3d program (but use the equivilant opengl functions) and the differnce between the two will be less than 1%. d3d doesnt have anything like display lists so theyre ruled out for a start.
n triangles and the fps keep at 60. but when I trying to draw 1 more ( which means n+1 triangles) the fps dropes to 45.<<
vsync
>> in the DX9 SDK there is some example, can draw more than 300,000 triangles and keep fps at 60, but I tried in opengl, max would be 80,000. does it mean opengl not that efficent under winodows?(I used Display list in this case)<<
youre comparing oranges with apples , thus its likely there will be a (large) difference between the two.
rewrite the d3d program (but use the equivilant opengl functions) and the differnce between the two will be less than 1%. d3d doesnt have anything like display lists so theyre ruled out for a start.
dont put state change infomation in a DisplayList with vertex data, the driver has a much harder task of optermising the display list with the state change infomation in it.
Also, you're state changes are redundant, unless you change it again OpenGL will remember the cull state from the time it is first set and you certainly shouldnt relie on the idea that the driver will be smart enuff to catch double changes to the same value coz that just dont happen.
Also, you're state changes are redundant, unless you change it again OpenGL will remember the cull state from the time it is first set and you certainly shouldnt relie on the idea that the driver will be smart enuff to catch double changes to the same value coz that just dont happen.
Thanks for your guys help.
Actually I know I am comparing between "orange" and "apple".:) But it is still unexpected so large difference between them.
So you guys mean that under Windows system Opengl has almost same performance as DX9?
And one more question, If z-test may improve performance in overlapping case, so the drawing order should be from small z value to the large z value in eye coordinates system?(We do not consider blending and memory in this case).
Actually I know I am comparing between "orange" and "apple".:) But it is still unexpected so large difference between them.
So you guys mean that under Windows system Opengl has almost same performance as DX9?
And one more question, If z-test may improve performance in overlapping case, so the drawing order should be from small z value to the large z value in eye coordinates system?(We do not consider blending and memory in this case).
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement