Skip to content

Commit 68367cf

Browse files
committed
Get surface_blit system compiling with SDL3
1 parent 09651b6 commit 68367cf

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

src_c/alphablit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,18 +1715,18 @@ premul_surf_color_by_alpha(SDL_Surface *src, SDL_Surface *dst)
17151715
#if !defined(__EMSCRIPTEN__)
17161716
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
17171717
if ((PG_SURF_BytesPerPixel(src) == 4) && pg_has_avx2()) {
1718-
premul_surf_color_by_alpha_avx2(src, dst);
1718+
premul_surf_color_by_alpha_avx2(src, src_format, dst);
17191719
return 0;
17201720
}
17211721
#if defined(__SSE2__)
17221722
if ((PG_SURF_BytesPerPixel(src) == 4) && SDL_HasSSE2()) {
1723-
premul_surf_color_by_alpha_sse2(src, dst);
1723+
premul_surf_color_by_alpha_sse2(src, src_format, dst);
17241724
return 0;
17251725
}
17261726
#endif /* __SSE2__*/
17271727
#if PG_ENABLE_ARM_NEON
17281728
if ((PG_SURF_BytesPerPixel(src) == 4) && SDL_HasNEON()) {
1729-
premul_surf_color_by_alpha_sse2(src, dst);
1729+
premul_surf_color_by_alpha_sse2(src, src_format, dst);
17301730
return 0;
17311731
}
17321732
#endif /* PG_ENABLE_ARM_NEON */

src_c/simd_blitters.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ premul_surf_color_by_alpha_non_simd(SDL_Surface *src,
5555
PG_PixelFormat *dst_format,
5656
SDL_Palette *dst_palette);
5757
void
58-
premul_surf_color_by_alpha_sse2(SDL_Surface *src, SDL_Surface *dst);
58+
premul_surf_color_by_alpha_sse2(SDL_Surface *src, PG_PixelFormat *srcfmt,
59+
SDL_Surface *dst);
5960

6061
void
6162
alphablit_alpha_avx2_argb_no_surf_alpha_opaque_dst(SDL_BlitInfo *info);
@@ -86,4 +87,5 @@ blit_blend_rgb_min_avx2(SDL_BlitInfo *info);
8687
void
8788
blit_blend_premultiplied_avx2(SDL_BlitInfo *info);
8889
void
89-
premul_surf_color_by_alpha_avx2(SDL_Surface *src, SDL_Surface *dst);
90+
premul_surf_color_by_alpha_avx2(SDL_Surface *src, PG_PixelFormat *src_format,
91+
SDL_Surface *dst);

