Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.640 diff -u -2 -0 -r1.640 ChangeLog --- xc/ChangeLog 4 Jan 2005 17:27:26 -0000 1.640 +++ xc/ChangeLog 4 Jan 2005 21:58:27 -0000 @@ -1,20 +1,28 @@ +2005-01-04 Roland Mainz + * xc/programs/glxgears/glxgears.c + Bugzilla #2220 (https://bugs.freedesktop.org/show_bug.cgi?id=2220) + attachment #xxx (https://bugs.freedesktop.org/attachment.cgi?id=xxx): + Make glxgears a better GL client via calling |glFinish()| between frame + swaps to avoid that the GL instruction queue gets spammed, sometimes + even killing all interactive usage of the Xserver. + 2005-01-04 Egbert Eich * config/cf/xorg.cf: - made structure of PPC64 part look more like the other structures. - added VBE driver to PPC64. I don't know if this really makes sense, but since we are building the int10 module we should also build the vbe module. - added i915 DRM driver to list of drivers for the AMD64 architecture. - added a check for gcc versions > 3 for setting GccAliasingFlags. 2005-01-03 Alan Coopersmith * programs/Xserver/hw/xfree86/xf86config/xorgconfig.c: Bugzilla #2211 (https://bugs.freedesktop.org/show_bug.cgi?id=2211) attachment #1627 (https://bugs.freedesktop.org/attachment.cgi?id=1627): xorgconfig default keyboard model outdated (should be pc105, not pc101/pc102) Index: xc/programs/glxgears/glxgears.c =================================================================== RCS file: /cvs/xorg/xc/programs/glxgears/glxgears.c,v retrieving revision 1.8 diff -u -2 -0 -r1.8 glxgears.c --- xc/programs/glxgears/glxgears.c 3 Jan 2005 01:06:35 -0000 1.8 +++ xc/programs/glxgears/glxgears.c 4 Jan 2005 21:59:50 -0000 @@ -50,47 +50,53 @@ #endif /* BUILD_PRINTSUPPORT */ #include #include #include #include #include #include #include #include #include #include #ifndef M_PI #define M_PI 3.14159265 #endif /* !M_PI */ /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) #define Log(x) { if(verbose) printf x; } -/* Globla vars */ -static const char *ProgramName; /* program name (from argv[0]) */ -static Bool verbose = False; /* verbose output what the program is doing */ - -static int xp_event_base, /* XpExtension even base */ - xp_error_base; /* XpExtension error base */ -static double degperpage = 5.0; /* Rotate gears degree per page */ +/* Global vars */ +static const char *ProgramName; /* program name (from argv[0]) */ +static Bool verbose = False; /* verbose output what the program is doing */ +static int xp_event_base = 0, /* XpExtension even base */ + xp_error_base = 0; /* XpExtension error base */ +static double degperpage = 10.0; /* Rotate gears degree per page */ +static Bool singletooth = False, + paused = False; +static Bool printInfo = False; +static Bool do_xflush_after_frame = False, /* Call |XFlush()| after each frame? */ + do_sched_yield_after_frame = False, /* Call |sched_yield()| after each frame? */ + do_xsync_after_frame = False, /* Call |XSync(dpy, False)| after each frame? */ + do_glfinish_after_frame = True; /* Call |glFinish()| after each frame */ #define TIMING 1 #ifdef TIMING /* XXX this probably isn't very portable */ /* return current time (in seconds) */ static long current_time(void) { struct timeval tv; struct timezone tz; (void) gettimeofday(&tv, &tz); return (long) tv.tv_sec * 1000000 + (long) tv.tv_usec; } #else /* TIMING */ /* dummy */ @@ -109,42 +115,40 @@ fprintf (stderr, "-display\tSet X11 display for output.\n"); #ifdef BUILD_PRINTSUPPORT fprintf (stderr, "-print\t\tUse printer instead of video card for output.\n"); fprintf (stderr, "-printer printername\tname of printer to use.\n"); fprintf (stderr, "-printfile printername\tOutput file for print job.\n"); fprintf (stderr, "-numpages count\tNumber of pages to print.\n"); fprintf (stderr, "-degperpage deg\tRotate gears degree per page.\n"); #endif /* BUILD_PRINTSUPPORT */ fprintf (stderr, "-info\t\tPrint additional GLX information.\n"); fprintf (stderr, "-singletooth\tDraw only one tooth for each gear (for debugging etc.).\n"); fprintf (stderr, "-h\t\tPrint this help page.\n"); fprintf (stderr, "-v\t\tVerbose output.\n"); fprintf (stderr, "\n"); exit(EXIT_FAILURE); } static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; static GLint speed = 60; -static int singletooth = 0, paused = 0; -static GLboolean printInfo = GL_FALSE; /* * * Draw a gear wheel. You'll probably want to call this function when * building a display list since we do a lot of trig here. * * Input: inner_radius - radius of hole at center * outer_radius - radius at center of teeth * width - width of gear * teeth - number of teeth * tooth_depth - depth of tooth */ static void gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth) { GLint i; GLfloat r0, r1, r2, maxr2, minr2; GLfloat angle, da; GLfloat u, v, len; @@ -548,80 +552,86 @@ { if (!paused) angle = angle + ((double)speed * useconds) / 1000000.0; } /* keep angle small so we don't lose precision! */ if (angle > 360.0) angle = angle - 360.0; #ifdef BUILD_PRINTSUPPORT if (numPages > 0) { Log(("Start page.\n")); XpStartPage(dpy, win); XpuWaitForPrintNotify(dpy, xp_event_base, XPStartPageNotify); } #endif /* BUILD_PRINTSUPPORT */ draw(); glXSwapBuffers(dpy, win); + /* Flush frame, give CPU away and/or sync with Xserver */ + if (do_glfinish_after_frame) + glFinish(); + if (do_xflush_after_frame) + XFlush(dpy); + if (do_sched_yield_after_frame) + sched_yield(); + if (do_xsync_after_frame) + XSync(dpy, False); + #ifdef BUILD_PRINTSUPPORT if (numPages > 0) { Log(("End page.\n")); XpEndPage(dpy); XpuWaitForPrintNotify(dpy, xp_event_base, XPEndPageNotify); /* Last page ? */ if( --numPages == 0 ) return; } #endif /* BUILD_PRINTSUPPORT */ t0 = t; } #ifdef TIMING { /* calc framerate */ static int frames = 0; static long t0 = 0; if (!t0) t0 = t; frames++; if (t - t0 >= 5000000L) { GLfloat seconds = (t - t0) / 1000000.0; GLfloat fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); t0 = t; frames = 0; } } - - /* Need to give cpu away in order to get precise timing next cycle, - * otherwise, gettimeofday would return almost the same value. */ - sched_yield(); #endif /* TIMING */ } } } int main(int argc, char *argv[]) { Bool use_threadsafe_api = False; Display *dpy; Window win; Screen *screen; GLXContext ctx; char *dpyName = NULL; int i; XRectangle winrect; #ifdef BUILD_PRINTSUPPORT long dpi_x = 0L, @@ -632,84 +642,111 @@ const char *printername = NULL; /* printer to query */ const char *toFile = NULL; /* output file (instead of printer) */ int numPages = 5; /* Numer of pages to print */ XPPrinterList plist = NULL; /* list of printers */ int plist_count; /* number of entries in |plist|-array */ unsigned short dummy; #endif /* BUILD_PRINTSUPPORT */ ProgramName = argv[0]; for (i = 1; i < argc; i++) { const char *arg = argv[i]; int len = strlen(arg); if (strcmp(argv[i], "-display") == 0) { if (++i >= argc) usage(); dpyName = argv[i]; } else if (strcmp(argv[i], "-info") == 0) { - printInfo = GL_TRUE; + printInfo = True; } #ifdef BUILD_PRINTSUPPORT else if (strcmp(argv[i], "-print") == 0) { doPrint = True; } else if (!strncmp("-printer", arg, len)) { if (++i >= argc) usage(); printername = argv[i]; doPrint = True; } else if (!strncmp("-printfile", arg, len)) { if (++i >= argc) usage(); toFile = argv[i]; doPrint = True; } else if (!strncmp("-numpages", arg, len)) { if (++i >= argc) usage(); errno = 0; /* reset errno to catch |atoi()|-errors */ numPages = atoi(argv[i]); if ((numPages <= 0) || (errno != 0)) usage(); doPrint = True; } else if (!strncmp("-degperpage", arg, len)) { if (++i >= argc) usage(); errno = 0; /* reset errno to catch |atof()|-errors */ degperpage = atof(argv[i]); if (errno != 0) usage(); doPrint = True; } #endif /* BUILD_PRINTSUPPORT */ else if (!strncmp("-v", arg, len)) { verbose = True; - printInfo = GL_TRUE; + printInfo = True; } else if (!strncmp("-singletooth", arg, len)) { singletooth = True; } + else if (!strncmp("-nosingletooth", arg, len)) { + singletooth = False; + } + else if (!strncmp("-xflush_after_frame", arg, len)) { + do_xflush_after_frame = True; + } + else if (!strncmp("-no_xflush_after_frame", arg, len)) { + do_xflush_after_frame = False; + } + else if (!strncmp("-sched_yield_after_frame", arg, len)) { + do_sched_yield_after_frame = True; + } + else if (!strncmp("-no_sched_yield_after_frame", arg, len)) { + do_sched_yield_after_frame = False; + } + else if (!strncmp("-xsync_after_frame", arg, len)) { + do_xsync_after_frame = True; + } + else if (!strncmp("-no_xsync_after_frame", arg, len)) { + do_xsync_after_frame = False; + } + else if (!strncmp("-glfinish_after_frame", arg, len)) { + do_glfinish_after_frame = True; + } + else if (!strncmp("-no_glfinish_after_frame", arg, len)) { + do_glfinish_after_frame = False; + } else if( !strncmp("-debug_use_threadsafe_api", arg, len) ) { use_threadsafe_api = True; } else if (!strcmp(argv[i], "-h")) { usage(); } else { fprintf(stderr, "%s: Unsupported option '%s'.\n", ProgramName, argv[i]); usage(); } } /* Init X threading API on demand (for debugging) */ if( use_threadsafe_api ) { if( !XInitThreads() ) { fprintf(stderr, "%s: XInitThreads() failure.\n", ProgramName); @@ -791,41 +828,41 @@ XpuStartJobToSpooler(dpy); XpuWaitForPrintNotify(dpy, xp_event_base, XPStartJobNotify); } screen = XpGetScreenOfContext(dpy, pcontext); /* Obtain some info about page geometry */ XpGetPageDimensions(dpy, pcontext, &dummy, &dummy, &winrect); /* Center output window on page */ winrect.width /= 2; winrect.height /= 2; winrect.x += winrect.width / 2; winrect.y += winrect.height / 2; } else #endif /* BUILD_PRINTSUPPORT */ { dpy = XOpenDisplay(dpyName); if (!dpy) { - fprintf(stderr, "%s: Error: couldn't open display '%s'\n", ProgramName, dpyName); + fprintf(stderr, "%s: Error: couldn't open display '%s'\n", ProgramName, NULLSTR(dpyName)); return EXIT_FAILURE; } screen = XDefaultScreenOfDisplay(dpy); winrect.x = 0; winrect.y = 0; winrect.width = 300; winrect.height = 300; } Log(("Window x=%d, y=%d, width=%d, height=%d\n", (int)winrect.x, (int)winrect.y, (int)winrect.width, (int)winrect.height)); make_window(dpy, screen, "glxgears", winrect.x, winrect.y, winrect.width, winrect.height, &win, &ctx); reshape(winrect.width, winrect.height); if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));