test: Create separate SHM segments for ref/out
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 2 Jul 2014 09:16:07 +0000 (09:16 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 2 Jul 2014 11:55:34 +0000 (12:55 +0100)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
test/lowlevel-blt-bench.c
test/test.h
test/test_display.c

index 63f6815..99b96c0 100644 (file)
@@ -218,10 +218,11 @@ static Picture source_radial_generic(struct test_display *t, struct test_target
        return XRenderCreateRadialGradient(t->dpy, &gradient, stops, colors, 2);
 }
 
-static XShmSegmentInfo shm;
+static XShmSegmentInfo shmref, shmout;
 
 static void setup_shm(struct test *t)
 {
+       XShmSegmentInfo shm;
        int size;
 
        shm.shmid = -1;
@@ -244,24 +245,28 @@ static void setup_shm(struct test *t)
        }
 
        shm.readOnly = False;
-       XShmAttach(t->ref.dpy, &shm);
+
+       shmref = shm;
+       XShmAttach(t->ref.dpy, &shmref);
        XSync(t->ref.dpy, True);
 
-       XShmAttach(t->out.dpy, &shm);
+       shmout = shm;
+       XShmAttach(t->out.dpy, &shmout);
        XSync(t->out.dpy, True);
 }
 
 static Picture source_shm(struct test_display *t, struct test_target *target)
 {
+       XShmSegmentInfo *shm = t->target == REF ? &shmref : &shmout;
        Pixmap pixmap;
        Picture picture;
        int size;
 
-       if (shm.shmid == -1)
+       if (shm->shmid == -1)
                return 0;
 
        pixmap = XShmCreatePixmap(t->dpy, t->root,
-                                 shm.shmaddr, &shm,
+                                 shm->shmaddr, shm,
                                  target->width, target->height, 32);
 
        picture = XRenderCreatePicture(t->dpy, pixmap,
@@ -270,8 +275,8 @@ static Picture source_shm(struct test_display *t, struct test_target *target)
        XFreePixmap(t->dpy, pixmap);
 
        size = target->width * target->height * 4;
-       memset(shm.shmaddr, 0x80, size/2);
-       memset(shm.shmaddr+size/2, 0xff, size/2);
+       memset(shm->shmaddr, 0x80, size/2);
+       memset(shm->shmaddr+size/2, 0xff, size/2);
 
        return picture;
 }
index bf0e5e6..a3ef979 100644 (file)
@@ -34,6 +34,7 @@ struct test {
                int has_shm_pixmaps;
                int width, height, depth;
                XRenderPictFormat *format;
+               enum { REF, OUT } target;
        } out, ref;
 };
 
index d5a8a02..98ee4e8 100644 (file)
@@ -136,11 +136,13 @@ static void test_get_displays(int argc, char **argv,
        default_setup(out);
        shm_setup(out);
        out->root = get_root(out);
+       out->target = OUT;
 
        ref->dpy = ref_display(out->width, out->height, out->depth);
        default_setup(ref);
        shm_setup(ref);
        ref->root = get_root(ref);
+       ref->target = REF;
 }
 
 void test_init(struct test *test, int argc, char **argv)