summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/video
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2016-07-14 00:50:19 +1000
committer Vas Crabb <vas@vastheman.com>2016-07-14 00:50:19 +1000
commitac7c2ce2d47483396a1825538156866174f21640 (patch)
treefa8e04b01c29e3274136a1d19ca9426d6ce229bf /src/emu/video
parent32873fc1dd2587977b4b2cb31e6dfa6f50a690e1 (diff)
Introduce validity checks for RGB utilities and fix bugs uncovered [Vas Crabb]
* Added several missing functions to rgbgen * Fixed logical shift right in rgbgen * Fixed sra that should be sra_imm in rdptpipe * Added some simple SSE4.1 optimisations in rgbsse * Re-organised rgbsse, rgbvmx and rgbgen to be in more logical order * Fixed return on some modifying operators * Made some more reference parameters const * Removed inline qualifier from a number of methods as it's implied when body is present at declaration * Mark some constructors explicit
Diffstat (limited to 'src/emu/video')
-rw-r--r--src/emu/video/rgbgen.h209
-rw-r--r--src/emu/video/rgbsse.cpp6
-rw-r--r--src/emu/video/rgbsse.h137
-rw-r--r--src/emu/video/rgbutil.h8
-rw-r--r--src/emu/video/rgbvmx.h186
5 files changed, 245 insertions, 301 deletions
diff --git a/src/emu/video/rgbgen.h b/src/emu/video/rgbgen.h
index 42014d14106..22cd253b3f8 100644
--- a/src/emu/video/rgbgen.h
+++ b/src/emu/video/rgbgen.h
@@ -8,8 +8,8 @@
***************************************************************************/
-#ifndef __RGBGEN__
-#define __RGBGEN__
+#ifndef MAME_EMU_VIDEO_RGBGEN_H
+#define MAME_EMU_VIDEO_RGBGEN_H
/***************************************************************************
@@ -19,36 +19,48 @@
class rgbaint_t
{
public:
- inline rgbaint_t(): m_a(0), m_r(0), m_g(0), m_b(0) { }
- inline rgbaint_t(UINT32 rgba) { set(rgba); }
- inline rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
- inline rgbaint_t(const rgb_t& rgba) { set(rgba); }
+ rgbaint_t(): m_a(0), m_r(0), m_g(0), m_b(0) { }
+ explicit rgbaint_t(UINT32 rgba) { set(rgba); }
+ rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
+ explicit rgbaint_t(const rgb_t& rgba) { set(rgba); }
- inline void set(rgbaint_t& other) { set(other.m_a, other.m_r, other.m_g, other.m_b); }
- inline void set(UINT32 rgba) { set((rgba >> 24) & 0xff, (rgba >> 16) & 0xff, (rgba >> 8) & 0xff, rgba & 0xff); }
- inline void set(INT32 a, INT32 r, INT32 g, INT32 b)
+ 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)
{
m_a = a;
m_r = r;
m_g = g;
m_b = b;
}
- inline void set(const rgb_t& rgba) { set(rgba.a(), rgba.r(), rgba.g(), rgba.b()); }
+ void set(const rgb_t& rgba) { set(rgba.a(), rgba.r(), rgba.g(), rgba.b()); }
- inline rgb_t to_rgba() const
- {
- return rgb_t(m_a, m_r, m_g, m_b);
- }
+ rgb_t to_rgba() const { return rgb_t(get_a(), get_r(), get_g(), get_b()); }
- inline rgb_t to_rgba_clamp() const
+ rgb_t to_rgba_clamp() const
{
- UINT8 a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a;
- UINT8 r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r;
- UINT8 g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g;
- UINT8 b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b;
+ const UINT8 a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a;
+ const UINT8 r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r;
+ const UINT8 g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g;
+ const UINT8 b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b;
return rgb_t(a, r, g, b);
}
+ void set_a(const INT32 value) { m_a = value; }
+ void set_r(const INT32 value) { m_r = value; }
+ void set_g(const INT32 value) { m_g = value; }
+ void set_b(const INT32 value) { m_b = value; }
+
+ UINT8 get_a() const { return UINT8(UINT32(m_a)); }
+ UINT8 get_r() const { return UINT8(UINT32(m_r)); }
+ UINT8 get_g() const { return UINT8(UINT32(m_g)); }
+ UINT8 get_b() const { return UINT8(UINT32(m_b)); }
+
+ INT32 get_a32() const { return m_a; }
+ INT32 get_r32() const { return m_r; }
+ INT32 get_g32() const { return m_g; }
+ INT32 get_b32() const { return m_b; }
+
inline void add(const rgbaint_t& color)
{
add_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
@@ -85,7 +97,7 @@ public:
m_b -= b;
}
- inline void subr(rgbaint_t& color)
+ inline void subr(const rgbaint_t& color)
{
subr_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
@@ -103,67 +115,7 @@ public:
m_b = b - m_b;
}
- inline void set_a(const INT32 value)
- {
- m_a = value;
- }
-
- inline void set_r(const INT32 value)
- {
- m_r = value;
- }
-
- inline void set_g(const INT32 value)
- {
- m_g = value;
- }
-
- inline void set_b(const INT32 value)
- {
- m_b = value;
- }
-
- inline UINT8 get_a() const
- {
- return m_a;
- }
-
- inline UINT8 get_r() const
- {
- return m_r;
- }
-
- inline UINT8 get_g() const
- {
- return m_g;
- }
-
- inline UINT8 get_b() const
- {
- return m_b;
- }
-
- inline INT32 get_a32() const
- {
- return m_a;
- }
-
- inline INT32 get_r32() const
- {
- return m_r;
- }
-
- inline INT32 get_g32() const
- {
- return m_g;
- }
-
- inline INT32 get_b32() const
- {
- return m_b;
- }
-
- inline void mul(rgbaint_t& color)
+ inline void mul(const rgbaint_t& color)
{
mul_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
@@ -202,10 +154,10 @@ public:
inline void shr(const rgbaint_t& shift)
{
- m_a >>= shift.m_a;
- m_r >>= shift.m_r;
- m_g >>= shift.m_g;
- m_b >>= shift.m_b;
+ m_a = INT32(UINT32(m_a) >> shift.m_a);
+ m_r = INT32(UINT32(m_r) >> shift.m_r);
+ m_g = INT32(UINT32(m_g) >> shift.m_g);
+ m_b = INT32(UINT32(m_b) >> shift.m_b);
}
inline void shr_imm(const UINT8 shift)
@@ -213,10 +165,10 @@ public:
if (shift == 0)
return;
- m_a >>= shift;
- m_r >>= shift;
- m_g >>= shift;
- m_b >>= shift;
+ m_a = INT32(UINT32(m_a) >> shift);
+ m_r = INT32(UINT32(m_r) >> shift);
+ m_g = INT32(UINT32(m_g) >> shift);
+ m_b = INT32(UINT32(m_b) >> shift);
}
inline void sra(const rgbaint_t& shift)
@@ -321,22 +273,12 @@ public:
inline void clamp_and_clear(const UINT32 sign)
{
- if (m_a & sign)
- m_a = 0;
-
- if (m_r & sign)
- m_r = 0;
-
- if (m_g & sign)
- m_g = 0;
+ if (m_a & sign) m_a = 0;
+ if (m_r & sign) m_r = 0;
+ if (m_g & sign) m_g = 0;
+ if (m_b & sign) m_b = 0;
- if (m_b & sign)
- m_b = 0;
-
- m_a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a;
- m_r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r;
- m_g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g;
- m_b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b;
+ clamp_to_uint8();
}
inline void clamp_to_uint8()
@@ -370,6 +312,14 @@ public:
m_b = (m_b > value) ? value : m_b;
}
+ inline void max(const INT32 value)
+ {
+ m_a = (m_a < value) ? value : m_a;
+ m_r = (m_r < value) ? value : m_r;
+ m_g = (m_g < value) ? value : m_g;
+ m_b = (m_b < value) ? value : m_b;
+ }
+
void blend(const rgbaint_t& other, UINT8 factor);
void scale_and_clamp(const rgbaint_t& scale);
@@ -426,35 +376,50 @@ public:
m_b = (m_b < value) ? 0xffffffff : 0;
}
- inline void merge_alpha(rgbaint_t& alpha)
+ inline void merge_alpha(const rgbaint_t& alpha)
{
m_a = alpha.m_a;
}
- inline rgbaint_t operator=(const rgbaint_t& other)
+ 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);
+ return *this;
+ }
+
+ rgbaint_t& operator+=(const INT32 other)
+ {
+ add_imm_rgba(other, other, other, other);
+ return *this;
+ }
+
+ rgbaint_t &operator-=(const rgbaint_t& other)
+ {
+ sub_imm_rgba(other.m_a, other.m_r, other.m_g, other.m_b);
+ return *this;
+ }
+
+ rgbaint_t& operator*=(const rgbaint_t& other)
{
- m_a = other.m_a;
- m_r = other.m_r;
- m_g = other.m_g;
- m_b = other.m_b;
+ mul_imm_rgba(other.m_a, other.m_r, other.m_g, other.m_b);
return *this;
}
- inline rgbaint_t& operator+=(const rgbaint_t& other)
+ rgbaint_t& operator*=(const INT32 other)
{
- m_a += other.m_a;
- m_r += other.m_r;
- m_g += other.m_g;
- m_b += other.m_b;
+ mul_imm_rgba(other, other, other, other);
return *this;
}
- inline rgbaint_t& operator+=(const INT32 other)
+ rgbaint_t& operator>>=(const INT32 shift)
{
- m_a += other;
- m_r += other;
- m_g += other;
- m_b += other;
+ sra_imm(shift);
return *this;
}
@@ -477,7 +442,7 @@ public:
return ((ag0 << 8) & 0xff00ff00) | (rb0 & 0x00ff00ff);
}
- inline void bilinear_filter_rgbaint(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
+ void bilinear_filter_rgbaint(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
{
UINT32 rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8);
UINT32 rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8);
@@ -504,4 +469,4 @@ protected:
INT32 m_b;
};
-#endif /* __RGBGEN__ */
+#endif // MAME_EMU_VIDEO_RGBGEN_H
diff --git a/src/emu/video/rgbsse.cpp b/src/emu/video/rgbsse.cpp
index ed20479fd9e..a26abed5609 100644
--- a/src/emu/video/rgbsse.cpp
+++ b/src/emu/video/rgbsse.cpp
@@ -166,13 +166,13 @@ const struct rgbaint_t::_statics rgbaint_t::statics =
void rgbaint_t::blend(const rgbaint_t& other, UINT8 factor)
{
- __m128i scale1 = _mm_set1_epi32(factor);
- __m128i scale2 = _mm_sub_epi32(_mm_set1_epi32(0x100), scale1);
+ const __m128i scale1 = _mm_set1_epi32(factor);
+ const rgbaint_t scale2(_mm_sub_epi32(_mm_set1_epi32(0x100), scale1));
rgbaint_t scaled_other(other);
scaled_other.mul(scale2);
- mul(scale1);
+ mul(rgbaint_t(scale1));
add(scaled_other);
sra_imm(8);
}
diff --git a/src/emu/video/rgbsse.h b/src/emu/video/rgbsse.h
index 99e99ddcde2..6b7c1bd6043 100644
--- a/src/emu/video/rgbsse.h
+++ b/src/emu/video/rgbsse.h
@@ -10,10 +10,16 @@
***************************************************************************/
-#ifndef __RGBSSE__
-#define __RGBSSE__
+#ifndef MAME_EMU_VIDEO_RGBSSE_H
+#define MAME_EMU_VIDEO_RGBSSE_H
+
+#pragma once
#include <emmintrin.h>
+#ifdef __SSE4_1__
+#include <smmintrin.h>
+#endif
+
/***************************************************************************
TYPE DEFINITIONS
@@ -22,16 +28,16 @@
class rgbaint_t
{
public:
- inline rgbaint_t() { }
- inline rgbaint_t(UINT32 rgba) { set(rgba); }
- inline rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
- inline rgbaint_t(const rgb_t& rgb) { set(rgb); }
- inline rgbaint_t(__m128i rgba) { m_value = rgba; }
+ rgbaint_t() { }
+ explicit rgbaint_t(UINT32 rgba) { set(rgba); }
+ rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
+ explicit rgbaint_t(const rgb_t& rgb) { set(rgb); }
+ explicit rgbaint_t(__m128i rgba) { m_value = rgba; }
- inline void set(rgbaint_t& other) { m_value = other.m_value; }
- inline void set(UINT32 rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); }
- inline void set(INT32 a, INT32 r, INT32 g, INT32 b) { m_value = _mm_set_epi32(a, r, g, b); }
- inline 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 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); }
+ void set(const rgb_t& rgb) { m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()), _mm_setzero_si128()); }
inline rgb_t to_rgba() const
{
@@ -43,6 +49,35 @@ public:
return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(m_value, _mm_setzero_si128()), _mm_setzero_si128()));
}
+#ifdef __SSE4_1__
+ void set_a(const INT32 value) { m_value = _mm_insert_epi32(m_value, value, 3); }
+ void set_r(const INT32 value) { m_value = _mm_insert_epi32(m_value, value, 2); }
+ void set_g(const INT32 value) { m_value = _mm_insert_epi32(m_value, value, 1); }
+ void set_b(const INT32 value) { m_value = _mm_insert_epi32(m_value, value, 0); }
+#else
+ void set_a(const INT32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, alpha_mask()), _mm_set_epi32(value, 0, 0, 0)); }
+ void set_r(const INT32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, red_mask()), _mm_set_epi32(0, value, 0, 0)); }
+ void set_g(const INT32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, green_mask()), _mm_set_epi32(0, 0, value, 0)); }
+ void set_b(const INT32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, blue_mask()), _mm_set_epi32(0, 0, 0, value)); }
+#endif
+
+ UINT8 get_a() const { return UINT8(unsigned(_mm_extract_epi16(m_value, 6))); }
+ UINT8 get_r() const { return UINT8(unsigned(_mm_extract_epi16(m_value, 4))); }
+ UINT8 get_g() const { return UINT8(unsigned(_mm_extract_epi16(m_value, 2))); }
+ UINT8 get_b() const { return UINT8(unsigned(_mm_extract_epi16(m_value, 0))); }
+
+#ifdef __SSE4_1__
+ INT32 get_a32() const { return _mm_extract_epi32(m_value, 3); }
+ INT32 get_r32() const { return _mm_extract_epi32(m_value, 2); }
+ INT32 get_g32() const { return _mm_extract_epi32(m_value, 1); }
+ INT32 get_b32() const { return _mm_extract_epi32(m_value, 0); }
+#else
+ INT32 get_a32() const { return (_mm_extract_epi16(m_value, 7) << 16) | _mm_extract_epi16(m_value, 6); }
+ INT32 get_r32() const { return (_mm_extract_epi16(m_value, 5) << 16) | _mm_extract_epi16(m_value, 4); }
+ INT32 get_g32() const { return (_mm_extract_epi16(m_value, 3) << 16) | _mm_extract_epi16(m_value, 2); }
+ INT32 get_b32() const { return (_mm_extract_epi16(m_value, 1) << 16) | _mm_extract_epi16(m_value, 0); }
+#endif
+
inline void add(const rgbaint_t& color2)
{
m_value = _mm_add_epi32(m_value, color2.m_value);
@@ -73,7 +108,7 @@ public:
m_value = _mm_sub_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
- inline void subr(rgbaint_t& color2)
+ inline void subr(const rgbaint_t& color2)
{
m_value = _mm_sub_epi32(color2.m_value, m_value);
}
@@ -88,66 +123,6 @@ public:
m_value = _mm_sub_epi32(_mm_set_epi32(a, r, g, b), m_value);
}
- inline void set_a(const INT32 value)
- {
- m_value = _mm_or_si128(_mm_and_si128(m_value, alpha_mask()), _mm_set_epi32(value, 0, 0, 0));
- }
-
- inline void set_r(const INT32 value)
- {
- m_value = _mm_or_si128(_mm_and_si128(m_value, red_mask()), _mm_set_epi32(0, value, 0, 0));
- }
-
- inline void set_g(const INT32 value)
- {
- m_value = _mm_or_si128(_mm_and_si128(m_value, green_mask()), _mm_set_epi32(0, 0, value, 0));
- }
-
- inline void set_b(const INT32 value)
- {
- m_value = _mm_or_si128(_mm_and_si128(m_value, blue_mask()), _mm_set_epi32(0, 0, 0, value));
- }
-
- inline UINT8 get_a() const
- {
- return _mm_extract_epi16(m_value, 6);
- }
-
- inline UINT8 get_r() const
- {
- return _mm_extract_epi16(m_value, 4);
- }
-
- inline UINT8 get_g() const
- {
- return _mm_extract_epi16(m_value, 2);
- }
-
- inline UINT8 get_b() const
- {
- return _mm_extract_epi16(m_value, 0);
- }
-
- inline INT32 get_a32() const
- {
- return (_mm_extract_epi16(m_value, 7) << 16) | _mm_extract_epi16(m_value, 6);
- }
-
- inline INT32 get_r32() const
- {
- return (_mm_extract_epi16(m_value, 5) << 16) | _mm_extract_epi16(m_value, 4);
- }
-
- inline INT32 get_g32() const
- {
- return (_mm_extract_epi16(m_value, 3) << 16) | _mm_extract_epi16(m_value, 2);
- }
-
- inline INT32 get_b32() const
- {
- return (_mm_extract_epi16(m_value, 1) << 16) | _mm_extract_epi16(m_value, 0);
- }
-
inline void mul(const rgbaint_t& color)
{
__m128i tmp1 = _mm_mul_epu32(m_value, color.m_value);
@@ -414,7 +389,7 @@ public:
m_value = _mm_cmplt_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
- inline rgbaint_t operator=(const rgbaint_t& other)
+ inline rgbaint_t &operator=(const rgbaint_t& other)
{
m_value = other.m_value;
return *this;
@@ -459,8 +434,12 @@ public:
inline void merge_alpha(const rgbaint_t& alpha)
{
+#ifdef __SSE4_1__
+ m_value = _mm_insert_epi32(m_value, _mm_extract_epi32(alpha.m_value, 3), 3);
+#else
m_value = _mm_insert_epi16(m_value, _mm_extract_epi16(alpha.m_value, 7), 7);
m_value = _mm_insert_epi16(m_value, _mm_extract_epi16(alpha.m_value, 6), 6);
+#endif
}
static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
@@ -487,7 +466,7 @@ public:
return _mm_cvtsi128_si32(color01);
}
- inline void bilinear_filter_rgbaint(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
+ void bilinear_filter_rgbaint(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
{
__m128i color00 = _mm_cvtsi32_si128(rgb00);
__m128i color01 = _mm_cvtsi32_si128(rgb01);
@@ -519,11 +498,11 @@ protected:
INT16 scale_table[256][8];
};
- static inline __m128i alpha_mask() { return *(__m128i *)&statics.alpha_mask[0]; }
- static inline __m128i red_mask() { return *(__m128i *)&statics.red_mask[0]; }
- static inline __m128i green_mask() { return *(__m128i *)&statics.green_mask[0]; }
- static inline __m128i blue_mask() { return *(__m128i *)&statics.blue_mask[0]; }
- static inline __m128i scale_factor(UINT8 index) { return *(__m128i *)&statics.scale_table[index][0]; }
+ static __m128i alpha_mask() { return *(__m128i *)&statics.alpha_mask[0]; }
+ static __m128i red_mask() { return *(__m128i *)&statics.red_mask[0]; }
+ static __m128i green_mask() { return *(__m128i *)&statics.green_mask[0]; }
+ static __m128i blue_mask() { return *(__m128i *)&statics.blue_mask[0]; }
+ static __m128i scale_factor(UINT8 index) { return *(__m128i *)&statics.scale_table[index][0]; }
__m128i m_value;
diff --git a/src/emu/video/rgbutil.h b/src/emu/video/rgbutil.h
index 15def4da2c0..e0ccd299a4e 100644
--- a/src/emu/video/rgbutil.h
+++ b/src/emu/video/rgbutil.h
@@ -9,10 +9,10 @@
***************************************************************************/
-#ifndef __RGBUTIL__
-#define __RGBUTIL__
+#ifndef MAME_EMU_VIDEO_RGBUTIL_H
+#define MAME_EMU_VIDEO_RGBUTIL_H
-/* use SSE on 64-bit implementations, where it can be assumed */
+// use SSE on 64-bit implementations, where it can be assumed
#if (!defined(MAME_DEBUG) || defined(__OPTIMIZE__)) && (defined(__SSE2__) || defined(_MSC_VER)) && defined(PTR64)
#include "rgbsse.h"
#elif defined(__ALTIVEC__)
@@ -21,4 +21,4 @@
#include "rgbgen.h"
#endif
-#endif /* __RGBUTIL__ */
+#endif // MAME_EMU_VIDEO_RGBUTIL_H
diff --git a/src/emu/video/rgbvmx.h b/src/emu/video/rgbvmx.h
index e034261461e..4aca3ff8fa9 100644
--- a/src/emu/video/rgbvmx.h
+++ b/src/emu/video/rgbvmx.h
@@ -28,15 +28,15 @@ protected:
typedef __vector unsigned int VECU32;
public:
- inline rgbaint_t() { set(0, 0, 0, 0); }
- inline rgbaint_t(UINT32 rgba) { set(rgba); }
- inline rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
- inline rgbaint_t(const rgb_t& rgb) { set(rgb); }
- inline rgbaint_t(VECS32 rgba) : m_value(rgba) { }
+ rgbaint_t() { set(0, 0, 0, 0); }
+ explicit rgbaint_t(UINT32 rgba) { set(rgba); }
+ rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b) { set(a, r, g, b); }
+ explicit rgbaint_t(const rgb_t& rgb) { set(rgb); }
+ explicit rgbaint_t(VECS32 rgba) : m_value(rgba) { }
- inline void set(rgbaint_t& other) { m_value = other.m_value; }
+ void set(const rgbaint_t& other) { m_value = other.m_value; }
- inline void set(UINT32 rgba)
+ void set(UINT32 rgba)
{
const VECU32 zero = { 0, 0, 0, 0 };
#ifdef __LITTLE_ENDIAN__
@@ -48,7 +48,7 @@ public:
#endif
}
- inline void set(INT32 a, INT32 r, INT32 g, INT32 b)
+ void set(INT32 a, INT32 r, INT32 g, INT32 b)
{
#ifdef __LITTLE_ENDIAN__
const VECS32 result = { b, g, r, a };
@@ -58,7 +58,7 @@ public:
m_value = result;
}
- inline void set(const rgb_t& rgb)
+ void set(const rgb_t& rgb)
{
const VECU32 zero = { 0, 0, 0, 0 };
#ifdef __LITTLE_ENDIAN__
@@ -88,94 +88,31 @@ public:
return result;
}
- inline void add(const rgbaint_t& color2)
- {
- m_value = vec_add(m_value, color2.m_value);
- }
-
- inline void add_imm(const INT32 imm)
- {
- const VECS32 temp = { imm, imm, imm, imm };
- m_value = vec_add(m_value, temp);
- }
-
- inline void add_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
- {
-#ifdef __LITTLE_ENDIAN__
- const VECS32 temp = { b, g, r, a };
-#else
- const VECS32 temp = { a, r, g, b };
-#endif
- m_value = vec_add(m_value, temp);
- }
-
- inline void sub(const rgbaint_t& color2)
- {
- m_value = vec_sub(m_value, color2.m_value);
- }
-
- inline void sub_imm(const INT32 imm)
- {
- const VECS32 temp = { imm, imm, imm, imm };
- m_value = vec_sub(m_value, temp);
- }
-
- inline void sub_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
- {
-#ifdef __LITTLE_ENDIAN__
- const VECS32 temp = { b, g, r, a };
-#else
- const VECS32 temp = { a, r, g, b };
-#endif
- m_value = vec_sub(m_value, temp);
- }
-
- inline void subr(rgbaint_t& color2)
- {
- m_value = vec_sub(color2.m_value, m_value);
- }
-
- inline void subr_imm(const INT32 imm)
- {
- const VECS32 temp = { imm, imm, imm, imm };
- m_value = vec_sub(temp, m_value);
- }
-
- inline void subr_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
- {
-#ifdef __LITTLE_ENDIAN__
- const VECS32 temp = { b, g, r, a };
-#else
- const VECS32 temp = { a, r, g, b };
-#endif
- m_value = vec_sub(temp, m_value);
- }
-
- inline void set_a(const INT32 value)
+ void set_a(const INT32 value)
{
const VECS32 temp = { value, value, value, value };
m_value = vec_perm(m_value, temp, alpha_perm);
}
- inline void set_r(const INT32 value)
+ void set_r(const INT32 value)
{
const VECS32 temp = { value, value, value, value };
m_value = vec_perm(m_value, temp, red_perm);
}
- inline void set_g(const INT32 value)
+ void set_g(const INT32 value)
{
const VECS32 temp = { value, value, value, value };
m_value = vec_perm(m_value, temp, green_perm);
}
- inline void set_b(const INT32 value)
+ void set_b(const INT32 value)
{
const VECS32 temp = { value, value, value, value };
m_value = vec_perm(m_value, temp, blue_perm);
}
- inline UINT8 get_a() const
+ UINT8 get_a() const
{
UINT8 result;
#ifdef __LITTLE_ENDIAN__
@@ -186,7 +123,7 @@ public:
return result;
}
- inline UINT8 get_r() const
+ UINT8 get_r() const
{
UINT8 result;
#ifdef __LITTLE_ENDIAN__
@@ -197,7 +134,7 @@ public:
return result;
}
- inline UINT8 get_g() const
+ UINT8 get_g() const
{
UINT8 result;
#ifdef __LITTLE_ENDIAN__
@@ -208,7 +145,7 @@ public:
return result;
}
- inline UINT8 get_b() const
+ UINT8 get_b() const
{
UINT8 result;
#ifdef __LITTLE_ENDIAN__
@@ -219,7 +156,7 @@ public:
return result;
}
- inline INT32 get_a32() const
+ INT32 get_a32() const
{
INT32 result;
#ifdef __LITTLE_ENDIAN__
@@ -230,7 +167,7 @@ public:
return result;
}
- inline INT32 get_r32() const
+ INT32 get_r32() const
{
INT32 result;
#ifdef __LITTLE_ENDIAN__
@@ -241,7 +178,7 @@ public:
return result;
}
- inline INT32 get_g32() const
+ INT32 get_g32() const
{
INT32 result;
#ifdef __LITTLE_ENDIAN__
@@ -252,7 +189,7 @@ public:
return result;
}
- inline INT32 get_b32() const
+ INT32 get_b32() const
{
INT32 result;
#ifdef __LITTLE_ENDIAN__
@@ -263,6 +200,69 @@ public:
return result;
}
+ inline void add(const rgbaint_t& color2)
+ {
+ m_value = vec_add(m_value, color2.m_value);
+ }
+
+ inline void add_imm(const INT32 imm)
+ {
+ const VECS32 temp = { imm, imm, imm, imm };
+ m_value = vec_add(m_value, temp);
+ }
+
+ inline void add_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
+ {
+#ifdef __LITTLE_ENDIAN__
+ const VECS32 temp = { b, g, r, a };
+#else
+ const VECS32 temp = { a, r, g, b };
+#endif
+ m_value = vec_add(m_value, temp);
+ }
+
+ inline void sub(const rgbaint_t& color2)
+ {
+ m_value = vec_sub(m_value, color2.m_value);
+ }
+
+ inline void sub_imm(const INT32 imm)
+ {
+ const VECS32 temp = { imm, imm, imm, imm };
+ m_value = vec_sub(m_value, temp);
+ }
+
+ inline void sub_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
+ {
+#ifdef __LITTLE_ENDIAN__
+ const VECS32 temp = { b, g, r, a };
+#else
+ const VECS32 temp = { a, r, g, b };
+#endif
+ m_value = vec_sub(m_value, temp);
+ }
+
+ inline void subr(const rgbaint_t& color2)
+ {
+ m_value = vec_sub(color2.m_value, m_value);
+ }
+
+ inline void subr_imm(const INT32 imm)
+ {
+ const VECS32 temp = { imm, imm, imm, imm };
+ m_value = vec_sub(temp, m_value);
+ }
+
+ inline void subr_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
+ {
+#ifdef __LITTLE_ENDIAN__
+ const VECS32 temp = { b, g, r, a };
+#else
+ const VECS32 temp = { a, r, g, b };
+#endif
+ m_value = vec_sub(temp, m_value);
+ }
+
inline void mul(const rgbaint_t& color)
{
const VECU32 shift = vec_splat_u32(-16);
@@ -545,7 +545,7 @@ public:
m_value = VECS32(vec_cmplt(m_value, temp));
}
- inline rgbaint_t operator=(const rgbaint_t& other)
+ inline rgbaint_t &operator=(const rgbaint_t& other)
{
m_value = other.m_value;
return *this;
@@ -607,7 +607,7 @@ public:
m_value = vec_perm(m_value, alpha.m_value, alpha_perm);
}
- static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
+ static UINT32 bilinear_filter(const UINT32 &rgb00, const UINT32 &rgb01, const UINT32 &rgb10, const UINT32 &rgb11, UINT8 u, UINT8 v)
{
const VECS32 zero = vec_splat_s32(0);
@@ -650,7 +650,7 @@ public:
return result;
}
- inline void bilinear_filter_rgbaint(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
+ void bilinear_filter_rgbaint(const UINT32 &rgb00, const UINT32 &rgb01, const UINT32 &rgb10, const UINT32 &rgb11, UINT8 u, UINT8 v)
{
const VECS32 zero = vec_splat_s32(0);
@@ -688,13 +688,13 @@ public:
}
protected:
- VECS32 m_value;
+ VECS32 m_value;
- static const VECU8 alpha_perm;
- static const VECU8 red_perm;
- static const VECU8 green_perm;
- static const VECU8 blue_perm;
- static const VECS16 scale_table[256];
+ static const VECU8 alpha_perm;
+ static const VECU8 red_perm;
+ static const VECU8 green_perm;
+ static const VECU8 blue_perm;
+ static const VECS16 scale_table[256];
};