check a bunch more RGB operations in validity (nw)

implement the missing ones in rgbgen
format similar one-liners in a more tabular way
use default copy construct/assign
This commit is contained in:
Vas Crabb 2016-07-15 16:18:42 +10:00
parent 231bfb6237
commit 7d5da01f94
4 changed files with 378 additions and 208 deletions

View File

@ -380,7 +380,7 @@ void validity_checker::validate_core()
void validity_checker::validate_inlines()
{
volatile UINT64 testu64a = random_i64();
volatile UINT64 testu64a = random_u64();
volatile INT64 testi64a = random_i64();
volatile UINT32 testu32a = random_u32();
volatile UINT32 testu32b = random_u32();
@ -507,37 +507,41 @@ void validity_checker::validate_rgb()
{
/*
This performs cursory tests of most of the vector-optimised RGB
utilities, concentrating on the low-level maths. It uses random
values most of the time for a quick go/no-go indication rather
than trying to exercise edge cases. It doesn't matter too much
if the compiler optimises out some of the operations since it's
really intended to check for logic bugs in the vector code.
utilities, concentrating on the low-level maths. It uses random
values most of the time for a quick go/no-go indication rather
than trying to exercise edge cases. It doesn't matter too much
if the compiler optimises out some of the operations since it's
really intended to check for logic bugs in the vector code. If
the compiler can work out that the code produces the expected
result, that's good enough.
The following functions are not tested yet:
rgbaint_t()
clamp_and_clear(const UINT32)
sign_extend(const UINT32, const UINT32)
min(const INT32)
max(const INT32)
blend(const rgbaint_t&, UINT8)
scale_and_clamp(const rgbaint_t&)
scale_imm_and_clamp(const INT32)
scale2_add_and_clamp(const rgbaint_t&, const rgbaint_t&, const rgbaint_t&)
scale_add_and_clamp(const rgbaint_t&, const rgbaint_t&);
scale_imm_add_and_clamp(const INT32, const rgbaint_t&);
cmpeq(const rgbaint_t&)
cmpeq_imm(const INT32)
cmpeq_imm_rgba(const INT32, const INT32, const INT32, const INT32)
cmpgt(const rgbaint_t&)
cmpgt_imm(const INT32)
cmpgt_imm_rgba(const INT32, const INT32, const INT32, const INT32)
cmplt(const rgbaint_t&)
cmplt_imm(const INT32)
cmplt_imm_rgba(const INT32, const INT32, const INT32, const INT32)
static bilinear_filter(UINT32, UINT32, UINT32, UINT32, UINT8, UINT8)
bilinear_filter_rgbaint(UINT32, UINT32, UINT32, UINT32, UINT8, UINT8)
The tests for bitwise logical operations are ordered to minimise
the chance of all-zero or all-one patterns producing a
misleading good result.
The following functions are not tested yet:
rgbaint_t()
clamp_and_clear(const UINT32)
sign_extend(const UINT32, const UINT32)
min(const INT32)
max(const INT32)
blend(const rgbaint_t&, UINT8)
scale_and_clamp(const rgbaint_t&)
scale_imm_and_clamp(const INT32)
scale2_add_and_clamp(const rgbaint_t&, const rgbaint_t&, const rgbaint_t&)
scale_add_and_clamp(const rgbaint_t&, const rgbaint_t&);
scale_imm_add_and_clamp(const INT32, const rgbaint_t&);
static bilinear_filter(UINT32, UINT32, UINT32, UINT32, UINT8, UINT8)
bilinear_filter_rgbaint(UINT32, UINT32, UINT32, UINT32, UINT8, UINT8)
*/
auto random_i32_nolimit = [this]
{
INT32 result;
do { result = random_i32(); } while ((result == std::numeric_limits<INT32>::min()) || (result == std::numeric_limits<INT32>::max()));
return result;
};
volatile INT32 expected_a, expected_r, expected_g, expected_b;
volatile INT32 actual_a, actual_r, actual_g, actual_b;
volatile INT32 imm;
@ -1034,6 +1038,291 @@ void validity_checker::validate_rgb()
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb >>= 11;
check_expected("rgbaint_t::operator>>=");
// test RGB equality comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = ~INT32(0);
expected_r = 0;
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits<INT32>::min()));
check_expected("rgbaint_t::cmpeq");
expected_a = 0;
expected_r = ~INT32(0);
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq(rgbaint_t(std::numeric_limits<INT32>::max(), actual_r, actual_g - 1, actual_b + 1));
check_expected("rgbaint_t::cmpeq");
// test immediate equality comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = ~INT32(0);
expected_r = (actual_r == actual_a) ? ~INT32(0) : 0;
expected_g = (actual_g == actual_a) ? ~INT32(0) : 0;
expected_b = (actual_b == actual_a) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(actual_a);
check_expected("rgbaint_t::cmpeq_imm");
expected_a = (actual_a == actual_r) ? ~INT32(0) : 0;
expected_r = ~INT32(0);
expected_g = (actual_g == actual_r) ? ~INT32(0) : 0;
expected_b = (actual_b == actual_r) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(actual_r);
check_expected("rgbaint_t::cmpeq_imm");
expected_a = (actual_a == actual_g) ? ~INT32(0) : 0;
expected_r = (actual_r == actual_g) ? ~INT32(0) : 0;
expected_g = ~INT32(0);
expected_b = (actual_b == actual_g) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(actual_g);
check_expected("rgbaint_t::cmpeq_imm");
expected_a = (actual_a == actual_b) ? ~INT32(0) : 0;
expected_r = (actual_r == actual_b) ? ~INT32(0) : 0;
expected_g = (actual_g == actual_b) ? ~INT32(0) : 0;
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(actual_b);
check_expected("rgbaint_t::cmpeq_imm");
expected_a = 0;
expected_r = 0;
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(std::numeric_limits<INT32>::min());
check_expected("rgbaint_t::cmpeq_imm");
expected_a = !actual_a ? ~INT32(0) : 0;
expected_r = !actual_r ? ~INT32(0) : 0;
expected_g = !actual_g ? ~INT32(0) : 0;
expected_b = !actual_b ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(0);
check_expected("rgbaint_t::cmpeq_imm");
expected_a = 0;
expected_r = 0;
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm(std::numeric_limits<INT32>::max());
check_expected("rgbaint_t::cmpeq_imm");
// test immediate RGB equality comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = 0;
expected_r = 0;
expected_g = ~INT32(0);
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm_rgba(std::numeric_limits<INT32>::min(), std::numeric_limits<INT32>::max(), actual_g, actual_b - 1);
check_expected("rgbaint_t::cmpeq_imm_rgba");
expected_a = 0;
expected_r = 0;
expected_g = 0;
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpeq_imm_rgba(actual_a + 1, std::numeric_limits<INT32>::min(), std::numeric_limits<INT32>::max(), actual_b);
check_expected("rgbaint_t::cmpeq_imm_rgba");
// test RGB greater than comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = 0;
expected_r = ~INT32(0);
expected_g = 0;
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits<INT32>::min()));
check_expected("rgbaint_t::cmpgt");
expected_a = 0;
expected_r = 0;
expected_g = ~INT32(0);
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt(rgbaint_t(std::numeric_limits<INT32>::max(), actual_r, actual_g - 1, actual_b + 1));
check_expected("rgbaint_t::cmpgt");
// test immediate greater than comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = 0;
expected_r = (actual_r > actual_a) ? ~INT32(0) : 0;
expected_g = (actual_g > actual_a) ? ~INT32(0) : 0;
expected_b = (actual_b > actual_a) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(actual_a);
check_expected("rgbaint_t::cmpgt_imm");
expected_a = (actual_a > actual_r) ? ~INT32(0) : 0;
expected_r = 0;
expected_g = (actual_g > actual_r) ? ~INT32(0) : 0;
expected_b = (actual_b > actual_r) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(actual_r);
check_expected("rgbaint_t::cmpgt_imm");
expected_a = (actual_a > actual_g) ? ~INT32(0) : 0;
expected_r = (actual_r > actual_g) ? ~INT32(0) : 0;
expected_g =0;
expected_b = (actual_b > actual_g) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(actual_g);
check_expected("rgbaint_t::cmpgt_imm");
expected_a = (actual_a > actual_b) ? ~INT32(0) : 0;
expected_r = (actual_r > actual_b) ? ~INT32(0) : 0;
expected_g = (actual_g > actual_b) ? ~INT32(0) : 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(actual_b);
check_expected("rgbaint_t::cmpgt_imm");
expected_a = ~INT32(0);
expected_r = ~INT32(0);
expected_g = ~INT32(0);
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(std::numeric_limits<INT32>::min());
check_expected("rgbaint_t::cmpgt_imm");
expected_a = (actual_a > 0) ? ~INT32(0) : 0;
expected_r = (actual_r > 0) ? ~INT32(0) : 0;
expected_g = (actual_g > 0) ? ~INT32(0) : 0;
expected_b = (actual_b > 0) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(0);
check_expected("rgbaint_t::cmpgt_imm");
expected_a = 0;
expected_r = 0;
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm(std::numeric_limits<INT32>::max());
check_expected("rgbaint_t::cmpgt_imm");
// test immediate RGB greater than comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = ~INT32(0);
expected_r = 0;
expected_g = 0;
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm_rgba(std::numeric_limits<INT32>::min(), std::numeric_limits<INT32>::max(), actual_g, actual_b - 1);
check_expected("rgbaint_t::cmpgt_imm_rgba");
expected_a = 0;
expected_r = ~INT32(0);
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmpgt_imm_rgba(actual_a + 1, std::numeric_limits<INT32>::min(), std::numeric_limits<INT32>::max(), actual_b);
check_expected("rgbaint_t::cmpgt_imm_rgba");
// test RGB less than comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = 0;
expected_r = 0;
expected_g = ~INT32(0);
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits<INT32>::min()));
check_expected("rgbaint_t::cmplt");
expected_a = ~INT32(0);
expected_r = 0;
expected_g = 0;
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt(rgbaint_t(std::numeric_limits<INT32>::max(), actual_r, actual_g - 1, actual_b + 1));
check_expected("rgbaint_t::cmplt");
// test immediate less than comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = 0;
expected_r = (actual_r < actual_a) ? ~INT32(0) : 0;
expected_g = (actual_g < actual_a) ? ~INT32(0) : 0;
expected_b = (actual_b < actual_a) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(actual_a);
check_expected("rgbaint_t::cmplt_imm");
expected_a = (actual_a < actual_r) ? ~INT32(0) : 0;
expected_r = 0;
expected_g = (actual_g < actual_r) ? ~INT32(0) : 0;
expected_b = (actual_b < actual_r) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(actual_r);
check_expected("rgbaint_t::cmplt_imm");
expected_a = (actual_a < actual_g) ? ~INT32(0) : 0;
expected_r = (actual_r < actual_g) ? ~INT32(0) : 0;
expected_g =0;
expected_b = (actual_b < actual_g) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(actual_g);
check_expected("rgbaint_t::cmplt_imm");
expected_a = (actual_a < actual_b) ? ~INT32(0) : 0;
expected_r = (actual_r < actual_b) ? ~INT32(0) : 0;
expected_g = (actual_g < actual_b) ? ~INT32(0) : 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(actual_b);
check_expected("rgbaint_t::cmplt_imm");
expected_a = 0;
expected_r = 0;
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(std::numeric_limits<INT32>::min());
check_expected("rgbaint_t::cmplt_imm");
expected_a = (actual_a < 0) ? ~INT32(0) : 0;
expected_r = (actual_r < 0) ? ~INT32(0) : 0;
expected_g = (actual_g < 0) ? ~INT32(0) : 0;
expected_b = (actual_b < 0) ? ~INT32(0) : 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(0);
check_expected("rgbaint_t::cmplt_imm");
expected_a = ~INT32(0);
expected_r = ~INT32(0);
expected_g = ~INT32(0);
expected_b = ~INT32(0);
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm(std::numeric_limits<INT32>::max());
check_expected("rgbaint_t::cmplt_imm");
// test immediate RGB less than comparison
actual_a = random_i32_nolimit();
actual_r = random_i32_nolimit();
actual_g = random_i32_nolimit();
actual_b = random_i32_nolimit();
expected_a = 0;
expected_r = ~INT32(0);
expected_g = 0;
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm_rgba(std::numeric_limits<INT32>::min(), std::numeric_limits<INT32>::max(), actual_g, actual_b - 1);
check_expected("rgbaint_t::cmplt_imm_rgba");
expected_a = ~INT32(0);
expected_r = 0;
expected_g = ~INT32(0);
expected_b = 0;
rgb.set(actual_a, actual_r, actual_g, actual_b);
rgb.cmplt_imm_rgba(actual_a + 1, std::numeric_limits<INT32>::min(), std::numeric_limits<INT32>::max(), actual_b);
check_expected("rgbaint_t::cmplt_imm_rgba");
}

