Fix alignment issues on 32 bit in qConvertA2RGB30PMToARGB64PM_sse2 and qConvertARGB32PMToARGB64PM_sse2

On 32 bit platforms the pointers may end up being 4 byte aligned.
Happens with MSVC on 32 bit Windows. _mm_store_si128 is documented to
require 16 byte alignment.

Change-Id: I80737fedf9e7f436a51a83924117cc0bc63017cc
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This commit is contained in:
Frederik Gladhorn 2015-10-22 14:38:44 +02:00 committed by Simon Hausmann
parent f343989852
commit 8ea61d6d2a

View File

@ -503,14 +503,16 @@ static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const
template<bool RGBA, bool maskAlpha>
static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count)
{
if (count <= 0)
return;
const __m128i amask = _mm_set1_epi32(0xff000000);
int i = 0;
if (((uintptr_t)buffer & 0xf) && count > 0) {
for (; ((uintptr_t)buffer & 0xf) && i < count; ++i) {
uint s = *src++;
if (RGBA)
s = RGBA2ARGB(s);
*buffer++ = QRgba64::fromArgb32(s);
i++;
}
for (; i < count-3; i += 4) {
__m128i vs = _mm_loadu_si128((const __m128i*)src);
@ -641,15 +643,18 @@ static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const ui
template<QtPixelOrder PixelOrder>
static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint *src, int count)
{
if (count <= 0)
return;
const __m128i rmask = _mm_set1_epi32(0x3ff00000);
const __m128i gmask = _mm_set1_epi32(0x000ffc00);
const __m128i bmask = _mm_set1_epi32(0x000003ff);
const __m128i afactor = _mm_set1_epi16(0x5555);
int i = 0;
if (((uintptr_t)buffer & 0xf) && count > 0) {
for (; ((uintptr_t)buffer & 0xf) && i < count; ++i)
*buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++);
i++;
}
for (; i < count-3; i += 4) {
__m128i vs = _mm_loadu_si128((const __m128i*)src);
src += 4;