[PATCH] Include ShmGetImage tests for x11perf

Chris Wilson chris at chris-wilson.co.uk
Thu Jan 6 05:25:43 PST 2011


I noticed that there were no corresponding tests for ShmGetImage to
attempt to measure the performance of readback without the overhead of
pushing those pixels over the wire.

This adds a test based on GetImage, but it has a bug where the Window is
cleared after the first run - it doesn't seem to affect the results.
I haven't been able to spot it, so I'm hoping a few more eyes might.
-Chris

---
 do_blt.c   |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 do_tests.c |   24 ++++++++++++++++++++++++
 x11perf.h  |    3 +++
 3 files changed, 79 insertions(+), 7 deletions(-)

diff --git a/do_blt.c b/do_blt.c
index 2834392..1c9458b 100644
--- a/do_blt.c
+++ b/do_blt.c
@@ -364,8 +364,8 @@ shmerrorhandler(Display *d, XErrorEvent *e)
 	return (*origerrorhandler)(d,e);
 }
 
-int 
-InitShmPutImage(XParms xp, Parms p, int reps)
+static int
+InitShmImage(XParms xp, Parms p, int reps, Bool read_only)
 {
     int	image_size;
 
@@ -382,7 +382,6 @@ InitShmPutImage(XParms xp, Parms p, int reps)
     	free(segsb);
     	return False;
     }	
-    XClearWindow(xp->d, xp->w);
     shm_image = *image;
     image_size = image->bytes_per_line * image->height;
     /* allow XYPixmap choice: */
@@ -418,7 +417,7 @@ InitShmPutImage(XParms xp, Parms p, int reps)
 	shmctl (shm_info.shmid, IPC_RMID, NULL);
 	return False;
     }
-    shm_info.readOnly = True;
+    shm_info.readOnly = read_only;
     XSync(xp->d,True);
     haderror = False;
     origerrorhandler = XSetErrorHandler(shmerrorhandler);
@@ -447,7 +446,21 @@ InitShmPutImage(XParms xp, Parms p, int reps)
     return reps;
 }
 
-void 
+int
+InitShmPutImage(XParms xp, Parms p, int reps)
+{
+    if (!InitShmImage(xp, p, reps, True)) return False;
+    XClearWindow(xp->d, xp->w);
+    return reps;
+}
+
+int
+InitShmGetImage(XParms xp, Parms p, int reps)
+{
+    return InitShmImage(xp, p, reps, False);
+}
+
+void
 DoShmPutImage(XParms xp, Parms p, int reps)
 {
     int i, size;
@@ -467,10 +480,30 @@ DoShmPutImage(XParms xp, Parms p, int reps)
     }
 }
 
-void 
-EndShmPutImage(XParms xp, Parms p)
+void
+DoShmGetImage(XParms xp, Parms p, int reps)
 {
+    int i, size;
+    XSegment *sa, *sb;
+
+    size = p->special;
+
+    shm_image.width = size;
+    shm_image.height = size;
+
+    for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
+	/* compute offsets into image data? */
+	XShmGetImage(xp->d, xp->w, &shm_image, sa->x1, sa->y1, xp->planemask);
+	XShmGetImage(xp->d, xp->w, &shm_image, sa->x2, sa->y2, xp->planemask);
+	XShmGetImage(xp->d, xp->w, &shm_image, sb->x2, sb->y2, xp->planemask);
+	XShmGetImage(xp->d, xp->w, &shm_image, sb->x1, sb->y1, xp->planemask);
+	CheckAbort ();
+    }
+}
 
+static void
+EndShmImage(XParms xp, Parms p)
+{
     EndGetImage (xp, p);
     XShmDetach (xp->d, &shm_info);
     XSync(xp->d, False);	/* need server to detach so can remove id */
@@ -480,6 +513,18 @@ EndShmPutImage(XParms xp, Parms p)
 	perror("shmctl rmid:");
 }
 
+void
+EndShmGetImage(XParms xp, Parms p)
+{
+    EndShmImage(xp, p);
+}
+
+void
+EndShmPutImage(XParms xp, Parms p)
+{
+    EndShmImage(xp, p);
+}
+
 #endif
 
 
diff --git a/do_tests.c b/do_tests.c
index e4f3cb1..ee1f02b 100644
--- a/do_tests.c
+++ b/do_tests.c
@@ -1210,6 +1210,30 @@ Test test[] = {
 		InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage,
 		V1_4FEATURE, ROP, 0,
 		{4, 500, "XY"}},
+  {"-shmget10", "ShmGetImage 10x10 square", NULL,
+		InitShmGetImage, DoShmGetImage, MidCopyPix, EndShmGetImage,
+		V1_2FEATURE, ROP, 0,
+		{4, 10}},
+  {"-shmget100", "ShmGetImage 100x100 square", NULL,
+		InitShmGetImage, DoShmGetImage, MidCopyPix, EndShmGetImage,
+		V1_2FEATURE, ROP, 0,
+		{4, 100}},
+  {"-shmget500", "ShmGetImage 500x500 square", NULL,
+		InitShmGetImage, DoShmGetImage, MidCopyPix, EndShmGetImage,
+		V1_2FEATURE, ROP, 0,
+		{4, 500}},
+  {"-shmgetxy10", "ShmGetImage XY 10x10 square", NULL,
+		InitShmGetImage, DoShmGetImage, MidCopyPix, EndShmGetImage,
+		V1_4FEATURE, ROP, 0,
+		{4, 10, "XY"}},
+  {"-shmgetxy100", "ShmGetImage XY 100x100 square", NULL,
+		InitShmGetImage, DoShmGetImage, MidCopyPix, EndShmGetImage,
+		V1_4FEATURE, ROP, 0,
+		{4, 100, "XY"}},
+  {"-shmgetxy500", "ShmGetImage XY 500x500 square", NULL,
+		InitShmGetImage, DoShmGetImage, MidCopyPix, EndShmGetImage,
+		V1_4FEATURE, ROP, 0,
+		{4, 500, "XY"}},
 #endif
   {"-getimage10", "GetImage 10x10 square", NULL,
 		InitGetImage, DoGetImage, NullProc, EndGetImage,
diff --git a/x11perf.h b/x11perf.h
index 1deb037..3cbb631 100644
--- a/x11perf.h
+++ b/x11perf.h
@@ -183,8 +183,11 @@ extern void DoGetImage ( XParms xp, Parms p, int reps );
 extern void DoPutImage ( XParms xp, Parms p, int reps );
 #ifdef MITSHM
 extern int InitShmPutImage ( XParms xp, Parms p, int reps );
+extern int InitShmGetImage ( XParms xp, Parms p, int reps );
 extern void DoShmPutImage ( XParms xp, Parms p, int reps );
+extern void DoShmGetImage ( XParms xp, Parms p, int reps );
 extern void EndShmPutImage ( XParms xp, Parms p );
+extern void EndShmGetImage ( XParms xp, Parms p );
 #endif
 extern void MidCopyPix ( XParms xp, Parms p );
 extern void EndCopyWin ( XParms xp, Parms p );
-- 
1.7.2.3


More information about the xorg-devel mailing list