summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@koto.keithp.com>2007-09-10 16:12:29 +0100
committerKeith Packard <keithp@koto.keithp.com>2007-09-10 16:12:29 +0100
commit55aa9c238c5d81c9dc0f679dfd2fea00f356247b (patch)
treeefd38abdae66591cf2458f0c5ab2d6da6db0a5f0
parent8b3b9d1d1d3a255000fb43bd09c62ef1e0798023 (diff)
Add Compositing tests.
-compwinwinXX, -comppixwinXX where XX is 10, 100 or 500. -pop <POP> <POP> ... where <POP> is one of Clear, Src, Dst, Over, OverReverse, In, InReverse, Out, OutReverse, Atop, AtopReverse, Xor, Add or Saturate. -format <FORMAT> <FORMAT> ... where <FORMAT> is one of RGB24, ARGB32, A8, A4, A1 or NATIVE
-rw-r--r--.cvsignore22
-rw-r--r--do_blt.c114
-rw-r--r--do_tests.c24
-rw-r--r--x11perf.c165
-rw-r--r--x11perf.h37
5 files changed, 329 insertions, 33 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index 83b86e4..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,22 +0,0 @@
-.deps
-Makefile
-Makefile.in
-Xmark.1
-aclocal.m4
-autom4te.cache
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-configure
-depcomp
-install-sh
-missing
-stamp-h1
-x11perf
-x11perf.1
-x11perfcomp
-x11perfcomp.1
diff --git a/do_blt.c b/do_blt.c
index 2d93255..b508b4a 100644
--- a/do_blt.c
+++ b/do_blt.c
@@ -564,3 +564,117 @@ DoCopyPlane(XParms xp, Parms p, int reps)
}
}
+#include <X11/extensions/Xrender.h>
+
+static Picture winPict, pixPict;
+
+int
+InitCompositeWin(XParms xp, Parms p, int reps)
+{
+ XRenderPictFormat *format;
+ (void) InitScroll (xp, p, reps);
+ InitCopyLocations (xp, p, reps);
+ format = XRenderFindVisualFormat (xp->d, xp->vinfo.visual);
+ winPict = XRenderCreatePicture (xp->d, xp->w, format, 0, NULL);
+ return reps;
+}
+
+int
+InitCompositePix(XParms xp, Parms p, int reps)
+{
+ XRenderPictFormat *format = NULL;
+ int depth;
+
+ (void) InitCompositeWin (xp, p, reps);
+
+ /* Create pixmap to write stuff into, and initialize it */
+ switch (xp->planemask) {
+ case PictStandardNative:
+ depth = xp->vinfo.depth;
+ format = XRenderFindVisualFormat (xp->d, xp->vinfo.visual);
+ break;
+ case PictStandardRGB24:
+ depth = 24;
+ break;
+ case PictStandardARGB32:
+ depth = 32;
+ break;
+ case PictStandardA8:
+ depth = 8;
+ break;
+ case PictStandardA4:
+ depth = 4;
+ break;
+ case PictStandardA1:
+ depth = 1;
+ break;
+ }
+ if (!format)
+ format = XRenderFindStandardFormat (xp->d, xp->planemask);
+
+ pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, depth);
+ pixPict = XRenderCreatePicture (xp->d, pix, format, 0, NULL);
+
+ XRenderComposite (xp->d, PictOpClear,
+ winPict, None, pixPict,
+ 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+#if 1
+ XRenderComposite (xp->d, PictOpOver,
+ winPict, None, pixPict,
+ 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+#endif
+ return reps;
+}
+
+void
+EndCompositeWin (XParms xp, Parms p)
+{
+ if (winPict)
+ {
+ XRenderFreePicture (xp->d, winPict);
+ winPict = None;
+ }
+ if (pixPict)
+ {
+ XRenderFreePicture (xp->d, pixPict);
+ pixPict = None;
+ }
+}
+
+static void
+CompositeArea(XParms xp, Parms p, int reps, Picture src, Picture dst)
+{
+ int i, size;
+ XSegment *sa, *sb;
+
+ size = p->special;
+ for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+ XRenderComposite (xp->d, xp->func,
+ src, None, dst,
+ sa->x1, sa->y1, 0, 0,
+ sa->x2, sa->y2, size, size);
+ XRenderComposite (xp->d, xp->func,
+ src, None, dst,
+ sa->x2, sa->y2, 0, 0, sa->x1, sa->y1, size, size);
+ XRenderComposite (xp->d, xp->func,
+ src, None, dst,
+ sb->x2, sb->y2, 0, 0, sb->x1, sb->y1, size, size);
+ XRenderComposite (xp->d, xp->func,
+ src, None, dst,
+ sb->x1, sb->y1, 0, 0, sb->x2, sb->y2, size, size);
+ CheckAbort ();
+ }
+}
+
+void
+DoCompositeWinWin (XParms xp, Parms p, int reps)
+{
+ CompositeArea (xp, p, reps, winPict, winPict);
+}
+
+void
+DoCompositePixWin (XParms xp, Parms p, int reps)
+{
+ CompositeArea (xp, p, reps, pixPict, winPict);
+}
diff --git a/do_tests.c b/do_tests.c
index 378ea83..189a219 100644
--- a/do_tests.c
+++ b/do_tests.c
@@ -1237,6 +1237,30 @@ Test test[] = {
InitGetImage, DoGetImage, NullProc, EndGetImage,
V1_4FEATURE, PLANEMASK, 0,
{4, 500, "XY"}},
+ {"-compwinwin10", "Composite 10x10 from window to window", NULL,
+ InitCompositeWin, DoCompositeWinWin, MidScroll, EndCompositeWin,
+ VERSION1_6, COMP, 0,
+ {4, 10}},
+ {"-compwinwin100", "Composite 10x10 from window to window", NULL,
+ InitCompositeWin, DoCompositeWinWin, MidScroll, EndCompositeWin,
+ VERSION1_6, COMP, 0,
+ {4, 100}},
+ {"-compwinwin500", "Composite 10x10 from window to window", NULL,
+ InitCompositeWin, DoCompositeWinWin, MidScroll, EndCompositeWin,
+ VERSION1_6, COMP, 0,
+ {4, 500}},
+ {"-comppixwin10", "Composite 10x10 from pixmap to window", NULL,
+ InitCompositePix, DoCompositePixWin, MidScroll, EndCompositeWin,
+ VERSION1_6, COMP, 0,
+ {4, 10}},
+ {"-comppixwin100", "Composite 100x100 from pixmap to window", NULL,
+ InitCompositePix, DoCompositePixWin, MidScroll, EndCompositeWin,
+ VERSION1_6, COMP, 0,
+ {4, 100}},
+ {"-comppixwin500", "Composite 500x500 from pixmap to window", NULL,
+ InitCompositePix, DoCompositePixWin, MidScroll, EndCompositeWin,
+ VERSION1_6, COMP, 0,
+ {4, 500}},
{"-noop", "X protocol NoOperation", NULL,
NullInitProc, DoNoOp, NullProc, NullProc,
V1_2FEATURE, PLANEMASK, 0,
diff --git a/x11perf.c b/x11perf.c
index c8ac0b2..08c0062 100644
--- a/x11perf.c
+++ b/x11perf.c
@@ -68,6 +68,32 @@ RopNameRec ropNames[] = {
{ "set", GXset } /* 1 */
};
+RopNameRec popNames[] = {
+ { "Clear", PictOpClear },
+ { "Src", PictOpSrc },
+ { "Dst", PictOpDst },
+ { "Over", PictOpOver },
+ { "OverReverse", PictOpOverReverse },
+ { "In", PictOpIn },
+ { "InReverse", PictOpInReverse },
+ { "Out", PictOpOut },
+ { "OutReverse", PictOpOutReverse },
+ { "Atop", PictOpAtop },
+ { "AtopReverse", PictOpAtopReverse },
+ { "Xor", PictOpXor },
+ { "Add", PictOpAdd },
+ { "Saturate", PictOpSaturate },
+};
+
+RopNameRec formatNames[] = {
+ { "RGB24", PictStandardRGB24 },
+ { "ARGB32", PictStandardARGB32 },
+ { "A8", PictStandardA8 },
+ { "A4", PictStandardA4 },
+ { "A1", PictStandardA1 },
+ { "NATIVE", PictStandardNative },
+};
+
char *(visualClassNames)[] = {
"StaticGray",
"GrayScale",
@@ -90,8 +116,15 @@ static double syncTime = 0.0;
static int saveargc;
static char **saveargv;
+#define NUM_ROPS 16
static int numRops = 1;
-static int rops[16] = { GXcopy };
+static int rops[NUM_ROPS] = { GXcopy };
+#define NUM_POPS 14
+static int numPops = 1;
+static int pops[NUM_POPS] = { PictOpOver };
+#define NUM_FORMATS 6
+static int numFormats = 1;
+static int formats[NUM_FORMATS] = { PictStandardNative };
static int numPlanemasks = 1;
static unsigned long planemasks[256] = { (unsigned long)~0 };
@@ -131,6 +164,8 @@ static int GetWords(int argi, int argc, char **argv, char **wordsp, int *nump);
static int GetNumbers(int argi, int argc, char **argv, unsigned long *intsp,
int *nump);
static int GetRops(int argi, int argc, char **argv, int *ropsp, int *nump);
+static int GetPops(int argi, int argc, char **argv, int *popsp, int *nump);
+static int GetFormats(int argi, int argc, char **argv, int *formatsp, int *nump);
/************************************************
* time related stuff *
@@ -329,7 +364,7 @@ GetVersion(int *pargc, /* MODIFIED */
{
int argc = *pargc;
char **pargv = argv+1;
- Version version = VERSION1_5;
+ Version version = VERSION1_6;
int i;
Bool found = False;
@@ -363,6 +398,15 @@ GetVersion(int *pargc, /* MODIFIED */
found = True;
continue;
}
+ if (!strcmp (arg, "-v1.5")) {
+ version = VERSION1_5;
+ *pargc -= 1;
+ if (found) {
+ fprintf(stderr, "Warning: multiple version specifications\n");
+ }
+ found = True;
+ continue;
+ }
if (!strcmp(arg,"-")) {
while (i<argc) *pargv++ = argv[i++];
break;
@@ -798,6 +842,12 @@ ProcessTest(XParms xp, Test *test, int func, unsigned long pm, char *label)
int j;
xp->planemask = pm;
+ xp->func = func;
+ if (test->testType == COMP)
+ {
+ func = GXcopy;
+ pm = ~0L;
+ }
CreatePerfGCs(xp, func, pm);
DisplayStatus(xp->d, "Calibrating", label, 0);
reps = CalibrateTest(xp, test, seconds, &time);
@@ -860,6 +910,7 @@ main(int argc, char *argv[])
XGCValues tgcv;
int screen;
int rop, pm;
+ int pop, format;
int window_y, window_x;
XVisualInfo *vinfolist, vinfotempl;
unsigned long vmask;
@@ -969,6 +1020,12 @@ main(int argc, char *argv[])
} else if (strcmp(argv[i], "-rop") == 0) {
skip = GetRops (i+1, argc, argv, rops, &numRops);
i += skip;
+ } else if (strcmp(argv[i], "-pop") == 0) {
+ skip = GetPops (i+1, argc, argv, pops, &numPops);
+ i += skip;
+ } else if (strcmp(argv[i], "-format") == 0) {
+ skip = GetFormats (i+1, argc, argv, formats, &numFormats);
+ i += skip;
} else if (strcmp(argv[i], "-pm") == 0) {
skip = GetNumbers (i+1, argc, argv, planemasks, &numPlanemasks);
i += skip;
@@ -1107,6 +1164,18 @@ main(int argc, char *argv[])
LABELP(i), subWindows[child]);
}
break;
+ case COMP:
+ /* Run it through all specified pops */
+ for (pop = 0; pop < numPops; pop++) {
+ if (pops[pop] == PictOpOver) {
+ printf ("%s\n", LABELP(i));
+ } else {
+ printf ("(%s) %s\n",
+ popNames[pops[pop]].name,
+ LABELP(i));
+ }
+ } /* for pop */
+ break;
} /* switch */
}
}
@@ -1314,6 +1383,28 @@ main(int argc, char *argv[])
ProcessTest(&xparms, &test[i], GXcopy, ~0L, label);
}
break;
+ case COMP:
+ /* Loop through the composite operands */
+ for (pop = 0; pop < numPops; pop++) {
+ for (format = 0; format < numFormats; format++) {
+ if (formats[format] == PictStandardNative) {
+ if (pops[pop] == PictOpOver) {
+ sprintf (label, "%s", LABELP(i));
+ } else {
+ sprintf (label, "(%s) %s",
+ popNames[pops[pop]].name,
+ LABELP(i));
+ }
+ } else {
+ sprintf (label, "(%s %s) %s",
+ popNames[pops[pop]].name,
+ formatNames[formats[format]].name,
+ LABELP(i));
+ }
+ ProcessTest (&xparms, &test[i], pops[pop], formats[format], label);
+ }
+ }
+ break;
} /* switch */
} /* if doit */
} /* ForEachTest */
@@ -1404,21 +1495,83 @@ GetRops (int argi, int argc, char **argv, int *ropsp, int *nump)
if (!strncmp (words[i], "GX", 2))
words[i] += 2;
if (!strcmp (words[i], "all")) {
- for (i = 0; i < 16; i++)
+ for (i = 0; i < NUM_ROPS; i++)
ropsp[i] = ropNames[i].rop;
- *nump = 16;
+ *nump = NUM_ROPS;
break;
}
- for (rop = 0; rop < 16; rop++) {
+ for (rop = 0; rop < NUM_ROPS; rop++) {
if (!strcmp (words[i], ropNames[rop].name)) {
ropsp[i] = ropNames[rop].rop;
break;
}
}
- if (rop == 16) {
+ if (rop == NUM_ROPS) {
usage ();
fprintf (stderr, "unknown rop name %s\n", words[i]);
}
}
return count;
}
+
+static int
+GetPops (int argi, int argc, char **argv, int *popsp, int *nump)
+{
+ char *words[256];
+ int count;
+ int i;
+ int pop;
+
+ count = GetWords (argi, argc, argv, words, nump);
+ for (i = 0; i < count; i++) {
+ if (!strncmp (words[i], "PictOp", 6))
+ words[i] += 6;
+ if (!strcmp (words[i], "all")) {
+ for (i = 0; i < NUM_POPS; i++)
+ popsp[i] = popNames[i].rop;
+ *nump = NUM_POPS;
+ break;
+ }
+ for (pop = 0; pop < NUM_POPS; pop++) {
+ if (!strcmp (words[i], popNames[pop].name)) {
+ popsp[i] = popNames[pop].rop;
+ break;
+ }
+ }
+ if (pop == NUM_POPS) {
+ usage ();
+ fprintf (stderr, "unknown picture op name %s\n", words[i]);
+ }
+ }
+ return count;
+}
+
+static int
+GetFormats (int argi, int argc, char **argv, int *formatsp, int *nump)
+{
+ char *words[256];
+ int count;
+ int i;
+ int format;
+
+ count = GetWords (argi, argc, argv, words, nump);
+ for (i = 0; i < count; i++) {
+ if (!strcmp (words[i], "all")) {
+ for (i = 0; i < NUM_FORMATS; i++)
+ formatsp[i] = formatNames[i].rop;
+ *nump = NUM_FORMATS;
+ break;
+ }
+ for (format = 0; format < NUM_FORMATS; format++) {
+ if (!strcmp (words[i], formatNames[format].name)) {
+ formatsp[i] = formatNames[format].rop;
+ break;
+ }
+ }
+ if (format == NUM_FORMATS) {
+ usage ();
+ fprintf (stderr, "unknown format name %s\n", words[i]);
+ }
+ }
+ return count;
+}
diff --git a/x11perf.h b/x11perf.h
index da98463..45a052d 100644
--- a/x11perf.h
+++ b/x11perf.h
@@ -39,6 +39,7 @@ SOFTWARE.
#include <X11/Xfuncs.h>
#endif
#include <stddef.h>
+#include <X11/extensions/Xrender.h>
#define POLY 1000 /* # (small) items in poly calls */
#define MAXROWS 40 /* Max rows of items in poly calls */
@@ -53,6 +54,7 @@ SOFTWARE.
#define BigTile ((char *)2) /* Big tile/stipple */
#define OddTile ((char *)1) /* Odd sized tile/stipple */
+#define PictStandardNative 5
typedef unsigned char Version;
@@ -60,11 +62,13 @@ typedef unsigned char Version;
#define VERSION1_3 ((Version)(1 << 1))
#define VERSION1_4 ((Version)(1 << 2))
#define VERSION1_5 ((Version)(1 << 3))
+#define VERSION1_6 ((Version)(1 << 4))
#define V1_2ONLY VERSION1_2
-#define V1_2FEATURE (VERSION1_2 | VERSION1_3 | VERSION1_4 | VERSION1_5)
-#define V1_3FEATURE (VERSION1_3 | VERSION1_4 | VERSION1_5)
-#define V1_4FEATURE (VERSION1_4 | VERSION1_5)
-#define V1_5FEATURE (VERSION1_5)
+#define V1_2FEATURE (VERSION1_2 | VERSION1_3 | VERSION1_4 | VERSION1_5 | VERSION1_6)
+#define V1_3FEATURE (VERSION1_3 | VERSION1_4 | VERSION1_5 | VERSION1_6)
+#define V1_4FEATURE (VERSION1_4 | VERSION1_5 | VERSION1_6)
+#define V1_5FEATURE (VERSION1_5 | VERSION1_6)
+#define V1_6FEATURE (VERSION1_6)
typedef struct _Parms {
/* Required fields */
@@ -84,6 +88,8 @@ typedef struct _XParms {
GC bggc;
GC ddfggc;
GC ddbggc;
+ Picture w_picture;
+ Picture p_picture;
unsigned long foreground;
unsigned long background;
unsigned long ddbackground;
@@ -93,6 +99,8 @@ typedef struct _XParms {
Bool save_under;
int backing_store;
unsigned long planemask;
+ int func;
+ int format;
Colormap cmap;
} XParmRec, *XParms;
@@ -104,7 +112,8 @@ typedef enum {
WINDOW, /* Windowing test, rop, planemask have no affect */
ROP, /* Graphics test, rop, planemask has some affect */
PLANEMASK, /* Graphics test, rop no affect, planemask some affect */
- NONROP /* Graphics or overhead test, rop has no affect */
+ NONROP, /* Graphics or overhead test, rop has no affect */
+ COMP /* Graphics test, render op */
} TestType;
typedef struct _Test {
@@ -186,6 +195,24 @@ extern void EndGetImage ( XParms xp, Parms p );
extern int InitCopyPlane ( XParms xp, Parms p, int reps );
extern void DoCopyPlane ( XParms xp, Parms p, int reps );
+int
+InitCompositeWin(XParms xp, Parms p, int reps);
+
+void
+EndCompositeWin (XParms xp, Parms p);
+
+void
+DoCompositeWinWin (XParms xp, Parms p, int reps);
+
+int
+InitCompositePix(XParms xp, Parms p, int reps);
+
+void
+EndCompositePix (XParms xp, Parms p);
+
+void
+DoCompositePixWin (XParms xp, Parms p, int reps);
+
/* do_complex.c */
extern int InitComplexPoly ( XParms xp, Parms p, int reps );
extern void DoComplexPoly ( XParms xp, Parms p, int reps );