Display list compilation speed

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();

Maybe you shouldn’t call glMaterialfv between glBegin and glEnd. Check errors for GL_INVALID_OPERATION…

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.

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

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

In reality, this code belong mostly on the GPU or CPU ?

CPU

Really,

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

Thanks,

Alberto

No, as Komat said, this is the driver that compile the display list, so all is performed on CPU.

AFAIK vendors discourage you to use glMaterial AT ALL. Don’t know why, though, i never used it anyway.

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

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:

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.

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

Then I have another suggestion: don’t use display lists. Use VBOs instead.

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

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.

One last question Zengar,

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

Thanks,

Alberto

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

Thanks V-man,

I will print this and read it carefully.