View File

@ -24,6 +24,9 @@ public:
rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
explicit rgbaint_t(const rgb_t& rgba) { set(rgba); }
rgbaint_t(const rgbaint_t& other) = default;
rgbaint_t &operator=(const rgbaint_t& other) = default;
void set(const rgbaint_t& other) { set(other.m_a, other.m_r, other.m_g, other.m_b); }
void set(UINT32 rgba) { set((rgba >> 24) & 0xff, (rgba >> 16) & 0xff, (rgba >> 8) & 0xff, rgba & 0xff); }
void set(INT32 a, INT32 r, INT32 g, INT32 b)
@ -212,15 +215,15 @@ public:
m_b |= high_mask;
}
inline void or_reg(const rgbaint_t& color)
{
or_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
void or_reg(const rgbaint_t& color) { or_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); }
void and_reg(const rgbaint_t& color) { and_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); }
void xor_reg(const rgbaint_t& color) { xor_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); }
inline void or_imm(const INT32 imm)
{
or_imm_rgba(imm, imm, imm, imm);
}
void andnot_reg(const rgbaint_t& color) { and_imm_rgba(~color.m_a, ~color.m_r, ~color.m_g, ~color.m_b); }
void or_imm(INT32 imm) { or_imm_rgba(imm, imm, imm, imm); }
void and_imm(INT32 imm) { and_imm_rgba(imm, imm, imm, imm); }
void xor_imm(INT32 imm) { xor_imm_rgba(imm, imm, imm, imm); }
inline void or_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
@ -230,21 +233,6 @@ public:
m_b |= b;
}
inline void and_reg(const rgbaint_t& color)
{
and_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
inline void andnot_reg(const rgbaint_t& color)
{
and_imm_rgba(~color.m_a, ~color.m_r, ~color.m_g, ~color.m_b);
}
inline void and_imm(const INT32 imm)
{
and_imm_rgba(imm, imm, imm, imm);
}
inline void and_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_a &= a;
@ -253,16 +241,6 @@ public:
m_b &= b;
}
inline void xor_reg(const rgbaint_t& color)
{
xor_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
inline void xor_imm(const INT32 imm)
{
xor_imm_rgba(imm, imm, imm, imm);
}
inline void xor_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_a ^= a;
@ -328,65 +306,43 @@ public:
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other);
void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other);
inline void cmpeq(const rgbaint_t& value)
void cmpeq(const rgbaint_t& value) { cmpeq_imm_rgba(value.m_a, value.m_r, value.m_g, value.m_b); }
void cmpgt(const rgbaint_t& value) { cmpgt_imm_rgba(value.m_a, value.m_r, value.m_g, value.m_b); }
void cmplt(const rgbaint_t& value) { cmplt_imm_rgba(value.m_a, value.m_r, value.m_g, value.m_b); }
void cmpeq_imm(INT32 value) { cmpeq_imm_rgba(value, value, value, value); }
void cmpgt_imm(INT32 value) { cmpgt_imm_rgba(value, value, value, value); }
void cmplt_imm(INT32 value) { cmplt_imm_rgba(value, value, value, value); }
void cmpeq_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b)
{
m_a = (m_a == value.m_a) ? 0xffffffff : 0;
m_r = (m_r == value.m_r) ? 0xffffffff : 0;
m_g = (m_g == value.m_g) ? 0xffffffff : 0;
m_b = (m_b == value.m_b) ? 0xffffffff : 0;
m_a = (m_a == a) ? 0xffffffff : 0;
m_r = (m_r == r) ? 0xffffffff : 0;
m_g = (m_g == g) ? 0xffffffff : 0;
m_b = (m_b == b) ? 0xffffffff : 0;
}
inline void cmpeq_imm(const INT32 value)
void cmpgt_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b)
{
m_a = (m_a == value) ? 0xffffffff : 0;
m_r = (m_r == value) ? 0xffffffff : 0;
m_g = (m_g == value) ? 0xffffffff : 0;
m_b = (m_b == value) ? 0xffffffff : 0;
m_a = (m_a > a) ? 0xffffffff : 0;
m_r = (m_r > r) ? 0xffffffff : 0;
m_g = (m_g > g) ? 0xffffffff : 0;
m_b = (m_b > b) ? 0xffffffff : 0;
}
inline void cmpgt(const rgbaint_t& value)
void cmplt_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b)
{
m_a = (m_a > value.m_a) ? 0xffffffff : 0;
m_r = (m_r > value.m_r) ? 0xffffffff : 0;
m_g = (m_g > value.m_g) ? 0xffffffff : 0;
m_b = (m_b > value.m_b) ? 0xffffffff : 0;
m_a = (m_a < a) ? 0xffffffff : 0;
m_r = (m_r < r) ? 0xffffffff : 0;
m_g = (m_g < g) ? 0xffffffff : 0;
m_b = (m_b < b) ? 0xffffffff : 0;
}
inline void cmpgt_imm(const INT32 value)
{
m_a = (m_a > value) ? 0xffffffff : 0;
m_r = (m_r > value) ? 0xffffffff : 0;
m_g = (m_g > value) ? 0xffffffff : 0;
m_b = (m_b > value) ? 0xffffffff : 0;
}
inline void cmplt(const rgbaint_t& value)
{
m_a = (m_a < value.m_a) ? 0xffffffff : 0;
m_r = (m_r < value.m_r) ? 0xffffffff : 0;
m_g = (m_g < value.m_g) ? 0xffffffff : 0;
m_b = (m_b < value.m_b) ? 0xffffffff : 0;
}
inline void cmplt_imm(const INT32 value)
{
m_a = (m_a < value) ? 0xffffffff : 0;
m_r = (m_r < value) ? 0xffffffff : 0;
m_g = (m_g < value) ? 0xffffffff : 0;
m_b = (m_b < value) ? 0xffffffff : 0;
}
inline void merge_alpha(const rgbaint_t& alpha)
void merge_alpha(const rgbaint_t& alpha)
{
m_a = alpha.m_a;
}
rgbaint_t &operator=(const rgbaint_t& other)
{
set(other.m_a, other.m_r, other.m_g, other.m_b);
return *this;
}
rgbaint_t& operator+=(const rgbaint_t& other)
{
add_imm_rgba(other.m_a, other.m_r, other.m_g, other.m_b);

View File

@ -34,6 +34,9 @@ public:
explicit rgbaint_t(const rgb_t& rgb) { set(rgb); }
explicit rgbaint_t(__m128i rgba) { m_value = rgba; }
rgbaint_t(const rgbaint_t& other) = default;
rgbaint_t &operator=(const rgbaint_t& other) = default;
void set(const rgbaint_t& other) { m_value = other.m_value; }
void set(UINT32 rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); }
void set(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_set_epi32(a, r, g, b); }
@ -212,55 +215,19 @@ public:
m_value = _mm_srai_epi32(m_value, shift);
}
inline void or_reg(const rgbaint_t& color2)
{
m_value = _mm_or_si128(m_value, color2.m_value);
}
void or_reg(const rgbaint_t& color2) { m_value = _mm_or_si128(m_value, color2.m_value); }
void and_reg(const rgbaint_t& color2) { m_value = _mm_and_si128(m_value, color2.m_value); }
void xor_reg(const rgbaint_t& color2) { m_value = _mm_xor_si128(m_value, color2.m_value); }
inline void or_imm(const INT32 value)
{
m_value = _mm_or_si128(m_value, _mm_set1_epi32(value));
}
void andnot_reg(const rgbaint_t& color2) { m_value = _mm_andnot_si128(color2.m_value, m_value); }
inline void or_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_or_si128(m_value, _mm_set_epi32(a, r, g, b));
}
void or_imm(INT32 value) { m_value = _mm_or_si128(m_value, _mm_set1_epi32(value)); }
void and_imm(INT32 value) { m_value = _mm_and_si128(m_value, _mm_set1_epi32(value)); }
void xor_imm(INT32 value) { m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value)); }
inline void and_reg(const rgbaint_t& color)
{
m_value = _mm_and_si128(m_value, color.m_value);
}
inline void andnot_reg(const rgbaint_t& color)
{
m_value = _mm_andnot_si128(color.m_value, m_value);
}
inline void and_imm(const INT32 value)
{
m_value = _mm_and_si128(m_value, _mm_set1_epi32(value));
}
inline void and_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_and_si128(m_value, _mm_set_epi32(a, r, g, b));
}
inline void xor_reg(const rgbaint_t& color2)
{
m_value = _mm_xor_si128(m_value, color2.m_value);
}
inline void xor_imm(const INT32 value)
{
m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value));
}
inline void xor_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_xor_si128(m_value, _mm_set_epi32(a, r, g, b));
}
void or_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_or_si128(m_value, _mm_set_epi32(a, r, g, b)); }
void and_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_and_si128(m_value, _mm_set_epi32(a, r, g, b)); }
void xor_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_xor_si128(m_value, _mm_set_epi32(a, r, g, b)); }
inline void clamp_and_clear(const UINT32 sign)
{
@ -344,56 +311,17 @@ public:
clamp_to_uint8();
}
inline void cmpeq(const rgbaint_t& value)
{
m_value = _mm_cmpeq_epi32(m_value, value.m_value);
}
void cmpeq(const rgbaint_t& value) { m_value = _mm_cmpeq_epi32(m_value, value.m_value); }
void cmpgt(const rgbaint_t& value) { m_value = _mm_cmpgt_epi32(m_value, value.m_value); }
void cmplt(const rgbaint_t& value) { m_value = _mm_cmplt_epi32(m_value, value.m_value); }
inline void cmpeq_imm(const INT32 value)
{
m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value));
}
void cmpeq_imm(INT32 value) { m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value)); }
void cmpgt_imm(INT32 value) { m_value = _mm_cmpgt_epi32(m_value, _mm_set1_epi32(value)); }
void cmplt_imm(INT32 value) { m_value = _mm_cmplt_epi32(m_value, _mm_set1_epi32(value)); }
inline void cmpeq_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_cmpeq_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
inline void cmpgt(const rgbaint_t& value)
{
m_value = _mm_cmpgt_epi32(m_value, value.m_value);
}
inline void cmpgt_imm(const INT32 value)
{
m_value = _mm_cmpgt_epi32(m_value, _mm_set1_epi32(value));
}
inline void cmpgt_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_cmpgt_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
inline void cmplt(const rgbaint_t& value)
{
m_value = _mm_cmplt_epi32(m_value, value.m_value);
}
inline void cmplt_imm(const INT32 value)
{
m_value = _mm_cmplt_epi32(m_value, _mm_set1_epi32(value));
}
inline void cmplt_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_cmplt_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
inline rgbaint_t &operator=(const rgbaint_t& other)
{
m_value = other.m_value;
return *this;
}
void cmpeq_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_cmpeq_epi32(m_value, _mm_set_epi32(a, r, g, b)); }
void cmpgt_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_cmpgt_epi32(m_value, _mm_set_epi32(a, r, g, b)); }
void cmplt_imm_rgba(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_cmplt_epi32(m_value, _mm_set_epi32(a, r, g, b)); }
inline rgbaint_t& operator+=(const rgbaint_t& other)
{

View File

@ -34,6 +34,9 @@ public:
explicit rgbaint_t(const rgb_t& rgb) { set(rgb); }
explicit rgbaint_t(VECS32 rgba) : m_value(rgba) { }
rgbaint_t(const rgbaint_t& other) = default;
rgbaint_t &operator=(const rgbaint_t& other) = default;
void set(const rgbaint_t& other) { m_value = other.m_value; }
void set(UINT32 rgba)
@ -545,12 +548,6 @@ public:
m_value = VECS32(vec_cmplt(m_value, temp));
}
inline rgbaint_t &operator=(const rgbaint_t& other)
{
m_value = other.m_value;
return *this;
}
inline rgbaint_t& operator+=(const rgbaint_t& other)
{
m_value = vec_add(m_value, other.m_value);