[AD] Using memmove in blit()?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


A few times I've heard the claim that memmove() (or memcpy) will be faster 
than Allegro's current blitter.
I've tested that with the attached patch and it doesn't appear to make much 
of a difference at all (note that I cannot use memmove() in 
_linear_blit_backward, despite memmove supposedly working properly if 
memory areas overlap). Timings from the test programme are inconclusive 
for me, with maybe a small hint that the memmove could be a bit faster, 
but not by much. Certainly less than the random variation between runs.
Anyone else care to do some benchmarks, or can anyone tell me if I missed 
something in the code if I'm not seeing as big a speed increase as I was 
expecting to see?

Evert
Index: src/c/cblit.h
===================================================================
--- src/c/cblit.h	(revision 5662)
+++ src/c/cblit.h	(working copy)
@@ -45,6 +45,8 @@
 
 
 
+#define USE_MEMMOVE
+
 /* _linear_blit:
  *  Normal forward blitting for linear bitmaps.
  */
@@ -60,6 +62,7 @@
       PIXEL_PTR s = OFFSET_PIXEL_PTR(bmp_read_line(src, sy + y), sx);
       PIXEL_PTR d = OFFSET_PIXEL_PTR(bmp_write_line(dst, dy + y), dx);
 
+      #ifndef USE_MEMMOVE
       for (x = w - 1; x >= 0; INC_PIXEL_PTR(s), INC_PIXEL_PTR(d), x--) {
 	 unsigned long c;
 
@@ -69,6 +72,9 @@
 	 bmp_select(dst);
 	 PUT_PIXEL(d, c);
       }
+      #else
+      memmove(d, s, w * sizeof *s);
+      #endif
    }
 
    bmp_unwrite_line(src);
@@ -77,6 +83,8 @@
 
 
 
+#undef USE_MEMMOVE
+
 /* _linear_blit_backward:
  *  Reverse blitting routine, for overlapping linear bitmaps.
  */
@@ -92,6 +100,7 @@
       PIXEL_PTR s = OFFSET_PIXEL_PTR(bmp_read_line(src, sy + y), sx + w - 1);
       PIXEL_PTR d = OFFSET_PIXEL_PTR(bmp_write_line(dst, dy + y), dx + w - 1);
 
+      #ifndef USE_MEMMOVE
       for (x = w - 1; x >= 0; DEC_PIXEL_PTR(s), DEC_PIXEL_PTR(d), x--) {
 	 unsigned long c;
 
@@ -101,6 +110,9 @@
 	 bmp_select(dst);
 	 PUT_PIXEL(d, c);
       }
+      #else
+      memmove(d, s, w * sizeof *s);
+      #endif
    }
 
    bmp_unwrite_line(src);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/