Skip to content
Permalink
Browse files

Fixed strict aliasing (or inline asm?) issue.

Some versions of GCC need this fix or alpha blending is broken.

  Fixes Bugzilla #648.
  • Loading branch information
icculus committed Sep 29, 2009
1 parent 1309faf commit b2ac61ed3cea65e5e7022cda4ac61f9a2201ddfb
Showing with 19 additions and 19 deletions.
  1. +19 −19 src/video/SDL_blit_A.c
@@ -234,12 +234,12 @@ static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info)
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip >> 2;
Uint32 dalpha = info->dst->Amask;
Uint8 load[8];
Uint64 load;

*(Uint64 *)load = 0x00fefefe00fefefeULL;/* alpha128 mask */
movq_m2r(*load, mm4); /* alpha128 mask -> mm4 */
*(Uint64 *)load = 0x0001010100010101ULL;/* !alpha128 mask */
movq_m2r(*load, mm3); /* !alpha128 mask -> mm3 */
load = 0x00fefefe00fefefeULL;/* alpha128 mask */
movq_m2r(load, mm4); /* alpha128 mask -> mm4 */
load = 0x0001010100010101ULL;/* !alpha128 mask */
movq_m2r(load, mm3); /* !alpha128 mask -> mm3 */
movd_m2r(dalpha, mm7); /* dst alpha mask */
punpckldq_r2r(mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */
while(height--) {
@@ -1883,24 +1883,24 @@ static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
Uint32 s, d;
Uint8 load[8];
Uint64 load;

alpha &= ~(1+2+4); /* cut alpha to get the exact same behaviour */
*(Uint64 *)load = alpha;
load = alpha;
alpha >>= 3; /* downscale alpha to 5 bits */

movq_m2r(*load, mm0); /* alpha(0000000A) -> mm0 */
movq_m2r(load, mm0); /* alpha(0000000A) -> mm0 */
punpcklwd_r2r(mm0, mm0); /* 00000A0A -> mm0 */
punpcklwd_r2r(mm0, mm0); /* 0A0A0A0A -> mm0 */
/* position alpha to allow for mullo and mulhi on diff channels
to reduce the number of operations */
psllq_i2r(3, mm0);

/* Setup the 565 color channel masks */
*(Uint64 *)load = 0x07E007E007E007E0ULL;
movq_m2r(*load, mm4); /* MASKGREEN -> mm4 */
*(Uint64 *)load = 0x001F001F001F001FULL;
movq_m2r(*load, mm7); /* MASKBLUE -> mm7 */
load = 0x07E007E007E007E0ULL;
movq_m2r(load, mm4); /* MASKGREEN -> mm4 */
load = 0x001F001F001F001FULL;
movq_m2r(load, mm7); /* MASKBLUE -> mm7 */
while(height--) {
DUFFS_LOOP_QUATRO2(
{
@@ -2022,24 +2022,24 @@ static void Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info)
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
Uint32 s, d;
Uint8 load[8];
Uint64 load;

alpha &= ~(1+2+4); /* cut alpha to get the exact same behaviour */
*(Uint64 *)load = alpha;
load = alpha;
alpha >>= 3; /* downscale alpha to 5 bits */

movq_m2r(*load, mm0); /* alpha(0000000A) -> mm0 */
movq_m2r(load, mm0); /* alpha(0000000A) -> mm0 */
punpcklwd_r2r(mm0, mm0); /* 00000A0A -> mm0 */
punpcklwd_r2r(mm0, mm0); /* 0A0A0A0A -> mm0 */
/* position alpha to allow for mullo and mulhi on diff channels
to reduce the number of operations */
psllq_i2r(3, mm0);

/* Setup the 555 color channel masks */
*(Uint64 *)load = 0x03E003E003E003E0ULL;
movq_m2r(*load, mm4); /* MASKGREEN -> mm4 */
*(Uint64 *)load = 0x001F001F001F001FULL;
movq_m2r(*load, mm7); /* MASKBLUE -> mm7 */
load = 0x03E003E003E003E0ULL;
movq_m2r(load, mm4); /* MASKGREEN -> mm4 */
load = 0x001F001F001F001FULL;
movq_m2r(load, mm7); /* MASKBLUE -> mm7 */
while(height--) {
DUFFS_LOOP_QUATRO2(
{

0 comments on commit b2ac61e

Please sign in to comment.