Non-working rgbint_t::sub inline

This commit is contained in:
therealmogminer@gmail.com 2015-06-15 23:06:16 +02:00
parent b5be1c3695
commit ac5a98e8f3
3 changed files with 33 additions and 49 deletions

View File

@ -34,11 +34,6 @@ rgbint_t::rgbint_t(rgb_t& rgb)
m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128());
}
rgbint_t::rgbint_t(__m128i value)
{
m_value = value;
}
rgbaint_t::rgbaint_t()
{
set_rgba(0, 0, 0, 0);
@ -110,6 +105,12 @@ rgbint_t& rgbint_t::operator+=(const rgbint_t& other)
return *this;
}
rgbint_t& rgbint_t::operator+=(const INT32 other)
{
m_value = _mm_add_epi32(m_value, _mm_set1_epi32(other));
return *this;
}
rgbint_t& rgbint_t::operator-=(const rgbint_t& other)
{
m_value = _mm_sub_epi32(m_value, other.m_value);
@ -129,25 +130,10 @@ rgbint_t& rgbint_t::operator*=(const INT32 other)
return *this;
}
rgbint_t rgbint_t::operator+(const rgbint_t& other)
rgbint_t& rgbint_t::operator>>=(const INT32 shift)
{
return _mm_add_epi32(m_value, other.m_value);
}
rgbint_t rgbint_t::operator-(const rgbint_t& other)
{
return _mm_sub_epi32(m_value, other.m_value);
}
rgbint_t rgbint_t::operator*(const rgbint_t& other)
{
return _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, other.m_value), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(other.m_value, 4)), _MM_SHUFFLE(0, 0, 2, 0)));
}
rgbint_t rgbint_t::operator*(const INT32 other)
{
const __m128i immv = _mm_set1_epi32(other);
return _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, immv), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4)), _MM_SHUFFLE(0, 0, 2, 0)));
m_value = _mm_srai_epi32(m_value, shift);
return *this;
}
/***************************************************************************
@ -202,7 +188,7 @@ void rgbaint_t::add_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const
m_value = _mm_add_epi32(m_value, temp);
}
void rgbint_t::sub(const rgbint_t& color2)
inline void rgbint_t::sub(const rgbint_t& color2)
{
m_value = _mm_sub_epi32(m_value, color2.m_value);
}

View File

@ -74,18 +74,16 @@ public:
rgbint_t operator=(const rgbint_t& other);
rgbint_t& operator+=(const rgbint_t& other);
rgbint_t& operator+=(const INT32 other);
rgbint_t& operator-=(const rgbint_t& other);
rgbint_t& operator*=(const rgbint_t& other);
rgbint_t& operator*=(const INT32 other);
rgbint_t operator+(const rgbint_t& other);
rgbint_t operator-(const rgbint_t& other);
rgbint_t operator*(const rgbint_t& other);
rgbint_t operator*(const INT32 other);
rgbint_t& operator>>=(const INT32 shift);
static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v);
protected:
volatile __m128i m_value;
__m128i m_value;
private:
rgbint_t(__m128i value);

View File

@ -434,16 +434,16 @@ void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SS
rgbaint_t v2_vec((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata).get());
rgbaint_t v3_vec((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss2, sst2, tbase2, tpal, userdata).get());
v1_vec.sub(v3_vec);
v2_vec.sub(v3_vec);
v1_vec -= v3_vec;
v2_vec -= v3_vec;
v1_vec.mul_imm(invtf);
v2_vec.mul_imm(invsf);
v1_vec *= invtf;
v2_vec *= invsf;
v1_vec.add(v2_vec);
v1_vec.add_imm(0x0080);
v1_vec.sra(8);
v1_vec.add(v3_vec);
v1_vec += v2_vec;
v1_vec += 0x0080;
v1_vec >>= 8;
v1_vec += v3_vec;
TEX->set((UINT32)v1_vec.to_rgba());
#else
@ -464,16 +464,16 @@ void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SS
rgbaint_t v1_vec((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss2, sst1, tbase1, tpal, userdata).get());
rgbaint_t v2_vec((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata).get());
v1_vec.sub(v0_vec);
v2_vec.sub(v0_vec);
v1_vec -= v0_vec;
v2_vec -= v0_vec;
v1_vec.mul_imm(sfrac);
v2_vec.mul_imm(tfrac);
v1_vec *= sfrac;
v2_vec *= tfrac;
v1_vec.add(v2_vec);
v1_vec.add_imm(0x0080);
v1_vec.sra(8);
v1_vec.add(v0_vec);
v1_vec += v2_vec;
v1_vec += 0x0080;
v1_vec >>= 8;
v1_vec += v0_vec;
TEX->set((UINT32)v1_vec.to_rgba());
#else
@ -493,10 +493,10 @@ void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SS
#if USE_SIMD
rgbaint_t t0_vec((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase1, tpal, userdata).get());
t0_vec.add((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss2, sst1, tbase1, tpal, userdata).get());
t0_vec.add((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss2, sst2, tbase2, tpal, userdata).get());
t0_vec.add((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata).get());
t0_vec.shr(2);
t0_vec += (rgbaint_t)((this)->*(m_texel_fetch[index]))(sss2, sst1, tbase1, tpal, userdata).get();
t0_vec += (rgbaint_t)((this)->*(m_texel_fetch[index]))(sss2, sst2, tbase2, tpal, userdata).get();
t0_vec += (rgbaint_t)((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata).get();
t0_vec >>= 2;
TEX->set((UINT32)t0_vec.to_rgba());
#else