Skip to content

Commit 63c6467

Browse files
committed
Fix missing pixels for SSE2 algorithm
Also, simplify mask code.
1 parent f7e13bf commit 63c6467

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src_c/simd_transform_sse2.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -632,17 +632,13 @@ invert_sse2(SDL_Surface *src, SDL_Surface *newsurf)
632632
Uint32 *srcp = (Uint32 *)src->pixels;
633633
Uint32 *dstp = (Uint32 *)newsurf->pixels;
634634

635-
Uint32 rgbmask = ~src->format->Amask;
636-
Uint64 rgbmask64 = ((Uint64)rgbmask << 32) | rgbmask;
637-
Uint64 amask64 = ~rgbmask64;
638-
639635
__m128i mm_src, mm_dst, mm_alpha, mm_rgb_invert_mask, mm_alpha_mask;
640636

641637
__m128i *srcp128 = (__m128i *)src->pixels;
642638
__m128i *dstp128 = (__m128i *)newsurf->pixels;
643639

644-
mm_rgb_invert_mask = _mm_set1_epi64x(rgbmask64);
645-
mm_alpha_mask = _mm_set1_epi64x(amask64);
640+
mm_rgb_invert_mask = _mm_set1_epi32(~src->format->Amask);
641+
mm_alpha_mask = _mm_set1_epi32(src->format->Amask);
646642

647643
while (num_batches--) {
648644
perfect_4_pixels_batch_counter = perfect_4_pixels;
@@ -667,7 +663,7 @@ invert_sse2(SDL_Surface *src, SDL_Surface *newsurf)
667663
}
668664
srcp = (Uint32 *)srcp128;
669665
dstp = (Uint32 *)dstp128;
670-
if (remaining_pixels_batch_counter > 0) {
666+
while (remaining_pixels_batch_counter--) {
671667
mm_src = _mm_cvtsi32_si128(*srcp);
672668
/*mm_src = 0x000000000000000000000000AARRGGBB*/
673669

0 commit comments

Comments
 (0)