Sam Lantinga wrote:
Hmm, on what versions of XFree86 and with which OpenGL drivers is this?
I think that for regular Xlib calls, XFree86 4.x new scheduler fixed
most of this responsiveness problem, but I wonder if GLX requests are
avoiding the regular scheduler and making things crappy just like it was
in 3.x?
This is for the software rendering implementation in XFree86 4.0.1
What’s happening is that the X server is so busy actually performing
the rendering that it doesn’t deliver key events.
Try the program I attached, first as-is, then another time with the
XSync() commented out. I suggest you try it both on 3.x and 4.0.1 to see
what I mean.
Also… If you could give me the MB/sec you get (with the XSync!) in
4.0.1 and what kind of hardware you have, I would be thankful!
Maybe this discussion should be relayed to the XFree86 list…
I’m on xpert at xfree86.org, don’t hesitate to come by!–
“Those who do not understand Unix are condemned to reinvent it,
poorly.” – Henry Spencer
-------------- next part --------------
#include <sys/time.h>
#include <stdio.h>
#include <X11/Xlib.h>
#undef TILE_TRICK
#undef GRAB_SERVER
#define WINDOW_X 640
#define WINDOW_Y 480
#define BLIT_X 640
#define BLIT_Y 480
#define DEPTH(display) DefaultDepth(display, DefaultScreen(display))
int main() {
unsigned int frames;
int i, j;
int buf;
Display* dpy;
XPixmapFormatValues* pixmapfmt;
Window win;
GC gc;
Pixmap bufs[2];
struct timeval time1;
struct timeval time2;
unsigned int diff;
unsigned int bytes_per_pixel = 0;
double mbps;
XGCValues gcvalues;
dpy = XOpenDisplay(NULL);
win = XCreateSimpleWindow(dpy,
DefaultRootWindow(dpy),
0, 0, /* x, y /
WINDOW_X, WINDOW_Y, / width, height /
0, 0, / border_width, border /
None); / background */
XSelectInput(dpy, win, ExposureMask | KeyPressMask);
XMapWindow(dpy, win);
bufs[0] = XCreatePixmap(dpy,
win,
BLIT_X, BLIT_Y, /* width, height /
DEPTH(dpy)); / depth */
bufs[1] = XCreatePixmap(dpy,
win,
BLIT_X, BLIT_Y, /* width, height /
DEPTH(dpy)); / depth */
gcvalues.function = GXcopy;
gcvalues.plane_mask = AllPlanes;
gcvalues.fill_style = FillSolid;
#ifdef TILE_TRICK
gcvalues.tile = bufs[0];
gcvalues.ts_x_origin = 0;
gcvalues.ts_y_origin = 0;
#endif
gcvalues.graphics_exposures = False;
gc = XCreateGC(dpy,
win,
GCFunction
| GCPlaneMask
| GCFillStyle
#ifdef TILE_TRICK
| GCTile
| GCTileStipXOrigin
| GCTileStipYOrigin
#endif
| GCGraphicsExposures,
&gcvalues);
XSetForeground(dpy,
gc,
WhitePixel(dpy, DefaultScreen(dpy)));
XFillRectangle(dpy,
bufs[0],
gc,
0, 0, /* x, y /
BLIT_X, BLIT_Y); / width, height */
XFillRectangle(dpy,
win,
gc,
0, 0,
640, 240);
XSetForeground(dpy,
gc,
BlackPixel(dpy, DefaultScreen(dpy)));
XFillRectangle(dpy,
bufs[1],
gc,
0, 0, /* x, y /
BLIT_X, BLIT_Y); / width, height */
pixmapfmt = XListPixmapFormats(dpy, &i);
for(j = 0; j < i; j++) {
printf(“Pixmap format #%i\n”, j);
printf(" depth = %i\n", pixmapfmt[j].depth);
printf(" bits_per_pixel = %i\n", pixmapfmt[j].bits_per_pixel);
printf(" scanline_pad = %i\n", pixmapfmt[j].scanline_pad);
if(pixmapfmt[j].depth == DEPTH(dpy)) {
printf(" is default pixmap format\n");
bytes_per_pixel = pixmapfmt[j].bits_per_pixel / 8;
}
}
XFree(pixmapfmt);
while(1) {
XEvent ev;
XNextEvent(dpy, &ev);
if(ev.type == Expose) {
printf("got Expose\n");
break;
}
}
frames = 0;
buf = 0;
XSetGraphicsExposures(dpy,
gc,
False);
gettimeofday(&time1, NULL);
#ifdef GRAB_SERVER
XGrabServer(dpy);
#endif
while(1) {
#ifdef TILE_TRICK
XSetWindowBackgroundPixmap(dpy, win, bufs[buf]);
XClearArea(dpy, win, 0, 0, BLIT_X, BLIT_Y, False);
#else
XCopyArea(dpy,
bufs[buf],
win,
gc,
0, 0, /* src_x, src_y /
BLIT_X, BLIT_Y, / width, height /
0, 0); / dest_x, dest_y */
#endif
XSync(dpy, False);
if(XPending(dpy)) {
XEvent ev;
XNextEvent(dpy, &ev);
if(ev.type == KeyPress && ev.xkey.keycode == 9)
break;
}
buf = 1 - buf;
frames++;
}
#ifdef GRAB_SERVER
XUngrabServer(dpy);
#endif
gettimeofday(&time2, NULL);
diff = (time2.tv_sec * 1000) + (time2.tv_usec / 1000);
diff -= (time1.tv_sec * 1000) + (time1.tv_usec / 1000);
printf(“frames = %i\n”, frames);
printf(“ms = %i\n”, diff);
printf(“bpp = %i\n”, bytes_per_pixel);
printf(“fps = %i\n”, (frames * 1000) / diff);
mbps = (frames * 1000) / diff;
mbps = mbps * (BLIT_X * BLIT_Y * bytes_per_pixel);
mbps = mbps / (1024 * 1024);
printf(“MB/sec = %f\n”, mbps);
XUnmapWindow(dpy, win);
XDestroyWindow(dpy, win);
XFreePixmap(dpy, bufs[0]);
XFreePixmap(dpy, bufs[1]);
XCloseDisplay(dpy);
return 0;
}