xf86-video-intel: 2 commits - test/lowlevel-blt-bench.c test/test_display.c test/test.h
Chris Wilson
ickle at kemper.freedesktop.org
Mon Jun 30 01:37:19 PDT 2014
test/lowlevel-blt-bench.c | 190 ++++++++++++++++++++++++++++++++++++++++------
test/test.h | 1
test/test_display.c | 4
3 files changed, 172 insertions(+), 23 deletions(-)
New commits:
commit 2e0000688d034535083950b98bc61745dd965352
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Mon Jun 30 08:44:33 2014 +0100
test/lowlevel-blt-bench: Exercise masks
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 26ea455..7f6f524 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -295,8 +295,8 @@ static const struct {
{ source_radial_generic, "radial (generic)" },
};
-static double _bench(struct test_display *t, enum target target_type,
- int op, int src, int loops)
+static double _bench_source(struct test_display *t, enum target target_type,
+ int op, int src, int loops)
{
XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 };
struct test_target target;
@@ -328,27 +328,80 @@ static double _bench(struct test_display *t, enum target target_type,
return elapsed;
}
-static void bench(struct test *t, enum target target, int op, int src)
+static void bench_source(struct test *t, enum target target, int op, int src)
{
double out, ref;
- ref = _bench(&t->ref, target, op, src, 1000);
+ ref = _bench_source(&t->ref, target, op, src, 1000);
if (ref < 0)
return;
- out = _bench(&t->out, target, op, src, 1000);
+ out = _bench_source(&t->out, target, op, src, 1000);
if (out < 0)
return;
-
fprintf (stdout, "%28s with %s: ref=%f, out=%f\n",
source[src].name, ops[op].name, ref, out);
}
+static double _bench_mask(struct test_display *t, enum target target_type,
+ int op, int src, int mask, int loops)
+{
+ XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 };
+ struct test_target target;
+ Picture ps, pm;
+ struct timespec tv;
+ double elapsed;
+
+ test_target_create_render(t, target_type, &target);
+ XRenderFillRectangle(t->dpy, PictOpClear, target.picture, &render_color,
+ 0, 0, target.width, target.height);
+
+ ps = source[src].create(t, &target);
+ pm = source[mask].create(t, &target);
+ if (ps && pm) {
+ test_timer_start(t, &tv);
+ while (loops--)
+ XRenderComposite(t->dpy, op,
+ ps, pm, target.picture,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ target.width, target.height);
+ elapsed = test_timer_stop(t, &tv);
+ } else
+ elapsed = -1;
+
+ if (ps)
+ XRenderFreePicture(t->dpy, ps);
+ if (pm)
+ XRenderFreePicture(t->dpy, pm);
+
+ test_target_destroy_render(t, &target);
+
+ return elapsed;
+}
+
+static void bench_mask(struct test *t, enum target target, int op, int src, int mask)
+{
+ double out, ref;
+
+ ref = _bench_mask(&t->ref, target, op, src, mask, 1000);
+ if (ref < 0)
+ return;
+
+ out = _bench_mask(&t->out, target, op, src, mask, 1000);
+ if (out < 0)
+ return;
+
+ fprintf (stdout, "%28s In %28s with %s: ref=%f, out=%f\n",
+ source[src].name, source[mask].name, ops[op].name, ref, out);
+}
+
int main(int argc, char **argv)
{
struct test test;
- unsigned op, src;
+ unsigned op, src, mask;
test_init(&test, argc, argv);
@@ -356,7 +409,12 @@ int main(int argc, char **argv)
for (op = 0; op < sizeof(ops)/sizeof(ops[0]); op++) {
for (src = 0; src < sizeof(source)/sizeof(source[0]); src++)
- bench(&test, ROOT, op, src);
+ bench_source(&test, ROOT, op, src);
+ fprintf (stdout, "\n");
+
+ for (src = 0; src < sizeof(source)/sizeof(source[0]); src++)
+ for (mask = 0; mask < sizeof(source)/sizeof(source[0]); mask++)
+ bench_mask(&test, ROOT, op, src, mask);
fprintf (stdout, "\n");
}
commit 37ac34c4e4500bfc272222754949edc1dbb8c7e2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Mon Jun 30 08:44:33 2014 +0100
test/lowlevel-blt-bench: Exercise SHM pixmaps
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 91af827..26ea455 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -23,6 +23,10 @@
* DEALINGS IN THE SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,7 +35,19 @@
#include <X11/X.h>
#include <X11/Xutil.h> /* for XDestroyImage */
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xrender.h>
+#include <X11/extensions/XShm.h>
+#if HAVE_X11_EXTENSIONS_SHMPROTO_H
+#include <X11/extensions/shmproto.h>
+#elif HAVE_X11_EXTENSIONS_SHMSTR_H
+#include <X11/extensions/shmstr.h>
+#else
+#error Failed to find the right header for X11 MIT-SHM protocol definitions
+#endif
#include <pixman.h> /* for pixman blt functions */
+#include <sys/ipc.h>
+#include <sys/shm.h>
#include "test.h"
@@ -67,7 +83,10 @@ static const struct op {
static Picture source_pixmap(struct test_display *t, struct test_target *target, int format)
{
- XRenderColor render_color = { 0x8000, 0x8000, 0x8000, 0x8000 };
+ XRenderColor render_color[2] = {
+ { 0x8000, 0x8000, 0x8000, 0x8000 },
+ { 0xffff, 0xffff, 0xffff, 0xffff },
+ };
Pixmap pixmap;
Picture picture;
@@ -80,8 +99,10 @@ static Picture source_pixmap(struct test_display *t, struct test_target *target,
0, NULL);
XFreePixmap(t->dpy, pixmap);
- XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color,
- 0, 0, target->width, target->height);
+ XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color[0],
+ 0, 0, target->width, target->height/2);
+ XRenderFillRectangle(t->dpy, PictOpSrc, picture, &render_color[1],
+ 0, target->height/2, target->width, target->height/2);
return picture;
}
@@ -197,6 +218,64 @@ static Picture source_radial_generic(struct test_display *t, struct test_target
return XRenderCreateRadialGradient(t->dpy, &gradient, stops, colors, 2);
}
+static XShmSegmentInfo shm;
+
+static void setup_shm(struct test *t)
+{
+ int size;
+
+ shm.shmid = -1;
+
+ if (!(t->ref.has_shm_pixmaps && t->out.has_shm_pixmaps))
+ return;
+
+ size = t->ref.width * t->ref.height * 4;
+ size = (size + 4095) & -4096;
+
+ shm.shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0666);
+ if (shm.shmid == -1)
+ return;
+
+ shm.shmaddr = shmat(shm.shmid, 0, 0);
+ if (shm.shmaddr == (char *) -1) {
+ shmctl(shm.shmid, IPC_RMID, NULL);
+ shm.shmid = -1;
+ return;
+ }
+
+ shm.readOnly = False;
+ XShmAttach(t->ref.dpy, &shm);
+ XSync(t->ref.dpy, True);
+
+ XShmAttach(t->out.dpy, &shm);
+ XSync(t->out.dpy, True);
+}
+
+static Picture source_shm(struct test_display *t, struct test_target *target)
+{
+ Pixmap pixmap;
+ Picture picture;
+ int size;
+
+ if (shm.shmid == -1)
+ return 0;
+
+ pixmap = XShmCreatePixmap(t->dpy, t->root,
+ shm.shmaddr, &shm,
+ target->width, target->height, 32);
+
+ picture = XRenderCreatePicture(t->dpy, pixmap,
+ XRenderFindStandardFormat(t->dpy, 0),
+ 0, NULL);
+ XFreePixmap(t->dpy, pixmap);
+
+ size = target->width * target->height * 4;
+ memset(shm.shmaddr, 0x80, size/2);
+ memset(shm.shmaddr+size/2, 0xff, size/2);
+
+ return picture;
+}
+
static const struct {
Picture (*create)(struct test_display *, struct test_target *);
const char *name;
@@ -208,6 +287,7 @@ static const struct {
{ source_a1, "a1 pixmap" },
{ source_1x1r, "a8r8g8b8 1x1R pixmap" },
{ source_solid, "solid" },
+ { source_shm, "a8r8g8b8 shm" },
{ source_linear_horizontal, "linear (horizontal gradient)" },
{ source_linear_vertical, "linear (vertical gradient)" },
{ source_linear_diagonal, "linear (diagonal gradient)" },
@@ -229,18 +309,20 @@ static double _bench(struct test_display *t, enum target target_type,
0, 0, target.width, target.height);
picture = source[src].create(t, &target);
+ if (picture) {
+ test_timer_start(t, &tv);
+ while (loops--)
+ XRenderComposite(t->dpy, op,
+ picture, 0, target.picture,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ target.width, target.height);
+ elapsed = test_timer_stop(t, &tv);
+ XRenderFreePicture(t->dpy, picture);
+ } else
+ elapsed = -1;
- test_timer_start(t, &tv);
- while (loops--)
- XRenderComposite(t->dpy, op,
- picture, 0, target.picture,
- 0, 0,
- 0, 0,
- 0, 0,
- target.width, target.height);
- elapsed = test_timer_stop(t, &tv);
-
- XRenderFreePicture(t->dpy, picture);
test_target_destroy_render(t, &target);
return elapsed;
@@ -251,7 +333,13 @@ static void bench(struct test *t, enum target target, int op, int src)
double out, ref;
ref = _bench(&t->ref, target, op, src, 1000);
+ if (ref < 0)
+ return;
+
out = _bench(&t->out, target, op, src, 1000);
+ if (out < 0)
+ return;
+
fprintf (stdout, "%28s with %s: ref=%f, out=%f\n",
source[src].name, ops[op].name, ref, out);
@@ -264,6 +352,8 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
+ setup_shm(&test);
+
for (op = 0; op < sizeof(ops)/sizeof(ops[0]); op++) {
for (src = 0; src < sizeof(source)/sizeof(source[0]); src++)
bench(&test, ROOT, op, src);
diff --git a/test/test.h b/test/test.h
index 383384b..bf0e5e6 100644
--- a/test/test.h
+++ b/test/test.h
@@ -31,6 +31,7 @@ struct test {
Window root;
XShmSegmentInfo shm;
int max_shm_size;
+ int has_shm_pixmaps;
int width, height, depth;
XRenderPictFormat *format;
} out, ref;
diff --git a/test/test_display.c b/test/test_display.c
index 892b54e..d5a8a02 100644
--- a/test/test_display.c
+++ b/test/test_display.c
@@ -97,10 +97,10 @@ static Display *ref_display(int width, int height, int depth)
static void shm_setup(struct test_display *d)
{
- int major, minor, has_pixmaps;
+ int major, minor;
int size;
- XShmQueryVersion(d->dpy, &major, &minor, &has_pixmaps);
+ XShmQueryVersion(d->dpy, &major, &minor, &d->has_shm_pixmaps);
if (major == 0 && minor == 0)
die("XSHM not supported\n");
More information about the xorg-commit
mailing list