src_c/simd_blitters_avx2.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,8 @@ blit_blend_premultiplied_avx2(SDL_BlitInfo *info)
15611561
#if defined(__AVX2__) && defined(HAVE_IMMINTRIN_H) && \
15621562
!defined(SDL_DISABLE_IMMINTRIN_H)
15631563
void
1564-
premul_surf_color_by_alpha_avx2(SDL_Surface *src, SDL_Surface *dst)
1564+
premul_surf_color_by_alpha_avx2(SDL_Surface *src, PG_PixelFormat *src_format,
1565+
SDL_Surface *dst)
15651566
{
15661567
int i, height = src->h;
15671568
const int width = src->w;
@@ -1578,7 +1579,7 @@ premul_surf_color_by_alpha_avx2(SDL_Surface *src, SDL_Surface *dst)
15781579
__m256i mm_src, mm_dst, alphaA, alphaB, mm_alpha_in;
15791580
__m256i mm_srcA, mm_srcB;
15801581

1581-
const __m256i mm256_amask = _mm256_set1_epi32(src->format->Amask);
1582+
const __m256i mm256_amask = _mm256_set1_epi32(src_format->Amask);
15821583
const __m256i mm_zero = _mm256_setzero_si256();
15831584
const __m256i partial_mask =
15841585
_mm256_set_epi32(0, pxl_excess > 6 ? -1 : 0, pxl_excess > 5 ? -1 : 0,
@@ -1587,10 +1588,10 @@ premul_surf_color_by_alpha_avx2(SDL_Surface *src, SDL_Surface *dst)
15871588
pxl_excess > 0 ? -1 : 0);
15881589
const __m256i mm256_ones = _mm256_set1_epi16(0x0001);
15891590

1590-
char _a_off = ((src->format->Amask >> 8) == 0) ? 0
1591-
: ((src->format->Amask >> 16) == 0) ? 1
1592-
: ((src->format->Amask >> 24) == 0) ? 2
1593-
: 3;
1591+
char _a_off = ((src_format->Amask >> 8) == 0) ? 0
1592+
: ((src_format->Amask >> 16) == 0) ? 1
1593+
: ((src_format->Amask >> 24) == 0) ? 2
1594+
: 3;
15941595

15951596
/* masks for shuffling the alpha to the RGB channels for multiplication */
15961597
const __m256i shuffle_maskA = _mm256_set_epi8(
@@ -1637,7 +1638,8 @@ premul_surf_color_by_alpha_avx2(SDL_Surface *src, SDL_Surface *dst)
16371638
}
16381639
#else
16391640
void
1640-
premul_surf_color_by_alpha_avx2(SDL_Surface *src, SDL_Surface *dst)
1641+
premul_surf_color_by_alpha_avx2(SDL_Surface *src, PG_PixelFormat *src_format,
1642+
SDL_Surface *dst)
16411643
{
16421644
BAD_AVX2_FUNCTION_CALL;
16431645
}

src_c/simd_blitters_sse2.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ alphablit_alpha_sse2_argb_surf_alpha(SDL_BlitInfo *info)
151151
Uint32 *dstp = (Uint32 *)info->d_pixels;
152152
int dstskip = info->d_skip >> 2;
153153

154-
SDL_PixelFormat *srcfmt = info->src;
155-
SDL_PixelFormat *dstfmt = info->dst;
154+
PG_PixelFormat *srcfmt = info->src;
155+
PG_PixelFormat *dstfmt = info->dst;
156156

157157
// int srcbpp = PG_FORMAT_BytesPerPixel(srcfmt);
158158
// int dstbpp = PG_FORMAT_BytesPerPixel(dstfmt);
@@ -293,8 +293,8 @@ alphablit_alpha_sse2_argb_no_surf_alpha(SDL_BlitInfo *info)
293293
int height = info->height;
294294
int srcskip = info->s_skip >> 2;
295295
int dstskip = info->d_skip >> 2;
296-
SDL_PixelFormat *srcfmt = info->src;
297-
SDL_PixelFormat *dstfmt = info->dst;
296+
PG_PixelFormat *srcfmt = info->src;
297+
PG_PixelFormat *dstfmt = info->dst;
298298

299299
/* Original 'Straight Alpha' blending equation:
300300
--------------------------------------------
@@ -719,7 +719,7 @@ blit_blend_premultiplied_sse2(SDL_BlitInfo *info)
719719
int srcskip = info->s_skip >> 2;
720720
Uint32 *dstp = (Uint32 *)info->d_pixels;
721721
int dstskip = info->d_skip >> 2;
722-
SDL_PixelFormat *srcfmt = info->src;
722+
PG_PixelFormat *srcfmt = info->src;
723723
Uint32 amask = srcfmt->Amask;
724724
// Uint64 multmask;
725725
Uint64 ones;
@@ -787,15 +787,14 @@ blit_blend_premultiplied_sse2(SDL_BlitInfo *info)
787787
}
788788

789789
void
790-
premul_surf_color_by_alpha_sse2(SDL_Surface *src, SDL_Surface *dst)
790+
premul_surf_color_by_alpha_sse2(SDL_Surface *src, PG_PixelFormat *srcfmt,
791+
SDL_Surface *dst)
791792
{
792793
int n;
793794
int width = src->w;
794795
int height = src->h;
795796
Uint32 *srcp = (Uint32 *)src->pixels;
796797
Uint32 *dstp = (Uint32 *)dst->pixels;
797-
798-
SDL_PixelFormat *srcfmt = src->format;
799798
Uint32 amask = srcfmt->Amask;
800799
Uint64 ones;
801800

0 commit comments

Comments
 (0)