[SDL] Alpha blending bug - fixed?

Alex Volkov avcp-sdlmail at usa.net
Fri Dec 1 15:32:57 PST 2006


This bug is actually my fault, and I just stumbled upon it myself a couple
days ago. I apologize for that, as I should have known better to
double-check the data type of Ashift.
IMHO, Frank's and Ryan's version of the fix is better with some minor
modifications to allows the compiler a bit more freedom. Also another
function has to be patched in a similar way -- the pure MMX (non-3DNow!)
one, gcc version of BlitRGBtoRGBPixelAlphaMMX.
In light of all this I propose the following patch (also attached):

Index: SDL_blit_A.c
===================================================================
--- SDL_blit_A.c	(revision 2923)
+++ SDL_blit_A.c	(working copy)
@@ -369,7 +369,9 @@
 	packsswb_r2r(mm6, mm3); /* 0000FFFF -> mm3 */
 	pxor_r2r(mm0, mm3); /* 0000F000 -> mm3 (~channel mask) */
 	/* get alpha channel shift */
-	movd_m2r(sf->Ashift, mm5); /* Ashift -> mm5 */
+	__asm__ __volatile__ (
+		"movd %0, %%mm5"
+		: : "rm" ((Uint32) sf->Ashift) ); /* Ashift -> mm5 */
 
 	while(height--) {
 	    DUFFS_LOOP4({
@@ -1566,7 +1568,6 @@
 	int dstskip = info->d_skip >> 2;
 	SDL_PixelFormat* sf = info->src;
 	Uint32 amask = sf->Amask;
-	Uint32 ashift = sf->Ashift;
 
 	__asm__ (
 	/* make mm6 all zeros. */
@@ -1588,7 +1589,7 @@
 	/* get alpha channel shift */
 	"movd      %1, %%mm5\n\t" /* Ashift -> mm5 */
 
-	  : /* nothing */ : "m" (amask), "m" (ashift) );
+	  : /* nothing */ : "m" (amask), "rm" ((Uint32) sf->Ashift) );
 
 	while(height--) {
  
--Alex. 

-----Original Message-----
From: sdl-bounces+avcp-sdlmail=usa.net at libsdl.org
[mailto:sdl-bounces+avcp-sdlmail=usa.net at libsdl.org] On Behalf Of Ryan C.
Gordon
Sent: Tuesday, November 21, 2006 6:35 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] Alpha blending bug - fixed?


> We'll go with Gabriel's patch.

...which is now Subversion revision #2914 for the 1.2 branch, and #2915 
for the 1.3 branch.

Thanks!

--ryan.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: SDL_blit_A.patch.txt
Url: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061201/43e1a0dd/attachment.txt 


More information about the SDL mailing list