Make use of DirectXMath XM_ALIGNED_STRUCT macro

This commit is contained in:
Chuck Walbourn 2021-01-03 14:09:39 -08:00
parent f3bad9f318
commit fd13c32036
2 changed files with 8 additions and 4 deletions

View File

@ -104,7 +104,7 @@ namespace
if (!DetermineEncoderSettings(result.format, pfEncode, blocksize, cflags)) if (!DetermineEncoderSettings(result.format, pfEncode, blocksize, cflags))
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
__declspec(align(16)) XMVECTOR temp[16]; XM_ALIGNED_DATA(16) XMVECTOR temp[16];
const uint8_t *pSrc = image.pixels; const uint8_t *pSrc = image.pixels;
const uint8_t *pEnd = image.pixels + image.slicePitch; const uint8_t *pEnd = image.pixels + image.slicePitch;
const size_t rowPitch = image.rowPitch; const size_t rowPitch = image.rowPitch;
@ -263,7 +263,7 @@ namespace
assert(bytesLeft > 0); assert(bytesLeft > 0);
size_t bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft)); size_t bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft));
__declspec(align(16)) XMVECTOR temp[16]; XM_ALIGNED_DATA(16) XMVECTOR temp[16];
if (!_LoadScanline(&temp[0], pw, pSrc, bytesToRead, format)) if (!_LoadScanline(&temp[0], pw, pSrc, bytesToRead, format))
fail = true; fail = true;
@ -441,7 +441,7 @@ namespace
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
} }
__declspec(align(16)) XMVECTOR temp[16]; XM_ALIGNED_DATA(16) XMVECTOR temp[16];
const uint8_t *pSrc = cImage.pixels; const uint8_t *pSrc = cImage.pixels;
const size_t rowPitch = result.rowPitch; const size_t rowPitch = result.rowPitch;
for (size_t h = 0; h < cImage.height; h += 4) for (size_t h = 0; h < cImage.height; h += 4)
@ -534,7 +534,7 @@ namespace DirectX
// Scan blocks for non-opaque alpha // Scan blocks for non-opaque alpha
static const XMVECTORF32 threshold = { { { 0.99f, 0.99f, 0.99f, 0.99f } } }; static const XMVECTORF32 threshold = { { { 0.99f, 0.99f, 0.99f, 0.99f } } };
__declspec(align(16)) XMVECTOR temp[16]; XM_ALIGNED_DATA(16) XMVECTOR temp[16];
const uint8_t *pPixels = cImage.pixels; const uint8_t *pPixels = cImage.pixels;
for (size_t h = 0; h < cImage.height; h += 4) for (size_t h = 0; h < cImage.height; h += 4)
{ {

View File

@ -119,6 +119,10 @@
#include <DirectXPackedVector.h> #include <DirectXPackedVector.h>
#if (DIRECTX_MATH_VERSION < 315)
#define XM_ALIGNED_DATA(x) __declspec(align(x))
#endif
#include <malloc.h> #include <malloc.h>
#include <Ole2.h> #include <Ole2.h>