x64: Do not use a union of LLColor4U. Especially having the two pointer in there will blow up the struct to at least 8 byte, which will break VBO packing as this class needs to be 4 byte in size.

(transplanted from 847df86d6b5daa69dcfc428df18876a9c1e8bef6)
master
Nicky 2016-04-22 14:58:25 +02:00
parent 30dcad4b95
commit e8aa2dd71f
6 changed files with 44 additions and 17 deletions

View File

@ -1218,9 +1218,10 @@ void LLImageRaw::fill( const LLColor4U& color )
if( 4 == getComponents() )
{
U32* data = (U32*) getData();
U32 rgbaColor = color.asRGBA();
for( S32 i = 0; i < pixels; i++ )
{
data[i] = color.mAll;
data[ i ] = rgbaColor;
}
}
else

View File

@ -47,14 +47,7 @@ class LLColor4U
{
public:
union
{
U8 mV[LENGTHOFCOLOR4U];
U32 mAll;
LLColor4* mSources;
LLColor4U* mSourcesU;
};
U8 mV[LENGTHOFCOLOR4U];
LLColor4U(); // Initializes LLColor4U to (0, 0, 0, 1)
LLColor4U(U8 r, U8 g, U8 b); // Initializes LLColor4U to (r, g, b, 1)
@ -132,6 +125,9 @@ public:
return LLColor4(*this);
}
U32 asRGBA() const;
void fromRGBA( U32 aVal );
static LLColor4U white;
static LLColor4U black;
static LLColor4U red;
@ -565,6 +561,36 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color)
mV[3] = 255;
}
inline U32 LLColor4U::asRGBA() const
{
U32 nRet( 0 );
// Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here
nRet |= mV[ 3 ];
nRet <<= 8;
nRet |= mV[ 2 ];
nRet <<= 8;
nRet |= mV[ 1 ];
nRet <<= 8;
nRet |= mV[ 0 ];
return nRet;
}
inline void LLColor4U::fromRGBA( U32 aVal )
{
// Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here
mV[ 0 ] = aVal & 0xFF;
aVal >>= 8;
mV[ 1 ] = aVal & 0xFF;
aVal >>= 8;
mV[ 2 ] = aVal & 0xFF;
aVal >>= 8;
mV[ 3 ] = aVal & 0xFF;
}
#endif

View File

@ -2132,7 +2132,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLVector4a src;
U32 vec[4];
vec[0] = vec[1] = vec[2] = vec[3] = color.mAll;
vec[0] = vec[1] = vec[2] = vec[3] = color.asRGBA();
src.loadua((F32*) vec);
@ -2168,7 +2168,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLColor4U glow4u = LLColor4U(0,0,0,glow);
U32 glow32 = glow4u.mAll;
U32 glow32 = glow4u.asRGBA();
U32 vec[4];
vec[0] = vec[1] = vec[2] = vec[3] = glow32;

View File

@ -735,7 +735,7 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color,
continue;
}
S32 offset = px + py * image_width;
((U32*)datap)[offset] = color.mAll;
((U32*)datap)[offset] = color.asRGBA();
}
// top line
@ -748,7 +748,7 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color,
continue;
}
S32 offset = px + py * image_width;
((U32*)datap)[offset] = color.mAll;
((U32*)datap)[offset] = color.asRGBA();
}
}
else
@ -770,7 +770,7 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color,
continue;
}
S32 offset = p_x + p_y * image_width;
((U32*)datap)[offset] = color.mAll;
((U32*)datap)[offset] = color.asRGBA();
}
}
}

View File

@ -283,7 +283,7 @@ void LLSkyTex::create(const F32 brightness)
S32 offset = basic_offset * sComponents;
U32* pix = (U32*)(data + offset);
LLColor4U temp = LLColor4U(mSkyData[basic_offset]);
*pix = temp.mAll;
*pix = temp.asRGBA();
}
}
createGLImage(sCurrent);

View File

@ -171,7 +171,7 @@ protected:
{
S32 offset = (i * sResolution + j) * sComponents;
U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
*pix = col.mAll;
*pix = col.asRGBA();
}
LLColor4U getPixel(const S32 i, const S32 j)
@ -179,7 +179,7 @@ protected:
LLColor4U col;
S32 offset = (i * sResolution + j) * sComponents;
U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
col.mAll = *pix;
col.fromRGBA( *pix );
return col;
}