From 99f285c3b2dd15f2167b540c6027c7be2d73f639 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 23 Dec 2016 02:57:50 +0300 Subject: Add unit tests for separate sse2 and avx2 dyes. Fix sse2 dyes. --- src/resources/dye/dye_unittest.cc | 1102 +++++++++++++++++--- .../dye/dyepalette_replaceaoglcolor_sse2.hpp | 2 +- .../dye/dyepalette_replacescolor_sse2.hpp | 2 +- .../dye/dyepalette_replacesoglcolor_sse2.hpp | 2 +- 4 files changed, 958 insertions(+), 150 deletions(-) (limited to 'src/resources/dye') diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc index c06d0aacb..0218c0e9a 100644 --- a/src/resources/dye/dye_unittest.cc +++ b/src/resources/dye/dye_unittest.cc @@ -227,6 +227,52 @@ TEST_CASE("Dye replaceSOGLColor 8 1 simd") REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02)); } +TEST_CASE("Dye replaceSOGLColor 8 1 sse2") +{ + DyePalette palette("#01ff02,030411,01ee02,010203", 6); + uint32_t data[8]; + data[0] = buildHex(0x20, 0x02, 0xff, 0x01); + data[1] = buildHex(0x30, 0x02, 0xff, 0x01); + data[2] = buildHex(0x40, 0x02, 0xff, 0x01); + data[3] = buildHex(0x50, 0x02, 0xff, 0x02); + data[4] = buildHex(0x20, 0x02, 0xff, 0x01); + data[5] = buildHex(0x30, 0x02, 0xff, 0x01); + data[6] = buildHex(0x40, 0x02, 0xff, 0x01); + data[7] = buildHex(0x60, 0x02, 0xff, 0x02); + palette.replaceSOGLColorSse2(&data[0], 8); + REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02)); + REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02)); +} + +TEST_CASE("Dye replaceSOGLColor 8 1 avx2") +{ + DyePalette palette("#01ff02,030411,01ee02,010203", 6); + uint32_t data[8]; + data[0] = buildHex(0x20, 0x02, 0xff, 0x01); + data[1] = buildHex(0x30, 0x02, 0xff, 0x01); + data[2] = buildHex(0x40, 0x02, 0xff, 0x01); + data[3] = buildHex(0x50, 0x02, 0xff, 0x02); + data[4] = buildHex(0x20, 0x02, 0xff, 0x01); + data[5] = buildHex(0x30, 0x02, 0xff, 0x01); + data[6] = buildHex(0x40, 0x02, 0xff, 0x01); + data[7] = buildHex(0x60, 0x02, 0xff, 0x02); + palette.replaceSOGLColorAvx2(&data[0], 8); + REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02)); + REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02)); +} + TEST_CASE("Dye replaceAOGLColor 1 1") { @@ -402,6 +448,52 @@ TEST_CASE("Dye replaceAOGLColor 8 1 simd") REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01)); REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10)); } + +TEST_CASE("Dye replaceAOGLColor 8 1 sse2") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[8]; + data[0] = buildHex(0x40, 0xee, 0x00, 0x01); + data[1] = buildHex(0x40, 0xee, 0x00, 0x01); + data[2] = buildHex(0x41, 0xee, 0x00, 0x01); + data[3] = buildHex(0x40, 0xee, 0x00, 0x01); + data[4] = buildHex(0x40, 0xee, 0x00, 0x01); + data[5] = buildHex(0x40, 0x40, 0x40, 0x40); + data[6] = buildHex(0x41, 0xe0, 0x00, 0x01); + data[7] = buildHex(0x40, 0xee, 0x00, 0x01); + palette.replaceAOGLColorSse2(&data[0], 8); + REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01)); + REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20)); + REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01)); + REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10)); +} + +TEST_CASE("Dye replaceAOGLColor 8 1 avx2") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[8]; + data[0] = buildHex(0x40, 0xee, 0x00, 0x01); + data[1] = buildHex(0x40, 0xee, 0x00, 0x01); + data[2] = buildHex(0x41, 0xee, 0x00, 0x01); + data[3] = buildHex(0x40, 0xee, 0x00, 0x01); + data[4] = buildHex(0x40, 0xee, 0x00, 0x01); + data[5] = buildHex(0x40, 0x40, 0x40, 0x40); + data[6] = buildHex(0x41, 0xe0, 0x00, 0x01); + data[7] = buildHex(0x40, 0xee, 0x00, 0x01); + palette.replaceAOGLColorAvx2(&data[0], 8); + REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01)); + REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20)); + REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01)); + REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10)); +} #endif // USE_OPENGL @@ -942,148 +1034,685 @@ TEST_CASE("Dye replaceSColor 10 1 simd") REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80)); } - -TEST_CASE("Dye replaceAColor 1 1") +TEST_CASE("Dye replaceSColor 1 1 sse2") { - DyePalette palette("#00ff0010,00001120", 8); + DyePalette palette("#00ff00,000011", 6); uint32_t data[1]; data[0] = buildHex(0x10, 0x03, 0x02, 0x01); - palette.replaceAColor(&data[0], 1); + palette.replaceSColorSse2(&data[0], 1); REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); } -TEST_CASE("Dye replaceAColor 1 2") +TEST_CASE("Dye replaceSColor 1 2 sse2") { - DyePalette palette("#02ff0120,040311ff", 8); + DyePalette palette("#403020,706050", 6); uint32_t data[1]; - data[0] = buildHex(0x02, 0xff, 0x01, 0x20); - palette.replaceAColor(&data[0], 1); - REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff)); + data[0] = buildHex(0x40, 0x30, 0x20, 0x10); + palette.replaceSColorSse2(&data[0], 1); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); } -TEST_CASE("Dye replaceAColor 1 3") +TEST_CASE("Dye replaceSColor 1 3 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); uint32_t data[1]; - data[0] = buildHex(0x01, 0x00, 0xee, 0x40); - palette.replaceAColor(&data[0], 1); - REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + palette.replaceSColorSse2(&data[0], 1); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); } -TEST_CASE("Dye replaceAColor 2 1") +TEST_CASE("Dye replaceSColor 2 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); uint32_t data[2]; - data[0] = buildHex(0x01, 0x00, 0xee, 0x40); - data[1] = buildHex(0x40, 0x40, 0x40, 0x40); - palette.replaceAColor(&data[0], 2); - REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); - REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColorSse2(&data[0], 2); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); } -TEST_CASE("Dye replaceAColor 3 1") +TEST_CASE("Dye replaceSColor 3 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); 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.replaceAColor(&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)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x30, 0x20, 0x30); + palette.replaceSColorSse2(&data[0], 3); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30)); } -TEST_CASE("Dye replaceAColor 4 1") +TEST_CASE("Dye replaceSColor 4 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); 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.replaceAColor(&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)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColorSse2(&data[0], 4); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); } -TEST_CASE("Dye replaceAColor 5 1") +TEST_CASE("Dye replaceSColor 5 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); 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.replaceAColor(&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)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x30); + data[4] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColorSse2(&data[0], 5); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20)); } -TEST_CASE("Dye replaceAColor 7 1") +TEST_CASE("Dye replaceSColor 7 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); 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.replaceAColor(&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)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + palette.replaceSColorSse2(&data[0], 7); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); } -TEST_CASE("Dye replaceAColor 8 1") +TEST_CASE("Dye replaceSColor 8 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); 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.replaceAColor(&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)); + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + palette.replaceSColorSse2(&data[0], 8); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); } -TEST_CASE("Dye replaceAColor 9 1") +TEST_CASE("Dye replaceSColor 9 1 sse2") { - DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + DyePalette palette("#123456,000000,ff3020,706050", 6); 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[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + data[8] = buildHex(0xff, 0x30, 0x20, 0x70); + palette.replaceSColorSse2(&data[0], 9); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); + REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70)); +} + +TEST_CASE("Dye replaceSColor 10 1 sse2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[10]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + data[8] = buildHex(0x12, 0x34, 0x56, 0x70); + data[9] = buildHex(0xff, 0x30, 0x20, 0x80); + palette.replaceSColorSse2(&data[0], 10); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); + REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70)); + REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80)); +} + +TEST_CASE("Dye replaceSColor 1 1 avx2") +{ + DyePalette palette("#00ff00,000011", 6); + uint32_t data[1]; + data[0] = buildHex(0x10, 0x03, 0x02, 0x01); + palette.replaceSColorAvx2(&data[0], 1); + REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); +} + +TEST_CASE("Dye replaceSColor 1 2 avx2") +{ + DyePalette palette("#403020,706050", 6); + uint32_t data[1]; + data[0] = buildHex(0x40, 0x30, 0x20, 0x10); + palette.replaceSColorAvx2(&data[0], 1); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); +} + +TEST_CASE("Dye replaceSColor 1 3 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[1]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + palette.replaceSColorAvx2(&data[0], 1); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); +} + +TEST_CASE("Dye replaceSColor 2 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[2]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColorAvx2(&data[0], 2); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); +} + +TEST_CASE("Dye replaceSColor 3 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[3]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x30, 0x20, 0x30); + palette.replaceSColorAvx2(&data[0], 3); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30)); +} + +TEST_CASE("Dye replaceSColor 4 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[4]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColorAvx2(&data[0], 4); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); +} + +TEST_CASE("Dye replaceSColor 5 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[5]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x30); + data[4] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColorAvx2(&data[0], 5); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20)); +} + +TEST_CASE("Dye replaceSColor 7 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[7]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + palette.replaceSColorAvx2(&data[0], 7); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); +} + +TEST_CASE("Dye replaceSColor 8 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[8]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + palette.replaceSColorAvx2(&data[0], 8); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); +} + +TEST_CASE("Dye replaceSColor 9 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[9]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + data[8] = buildHex(0xff, 0x30, 0x20, 0x70); + palette.replaceSColorAvx2(&data[0], 9); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); + REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70)); +} + +TEST_CASE("Dye replaceSColor 10 1 avx2") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[10]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + data[8] = buildHex(0x12, 0x34, 0x56, 0x70); + data[9] = buildHex(0xff, 0x30, 0x20, 0x80); + palette.replaceSColorAvx2(&data[0], 10); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); + REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70)); + REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80)); +} + + +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); + REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); +} + +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); + REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff)); +} + +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); + REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); +} + +TEST_CASE("Dye replaceAColor 2 1") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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") +{ + 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.replaceAColor(&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 default") +{ + DyePalette palette("#00ff0010,00001120", 8); + uint32_t data[1]; + data[0] = buildHex(0x10, 0x03, 0x02, 0x01); + palette.replaceAColorDefault(&data[0], 1); + REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); +} + +TEST_CASE("Dye replaceAColor 1 2 default") +{ + DyePalette palette("#02ff0120,040311ff", 8); + uint32_t data[1]; + data[0] = buildHex(0x02, 0xff, 0x01, 0x20); + palette.replaceAColorDefault(&data[0], 1); + REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff)); +} + +TEST_CASE("Dye replaceAColor 1 3 default") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[1]; + data[0] = buildHex(0x01, 0x00, 0xee, 0x40); + palette.replaceAColorDefault(&data[0], 1); + REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); +} + +TEST_CASE("Dye replaceAColor 2 1 default") +{ + 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.replaceAColorDefault(&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 default") +{ + 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.replaceAColorDefault(&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 default") +{ + 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.replaceAColorDefault(&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 default") +{ + 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.replaceAColorDefault(&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 default") +{ + 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.replaceAColorDefault(&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 default") +{ + 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.replaceAColorDefault(&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 default") +{ + 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.replaceAColor(&data[0], 9); + palette.replaceAColorDefault(&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)); @@ -1095,7 +1724,7 @@ TEST_CASE("Dye replaceAColor 9 1") REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 10 1") +TEST_CASE("Dye replaceAColor 10 1 default") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[10]; @@ -1109,7 +1738,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); + palette.replaceAColorDefault(&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)); @@ -1122,58 +1751,58 @@ TEST_CASE("Dye replaceAColor 10 1") REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff)); } -TEST_CASE("Dye replaceAColor 1 1 default") +TEST_CASE("Dye replaceAColor 1 1 simd") { DyePalette palette("#00ff0010,00001120", 8); uint32_t data[1]; data[0] = buildHex(0x10, 0x03, 0x02, 0x01); - palette.replaceAColorDefault(&data[0], 1); + palette.replaceAColorSimd(&data[0], 1); REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); } -TEST_CASE("Dye replaceAColor 1 2 default") +TEST_CASE("Dye replaceAColor 1 2 simd") { DyePalette palette("#02ff0120,040311ff", 8); uint32_t data[1]; data[0] = buildHex(0x02, 0xff, 0x01, 0x20); - palette.replaceAColorDefault(&data[0], 1); + palette.replaceAColorSimd(&data[0], 1); REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff)); } -TEST_CASE("Dye replaceAColor 1 3 default") +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.replaceAColorDefault(&data[0], 1); + palette.replaceAColorSimd(&data[0], 1); REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); } -TEST_CASE("Dye replaceAColor 2 1 default") +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.replaceAColorDefault(&data[0], 2); + 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 default") +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.replaceAColorDefault(&data[0], 3); + 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 default") +TEST_CASE("Dye replaceAColor 4 1 simd") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[4]; @@ -1181,14 +1810,14 @@ TEST_CASE("Dye replaceAColor 4 1 default") data[1] = buildHex(0x40, 0x40, 0x40, 0x40); data[2] = buildHex(0x01, 0x00, 0xee, 0x50); data[3] = buildHex(0x40, 0x40, 0x40, 0x40); - palette.replaceAColorDefault(&data[0], 4); + 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 default") +TEST_CASE("Dye replaceAColor 5 1 simd") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[5]; @@ -1197,7 +1826,7 @@ TEST_CASE("Dye replaceAColor 5 1 default") data[2] = buildHex(0x01, 0x00, 0xee, 0x50); data[3] = buildHex(0x50, 0x40, 0x40, 0x60); data[4] = buildHex(0x40, 0x40, 0x40, 0x40); - palette.replaceAColorDefault(&data[0], 5); + 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)); @@ -1205,7 +1834,7 @@ TEST_CASE("Dye replaceAColor 5 1 default") REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 7 1 default") +TEST_CASE("Dye replaceAColor 7 1 simd") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[7]; @@ -1216,7 +1845,7 @@ TEST_CASE("Dye replaceAColor 7 1 default") data[4] = buildHex(0x01, 0x00, 0xee, 0x40); data[5] = buildHex(0x40, 0x40, 0x41, 0x40); data[6] = buildHex(0x01, 0x00, 0xee, 0x50); - palette.replaceAColorDefault(&data[0], 7); + 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)); @@ -1226,7 +1855,7 @@ TEST_CASE("Dye replaceAColor 7 1 default") REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50)); } -TEST_CASE("Dye replaceAColor 8 1 default") +TEST_CASE("Dye replaceAColor 8 1 simd") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[8]; @@ -1238,7 +1867,7 @@ TEST_CASE("Dye replaceAColor 8 1 default") data[5] = buildHex(0x40, 0x40, 0x41, 0x40); data[6] = buildHex(0x01, 0x00, 0xee, 0x50); data[7] = buildHex(0x40, 0x40, 0x40, 0x40); - palette.replaceAColorDefault(&data[0], 8); + 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)); @@ -1249,7 +1878,7 @@ TEST_CASE("Dye replaceAColor 8 1 default") REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 9 1 default") +TEST_CASE("Dye replaceAColor 9 1 simd") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[9]; @@ -1262,7 +1891,7 @@ TEST_CASE("Dye replaceAColor 9 1 default") data[6] = buildHex(0x01, 0x00, 0xee, 0x50); data[7] = buildHex(0x02, 0x40, 0x40, 0x40); data[8] = buildHex(0x40, 0x40, 0x40, 0x40); - palette.replaceAColorDefault(&data[0], 9); + 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)); @@ -1274,7 +1903,7 @@ TEST_CASE("Dye replaceAColor 9 1 default") REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 10 1 default") +TEST_CASE("Dye replaceAColor 10 1 simd") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[10]; @@ -1288,7 +1917,7 @@ TEST_CASE("Dye replaceAColor 10 1 default") data[7] = buildHex(0x02, 0x40, 0x40, 0x40); data[8] = buildHex(0x40, 0x40, 0x40, 0x40); data[9] = buildHex(0x01, 0x00, 0xee, 0x40); - palette.replaceAColorDefault(&data[0], 10); + 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)); @@ -1301,58 +1930,58 @@ TEST_CASE("Dye replaceAColor 10 1 default") REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff)); } -TEST_CASE("Dye replaceAColor 1 1 simd") +TEST_CASE("Dye replaceAColor 1 1 sse2") { DyePalette palette("#00ff0010,00001120", 8); uint32_t data[1]; data[0] = buildHex(0x10, 0x03, 0x02, 0x01); - palette.replaceAColorSimd(&data[0], 1); + palette.replaceAColorSse2(&data[0], 1); REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); } -TEST_CASE("Dye replaceAColor 1 2 simd") +TEST_CASE("Dye replaceAColor 1 2 sse2") { DyePalette palette("#02ff0120,040311ff", 8); uint32_t data[1]; data[0] = buildHex(0x02, 0xff, 0x01, 0x20); - palette.replaceAColorSimd(&data[0], 1); + palette.replaceAColorSse2(&data[0], 1); REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff)); } -TEST_CASE("Dye replaceAColor 1 3 simd") +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.replaceAColorSimd(&data[0], 1); + palette.replaceAColorSse2(&data[0], 1); REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); } -TEST_CASE("Dye replaceAColor 2 1 simd") +TEST_CASE("Dye replaceAColor 2 1 sse2") { 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); + palette.replaceAColorSse2(&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") +TEST_CASE("Dye replaceAColor 3 1 sse2") { 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); + palette.replaceAColorSse2(&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") +TEST_CASE("Dye replaceAColor 4 1 sse2") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[4]; @@ -1360,14 +1989,14 @@ TEST_CASE("Dye replaceAColor 4 1 simd") 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); + palette.replaceAColorSse2(&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") +TEST_CASE("Dye replaceAColor 5 1 sse2") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[5]; @@ -1376,7 +2005,7 @@ TEST_CASE("Dye replaceAColor 5 1 simd") 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); + palette.replaceAColorSse2(&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)); @@ -1384,7 +2013,7 @@ TEST_CASE("Dye replaceAColor 5 1 simd") REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 7 1 simd") +TEST_CASE("Dye replaceAColor 7 1 sse2") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[7]; @@ -1395,7 +2024,7 @@ TEST_CASE("Dye replaceAColor 7 1 simd") 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); + palette.replaceAColorSse2(&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)); @@ -1405,7 +2034,7 @@ TEST_CASE("Dye replaceAColor 7 1 simd") REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50)); } -TEST_CASE("Dye replaceAColor 8 1 simd") +TEST_CASE("Dye replaceAColor 8 1 sse2") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[8]; @@ -1417,7 +2046,7 @@ TEST_CASE("Dye replaceAColor 8 1 simd") 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); + palette.replaceAColorSse2(&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)); @@ -1428,7 +2057,7 @@ TEST_CASE("Dye replaceAColor 8 1 simd") REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 9 1 simd") +TEST_CASE("Dye replaceAColor 9 1 sse2") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[9]; @@ -1441,7 +2070,7 @@ TEST_CASE("Dye replaceAColor 9 1 simd") 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); + palette.replaceAColorSse2(&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)); @@ -1453,7 +2082,7 @@ TEST_CASE("Dye replaceAColor 9 1 simd") REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00)); } -TEST_CASE("Dye replaceAColor 10 1 simd") +TEST_CASE("Dye replaceAColor 10 1 sse2") { DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); uint32_t data[10]; @@ -1467,7 +2096,186 @@ TEST_CASE("Dye replaceAColor 10 1 simd") 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); + palette.replaceAColorSse2(&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 avx2") +{ + DyePalette palette("#00ff0010,00001120", 8); + uint32_t data[1]; + data[0] = buildHex(0x10, 0x03, 0x02, 0x01); + palette.replaceAColorAvx2(&data[0], 1); + REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01)); +} + +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); + REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff)); +} + +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); + REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); +} + +TEST_CASE("Dye replaceAColor 2 1 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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 avx2") +{ + 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.replaceAColorAvx2(&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_replaceaoglcolor_sse2.hpp b/src/resources/dye/dyepalette_replaceaoglcolor_sse2.hpp index 44485093d..24c15b506 100644 --- a/src/resources/dye/dyepalette_replaceaoglcolor_sse2.hpp +++ b/src/resources/dye/dyepalette_replaceaoglcolor_sse2.hpp @@ -27,7 +27,7 @@ if (sz % 2) -- it_end; - for (int ptr = 0; ptr < bufSize; ptr += 8) + for (int ptr = 0; ptr < bufSize; ptr += 4) { // __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>( // &pixels[ptr])); diff --git a/src/resources/dye/dyepalette_replacescolor_sse2.hpp b/src/resources/dye/dyepalette_replacescolor_sse2.hpp index 2a232d3ef..437a05ff3 100644 --- a/src/resources/dye/dyepalette_replacescolor_sse2.hpp +++ b/src/resources/dye/dyepalette_replacescolor_sse2.hpp @@ -27,7 +27,7 @@ const int mod = bufSize % 8; const int bufEnd = bufSize - mod; - for (int ptr = 0; ptr < bufEnd; ptr += 8) + for (int ptr = 0; ptr < bufEnd; ptr += 4) { __m128i mask = _mm_set1_epi32(0xffffff00); // __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(pixels)); diff --git a/src/resources/dye/dyepalette_replacesoglcolor_sse2.hpp b/src/resources/dye/dyepalette_replacesoglcolor_sse2.hpp index 7228ed37c..27be27c16 100644 --- a/src/resources/dye/dyepalette_replacesoglcolor_sse2.hpp +++ b/src/resources/dye/dyepalette_replacesoglcolor_sse2.hpp @@ -25,7 +25,7 @@ if (sz % 2) -- it_end; - for (int ptr = 0; ptr < bufSize; ptr += 8) + for (int ptr = 0; ptr < bufSize; ptr += 4) { __m128i mask = _mm_set1_epi32(0x00ffffff); // __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>( -- cgit v1.2.3-70-g09d2