Hi! I created a patch for bug #6758 which first only should have fixed a bug where we were not conform with the OpenGL specs and thus hit an assert in the xf86-video-ati driver's DRI implementation. (The crash is a bug in the driver.)
Basically it comes down to this: You are not allowed to call glLoadEntity() inside a glBegin()/glEnd() block to which glNewList()/glEndList() also counts. (A GL list is a precompiled (by the driver) list of OpenGL operations which is used to speedup rendering.) Now comes the interesting part: When I removed the list from that code and rendered the shadows 2 times (instead of one time into the list and then call the list) I get about 10 fps _more_ than with the current implementation. (30 fps vs. 20 fps approx., with lots of bots) This is probly a result of list compilation being slower than rendering. Which would give the conclusion that lists should only be used when rendering them much more often than 1 time. (Rendering units with them would probably give a benefit.) Now my question: Do others experience the same speedup? How to test that: 1. Make sure your video card doesn't support GL_EXT_stencil_two_side (You get a message when running with --debug 3d, alternatively you can check glxinfo or your drivers info page on Windows) 2. Apply the patch. 3. Run a debug compile (to be able to enter cheatmode) 4. Start it with --cheat 5. Press SHIFT+BACKSPACE (to enable cheat mode), then press t (for message) and type "timedemo" ENTER 6. See a message about the current average framerate in the upper left 7. Do this a couple of times with lots of units so you get reliable results If others than just me detect the speedup also (means it is not driver/graphics card dependend) then I will commit that patch. --Dennis
Index: lib/ivis_opengl/piedraw.c
===================================================================
--- lib/ivis_opengl/piedraw.c (revision 296)
+++ lib/ivis_opengl/piedraw.c (working copy)
@@ -701,13 +701,13 @@
static BOOL dlist_defined = FALSE;
static GLuint dlist;
unsigned int i;
- float l[4];
+ float pos_lgt0[4];
fVector light;
float invmat[9];
float width = pie_GetVideoBufferWidth();
float height = pie_GetVideoBufferHeight();
- glGetLightfv(GL_LIGHT0, GL_POSITION, l);
+ glGetLightfv(GL_LIGHT0, GL_POSITION, pos_lgt0);
pie_SetTexturePage(-1);
@@ -730,6 +730,19 @@
glActiveStencilFaceEXT(GL_FRONT);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glStencilFunc(GL_ALWAYS, 0, ~0);
+
+ for (i = 0; i < nb_scshapes; ++i) {
+ glLoadIdentity();
+ glMultMatrixf(scshapes[i].matrix);
+ inverse_matrix(scshapes[i].matrix, invmat);
+ light.x = invmat[0]*pos_lgt0[0] + invmat[3]*pos_lgt0[1] + invmat[6]*pos_lgt0[2];
+ light.y = invmat[1]*pos_lgt0[0] + invmat[4]*pos_lgt0[1] + invmat[7]*pos_lgt0[2];
+ light.z = invmat[2]*pos_lgt0[0] + invmat[5]*pos_lgt0[1] + invmat[8]*pos_lgt0[2];
+ pie_DrawShadow(scshapes[i].shape, scshapes[i].flag, scshapes[i].flag_data, &light);
+ }
+
+ glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
+
} else {
if (!dlist_defined) {
dlist = glGenLists(1);
@@ -742,32 +755,31 @@
glCullFace(GL_BACK);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
- // Start display list.
- glNewList(dlist, GL_COMPILE_AND_EXECUTE);
- }
+ // Compute and draw shadows
+ for (i = 0; i < nb_scshapes; ++i) {
+ glLoadIdentity();
+ glMultMatrixf(scshapes[i].matrix);
+ inverse_matrix(scshapes[i].matrix, invmat);
+ light.x = invmat[0]*pos_lgt0[0] + invmat[3]*pos_lgt0[1] + invmat[6]*pos_lgt0[2];
+ light.y = invmat[1]*pos_lgt0[0] + invmat[4]*pos_lgt0[1] + invmat[7]*pos_lgt0[2];
+ light.z = invmat[2]*pos_lgt0[0] + invmat[5]*pos_lgt0[1] + invmat[8]*pos_lgt0[2];
+ pie_DrawShadow(scshapes[i].shape, scshapes[i].flag, scshapes[i].flag_data, &light);
+ }
- for (i = 0; i < nb_scshapes; ++i) {
- glLoadIdentity();
- glMultMatrixf(scshapes[i].matrix);
- inverse_matrix(scshapes[i].matrix, invmat);
- light.x = invmat[0]*l[0] + invmat[3]*l[1] + invmat[6]*l[2];
- light.y = invmat[1]*l[0] + invmat[4]*l[1] + invmat[7]*l[2];
- light.z = invmat[2]*l[0] + invmat[5]*l[1] + invmat[8]*l[2];
- pie_DrawShadow(scshapes[i].shape, scshapes[i].flag, scshapes[i].flag_data, &light);
- }
-
- if (stencil_one_pass()) {
- glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
- } else {
- // End display list.
- glEndList();
-
// Setup stencil for front faces.
glCullFace(GL_FRONT);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
- // Draw display list
- glCallList(dlist);
+ // Draw shadows again
+ for (i = 0; i < nb_scshapes; ++i) {
+ glLoadIdentity();
+ glMultMatrixf(scshapes[i].matrix);
+ inverse_matrix(scshapes[i].matrix, invmat);
+ light.x = invmat[0]*pos_lgt0[0] + invmat[3]*pos_lgt0[1] + invmat[6]*pos_lgt0[2];
+ light.y = invmat[1]*pos_lgt0[0] + invmat[4]*pos_lgt0[1] + invmat[7]*pos_lgt0[2];
+ light.z = invmat[2]*pos_lgt0[0] + invmat[5]*pos_lgt0[1] + invmat[8]*pos_lgt0[2];
+ pie_DrawShadow(scshapes[i].shape, scshapes[i].flag, scshapes[i].flag_data, &light);
+ }
}
glEnable(GL_CULL_FACE);
pgpmXYRscK4DJ.pgp
Description: PGP signature
_______________________________________________ Warzone-dev mailing list [email protected] https://mail.gna.org/listinfo/warzone-dev
