[SDL] Alpha blending bug - fixed?

Frank Mehnert fm3 at os.inf.tu-dresden.de
Sun Dec 3 13:00:50 PST 2006


Hi Alex,

On Saturday 02 December 2006 00:32, Alex Volkov wrote:
> 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--) {

"rm" is senseless as the compiler can never choose "m". It _must_ choose
"r" since using "m" he would complain

  memory input 1 is not directly addressable

Kind regards,

Frank
-- 
## Dept. of Computer Science, Dresden University of Technology, Germany ##
## http://os.inf.tu-dresden.de/~fm3                                     ##
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061203/a46f1b99/attachment.pgp 


More information about the SDL mailing list