Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.800 diff -u -2 -0 -r1.800 ChangeLog --- xc/ChangeLog 7 Mar 2005 19:27:21 -0000 1.800 +++ xc/ChangeLog 7 Mar 2005 19:33:51 -0000 @@ -1,21 +1,29 @@ 2005-03-07 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) + Backout of attachment #1630 (https://bugs.freedesktop.org/attachment.cgi?id=1630) + as the described issue should be fixed in the GLX implementation of + the server side (per discussion in xorg@freedesktop.org). + +2005-03-07 Roland Mainz * xc/config/cf/Imake.rules * xc/programs/Xserver/hw/xfree86/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/ark/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/dummy/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i2c/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/newport/Imakefile Index: xc/programs/glxgears/glxgears.c =================================================================== RCS file: /cvs/xorg/xc/programs/glxgears/glxgears.c,v retrieving revision 1.9 diff -u -2 -0 -r1.9 glxgears.c --- xc/programs/glxgears/glxgears.c 4 Jan 2005 22:05:09 -0000 1.9 +++ xc/programs/glxgears/glxgears.c 7 Mar 2005 19:34:13 -0000 @@ -50,53 +50,47 @@ #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; } -/* 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 */ +/* 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 */ #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 */ @@ -115,40 +109,42 @@ 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; @@ -552,86 +548,80 @@ { 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, @@ -642,111 +632,84 @@ 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 = True; + printInfo = GL_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 = True; + printInfo = GL_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); @@ -828,41 +791,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, NULLSTR(dpyName)); + fprintf(stderr, "%s: Error: couldn't open display '%s'\n", ProgramName, 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));