29 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
30 #ifndef SDL_BIG_ENDIAN
31 #include <SDL_endian.h>
37 #include <immintrin.h>
45 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
46 const size_t sz =
mColors.size();
47 if ((sz == 0U) || (pixels ==
nullptr))
52 for (
const uint32_t *
const p_end = pixels +
CAST_SIZE(bufSize);
56 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(pixels);
57 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
58 const unsigned int data = (*pixels) & 0xffffff00;
61 const unsigned int data = (*pixels) & 0x00ffffff;
64 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
71 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
72 const unsigned int coldata = (col.
value[0] << 24)
76 const unsigned int coldata = (col.
value[0])
106 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
107 const size_t sz =
mColors.size();
108 if ((sz == 0U) || (pixels ==
nullptr))
113 const int mod = bufSize % 4;
114 const int bufEnd = bufSize - mod;
116 for (
int ptr = 0; ptr < bufEnd; ptr += 4)
118 __m128i mask = _mm_set1_epi32(0x00ffffff);
121 __m128i
base = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(
124 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
131 __m128i base2 = _mm_and_si128(mask,
base);
132 __m128i newMask = _mm_set1_epi32(col2.
valueSOgl);
133 __m128i cmpMask = _mm_set1_epi32(col.
valueSOgl);
134 __m128i cmpRes = _mm_cmpeq_epi32(base2, cmpMask);
135 cmpRes = _mm_and_si128(mask, cmpRes);
136 __m128i srcAnd = _mm_andnot_si128(cmpRes,
base);
137 __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
138 base = _mm_or_si128(srcAnd, dstAnd);
142 _mm_storeu_si128(
reinterpret_cast<__m128i*
>(&pixels[ptr]),
base);
145 for (
int ptr = bufSize - mod; ptr < bufSize; ptr ++)
147 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(&pixels[ptr]);
148 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
149 const unsigned int data = pixels[ptr] & 0xffffff00;
152 const unsigned int data = pixels[ptr] & 0x00ffffff;
155 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
162 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
163 const unsigned int coldata = (col.
value[0] << 24)
167 const unsigned int coldata = (col.
value[0])
173 p[0] = col2.
value[0];
174 p[1] = col2.
value[1];
175 p[2] = col2.
value[2];
188 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
189 const size_t sz =
mColors.size();
190 if ((sz == 0U) || (pixels ==
nullptr))
195 const int mod = bufSize % 8;
196 const int bufEnd = bufSize - mod;
198 for (
int ptr = 0; ptr < bufEnd; ptr += 8)
200 __m256i mask = _mm256_set1_epi32(0x00ffffff);
203 __m256i
base = _mm256_loadu_si256(
reinterpret_cast<__m256i*
>(
206 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
213 __m256i base2 = _mm256_and_si256(mask,
base);
214 __m256i newMask = _mm256_set1_epi32(col2.
valueSOgl);
215 __m256i cmpMask = _mm256_set1_epi32(col.
valueSOgl);
216 __m256i cmpRes = _mm256_cmpeq_epi32(base2, cmpMask);
217 cmpRes = _mm256_and_si256(mask, cmpRes);
218 __m256i srcAnd = _mm256_andnot_si256(cmpRes,
base);
219 __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
220 base = _mm256_or_si256(srcAnd, dstAnd);
225 _mm256_storeu_si256(
reinterpret_cast<__m256i*
>(&pixels[ptr]),
229 for (
int ptr = bufSize - mod; ptr < bufSize; ptr ++)
231 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(&pixels[ptr]);
232 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
233 const unsigned int data = pixels[ptr] & 0xffffff00;
236 const unsigned int data = pixels[ptr] & 0x00ffffff;
239 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
246 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
247 const unsigned int coldata = (col.
value[0] << 24)
251 const unsigned int coldata = (col.
value[0])
257 p[0] = col2.
value[0];
258 p[1] = col2.
value[1];
259 p[2] = col2.
value[2];
void replaceSOGLColorDefault(uint32_t *pixels, const int bufSize) const
union EAthena::ItemFlags __attribute__((packed))
std::map< std::string, DyeColor > mColors