summaryrefslogtreecommitdiff
path: root/src/resources/dye
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/dye')
-rw-r--r--src/resources/dye/dye_unittest.cc245
-rw-r--r--src/resources/dye/dyepalette.cpp12
-rw-r--r--src/resources/dye/dyepalette.h43
-rw-r--r--src/resources/dye/dyepalette_replaceacolor.cpp259
-rw-r--r--src/resources/dye/dyepalette_replaceacolor_avx2.hpp85
-rw-r--r--src/resources/dye/dyepalette_replaceacolor_default.hpp109
-rw-r--r--src/resources/dye/dyepalette_replaceacolor_sse2.hpp85
7 files changed, 262 insertions, 576 deletions
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
index 6d6e6028e..b9831d087 100644
--- a/src/resources/dye/dye_unittest.cc
+++ b/src/resources/dye/dye_unittest.cc
@@ -1208,7 +1208,7 @@ TEST_CASE("Dye replaceAColor 1 1", "")
DyePalette palette("#00ff0010,00001120", 8);
uint32_t data[1];
data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceAColor(&data[0], 1);
+ DYEPALETTE(palette, AColor)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}
@@ -1217,7 +1217,7 @@ TEST_CASE("Dye replaceAColor 1 2", "")
DyePalette palette("#02ff0120,040311ff", 8);
uint32_t data[1];
data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- palette.replaceAColor(&data[0], 1);
+ DYEPALETTE(palette, AColor)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}
@@ -1226,7 +1226,7 @@ TEST_CASE("Dye replaceAColor 1 3", "")
DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
uint32_t data[1];
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColor(&data[0], 1);
+ DYEPALETTE(palette, AColor)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}
@@ -1236,7 +1236,7 @@ TEST_CASE("Dye replaceAColor 2 1", "")
uint32_t data[2];
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColor(&data[0], 2);
+ DYEPALETTE(palette, AColor)(&data[0], 2);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}
@@ -1248,7 +1248,7 @@ TEST_CASE("Dye replaceAColor 3 1", "")
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColor(&data[0], 3);
+ DYEPALETTE(palette, AColor)(&data[0], 3);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
@@ -1262,7 +1262,7 @@ TEST_CASE("Dye replaceAColor 4 1", "")
data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColor(&data[0], 4);
+ DYEPALETTE(palette, AColor)(&data[0], 4);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1278,7 +1278,7 @@ TEST_CASE("Dye replaceAColor 5 1", "")
data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColor(&data[0], 5);
+ DYEPALETTE(palette, AColor)(&data[0], 5);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1297,7 +1297,7 @@ TEST_CASE("Dye replaceAColor 7 1", "")
data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- palette.replaceAColor(&data[0], 7);
+ DYEPALETTE(palette, AColor)(&data[0], 7);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1319,7 +1319,7 @@ TEST_CASE("Dye replaceAColor 8 1", "")
data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColor(&data[0], 8);
+ DYEPALETTE(palette, AColor)(&data[0], 8);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1343,7 +1343,7 @@ TEST_CASE("Dye replaceAColor 9 1", "")
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColor(&data[0], 9);
+ DYEPALETTE(palette, AColor)(&data[0], 9);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1369,7 +1369,7 @@ TEST_CASE("Dye replaceAColor 10 1", "")
data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColor(&data[0], 10);
+ DYEPALETTE(palette, AColor)(&data[0], 10);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1561,191 +1561,12 @@ TEST_CASE("Dye replaceAColor 10 1 default", "")
REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
}
-TEST_CASE("Dye replaceAColor 1 1 simd", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceAColorSimd(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAColor 1 2 simd", "")
-{
- DyePalette palette("#02ff0120,040311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- palette.replaceAColorSimd(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 3 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorSimd(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 2 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSimd(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 3 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[3];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
- data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSimd(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
- REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 4 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSimd(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 5 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[5];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
- data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSimd(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
- REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 7 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[7];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- palette.replaceAColorSimd(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
-}
-
-TEST_CASE("Dye replaceAColor 8 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSimd(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 9 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[9];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSimd(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 10 1 simd", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[10];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorSimd(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
TEST_CASE("Dye replaceAColor 1 1 sse2", "")
{
DyePalette palette("#00ff0010,00001120", 8);
uint32_t data[1];
data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceAColorSse2(&data[0], 1);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}
@@ -1754,7 +1575,7 @@ TEST_CASE("Dye replaceAColor 1 2 sse2", "")
DyePalette palette("#02ff0120,040311ff", 8);
uint32_t data[1];
data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- palette.replaceAColorSse2(&data[0], 1);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}
@@ -1763,7 +1584,7 @@ TEST_CASE("Dye replaceAColor 1 3 sse2", "")
DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
uint32_t data[1];
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorSse2(&data[0], 1);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}
@@ -1773,7 +1594,7 @@ TEST_CASE("Dye replaceAColor 2 1 sse2", "")
uint32_t data[2];
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSse2(&data[0], 2);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 2);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}
@@ -1785,7 +1606,7 @@ TEST_CASE("Dye replaceAColor 3 1 sse2", "")
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSse2(&data[0], 3);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 3);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
@@ -1799,7 +1620,7 @@ TEST_CASE("Dye replaceAColor 4 1 sse2", "")
data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSse2(&data[0], 4);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 4);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1815,7 +1636,7 @@ TEST_CASE("Dye replaceAColor 5 1 sse2", "")
data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSse2(&data[0], 5);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 5);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1834,7 +1655,7 @@ TEST_CASE("Dye replaceAColor 7 1 sse2", "")
data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- palette.replaceAColorSse2(&data[0], 7);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 7);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1856,7 +1677,7 @@ TEST_CASE("Dye replaceAColor 8 1 sse2", "")
data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSse2(&data[0], 8);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 8);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1880,7 +1701,7 @@ TEST_CASE("Dye replaceAColor 9 1 sse2", "")
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorSse2(&data[0], 9);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 9);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1906,7 +1727,7 @@ TEST_CASE("Dye replaceAColor 10 1 sse2", "")
data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorSse2(&data[0], 10);
+ DYEPALETTE(palette, AColorSse2)(&data[0], 10);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1924,7 +1745,7 @@ TEST_CASE("Dye replaceAColor 1 1 avx2", "")
DyePalette palette("#00ff0010,00001120", 8);
uint32_t data[1];
data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceAColorAvx2(&data[0], 1);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
}
@@ -1933,7 +1754,7 @@ TEST_CASE("Dye replaceAColor 1 2 avx2", "")
DyePalette palette("#02ff0120,040311ff", 8);
uint32_t data[1];
data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- palette.replaceAColorAvx2(&data[0], 1);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
}
@@ -1942,7 +1763,7 @@ TEST_CASE("Dye replaceAColor 1 3 avx2", "")
DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
uint32_t data[1];
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorAvx2(&data[0], 1);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
}
@@ -1952,7 +1773,7 @@ TEST_CASE("Dye replaceAColor 2 1 avx2", "")
uint32_t data[2];
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorAvx2(&data[0], 2);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 2);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
}
@@ -1964,7 +1785,7 @@ TEST_CASE("Dye replaceAColor 3 1 avx2", "")
data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorAvx2(&data[0], 3);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 3);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
@@ -1978,7 +1799,7 @@ TEST_CASE("Dye replaceAColor 4 1 avx2", "")
data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorAvx2(&data[0], 4);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 4);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -1994,7 +1815,7 @@ TEST_CASE("Dye replaceAColor 5 1 avx2", "")
data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorAvx2(&data[0], 5);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 5);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -2013,7 +1834,7 @@ TEST_CASE("Dye replaceAColor 7 1 avx2", "")
data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- palette.replaceAColorAvx2(&data[0], 7);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 7);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -2035,7 +1856,7 @@ TEST_CASE("Dye replaceAColor 8 1 avx2", "")
data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorAvx2(&data[0], 8);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 8);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -2059,7 +1880,7 @@ TEST_CASE("Dye replaceAColor 9 1 avx2", "")
data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorAvx2(&data[0], 9);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 9);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
@@ -2085,7 +1906,7 @@ TEST_CASE("Dye replaceAColor 10 1 avx2", "")
data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorAvx2(&data[0], 10);
+ DYEPALETTE(palette, AColorAvx2)(&data[0], 10);
REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp
index c341d140e..bf12b7047 100644
--- a/src/resources/dye/dyepalette.cpp
+++ b/src/resources/dye/dyepalette.cpp
@@ -50,6 +50,9 @@ DyeFunctionPtr DyePalette::funcReplaceSColorAvx2 = nullptr;
DyeFunctionPtr DyePalette::funcReplaceSOGLColor = nullptr;
DyeFunctionPtr DyePalette::funcReplaceSOGLColorSse2 = nullptr;
DyeFunctionPtr DyePalette::funcReplaceSOGLColorAvx2 = nullptr;
+DyeFunctionPtr DyePalette::funcReplaceAColor = nullptr;
+DyeFunctionPtr DyePalette::funcReplaceAColorSse2 = nullptr;
+DyeFunctionPtr DyePalette::funcReplaceAColorAvx2 = nullptr;
DyePalette::DyePalette(const std::string &restrict description,
const uint8_t blockSize) :
@@ -248,6 +251,9 @@ void DyePalette::initFunctions()
funcReplaceSOGLColor = &DyePalette::replaceSOGLColorAvx2;
funcReplaceSOGLColorAvx2 = &DyePalette::replaceSOGLColorAvx2;
funcReplaceSOGLColorSse2 = &DyePalette::replaceSOGLColorSse2;
+ funcReplaceAColor = &DyePalette::replaceAColorAvx2;
+ funcReplaceAColorAvx2 = &DyePalette::replaceAColorAvx2;
+ funcReplaceAColorSse2 = &DyePalette::replaceAColorSse2;
}
else if (flags & Cpu::FEATURE_SSE2)
{
@@ -257,6 +263,9 @@ void DyePalette::initFunctions()
funcReplaceSOGLColor = &DyePalette::replaceSOGLColorSse2;
funcReplaceSOGLColorAvx2 = &DyePalette::replaceSOGLColorSse2;
funcReplaceSOGLColorSse2 = &DyePalette::replaceSOGLColorSse2;
+ funcReplaceAColor = &DyePalette::replaceAColorSse2;
+ funcReplaceAColorAvx2 = &DyePalette::replaceAColorSse2;
+ funcReplaceAColorSse2 = &DyePalette::replaceAColorSse2;
}
else
#endif // SIMD_SUPPORTED
@@ -267,5 +276,8 @@ void DyePalette::initFunctions()
funcReplaceSOGLColor = &DyePalette::replaceSOGLColorDefault;
funcReplaceSOGLColorAvx2 = &DyePalette::replaceSOGLColorDefault;
funcReplaceSOGLColorSse2 = &DyePalette::replaceSOGLColorDefault;
+ funcReplaceAColor = &DyePalette::replaceAColorDefault;
+ funcReplaceAColorAvx2 = &DyePalette::replaceAColorDefault;
+ funcReplaceAColorSse2 = &DyePalette::replaceAColorDefault;
}
}
diff --git a/src/resources/dye/dyepalette.h b/src/resources/dye/dyepalette.h
index 4129928fa..1ac15c9a0 100644
--- a/src/resources/dye/dyepalette.h
+++ b/src/resources/dye/dyepalette.h
@@ -92,54 +92,14 @@ class DyePalette final
/**
* replace colors for SDL for A dye.
*/
- void replaceAColor(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
void replaceAColorDefault(uint32_t *restrict pixels,
const int bufSize) const restrict2;
- /**
- * replace colors for SDL for A dye.
- */
- FUNCTION_SIMD_DEFAULT
- void replaceAColorSimd(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
- FUNCTION_SIMD_DEFAULT
- void replaceAColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
- FUNCTION_SIMD_DEFAULT
- void replaceAColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
#ifdef SIMD_SUPPORTED
/**
* replace colors for SDL for A dye.
*/
__attribute__ ((target ("sse2")))
- void replaceAColorSimd(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
- __attribute__ ((target ("avx2")))
- void replaceAColorSimd(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
- /**
- * replace colors for SDL for A dye.
- */
- __attribute__ ((target ("sse2")))
void replaceAColorSse2(uint32_t *restrict pixels,
const int bufSize) const restrict2;
@@ -248,6 +208,9 @@ class DyePalette final
static DyeFunctionPtr funcReplaceSOGLColor;
static DyeFunctionPtr funcReplaceSOGLColorSse2;
static DyeFunctionPtr funcReplaceSOGLColorAvx2;
+ static DyeFunctionPtr funcReplaceAColor;
+ static DyeFunctionPtr funcReplaceAColorSse2;
+ static DyeFunctionPtr funcReplaceAColorAvx2;
#ifndef UNITTESTS
private:
diff --git a/src/resources/dye/dyepalette_replaceacolor.cpp b/src/resources/dye/dyepalette_replaceacolor.cpp
index 51bd9e36f..718a85853 100644
--- a/src/resources/dye/dyepalette_replaceacolor.cpp
+++ b/src/resources/dye/dyepalette_replaceacolor.cpp
@@ -33,20 +33,96 @@
#include "debug.h"
-void DyePalette::replaceAColor(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
-#ifdef SIMD_SUPPORTED
- replaceAColorSimd(pixels, bufSize);
-#else // SIMD_SUPPORTED
-#include "resources/dye/dyepalette_replaceacolor_default.hpp"
-#endif // SIMD_SUPPORTED
-}
-
void DyePalette::replaceAColorDefault(uint32_t *restrict pixels,
const int bufSize) const restrict2
{
-#include "resources/dye/dyepalette_replaceacolor_default.hpp"
+ std::vector<DyeColor>::const_iterator it_end = mColors.end();
+ const size_t sz = mColors.size();
+ if (!sz || !pixels)
+ return;
+ if (sz % 2)
+ -- it_end;
+
+#ifdef ENABLE_CILKPLUS
+ cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
+ {
+ uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
+ const unsigned int data = pixels[ptr];
+
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
+ {
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
+
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ const unsigned int coldata = (col.value[3] << 24U)
+ | (col.value[2] << 16U)
+ | (col.value[1] << 8U)
+ | (col.value[0]);
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
+ const unsigned int coldata = (col.value[3])
+ | (col.value[2] << 8U)
+ | (col.value[1] << 16U) |
+ (col.value[0] << 24U);
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
+ if (data == coldata)
+ {
+ p[3] = col2.value[0];
+ p[2] = col2.value[1];
+ p[1] = col2.value[2];
+ p[0] = col2.value[3];
+ break;
+ }
+
+ ++ it;
+ }
+ }
+
+#else // ENABLE_CILKPLUS
+
+ for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
+ pixels != p_end;
+ ++pixels)
+ {
+ uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
+ const unsigned int data = *pixels;
+
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
+ {
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
+
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ const unsigned int coldata = (col.value[3] << 24U)
+ | (col.value[2] << 16U)
+ | (col.value[1] << 8U)
+ | (col.value[0]);
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+ const unsigned int coldata = (col.value[3])
+ | (col.value[2] << 8U)
+ | (col.value[1] << 16U) |
+ (col.value[0] << 24U);
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
+ if (data == coldata)
+ {
+ p[3] = col2.value[0];
+ p[2] = col2.value[1];
+ p[1] = col2.value[2];
+ p[0] = col2.value[3];
+ break;
+ }
+
+ ++ it;
+ }
+ }
+#endif // ENABLE_CILKPLUS
}
#ifdef SIMD_SUPPORTED
@@ -59,52 +135,145 @@ static void print256(const char *const text, const __m256i &val)
*/
__attribute__ ((target ("sse2")))
-void DyePalette::replaceAColorSimd(uint32_t *restrict pixels,
+void DyePalette::replaceAColorSse2(uint32_t *restrict pixels,
const int bufSize) const restrict2
{
-#include "resources/dye/dyepalette_replaceacolor_sse2.hpp"
-}
+ std::vector<DyeColor>::const_iterator it_end = mColors.end();
+ const size_t sz = mColors.size();
+ if (!sz || !pixels)
+ return;
+ if (sz % 2)
+ -- it_end;
+ const int mod = bufSize % 4;
+ const int bufEnd = bufSize - mod;
-__attribute__ ((target ("avx2")))
-void DyePalette::replaceAColorSimd(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
-#include "resources/dye/dyepalette_replaceacolor_avx2.hpp"
-}
+ for (int ptr = 0; ptr < bufEnd; ptr += 4)
+ {
+// __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(pixels));
+ __m128i base = _mm_loadu_si128(reinterpret_cast<__m128i*>(
+ &pixels[ptr]));
-__attribute__ ((target ("sse2")))
-void DyePalette::replaceAColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
-#include "resources/dye/dyepalette_replaceacolor_sse2.hpp"
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
+ {
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
+
+ __m128i newMask = _mm_set1_epi32(col2.valueA);
+ __m128i cmpMask = _mm_set1_epi32(col.valueA);
+ __m128i cmpRes = _mm_cmpeq_epi32(base, cmpMask);
+ __m128i srcAnd = _mm_andnot_si128(cmpRes, base);
+ __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
+ base = _mm_or_si128(srcAnd, dstAnd);
+
+ ++ it;
+ }
+// _mm_store_si128(reinterpret_cast<__m128i*>(pixels), base);
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
+ }
+
+ // complete end without simd
+ for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
+ {
+ uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
+ const unsigned int data = pixels[ptr];
+
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
+ {
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
+
+ const unsigned int coldata = (col.value[3]) |
+ (col.value[2] << 8U) |
+ (col.value[1] << 16U) |
+ (col.value[0] << 24U);
+
+ if (data == coldata)
+ {
+ p[3] = col2.value[0];
+ p[2] = col2.value[1];
+ p[1] = col2.value[2];
+ p[0] = col2.value[3];
+ break;
+ }
+
+ ++ it;
+ }
+ }
}
__attribute__ ((target ("avx2")))
void DyePalette::replaceAColorAvx2(uint32_t *restrict pixels,
const int bufSize) const restrict2
{
-#include "resources/dye/dyepalette_replaceacolor_avx2.hpp"
-}
+ std::vector<DyeColor>::const_iterator it_end = mColors.end();
+ const size_t sz = mColors.size();
+ if (!sz || !pixels)
+ return;
+ if (sz % 2)
+ -- it_end;
+ const int mod = bufSize % 8;
+ const int bufEnd = bufSize - mod;
-#endif // SIMD_SUPPORTED
+ for (int ptr = 0; ptr < bufEnd; ptr += 8)
+ {
+// __m256i base = _mm256_load_si256(reinterpret_cast<__m256i*>(pixels));
+ __m256i base = _mm256_loadu_si256(reinterpret_cast<__m256i*>(
+ &pixels[ptr]));
-FUNCTION_SIMD_DEFAULT
-void DyePalette::replaceAColorSimd(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
-#include "resources/dye/dyepalette_replaceacolor_default.hpp"
-}
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
+ {
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
-FUNCTION_SIMD_DEFAULT
-void DyePalette::replaceAColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
-#include "resources/dye/dyepalette_replaceacolor_default.hpp"
-}
+ __m256i newMask = _mm256_set1_epi32(col2.valueA);
+ __m256i cmpMask = _mm256_set1_epi32(col.valueA);
+ __m256i cmpRes = _mm256_cmpeq_epi32(base, cmpMask);
+ __m256i srcAnd = _mm256_andnot_si256(cmpRes, base);
+ __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
+ base = _mm256_or_si256(srcAnd, dstAnd);
-FUNCTION_SIMD_DEFAULT
-void DyePalette::replaceAColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
-#include "resources/dye/dyepalette_replaceacolor_default.hpp"
+ ++ it;
+ }
+// _mm256_store_si256(reinterpret_cast<__m256i*>(pixels), base);
+ _mm256_storeu_si256(reinterpret_cast<__m256i*>(&pixels[ptr]), base);
+ }
+
+ // complete end without simd
+ for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
+ {
+ uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
+ const unsigned int data = pixels[ptr];
+
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
+ {
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
+
+ const unsigned int coldata = (col.value[3]) |
+ (col.value[2] << 8U) |
+ (col.value[1] << 16U) |
+ (col.value[0] << 24U);
+
+ if (data == coldata)
+ {
+ p[3] = col2.value[0];
+ p[2] = col2.value[1];
+ p[1] = col2.value[2];
+ p[0] = col2.value[3];
+ break;
+ }
+
+ ++ it;
+ }
+ }
}
+
+#endif // SIMD_SUPPORTED
diff --git a/src/resources/dye/dyepalette_replaceacolor_avx2.hpp b/src/resources/dye/dyepalette_replaceacolor_avx2.hpp
deleted file mode 100644
index 7dc521f77..000000000
--- a/src/resources/dye/dyepalette_replaceacolor_avx2.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- std::vector<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (!sz || !pixels)
- return;
- if (sz % 2)
- -- it_end;
- const int mod = bufSize % 8;
- const int bufEnd = bufSize - mod;
-
- for (int ptr = 0; ptr < bufEnd; ptr += 8)
- {
-// __m256i base = _mm256_load_si256(reinterpret_cast<__m256i*>(pixels));
- __m256i base = _mm256_loadu_si256(reinterpret_cast<__m256i*>(
- &pixels[ptr]));
-
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m256i newMask = _mm256_set1_epi32(col2.valueA);
- __m256i cmpMask = _mm256_set1_epi32(col.valueA);
- __m256i cmpRes = _mm256_cmpeq_epi32(base, cmpMask);
- __m256i srcAnd = _mm256_andnot_si256(cmpRes, base);
- __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
- base = _mm256_or_si256(srcAnd, dstAnd);
-
- ++ it;
- }
-// _mm256_store_si256(reinterpret_cast<__m256i*>(pixels), base);
- _mm256_storeu_si256(reinterpret_cast<__m256i*>(&pixels[ptr]), base);
- }
-
- // complete end without simd
- for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- const unsigned int coldata = (col.value[3]) |
- (col.value[2] << 8U) |
- (col.value[1] << 16U) |
- (col.value[0] << 24U);
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
diff --git a/src/resources/dye/dyepalette_replaceacolor_default.hpp b/src/resources/dye/dyepalette_replaceacolor_default.hpp
deleted file mode 100644
index c5bf0075f..000000000
--- a/src/resources/dye/dyepalette_replaceacolor_default.hpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- std::vector<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (!sz || !pixels)
- return;
- if (sz % 2)
- -- it_end;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3] << 24U)
- | (col.value[2] << 16U)
- | (col.value[1] << 8U)
- | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[3])
- | (col.value[2] << 8U)
- | (col.value[1] << 16U) |
- (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
- const unsigned int data = *pixels;
-
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3] << 24U)
- | (col.value[2] << 16U)
- | (col.value[1] << 8U)
- | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3])
- | (col.value[2] << 8U)
- | (col.value[1] << 16U) |
- (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
diff --git a/src/resources/dye/dyepalette_replaceacolor_sse2.hpp b/src/resources/dye/dyepalette_replaceacolor_sse2.hpp
deleted file mode 100644
index 82854f9d8..000000000
--- a/src/resources/dye/dyepalette_replaceacolor_sse2.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- std::vector<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (!sz || !pixels)
- return;
- if (sz % 2)
- -- it_end;
- const int mod = bufSize % 4;
- const int bufEnd = bufSize - mod;
-
- for (int ptr = 0; ptr < bufEnd; ptr += 4)
- {
-// __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(pixels));
- __m128i base = _mm_loadu_si128(reinterpret_cast<__m128i*>(
- &pixels[ptr]));
-
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m128i newMask = _mm_set1_epi32(col2.valueA);
- __m128i cmpMask = _mm_set1_epi32(col.valueA);
- __m128i cmpRes = _mm_cmpeq_epi32(base, cmpMask);
- __m128i srcAnd = _mm_andnot_si128(cmpRes, base);
- __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
- base = _mm_or_si128(srcAnd, dstAnd);
-
- ++ it;
- }
-// _mm_store_si128(reinterpret_cast<__m128i*>(pixels), base);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- }
-
- // complete end without simd
- for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- const unsigned int coldata = (col.value[3]) |
- (col.value[2] << 8U) |
- (col.value[1] << 16U) |
- (col.value[0] << 24U);
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }