-
Notifications
You must be signed in to change notification settings - Fork 68
/
BitBltArmSimd.c
437 lines (387 loc) · 35.9 KB
/
BitBltArmSimd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
/*
* Copyright © 2013 Raspberry Pi Foundation
* Copyright © 2013 RISC OS Open Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The copyright holders make no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
*/
#include <stddef.h>
#include <stdint.h>
#include "BitBltInternal.h"
enum {
HALFTONE_NONE,
HALFTONE_SCALAR,
HALFTONE_VECTOR
};
//typedef void (*armSimdAsmFn)(uint32_t width, uint32_t height, uint32_t *dst, uint32_t dstStride, uint32_t *src, uint32_t srcStride, uint32_t halftone, uint32_t halftoneInfo, uint32_t *colourMap, uint32_t bitPtrs, ...);
#define FAST_PATH(op, src_bpp, dst_bpp, qualifier, halftone_type) \
extern void armSimd##op##src_bpp##_##dst_bpp##qualifier##_wide (uint32_t width, uint32_t height, uint32_t *dst, uint32_t dstStride, uint32_t *src, uint32_t srcStride, uint32_t halftone, uint32_t halftoneInfo, uint32_t *colourMap, uint32_t bitPtrs, ...); \
extern void armSimd##op##src_bpp##_##dst_bpp##qualifier##_narrow(uint32_t width, uint32_t height, uint32_t *dst, uint32_t dstStride, uint32_t *src, uint32_t srcStride, uint32_t halftone, uint32_t halftoneInfo, uint32_t *colourMap, uint32_t bitPtrs, ...); \
extern void armSimd##op##src_bpp##_##dst_bpp##qualifier##_tiny (uint32_t width, uint32_t height, uint32_t *dst, uint32_t dstStride, uint32_t *src, uint32_t srcStride, uint32_t halftone, uint32_t halftoneInfo, uint32_t *colourMap, uint32_t bitPtrs, ...); \
static void fastPath##op##src_bpp##_##dst_bpp##qualifier(operation_t *op, uint32_t flags) \
{ \
IGNORE(flags); \
/* Copy certain parts of the operation structure to locals to help compiler */ \
uint32_t *srcBits = op->src.bits; \
uint32_t srcPitch = op->src.pitch / sizeof (uint32_t); \
uint32_t srcX = op->src.x; \
uint32_t srcY = op->src.y; \
uint32_t *dstBits = op->dest.bits; \
uint32_t dstPitch = op->dest.pitch / sizeof (uint32_t); \
uint32_t dstX = op->dest.x; \
uint32_t dstY = op->dest.y; \
uint32_t width = op->width; \
uint32_t height = op->height; \
uint32_t *cmLookupTable = *op->cmLookupTable; \
uint32_t halftoneHeight = op->halftoneHeight; \
uint32_t *halftoneBase = (uint32_t *) *op->halftoneBase; \
/* Get pointers to initial words */ \
uint32_t *src = 0; \
if (src_bpp > 0) \
src = srcBits + srcPitch * srcY + srcX * src_bpp / 32; \
uint32_t *dst = dstBits + dstPitch * dstY + dstX * dst_bpp / 32; \
/* Get initial pixel offset within words, mangle into pitch if possible */ \
uint32_t bitPtrs = 0; \
uint32_t srcXpix = 0; \
if (src_bpp > 0) { \
srcXpix = srcX & (31 / (src_bpp == 0 ? 1 : src_bpp)); /* ?: to avoid compiler warning on GCC! */ \
if (src_bpp < 8) \
bitPtrs = srcXpix << 27; \
else if (src_bpp == 8 || src_bpp == 16) \
srcPitch |= srcXpix << 30; \
} \
uint32_t dstXpix = dstX & (31/dst_bpp); \
if (dst_bpp < 8) \
bitPtrs |= dstXpix; \
else if (dst_bpp == 8 || dst_bpp == 16) \
dstPitch |= dstXpix << 30; \
/* Adjust strides to remove number of words partially or wholly read/written */ \
if (src_bpp > 0) \
srcPitch -= (src_bpp * (srcXpix + width) + 31) / 32; \
dstPitch -= (dst_bpp * (dstXpix + width) + 31) / 32; \
/* Deal with halftoning */ \
uint32_t halftone = 0; \
uint32_t halftoneInfo = 0; \
if (halftone_type == HALFTONE_SCALAR) \
halftone = halftoneBase[0]; \
else if (halftone_type == HALFTONE_VECTOR) { \
halftone = (uint32_t) (halftoneBase + halftoneHeight); \
halftoneInfo = (((dstY % halftoneHeight) - halftoneHeight) << 17) | (-halftoneHeight & 0x7FFF); \
} \
/* Work out which width class this operation is. \
* Rather than re-evaluate this for each line, we want one choice \
* for the whole operation; this means we can't assume anything about \
* alignment to sizes larger than 4 bytes, because that's the only \
* guarantee we have about line stride. */ \
if (width > (128-32)/dst_bpp && (((dstXpix-1) ^ (dstXpix+width-(128-32)/dst_bpp)) &~ (31/dst_bpp))) \
armSimd##op##src_bpp##_##dst_bpp##qualifier##_wide(width, height, dst, dstPitch, src, srcPitch, halftone, halftoneInfo, cmLookupTable, bitPtrs); \
else if (dst_bpp > 8 || (((dstXpix-1) ^ (dstXpix+width)) &~ (31/dst_bpp))) \
armSimd##op##src_bpp##_##dst_bpp##qualifier##_narrow(width, height, dst, dstPitch, src, srcPitch, halftone, halftoneInfo, cmLookupTable, bitPtrs); \
else \
armSimd##op##src_bpp##_##dst_bpp##qualifier##_tiny(width, height, dst, dstPitch, src, srcPitch, halftone, halftoneInfo, cmLookupTable, bitPtrs); \
}
FAST_PATH(SourceWord,1,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,1,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,2,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,1,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,2,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,4,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,1,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,2,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,4,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,8,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,1,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,2,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,4,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,8,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,16,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,1,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,2,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,4,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,8,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,16,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,32,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,2,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,4,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,8,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,16,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,32,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,4,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,8,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,16,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,32,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,8,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,16,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,32,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,16,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,32,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,32,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,1,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,1,_scalar,HALFTONE_SCALAR)
FAST_PATH(SourceWord,0,2,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,2,_scalar,HALFTONE_SCALAR)
FAST_PATH(SourceWord,0,4,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,4,_scalar,HALFTONE_SCALAR)
FAST_PATH(SourceWord,0,8,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,8,_scalar,HALFTONE_SCALAR)
FAST_PATH(SourceWord,0,16,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,16,_scalar,HALFTONE_SCALAR)
FAST_PATH(SourceWord,0,32,,HALFTONE_NONE)
FAST_PATH(SourceWord,0,32,_scalar,HALFTONE_SCALAR)
FAST_PATH(PixPaint,1,1,,HALFTONE_NONE)
FAST_PATH(PixPaint,2,2,,HALFTONE_NONE)
FAST_PATH(PixPaint,4,4,,HALFTONE_NONE)
FAST_PATH(PixPaint,8,8,,HALFTONE_NONE)
FAST_PATH(PixPaint,16,16,,HALFTONE_NONE)
FAST_PATH(PixPaint,32,32,,HALFTONE_NONE)
FAST_PATH(AlphaBlend,32,32,,HALFTONE_NONE)
FAST_PATH(BitAnd,1,1,,HALFTONE_NONE)
FAST_PATH(BitAnd,2,2,,HALFTONE_NONE)
FAST_PATH(BitAnd,4,4,,HALFTONE_NONE)
FAST_PATH(BitAnd,8,8,,HALFTONE_NONE)
FAST_PATH(BitAnd,16,16,,HALFTONE_NONE)
FAST_PATH(BitAnd,32,32,,HALFTONE_NONE)
static fast_path_t fastPaths[] = {
{ fastPathSourceWord1_32, CR_sourceWord, STD_FLAGS(1,32,DIRECT,NO) },
{ fastPathSourceWord1_16, CR_sourceWord, STD_FLAGS(1,16,DIRECT,NO) },
{ fastPathSourceWord2_32, CR_sourceWord, STD_FLAGS(2,32,DIRECT,NO) },
{ fastPathSourceWord1_8, CR_sourceWord, STD_FLAGS(1,8,DIRECT,NO) },
{ fastPathSourceWord2_16, CR_sourceWord, STD_FLAGS(2,16,DIRECT,NO) },
{ fastPathSourceWord4_32, CR_sourceWord, STD_FLAGS(4,32,DIRECT,NO) },
{ fastPathSourceWord1_4, CR_sourceWord, STD_FLAGS(1,4,DIRECT,NO) },
{ fastPathSourceWord2_8, CR_sourceWord, STD_FLAGS(2,8,DIRECT,NO) },
{ fastPathSourceWord4_16, CR_sourceWord, STD_FLAGS(4,16,DIRECT,NO) },
{ fastPathSourceWord8_32, CR_sourceWord, STD_FLAGS(8,32,DIRECT,NO) },
{ fastPathSourceWord1_2, CR_sourceWord, STD_FLAGS(1,2,DIRECT,NO) },
{ fastPathSourceWord2_4, CR_sourceWord, STD_FLAGS(2,4,DIRECT,NO) },
{ fastPathSourceWord4_8, CR_sourceWord, STD_FLAGS(4,8,DIRECT,NO) },
{ fastPathSourceWord8_16, CR_sourceWord, STD_FLAGS(8,16,DIRECT,NO) },
{ fastPathSourceWord16_32, CR_sourceWord, STD_FLAGS(16,32,NO,NO) },
{ fastPathSourceWord1_1, CR_sourceWord, STD_FLAGS(1,1,NO,NO) },
{ fastPathSourceWord2_2, CR_sourceWord, STD_FLAGS(2,2,NO,NO) },
{ fastPathSourceWord4_4, CR_sourceWord, STD_FLAGS(4,4,NO,NO) },
{ fastPathSourceWord8_8, CR_sourceWord, STD_FLAGS(8,8,NO,NO) },
{ fastPathSourceWord16_16, CR_sourceWord, STD_FLAGS(16,16,NO,NO) },
{ fastPathSourceWord32_32, CR_sourceWord, STD_FLAGS(32,32,NO,NO) },
{ fastPathSourceWord2_1, CR_sourceWord, STD_FLAGS(2,1,DIRECT,NO) },
{ fastPathSourceWord4_2, CR_sourceWord, STD_FLAGS(4,2,DIRECT,NO) },
{ fastPathSourceWord8_4, CR_sourceWord, STD_FLAGS(8,4,DIRECT,NO) },
{ fastPathSourceWord16_8, CR_sourceWord, STD_FLAGS(16,8,DIRECT,NO) },
{ fastPathSourceWord32_16, CR_sourceWord, STD_FLAGS(32,16,NO,NO) },
{ fastPathSourceWord4_1, CR_sourceWord, STD_FLAGS(4,1,DIRECT,NO) },
{ fastPathSourceWord8_2, CR_sourceWord, STD_FLAGS(8,2,DIRECT,NO) },
{ fastPathSourceWord16_4, CR_sourceWord, STD_FLAGS(16,4,DIRECT,NO) },
{ fastPathSourceWord32_8, CR_sourceWord, STD_FLAGS(32,8,15BIT,NO) },
{ fastPathSourceWord8_1, CR_sourceWord, STD_FLAGS(8,1,DIRECT,NO) },
{ fastPathSourceWord16_2, CR_sourceWord, STD_FLAGS(16,2,DIRECT,NO) },
{ fastPathSourceWord32_4, CR_sourceWord, STD_FLAGS(32,4,15BIT,NO) },
{ fastPathSourceWord16_1, CR_sourceWord, STD_FLAGS(16,1,DIRECT,NO) },
{ fastPathSourceWord32_2, CR_sourceWord, STD_FLAGS(32,2,15BIT,NO) },
{ fastPathSourceWord32_1, CR_sourceWord, STD_FLAGS(32,1,15BIT,NO) },
{ fastPathSourceWord0_1, CR_sourceWord, STD_FLAGS_NO_SOURCE(1,NO) },
{ fastPathSourceWord0_1_scalar, CR_sourceWord, STD_FLAGS_NO_SOURCE(1,SCALAR) },
{ fastPathSourceWord0_2, CR_sourceWord, STD_FLAGS_NO_SOURCE(2,NO) },
{ fastPathSourceWord0_2_scalar, CR_sourceWord, STD_FLAGS_NO_SOURCE(2,SCALAR) },
{ fastPathSourceWord0_4, CR_sourceWord, STD_FLAGS_NO_SOURCE(4,NO) },
{ fastPathSourceWord0_4_scalar, CR_sourceWord, STD_FLAGS_NO_SOURCE(4,SCALAR) },
{ fastPathSourceWord0_8, CR_sourceWord, STD_FLAGS_NO_SOURCE(8,NO) },
{ fastPathSourceWord0_8_scalar, CR_sourceWord, STD_FLAGS_NO_SOURCE(8,SCALAR) },
{ fastPathSourceWord0_16, CR_sourceWord, STD_FLAGS_NO_SOURCE(16,NO) },
{ fastPathSourceWord0_16_scalar, CR_sourceWord, STD_FLAGS_NO_SOURCE(16,SCALAR) },
{ fastPathSourceWord0_32, CR_sourceWord, STD_FLAGS_NO_SOURCE(32,NO) },
{ fastPathSourceWord0_32_scalar, CR_sourceWord, STD_FLAGS_NO_SOURCE(32,SCALAR) },
{ fastPathPixPaint1_1, CR_pixPaint, STD_FLAGS(1,1,NO,NO) },
{ fastPathPixPaint2_2, CR_pixPaint, STD_FLAGS(2,2,NO,NO) },
{ fastPathPixPaint4_4, CR_pixPaint, STD_FLAGS(4,4,NO,NO) },
{ fastPathPixPaint8_8, CR_pixPaint, STD_FLAGS(8,8,NO,NO) },
{ fastPathPixPaint16_16, CR_pixPaint, STD_FLAGS(16,16,NO,NO) },
{ fastPathPixPaint32_32, CR_pixPaint, STD_FLAGS(32,32,NO,NO) },
{ fastPathAlphaBlend32_32, CR_alphaBlend, STD_FLAGS(32,32,NO,NO) },
{ fastPathBitAnd1_1, CR_bitAnd, STD_FLAGS(1,1,NO,NO) },
{ fastPathBitAnd2_2, CR_bitAnd, STD_FLAGS(2,2,NO,NO) },
{ fastPathBitAnd4_4, CR_bitAnd, STD_FLAGS(4,4,NO,NO) },
{ fastPathBitAnd8_8, CR_bitAnd, STD_FLAGS(8,8,NO,NO) },
{ fastPathBitAnd16_16, CR_bitAnd, STD_FLAGS(16,16,NO,NO) },
{ fastPathBitAnd32_32, CR_bitAnd, STD_FLAGS(32,32,NO,NO) },
};
#define TALLY_FAST_PATH(op, srcA_bpp, srcB_bpp) \
extern uint32_t armSimd##op##Tally##srcB_bpp##_##srcA_bpp##_wide (uint32_t width, uint32_t height, const uint32_t *srcA, uint32_t srcAStride, const uint32_t *srcB, uint32_t srcBStride, uint32_t colorA, uint32_t colorB, void *unused, uint32_t bitPtrs); \
extern uint32_t armSimd##op##Tally##srcB_bpp##_##srcA_bpp##_narrow(uint32_t width, uint32_t height, const uint32_t *srcA, uint32_t srcAStride, const uint32_t *srcB, uint32_t srcBStride, uint32_t colorA, uint32_t colorB, void *unused, uint32_t bitPtrs); \
extern uint32_t armSimd##op##Tally##srcB_bpp##_##srcA_bpp##_tiny (uint32_t width, uint32_t height, const uint32_t *srcA, uint32_t srcAStride, const uint32_t *srcB, uint32_t srcBStride, uint32_t colorA, uint32_t colorB, void *unused, uint32_t bitPtrs); \
static uint32_t tallyFastPath##op##srcA_bpp##_##srcB_bpp(const compare_operation_t *op, uint32_t log2bppA, uint32_t log2bppB) \
{ \
IGNORE(log2bppA); \
IGNORE(log2bppB); \
COPY_COMPARE_OP_TO_LOCALS(op, uint32_t, uint32_t); \
/* Get pointers to initial words */ \
const uint32_t *srcA = srcABits + srcAPitch * srcAY + srcAX * srcA_bpp / 32; \
const uint32_t *srcB = srcBBits + srcBPitch * srcBY + srcBX * srcB_bpp / 32; \
/* Get initial pixel offset within words, mangle into pitch if possible */ \
uint32_t bitPtrs = 0; \
uint32_t srcAXpix = srcAX & (31 / srcA_bpp); \
if (srcA_bpp < 8) \
bitPtrs = srcAXpix; \
else if (srcA_bpp == 8 || srcA_bpp == 16) \
srcAPitch |= srcAXpix << 30; \
uint32_t srcBXpix = srcBX & (31 / srcB_bpp); \
if (srcB_bpp < 8) \
bitPtrs |= srcBXpix << 27; \
else if (srcB_bpp == 8 || srcB_bpp == 16) \
srcBPitch |= srcBXpix << 30; \
/* Adjust strides to remove number of words partially or wholly read/written */ \
srcAPitch -= (srcA_bpp * (srcAXpix + width) + 31) / 32; \
srcBPitch -= (srcB_bpp * (srcBXpix + width) + 31) / 32; \
/* Work out which width class this operation is. \
* Rather than re-evaluate this for each line, we want one choice \
* for the whole operation; this means we can't assume anything about \
* alignment to sizes larger than 4 bytes, because that's the only \
* guarantee we have about line stride. */ \
if (width > (128-32)/srcA_bpp && (((srcAXpix-1) ^ (srcAXpix+width-(128-32)/srcA_bpp)) &~ (31/srcA_bpp))) \
return armSimd##op##Tally##srcB_bpp##_##srcA_bpp##_wide(width, height, srcA, srcAPitch, srcB, srcBPitch, colorA, colorB, 0, bitPtrs); \
else if (srcA_bpp > 8 || (((srcAXpix-1) ^ (srcAXpix+width)) &~ (31/srcA_bpp))) \
return armSimd##op##Tally##srcB_bpp##_##srcA_bpp##_narrow(width, height, srcA, srcAPitch, srcB, srcBPitch, colorA, colorB, 0, bitPtrs); \
else \
return armSimd##op##Tally##srcB_bpp##_##srcA_bpp##_tiny(width, height, srcA, srcAPitch, srcB, srcBPitch, colorA, colorB, 0, bitPtrs); \
}
#define TEST_FAST_PATH(op, srcA_bpp, srcB_bpp) \
extern uint32_t armSimd##op##Test##srcB_bpp##_##srcA_bpp##_wide (uint32_t width, uint32_t height, const uint32_t *srcA, uint32_t srcAStride, const uint32_t *srcB, uint32_t srcBStride, uint32_t colorA, uint32_t colorB, void *unused, uint32_t bitPtrs); \
extern uint32_t armSimd##op##Test##srcB_bpp##_##srcA_bpp##_narrow(uint32_t width, uint32_t height, const uint32_t *srcA, uint32_t srcAStride, const uint32_t *srcB, uint32_t srcBStride, uint32_t colorA, uint32_t colorB, void *unused, uint32_t bitPtrs); \
extern uint32_t armSimd##op##Test##srcB_bpp##_##srcA_bpp##_tiny (uint32_t width, uint32_t height, const uint32_t *srcA, uint32_t srcAStride, const uint32_t *srcB, uint32_t srcBStride, uint32_t colorA, uint32_t colorB, void *unused, uint32_t bitPtrs); \
static uint32_t testFastPath##op##srcA_bpp##_##srcB_bpp(const compare_operation_t *op, uint32_t log2bppA, uint32_t log2bppB) \
{ \
IGNORE(log2bppA); \
IGNORE(log2bppB); \
COPY_COMPARE_OP_TO_LOCALS(op, uint32_t, uint32_t); \
/* Early termination is most likely in the centre, so start from the */ \
/* middle and work outwards */ \
const uint32_t *srcAUp = srcABits + srcAPitch * (srcAY + (height >> 1)) + srcAX * srcA_bpp / 32; \
const uint32_t *srcBUp = srcBBits + srcBPitch * (srcBY + (height >> 1)) + srcBX * srcB_bpp / 32; \
const uint32_t *srcADown = srcAUp; \
const uint32_t *srcBDown = srcBUp; \
/* Get initial pixel offset within words, mangle into pitch if possible */ \
uint32_t bitPtrs = 0; \
uint32_t srcAXpix = srcAX & (31 / srcA_bpp); \
if (srcA_bpp < 8) \
bitPtrs = srcAXpix; \
else if (srcA_bpp == 8 || srcA_bpp == 16) \
srcAPitch |= srcAXpix << 30; \
uint32_t srcBXpix = srcBX & (31 / srcB_bpp); \
if (srcB_bpp < 8) \
bitPtrs |= srcBXpix << 27; \
else if (srcB_bpp == 8 || srcB_bpp == 16) \
srcBPitch |= srcBXpix << 30; \
/* Work out which width class this operation is. */ \
/* Rather than re-evaluate this for each line, we want one choice for the */ \
/* whole operation; this means we can't assume anything about alignment */ \
/* to sizes larger than 4 bytes, because that's the only guarantee we */ \
/* have about line stride. */ \
uint32_t (*testRow)(uint32_t, uint32_t, const uint32_t *, uint32_t, const uint32_t *, uint32_t, uint32_t, uint32_t, void *, uint32_t); \
if (width > (128-32)/srcA_bpp && (((srcAXpix-1) ^ (srcAXpix+width-(128-32)/srcA_bpp)) &~ (31/srcA_bpp))) \
testRow = armSimd##op##Test##srcB_bpp##_##srcA_bpp##_wide; \
else if (srcA_bpp > 8 || (((srcAXpix-1) ^ (srcAXpix+width)) &~ (31/srcA_bpp))) \
testRow = armSimd##op##Test##srcB_bpp##_##srcA_bpp##_narrow; \
else \
testRow = armSimd##op##Test##srcB_bpp##_##srcA_bpp##_tiny; \
if (height & 1) \
{ \
height++; \
goto odd_number_of_rows_remain; \
} \
while (height != 0) \
{ \
srcADown -= srcAPitch; \
srcBDown -= srcBPitch; \
if (testRow(width, 1, srcADown, srcAPitch, srcBDown, srcBPitch, colorA, colorB, 0, bitPtrs)) \
return 1; \
odd_number_of_rows_remain: \
if (testRow(width, 1, srcAUp, srcAPitch, srcBUp, srcBPitch, colorA, colorB, 0, bitPtrs)) \
return 1; \
srcAUp += srcAPitch; \
srcBUp += srcBPitch; \
height -= 2; \
} \
return 0; \
}
#define ADD_TALLY_FN(op, srcA_bpp, srcB_bpp) \
do { compareColorsFns[(((MR_##op * 2) + 1) * 3 + \
(srcA_bpp == 8 ? 0 : srcA_bpp == 16 ? 1 : 2)) * 3 + \
(srcB_bpp == 8 ? 0 : srcB_bpp == 16 ? 1 : 2)] = \
tallyFastPath##op##srcA_bpp##_##srcB_bpp; } while(0)
#define ADD_TEST_FN(op, srcA_bpp, srcB_bpp) \
do { compareColorsFns[(((MR_##op * 2) + 0) * 3 + \
(srcA_bpp == 8 ? 0 : srcA_bpp == 16 ? 1 : 2)) * 3 + \
(srcB_bpp == 8 ? 0 : srcB_bpp == 16 ? 1 : 2)] = \
testFastPath##op##srcA_bpp##_##srcB_bpp; } while(0)
TALLY_FAST_PATH(pixelMatch, 32, 32)
TALLY_FAST_PATH(notAnotB, 32, 32)
TALLY_FAST_PATH(notAmatchB, 32, 32)
TEST_FAST_PATH(pixelMatch, 32, 32)
TEST_FAST_PATH(notAnotB, 32, 32)
TEST_FAST_PATH(notAmatchB, 32, 32)
TALLY_FAST_PATH(pixelMatch, 16, 16)
TALLY_FAST_PATH(notAnotB, 16, 16)
TALLY_FAST_PATH(notAmatchB, 16, 16)
TEST_FAST_PATH(pixelMatch, 16, 16)
TEST_FAST_PATH(notAnotB, 16, 16)
TEST_FAST_PATH(notAmatchB, 16, 16)
TALLY_FAST_PATH(pixelMatch, 16, 32)
TALLY_FAST_PATH(notAnotB, 16, 32)
TALLY_FAST_PATH(notAmatchB, 16, 32)
TEST_FAST_PATH(pixelMatch, 16, 32)
TEST_FAST_PATH(notAnotB, 16, 32)
TEST_FAST_PATH(notAmatchB, 16, 32)
TALLY_FAST_PATH(notAmatchB, 32, 16)
TEST_FAST_PATH(notAmatchB, 32, 16)
TALLY_FAST_PATH(pixelMatch, 8, 8)
TALLY_FAST_PATH(notAnotB, 8, 8)
TALLY_FAST_PATH(notAmatchB, 8, 8)
TEST_FAST_PATH(pixelMatch, 8, 8)
TEST_FAST_PATH(notAnotB, 8, 8)
TEST_FAST_PATH(notAmatchB, 8, 8)
void addArmSimdFastPaths(void)
{
addFastPaths(fastPaths, sizeof fastPaths / sizeof *fastPaths);
ADD_TALLY_FN(pixelMatch, 32, 32);
ADD_TALLY_FN(notAnotB, 32, 32);
ADD_TALLY_FN(notAmatchB, 32, 32);
ADD_TEST_FN(pixelMatch, 32, 32);
ADD_TEST_FN(notAnotB, 32, 32);
ADD_TEST_FN(notAmatchB, 32, 32);
ADD_TALLY_FN(pixelMatch, 16, 16);
ADD_TALLY_FN(notAnotB, 16, 16);
ADD_TALLY_FN(notAmatchB, 16, 16);
ADD_TEST_FN(pixelMatch, 16, 16);
ADD_TEST_FN(notAnotB, 16, 16);
ADD_TEST_FN(notAmatchB, 16, 16);
ADD_TALLY_FN(pixelMatch, 16, 32);
ADD_TALLY_FN(notAnotB, 16, 32);
ADD_TALLY_FN(notAmatchB, 16, 32);
ADD_TEST_FN(pixelMatch, 16, 32);
ADD_TEST_FN(notAnotB, 16, 32);
ADD_TEST_FN(notAmatchB, 16, 32);
ADD_TALLY_FN(notAmatchB, 32, 16);
ADD_TEST_FN(notAmatchB, 32, 16);
ADD_TALLY_FN(pixelMatch, 8, 8);
ADD_TALLY_FN(notAnotB, 8, 8);
ADD_TALLY_FN(notAmatchB, 8, 8);
ADD_TEST_FN(pixelMatch, 8, 8);
ADD_TEST_FN(notAnotB, 8, 8);
ADD_TEST_FN(notAmatchB, 8, 8);
}