rgbsse: Rather simple performance optimization. (nw)

This commit is contained in:
Ted Green 2017-09-29 10:32:33 -06:00
parent c31dfdcfda
commit 93c7761d9d
2 changed files with 10 additions and 2 deletions

View File

@ -597,6 +597,14 @@ void validity_checker::validate_rgb()
rgb.set(rgbaint_t(expected_a, expected_r, expected_g, expected_b));
check_expected("rgbaint_t::set(rgbaint_t)");
packed = random_i32();
expected_a = packed.a();
expected_r = packed.r();
expected_g = packed.g();
expected_b = packed.b();
rgb.set(packed);
check_expected("rgbaint_t::set(const rgb_t& rgb)");
// check construct/assign
expected_a = random_i32();
expected_r = random_i32();

View File

@ -38,9 +38,9 @@ public:
rgbaint_t &operator=(const rgbaint_t& other) = default;
void set(const rgbaint_t& other) { m_value = other.m_value; }
void set(u32 rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); }
void set(const u32& rgba) { m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgba), _mm_setzero_si128()), _mm_setzero_si128()); }
void set(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_set_epi32(a, r, g, b); }
void set(const rgb_t& rgb) { m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()), _mm_setzero_si128()); }
void set(const rgb_t& rgb) { set((const u32&) rgb); }
inline rgb_t to_rgba() const
{