Skip to content

Commit d49942b

Browse files
authored
Merge pull request #249 from AlchemyViewer/rye/broken-rendering
Revert SIMD uuid to fix broken rendering
2 parents dce24b0 + 1ca4b16 commit d49942b

4 files changed

Lines changed: 35 additions & 250 deletions

File tree

indra/llcommon/lluuid.cpp

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,6 @@ void LLUUID::setNull()
935935
word[3] = 0;
936936
}
937937

938-
#if !defined(LL_X86) && !defined(LL_ARM64)
939938

940939
// Compare
941940
bool LLUUID::operator==(const LLUUID& rhs) const
@@ -988,6 +987,28 @@ bool LLUUID::isNull() const
988987
return !(word[0] | word[1] | word[2] | word[3]);
989988
}
990989

990+
LLUUID::LLUUID(const char* in_string)
991+
{
992+
if (!in_string || in_string[0] == 0)
993+
{
994+
setNull();
995+
return;
996+
}
997+
998+
set(in_string);
999+
}
1000+
1001+
LLUUID::LLUUID(const std::string& in_string)
1002+
{
1003+
if (in_string.empty())
1004+
{
1005+
setNull();
1006+
return;
1007+
}
1008+
1009+
set(in_string);
1010+
}
1011+
9911012
// IW: DON'T "optimize" these w/ U32s or you'll scoogie the sort order
9921013
// IW: this will make me very sad
9931014
bool LLUUID::operator<(const LLUUID& rhs) const
@@ -1016,30 +1037,6 @@ bool LLUUID::operator>(const LLUUID& rhs) const
10161037
return (mData[UUID_BYTES - 1] > rhs.mData[UUID_BYTES - 1]);
10171038
}
10181039

1019-
#endif
1020-
1021-
LLUUID::LLUUID(const char* in_string)
1022-
{
1023-
if (!in_string || in_string[0] == 0)
1024-
{
1025-
setNull();
1026-
return;
1027-
}
1028-
1029-
set(in_string);
1030-
}
1031-
1032-
LLUUID::LLUUID(const std::string& in_string)
1033-
{
1034-
if (in_string.empty())
1035-
{
1036-
setNull();
1037-
return;
1038-
}
1039-
1040-
set(in_string);
1041-
}
1042-
10431040
U16 LLUUID::getCRC16() const
10441041
{
10451042
// A UUID is 16 bytes, or 8 shorts.
@@ -1058,10 +1055,6 @@ U16 LLUUID::getCRC16() const
10581055

10591056
U32 LLUUID::getCRC32() const
10601057
{
1061-
U32 ret = 0;
1062-
for(U32 i = 0;i < 4;++i)
1063-
{
1064-
ret += (mData[i*4]) | (mData[i*4+1]) << 8 | (mData[i*4+2]) << 16 | (mData[i*4+3]) << 24;
1065-
}
1066-
return ret;
1058+
U32* tmp = (U32*)mData;
1059+
return tmp[0] + tmp[1] + tmp[2] + tmp[3];
10671060
}

indra/llcommon/lluuid.h

Lines changed: 7 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,13 @@
2626
#ifndef LL_LLUUID_H
2727
#define LL_LLUUID_H
2828

29-
#include "llpreprocessor.h"
30-
3129
#include <iostream>
3230
#include <set>
3331
#include <vector>
3432
#include "stdtypes.h"
33+
#include "llpreprocessor.h"
3534
#include <boost/functional/hash.hpp>
3635

37-
#if LL_ARM64
38-
#include "sse2neon.h"
39-
#elif LL_X86
40-
#include <immintrin.h>
41-
#endif
42-
4336
class LLMutex;
4437

4538
const S32 UUID_BYTES = 16;
@@ -83,15 +76,6 @@ class LL_COMMON_API LLUUID
8376
//
8477
// ACCESSORS
8578
//
86-
87-
// BEGIN BOOST
88-
// Contains code from the Boost Library with license below.
89-
/*
90-
* Copyright Andrey Semashev 2013.
91-
* Distributed under the Boost Software License, Version 1.0.
92-
* (See accompanying file LICENSE_1_0.txt or copy at
93-
* http://www.boost.org/LICENSE_1_0.txt)
94-
*/
9579
private:
9680
// Derived from Boost.UUID hash impl
9781
inline std::uint64_t hash_mix_mx( std::uint64_t x ) const noexcept
@@ -135,97 +119,17 @@ class LL_COMMON_API LLUUID
135119
return id.getHash();
136120
}
137121

138-
#if defined(LL_X86) || defined(LL_ARM64)
139-
LL_FORCE_INLINE __m128i load_unaligned_si128(const U8* p) const
140-
{
141-
return _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
142-
}
143-
144-
bool isNull() const // Faster than comparing to LLUUID::null.
145-
{
146-
__m128i mm = load_unaligned_si128(mData);
147-
#if defined(__AVX2__) || defined(__SSE4_1__) || defined(LL_ARM64)
148-
return _mm_test_all_zeros(mm, mm) != 0;
149-
#else
150-
mm = _mm_cmpeq_epi32(mm, _mm_setzero_si128());
151-
return _mm_movemask_epi8(mm) == 0xFFFF;
152-
#endif
153-
}
154-
155-
bool notNull() const // Faster than comparing to LLUUID::null.
156-
{
157-
return !isNull();
158-
}
122+
bool isNull() const; // Faster than comparing to LLUUID::null.
123+
bool notNull() const; // Faster than comparing to LLUUID::null.
159124
// JC: This is dangerous. It allows UUIDs to be cast automatically
160125
// to integers, among other things. Use isNull() or notNull().
161126
// operator bool() const;
162127

