Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » FBlend missing pixels

This thread is locked; no one can reply to it. rss feed Print
FBlend missing pixels
BlackEye
Member #3,762
August 2003

I'm using FBlend 0.5 b1 from sourceforge. When I use fblend_trans, the rightmost few pixels of the source bitmap aren't drawn. This happens when I'm in a color depth of 32, and the source bitmap width is not a multiple of 4. If I change the color depth to 16, or the source bitmap width to a multiple of 4, it works as expected. The other blend functions don't seem to have this problem. The function fblend_rect_trans_32 works as well with any source bitmap. I've traced the problem to the call to fblend_trans_sse_32, but I don't know assembly so I don't know where the problem is inside the function.

Here is a screenshot of the issue and piece of code to duplicate the problem. The first row is drawn by FBlend, the second by the standard allegro functions. The first box is 20 pixels wide, and the second is 19.
591948

1#include <allegro.h>
2#include <fblend.h>
3 
4int main()
5{
6 allegro_init();
7 set_color_depth(32);
8 set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
9 
10 BITMAP *buffer=create_bitmap(SCREEN_W,SCREEN_H);
11 BITMAP *b1=create_bitmap(20,20);
12 BITMAP *b2=create_bitmap(19,19);
13 
14 clear_bitmap(buffer);
15 clear_to_color(b1,makecol(255,0,255));
16 clear_to_color(b2,makecol(255,0,255));
17 
18 rect(b1,0,0,19,19,makecol(255,255,255));
19 rect(b2,0,0,18,18,makecol(255,255,255));
20 
21 fblend_trans(b1,buffer,20,20,200);
22 fblend_trans(b2,buffer,80,20,200);
23 
24 set_trans_blender(0,0,0,200);
25 draw_trans_sprite(buffer,b1,20,80);
26 draw_trans_sprite(buffer,b2,80,80);
27 
28 blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
29 
30 allegro_message("done");
31 
32 return 0;
33}
34END_OF_MAIN()

I know FBlend is not currently maintained, but it would be nice to know if anyone else has run into this problem, and if you know what needs to be changed in the code to make it work.

Bob
Free Market Evangelist
September 2000
avatar

Copy/paste bug. Try this patch on trans32.s:

1--- trans32.s 2002-02-26 17:21:02.000000000 -0600
2+++ Copy of trans32.s 2007-04-16 22:06:03.250000000 -0500
3@@ -246,7 +246,7 @@
4 por %mm4, %mm0; /* Recombine components */
5 paddb %mm2, %mm0;
6 
7- movq %mm0, %es:-8(%edi); /* Write results back */
8+ movq %mm0, %es:(%edi); /* Write results back */
9 
10 _align_;
11 trans_sse_32_end:
12@@ -404,7 +404,7 @@
13 movq %mm1, %mm4;
14 paddb %mm2, %mm5; /* %mm5 = first 2 pixels blended */
15 
16- movq %mm5, %es:-4(%edi); /* Write results back */
17+ movq %mm5, %es:(%edi); /* Write results back */
18 
19 _align_;
20 trans_sse_32_half_end:
21@@ -640,7 +640,7 @@
22 por %mm4, %mm0; /* Recombine components */
23 paddb %mm2, %mm0;
24 
25- movq %mm0, %es:-8(%edi); /* Write results back */
26+ movq %mm0, %es:(%edi); /* Write results back */
27 
28 _align_;
29 trans_mmx_32_end:
30@@ -795,7 +795,7 @@
31 movq %mm1, %mm4;
32 paddb %mm2, %mm5; /* %mm5 = first 2 pixels blended */
33 
34- movq %mm5, %es:-4(%edi); /* Write results back */
35+ movq %mm5, %es:(%edi); /* Write results back */
36 
37 _align_;
38 trans_mmx_32_half_end:

--
- Bob
[ -- All my signature links are 404 -- ]

BlackEye
Member #3,762
August 2003

I got the patch applied. I cleaned all the intermediate files and rebuilt FBlend and the sample app, but it still has the same issue.

Paul whoknows
Member #5,081
September 2004
avatar

Just download Fblend HERE.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

BlackEye
Member #3,762
August 2003

I didn't see a source download for the version on that site. Anyway, I tried the precompiled one and the same issue is there.

Bob
Free Market Evangelist
September 2000
avatar

Well I can't explain it. The rest of the code is pretty much the same for 16-bit vs 32-bit.

--
- Bob
[ -- All my signature links are 404 -- ]

Paul whoknows
Member #5,081
September 2004
avatar

I tried your code and I had the same problem!
Well, at least is good to know that this only happens under the conditions you listed above, however it would be nice if some assembler-guy can fix it.
I am using Fblend a lot, and I did not notice this before!:-[

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

BlackEye
Member #3,762
August 2003

Well I'm glad someone confirmed the problem. I thought I was going crazy. I found that if the source width is a multiple of 4 + 1, it works as well.

Matt Smith
Member #783
November 2000

Probably the reason nobody noticed this before is because it is generally faster and easier to keep all source bitmaps multiples of 4 wide, wherever possible.

Go to: