diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-01-06 10:58:53 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-01-07 13:43:01 +0000 |
commit | 7f46d58f7523a07e9086b7c47534c37240d83409 (patch) | |
tree | 58b40bb316b7c95bbf95ed708b044f7ee11d1f08 | |
parent | c39d831d409537fce2f36c8672f908a7cc810519 (diff) |
Add tests for ShmGetImage
Similar to GetImage and ShmPutImage, test the performance of retrieving
pixel data from the X server without the overhead of copying the pixels.
In the upper bound, using XShmGetImage, the performance will be limited
by the RTT latency (x11perf -prop). However, comparing the scaling factors
of XShmGetImage and XGetImage will give some insight into the driver
efficiency.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | do_blt.c | 58 | ||||
-rw-r--r-- | do_tests.c | 24 | ||||
-rw-r--r-- | x11perf.h | 3 |
3 files changed, 78 insertions, 7 deletions
@@ -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,17 @@ 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 @@ -1210,6 +1210,30 @@ Test test[] = { InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage, V1_4FEATURE, ROP, 0, {4, 500, "XY"}}, + {"-shmget10", "ShmGetImage 10x10 square", NULL, + InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, + V1_2FEATURE, ROP, 0, + {4, 10}}, + {"-shmget100", "ShmGetImage 100x100 square", NULL, + InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, + V1_2FEATURE, ROP, 0, + {4, 100}}, + {"-shmget500", "ShmGetImage 500x500 square", NULL, + InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, + V1_2FEATURE, ROP, 0, + {4, 500}}, + {"-shmgetxy10", "ShmGetImage XY 10x10 square", NULL, + InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, + V1_4FEATURE, ROP, 0, + {4, 10, "XY"}}, + {"-shmgetxy100", "ShmGetImage XY 100x100 square", NULL, + InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, + V1_4FEATURE, ROP, 0, + {4, 100, "XY"}}, + {"-shmgetxy500", "ShmGetImage XY 500x500 square", NULL, + InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage, + V1_4FEATURE, ROP, 0, + {4, 500, "XY"}}, #endif {"-getimage10", "GetImage 10x10 square", NULL, InitGetImage, DoGetImage, NullProc, EndGetImage, @@ -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 ); |