163-
bool operator==(const LLUUID& rhs) const
164-
{
165-
__m128i mm_left = load_unaligned_si128(mData);
166-
__m128i mm_right = load_unaligned_si128(rhs.mData);
167-
168-
#if defined(__AVX2__) || defined(__SSE4_1__) || defined(LL_ARM64)
169-
__m128i mm = _mm_xor_si128(mm_left, mm_right);
170-
return _mm_test_all_zeros(mm, mm) != 0;
171-
#else
172-
__m128i mm_cmp = _mm_cmpeq_epi32(mm_left, mm_right);
173-
return _mm_movemask_epi8(mm_cmp) == 0xFFFF;
174-
#endif
175-
}
176-
177-
bool operator!=(const LLUUID& rhs) const
178-
{
179-
return !((*this) == rhs);
180-
}
181-
182-
bool operator<(const LLUUID& rhs) const
183-
{
184-
__m128i mm_left = load_unaligned_si128(mData);
185-
__m128i mm_right = load_unaligned_si128(rhs.mData);
186-
187-
// To emulate lexicographical_compare behavior we have to perform two comparisons - the forward and reverse one.
188-
// Then we know which bytes are equivalent and which ones are different, and for those different the comparison results
189-
// will be opposite. Then we'll be able to find the first differing comparison result (for both forward and reverse ways),
190-
// and depending on which way it is for, this will be the result of the operation. There are a few notes to consider:
191-
//
192-
// 1. Due to little endian byte order the first bytes go into the lower part of the xmm registers,
193-
// so the comparison results in the least significant bits will actually be the most signigicant for the final operation result.
194-
// This means we have to determine which of the comparison results have the least significant bit on, and this is achieved with
195-
// the "(x - 1) ^ x" trick.
196-
// 2. Because there is only signed comparison in SSE/AVX, we have to invert byte comparison results whenever signs of the corresponding
197-
// bytes are different. I.e. in signed comparison it's -1 < 1, but in unsigned it is the opposite (255 > 1). To do that we XOR left and right,
198-
// making the most significant bit of each byte 1 if the signs are different, and later apply this mask with another XOR to the comparison results.
199-
// 3. pcmpgtw compares for "greater" relation, so we swap the arguments to get what we need.
200-
201-
const __m128i mm_signs_mask = _mm_xor_si128(mm_left, mm_right);
202-
203-
__m128i mm_cmp = _mm_cmpgt_epi8(mm_right, mm_left), mm_rcmp = _mm_cmpgt_epi8(mm_left, mm_right);
204-
205-
mm_cmp = _mm_xor_si128(mm_signs_mask, mm_cmp);
206-
mm_rcmp = _mm_xor_si128(mm_signs_mask, mm_rcmp);
207128

208-
uint32_t cmp = static_cast<uint32_t>(_mm_movemask_epi8(mm_cmp)), rcmp = static_cast<uint32_t>(_mm_movemask_epi8(mm_rcmp));
209-
210-
cmp = (cmp - 1u) ^ cmp;
211-
rcmp = (rcmp - 1u) ^ rcmp;
212-
213-
return cmp < rcmp;
214-
}
215-
216-
bool operator>(const LLUUID& rhs) const
217-
{
218-
return rhs < (*this);
219-
}
220-
// END BOOST
221-
#else // Non-intrinsic path
222-
bool isNull() const; // Faster than comparing to LLUUID::null.
223-
bool notNull() const; // Faster than comparing to LLUUID::null.
224-
bool operator==(const LLUUID& rhs) const;
225-
bool operator!=(const LLUUID& rhs) const;
226-
bool operator<(const LLUUID& rhs) const;
227-
bool operator>(const LLUUID& rhs) const;
228-
#endif
129+
bool operator==(const LLUUID &rhs) const;
130+
bool operator!=(const LLUUID &rhs) const;
131+
bool operator<(const LLUUID &rhs) const;
132+
bool operator>(const LLUUID &rhs) const;
229133

230134
// xor functions. Useful since any two random uuids xored together
231135
// will yield a determinate third random unique id that can be

indra/llprimitive/llmaterialid.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ LLMaterialID::LLMaterialID(const LLUUID& lluid)
6161
set(lluid.mData);
6262
}
6363

64-
#if !defined(LL_X86) && !defined(LL_ARM64)
65-
6664
bool LLMaterialID::operator == (const LLMaterialID& pOtherMaterialID) const
6765
{
6866
return (compareToOtherMaterialID(pOtherMaterialID) == 0);
@@ -98,8 +96,6 @@ bool LLMaterialID::isNull() const
9896
return (compareToOtherMaterialID(LLMaterialID::null) == 0);
9997
}
10098

101-
#endif
102-
10399
const U8* LLMaterialID::get() const
104100
{
105101
return mID;
@@ -138,7 +134,7 @@ std::string LLMaterialID::asString() const
138134
{
139135
materialIDString += "-";
140136
}
141-
const U32* value = reinterpret_cast<const U32*>(&get()[i * sizeof(U32)]);
137+
const U32 *value = reinterpret_cast<const U32*>(&get()[i * sizeof(U32)]);
142138
materialIDString += llformat("%08x", *value);
143139
}
144140
return materialIDString;
@@ -163,8 +159,6 @@ void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID)
163159
memcpy(mID, &pMaterialID[0], MATERIAL_ID_SIZE * sizeof(U8));
164160
}
165161

166-
#if !defined(LL_X86) && !defined(LL_ARM64)
167-
168162
int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const
169163
{
170164
int retVal = 0;
@@ -178,5 +172,3 @@ int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID)
178172

179173
return retVal;
180174
}
181-
182-
#endif

0 commit comments

Comments
 (0)