diff --git a/DirectXTex/DirectXTexPMAlpha.cpp b/DirectXTex/DirectXTexPMAlpha.cpp index fd7df1e..154b4a8 100644 --- a/DirectXTex/DirectXTexPMAlpha.cpp +++ b/DirectXTex/DirectXTexPMAlpha.cpp @@ -124,7 +124,10 @@ namespace { XMVECTOR v = *ptr; XMVECTOR alpha = XMVectorSplatW(*ptr); - alpha = XMVectorDivide(v, alpha); + if (XMVectorGetX(alpha) > 0) + { + alpha = XMVectorDivide(v, alpha); + } *(ptr++) = XMVectorSelect(v, alpha, g_XMSelect1110); } @@ -143,9 +146,9 @@ namespace assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); - static_assert(static_cast(TEX_PMALPHA_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); + static_assert(static_cast(TEX_PMALPHA_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); + static_assert(static_cast(TEX_PMALPHA_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); + static_assert(static_cast(TEX_PMALPHA_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); flags &= TEX_PMALPHA_SRGB; ScopedAlignedArrayXMVECTOR scanline(static_cast(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16))); @@ -167,7 +170,10 @@ namespace { XMVECTOR v = *ptr; XMVECTOR alpha = XMVectorSplatW(*ptr); - alpha = XMVectorDivide(v, alpha); + if (XMVectorGetX(alpha) > 0) + { + alpha = XMVectorDivide(v, alpha); + } *(ptr++) = XMVectorSelect(v, alpha, g_XMSelect1110); }