Skip to content

Commit 09651b6

Browse files
committed
Get surface_fill system compiling SDL3
1 parent 32453be commit 09651b6

File tree

4 files changed

+249
-223
lines changed

4 files changed

+249
-223
lines changed

src_c/simd_fill.h

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,64 +40,84 @@ _pg_HasSSE_NEON();
4040

4141
// AVX2 functions
4242
int
43-
surface_fill_blend_add_avx2(SDL_Surface *surface, SDL_Rect *rect,
43+
surface_fill_blend_add_avx2(SDL_Surface *surface,
44+
PG_PixelFormat *surface_format, SDL_Rect *rect,
4445
Uint32 color);
4546
int
46-
surface_fill_blend_rgba_add_avx2(SDL_Surface *surface, SDL_Rect *rect,
47-
Uint32 color);
47+
surface_fill_blend_rgba_add_avx2(SDL_Surface *surface,
48+
PG_PixelFormat *surface_format,
49+
SDL_Rect *rect, Uint32 color);
4850

4951
int
50-
surface_fill_blend_sub_avx2(SDL_Surface *surface, SDL_Rect *rect,
52+
surface_fill_blend_sub_avx2(SDL_Surface *surface,
53+
PG_PixelFormat *surface_format, SDL_Rect *rect,
5154
Uint32 color);
5255
int
53-
surface_fill_blend_rgba_sub_avx2(SDL_Surface *surface, SDL_Rect *rect,
54-
Uint32 color);
56+
surface_fill_blend_rgba_sub_avx2(SDL_Surface *surface,
57+
PG_PixelFormat *surface_format,
58+
SDL_Rect *rect, Uint32 color);
5559
int
56-
surface_fill_blend_mult_avx2(SDL_Surface *surface, SDL_Rect *rect,
60+
surface_fill_blend_mult_avx2(SDL_Surface *surface,
61+
PG_PixelFormat *surface_format, SDL_Rect *rect,
5762
Uint32 color);
5863
int
59-
surface_fill_blend_rgba_mult_avx2(SDL_Surface *surface, SDL_Rect *rect,
60-
Uint32 color);
64+
surface_fill_blend_rgba_mult_avx2(SDL_Surface *surface,
65+
PG_PixelFormat *surface_format,
66+
SDL_Rect *rect, Uint32 color);
6167
int
62-
surface_fill_blend_min_avx2(SDL_Surface *surface, SDL_Rect *rect,
68+
surface_fill_blend_min_avx2(SDL_Surface *surface,
69+
PG_PixelFormat *surface_format, SDL_Rect *rect,
6370
Uint32 color);
6471
int
65-
surface_fill_blend_rgba_min_avx2(SDL_Surface *surface, SDL_Rect *rect,
66-
Uint32 color);
72+
surface_fill_blend_rgba_min_avx2(SDL_Surface *surface,
73+
PG_PixelFormat *surface_format,
74+
SDL_Rect *rect, Uint32 color);
6775
int
68-
surface_fill_blend_max_avx2(SDL_Surface *surface, SDL_Rect *rect,
76+
surface_fill_blend_max_avx2(SDL_Surface *surface,
77+
PG_PixelFormat *surface_format, SDL_Rect *rect,
6978
Uint32 color);
7079
int
71-
surface_fill_blend_rgba_max_avx2(SDL_Surface *surface, SDL_Rect *rect,
72-
Uint32 color);
80+
surface_fill_blend_rgba_max_avx2(SDL_Surface *surface,
81+
PG_PixelFormat *surface_format,
82+
SDL_Rect *rect, Uint32 color);
7383
// SSE2 functions
7484
int
75-
surface_fill_blend_add_sse2(SDL_Surface *surface, SDL_Rect *rect,
85+
surface_fill_blend_add_sse2(SDL_Surface *surface,
86+
PG_PixelFormat *surface_format, SDL_Rect *rect,
7687
Uint32 color);
7788
int
78-
surface_fill_blend_rgba_add_sse2(SDL_Surface *surface, SDL_Rect *rect,
79-
Uint32 color);
89+
surface_fill_blend_rgba_add_sse2(SDL_Surface *surface,
90+
PG_PixelFormat *surface_format,
91+
SDL_Rect *rect, Uint32 color);
8092
int
81-
surface_fill_blend_sub_sse2(SDL_Surface *surface, SDL_Rect *rect,
93+
surface_fill_blend_sub_sse2(SDL_Surface *surface,
94+
PG_PixelFormat *surface_format, SDL_Rect *rect,
8295
Uint32 color);
8396
int
84-
surface_fill_blend_rgba_sub_sse2(SDL_Surface *surface, SDL_Rect *rect,
85-
Uint32 color);
97+
surface_fill_blend_rgba_sub_sse2(SDL_Surface *surface,
98+
PG_PixelFormat *surface_format,
99+
SDL_Rect *rect, Uint32 color);
86100
int
87-
surface_fill_blend_mult_sse2(SDL_Surface *surface, SDL_Rect *rect,
101+
surface_fill_blend_mult_sse2(SDL_Surface *surface,
102+
PG_PixelFormat *surface_format, SDL_Rect *rect,
88103
Uint32 color);
89104
int
90-
surface_fill_blend_rgba_mult_sse2(SDL_Surface *surface, SDL_Rect *rect,
91-
Uint32 color);
105+
surface_fill_blend_rgba_mult_sse2(SDL_Surface *surface,
106+
PG_PixelFormat *surface_format,
107+
SDL_Rect *rect, Uint32 color);
92108
int
93-
surface_fill_blend_min_sse2(SDL_Surface *surface, SDL_Rect *rect,
109+
surface_fill_blend_min_sse2(SDL_Surface *surface,
110+
PG_PixelFormat *surface_format, SDL_Rect *rect,
94111
Uint32 color);
95112
int
96-
surface_fill_blend_rgba_min_sse2(SDL_Surface *surface, SDL_Rect *rect,
97-
Uint32 color);
113+
surface_fill_blend_rgba_min_sse2(SDL_Surface *surface,
114+
PG_PixelFormat *surface_format,
115+
SDL_Rect *rect, Uint32 color);
98116
int
99-
surface_fill_blend_max_sse2(SDL_Surface *surface, SDL_Rect *rect,
117+
surface_fill_blend_max_sse2(SDL_Surface *surface,
118+
PG_PixelFormat *surface_format, SDL_Rect *rect,
100119
Uint32 color);
101120
int
102-
surface_fill_blend_rgba_max_sse2(SDL_Surface *surface, SDL_Rect *rect,
103-
Uint32 color);
121+
surface_fill_blend_rgba_max_sse2(SDL_Surface *surface,
122+
PG_PixelFormat *surface_format,
123+
SDL_Rect *rect, Uint32 color);

src_c/simd_surface_fill_avx2.c

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ _pg_has_avx2()
4747
pxl_excess > 2 ? -1 : 0, pxl_excess > 1 ? -1 : 0, \
4848
pxl_excess > 0 ? -1 : 0); \
4949
/* prep and load the color */ \
50-
Uint32 amask = surface->format->Amask; \
50+
Uint32 amask = surface_format->Amask; \
5151
if (amask) { \
5252
{ \
5353
COLOR_PROCESS_CODE \
@@ -105,52 +105,58 @@ _pg_has_avx2()
105105
/* ==== recombine A and B pixels ==== */ \
106106
mm256_dst = _mm256_packus_epi16(_shuff16_temp, shuff_dst);
107107

108-
#define FILLERS(NAME, COLOR_PROCESS_CODE, FILL_CODE) \
109-
int surface_fill_blend_##NAME##_avx2(SDL_Surface *surface, \
110-
SDL_Rect *rect, Uint32 color) \
111-
{ \
112-
SETUP_AVX2_FILLER(COLOR_PROCESS_CODE) \
113-
RUN_AVX2_FILLER(FILL_CODE) \
114-
return 0; \
115-
} \
116-
int surface_fill_blend_rgba_##NAME##_avx2(SDL_Surface *surface, \
117-
SDL_Rect *rect, Uint32 color) \
118-
{ \
119-
SETUP_AVX2_FILLER({}) \
120-
RUN_AVX2_FILLER(FILL_CODE) \
121-
return 0; \
108+
#define FILLERS(NAME, COLOR_PROCESS_CODE, FILL_CODE) \
109+
int surface_fill_blend_##NAME##_avx2(SDL_Surface *surface, \
110+
PG_PixelFormat *surface_format, \
111+
SDL_Rect *rect, Uint32 color) \
112+
{ \
113+
SETUP_AVX2_FILLER(COLOR_PROCESS_CODE) \
114+
RUN_AVX2_FILLER(FILL_CODE) \
115+
return 0; \
116+
} \
117+
int surface_fill_blend_rgba_##NAME##_avx2(SDL_Surface *surface, \
118+
PG_PixelFormat *surface_format, \
119+
SDL_Rect *rect, Uint32 color) \
120+
{ \
121+
SETUP_AVX2_FILLER({}) \
122+
RUN_AVX2_FILLER(FILL_CODE) \
123+
return 0; \
122124
}
123125

124-
#define FILLERS_SHUFF(NAME, COLOR_PROCESS_CODE, FILL_CODE) \
125-
int surface_fill_blend_##NAME##_avx2(SDL_Surface *surface, \
126-
SDL_Rect *rect, Uint32 color) \
127-
{ \
128-
SETUP_AVX2_FILLER(COLOR_PROCESS_CODE) \
129-
SETUP_SHUFFLE \
130-
RUN_AVX2_FILLER(RUN_16BIT_SHUFFLE_OUT(FILL_CODE)) \
131-
return 0; \
132-
} \
133-
int surface_fill_blend_rgba_##NAME##_avx2(SDL_Surface *surface, \
134-
SDL_Rect *rect, Uint32 color) \
135-
{ \
136-
SETUP_AVX2_FILLER({}) \
137-
SETUP_SHUFFLE \
138-
RUN_AVX2_FILLER(RUN_16BIT_SHUFFLE_OUT(FILL_CODE)) \
139-
return 0; \
126+
#define FILLERS_SHUFF(NAME, COLOR_PROCESS_CODE, FILL_CODE) \
127+
int surface_fill_blend_##NAME##_avx2(SDL_Surface *surface, \
128+
PG_PixelFormat *surface_format, \
129+
SDL_Rect *rect, Uint32 color) \
130+
{ \
131+
SETUP_AVX2_FILLER(COLOR_PROCESS_CODE) \
132+
SETUP_SHUFFLE \
133+
RUN_AVX2_FILLER(RUN_16BIT_SHUFFLE_OUT(FILL_CODE)) \
134+
return 0; \
135+
} \
136+
int surface_fill_blend_rgba_##NAME##_avx2(SDL_Surface *surface, \
137+
PG_PixelFormat *surface_format, \
138+
SDL_Rect *rect, Uint32 color) \
139+
{ \
140+
SETUP_AVX2_FILLER({}) \
141+
SETUP_SHUFFLE \
142+
RUN_AVX2_FILLER(RUN_16BIT_SHUFFLE_OUT(FILL_CODE)) \
143+
return 0; \
140144
}
141145

142-
#define INVALID_DEFS(NAME) \
143-
int surface_fill_blend_##NAME##_avx2(SDL_Surface *surface, \
144-
SDL_Rect *rect, Uint32 color) \
145-
{ \
146-
BAD_AVX2_FUNCTION_CALL; \
147-
return -1; \
148-
} \
149-
int surface_fill_blend_rgba_##NAME##_avx2(SDL_Surface *surface, \
150-
SDL_Rect *rect, Uint32 color) \
151-
{ \
152-
BAD_AVX2_FUNCTION_CALL; \
153-
return -1; \
146+
#define INVALID_DEFS(NAME) \
147+
int surface_fill_blend_##NAME##_avx2(SDL_Surface *surface, \
148+
PG_PixelFormat *surface_format, \
149+
SDL_Rect *rect, Uint32 color) \
150+
{ \
151+
BAD_AVX2_FUNCTION_CALL; \
152+
return -1; \
153+
} \
154+
int surface_fill_blend_rgba_##NAME##_avx2(SDL_Surface *surface, \
155+
PG_PixelFormat *surface_format, \
156+
SDL_Rect *rect, Uint32 color) \
157+
{ \
158+
BAD_AVX2_FUNCTION_CALL; \
159+
return -1; \
154160
}
155161

156162
#define ADD_CODE mm256_dst = _mm256_adds_epu8(mm256_dst, mm256_color);

0 commit comments

Comments
 (0)