From dc8e0b3c2237ba1b2115fd6da6b5b8eca95b990c Mon Sep 17 00:00:00 2001 From: ted green Date: Sun, 12 Jul 2015 10:33:58 -0600 Subject: [PATCH] Fixed some rgbaint_t functions. Added some optimizations to rgbaint_t. --- src/emu/video/rgbgen.c | 2 +- src/emu/video/rgbgen.h | 2 +- src/emu/video/rgbsse.c | 42 +++++----------------------------------- src/emu/video/rgbsse.h | 30 +++++++++++++++++++++++++--- src/emu/video/rgbvmx.c | 14 +++++++------- src/emu/video/rgbvmx.h | 2 +- src/emu/video/vooddefs.h | 2 +- 7 files changed, 43 insertions(+), 51 deletions(-) diff --git a/src/emu/video/rgbgen.c b/src/emu/video/rgbgen.c index 2586653ab54..4e7e6042569 100644 --- a/src/emu/video/rgbgen.c +++ b/src/emu/video/rgbgen.c @@ -117,7 +117,7 @@ void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& oth if ((UINT32)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; } } -void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) +void rgbaint_t::scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) { m_a = (m_a * scale.m_a + other.m_a * scale2.m_a) >> 8; m_r = (m_r * scale.m_r + other.m_r * scale2.m_r) >> 8; diff --git a/src/emu/video/rgbgen.h b/src/emu/video/rgbgen.h index 57504820404..dae5a2984d3 100644 --- a/src/emu/video/rgbgen.h +++ b/src/emu/video/rgbgen.h @@ -374,7 +374,7 @@ public: void scale_and_clamp(const rgbaint_t& scale); void scale_imm_and_clamp(const INT32 scale); - void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2); + void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2); 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); diff --git a/src/emu/video/rgbsse.c b/src/emu/video/rgbsse.c index 35f18b6e4b3..ed20479fd9e 100644 --- a/src/emu/video/rgbsse.c +++ b/src/emu/video/rgbsse.c @@ -174,53 +174,21 @@ void rgbaint_t::blend(const rgbaint_t& other, UINT8 factor) mul(scale1); add(scaled_other); - sra(8); + sra_imm(8); } void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) { mul(scale); - sra(8); - max(0); - min(255); + sra_imm(8); + clamp_to_uint8(); } void rgbaint_t::scale_imm_and_clamp(const INT32 scale) { mul_imm(scale); - sra(8); - max(0); - min(255); -} - -void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) -{ - rgbaint_t color2(other); - color2.mul(scale2); - - mul(scale); - add(color2); - sra(8); - max(0); - min(255); -} - -void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other) -{ - mul_imm(scale); - sra(8); - add(other); - max(0); - min(255); -} - -void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other) -{ - mul(scale); - sra(8); - add(other); - max(0); - min(255); + sra_imm(8); + clamp_to_uint8(); } #endif // defined(__SSE2__) || defined(_MSC_VER) diff --git a/src/emu/video/rgbsse.h b/src/emu/video/rgbsse.h index 78070d89ea2..5f88e0e717c 100644 --- a/src/emu/video/rgbsse.h +++ b/src/emu/video/rgbsse.h @@ -341,9 +341,33 @@ public: void scale_and_clamp(const rgbaint_t& scale); void scale_imm_and_clamp(const INT32 scale); - void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2); - 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 scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other) + { + mul_imm(scale); + sra_imm(8); + add(other); + clamp_to_uint8(); + } + + inline void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other) + { + mul(scale); + sra_imm(8); + add(other); + clamp_to_uint8(); + } + + inline void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) + { + rgbaint_t color2(other); + color2.mul(scale2); + + mul(scale); + add(color2); + sra_imm(8); + clamp_to_uint8(); + } inline void cmpeq(const rgbaint_t& value) { diff --git a/src/emu/video/rgbvmx.c b/src/emu/video/rgbvmx.c index 241893a64d9..7684a080ec0 100644 --- a/src/emu/video/rgbvmx.c +++ b/src/emu/video/rgbvmx.c @@ -168,13 +168,13 @@ void rgbaint_t::blend(const rgbaint_t& other, UINT8 factor) m_value = vec_msum((VECU16)m_value, (VECU16)scale1, vec_mulo((VECU16)other.m_value, (VECU16)scale2)); m_value = vec_add(vec_sl(temp, shift), (VECU32)m_value); - sra(8); + sra_imm(8); } void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) { mul(scale); - sra(8); + sra_imm(8); max(0); min(255); } @@ -182,19 +182,19 @@ void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) void rgbaint_t::scale_imm_and_clamp(const INT32 scale) { mul_imm(scale); - sra(8); + srsra_imma(8); max(0); min(255); } -void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) +void rgbaint_t::scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) { rgbaint_t color2(other); color2.mul(scale2); mul(scale); add(color2); - sra(8); + sra_imm(8); max(0); min(255); } @@ -202,7 +202,7 @@ void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& oth void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other) { mul_imm(scale); - sra(8); + sra_imm(8); add(other); max(0); min(255); @@ -211,7 +211,7 @@ void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& othe void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other) { mul(scale); - sra(8); + sra_imm(8); add(other); max(0); min(255); diff --git a/src/emu/video/rgbvmx.h b/src/emu/video/rgbvmx.h index af720723961..10c235eaa5a 100644 --- a/src/emu/video/rgbvmx.h +++ b/src/emu/video/rgbvmx.h @@ -342,7 +342,7 @@ public: void scale_and_clamp(const rgbaint_t& scale); void scale_imm_and_clamp(const INT32 scale); - void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2); + void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2); 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); diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index efa82284350..db67d2de8d5 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -2941,7 +2941,7 @@ INLINE void ATTR_FORCE_INLINE alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 // Main blend rgbaint_t destColor(da, dr, dg, db); - srcColor.scale_add_and_clamp(srcScale, destColor, destScale); + srcColor.scale2_add_and_clamp(srcScale, destColor, destScale); /* clamp */ //CLAMP((RR), 0x00, 0xff); //CLAMP((GG), 0x00, 0xff);