From 91654fc9df8e289dfc9d9f8080fd98dca39ee9f8 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Thu, 4 Apr 2013 11:27:05 -0700 Subject: [PATCH] Fixed bug with non-square volume mipmaps --- DirectXTex/DirectXTexMipmaps.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DirectXTex/DirectXTexMipmaps.cpp b/DirectXTex/DirectXTexMipmaps.cpp index a77630d..631a244 100644 --- a/DirectXTex/DirectXTexMipmaps.cpp +++ b/DirectXTex/DirectXTexMipmaps.cpp @@ -579,7 +579,7 @@ static HRESULT _Generate3DMipsPointFilter( _In_ size_t depth, _In_ size_t levels size_t rowPitch = src->rowPitch; - size_t nheight = height >> 1; + size_t nheight = (height > 1) ? (height >> 1) : 1; for( size_t y = 0; y < nheight; ++y ) { @@ -587,7 +587,7 @@ static HRESULT _Generate3DMipsPointFilter( _In_ size_t depth, _In_ size_t levels return E_FAIL; pSrc += rowPitch*2; - size_t nwidth = width >> 1; + size_t nwidth = (width > 1) ? (width >> 1) : 1; for( size_t x = 0; x < nwidth; ++x ) { @@ -614,7 +614,7 @@ static HRESULT _Generate3DMipsPointFilter( _In_ size_t depth, _In_ size_t levels size_t rowPitch = src->rowPitch; - size_t nheight = height >> 1; + size_t nheight = (height > 1) ? (height >> 1) : 1; for( size_t y = 0; y < nheight; ++y ) { @@ -622,7 +622,7 @@ static HRESULT _Generate3DMipsPointFilter( _In_ size_t depth, _In_ size_t levels return E_FAIL; pSrc += rowPitch*2; - size_t nwidth = width >> 1; + size_t nwidth = (width > 1) ? (width >> 1) : 1; for( size_t x = 0; x < nwidth; ++x ) { @@ -717,7 +717,7 @@ static HRESULT _Generate3DMipsBoxFilter( _In_ size_t depth, _In_ size_t levels, size_t aRowPitch = srca->rowPitch; size_t bRowPitch = srcb->rowPitch; - size_t nheight = height >> 1; + size_t nheight = (height > 1) ? (height >> 1) : 1; for( size_t y = 0; y < nheight; ++y ) { @@ -746,7 +746,7 @@ static HRESULT _Generate3DMipsBoxFilter( _In_ size_t depth, _In_ size_t levels, pSrc2 += bRowPitch; } - size_t nwidth = width >> 1; + size_t nwidth = (width > 1) ? (width >> 1) : 1; for( size_t x = 0; x < nwidth; ++x ) { @@ -784,7 +784,7 @@ static HRESULT _Generate3DMipsBoxFilter( _In_ size_t depth, _In_ size_t levels, size_t rowPitch = src->rowPitch; - size_t nheight = height >> 1; + size_t nheight = (height > 1) ? (height >> 1) : 1; for( size_t y = 0; y < nheight; ++y ) { @@ -799,7 +799,7 @@ static HRESULT _Generate3DMipsBoxFilter( _In_ size_t depth, _In_ size_t levels, pSrc += rowPitch; } - size_t nwidth = width >> 1; + size_t nwidth = (width > 1) ? (width >> 1) : 1; for( size_t x = 0; x < nwidth; ++x ) {