From 316f65649b458f092731d856266899f2e784379d Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 13 Dec 2019 00:01:17 -0800 Subject: [PATCH] More noexcept annotation --- DirectXTex/BC.cpp | 22 +-- DirectXTex/BC.h | 74 ++++----- DirectXTex/BC4BC5.cpp | 46 +++--- DirectXTex/BC6HBC7.cpp | 222 +++++++++++++-------------- DirectXTex/BCDirectCompute.h | 2 +- DirectXTex/DirectXTex.h | 100 ++++++------ DirectXTex/DirectXTex.inl | 4 +- DirectXTex/DirectXTexCompress.cpp | 16 +- DirectXTex/DirectXTexCompressGPU.cpp | 2 +- DirectXTex/DirectXTexConvert.cpp | 48 +++--- DirectXTex/DirectXTexD3D11.cpp | 4 +- DirectXTex/DirectXTexD3D12.cpp | 10 +- DirectXTex/DirectXTexDDS.cpp | 26 ++-- DirectXTex/DirectXTexFlipRotate.cpp | 10 +- DirectXTex/DirectXTexHDR.cpp | 20 +-- DirectXTex/DirectXTexImage.cpp | 32 ++-- DirectXTex/DirectXTexMipmaps.cpp | 62 ++++---- DirectXTex/DirectXTexMisc.cpp | 4 +- DirectXTex/DirectXTexNormalMaps.cpp | 10 +- DirectXTex/DirectXTexP.h | 46 +++--- DirectXTex/DirectXTexPMAlpha.cpp | 12 +- DirectXTex/DirectXTexResize.cpp | 24 +-- DirectXTex/DirectXTexTGA.cpp | 28 ++-- DirectXTex/DirectXTexUtil.cpp | 6 +- DirectXTex/DirectXTexWIC.cpp | 4 +- DirectXTex/filters.h | 8 +- DirectXTex/scoped.h | 12 +- 27 files changed, 428 insertions(+), 426 deletions(-) diff --git a/DirectXTex/BC.cpp b/DirectXTex/BC.cpp index 0c9cceb..bee33a5 100644 --- a/DirectXTex/BC.cpp +++ b/DirectXTex/BC.cpp @@ -33,7 +33,7 @@ namespace //------------------------------------------------------------------------------------- // Decode/Encode RGB 5/6/5 colors //------------------------------------------------------------------------------------- - inline void Decode565(_Out_ HDRColorA *pColor, _In_ const uint16_t w565) + inline void Decode565(_Out_ HDRColorA *pColor, _In_ const uint16_t w565) noexcept { pColor->r = static_cast((w565 >> 11) & 31) * (1.0f / 31.0f); pColor->g = static_cast((w565 >> 5) & 63) * (1.0f / 63.0f); @@ -41,7 +41,7 @@ namespace pColor->a = 1.0f; } - inline uint16_t Encode565(_In_ const HDRColorA *pColor) + inline uint16_t Encode565(_In_ const HDRColorA *pColor) noexcept { HDRColorA Color; @@ -67,7 +67,7 @@ namespace _Out_ HDRColorA *pY, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pPoints, uint32_t cSteps, - DWORD flags) + DWORD flags) noexcept { static const float fEpsilon = (0.25f / 64.0f) * (0.25f / 64.0f); static const float pC3[] = { 2.0f / 2.0f, 1.0f / 2.0f, 0.0f / 2.0f }; @@ -318,7 +318,7 @@ namespace inline void DecodeBC1( _Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_ const D3DX_BC1 *pBC, - bool isbc1) + bool isbc1) noexcept { assert(pColor && pBC); static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes"); @@ -372,7 +372,7 @@ namespace _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor, bool bColorKey, float threshold, - DWORD flags) + DWORD flags) noexcept { assert(pBC && pColor); static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes"); @@ -728,14 +728,14 @@ namespace // BC1 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC1(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC1(XMVECTOR *pColor, const uint8_t *pBC) noexcept { auto pBC1 = reinterpret_cast(pBC); DecodeBC1(pColor, pBC1, true); } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float threshold, DWORD flags) +void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float threshold, DWORD flags) noexcept { assert(pBC && pColor); @@ -799,7 +799,7 @@ void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float threshol // BC2 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(D3DX_BC2) == 16, "D3DX_BC2 should be 16 bytes"); @@ -825,7 +825,7 @@ void DirectX::D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { assert(pBC && pColor); static_assert(sizeof(D3DX_BC2) == 16, "D3DX_BC2 should be 16 bytes"); @@ -899,7 +899,7 @@ void DirectX::D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) // BC3 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(D3DX_BC3) == 16, "D3DX_BC3 should be 16 bytes"); @@ -941,7 +941,7 @@ void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { assert(pBC && pColor); static_assert(sizeof(D3DX_BC3) == 16, "D3DX_BC3 should be 16 bytes"); diff --git a/DirectXTex/BC.h b/DirectXTex/BC.h index d585497..b4cbf23 100644 --- a/DirectXTex/BC.h +++ b/DirectXTex/BC.h @@ -50,38 +50,38 @@ public: public: HDRColorA() = default; - HDRColorA(float _r, float _g, float _b, float _a) : r(_r), g(_g), b(_b), a(_a) {} - HDRColorA(const HDRColorA& c) : r(c.r), g(c.g), b(c.b), a(c.a) {} + HDRColorA(float _r, float _g, float _b, float _a) noexcept : r(_r), g(_g), b(_b), a(_a) {} + HDRColorA(const HDRColorA& c) noexcept : r(c.r), g(c.g), b(c.b), a(c.a) {} // binary operators - HDRColorA operator + (const HDRColorA& c) const + HDRColorA operator + (const HDRColorA& c) const noexcept { return HDRColorA(r + c.r, g + c.g, b + c.b, a + c.a); } - HDRColorA operator - (const HDRColorA& c) const + HDRColorA operator - (const HDRColorA& c) const noexcept { return HDRColorA(r - c.r, g - c.g, b - c.b, a - c.a); } - HDRColorA operator * (float f) const + HDRColorA operator * (float f) const noexcept { return HDRColorA(r * f, g * f, b * f, a * f); } - HDRColorA operator / (float f) const + HDRColorA operator / (float f) const noexcept { float fInv = 1.0f / f; return HDRColorA(r * fInv, g * fInv, b * fInv, a * fInv); } - float operator * (const HDRColorA& c) const + float operator * (const HDRColorA& c) const noexcept { return r * c.r + g * c.g + b * c.b + a * c.a; } // assignment operators - HDRColorA& operator += (const HDRColorA& c) + HDRColorA& operator += (const HDRColorA& c) noexcept { r += c.r; g += c.g; @@ -90,7 +90,7 @@ public: return *this; } - HDRColorA& operator -= (const HDRColorA& c) + HDRColorA& operator -= (const HDRColorA& c) noexcept { r -= c.r; g -= c.g; @@ -99,7 +99,7 @@ public: return *this; } - HDRColorA& operator *= (float f) + HDRColorA& operator *= (float f) noexcept { r *= f; g *= f; @@ -108,7 +108,7 @@ public: return *this; } - HDRColorA& operator /= (float f) + HDRColorA& operator /= (float f) noexcept { float fInv = 1.0f / f; r *= fInv; @@ -118,7 +118,7 @@ public: return *this; } - HDRColorA& Clamp(_In_ float fMin, _In_ float fMax) + HDRColorA& Clamp(_In_ float fMin, _In_ float fMax) noexcept { r = std::min(fMax, std::max(fMin, r)); g = std::min(fMax, std::max(fMin, g)); @@ -127,12 +127,12 @@ public: return *this; } - HDRColorA(const LDRColorA& c); - HDRColorA& operator = (const LDRColorA& c); - LDRColorA ToLDRColorA() const; + HDRColorA(const LDRColorA& c) noexcept; + HDRColorA& operator = (const LDRColorA& c) noexcept; + LDRColorA ToLDRColorA() const noexcept; }; -inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) +inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) noexcept { pOut->r = pC1->r + s * (pC2->r - pC1->r); pOut->g = pC1->g + s * (pC2->g - pC1->g); @@ -170,7 +170,7 @@ struct D3DX_BC3 //------------------------------------------------------------------------------------- #pragma warning(push) #pragma warning(disable : 4127) -template void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) +template void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) noexcept { static const float pC6[] = { 5.0f / 5.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f, 1.0f / 5.0f, 0.0f / 5.0f }; static const float pD6[] = { 0.0f / 5.0f, 1.0f / 5.0f, 2.0f / 5.0f, 3.0f / 5.0f, 4.0f / 5.0f, 5.0f / 5.0f }; @@ -298,28 +298,28 @@ template void OptimizeAlpha(float *pX, float *pY, const float *pPo typedef void (*BC_DECODE)(XMVECTOR *pColor, const uint8_t *pBC); typedef void (*BC_ENCODE)(uint8_t *pDXT, const XMVECTOR *pColor, DWORD flags); -void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC); -void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); -void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); -void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC); -void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC); -void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); -void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); -void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); -void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); -void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC); +void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept; +void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; +void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; +void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept; +void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept; +void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; +void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; +void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; +void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; +void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; -void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ DWORD flags); +void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ DWORD flags) noexcept; // BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above -void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); +void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; +void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags) noexcept; } // namespace diff --git a/DirectXTex/BC4BC5.cpp b/DirectXTex/BC4BC5.cpp index 1b9034b..a2cce90 100644 --- a/DirectXTex/BC4BC5.cpp +++ b/DirectXTex/BC4BC5.cpp @@ -38,13 +38,13 @@ namespace // BC4U/BC5U struct BC4_UNORM { - float R(size_t uOffset) const + float R(size_t uOffset) const noexcept { size_t uIndex = GetIndex(uOffset); return DecodeFromIndex(uIndex); } - float DecodeFromIndex(size_t uIndex) const + float DecodeFromIndex(size_t uIndex) const noexcept { if (uIndex == 0) return red_0 / 255.0f; @@ -68,12 +68,12 @@ namespace } } - size_t GetIndex(size_t uOffset) const + size_t GetIndex(size_t uOffset) const noexcept { return static_cast((data >> (3 * uOffset + 16)) & 0x07); } - void SetIndex(size_t uOffset, size_t uIndex) + void SetIndex(size_t uOffset, size_t uIndex) noexcept { data &= ~(uint64_t(0x07) << (3 * uOffset + 16)); data |= (uint64_t(uIndex) << (3 * uOffset + 16)); @@ -94,13 +94,13 @@ namespace // BC4S/BC5S struct BC4_SNORM { - float R(size_t uOffset) const + float R(size_t uOffset) const noexcept { size_t uIndex = GetIndex(uOffset); return DecodeFromIndex(uIndex); } - float DecodeFromIndex(size_t uIndex) const + float DecodeFromIndex(size_t uIndex) const noexcept { int8_t sred_0 = (red_0 == -128) ? -127 : red_0; int8_t sred_1 = (red_1 == -128) ? -127 : red_1; @@ -127,12 +127,12 @@ namespace } } - size_t GetIndex(size_t uOffset) const + size_t GetIndex(size_t uOffset) const noexcept { return static_cast((data >> (3 * uOffset + 16)) & 0x07); } - void SetIndex(size_t uOffset, size_t uIndex) + void SetIndex(size_t uOffset, size_t uIndex) noexcept { data &= ~(uint64_t(0x07) << (3 * uOffset + 16)); data |= (uint64_t(uIndex) << (3 * uOffset + 16)); @@ -155,7 +155,7 @@ namespace //------------------------------------------------------------------------------------- // Convert a floating point value to an 8-bit SNORM //------------------------------------------------------------------------------------- - void inline FloatToSNorm(_In_ float fVal, _Out_ int8_t *piSNorm) + void inline FloatToSNorm(_In_ float fVal, _Out_ int8_t *piSNorm) noexcept { const uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1)); @@ -183,7 +183,7 @@ namespace void FindEndPointsBC4U( _In_reads_(BLOCK_SIZE) const float theTexelsU[], _Out_ uint8_t &endpointU_0, - _Out_ uint8_t &endpointU_1) + _Out_ uint8_t &endpointU_1) noexcept { // The boundary of codec for signed/unsigned format const float MIN_NORM = 0.f; @@ -238,7 +238,7 @@ namespace void FindEndPointsBC4S( _In_reads_(BLOCK_SIZE) const float theTexelsU[], _Out_ int8_t &endpointU_0, - _Out_ int8_t &endpointU_1) + _Out_ int8_t &endpointU_1) noexcept { // The boundary of codec for signed/unsigned format const float MIN_NORM = -1.f; @@ -300,7 +300,7 @@ namespace _Out_ uint8_t &endpointU_0, _Out_ uint8_t &endpointU_1, _Out_ uint8_t &endpointV_0, - _Out_ uint8_t &endpointV_1) + _Out_ uint8_t &endpointV_1) noexcept { //Encoding the U and V channel by BC4 codec separately. FindEndPointsBC4U(theTexelsU, endpointU_0, endpointU_1); @@ -313,7 +313,7 @@ namespace _Out_ int8_t &endpointU_0, _Out_ int8_t &endpointU_1, _Out_ int8_t &endpointV_0, - _Out_ int8_t &endpointV_1) + _Out_ int8_t &endpointV_1) noexcept { //Encoding the U and V channel by BC4 codec separately. FindEndPointsBC4S(theTexelsU, endpointU_0, endpointU_1); @@ -324,7 +324,7 @@ namespace //------------------------------------------------------------------------------ void FindClosestUNORM( _Inout_ BC4_UNORM* pBC, - _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) + _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) noexcept { float rGradient[8]; for (size_t i = 0; i < 8; ++i) @@ -351,7 +351,7 @@ namespace void FindClosestSNORM( _Inout_ BC4_SNORM* pBC, - _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) + _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) noexcept { float rGradient[8]; for (size_t i = 0; i < 8; ++i) @@ -386,7 +386,7 @@ namespace // BC4 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC4U(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC4U(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes"); @@ -401,7 +401,7 @@ void DirectX::D3DXDecodeBC4U(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes"); @@ -416,7 +416,7 @@ void DirectX::D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC4U(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC4U(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { UNREFERENCED_PARAMETER(flags); @@ -437,7 +437,7 @@ void DirectX::D3DXEncodeBC4U(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC4S(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC4S(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { UNREFERENCED_PARAMETER(flags); @@ -462,7 +462,7 @@ void DirectX::D3DXEncodeBC4S(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) // BC5 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes"); @@ -478,7 +478,7 @@ void DirectX::D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes"); @@ -494,7 +494,7 @@ void DirectX::D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC5U(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC5U(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { UNREFERENCED_PARAMETER(flags); @@ -528,7 +528,7 @@ void DirectX::D3DXEncodeBC5U(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC5S(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC5S(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { UNREFERENCED_PARAMETER(flags); diff --git a/DirectXTex/BC6HBC7.cpp b/DirectXTex/BC6HBC7.cpp index e94cea7..4becf39 100644 --- a/DirectXTex/BC6HBC7.cpp +++ b/DirectXTex/BC6HBC7.cpp @@ -337,9 +337,9 @@ namespace DirectX uint8_t r, g, b, a; LDRColorA() = default; - LDRColorA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {} + LDRColorA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) noexcept : r(_r), g(_g), b(_b), a(_a) {} - const uint8_t& operator [] (_In_range_(0, 3) size_t uElement) const + const uint8_t& operator [] (_In_range_(0, 3) size_t uElement) const noexcept { switch (uElement) { @@ -351,7 +351,7 @@ namespace DirectX } } - uint8_t& operator [] (_In_range_(0, 3) size_t uElement) + uint8_t& operator [] (_In_range_(0, 3) size_t uElement) noexcept { switch (uElement) { @@ -363,7 +363,7 @@ namespace DirectX } } - LDRColorA operator = (_In_ const HDRColorA& c) + LDRColorA operator = (_In_ const HDRColorA& c) noexcept { LDRColorA ret; HDRColorA tmp(c); @@ -375,7 +375,7 @@ namespace DirectX return ret; } - static void InterpolateRGB(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ _In_range_(2, 4) size_t wcprec, _Out_ LDRColorA& out) + static void InterpolateRGB(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ _In_range_(2, 4) size_t wcprec, _Out_ LDRColorA& out) noexcept { const int* aWeights = nullptr; switch (wcprec) @@ -390,7 +390,7 @@ namespace DirectX out.b = uint8_t((uint32_t(c0.b) * uint32_t(BC67_WEIGHT_MAX - aWeights[wc]) + uint32_t(c1.b) * uint32_t(aWeights[wc]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); } - static void InterpolateA(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wa, _In_range_(2, 4) _In_ size_t waprec, _Out_ LDRColorA& out) + static void InterpolateA(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wa, _In_range_(2, 4) _In_ size_t waprec, _Out_ LDRColorA& out) noexcept { const int* aWeights = nullptr; switch (waprec) @@ -403,7 +403,7 @@ namespace DirectX out.a = uint8_t((uint32_t(c0.a) * uint32_t(BC67_WEIGHT_MAX - aWeights[wa]) + uint32_t(c1.a) * uint32_t(aWeights[wa]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); } - static void Interpolate(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ size_t wa, _In_ _In_range_(2, 4) size_t wcprec, _In_ _In_range_(2, 4) size_t waprec, _Out_ LDRColorA& out) + static void Interpolate(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ size_t wa, _In_ _In_range_(2, 4) size_t wcprec, _In_ _In_range_(2, 4) size_t waprec, _Out_ LDRColorA& out) noexcept { InterpolateRGB(c0, c1, wc, wcprec, out); InterpolateA(c0, c1, wa, waprec, out); @@ -418,7 +418,7 @@ namespace DirectX LDRColorA B; }; - inline HDRColorA::HDRColorA(const LDRColorA& c) + inline HDRColorA::HDRColorA(const LDRColorA& c) noexcept { r = float(c.r) * (1.0f / 255.0f); g = float(c.g) * (1.0f / 255.0f); @@ -426,7 +426,7 @@ namespace DirectX a = float(c.a) * (1.0f / 255.0f); } - inline HDRColorA& HDRColorA::operator = (const LDRColorA& c) + inline HDRColorA& HDRColorA::operator = (const LDRColorA& c) noexcept { r = static_cast(c.r); g = static_cast(c.g); @@ -435,7 +435,7 @@ namespace DirectX return *this; } - inline LDRColorA HDRColorA::ToLDRColorA() const + inline LDRColorA HDRColorA::ToLDRColorA() const noexcept { return LDRColorA(static_cast(r + 0.01f), static_cast(g + 0.01f), static_cast(b + 0.01f), static_cast(a + 0.01f)); } @@ -451,10 +451,10 @@ namespace public: INTColor() = default; - INTColor(int nr, int ng, int nb) : r(nr), g(ng), b(nb), pad(0) {} - INTColor(const INTColor& c) : r(c.r), g(c.g), b(c.b), pad(0) {} + INTColor(int nr, int ng, int nb) noexcept : r(nr), g(ng), b(nb), pad(0) {} + INTColor(const INTColor& c) noexcept : r(c.r), g(c.g), b(c.b), pad(0) {} - INTColor& operator += (_In_ const INTColor& c) + INTColor& operator += (_In_ const INTColor& c) noexcept { r += c.r; g += c.g; @@ -462,7 +462,7 @@ namespace return *this; } - INTColor& operator -= (_In_ const INTColor& c) + INTColor& operator -= (_In_ const INTColor& c) noexcept { r -= c.r; g -= c.g; @@ -470,7 +470,7 @@ namespace return *this; } - INTColor& operator &= (_In_ const INTColor& c) + INTColor& operator &= (_In_ const INTColor& c) noexcept { r &= c.r; g &= c.g; @@ -478,14 +478,14 @@ namespace return *this; } - int& operator [] (_In_ uint8_t i) + int& operator [] (_In_ uint8_t i) noexcept { assert(i < sizeof(INTColor) / sizeof(int)); _Analysis_assume_(i < sizeof(INTColor) / sizeof(int)); return reinterpret_cast(this)[i]; } - void Set(_In_ const HDRColorA& c, _In_ bool bSigned) + void Set(_In_ const HDRColorA& c, _In_ bool bSigned) noexcept { PackedVector::XMHALF4 aF16; @@ -497,7 +497,7 @@ namespace b = F16ToINT(aF16.z, bSigned); } - INTColor& Clamp(_In_ int iMin, _In_ int iMax) + INTColor& Clamp(_In_ int iMin, _In_ int iMax) noexcept { r = std::min(iMax, std::max(iMin, r)); g = std::min(iMax, std::max(iMin, g)); @@ -505,7 +505,7 @@ namespace return *this; } - INTColor& SignExtend(_In_ const LDRColorA& Prec) + INTColor& SignExtend(_In_ const LDRColorA& Prec) noexcept { r = SIGN_EXTEND(r, int(Prec.r)); g = SIGN_EXTEND(g, int(Prec.g)); @@ -513,7 +513,7 @@ namespace return *this; } - void ToF16(_Out_writes_(3) PackedVector::HALF aF16[3], _In_ bool bSigned) const + void ToF16(_Out_writes_(3) PackedVector::HALF aF16[3], _In_ bool bSigned) const noexcept { aF16[0] = INT2F16(r, bSigned); aF16[1] = INT2F16(g, bSigned); @@ -521,7 +521,7 @@ namespace } private: - static int F16ToINT(_In_ const PackedVector::HALF& f, _In_ bool bSigned) + static int F16ToINT(_In_ const PackedVector::HALF& f, _In_ bool bSigned) noexcept { uint16_t input = *reinterpret_cast(&f); int out, s; @@ -541,7 +541,7 @@ namespace return out; } - static PackedVector::HALF INT2F16(_In_ int input, _In_ bool bSigned) + static PackedVector::HALF INT2F16(_In_ int input, _In_ bool bSigned) noexcept { PackedVector::HALF h; uint16_t out; @@ -578,7 +578,7 @@ namespace class CBits { public: - uint8_t GetBit(_Inout_ size_t& uStartBit) const + uint8_t GetBit(_Inout_ size_t& uStartBit) const noexcept { assert(uStartBit < 128); _Analysis_assume_(uStartBit < 128); @@ -588,7 +588,7 @@ namespace return ret; } - uint8_t GetBits(_Inout_ size_t& uStartBit, _In_ size_t uNumBits) const + uint8_t GetBits(_Inout_ size_t& uStartBit, _In_ size_t uNumBits) const noexcept { if (uNumBits == 0) return 0; assert(uStartBit + uNumBits <= 128 && uNumBits <= 8); @@ -611,7 +611,7 @@ namespace return ret; } - void SetBit(_Inout_ size_t& uStartBit, _In_ uint8_t uValue) + void SetBit(_Inout_ size_t& uStartBit, _In_ uint8_t uValue) noexcept { assert(uStartBit < 128 && uValue < 2); _Analysis_assume_(uStartBit < 128 && uValue < 2); @@ -622,7 +622,7 @@ namespace uStartBit++; } - void SetBits(_Inout_ size_t& uStartBit, _In_ size_t uNumBits, _In_ uint8_t uValue) + void SetBits(_Inout_ size_t& uStartBit, _In_ size_t uNumBits, _In_ uint8_t uValue) noexcept { if (uNumBits == 0) return; @@ -656,8 +656,8 @@ namespace class D3DX_BC6H : private CBits< 16 > { public: - void Decode(_In_ bool bSigned, _Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const; - void Encode(_In_ bool bSigned, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn); + void Decode(_In_ bool bSigned, _Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const noexcept; + void Encode(_In_ bool bSigned, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn) noexcept; private: #pragma warning(push) @@ -709,7 +709,7 @@ namespace INTEndPntPair aUnqEndPts[BC6H_MAX_SHAPES][BC6H_MAX_REGIONS]; INTColor aIPixels[NUM_PIXELS_PER_BLOCK]; - EncodeParams(const HDRColorA* const aOriginal, bool bSignedFormat) : + EncodeParams(const HDRColorA* const aOriginal, bool bSignedFormat) noexcept : fBestErr(FLT_MAX), bSigned(bSignedFormat), uMode(0), uShape(0), aHDRPixels(aOriginal), aUnqEndPts{}, aIPixels{} { for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) @@ -720,35 +720,35 @@ namespace }; #pragma warning(pop) - static int Quantize(_In_ int iValue, _In_ int prec, _In_ bool bSigned); - static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned); - static int FinishUnquantize(_In_ int comp, _In_ bool bSigned); + static int Quantize(_In_ int iValue, _In_ int prec, _In_ bool bSigned) noexcept; + static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned) noexcept; + static int FinishUnquantize(_In_ int comp, _In_ bool bSigned) noexcept; - static bool EndPointsFit(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[]); + static bool EndPointsFit(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[]) noexcept; void GeneratePaletteQuantized(_In_ const EncodeParams* pEP, _In_ const INTEndPntPair& endPts, - _Out_writes_(BC6H_MAX_INDICES) INTColor aPalette[]) const; - float MapColorsQuantized(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ const INTEndPntPair &endPts) const; + _Out_writes_(BC6H_MAX_INDICES) INTColor aPalette[]) const noexcept; + float MapColorsQuantized(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ const INTEndPntPair &endPts) const noexcept; float PerturbOne(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ uint8_t ch, - _In_ const INTEndPntPair& oldEndPts, _Out_ INTEndPntPair& newEndPts, _In_ float fOldErr, _In_ int do_b) const; + _In_ const INTEndPntPair& oldEndPts, _Out_ INTEndPntPair& newEndPts, _In_ float fOldErr, _In_ int do_b) const noexcept; void OptimizeOne(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ float aOrgErr, - _In_ const INTEndPntPair &aOrgEndPts, _Out_ INTEndPntPair &aOptEndPts) const; + _In_ const INTEndPntPair &aOrgEndPts, _Out_ INTEndPntPair &aOptEndPts) const noexcept; void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const float aOrgErr[], _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aOrgEndPts[], - _Out_writes_all_(BC6H_MAX_REGIONS) INTEndPntPair aOptEndPts[]) const; + _Out_writes_all_(BC6H_MAX_REGIONS) INTEndPntPair aOptEndPts[]) const noexcept; static void SwapIndices(_In_ const EncodeParams* pEP, _Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], - _In_reads_(NUM_PIXELS_PER_BLOCK) size_t aIndices[]); + _In_reads_(NUM_PIXELS_PER_BLOCK) size_t aIndices[]) noexcept; void AssignIndices(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[], _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], - _Out_writes_(BC6H_MAX_REGIONS) float aTotErr[]) const; - void QuantizeEndPts(_In_ const EncodeParams* pEP, _Out_writes_(BC6H_MAX_REGIONS) INTEndPntPair* qQntEndPts) const; + _Out_writes_(BC6H_MAX_REGIONS) float aTotErr[]) const noexcept; + void QuantizeEndPts(_In_ const EncodeParams* pEP, _Out_writes_(BC6H_MAX_REGIONS) INTEndPntPair* qQntEndPts) const noexcept; void EmitBlock(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[], - _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndices[]); - void Refine(_Inout_ EncodeParams* pEP); + _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndices[]) noexcept; + void Refine(_Inout_ EncodeParams* pEP) noexcept; - static void GeneratePaletteUnquantized(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _Out_writes_(BC6H_MAX_INDICES) INTColor aPalette[]); - float MapColors(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _In_ size_t np, _In_reads_(np) const size_t* auIndex) const; - float RoughMSE(_Inout_ EncodeParams* pEP) const; + static void GeneratePaletteUnquantized(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _Out_writes_(BC6H_MAX_INDICES) INTColor aPalette[]) noexcept; + float MapColors(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _In_ size_t np, _In_reads_(np) const size_t* auIndex) const noexcept; + float RoughMSE(_Inout_ EncodeParams* pEP) const noexcept; private: static const ModeDescriptor ms_aDesc[][82]; @@ -760,8 +760,8 @@ namespace class D3DX_BC7 : private CBits< 16 > { public: - void Decode(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const; - void Encode(DWORD flags, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn); + void Decode(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const noexcept; + void Encode(DWORD flags, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn) noexcept; private: struct ModeInfo @@ -786,18 +786,18 @@ namespace LDRColorA aLDRPixels[NUM_PIXELS_PER_BLOCK]; const HDRColorA* const aHDRPixels; - EncodeParams(const HDRColorA* const aOriginal) : uMode(0), aEndPts{}, aLDRPixels{}, aHDRPixels(aOriginal) {} + EncodeParams(const HDRColorA* const aOriginal) noexcept : uMode(0), aEndPts{}, aLDRPixels{}, aHDRPixels(aOriginal) {} }; #pragma warning(pop) - static uint8_t Quantize(_In_ uint8_t comp, _In_ uint8_t uPrec) + static uint8_t Quantize(_In_ uint8_t comp, _In_ uint8_t uPrec) noexcept { assert(0 < uPrec && uPrec <= 8); uint8_t rnd = std::min(255u, static_cast(unsigned(comp) + (1u << (7 - uPrec)))); return uint8_t(rnd >> (8u - uPrec)); } - static LDRColorA Quantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec) + static LDRColorA Quantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec) noexcept { LDRColorA q; q.r = Quantize(c.r, RGBAPrec.r); @@ -810,14 +810,14 @@ namespace return q; } - static uint8_t Unquantize(_In_ uint8_t comp, _In_ size_t uPrec) + static uint8_t Unquantize(_In_ uint8_t comp, _In_ size_t uPrec) noexcept { assert(0 < uPrec && uPrec <= 8); comp = static_cast(unsigned(comp) << (8 - uPrec)); return uint8_t(comp | (comp >> uPrec)); } - static LDRColorA Unquantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec) + static LDRColorA Unquantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec) noexcept { LDRColorA q; q.r = Unquantize(c.r, RGBAPrec.r); @@ -828,32 +828,32 @@ namespace } void GeneratePaletteQuantized(_In_ const EncodeParams* pEP, _In_ size_t uIndexMode, _In_ const LDREndPntPair& endpts, - _Out_writes_(BC7_MAX_INDICES) LDRColorA aPalette[]) const; + _Out_writes_(BC7_MAX_INDICES) LDRColorA aPalette[]) const noexcept; float PerturbOne(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA colors[], _In_ size_t np, _In_ size_t uIndexMode, _In_ size_t ch, _In_ const LDREndPntPair &old_endpts, - _Out_ LDREndPntPair &new_endpts, _In_ float old_err, _In_ uint8_t do_b) const; + _Out_ LDREndPntPair &new_endpts, _In_ float old_err, _In_ uint8_t do_b) const noexcept; void Exhaustive(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA aColors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ size_t ch, _Inout_ float& fOrgErr, _Inout_ LDREndPntPair& optEndPt) const; + _In_ size_t ch, _Inout_ float& fOrgErr, _Inout_ LDREndPntPair& optEndPt) const noexcept; void OptimizeOne(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA colors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ float orig_err, _In_ const LDREndPntPair &orig_endpts, _Out_ LDREndPntPair &opt_endpts) const; + _In_ float orig_err, _In_ const LDREndPntPair &orig_endpts, _Out_ LDREndPntPair &opt_endpts) const noexcept; void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode, _In_reads_(BC7_MAX_REGIONS) const float orig_err[], _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair orig_endpts[], - _Out_writes_(BC7_MAX_REGIONS) LDREndPntPair opt_endpts[]) const; + _Out_writes_(BC7_MAX_REGIONS) LDREndPntPair opt_endpts[]) const noexcept; void AssignIndices(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode, _In_reads_(BC7_MAX_REGIONS) LDREndPntPair endpts[], _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices2[], - _Out_writes_(BC7_MAX_REGIONS) float afTotErr[]) const; + _Out_writes_(BC7_MAX_REGIONS) float afTotErr[]) const noexcept; void EmitBlock(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode, _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair aEndPts[], _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndex[], - _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndex2[]); - void FixEndpointPBits(_In_ const EncodeParams* pEP, _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair *pOrigEndpoints, _Out_writes_(BC7_MAX_REGIONS) LDREndPntPair *pFixedEndpoints); - float Refine(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode); + _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndex2[]) noexcept; + void FixEndpointPBits(_In_ const EncodeParams* pEP, _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair *pOrigEndpoints, _Out_writes_(BC7_MAX_REGIONS) LDREndPntPair *pFixedEndpoints) noexcept; + float Refine(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode) noexcept; float MapColors(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA aColors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ const LDREndPntPair& endPts, _In_ float fMinErr) const; - static float RoughMSE(_Inout_ EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode); + _In_ const LDREndPntPair& endPts, _In_ float fMinErr) const noexcept; + static float RoughMSE(_Inout_ EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode) noexcept; private: static const ModeInfo ms_aInfo[]; @@ -1114,7 +1114,7 @@ namespace //------------------------------------------------------------------------------------- // Helper functions //------------------------------------------------------------------------------------- - inline bool IsFixUpOffset(_In_range_(0, 2) size_t uPartitions, _In_range_(0, 63) size_t uShape, _In_range_(0, 15) size_t uOffset) + inline bool IsFixUpOffset(_In_range_(0, 2) size_t uPartitions, _In_range_(0, 63) size_t uShape, _In_range_(0, 15) size_t uOffset) noexcept { assert(uPartitions < 3 && uShape < 64 && uOffset < 16); _Analysis_assume_(uPartitions < 3 && uShape < 64 && uOffset < 16); @@ -1128,14 +1128,14 @@ namespace return false; } - inline void TransformForward(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[]) + inline void TransformForward(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[]) noexcept { aEndPts[0].B -= aEndPts[0].A; aEndPts[1].A -= aEndPts[0].A; aEndPts[1].B -= aEndPts[0].A; } - inline void TransformInverse(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], _In_ const LDRColorA& Prec, _In_ bool bSigned) + inline void TransformInverse(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], _In_ const LDRColorA& Prec, _In_ bool bSigned) noexcept { INTColor WrapMask((1 << Prec.r) - 1, (1 << Prec.g) - 1, (1 << Prec.b) - 1); aEndPts[0].B += aEndPts[0].A; aEndPts[0].B &= WrapMask; @@ -1149,7 +1149,7 @@ namespace } } - inline float Norm(_In_ const INTColor& a, _In_ const INTColor& b) + inline float Norm(_In_ const INTColor& a, _In_ const INTColor& b) noexcept { float dr = float(a.r) - float(b.r); float dg = float(a.g) - float(b.g); @@ -1158,7 +1158,7 @@ namespace } // return # of bits needed to store n. handle signed or unsigned cases properly - inline int NBits(_In_ int n, _In_ bool bIsSigned) + inline int NBits(_In_ int n, _In_ bool bIsSigned) noexcept { int nb; if (n == 0) @@ -1186,7 +1186,7 @@ namespace _Out_ HDRColorA* pY, _In_range_(3, 4) uint32_t cSteps, size_t cPixels, - _In_reads_(cPixels) const size_t* pIndex) + _In_reads_(cPixels) const size_t* pIndex) noexcept { float fError = FLT_MAX; const float *pC = (3 == cSteps) ? pC3 : pC4; @@ -1382,7 +1382,7 @@ namespace _Out_ HDRColorA* pY, _In_range_(3, 4) uint32_t cSteps, size_t cPixels, - _In_reads_(cPixels) const size_t* pIndex) + _In_reads_(cPixels) const size_t* pIndex) noexcept { float fError = FLT_MAX; const float *pC = (3 == cSteps) ? pC3 : pC4; @@ -1551,7 +1551,7 @@ namespace uint8_t uIndexPrec, uint8_t uIndexPrec2, _Out_opt_ size_t* pBestIndex = nullptr, - _Out_opt_ size_t* pBestIndex2 = nullptr) + _Out_opt_ size_t* pBestIndex2 = nullptr) noexcept { const size_t uNumIndices = size_t(1) << uIndexPrec; const size_t uNumIndices2 = size_t(1) << uIndexPrec2; @@ -1624,7 +1624,7 @@ namespace } - void FillWithErrorColors(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) + void FillWithErrorColors(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) noexcept { for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) { @@ -1644,7 +1644,7 @@ namespace // BC6H Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const +void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept { assert(pOut); @@ -1805,7 +1805,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const _Use_decl_annotations_ -void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) +void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) noexcept { assert(pIn); @@ -1852,7 +1852,7 @@ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) //------------------------------------------------------------------------------------- _Use_decl_annotations_ -int D3DX_BC6H::Quantize(int iValue, int prec, bool bSigned) +int D3DX_BC6H::Quantize(int iValue, int prec, bool bSigned) noexcept { assert(prec > 1); // didn't bother to make it work for 1 int q, s = 0; @@ -1881,7 +1881,7 @@ int D3DX_BC6H::Quantize(int iValue, int prec, bool bSigned) _Use_decl_annotations_ -int D3DX_BC6H::Unquantize(int comp, uint8_t uBitsPerComp, bool bSigned) +int D3DX_BC6H::Unquantize(int comp, uint8_t uBitsPerComp, bool bSigned) noexcept { int unq = 0, s = 0; if (bSigned) @@ -1918,7 +1918,7 @@ int D3DX_BC6H::Unquantize(int comp, uint8_t uBitsPerComp, bool bSigned) _Use_decl_annotations_ -int D3DX_BC6H::FinishUnquantize(int comp, bool bSigned) +int D3DX_BC6H::FinishUnquantize(int comp, bool bSigned) noexcept { if (bSigned) { @@ -1933,7 +1933,7 @@ int D3DX_BC6H::FinishUnquantize(int comp, bool bSigned) //------------------------------------------------------------------------------------- _Use_decl_annotations_ -bool D3DX_BC6H::EndPointsFit(const EncodeParams* pEP, const INTEndPntPair aEndPts[]) +bool D3DX_BC6H::EndPointsFit(const EncodeParams* pEP, const INTEndPntPair aEndPts[]) noexcept { assert(pEP); const bool bTransformed = ms_aInfo[pEP->uMode].bTransformed; @@ -1975,7 +1975,7 @@ bool D3DX_BC6H::EndPointsFit(const EncodeParams* pEP, const INTEndPntPair aEndPt _Use_decl_annotations_ -void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPntPair& endPts, INTColor aPalette[]) const +void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPntPair& endPts, INTColor aPalette[]) const noexcept { assert(pEP); const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; @@ -2026,7 +2026,7 @@ void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPn // given a collection of colors and quantized endpoints, generate a palette, choose best entries, and return a single toterr _Use_decl_annotations_ -float D3DX_BC6H::MapColorsQuantized(const EncodeParams* pEP, const INTColor aColors[], size_t np, const INTEndPntPair &endPts) const +float D3DX_BC6H::MapColorsQuantized(const EncodeParams* pEP, const INTColor aColors[], size_t np, const INTEndPntPair &endPts) const noexcept { assert(pEP); @@ -2062,7 +2062,7 @@ float D3DX_BC6H::MapColorsQuantized(const EncodeParams* pEP, const INTColor aCol _Use_decl_annotations_ float D3DX_BC6H::PerturbOne(const EncodeParams* pEP, const INTColor aColors[], size_t np, uint8_t ch, - const INTEndPntPair& oldEndPts, INTEndPntPair& newEndPts, float fOldErr, int do_b) const + const INTEndPntPair& oldEndPts, INTEndPntPair& newEndPts, float fOldErr, int do_b) const noexcept { assert(pEP); uint8_t uPrec; @@ -2123,7 +2123,7 @@ float D3DX_BC6H::PerturbOne(const EncodeParams* pEP, const INTColor aColors[], s _Use_decl_annotations_ void D3DX_BC6H::OptimizeOne(const EncodeParams* pEP, const INTColor aColors[], size_t np, float aOrgErr, - const INTEndPntPair &aOrgEndPts, INTEndPntPair &aOptEndPts) const + const INTEndPntPair &aOrgEndPts, INTEndPntPair &aOptEndPts) const noexcept { assert(pEP); float aOptErr = aOrgErr; @@ -2175,7 +2175,7 @@ void D3DX_BC6H::OptimizeOne(const EncodeParams* pEP, const INTColor aColors[], s _Use_decl_annotations_ -void D3DX_BC6H::OptimizeEndPoints(const EncodeParams* pEP, const float aOrgErr[], const INTEndPntPair aOrgEndPts[], INTEndPntPair aOptEndPts[]) const +void D3DX_BC6H::OptimizeEndPoints(const EncodeParams* pEP, const float aOrgErr[], const INTEndPntPair aOrgEndPts[], INTEndPntPair aOptEndPts[]) const noexcept { assert(pEP); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -2202,7 +2202,7 @@ void D3DX_BC6H::OptimizeEndPoints(const EncodeParams* pEP, const float aOrgErr[] // Swap endpoints as needed to ensure that the indices at fix up have a 0 high-order bit _Use_decl_annotations_ -void D3DX_BC6H::SwapIndices(const EncodeParams* pEP, INTEndPntPair aEndPts[], size_t aIndices[]) +void D3DX_BC6H::SwapIndices(const EncodeParams* pEP, INTEndPntPair aEndPts[], size_t aIndices[]) noexcept { assert(pEP); const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -2231,7 +2231,7 @@ void D3DX_BC6H::SwapIndices(const EncodeParams* pEP, INTEndPntPair aEndPts[], si // assign indices given a tile, shape, and quantized endpoints, return toterr for each region _Use_decl_annotations_ -void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndPts[], size_t aIndices[], float aTotErr[]) const +void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndPts[], size_t aIndices[], float aTotErr[]) const noexcept { assert(pEP); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -2273,7 +2273,7 @@ void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndP _Use_decl_annotations_ -void D3DX_BC6H::QuantizeEndPts(const EncodeParams* pEP, INTEndPntPair* aQntEndPts) const +void D3DX_BC6H::QuantizeEndPts(const EncodeParams* pEP, INTEndPntPair* aQntEndPts) const noexcept { assert(pEP && aQntEndPts); const INTEndPntPair* aUnqEndPts = pEP->aUnqEndPts[pEP->uShape]; @@ -2295,7 +2295,7 @@ void D3DX_BC6H::QuantizeEndPts(const EncodeParams* pEP, INTEndPntPair* aQntEndPt _Use_decl_annotations_ -void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[], const size_t aIndices[]) +void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[], const size_t aIndices[]) noexcept { assert(pEP); const uint8_t uRealMode = ms_aInfo[pEP->uMode].uMode; @@ -2339,7 +2339,7 @@ void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[] _Use_decl_annotations_ -void D3DX_BC6H::Refine(EncodeParams* pEP) +void D3DX_BC6H::Refine(EncodeParams* pEP) noexcept { assert(pEP); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -2389,7 +2389,7 @@ void D3DX_BC6H::Refine(EncodeParams* pEP) _Use_decl_annotations_ -void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegion, INTColor aPalette[]) +void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegion, INTColor aPalette[]) noexcept { assert(pEP); assert(uRegion < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); @@ -2425,7 +2425,7 @@ void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegi _Use_decl_annotations_ -float D3DX_BC6H::MapColors(const EncodeParams* pEP, size_t uRegion, size_t np, const size_t* auIndex) const +float D3DX_BC6H::MapColors(const EncodeParams* pEP, size_t uRegion, size_t np, const size_t* auIndex) const noexcept { assert(pEP); const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; @@ -2450,7 +2450,7 @@ float D3DX_BC6H::MapColors(const EncodeParams* pEP, size_t uRegion, size_t np, c } _Use_decl_annotations_ -float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const +float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const noexcept { assert(pEP); assert(pEP->uShape < BC6H_MAX_SHAPES); @@ -2517,7 +2517,7 @@ float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const // BC7 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void D3DX_BC7::Decode(HDRColorA* pOut) const +void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept { assert(pOut); @@ -2726,7 +2726,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const } _Use_decl_annotations_ -void D3DX_BC7::Encode(DWORD flags, const HDRColorA* const pIn) +void D3DX_BC7::Encode(DWORD flags, const HDRColorA* const pIn) noexcept { assert(pIn); @@ -2835,7 +2835,7 @@ void D3DX_BC7::Encode(DWORD flags, const HDRColorA* const pIn) //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMode, const LDREndPntPair& endPts, LDRColorA aPalette[]) const +void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMode, const LDREndPntPair& endPts, LDRColorA aPalette[]) const noexcept { assert(pEP); const size_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; @@ -2865,7 +2865,7 @@ void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMo _Use_decl_annotations_ float D3DX_BC7::PerturbOne(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, size_t ch, - const LDREndPntPair &oldEndPts, LDREndPntPair &newEndPts, float fOldErr, uint8_t do_b) const + const LDREndPntPair &oldEndPts, LDREndPntPair &newEndPts, float fOldErr, uint8_t do_b) const noexcept { assert(pEP); const int prec = ms_aInfo[pEP->uMode].RGBAPrecWithP[ch]; @@ -2907,7 +2907,7 @@ float D3DX_BC7::PerturbOne(const EncodeParams* pEP, const LDRColorA aColors[], s // always ensure endpoint ordering is preserved (no need to overlap the scan) _Use_decl_annotations_ void D3DX_BC7::Exhaustive(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, size_t ch, - float& fOrgErr, LDREndPntPair& optEndPt) const + float& fOrgErr, LDREndPntPair& optEndPt) const noexcept { assert(pEP); const uint8_t uPrec = ms_aInfo[pEP->uMode].RGBAPrecWithP[ch]; @@ -2978,7 +2978,7 @@ void D3DX_BC7::Exhaustive(const EncodeParams* pEP, const LDRColorA aColors[], si _Use_decl_annotations_ void D3DX_BC7::OptimizeOne(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, - float fOrgErr, const LDREndPntPair& org, LDREndPntPair& opt) const + float fOrgErr, const LDREndPntPair& org, LDREndPntPair& opt) const noexcept { assert(pEP); @@ -3044,7 +3044,7 @@ void D3DX_BC7::OptimizeOne(const EncodeParams* pEP, const LDRColorA aColors[], s _Use_decl_annotations_ void D3DX_BC7::OptimizeEndPoints(const EncodeParams* pEP, size_t uShape, size_t uIndexMode, const float afOrgErr[], - const LDREndPntPair aOrgEndPts[], LDREndPntPair aOptEndPts[]) const + const LDREndPntPair aOrgEndPts[], LDREndPntPair aOptEndPts[]) const noexcept { assert(pEP); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -3067,7 +3067,7 @@ void D3DX_BC7::OptimizeEndPoints(const EncodeParams* pEP, size_t uShape, size_t _Use_decl_annotations_ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uIndexMode, LDREndPntPair endPts[], size_t aIndices[], size_t aIndices2[], - float afTotErr[]) const + float afTotErr[]) const noexcept { assert(pEP); assert(uShape < BC7_MAX_SHAPES); @@ -3146,7 +3146,7 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd } _Use_decl_annotations_ -void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode, const LDREndPntPair aEndPts[], const size_t aIndex[], const size_t aIndex2[]) +void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode, const LDREndPntPair aEndPts[], const size_t aIndex[], const size_t aIndex2[]) noexcept { assert(pEP); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -3233,7 +3233,7 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio } _Use_decl_annotations_ -void D3DX_BC7::FixEndpointPBits(const EncodeParams* pEP, const LDREndPntPair *pOrigEndpoints, LDREndPntPair *pFixedEndpoints) +void D3DX_BC7::FixEndpointPBits(const EncodeParams* pEP, const LDREndPntPair *pOrigEndpoints, LDREndPntPair *pFixedEndpoints) noexcept { assert(pEP); const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; @@ -3318,7 +3318,7 @@ void D3DX_BC7::FixEndpointPBits(const EncodeParams* pEP, const LDREndPntPair *pO } _Use_decl_annotations_ -float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode) +float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode) noexcept { assert(pEP); assert(uShape < BC7_MAX_SHAPES); @@ -3376,7 +3376,7 @@ float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation, } _Use_decl_annotations_ -float D3DX_BC7::MapColors(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, const LDREndPntPair& endPts, float fMinErr) const +float D3DX_BC7::MapColors(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, const LDREndPntPair& endPts, float fMinErr) const noexcept { assert(pEP); const uint8_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; @@ -3399,7 +3399,7 @@ float D3DX_BC7::MapColors(const EncodeParams* pEP, const LDRColorA aColors[], si } _Use_decl_annotations_ -float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode) +float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode) noexcept { assert(pEP); assert(uShape < BC7_MAX_SHAPES); @@ -3512,7 +3512,7 @@ float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode) // BC6H Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC6HU(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC6HU(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(D3DX_BC6H) == 16, "D3DX_BC6H should be 16 bytes"); @@ -3520,7 +3520,7 @@ void DirectX::D3DXDecodeBC6HU(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXDecodeBC6HS(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC6HS(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(D3DX_BC6H) == 16, "D3DX_BC6H should be 16 bytes"); @@ -3528,7 +3528,7 @@ void DirectX::D3DXDecodeBC6HS(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC6HU(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC6HU(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { UNREFERENCED_PARAMETER(flags); assert(pBC && pColor); @@ -3537,7 +3537,7 @@ void DirectX::D3DXEncodeBC6HU(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC6HS(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC6HS(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { UNREFERENCED_PARAMETER(flags); assert(pBC && pColor); @@ -3550,7 +3550,7 @@ void DirectX::D3DXEncodeBC6HS(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) // BC7 Compression //------------------------------------------------------------------------------------- _Use_decl_annotations_ -void DirectX::D3DXDecodeBC7(XMVECTOR *pColor, const uint8_t *pBC) +void DirectX::D3DXDecodeBC7(XMVECTOR *pColor, const uint8_t *pBC) noexcept { assert(pColor && pBC); static_assert(sizeof(D3DX_BC7) == 16, "D3DX_BC7 should be 16 bytes"); @@ -3558,7 +3558,7 @@ void DirectX::D3DXDecodeBC7(XMVECTOR *pColor, const uint8_t *pBC) } _Use_decl_annotations_ -void DirectX::D3DXEncodeBC7(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) +void DirectX::D3DXEncodeBC7(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) noexcept { assert(pBC && pColor); static_assert(sizeof(D3DX_BC7) == 16, "D3DX_BC7 should be 16 bytes"); diff --git a/DirectXTex/BCDirectCompute.h b/DirectXTex/BCDirectCompute.h index f231c07..f3b4e26 100644 --- a/DirectXTex/BCDirectCompute.h +++ b/DirectXTex/BCDirectCompute.h @@ -23,7 +23,7 @@ namespace DirectX HRESULT Compress(const Image& srcImage, const Image& destImage); - DXGI_FORMAT GetSourceFormat() const { return m_srcformat; } + DXGI_FORMAT GetSourceFormat() const noexcept { return m_srcformat; } private: DXGI_FORMAT m_bcformat; diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h index 5ea0e59..e967831 100644 --- a/DirectXTex/DirectXTex.h +++ b/DirectXTex/DirectXTex.h @@ -215,25 +215,25 @@ namespace DirectX HRESULT __cdecl GetMetadataFromDDSMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ DWORD flags, - _Out_ TexMetadata& metadata); + _Out_ TexMetadata& metadata) noexcept; HRESULT __cdecl GetMetadataFromDDSFile( _In_z_ const wchar_t* szFile, _In_ DWORD flags, - _Out_ TexMetadata& metadata); + _Out_ TexMetadata& metadata) noexcept; HRESULT __cdecl GetMetadataFromHDRMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_ TexMetadata& metadata); + _Out_ TexMetadata& metadata) noexcept; HRESULT __cdecl GetMetadataFromHDRFile( _In_z_ const wchar_t* szFile, - _Out_ TexMetadata& metadata); + _Out_ TexMetadata& metadata) noexcept; HRESULT __cdecl GetMetadataFromTGAMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_ TexMetadata& metadata); + _Out_ TexMetadata& metadata) noexcept; HRESULT __cdecl GetMetadataFromTGAFile( _In_z_ const wchar_t* szFile, - _Out_ TexMetadata& metadata); + _Out_ TexMetadata& metadata) noexcept; HRESULT __cdecl GetMetadataFromWICMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, @@ -273,24 +273,24 @@ namespace DirectX ScratchImage(const ScratchImage&) = delete; ScratchImage& operator=(const ScratchImage&) = delete; - HRESULT __cdecl Initialize(_In_ const TexMetadata& mdata, _In_ DWORD flags = CP_FLAGS_NONE); + HRESULT __cdecl Initialize(_In_ const TexMetadata& mdata, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl Initialize1D(_In_ DXGI_FORMAT fmt, _In_ size_t length, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE); - HRESULT __cdecl Initialize2D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE); - HRESULT __cdecl Initialize3D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t depth, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE); - HRESULT __cdecl InitializeCube(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t nCubes, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE); + HRESULT __cdecl Initialize1D(_In_ DXGI_FORMAT fmt, _In_ size_t length, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; + HRESULT __cdecl Initialize2D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; + HRESULT __cdecl Initialize3D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t depth, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; + HRESULT __cdecl InitializeCube(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t nCubes, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl InitializeFromImage(_In_ const Image& srcImage, _In_ bool allow1D = false, _In_ DWORD flags = CP_FLAGS_NONE); - HRESULT __cdecl InitializeArrayFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false, _In_ DWORD flags = CP_FLAGS_NONE); - HRESULT __cdecl InitializeCubeFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ DWORD flags = CP_FLAGS_NONE); - HRESULT __cdecl Initialize3DFromImages(_In_reads_(depth) const Image* images, _In_ size_t depth, _In_ DWORD flags = CP_FLAGS_NONE); + HRESULT __cdecl InitializeFromImage(_In_ const Image& srcImage, _In_ bool allow1D = false, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; + HRESULT __cdecl InitializeArrayFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; + HRESULT __cdecl InitializeCubeFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; + HRESULT __cdecl Initialize3DFromImages(_In_reads_(depth) const Image* images, _In_ size_t depth, _In_ DWORD flags = CP_FLAGS_NONE) noexcept; void __cdecl Release() noexcept; - bool __cdecl OverrideFormat(_In_ DXGI_FORMAT f); + bool __cdecl OverrideFormat(_In_ DXGI_FORMAT f) noexcept; const TexMetadata& __cdecl GetMetadata() const noexcept { return m_metadata; } - const Image* __cdecl GetImage(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const; + const Image* __cdecl GetImage(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const noexcept; const Image* __cdecl GetImages() const noexcept { return m_image; } size_t __cdecl GetImageCount() const noexcept { return m_nimages; } @@ -343,47 +343,47 @@ namespace DirectX HRESULT __cdecl LoadFromDDSMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ DWORD flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image); + _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl LoadFromDDSFile( _In_z_ const wchar_t* szFile, _In_ DWORD flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image); + _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl SaveToDDSMemory( _In_ const Image& image, _In_ DWORD flags, - _Out_ Blob& blob); + _Out_ Blob& blob) noexcept; HRESULT __cdecl SaveToDDSMemory( _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD flags, - _Out_ Blob& blob); + _Out_ Blob& blob) noexcept; - HRESULT __cdecl SaveToDDSFile(_In_ const Image& image, _In_ DWORD flags, _In_z_ const wchar_t* szFile); + HRESULT __cdecl SaveToDDSFile(_In_ const Image& image, _In_ DWORD flags, _In_z_ const wchar_t* szFile) noexcept; HRESULT __cdecl SaveToDDSFile( _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DWORD flags, _In_z_ const wchar_t* szFile); + _In_ DWORD flags, _In_z_ const wchar_t* szFile) noexcept; // HDR operations HRESULT __cdecl LoadFromHDRMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image); + _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl LoadFromHDRFile( _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image); + _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl SaveToHDRMemory(_In_ const Image& image, _Out_ Blob& blob); - HRESULT __cdecl SaveToHDRFile(_In_ const Image& image, _In_z_ const wchar_t* szFile); + HRESULT __cdecl SaveToHDRMemory(_In_ const Image& image, _Out_ Blob& blob) noexcept; + HRESULT __cdecl SaveToHDRFile(_In_ const Image& image, _In_z_ const wchar_t* szFile) noexcept; // TGA operations HRESULT __cdecl LoadFromTGAMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image); + _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl LoadFromTGAFile( _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image); + _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr); - HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr); + HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; + HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; // WIC operations HRESULT __cdecl LoadFromWICMemory( @@ -429,10 +429,10 @@ namespace DirectX TEX_FR_FLIP_VERTICAL = 0x10, }; - HRESULT __cdecl FlipRotate(_In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image); + HRESULT __cdecl FlipRotate(_In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl FlipRotate( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DWORD flags, _Out_ ScratchImage& result); + _In_ DWORD flags, _Out_ ScratchImage& result) noexcept; // Flip and/or rotate image enum TEX_FILTER_FLAGS @@ -491,10 +491,10 @@ namespace DirectX HRESULT __cdecl Resize( _In_ const Image& srcImage, _In_ size_t width, _In_ size_t height, _In_ DWORD filter, - _Out_ ScratchImage& image); + _Out_ ScratchImage& image) noexcept; HRESULT __cdecl Resize( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ size_t width, _In_ size_t height, _In_ DWORD filter, _Out_ ScratchImage& result); + _In_ size_t width, _In_ size_t height, _In_ DWORD filter, _Out_ ScratchImage& result) noexcept; // Resize the image to width x height. Defaults to Fant filtering. // Note for a complex resize, the result will always have mipLevels == 1 @@ -509,15 +509,15 @@ namespace DirectX _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage& result); // Convert the image to a new format - HRESULT __cdecl ConvertToSinglePlane(_In_ const Image& srcImage, _Out_ ScratchImage& image); + HRESULT __cdecl ConvertToSinglePlane(_In_ const Image& srcImage, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl ConvertToSinglePlane( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _Out_ ScratchImage& image); + _Out_ ScratchImage& image) noexcept; // Converts the image from a planar format to an equivalent non-planar format HRESULT __cdecl GenerateMipMaps( _In_ const Image& baseImage, _In_ DWORD filter, _In_ size_t levels, - _Inout_ ScratchImage& mipChain, _In_ bool allow1D = false); + _Inout_ ScratchImage& mipChain, _In_ bool allow1D = false) noexcept; HRESULT __cdecl GenerateMipMaps( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD filter, _In_ size_t levels, _Inout_ ScratchImage& mipChain); @@ -526,7 +526,7 @@ namespace DirectX HRESULT __cdecl GenerateMipMaps3D( _In_reads_(depth) const Image* baseImages, _In_ size_t depth, _In_ DWORD filter, _In_ size_t levels, - _Out_ ScratchImage& mipChain); + _Out_ ScratchImage& mipChain) noexcept; HRESULT __cdecl GenerateMipMaps3D( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD filter, _In_ size_t levels, _Out_ ScratchImage& mipChain); @@ -535,7 +535,7 @@ namespace DirectX HRESULT __cdecl ScaleMipMapsAlphaForCoverage( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ size_t item, - _In_ float alphaReference, _Inout_ ScratchImage& mipChain); + _In_ float alphaReference, _Inout_ ScratchImage& mipChain) noexcept; enum TEX_PMALPHA_FLAGS @@ -555,10 +555,10 @@ namespace DirectX // if the output format type is IsSRGB(), then SRGB_OUT is on by default }; - HRESULT __cdecl PremultiplyAlpha(_In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image); + HRESULT __cdecl PremultiplyAlpha(_In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl PremultiplyAlpha( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DWORD flags, _Out_ ScratchImage& result); + _In_ DWORD flags, _Out_ ScratchImage& result) noexcept; // Converts to/from a premultiplied alpha version of the texture enum TEX_COMPRESS_FLAGS @@ -611,10 +611,10 @@ namespace DirectX // DirectCompute-based compression (alphaWeight is only used by BC7. 1.0 is the typical value to use) #endif - HRESULT __cdecl Decompress(_In_ const Image& cImage, _In_ DXGI_FORMAT format, _Out_ ScratchImage& image); + HRESULT __cdecl Decompress(_In_ const Image& cImage, _In_ DXGI_FORMAT format, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl Decompress( _In_reads_(nimages) const Image* cImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _Out_ ScratchImage& images); + _In_ DXGI_FORMAT format, _Out_ ScratchImage& images) noexcept; //--------------------------------------------------------------------------------- // Normal map operations @@ -645,10 +645,10 @@ namespace DirectX HRESULT __cdecl ComputeNormalMap( _In_ const Image& srcImage, _In_ DWORD flags, _In_ float amplitude, - _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMap); + _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMap) noexcept; HRESULT __cdecl ComputeNormalMap( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DWORD flags, _In_ float amplitude, _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMaps); + _In_ DWORD flags, _In_ float amplitude, _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMaps) noexcept; //--------------------------------------------------------------------------------- // Misc image operations @@ -661,7 +661,7 @@ namespace DirectX size_t h; Rect() = default; - Rect(size_t _x, size_t _y, size_t _w, size_t _h) : x(_x), y(_y), w(_w), h(_h) {} + Rect(size_t _x, size_t _y, size_t _w, size_t _h) noexcept : x(_x), y(_y), w(_w), h(_h) {} }; HRESULT __cdecl CopyRectangle( @@ -687,7 +687,7 @@ namespace DirectX // Indicates that image should be scaled and biased before comparison (i.e. UNORM -> SNORM) }; - HRESULT __cdecl ComputeMSE(_In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV, _In_ DWORD flags = 0); + HRESULT __cdecl ComputeMSE(_In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV, _In_ DWORD flags = 0) noexcept; HRESULT __cdecl EvaluateImage( _In_ const Image& image, @@ -749,7 +749,7 @@ namespace DirectX _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, _Outptr_ ID3D11ShaderResourceView** ppSRV) noexcept; - HRESULT __cdecl CaptureTexture(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _Out_ ScratchImage& result); + HRESULT __cdecl CaptureTexture(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _Out_ ScratchImage& result) noexcept; #endif //--------------------------------------------------------------------------------- @@ -775,7 +775,7 @@ namespace DirectX _In_ ID3D12CommandQueue* pCommandQueue, _In_ ID3D12Resource* pSource, _In_ bool isCubeMap, _Out_ ScratchImage& result, _In_ D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET, - _In_ D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET); + _In_ D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET) noexcept; #endif #include "DirectXTex.inl" diff --git a/DirectXTex/DirectXTex.inl b/DirectXTex/DirectXTex.inl index 1d13fa0..a430b25 100644 --- a/DirectXTex/DirectXTex.inl +++ b/DirectXTex/DirectXTex.inl @@ -94,7 +94,7 @@ inline bool __cdecl IsSRGB(DXGI_FORMAT fmt) noexcept // Image I/O //===================================================================================== _Use_decl_annotations_ -inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DWORD flags, Blob& blob) +inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DWORD flags, Blob& blob) noexcept { TexMetadata mdata = {}; mdata.width = image.width; @@ -109,7 +109,7 @@ inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DWORD flags, Blob& bl } _Use_decl_annotations_ -inline HRESULT __cdecl SaveToDDSFile(const Image& image, DWORD flags, const wchar_t* szFile) +inline HRESULT __cdecl SaveToDDSFile(const Image& image, DWORD flags, const wchar_t* szFile) noexcept { TexMetadata mdata = {}; mdata.width = image.width; diff --git a/DirectXTex/DirectXTexCompress.cpp b/DirectXTex/DirectXTexCompress.cpp index e306c87..c987183 100644 --- a/DirectXTex/DirectXTexCompress.cpp +++ b/DirectXTex/DirectXTexCompress.cpp @@ -22,7 +22,7 @@ using namespace DirectX; namespace { - inline DWORD GetBCFlags(_In_ DWORD compress) + inline DWORD GetBCFlags(_In_ DWORD compress) noexcept { static_assert(static_cast(TEX_COMPRESS_RGB_DITHER) == static_cast(BC_FLAGS_DITHER_RGB), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast(TEX_COMPRESS_A_DITHER) == static_cast(BC_FLAGS_DITHER_A), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); @@ -33,7 +33,7 @@ namespace return (compress & (BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A | BC_FLAGS_UNIFORM | BC_FLAGS_USE_3SUBSETS | BC_FLAGS_FORCE_BC7_MODE6)); } - inline DWORD GetSRGBFlags(_In_ DWORD compress) + inline DWORD GetSRGBFlags(_In_ DWORD compress) noexcept { static_assert(static_cast(TEX_COMPRESS_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast(TEX_COMPRESS_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); @@ -41,7 +41,7 @@ namespace return (compress & TEX_COMPRESS_SRGB); } - inline bool DetermineEncoderSettings(_In_ DXGI_FORMAT format, _Out_ BC_ENCODE& pfEncode, _Out_ size_t& blocksize, _Out_ DWORD& cflags) + inline bool DetermineEncoderSettings(_In_ DXGI_FORMAT format, _Out_ BC_ENCODE& pfEncode, _Out_ size_t& blocksize, _Out_ DWORD& cflags) noexcept { switch (format) { @@ -329,7 +329,7 @@ namespace //------------------------------------------------------------------------------------- - DXGI_FORMAT DefaultDecompress(_In_ DXGI_FORMAT format) + DXGI_FORMAT DefaultDecompress(_In_ DXGI_FORMAT format) noexcept { switch (format) { @@ -493,10 +493,10 @@ namespace //------------------------------------------------------------------------------------- namespace DirectX { - bool _IsAlphaAllOpaqueBC(_In_ const Image& cImage); + bool _IsAlphaAllOpaqueBC(_In_ const Image& cImage) noexcept; // Also used by Image - bool _IsAlphaAllOpaqueBC(_In_ const Image& cImage) + bool _IsAlphaAllOpaqueBC(_In_ const Image& cImage) noexcept { if (!cImage.pixels) return false; @@ -727,7 +727,7 @@ _Use_decl_annotations_ HRESULT DirectX::Decompress( const Image& cImage, DXGI_FORMAT format, - ScratchImage& image) + ScratchImage& image) noexcept { if (!IsCompressed(cImage.format) || IsCompressed(format)) return E_INVALIDARG; @@ -777,7 +777,7 @@ HRESULT DirectX::Decompress( size_t nimages, const TexMetadata& metadata, DXGI_FORMAT format, - ScratchImage& images) + ScratchImage& images) noexcept { if (!cImages || !nimages) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexCompressGPU.cpp b/DirectXTex/DirectXTexCompressGPU.cpp index e3f1734..690edfc 100644 --- a/DirectXTex/DirectXTexCompressGPU.cpp +++ b/DirectXTex/DirectXTexCompressGPU.cpp @@ -17,7 +17,7 @@ using namespace DirectX; namespace { - inline DWORD GetSRGBFlags(_In_ DWORD compress) + inline DWORD GetSRGBFlags(_In_ DWORD compress) noexcept { static_assert(static_cast(TEX_COMPRESS_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast(TEX_COMPRESS_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index de25d76..37dbf47 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -17,7 +17,7 @@ using Microsoft::WRL::ComPtr; namespace { - inline uint32_t FloatTo7e3(float Value) + inline uint32_t FloatTo7e3(float Value) noexcept { uint32_t IValue = reinterpret_cast(&Value)[0]; @@ -50,7 +50,7 @@ namespace } } - inline float FloatFrom7e3(uint32_t Value) + inline float FloatFrom7e3(uint32_t Value) noexcept { auto Mantissa = static_cast(Value & 0x7F); @@ -83,7 +83,7 @@ namespace return reinterpret_cast(&Result)[0]; } - inline uint32_t FloatTo6e4(float Value) + inline uint32_t FloatTo6e4(float Value) noexcept { uint32_t IValue = reinterpret_cast(&Value)[0]; @@ -116,7 +116,7 @@ namespace } } - inline float FloatFrom6e4(uint32_t Value) + inline float FloatFrom6e4(uint32_t Value) noexcept { uint32_t Mantissa = static_cast(Value & 0x3F); @@ -205,7 +205,7 @@ void DirectX::_CopyScanline( const void* pSource, size_t inSize, DXGI_FORMAT format, - DWORD flags) + DWORD flags) noexcept { assert(pDestination && outSize > 0); assert(pSource && inSize > 0); @@ -450,7 +450,7 @@ void DirectX::_SwizzleScanline( const void* pSource, size_t inSize, DXGI_FORMAT format, - DWORD flags) + DWORD flags) noexcept { assert(pDestination && outSize > 0); assert(pSource && inSize > 0); @@ -621,7 +621,7 @@ bool DirectX::_ExpandScanline( const void* pSource, size_t inSize, DXGI_FORMAT inFormat, - DWORD flags) + DWORD flags) noexcept { assert(pDestination && outSize > 0); assert(pSource && inSize > 0); @@ -760,7 +760,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline( size_t count, const void* pSource, size_t size, - DXGI_FORMAT format) + DXGI_FORMAT format) noexcept { assert(pDestination && count > 0 && ((reinterpret_cast(pDestination) & 0xF) == 0)); assert(pSource && size > 0); @@ -1609,7 +1609,7 @@ bool DirectX::_StoreScanline( DXGI_FORMAT format, const XMVECTOR* pSource, size_t count, - float threshold) + float threshold) noexcept { assert(pDestination && size > 0); assert(pSource && count > 0 && ((reinterpret_cast(pSource) & 0xF) == 0)); @@ -2462,7 +2462,7 @@ bool DirectX::_StoreScanline( // Convert DXGI image to/from GUID_WICPixelFormat128bppRGBAFloat (no range conversions) //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::_ConvertToR32G32B32A32(const Image& srcImage, ScratchImage& image) +HRESULT DirectX::_ConvertToR32G32B32A32(const Image& srcImage, ScratchImage& image) noexcept { if (!srcImage.pixels) return E_POINTER; @@ -2502,7 +2502,7 @@ HRESULT DirectX::_ConvertToR32G32B32A32(const Image& srcImage, ScratchImage& ima } _Use_decl_annotations_ -HRESULT DirectX::_ConvertFromR32G32B32A32(const Image& srcImage, const Image& destImage) +HRESULT DirectX::_ConvertFromR32G32B32A32(const Image& srcImage, const Image& destImage) noexcept { assert(srcImage.format == DXGI_FORMAT_R32G32B32A32_FLOAT); @@ -2528,7 +2528,7 @@ HRESULT DirectX::_ConvertFromR32G32B32A32(const Image& srcImage, const Image& de } _Use_decl_annotations_ -HRESULT DirectX::_ConvertFromR32G32B32A32(const Image& srcImage, DXGI_FORMAT format, ScratchImage& image) +HRESULT DirectX::_ConvertFromR32G32B32A32(const Image& srcImage, DXGI_FORMAT format, ScratchImage& image) noexcept { if (!srcImage.pixels) return E_POINTER; @@ -2560,7 +2560,7 @@ HRESULT DirectX::_ConvertFromR32G32B32A32( size_t nimages, const TexMetadata& metadata, DXGI_FORMAT format, - ScratchImage& result) + ScratchImage& result) noexcept { if (!srcImages) return E_POINTER; @@ -2631,7 +2631,7 @@ HRESULT DirectX::_ConvertFromR32G32B32A32( // Convert DXGI image to/from GUID_WICPixelFormat64bppRGBAHalf (no range conversions) //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::_ConvertToR16G16B16A16(const Image& srcImage, ScratchImage& image) +HRESULT DirectX::_ConvertToR16G16B16A16(const Image& srcImage, ScratchImage& image) noexcept { if (!srcImage.pixels) return E_POINTER; @@ -2683,7 +2683,7 @@ HRESULT DirectX::_ConvertToR16G16B16A16(const Image& srcImage, ScratchImage& ima } _Use_decl_annotations_ -HRESULT DirectX::_ConvertFromR16G16B16A16(const Image& srcImage, const Image& destImage) +HRESULT DirectX::_ConvertFromR16G16B16A16(const Image& srcImage, const Image& destImage) noexcept { assert(srcImage.format == DXGI_FORMAT_R16G16B16A16_FLOAT); @@ -2733,7 +2733,7 @@ bool DirectX::_StoreScanlineLinear( XMVECTOR* pSource, size_t count, DWORD flags, - float threshold) + float threshold) noexcept { assert(pDestination && size > 0); assert(pSource && count > 0 && ((reinterpret_cast(pSource) & 0xF) == 0)); @@ -2808,7 +2808,7 @@ bool DirectX::_LoadScanlineLinear( const void* pSource, size_t size, DXGI_FORMAT format, - DWORD flags) + DWORD flags) noexcept { assert(pDestination && count > 0 && ((reinterpret_cast(pDestination) & 0xF) == 0)); assert(pSource && size > 0); @@ -2984,7 +2984,7 @@ namespace } _Use_decl_annotations_ -DWORD DirectX::_GetConvertFlags(DXGI_FORMAT format) +DWORD DirectX::_GetConvertFlags(DXGI_FORMAT format) noexcept { #ifdef _DEBUG // Ensure conversion table is in ascending order @@ -3908,7 +3908,7 @@ bool DirectX::_StoreScanlineDither( float threshold, size_t y, size_t z, - XMVECTOR* pDiffusionErrors) + XMVECTOR* pDiffusionErrors) noexcept { assert(pDestination && size > 0); assert(pSource && count > 0 && ((reinterpret_cast(pSource) & 0xF) == 0)); @@ -4371,7 +4371,7 @@ namespace _In_ DXGI_FORMAT sformat, _In_ DXGI_FORMAT tformat, _Out_ WICPixelFormatGUID& pfGUID, - _Out_ WICPixelFormatGUID& targetGUID) + _Out_ WICPixelFormatGUID& targetGUID) noexcept { memset(&pfGUID, 0, sizeof(GUID)); memset(&targetGUID, 0, sizeof(GUID)); @@ -4664,7 +4664,7 @@ namespace } //------------------------------------------------------------------------------------- - DXGI_FORMAT _PlanarToSingle(_In_ DXGI_FORMAT format) + DXGI_FORMAT _PlanarToSingle(_In_ DXGI_FORMAT format) noexcept { switch (format) { @@ -4735,7 +4735,7 @@ namespace }\ } - HRESULT ConvertToSinglePlane_(_In_ const Image& srcImage, _In_ const Image& destImage) + HRESULT ConvertToSinglePlane_(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept { assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); @@ -5039,7 +5039,7 @@ HRESULT DirectX::Convert( // Convert image from planar to single plane (image) //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::ConvertToSinglePlane(const Image& srcImage, ScratchImage& image) +HRESULT DirectX::ConvertToSinglePlane(const Image& srcImage, ScratchImage& image) noexcept { if (!IsPlanar(srcImage.format)) return E_INVALIDARG; @@ -5084,7 +5084,7 @@ HRESULT DirectX::ConvertToSinglePlane( const Image* srcImages, size_t nimages, const TexMetadata& metadata, - ScratchImage& result) + ScratchImage& result) noexcept { if (!srcImages || !nimages) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index 37661e7..872d243 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -32,7 +32,7 @@ namespace _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, const TexMetadata& metadata, - const ScratchImage& result) + const ScratchImage& result) noexcept { if (!pContext || !pSource || !result.GetPixels()) return E_POINTER; @@ -729,7 +729,7 @@ HRESULT DirectX::CaptureTexture( ID3D11Device* pDevice, ID3D11DeviceContext* pContext, ID3D11Resource* pSource, - ScratchImage& result) + ScratchImage& result) noexcept { if (!pDevice || !pContext || !pSource) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexD3D12.cpp b/DirectXTex/DirectXTexD3D12.cpp index 8d7c843..4e97550 100644 --- a/DirectXTex/DirectXTexD3D12.cpp +++ b/DirectXTex/DirectXTexD3D12.cpp @@ -44,7 +44,7 @@ namespace _In_ DXGI_FORMAT fmt, _In_ size_t height, _In_ size_t slicePlane, - _Inout_ T& res) + _Inout_ T& res) noexcept { switch (static_cast(fmt)) { @@ -119,7 +119,7 @@ namespace UINT& numberOfPlanes, UINT& numberOfResources, D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState) + D3D12_RESOURCE_STATES afterState) noexcept { if (!pCommandQ || !pSource) return E_INVALIDARG; @@ -152,7 +152,9 @@ namespace if (memAlloc > SIZE_MAX) return E_UNEXPECTED; - layoutBuff.reset(new uint8_t[memAlloc]); + layoutBuff.reset(new (std::nothrow) uint8_t[memAlloc]); + if (!layoutBuff) + return E_OUTOFMEMORY; auto pLayout = reinterpret_cast(layoutBuff.get()); auto pRowSizesInBytes = reinterpret_cast(pLayout + numberOfResources); @@ -644,7 +646,7 @@ HRESULT DirectX::CaptureTexture( bool isCubeMap, ScratchImage& result, D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState) + D3D12_RESOURCE_STATES afterState) noexcept { if (!pCommandQueue || !pSource) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index fc250b8..40a5d61 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -154,7 +154,7 @@ namespace // FourCC CTX1 (Xbox 360 only) // FourCC EAR, EARG, ET2, ET2A (Ericsson Texture Compression) - DXGI_FORMAT GetDXGIFormat(const DDS_HEADER& hdr, const DDS_PIXELFORMAT& ddpf, DWORD flags, _Inout_ DWORD& convFlags) + DXGI_FORMAT GetDXGIFormat(const DDS_HEADER& hdr, const DDS_PIXELFORMAT& ddpf, DWORD flags, _Inout_ DWORD& convFlags) noexcept { uint32_t ddpfFlags = ddpf.flags; if (hdr.reserved1[9] == MAKEFOURCC('N', 'V', 'T', 'T')) @@ -272,7 +272,7 @@ namespace size_t size, DWORD flags, _Out_ TexMetadata& metadata, - _Inout_ DWORD& convFlags) + _Inout_ DWORD& convFlags) noexcept { if (!pSource) return E_INVALIDARG; @@ -536,7 +536,7 @@ HRESULT DirectX::_EncodeDDSHeader( DWORD flags, void* pDestination, size_t maxsize, - size_t& required) + size_t& required) noexcept { if (!IsValid(metadata.format)) return E_INVALIDARG; @@ -789,7 +789,7 @@ namespace TEXP_LEGACY_A8L8 }; - inline TEXP_LEGACY_FORMAT _FindLegacyFormat(DWORD flags) + inline TEXP_LEGACY_FORMAT _FindLegacyFormat(DWORD flags) noexcept { TEXP_LEGACY_FORMAT lformat = TEXP_LEGACY_UNKNOWN; @@ -826,7 +826,7 @@ namespace size_t inSize, _In_ TEXP_LEGACY_FORMAT inFormat, _In_reads_opt_(256) const uint32_t* pal8, - _In_ DWORD flags) + _In_ DWORD flags) noexcept { assert(pDestination && outSize > 0); assert(pSource && inSize > 0); @@ -1134,7 +1134,7 @@ namespace _In_ DWORD cpFlags, _In_ DWORD convFlags, _In_reads_opt_(256) const uint32_t *pal8, - _In_ const ScratchImage& image) + _In_ const ScratchImage& image) noexcept { assert(pPixels); assert(image.GetPixels()); @@ -1402,7 +1402,7 @@ namespace return S_OK; } - HRESULT CopyImageInPlace(DWORD convFlags, _In_ const ScratchImage& image) + HRESULT CopyImageInPlace(DWORD convFlags, _In_ const ScratchImage& image) noexcept { if (!image.GetPixels()) return E_FAIL; @@ -1462,7 +1462,7 @@ HRESULT DirectX::GetMetadataFromDDSMemory( const void* pSource, size_t size, DWORD flags, - TexMetadata& metadata) + TexMetadata& metadata) noexcept { if (!pSource || size == 0) return E_INVALIDARG; @@ -1475,7 +1475,7 @@ _Use_decl_annotations_ HRESULT DirectX::GetMetadataFromDDSFile( const wchar_t* szFile, DWORD flags, - TexMetadata& metadata) + TexMetadata& metadata) noexcept { if (!szFile) return E_INVALIDARG; @@ -1534,7 +1534,7 @@ HRESULT DirectX::LoadFromDDSMemory( size_t size, DWORD flags, TexMetadata* metadata, - ScratchImage& image) + ScratchImage& image) noexcept { if (!pSource || size == 0) return E_INVALIDARG; @@ -1606,7 +1606,7 @@ HRESULT DirectX::LoadFromDDSFile( const wchar_t* szFile, DWORD flags, TexMetadata* metadata, - ScratchImage& image) + ScratchImage& image) noexcept { if (!szFile) return E_INVALIDARG; @@ -1796,7 +1796,7 @@ HRESULT DirectX::SaveToDDSMemory( size_t nimages, const TexMetadata& metadata, DWORD flags, - Blob& blob) + Blob& blob) noexcept { if (!images || (nimages == 0)) return E_INVALIDARG; @@ -2024,7 +2024,7 @@ HRESULT DirectX::SaveToDDSFile( size_t nimages, const TexMetadata& metadata, DWORD flags, - const wchar_t* szFile) + const wchar_t* szFile) noexcept { if (!szFile) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexFlipRotate.cpp b/DirectXTex/DirectXTexFlipRotate.cpp index afe88fb..25eeeb5 100644 --- a/DirectXTex/DirectXTexFlipRotate.cpp +++ b/DirectXTex/DirectXTexFlipRotate.cpp @@ -23,7 +23,7 @@ namespace const Image& srcImage, DWORD flags, const WICPixelFormatGUID& pfGUID, - const Image& destImage) + const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; @@ -91,7 +91,7 @@ namespace HRESULT PerformFlipRotateViaF16( const Image& srcImage, DWORD flags, - const Image& destImage) + const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; @@ -133,7 +133,7 @@ namespace HRESULT PerformFlipRotateViaF32( const Image& srcImage, DWORD flags, - const Image& destImage) + const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; @@ -185,7 +185,7 @@ _Use_decl_annotations_ HRESULT DirectX::FlipRotate( const Image& srcImage, DWORD flags, - ScratchImage& image) + ScratchImage& image) noexcept { if (!srcImage.pixels) return E_POINTER; @@ -284,7 +284,7 @@ HRESULT DirectX::FlipRotate( size_t nimages, const TexMetadata& metadata, DWORD flags, - ScratchImage& result) + ScratchImage& result) noexcept { if (!srcImages || !nimages) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexHDR.cpp b/DirectXTex/DirectXTexHDR.cpp index 9e8a6a3..daa76a3 100644 --- a/DirectXTex/DirectXTexHDR.cpp +++ b/DirectXTex/DirectXTexHDR.cpp @@ -55,7 +55,7 @@ namespace "\n"\ "-Y %u +X %u\n"; - inline size_t FindEOL(const char* str, size_t maxlen) + inline size_t FindEOL(const char* str, size_t maxlen) noexcept { size_t pos = 0; @@ -79,7 +79,7 @@ namespace size_t size, _Out_ TexMetadata& metadata, size_t& offset, - float& exposure) + float& exposure) noexcept { if (!pSource) return E_INVALIDARG; @@ -290,7 +290,7 @@ namespace //------------------------------------------------------------------------------------- // FloatToRGBE //------------------------------------------------------------------------------------- - inline void FloatToRGBE(_Out_writes_(width*4) uint8_t* pDestination, _In_reads_(width*fpp) const float* pSource, size_t width, _In_range_(3, 4) int fpp) + inline void FloatToRGBE(_Out_writes_(width*4) uint8_t* pDestination, _In_reads_(width*fpp) const float* pSource, size_t width, _In_range_(3, 4) int fpp) noexcept { auto ePtr = pSource + width * size_t(fpp); @@ -333,7 +333,7 @@ namespace // Encode using Adapative RLE //------------------------------------------------------------------------------------- _Success_(return > 0) - size_t EncodeRLE(_Out_writes_(width * 4) uint8_t* enc, _In_reads_(width * 4) const uint8_t* rgbe, size_t rowPitch, size_t width) + size_t EncodeRLE(_Out_writes_(width * 4) uint8_t* enc, _In_reads_(width * 4) const uint8_t* rgbe, size_t rowPitch, size_t width) noexcept { if (width < 8 || width > INT16_MAX) { @@ -523,7 +523,7 @@ namespace // Obtain metadata from HDR file in memory/on disk //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromHDRMemory(const void* pSource, size_t size, TexMetadata& metadata) +HRESULT DirectX::GetMetadataFromHDRMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept { if (!pSource || size == 0) return E_INVALIDARG; @@ -534,7 +534,7 @@ HRESULT DirectX::GetMetadataFromHDRMemory(const void* pSource, size_t size, TexM } _Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& metadata) +HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& metadata) noexcept { if (!szFile) return E_INVALIDARG; @@ -587,7 +587,7 @@ HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& meta // Load a HDR file in memory //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) +HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept { if (!pSource || size == 0) return E_INVALIDARG; @@ -804,7 +804,7 @@ HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata // Load a HDR file from disk //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image) +HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image) noexcept { if (!szFile) return E_INVALIDARG; @@ -867,7 +867,7 @@ HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, S // Save a HDR file to memory //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) +HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) noexcept { if (!image.pixels) return E_POINTER; @@ -969,7 +969,7 @@ HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) // Save a HDR file to disk //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) +HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexcept { if (!szFile) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexImage.cpp b/DirectXTex/DirectXTexImage.cpp index 3efd207..4e16a34 100644 --- a/DirectXTex/DirectXTexImage.cpp +++ b/DirectXTex/DirectXTexImage.cpp @@ -13,9 +13,9 @@ namespace DirectX { - extern bool _CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels); - extern bool _CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels); - extern bool _IsAlphaAllOpaqueBC(_In_ const Image& cImage); + extern bool _CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels) noexcept; + extern bool _CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels) noexcept; + extern bool _IsAlphaAllOpaqueBC(_In_ const Image& cImage) noexcept; } using namespace DirectX; @@ -28,7 +28,7 @@ bool DirectX::_DetermineImageArray( const TexMetadata& metadata, DWORD cpFlags, size_t& nImages, - size_t& pixelSize) + size_t& pixelSize) noexcept { assert(metadata.width > 0 && metadata.height > 0 && metadata.depth > 0); assert(metadata.arraySize > 0); @@ -133,7 +133,7 @@ bool DirectX::_SetupImageArray( const TexMetadata& metadata, DWORD cpFlags, Image* images, - size_t nImages) + size_t nImages) noexcept { assert(pMemory); assert(pixelSize > 0); @@ -282,7 +282,7 @@ ScratchImage& ScratchImage::operator= (ScratchImage&& moveFrom) noexcept // Methods //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT ScratchImage::Initialize(const TexMetadata& mdata, DWORD flags) +HRESULT ScratchImage::Initialize(const TexMetadata& mdata, DWORD flags) noexcept { if (!IsValid(mdata.format)) return E_INVALIDARG; @@ -368,7 +368,7 @@ HRESULT ScratchImage::Initialize(const TexMetadata& mdata, DWORD flags) } _Use_decl_annotations_ -HRESULT ScratchImage::Initialize1D(DXGI_FORMAT fmt, size_t length, size_t arraySize, size_t mipLevels, DWORD flags) +HRESULT ScratchImage::Initialize1D(DXGI_FORMAT fmt, size_t length, size_t arraySize, size_t mipLevels, DWORD flags) noexcept { if (!length || !arraySize) return E_INVALIDARG; @@ -384,7 +384,7 @@ HRESULT ScratchImage::Initialize1D(DXGI_FORMAT fmt, size_t length, size_t arrayS } _Use_decl_annotations_ -HRESULT ScratchImage::Initialize2D(DXGI_FORMAT fmt, size_t width, size_t height, size_t arraySize, size_t mipLevels, DWORD flags) +HRESULT ScratchImage::Initialize2D(DXGI_FORMAT fmt, size_t width, size_t height, size_t arraySize, size_t mipLevels, DWORD flags) noexcept { if (!IsValid(fmt) || !width || !height || !arraySize) return E_INVALIDARG; @@ -435,7 +435,7 @@ HRESULT ScratchImage::Initialize2D(DXGI_FORMAT fmt, size_t width, size_t height, } _Use_decl_annotations_ -HRESULT ScratchImage::Initialize3D(DXGI_FORMAT fmt, size_t width, size_t height, size_t depth, size_t mipLevels, DWORD flags) +HRESULT ScratchImage::Initialize3D(DXGI_FORMAT fmt, size_t width, size_t height, size_t depth, size_t mipLevels, DWORD flags) noexcept { if (!IsValid(fmt) || !width || !height || !depth) return E_INVALIDARG; @@ -489,7 +489,7 @@ HRESULT ScratchImage::Initialize3D(DXGI_FORMAT fmt, size_t width, size_t height, } _Use_decl_annotations_ -HRESULT ScratchImage::InitializeCube(DXGI_FORMAT fmt, size_t width, size_t height, size_t nCubes, size_t mipLevels, DWORD flags) +HRESULT ScratchImage::InitializeCube(DXGI_FORMAT fmt, size_t width, size_t height, size_t nCubes, size_t mipLevels, DWORD flags) noexcept { if (!width || !height || !nCubes) return E_INVALIDARG; @@ -505,7 +505,7 @@ HRESULT ScratchImage::InitializeCube(DXGI_FORMAT fmt, size_t width, size_t heigh } _Use_decl_annotations_ -HRESULT ScratchImage::InitializeFromImage(const Image& srcImage, bool allow1D, DWORD flags) +HRESULT ScratchImage::InitializeFromImage(const Image& srcImage, bool allow1D, DWORD flags) noexcept { HRESULT hr = (srcImage.height > 1 || !allow1D) ? Initialize2D(srcImage.format, srcImage.width, srcImage.height, 1, 1, flags) @@ -542,7 +542,7 @@ HRESULT ScratchImage::InitializeFromImage(const Image& srcImage, bool allow1D, D } _Use_decl_annotations_ -HRESULT ScratchImage::InitializeArrayFromImages(const Image* images, size_t nImages, bool allow1D, DWORD flags) +HRESULT ScratchImage::InitializeArrayFromImages(const Image* images, size_t nImages, bool allow1D, DWORD flags) noexcept { if (!images || !nImages) return E_INVALIDARG; @@ -602,7 +602,7 @@ HRESULT ScratchImage::InitializeArrayFromImages(const Image* images, size_t nIma } _Use_decl_annotations_ -HRESULT ScratchImage::InitializeCubeFromImages(const Image* images, size_t nImages, DWORD flags) +HRESULT ScratchImage::InitializeCubeFromImages(const Image* images, size_t nImages, DWORD flags) noexcept { if (!images || !nImages) return E_INVALIDARG; @@ -621,7 +621,7 @@ HRESULT ScratchImage::InitializeCubeFromImages(const Image* images, size_t nImag } _Use_decl_annotations_ -HRESULT ScratchImage::Initialize3DFromImages(const Image* images, size_t depth, DWORD flags) +HRESULT ScratchImage::Initialize3DFromImages(const Image* images, size_t depth, DWORD flags) noexcept { if (!images || !depth) return E_INVALIDARG; @@ -698,7 +698,7 @@ void ScratchImage::Release() noexcept } _Use_decl_annotations_ -bool ScratchImage::OverrideFormat(DXGI_FORMAT f) +bool ScratchImage::OverrideFormat(DXGI_FORMAT f) noexcept { if (!m_image) return false; @@ -717,7 +717,7 @@ bool ScratchImage::OverrideFormat(DXGI_FORMAT f) } _Use_decl_annotations_ -const Image* ScratchImage::GetImage(size_t mip, size_t item, size_t slice) const +const Image* ScratchImage::GetImage(size_t mip, size_t item, size_t slice) const noexcept { if (mip >= m_metadata.mipLevels) return nullptr; diff --git a/DirectXTex/DirectXTexMipmaps.cpp b/DirectXTex/DirectXTexMipmaps.cpp index 650993c..5e68d4c 100644 --- a/DirectXTex/DirectXTexMipmaps.cpp +++ b/DirectXTex/DirectXTexMipmaps.cpp @@ -18,13 +18,13 @@ using Microsoft::WRL::ComPtr; namespace { - inline bool ispow2(_In_ size_t x) + inline bool ispow2(_In_ size_t x) noexcept { return ((x != 0) && !(x & (x - 1))); } - size_t CountMips(_In_ size_t width, _In_ size_t height) + size_t CountMips(_In_ size_t width, _In_ size_t height) noexcept { size_t mipLevels = 1; @@ -43,7 +43,7 @@ namespace } - size_t CountMips3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth) + size_t CountMips3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth) noexcept { size_t mipLevels = 1; @@ -70,7 +70,7 @@ namespace _In_ IWICBitmap* src, _In_ DWORD filter, _In_ const WICPixelFormatGUID& desiredPixelFormat, - _Deref_out_ IWICBitmap** dest) + _Deref_out_ IWICBitmap** dest) noexcept { if (!pWIC || !src || !dest) return E_POINTER; @@ -137,7 +137,7 @@ namespace HRESULT ScaleAlpha( const Image& srcImage, float alphaScale, - const Image& destImage) + const Image& destImage) noexcept { assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); @@ -187,7 +187,7 @@ namespace void GenerateAlphaCoverageConvolutionVectors( _In_ size_t N, - _Out_writes_(N*N) XMVECTOR* vectors) + _Out_writes_(N*N) XMVECTOR* vectors) noexcept { for (size_t sy = 0; sy < N; ++sy) { @@ -210,7 +210,7 @@ namespace const Image& srcImage, float alphaReference, float alphaScale, - float& coverage) + float& coverage) noexcept { coverage = 0.0f; @@ -299,7 +299,7 @@ namespace const Image& srcImage, float alphaReference, float targetCoverage, - float& alphaScale) + float& alphaScale) noexcept { float minAlphaScale = 0.0f; float maxAlphaScale = 4.0f; @@ -348,15 +348,15 @@ namespace namespace DirectX { - bool _CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels); - bool _CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels); + bool _CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels) noexcept; + bool _CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels) noexcept; // Also used by Compress HRESULT _ResizeSeparateColorAndAlpha(_In_ IWICImagingFactory* pWIC, _In_ bool iswic2, _In_ IWICBitmap* original, - _In_ size_t newWidth, _In_ size_t newHeight, _In_ DWORD filter, _Inout_ const Image* img); + _In_ size_t newWidth, _In_ size_t newHeight, _In_ DWORD filter, _Inout_ const Image* img) noexcept; // Also used by Resize - bool _CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels) + bool _CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels) noexcept { if (mipLevels > 1) { @@ -375,7 +375,7 @@ namespace DirectX return true; } - bool _CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels) + bool _CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels) noexcept { if (mipLevels > 1) { @@ -403,7 +403,7 @@ namespace DirectX size_t newWidth, size_t newHeight, DWORD filter, - const Image* img) + const Image* img) noexcept { if (!pWIC || !original || !img) return E_POINTER; @@ -615,7 +615,7 @@ namespace DirectX namespace { //--- determine when to use WIC vs. non-WIC paths --- - bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ DWORD filter) + bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ DWORD filter) noexcept { if (filter & TEX_FILTER_FORCE_NON_WIC) { @@ -692,7 +692,7 @@ namespace _In_ size_t levels, _In_ const WICPixelFormatGUID& pfGUID, _In_ const ScratchImage& mipChain, - _In_ size_t item) + _In_ size_t item) noexcept { assert(levels > 1); @@ -834,7 +834,7 @@ namespace _In_reads_(nimages) const Image* baseImages, _In_ size_t nimages, _In_ const TexMetadata& mdata, - _Out_ ScratchImage& mipChain) + _Out_ ScratchImage& mipChain) noexcept { if (!baseImages || !nimages) return E_INVALIDARG; @@ -886,7 +886,7 @@ namespace } //--- 2D Point Filter --- - HRESULT Generate2DMipsPointFilter(size_t levels, const ScratchImage& mipChain, size_t item) + HRESULT Generate2DMipsPointFilter(size_t levels, const ScratchImage& mipChain, size_t item) noexcept { if (!mipChain.GetImages()) return E_INVALIDARG; @@ -970,7 +970,7 @@ namespace //--- 2D Box Filter --- - HRESULT Generate2DMipsBoxFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) + HRESULT Generate2DMipsBoxFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) noexcept { if (!mipChain.GetImages()) return E_INVALIDARG; @@ -1064,7 +1064,7 @@ namespace //--- 2D Linear Filter --- - HRESULT Generate2DMipsLinearFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) + HRESULT Generate2DMipsLinearFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) noexcept { if (!mipChain.GetImages()) return E_INVALIDARG; @@ -1175,7 +1175,7 @@ namespace } //--- 2D Cubic Filter --- - HRESULT Generate2DMipsCubicFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) + HRESULT Generate2DMipsCubicFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) noexcept { if (!mipChain.GetImages()) return E_INVALIDARG; @@ -1361,7 +1361,7 @@ namespace //--- 2D Triangle Filter --- - HRESULT Generate2DMipsTriangleFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) + HRESULT Generate2DMipsTriangleFilter(size_t levels, DWORD filter, const ScratchImage& mipChain, size_t item) noexcept { if (!mipChain.GetImages()) return E_INVALIDARG; @@ -1580,7 +1580,7 @@ namespace _In_reads_(depth) const Image* baseImages, size_t depth, size_t levels, - _Out_ ScratchImage& mipChain) + _Out_ ScratchImage& mipChain) noexcept { if (!baseImages || !depth) return E_INVALIDARG; @@ -1631,7 +1631,7 @@ namespace //--- 3D Point Filter --- - HRESULT Generate3DMipsPointFilter(size_t depth, size_t levels, const ScratchImage& mipChain) + HRESULT Generate3DMipsPointFilter(size_t depth, size_t levels, const ScratchImage& mipChain) noexcept { if (!depth || !mipChain.GetImages()) return E_INVALIDARG; @@ -1777,7 +1777,7 @@ namespace //--- 3D Box Filter --- - HRESULT Generate3DMipsBoxFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) + HRESULT Generate3DMipsBoxFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) noexcept { if (!depth || !mipChain.GetImages()) return E_INVALIDARG; @@ -1949,7 +1949,7 @@ namespace //--- 3D Linear Filter --- - HRESULT Generate3DMipsLinearFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) + HRESULT Generate3DMipsLinearFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) noexcept { if (!depth || !mipChain.GetImages()) return E_INVALIDARG; @@ -2142,7 +2142,7 @@ namespace //--- 3D Cubic Filter --- - HRESULT Generate3DMipsCubicFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) + HRESULT Generate3DMipsCubicFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) noexcept { if (!depth || !mipChain.GetImages()) return E_INVALIDARG; @@ -2521,7 +2521,7 @@ namespace //--- 3D Triangle Filter --- - HRESULT Generate3DMipsTriangleFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) + HRESULT Generate3DMipsTriangleFilter(size_t depth, size_t levels, DWORD filter, const ScratchImage& mipChain) noexcept { if (!depth || !mipChain.GetImages()) return E_INVALIDARG; @@ -2777,7 +2777,7 @@ HRESULT DirectX::GenerateMipMaps( DWORD filter, size_t levels, ScratchImage& mipChain, - bool allow1D) + bool allow1D) noexcept { if (!IsValid(baseImage.format)) return E_INVALIDARG; @@ -3199,7 +3199,7 @@ HRESULT DirectX::GenerateMipMaps3D( size_t depth, DWORD filter, size_t levels, - ScratchImage& mipChain) + ScratchImage& mipChain) noexcept { if (!baseImages || !depth) return E_INVALIDARG; @@ -3423,7 +3423,7 @@ HRESULT DirectX::ScaleMipMapsAlphaForCoverage( const TexMetadata& metadata, size_t item, float alphaReference, - ScratchImage& mipChain) + ScratchImage& mipChain) noexcept { if (!srcImages || !nimages || !IsValid(metadata.format) || nimages > metadata.mipLevels || !mipChain.GetImages()) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexMisc.cpp b/DirectXTex/DirectXTexMisc.cpp index e5ddbba..051f0b5 100644 --- a/DirectXTex/DirectXTexMisc.cpp +++ b/DirectXTex/DirectXTexMisc.cpp @@ -23,7 +23,7 @@ namespace const Image& image2, float& mse, _Out_writes_opt_(4) float* mseV, - DWORD flags) + DWORD flags) noexcept { if (!image1.pixels || !image2.pixels) return E_POINTER; @@ -384,7 +384,7 @@ HRESULT DirectX::ComputeMSE( const Image& image2, float& mse, float* mseV, - DWORD flags) + DWORD flags) noexcept { if (!image1.pixels || !image2.pixels) return E_POINTER; diff --git a/DirectXTex/DirectXTexNormalMaps.cpp b/DirectXTex/DirectXTexNormalMaps.cpp index 191db39..b41ea0d 100644 --- a/DirectXTex/DirectXTexNormalMaps.cpp +++ b/DirectXTex/DirectXTexNormalMaps.cpp @@ -17,7 +17,7 @@ namespace { #pragma prefast(suppress : 25000, "FXMVECTOR is 16 bytes") - inline float EvaluateColor(_In_ FXMVECTOR val, _In_ DWORD flags) + inline float EvaluateColor(_In_ FXMVECTOR val, _In_ DWORD flags) noexcept { XMFLOAT4A f; @@ -49,7 +49,7 @@ namespace _In_reads_(width) const XMVECTOR* pSource, _Out_writes_(width + 2) float* pDest, size_t width, - DWORD flags) + DWORD flags) noexcept { assert(pSource && pDest); assert(width > 0); @@ -74,7 +74,7 @@ namespace } HRESULT ComputeNMap(_In_ const Image& srcImage, _In_ DWORD flags, _In_ float amplitude, - _In_ DXGI_FORMAT format, _In_ const Image& normalMap) + _In_ DXGI_FORMAT format, _In_ const Image& normalMap) noexcept { if (!srcImage.pixels || !normalMap.pixels) return E_INVALIDARG; @@ -258,7 +258,7 @@ HRESULT DirectX::ComputeNormalMap( DWORD flags, float amplitude, DXGI_FORMAT format, - ScratchImage& normalMap) + ScratchImage& normalMap) noexcept { if (!srcImage.pixels || !IsValid(format)) return E_INVALIDARG; @@ -316,7 +316,7 @@ HRESULT DirectX::ComputeNormalMap( DWORD flags, float amplitude, DXGI_FORMAT format, - ScratchImage& normalMaps) + ScratchImage& normalMaps) noexcept { if (!srcImages || !nimages || !IsValid(format)) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexP.h b/DirectXTex/DirectXTexP.h index cbaaaa2..996f428 100644 --- a/DirectXTex/DirectXTexP.h +++ b/DirectXTex/DirectXTexP.h @@ -147,12 +147,12 @@ namespace DirectX { //--------------------------------------------------------------------------------- // WIC helper functions - DXGI_FORMAT __cdecl _WICToDXGI(_In_ const GUID& guid); - bool __cdecl _DXGIToWIC(_In_ DXGI_FORMAT format, _Out_ GUID& guid, _In_ bool ignoreRGBvsBGR = false); + DXGI_FORMAT __cdecl _WICToDXGI(_In_ const GUID& guid) noexcept; + bool __cdecl _DXGIToWIC(_In_ DXGI_FORMAT format, _Out_ GUID& guid, _In_ bool ignoreRGBvsBGR = false) noexcept; - DWORD __cdecl _CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID& targetGUID); + DWORD __cdecl _CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID& targetGUID) noexcept; - inline WICBitmapDitherType __cdecl _GetWICDither(_In_ DWORD flags) + inline WICBitmapDitherType __cdecl _GetWICDither(_In_ DWORD flags) noexcept { static_assert(TEX_FILTER_DITHER == 0x10000, "TEX_FILTER_DITHER* flag values don't match mask"); @@ -172,7 +172,7 @@ namespace DirectX } } - inline WICBitmapInterpolationMode __cdecl _GetWICInterp(_In_ DWORD flags) + inline WICBitmapInterpolationMode __cdecl _GetWICInterp(_In_ DWORD flags) noexcept { static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK"); @@ -202,12 +202,12 @@ namespace DirectX // Image helper functions _Success_(return != false) bool __cdecl _DetermineImageArray( _In_ const TexMetadata& metadata, _In_ DWORD cpFlags, - _Out_ size_t& nImages, _Out_ size_t& pixelSize); + _Out_ size_t& nImages, _Out_ size_t& pixelSize) noexcept; _Success_(return != false) bool __cdecl _SetupImageArray( _In_reads_bytes_(pixelSize) uint8_t *pMemory, _In_ size_t pixelSize, _In_ const TexMetadata& metadata, _In_ DWORD cpFlags, - _Out_writes_(nImages) Image* images, _In_ size_t nImages); + _Out_writes_(nImages) Image* images, _In_ size_t nImages) noexcept; //--------------------------------------------------------------------------------- // Conversion helper functions @@ -243,60 +243,60 @@ namespace DirectX CONVF_RGBA_MASK = 0xF0000, }; - DWORD __cdecl _GetConvertFlags(_In_ DXGI_FORMAT format); + DWORD __cdecl _GetConvertFlags(_In_ DXGI_FORMAT format) noexcept; void __cdecl _CopyScanline( _When_(pDestination == pSource, _Inout_updates_bytes_(outSize)) _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) void* pDestination, _In_ size_t outSize, _In_reads_bytes_(inSize) const void* pSource, _In_ size_t inSize, - _In_ DXGI_FORMAT format, _In_ DWORD flags); + _In_ DXGI_FORMAT format, _In_ DWORD flags) noexcept; void __cdecl _SwizzleScanline( _When_(pDestination == pSource, _In_) _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) void* pDestination, _In_ size_t outSize, _In_reads_bytes_(inSize) const void* pSource, _In_ size_t inSize, - _In_ DXGI_FORMAT format, _In_ DWORD flags); + _In_ DXGI_FORMAT format, _In_ DWORD flags) noexcept; _Success_(return != false) bool __cdecl _ExpandScanline( _Out_writes_bytes_(outSize) void* pDestination, _In_ size_t outSize, _In_ DXGI_FORMAT outFormat, _In_reads_bytes_(inSize) const void* pSource, _In_ size_t inSize, - _In_ DXGI_FORMAT inFormat, _In_ DWORD flags); + _In_ DXGI_FORMAT inFormat, _In_ DWORD flags) noexcept; _Success_(return != false) bool __cdecl _LoadScanline( _Out_writes_(count) XMVECTOR* pDestination, _In_ size_t count, - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ DXGI_FORMAT format); + _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ DXGI_FORMAT format) noexcept; _Success_(return != false) bool __cdecl _LoadScanlineLinear( _Out_writes_(count) XMVECTOR* pDestination, _In_ size_t count, - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ DXGI_FORMAT format, _In_ DWORD flags); + _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ DXGI_FORMAT format, _In_ DWORD flags) noexcept; _Success_(return != false) bool __cdecl _StoreScanline( _Out_writes_bytes_(size) void* pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, - _In_reads_(count) const XMVECTOR* pSource, _In_ size_t count, _In_ float threshold = 0); + _In_reads_(count) const XMVECTOR* pSource, _In_ size_t count, _In_ float threshold = 0) noexcept; _Success_(return != false) bool __cdecl _StoreScanlineLinear( _Out_writes_bytes_(size) void* pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, - _Inout_updates_all_(count) XMVECTOR* pSource, _In_ size_t count, _In_ DWORD flags, _In_ float threshold = 0); + _Inout_updates_all_(count) XMVECTOR* pSource, _In_ size_t count, _In_ DWORD flags, _In_ float threshold = 0) noexcept; _Success_(return != false) bool __cdecl _StoreScanlineDither( _Out_writes_bytes_(size) void* pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, _Inout_updates_all_(count) XMVECTOR* pSource, _In_ size_t count, _In_ float threshold, size_t y, size_t z, - _Inout_updates_all_opt_(count + 2) XMVECTOR* pDiffusionErrors); + _Inout_updates_all_opt_(count + 2) XMVECTOR* pDiffusionErrors) noexcept; - HRESULT __cdecl _ConvertToR32G32B32A32(_In_ const Image& srcImage, _Inout_ ScratchImage& image); + HRESULT __cdecl _ConvertToR32G32B32A32(_In_ const Image& srcImage, _Inout_ ScratchImage& image) noexcept; - HRESULT __cdecl _ConvertFromR32G32B32A32(_In_ const Image& srcImage, _In_ const Image& destImage); - HRESULT __cdecl _ConvertFromR32G32B32A32(_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _Inout_ ScratchImage& image); + HRESULT __cdecl _ConvertFromR32G32B32A32(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept; + HRESULT __cdecl _ConvertFromR32G32B32A32(_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _Inout_ ScratchImage& image) noexcept; HRESULT __cdecl _ConvertFromR32G32B32A32( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _Out_ ScratchImage& result); + _In_ DXGI_FORMAT format, _Out_ ScratchImage& result) noexcept; - HRESULT __cdecl _ConvertToR16G16B16A16(_In_ const Image& srcImage, _Inout_ ScratchImage& image); + HRESULT __cdecl _ConvertToR16G16B16A16(_In_ const Image& srcImage, _Inout_ ScratchImage& image) noexcept; - HRESULT __cdecl _ConvertFromR16G16B16A16(_In_ const Image& srcImage, _In_ const Image& destImage); + HRESULT __cdecl _ConvertFromR16G16B16A16(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept; void __cdecl _ConvertScanline( _Inout_updates_all_(count) XMVECTOR* pBuffer, _In_ size_t count, @@ -306,6 +306,6 @@ namespace DirectX // DDS helper functions HRESULT __cdecl _EncodeDDSHeader( _In_ const TexMetadata& metadata, DWORD flags, - _Out_writes_bytes_to_opt_(maxsize, required) void* pDestination, _In_ size_t maxsize, _Out_ size_t& required); + _Out_writes_bytes_to_opt_(maxsize, required) void* pDestination, _In_ size_t maxsize, _Out_ size_t& required) noexcept; } // namespace diff --git a/DirectXTex/DirectXTexPMAlpha.cpp b/DirectXTex/DirectXTexPMAlpha.cpp index aaafe11..fd7df1e 100644 --- a/DirectXTex/DirectXTexPMAlpha.cpp +++ b/DirectXTex/DirectXTexPMAlpha.cpp @@ -17,7 +17,7 @@ namespace { //--------------------------------------------------------------------------------- // NonPremultiplied alpha -> Premultiplied alpha - HRESULT PremultiplyAlpha_(const Image& srcImage, const Image& destImage) + HRESULT PremultiplyAlpha_(const Image& srcImage, const Image& destImage) noexcept { assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); @@ -55,7 +55,7 @@ namespace return S_OK; } - HRESULT PremultiplyAlphaLinear(const Image& srcImage, DWORD flags, const Image& destImage) + HRESULT PremultiplyAlphaLinear(const Image& srcImage, DWORD flags, const Image& destImage) noexcept { assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); @@ -100,7 +100,7 @@ namespace //--------------------------------------------------------------------------------- // Premultiplied alpha -> NonPremultiplied alpha (a.k.a. Straight alpha) - HRESULT DemultiplyAlpha(const Image& srcImage, const Image& destImage) + HRESULT DemultiplyAlpha(const Image& srcImage, const Image& destImage) noexcept { assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); @@ -138,7 +138,7 @@ namespace return S_OK; } - HRESULT DemultiplyAlphaLinear(const Image& srcImage, DWORD flags, const Image& destImage) + HRESULT DemultiplyAlphaLinear(const Image& srcImage, DWORD flags, const Image& destImage) noexcept { assert(srcImage.width == destImage.width); assert(srcImage.height == destImage.height); @@ -194,7 +194,7 @@ _Use_decl_annotations_ HRESULT DirectX::PremultiplyAlpha( const Image& srcImage, DWORD flags, - ScratchImage& image) + ScratchImage& image) noexcept { if (!srcImage.pixels) return E_POINTER; @@ -247,7 +247,7 @@ HRESULT DirectX::PremultiplyAlpha( size_t nimages, const TexMetadata& metadata, DWORD flags, - ScratchImage& result) + ScratchImage& result) noexcept { if (!srcImages || !nimages) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexResize.cpp b/DirectXTex/DirectXTexResize.cpp index b7c2df5..c3208d4 100644 --- a/DirectXTex/DirectXTexResize.cpp +++ b/DirectXTex/DirectXTexResize.cpp @@ -19,7 +19,7 @@ using Microsoft::WRL::ComPtr; namespace DirectX { extern HRESULT _ResizeSeparateColorAndAlpha(_In_ IWICImagingFactory* pWIC, _In_ bool iswic2, _In_ IWICBitmap* original, - _In_ size_t newWidth, _In_ size_t newHeight, _In_ DWORD filter, _Inout_ const Image* img); + _In_ size_t newWidth, _In_ size_t newHeight, _In_ DWORD filter, _Inout_ const Image* img) noexcept; } namespace @@ -29,7 +29,7 @@ namespace const Image& srcImage, DWORD filter, const WICPixelFormatGUID& pfGUID, - const Image& destImage) + const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; @@ -129,7 +129,7 @@ namespace HRESULT PerformResizeViaF32( const Image& srcImage, DWORD filter, - const Image& destImage) + const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; @@ -170,7 +170,7 @@ namespace //--- determine when to use WIC vs. non-WIC paths --- - bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ DWORD filter) + bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ DWORD filter) noexcept { if (filter & TEX_FILTER_FORCE_NON_WIC) { @@ -245,7 +245,7 @@ namespace //------------------------------------------------------------------------------------- //--- Point Filter --- - HRESULT ResizePointFilter(const Image& srcImage, const Image& destImage) + HRESULT ResizePointFilter(const Image& srcImage, const Image& destImage) noexcept { assert(srcImage.pixels && destImage.pixels); assert(srcImage.format == destImage.format); @@ -303,7 +303,7 @@ namespace //--- Box Filter --- - HRESULT ResizeBoxFilter(const Image& srcImage, DWORD filter, const Image& destImage) + HRESULT ResizeBoxFilter(const Image& srcImage, DWORD filter, const Image& destImage) noexcept { assert(srcImage.pixels && destImage.pixels); assert(srcImage.format == destImage.format); @@ -365,7 +365,7 @@ namespace //--- Linear Filter --- - HRESULT ResizeLinearFilter(const Image& srcImage, DWORD filter, const Image& destImage) + HRESULT ResizeLinearFilter(const Image& srcImage, DWORD filter, const Image& destImage) noexcept { assert(srcImage.pixels && destImage.pixels); assert(srcImage.format == destImage.format); @@ -451,7 +451,7 @@ namespace //--- Cubic Filter --- - HRESULT ResizeCubicFilter(const Image& srcImage, DWORD filter, const Image& destImage) + HRESULT ResizeCubicFilter(const Image& srcImage, DWORD filter, const Image& destImage) noexcept { assert(srcImage.pixels && destImage.pixels); assert(srcImage.format == destImage.format); @@ -611,7 +611,7 @@ namespace //--- Triangle Filter --- - HRESULT ResizeTriangleFilter(const Image& srcImage, DWORD filter, const Image& destImage) + HRESULT ResizeTriangleFilter(const Image& srcImage, DWORD filter, const Image& destImage) noexcept { assert(srcImage.pixels && destImage.pixels); assert(srcImage.format == destImage.format); @@ -790,7 +790,7 @@ namespace //--- Custom filter resize --- - HRESULT PerformResizeUsingCustomFilters(const Image& srcImage, DWORD filter, const Image& destImage) + HRESULT PerformResizeUsingCustomFilters(const Image& srcImage, DWORD filter, const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; @@ -842,7 +842,7 @@ HRESULT DirectX::Resize( size_t width, size_t height, DWORD filter, - ScratchImage& image) + ScratchImage& image) noexcept { if (width == 0 || height == 0) return E_INVALIDARG; @@ -929,7 +929,7 @@ HRESULT DirectX::Resize( size_t width, size_t height, DWORD filter, - ScratchImage& result) + ScratchImage& result) noexcept { if (!srcImages || !nimages || width == 0 || height == 0) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexTGA.cpp b/DirectXTex/DirectXTexTGA.cpp index c0e02c8..34ee5be 100644 --- a/DirectXTex/DirectXTexTGA.cpp +++ b/DirectXTex/DirectXTexTGA.cpp @@ -136,7 +136,7 @@ namespace size_t size, _Out_ TexMetadata& metadata, size_t& offset, - _Inout_opt_ DWORD* convFlags) + _Inout_opt_ DWORD* convFlags) noexcept { if (!pSource) return E_INVALIDARG; @@ -251,7 +251,7 @@ namespace //------------------------------------------------------------------------------------- // Set alpha for images with all 0 alpha channel //------------------------------------------------------------------------------------- - HRESULT SetAlphaChannelToOpaque(_In_ const Image* image) + HRESULT SetAlphaChannelToOpaque(_In_ const Image* image) noexcept { assert(image); @@ -276,7 +276,7 @@ namespace _In_reads_bytes_(size) const void* pSource, size_t size, _In_ const Image* image, - _In_ DWORD convFlags) + _In_ DWORD convFlags) noexcept { assert(pSource && size > 0); @@ -626,7 +626,7 @@ namespace _In_reads_bytes_(size) const void* pSource, size_t size, _In_ const Image* image, - _In_ DWORD convFlags) + _In_ DWORD convFlags) noexcept { assert(pSource && size > 0); @@ -810,7 +810,7 @@ namespace //------------------------------------------------------------------------------------- // Encodes TGA file header //------------------------------------------------------------------------------------- - HRESULT EncodeTGAHeader(_In_ const Image& image, _Out_ TGA_HEADER& header, _Inout_ DWORD& convFlags) + HRESULT EncodeTGAHeader(_In_ const Image& image, _Out_ TGA_HEADER& header, _Inout_ DWORD& convFlags) noexcept { memset(&header, 0, sizeof(TGA_HEADER)); @@ -877,7 +877,7 @@ namespace _Out_writes_bytes_(outSize) void* pDestination, _In_ size_t outSize, _In_reads_bytes_(inSize) const void* pSource, - _In_ size_t inSize) + _In_ size_t inSize) noexcept { assert(pDestination && outSize > 0); assert(pSource && inSize > 0); @@ -908,7 +908,7 @@ namespace //------------------------------------------------------------------------------------- // TGA 2.0 Extension helpers //------------------------------------------------------------------------------------- - void SetExtension(TGA_EXTENSION *ext, const TexMetadata& metadata) + void SetExtension(TGA_EXTENSION *ext, const TexMetadata& metadata) noexcept { memset(ext, 0, sizeof(TGA_EXTENSION)); @@ -965,7 +965,7 @@ namespace } } - TEX_ALPHA_MODE GetAlphaModeFromExtension(const TGA_EXTENSION *ext) + TEX_ALPHA_MODE GetAlphaModeFromExtension(const TGA_EXTENSION *ext) noexcept { if (ext && ext->wSize == sizeof(TGA_EXTENSION)) { @@ -994,7 +994,7 @@ _Use_decl_annotations_ HRESULT DirectX::GetMetadataFromTGAMemory( const void* pSource, size_t size, - TexMetadata& metadata) + TexMetadata& metadata) noexcept { if (!pSource || size == 0) return E_INVALIDARG; @@ -1004,7 +1004,7 @@ HRESULT DirectX::GetMetadataFromTGAMemory( } _Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TexMetadata& metadata) +HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TexMetadata& metadata) noexcept { if (!szFile) return E_INVALIDARG; @@ -1060,7 +1060,7 @@ HRESULT DirectX::LoadFromTGAMemory( const void* pSource, size_t size, TexMetadata* metadata, - ScratchImage& image) + ScratchImage& image) noexcept { if (!pSource || size == 0) return E_INVALIDARG; @@ -1137,7 +1137,7 @@ _Use_decl_annotations_ HRESULT DirectX::LoadFromTGAFile( const wchar_t* szFile, TexMetadata* metadata, - ScratchImage& image) + ScratchImage& image) noexcept { if (!szFile) return E_INVALIDARG; @@ -1465,7 +1465,7 @@ HRESULT DirectX::LoadFromTGAFile( // Save a TGA file to memory //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::SaveToTGAMemory(const Image& image, Blob& blob, const TexMetadata* metadata) +HRESULT DirectX::SaveToTGAMemory(const Image& image, Blob& blob, const TexMetadata* metadata) noexcept { if (!image.pixels) return E_POINTER; @@ -1556,7 +1556,7 @@ HRESULT DirectX::SaveToTGAMemory(const Image& image, Blob& blob, const TexMetada // Save a TGA file to disk //------------------------------------------------------------------------------------- _Use_decl_annotations_ -HRESULT DirectX::SaveToTGAFile(const Image& image, const wchar_t* szFile, const TexMetadata* metadata) +HRESULT DirectX::SaveToTGAFile(const Image& image, const wchar_t* szFile, const TexMetadata* metadata) noexcept { if (!szFile) return E_INVALIDARG; diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index b110135..fbd53f7 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -121,7 +121,7 @@ namespace //===================================================================================== _Use_decl_annotations_ -DXGI_FORMAT DirectX::_WICToDXGI(const GUID& guid) +DXGI_FORMAT DirectX::_WICToDXGI(const GUID& guid) noexcept { for (size_t i = 0; i < _countof(g_WICFormats); ++i) { @@ -141,7 +141,7 @@ DXGI_FORMAT DirectX::_WICToDXGI(const GUID& guid) } _Use_decl_annotations_ -bool DirectX::_DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR) +bool DirectX::_DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR) noexcept { switch (format) { @@ -201,7 +201,7 @@ bool DirectX::_DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR) return false; } -DWORD DirectX::_CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID& targetGUID) +DWORD DirectX::_CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID& targetGUID) noexcept { DWORD srgb = 0; diff --git a/DirectXTex/DirectXTexWIC.cpp b/DirectXTex/DirectXTexWIC.cpp index 5c3b801..4d38d12 100644 --- a/DirectXTex/DirectXTexWIC.cpp +++ b/DirectXTex/DirectXTexWIC.cpp @@ -60,7 +60,7 @@ #else #pragma prefast(suppress:6387 28196, "a simple wrapper around an existing annotated function" ); - static inline HRESULT CreateMemoryStream(_Outptr_ IStream** stream) + static inline HRESULT CreateMemoryStream(_Outptr_ IStream** stream) noexcept { return CreateStreamOnHGlobal(nullptr, TRUE, stream); } @@ -150,7 +150,7 @@ namespace DWORD flags, bool iswic2, _Out_opt_ WICPixelFormatGUID* pConvert, - _Out_ TEX_ALPHA_MODE* alphaMode) + _Out_ TEX_ALPHA_MODE* alphaMode) noexcept { if (pConvert) memset(pConvert, 0, sizeof(WICPixelFormatGUID)); diff --git a/DirectXTex/filters.h b/DirectXTex/filters.h index 43667a8..c457c43 100644 --- a/DirectXTex/filters.h +++ b/DirectXTex/filters.h @@ -59,7 +59,7 @@ struct LinearFilter float weight1; }; -inline void _CreateLinearFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _Out_writes_(dest) LinearFilter* lf) +inline void _CreateLinearFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _Out_writes_(dest) LinearFilter* lf) noexcept { assert(source > 0); assert(dest > 0); @@ -118,7 +118,7 @@ XMGLOBALCONST XMVECTORF32 g_cubicThird = { { { 1.f / 3.f, 1.f / 3.f, 1.f / 3.f, XMGLOBALCONST XMVECTORF32 g_cubicSixth = { { { 1.f / 6.f, 1.f / 6.f, 1.f / 6.f, 1.f / 6.f } } }; XMGLOBALCONST XMVECTORF32 g_cubicHalf = { { { 1.f / 2.f, 1.f / 2.f, 1.f / 2.f, 1.f / 2.f } } }; -inline ptrdiff_t bounduvw(ptrdiff_t u, ptrdiff_t maxu, bool wrap, bool mirror) +inline ptrdiff_t bounduvw(ptrdiff_t u, ptrdiff_t maxu, bool wrap, bool mirror) noexcept { if (wrap) { @@ -159,7 +159,7 @@ struct CubicFilter float x; }; -inline void _CreateCubicFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _In_ bool mirror, _Out_writes_(dest) CubicFilter* cf) +inline void _CreateCubicFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _In_ bool mirror, _Out_writes_(dest) CubicFilter* cf) noexcept { assert(source > 0); assert(dest > 0); @@ -246,7 +246,7 @@ namespace TriangleFilter static const float TF_EPSILON = 0.00001f; - inline HRESULT _Create(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _Inout_ std::unique_ptr& tf) + inline HRESULT _Create(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _Inout_ std::unique_ptr& tf) noexcept { assert(source > 0); assert(dest > 0); diff --git a/DirectXTex/scoped.h b/DirectXTex/scoped.h index 548e2fd..3b9d566 100644 --- a/DirectXTex/scoped.h +++ b/DirectXTex/scoped.h @@ -14,21 +14,21 @@ #include //--------------------------------------------------------------------------------- -struct aligned_deleter { void operator()(void* p) { _aligned_free(p); } }; +struct aligned_deleter { void operator()(void* p) noexcept { _aligned_free(p); } }; typedef std::unique_ptr ScopedAlignedArrayFloat; typedef std::unique_ptr ScopedAlignedArrayXMVECTOR; //--------------------------------------------------------------------------------- -struct handle_closer { void operator()(HANDLE h) { 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); } }; typedef std::unique_ptr ScopedHandle; -inline HANDLE safe_handle(HANDLE h) { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } +inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } //--------------------------------------------------------------------------------- -struct find_closer { void operator()(HANDLE h) { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; +struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; typedef std::unique_ptr ScopedFindHandle; @@ -36,7 +36,7 @@ typedef std::unique_ptr ScopedFindHandle; class auto_delete_file { public: - auto_delete_file(HANDLE hFile) : m_handle(hFile) {} + auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} auto_delete_file(const auto_delete_file&) = delete; auto_delete_file& operator=(const auto_delete_file&) = delete; @@ -51,7 +51,7 @@ public: } } - void clear() { m_handle = nullptr; } + void clear() noexcept { m_handle = nullptr; } private: HANDLE m_handle;