PDA

View Full Version : Display list compilation speed



devdept
07-25-2008, 05:41 AM
Hi All,


Today's question is: what's wrong with the code below?

Looks fine, isn't it? Who can explain why it takes

200 ms on a NVidia Quadro 3700

and

20 ms on a ATI FireGL V5600


They are both recent graphics cards.


Thanks in adavance,


Alberto




if (drawList == 0)
drawList = glGenLists(1);

glNewList(drawList, gl.COMPILE);

glBegin(gl.TRIANGLES);

foreach (Triangle mt in triangleList)
{

glMaterialfv(gl.FRONT_AND_BACK, gl.DIFFUSE, new float[] { 1,0,0,1 });

glNormal3d(normals[mt.no1].x, normals[mt.no1].y, normals[mt.no1].z);

glVertex3d(vertices[mt.v1].x, vertices[mt.v1].y, vertices[mt.v1].z);


gl.Materialfv(gl.FRONT_AND_BACK, gl.DIFFUSE, new float[] { 1,0,0,1 });

glNormal3d(normals[mt.no2].x, normals[mt.no2].y, normals[mt.no2].z);

glVertex3d(vertices[mt.v2].x, vertices[mt.v2].y, vertices[mt.v2].z);


glMaterialfv(gl.FRONT_AND_BACK, gl.DIFFUSE, new float[] { 1,0,0,1 });

gl.Normal3d(normals[mt.no3].x, normals[mt.no3].y, normals[mt.no3].z);

glVertex3d(vertices[mt.v3].x, vertices[mt.v3].y, vertices[mt.v3].z);

}

glEnd();

glEndList();

oc2k1
07-25-2008, 06:00 AM
Maybe you shouldn't call glMaterialfv between glBegin and glEnd. Check errors for GL_INVALID_OPERATION...

dletozeun
07-25-2008, 06:08 AM
Yes maybe it is a bit long on one card a faster on another, you can't do the comparison...
then, it would be faster if you were not specifying material at each vertex.
You should group all primitives that have the same material and call glMaterial once per promitive.

Then, even if this is still long, display lists compilation is not expected to be done each frame... If you have dynamic objects use vbo instead.

Komat
07-25-2008, 06:08 AM
Looks fine, isn't it? Who can explain why it takes
200 ms on a NVidia Quadro 3700
and
20 ms on a ATI FireGL V5600

Maybe the Nvidia driver attempts to optimize the list more thoroughly than the ATI one.



Maybe you shouldn't call glMaterialfv between glBegin and glEnd.

glMaterial is one from operations which is explicitly allowed between glBegin and glEnd.

devdept
07-25-2008, 06:37 AM
In reality, this code belong mostly on the GPU or CPU ?

Komat
07-25-2008, 06:54 AM
CPU

devdept
07-25-2008, 07:21 AM
Really,

So the graphics card performance doesn't affect this timing?

Thanks,

Alberto

dletozeun
07-25-2008, 07:38 AM
No, as Komat said, this is the driver that compile the display list, so all is performed on CPU.

Jan
07-25-2008, 08:37 AM
AFAIK vendors discourage you to use glMaterial AT ALL. Don't know why, though, i never used it anyway.

devdept
07-25-2008, 02:29 PM
It remains to demonstrate why with two almost equal machines we get such a 10x difference in display list compilation if only the CPU is involved...

Maybe pushing the compiled display list to the GPU can take a different amount of time.

Thanks,

Alberto

dletozeun
07-25-2008, 02:37 PM
You have test it on 2 differents graphic cards, 2 different drivers, ATI and nvidia ones. How could you expect to see the same performances!?

Although, compiling display list as nothing to do with GPU, this is just a precomputation to avoid useless driver calls nothing more.
Can you explain us why are you making such a big deal with a such insignificant thing? :eek:

Zengar
07-25-2008, 04:09 PM
If you only need diffuse, use glColor and glColorMaterial. The material properties AFAIK are not per-vertex attributes, I don't know how the driver get's around this problem, but it is not really important in this case. Nvidia drivers are known to perform better DL optimization then ATI ones, maybe this explains the performance difference.

devdept
07-26-2008, 03:03 PM
Thanks to you all guys, I understand all your point of view.

The point is that a customer is trying to give back a new NVIDIA based DELL machine because it is slower to compile DL than their very old ATI based one.

They asked us why we optimize our code for ATI only and wanted to be sure to have done all the best for both graphic card drivers.


Thanks again,

Alberto

Zengar
07-26-2008, 03:22 PM
Then I have another suggestion: don't use display lists. Use VBOs instead.

devdept
07-26-2008, 03:27 PM
Hi Zengar,

Never used that before, do you know a good kick start tutorial on the internet?

Where they supported in OpenGL 1.1?

Thanks,

Alberto

Zengar
07-26-2008, 03:46 PM
I don't know any tutorials but you find one soon if you google. VBOs are basically server-side vertex arrays. They were introduces several years ago, went into the core in GL 1.5 (if I remember corectly) and are suported on any reasonably new hardware.

devdept
07-26-2008, 03:56 PM
One last question Zengar,

Are they faster than display list? What are pros and cons comparing the two?

Thanks,

Alberto

V-man
07-26-2008, 04:16 PM
VBO and display list should give about the same performance.
The other think I noticed is that you use double instead of float.
Read this
http://www.opengl.org/wiki/index.php/Common_Mistakes#Unsupported_formats_.231

devdept
07-26-2008, 04:46 PM
Thanks V-man,

I will print this and read it carefully.