[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Elias Pschernig wrote:
Hm, I guess, memset() makes use of special asm instructions which
allegro's clear does not, or something. Can you post a simple test
program which compares the two, and if possible, a patch which does the
change - so the old vs. new clear_bitmap could be directly compared.
Attached patch and the test progam.
Here are my test results on linux, P4:
patched:
15-bit: 2000 calls, 1.105000 ms per call
16-bit: 2000 calls, 1.115000 ms per call
24-bit: 2000 calls, 1.870000 ms per call
32-bit: 2000 calls, 2.650000 ms per call
vanilla:
15-bit: 2000 calls, 1.475000 ms per call
16-bit: 2000 calls, 1.465000 ms per call
24-bit: 2000 calls, 2.225000 ms per call
32-bit: 2000 calls, 2.655000 ms per call
I was wondering, is it OK to clear the 16th bit when in 15-bit mode?
--
Milan Mimica
diff -u3r allegro-4.1.18/src/gfx.c allegro-4.1.18-fix/src/gfx.c
--- allegro-4.1.18/src/gfx.c 2005-01-27 12:14:01.000000000 +0100
+++ allegro-4.1.18-fix/src/gfx.c 2005-01-27 12:08:26.000000000 +0100
@@ -23,6 +23,7 @@
#include <math.h>
+#include <string.h>
#include "allegro.h"
#include "allegro/internal/aintern.h"
@@ -158,7 +159,10 @@
*/
void clear_bitmap(BITMAP *bitmap)
{
- clear_to_color(bitmap, 0);
+ if (is_memory_bitmap(bitmap))
+ memset(bitmap->line[0], 0, BYTES_PER_PIXEL(bitmap_color_depth(bitmap)) * bitmap->w * bitmap->h);
+ else
+ clear_to_color(bitmap, 0);
}
#include <allegro.h>
#include <time.h>
#include <stdio.h>
int main() {
int c;
int t;
BITMAP *bmp;
const int iter = 2000;
allegro_init();
bmp = create_bitmap_ex(15, 800, 600);
t = clock();
for (c = 0; c < iter; ++c)
clear_bitmap(bmp);
t = clock() - t;
printf("15-bit: %i calls, %f ms per call\n", iter, 1000.0 * t / (iter * (double)CLOCKS_PER_SEC));
destroy_bitmap(bmp);
bmp = create_bitmap_ex(16, 800, 600);
t = clock();
for (c = 0; c < iter; ++c)
clear_bitmap(bmp);
t = clock() - t;
printf("16-bit: %i calls, %f ms per call\n", iter, 1000.0 * t / (iter * (double)CLOCKS_PER_SEC));
destroy_bitmap(bmp);
bmp = create_bitmap_ex(24, 800, 600);
t = clock();
for (c = 0; c < iter; ++c)
clear_bitmap(bmp);
t = clock() - t;
printf("24-bit: %i calls, %f ms per call\n", iter, 1000.0 * t / (iter * (double)CLOCKS_PER_SEC));
destroy_bitmap(bmp);
bmp = create_bitmap_ex(32, 800, 600);
t = clock();
for (c = 0; c < iter; ++c)
clear_bitmap(bmp);
t = clock() - t;
printf("32-bit: %i calls, %f ms per call\n", iter, 1000.0 * t / (iter * (double)CLOCKS_PER_SEC));
destroy_bitmap(bmp);
return 0;
}
END_OF_MAIN()