summaryrefslogtreecommitdiffstats
path: root/progs/xdemos
diff options
context:
space:
mode:
Diffstat (limited to 'progs/xdemos')
-rw-r--r--progs/xdemos/.gitignore7
-rw-r--r--progs/xdemos/Makefile47
-rw-r--r--progs/xdemos/glsync.c11
-rw-r--r--progs/xdemos/glxinfo.c30
-rw-r--r--progs/xdemos/msctest.c13
-rw-r--r--progs/xdemos/omlsync.c45
6 files changed, 84 insertions, 69 deletions
diff --git a/progs/xdemos/.gitignore b/progs/xdemos/.gitignore
index a65b890d3dc..2f5e909079a 100644
--- a/progs/xdemos/.gitignore
+++ b/progs/xdemos/.gitignore
@@ -13,11 +13,14 @@ glxpixmap
glxsnoop
glxswapcontrol
manywin
+msctest
multictx
offset
+omlsync
overlay
-pbdemo
pbinfo
+pbdemo
+shape
sharedtex
sharedtex_mt
texture_from_pixmap
@@ -26,5 +29,3 @@ xdemo
xfont
xrotfontdemo
yuvrect_client
-msctest
-omlsync
diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
index 9cf984b59e5..2663015b2c7 100644
--- a/progs/xdemos/Makefile
+++ b/progs/xdemos/Makefile
@@ -9,7 +9,7 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
# Add X11 and pthread libs to satisfy GNU gold.
-APP_LIB_DEPS += -lX11 -lpthread
+APP_LIB_DEPS += $(X11_LIBS) -lpthread
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
@@ -53,17 +53,18 @@ EXTRA_PROGS = \
##### RULES #####
-.SUFFIXES:
-.SUFFIXES: .c
+.o: $(LIB_DEP)
+ $(APP_CC) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
-.c: $(LIB_DEP)
- $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
+.c.o:
+ $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $< -c -o $@
##### TARGETS #####
default: $(PROGS)
+$(PROGS): $(PROGS:%=%.o)
extra: $(EXTRA_PROGS)
@@ -74,45 +75,29 @@ clean:
# special cases
+pbutil.o: pbutil.h
+pbinfo.o: pbutil.h
pbinfo: pbinfo.o pbutil.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) pbinfo.o pbutil.o $(LIBS) -o $@
+pbdemo.o: pbutil.h
pbdemo: pbdemo.o pbutil.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) pbdemo.o pbutil.o $(LIBS) -o $@
-pbinfo.o: pbinfo.c pbutil.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbinfo.c
-
-pbdemo.o: pbdemo.c pbutil.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbdemo.c
-
-pbutil.o: pbutil.c pbutil.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbutil.c
-
+glxgears_fbconfig.o: pbutil.h
glxgears_fbconfig: glxgears_fbconfig.o pbutil.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(LIBS) -o $@
-glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h
- $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c
-
+xuserotfont.o: xuserotfont.h
+xrotfontdemo.o: xuserotfont.h
xrotfontdemo: xrotfontdemo.o xuserotfont.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(LIBS) -o $@
-xuserotfont.o: xuserotfont.c xuserotfont.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xuserotfont.c
-
-xrotfontdemo.o: xrotfontdemo.c xuserotfont.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c
-
+ipc.o: ipc.h
+corender.o: ipc.h
corender: corender.o ipc.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) corender.o ipc.o $(LIBS) -o $@
-corender.o: corender.c ipc.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) corender.c
-
-ipc.o: ipc.c ipc.h
- $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c
-
-yuvrect_client: yuvrect_client.c
- $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -l$(GLU_LIB) -o $@
+yuvrect_client: yuvrect_client.o
+ $(APP_CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -l$(GLU_LIB) -o $@
diff --git a/progs/xdemos/glsync.c b/progs/xdemos/glsync.c
index c00ba9e4687..3751373e23b 100644
--- a/progs/xdemos/glsync.c
+++ b/progs/xdemos/glsync.c
@@ -63,10 +63,9 @@ void (*swap_interval)();
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
- const char *extensionsString, *client_extensions, *pos;
+ const char *extensionsString, *pos;
extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
- client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
pos = strstr(extensionsString, extension);
@@ -74,12 +73,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
return 1;
- pos = strstr(client_extensions, extension);
-
- if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
- (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
- return 1;
-
return 0;
}
@@ -235,7 +228,7 @@ int main(int argc, char *argv[])
XMapWindow(disp, winGL);
ret = glXMakeCurrent(disp, winGL, context);
- if (ret) {
+ if (!ret) {
fprintf(stderr, "failed to make context current: %d\n", ret);
}
diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c
index 332f5c2f463..b656e58924e 100644
--- a/progs/xdemos/glxinfo.c
+++ b/progs/xdemos/glxinfo.c
@@ -80,6 +80,7 @@ struct visual_attribs
/* GL visual attribs */
int supportsGL;
+ int drawableType;
int transparentType;
int transparentRedValue;
int transparentGreenValue;
@@ -585,6 +586,28 @@ visual_class_name(int cls)
}
}
+static const char *
+visual_drawable_type(int type)
+{
+ static char buffer[256], *p;
+ const static struct { int bit; const char *name; } bits[] = {
+ { GLX_WINDOW_BIT, "window" },
+ { GLX_PIXMAP_BIT, "pixmap" },
+ { GLX_PBUFFER_BIT, "pbuffer" }
+ };
+ int i;
+
+ p = buffer;
+ for (i = 0; i < 3; i++) {
+ if (p > buffer)
+ *p++ = ',';
+ if (type & bits[i].bit)
+ strcpy(p, bits[i].name);
+ p += strlen(bits[i].name);
+ }
+
+ return buffer;
+}
static const char *
visual_class_abbrev(int cls)
@@ -655,6 +678,7 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
else
attribs->render_type = GLX_COLOR_INDEX_BIT;
+ glXGetConfig(dpy, vInfo, GLX_DRAWABLE_TYPE, &attribs->drawableType);
glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
@@ -753,6 +777,7 @@ get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type);
attribs->klass = glx_token_to_visual_class(visual_type);
+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_DRAWABLE_TYPE, &attribs->drawableType);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type);
@@ -798,8 +823,9 @@ get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
static void
print_visual_attribs_verbose(const struct visual_attribs *attribs)
{
- printf("Visual ID: %x depth=%d class=%s\n",
- attribs->id, attribs->depth, visual_class_name(attribs->klass));
+ printf("Visual ID: %x depth=%d class=%s, type=%s\n",
+ attribs->id, attribs->depth, visual_class_name(attribs->klass),
+ visual_drawable_type(attribs->drawableType));
printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
attribs->bufferSize, attribs->level,
visual_render_type_name(attribs->render_type),
diff --git a/progs/xdemos/msctest.c b/progs/xdemos/msctest.c
index 001ecf04d6c..11b04344426 100644
--- a/progs/xdemos/msctest.c
+++ b/progs/xdemos/msctest.c
@@ -45,10 +45,9 @@ void (*wait_sync)(Display *dpy, Window winGL, int64_t target_msc, int64_t diviso
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
- const char *extensionsString, *client_extensions, *pos;
+ const char *extensionsString, *pos;
extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
- client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
pos = strstr(extensionsString, extension);
@@ -56,12 +55,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
return 1;
- pos = strstr(client_extensions, extension);
-
- if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
- (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
- return 1;
-
return 0;
}
@@ -167,8 +160,8 @@ int main(int argc, char *argv[])
glXMakeCurrent(disp, winGL, context);
- get_sync_values = glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
- wait_sync = glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
+ get_sync_values = (void *)glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
+ wait_sync = (void *)glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
if (!get_sync_values || !wait_sync) {
fprintf(stderr, "failed to get sync values function\n");
diff --git a/progs/xdemos/omlsync.c b/progs/xdemos/omlsync.c
index 4eee849b532..061d6c68613 100644
--- a/progs/xdemos/omlsync.c
+++ b/progs/xdemos/omlsync.c
@@ -69,13 +69,13 @@ Bool (*glXWaitForMscOML)(Display *dpy, GLXDrawable drawable, int64_t target_msc,
int64_t *msc, int64_t *sbc);
Bool (*glXWaitForSbcOML)(Display *dpy, GLXDrawable drawable, int64_t target_sbc,
int64_t *ust, int64_t *msc, int64_t *sbc);
+int (*glXSwapInterval)(int interval);
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
- const char *extensionsString, *client_extensions, *pos;
+ const char *extensionsString, *pos;
extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
- client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
pos = strstr(extensionsString, extension);
@@ -83,25 +83,20 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
return 1;
- pos = strstr(client_extensions, extension);
-
- if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
- (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
- return 1;
-
return 0;
}
extern char *optarg;
extern int optind, opterr, optopt;
-static char optstr[] = "w:h:vd:r:n:";
+static char optstr[] = "w:h:vd:r:n:i:";
static void usage(char *name)
{
- printf("usage: %s [-w <width>] [-h <height>] [-i<swap interval>] "
- "[-n<wait interval>] [-v]\n", name);
+ printf("usage: %s [-w <width>] [-h <height>] ...\n", name);
+ printf("\t-d<divisor> - divisor for OML swap\n");
+ printf("\t-r<remainder> - remainder for OML swap\n");
+ printf("\t-n<interval> - wait interval for OML WaitMSC\n");
printf("\t-i<swap interval> - swap at most once every n frames\n");
- printf("\t-n<wait interval> - wait n frames between swaps\n");
printf("\t-v: verbose (print count)\n");
exit(-1);
}
@@ -115,8 +110,9 @@ int main(int argc, char *argv[])
GLXContext context;
int dummy;
Atom wmDelete;
+ int64_t ust, msc, sbc;
int width = 500, height = 500, verbose = 0, divisor = 0, remainder = 0,
- wait_interval = 0;
+ wait_interval = 0, swap_interval = 1;
int c, i = 1;
int ret;
int db_attribs[] = { GLX_RGBA,
@@ -149,6 +145,9 @@ int main(int argc, char *argv[])
case 'n':
wait_interval = atoi(optarg);
break;
+ case 'i':
+ swap_interval = atoi(optarg);
+ break;
default:
usage(argv[0]);
break;
@@ -171,6 +170,11 @@ int main(int argc, char *argv[])
return -1;
}
+ if (!GLXExtensionSupported(disp, "GLX_MESA_swap_control")) {
+ fprintf(stderr, "GLX_MESA_swap_control not supported\n");
+ return -1;
+ }
+
pvi = glXChooseVisual(disp, DefaultScreen(disp), db_attribs);
if (!pvi) {
@@ -224,8 +228,14 @@ int main(int argc, char *argv[])
glXSwapBuffersMscOML = (void *)glXGetProcAddress((unsigned char *)"glXSwapBuffersMscOML");
glXWaitForMscOML = (void *)glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
glXWaitForSbcOML = (void *)glXGetProcAddress((unsigned char *)"glXWaitForSbcOML");
+ glXSwapInterval = (void *)glXGetProcAddress((unsigned char *)"glXSwapIntervalMESA");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glXSwapInterval(swap_interval);
+ fprintf(stderr, "set swap interval to %d\n", swap_interval);
+
+ glXGetSyncValuesOML(disp, winGL, &ust, &msc, &sbc);
while (i++) {
/* Alternate colors to make tearing obvious */
if (i & 1) {
@@ -239,7 +249,14 @@ int main(int argc, char *argv[])
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRectf(0, 0, width, height);
- glXSwapBuffersMscOML(disp, winGL, 0, divisor, remainder);
+ if (!wait_interval)
+ glXSwapBuffersMscOML(disp, winGL, 0, divisor,
+ remainder);
+ else {
+ glXWaitForMscOML(disp, winGL, msc + wait_interval,
+ divisor, remainder, &ust, &msc, &sbc);
+ glXSwapBuffersMscOML(disp, winGL, 0, 0, 0);
+ }
}
XDestroyWindow(disp, winGL);