mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 19:50:13 +02:00
Added make_AlignedArray helpers to scoped.h
This commit is contained in:
parent
fd13c32036
commit
95c4991486
@ -28,7 +28,7 @@ option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
|
|||||||
# NOTE requires adding DirectXTexEXR.h/.cpp source files (vcpkg does this automatically)
|
# NOTE requires adding DirectXTexEXR.h/.cpp source files (vcpkg does this automatically)
|
||||||
option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR support" OFF)
|
option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR support" OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
@ -74,8 +74,7 @@ if(BUILD_DX11)
|
|||||||
DirectXTex/BCDirectCompute.h
|
DirectXTex/BCDirectCompute.h
|
||||||
DirectXTex/BCDirectCompute.cpp
|
DirectXTex/BCDirectCompute.cpp
|
||||||
DirectXTex/DirectXTexCompressGPU.cpp
|
DirectXTex/DirectXTexCompressGPU.cpp
|
||||||
DirectXTex/DirectXTexD3D11.cpp
|
DirectXTex/DirectXTexD3D11.cpp)
|
||||||
DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc)
|
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_DX12)
|
if(BUILD_DX12)
|
||||||
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
||||||
@ -92,9 +91,10 @@ if(ENABLE_OPENEXR_SUPPORT)
|
|||||||
DirectXTex/DirectXTexEXR.cpp)
|
DirectXTex/DirectXTexEXR.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
|
|
||||||
|
|
||||||
if(BUILD_DX11)
|
if(BUILD_DX11)
|
||||||
|
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
|
||||||
|
DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc"
|
OUTPUT "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc"
|
||||||
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
|
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd"
|
||||||
@ -105,6 +105,8 @@ if(BUILD_DX11)
|
|||||||
USES_TERMINAL)
|
USES_TERMINAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
|
||||||
|
|
||||||
source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXTex/*.*)
|
source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXTex/*.*)
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
@ -160,8 +162,7 @@ install(EXPORT ${PROJECT_NAME}-targets
|
|||||||
install(FILES ${LIBRARY_HEADERS}
|
install(FILES ${LIBRARY_HEADERS}
|
||||||
DESTINATION include)
|
DESTINATION include)
|
||||||
|
|
||||||
install(
|
install(FILES
|
||||||
FILES
|
|
||||||
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config.cmake
|
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config.cmake
|
||||||
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config-version.cmake
|
${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config-version.cmake
|
||||||
DESTINATION cmake/)
|
DESTINATION cmake/)
|
||||||
|
@ -59,7 +59,7 @@ namespace
|
|||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR) * srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
{
|
{
|
||||||
image.Release();
|
image.Release();
|
||||||
|
@ -2640,7 +2640,7 @@ HRESULT DirectX::_ConvertToR16G16B16A16(const Image& srcImage, ScratchImage& ima
|
|||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR) * srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
{
|
{
|
||||||
image.Release();
|
image.Release();
|
||||||
@ -2693,7 +2693,7 @@ HRESULT DirectX::_ConvertFromR16G16B16A16(const Image& srcImage, const Image& de
|
|||||||
if (srcImage.width != destImage.width || srcImage.height != destImage.height)
|
if (srcImage.width != destImage.width || srcImage.height != destImage.height)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR) * srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -4597,7 +4597,7 @@ namespace
|
|||||||
if (filter & TEX_FILTER_DITHER_DIFFUSION)
|
if (filter & TEX_FILTER_DITHER_DIFFUSION)
|
||||||
{
|
{
|
||||||
// Error diffusion dithering (aka Floyd-Steinberg dithering)
|
// Error diffusion dithering (aka Floyd-Steinberg dithering)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*(width * 2 + 2)), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2 + 2);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -4620,7 +4620,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ bool ScratchImage::IsAlphaAllOpaque() const noexcept
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*m_metadata.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(m_metadata.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ namespace
|
|||||||
assert(srcImage.width == destImage.width);
|
assert(srcImage.width == destImage.width);
|
||||||
assert(srcImage.height == destImage.height);
|
assert(srcImage.height == destImage.height);
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
{
|
{
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
@ -214,13 +214,13 @@ namespace
|
|||||||
{
|
{
|
||||||
coverage = 0.0f;
|
coverage = 0.0f;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR row0(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto row0 = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!row0)
|
if (!row0)
|
||||||
{
|
{
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR row1(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto row1 = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!row1)
|
if (!row1)
|
||||||
{
|
{
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
@ -896,7 +896,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate temporary space (2 scanlines)
|
// Allocate temporary space (2 scanlines)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 2), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -983,7 +983,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// Allocate temporary space (3 scanlines)
|
// Allocate temporary space (3 scanlines)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 3), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 3);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -1074,7 +1074,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate temporary space (3 scanlines, plus X and Y filters)
|
// Allocate temporary space (3 scanlines, plus X and Y filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 3), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 3);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -1185,7 +1185,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate temporary space (5 scanlines, plus X and Y filters)
|
// Allocate temporary space (5 scanlines, plus X and Y filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 5), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 5);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -1373,7 +1373,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate initial temporary space (1 scanline, accumulation rows, plus X and Y filters)
|
// Allocate initial temporary space (1 scanline, accumulation rows, plus X and Y filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * width, 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -1462,9 +1462,10 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rowAcc->scanline.reset(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * nwidth, 16)));
|
auto nscanline = make_AlignedArrayXMVECTOR(nwidth);
|
||||||
if (!rowAcc->scanline)
|
if (!nscanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
rowAcc->scanline.swap(nscanline);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth);
|
memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth);
|
||||||
@ -1641,7 +1642,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate temporary space (2 scanlines)
|
// Allocate temporary space (2 scanlines)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 2), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -1790,7 +1791,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// Allocate temporary space (5 scanlines)
|
// Allocate temporary space (5 scanlines)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 5), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 5);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -1959,7 +1960,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate temporary space (5 scanlines, plus X/Y/Z filters)
|
// Allocate temporary space (5 scanlines, plus X/Y/Z filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 5), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 5);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -2152,7 +2153,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate temporary space (17 scanlines, plus X/Y/Z filters)
|
// Allocate temporary space (17 scanlines, plus X/Y/Z filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 17), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 17);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -2533,7 +2534,7 @@ namespace
|
|||||||
size_t height = mipChain.GetMetadata().height;
|
size_t height = mipChain.GetMetadata().height;
|
||||||
|
|
||||||
// Allocate initial temporary space (1 scanline, accumulation rows, plus X/Y/Z filters)
|
// Allocate initial temporary space (1 scanline, accumulation rows, plus X/Y/Z filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * width, 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -2616,10 +2617,10 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t bytes = sizeof(XMVECTOR) * nwidth * nheight;
|
auto nscanline = make_AlignedArrayXMVECTOR(uint64_t(nwidth) * uint64_t(nheight));
|
||||||
sliceAcc->scanline.reset(static_cast<XMVECTOR*>(_aligned_malloc(bytes, 16)));
|
if (!nscanline)
|
||||||
if (!sliceAcc->scanline)
|
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
sliceAcc->scanline.swap(nscanline);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(sliceAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth * nheight);
|
memset(sliceAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth * nheight);
|
||||||
|
@ -33,7 +33,7 @@ namespace
|
|||||||
|
|
||||||
const size_t width = image1.width;
|
const size_t width = image1.width;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width) * 2, 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ namespace
|
|||||||
|
|
||||||
const size_t width = image.width;
|
const size_t width = image.width;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ namespace
|
|||||||
|
|
||||||
const size_t width = srcImage.width;
|
const size_t width = srcImage.width;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanlines(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width*2), 16)));
|
auto scanlines = make_AlignedArrayXMVECTOR(uint64_t(width) * 2);
|
||||||
if (!scanlines)
|
if (!scanlines)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ HRESULT DirectX::CopyRectangle(
|
|||||||
|
|
||||||
uint8_t* pDest = dstImage.pixels + (yOffset * dstImage.rowPitch) + (xOffset * dbpp);
|
uint8_t* pDest = dstImage.pixels + (yOffset * dstImage.rowPitch) + (xOffset * dbpp);
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcRect.w), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcRect.w);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
@ -92,11 +92,11 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// Allocate temporary space (4 scanlines and 3 evaluated rows)
|
// Allocate temporary space (4 scanlines and 3 evaluated rows)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*width * 4), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 4);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
ScopedAlignedArrayFloat buffer(static_cast<float*>(_aligned_malloc(((sizeof(float) * (width + 2)) * 3), 16)));
|
auto buffer = make_AlignedArrayFloat((uint64_t(width) + 2) * 3);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace
|
|||||||
assert(srcImage.width == destImage.width);
|
assert(srcImage.width == destImage.width);
|
||||||
assert(srcImage.height == destImage.height);
|
assert(srcImage.height == destImage.height);
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace
|
|||||||
static_assert(static_cast<int>(TEX_PMALPHA_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
|
static_assert(static_cast<int>(TEX_PMALPHA_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
|
||||||
flags &= TEX_PMALPHA_SRGB;
|
flags &= TEX_PMALPHA_SRGB;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ namespace
|
|||||||
assert(srcImage.width == destImage.width);
|
assert(srcImage.width == destImage.width);
|
||||||
assert(srcImage.height == destImage.height);
|
assert(srcImage.height == destImage.height);
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ namespace
|
|||||||
static_assert(static_cast<int>(TEX_PMALPHA_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*");
|
static_assert(static_cast<int>(TEX_PMALPHA_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*");
|
||||||
flags &= TEX_PMALPHA_SRGB;
|
flags &= TEX_PMALPHA_SRGB;
|
||||||
|
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
@ -251,8 +251,7 @@ namespace
|
|||||||
assert(srcImage.format == destImage.format);
|
assert(srcImage.format == destImage.format);
|
||||||
|
|
||||||
// Allocate temporary space (2 scanlines)
|
// Allocate temporary space (2 scanlines)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width + destImage.width);
|
||||||
(sizeof(XMVECTOR) * (srcImage.width + destImage.width)), 16)));
|
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -312,8 +311,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// Allocate temporary space (3 scanlines)
|
// Allocate temporary space (3 scanlines)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) * 2 + destImage.width);
|
||||||
(sizeof(XMVECTOR) * (srcImage.width * 2 + destImage.width)), 16)));
|
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -371,8 +369,7 @@ namespace
|
|||||||
assert(srcImage.format == destImage.format);
|
assert(srcImage.format == destImage.format);
|
||||||
|
|
||||||
// Allocate temporary space (3 scanlines, plus X and Y filters)
|
// Allocate temporary space (3 scanlines, plus X and Y filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) * 2 + destImage.width);
|
||||||
(sizeof(XMVECTOR) * (srcImage.width * 2 + destImage.width)), 16)));
|
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -457,8 +454,7 @@ namespace
|
|||||||
assert(srcImage.format == destImage.format);
|
assert(srcImage.format == destImage.format);
|
||||||
|
|
||||||
// Allocate temporary space (5 scanlines, plus X and Y filters)
|
// Allocate temporary space (5 scanlines, plus X and Y filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(
|
auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) * 4 + destImage.width);
|
||||||
(sizeof(XMVECTOR) * (srcImage.width * 4 + destImage.width)), 16)));
|
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -619,7 +615,7 @@ namespace
|
|||||||
using namespace TriangleFilter;
|
using namespace TriangleFilter;
|
||||||
|
|
||||||
// Allocate initial temporary space (1 scanline, accumulation rows, plus X and Y filters)
|
// Allocate initial temporary space (1 scanline, accumulation rows, plus X and Y filters)
|
||||||
ScopedAlignedArrayXMVECTOR scanline(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * srcImage.width, 16)));
|
auto scanline = make_AlignedArrayXMVECTOR(srcImage.width);
|
||||||
if (!scanline)
|
if (!scanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
@ -688,9 +684,10 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rowAcc->scanline.reset(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * destImage.width, 16)));
|
auto nscanline = make_AlignedArrayXMVECTOR(destImage.width);
|
||||||
if (!rowAcc->scanline)
|
if (!nscanline)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
rowAcc->scanline.swap(nscanline);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * destImage.width);
|
memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * destImage.width);
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@ -19,8 +21,26 @@ struct aligned_deleter { void operator()(void* p) noexcept { _aligned_free(p); }
|
|||||||
|
|
||||||
using ScopedAlignedArrayFloat = std::unique_ptr<float[], aligned_deleter>;
|
using ScopedAlignedArrayFloat = std::unique_ptr<float[], aligned_deleter>;
|
||||||
|
|
||||||
|
inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count)
|
||||||
|
{
|
||||||
|
uint64_t size = sizeof(float) * count;
|
||||||
|
if (size > static_cast<uint64_t>(UINT32_MAX))
|
||||||
|
return nullptr;
|
||||||
|
auto ptr = _aligned_malloc(static_cast<size_t>(size), 16);
|
||||||
|
return ScopedAlignedArrayFloat(static_cast<float*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
using ScopedAlignedArrayXMVECTOR = std::unique_ptr<DirectX::XMVECTOR[], aligned_deleter>;
|
using ScopedAlignedArrayXMVECTOR = std::unique_ptr<DirectX::XMVECTOR[], aligned_deleter>;
|
||||||
|
|
||||||
|
inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count)
|
||||||
|
{
|
||||||
|
uint64_t size = sizeof(DirectX::XMVECTOR) * count;
|
||||||
|
if (size > static_cast<uint64_t>(UINT32_MAX))
|
||||||
|
return nullptr;
|
||||||
|
auto ptr = _aligned_malloc(static_cast<size_t>(size), 16);
|
||||||
|
return ScopedAlignedArrayXMVECTOR(static_cast<DirectX::XMVECTOR*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
struct handle_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } };
|
struct handle_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user