diff --git a/DirectXTex/BC.h b/DirectXTex/BC.h index 300fc09..c386895 100644 --- a/DirectXTex/BC.h +++ b/DirectXTex/BC.h @@ -72,7 +72,7 @@ class LDRColorA public: uint8_t r, g, b, a; - LDRColorA() DIRECTX_CTOR_DEFAULT + LDRColorA() = default; LDRColorA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {} const uint8_t& operator [] (_In_range_(0,3) size_t uElement) const @@ -144,7 +144,7 @@ public: float r, g, b, a; public: - HDRColorA() DIRECTX_CTOR_DEFAULT + 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(const LDRColorA& c) @@ -308,7 +308,7 @@ public: int pad; public: - INTColor() DIRECTX_CTOR_DEFAULT + INTColor() = default; INTColor(int nr, int ng, int nb) {r = nr; g = ng; b = nb;} INTColor(const INTColor& c) {r = c.r; g = c.g; b = c.b;} diff --git a/DirectXTex/DDS.h b/DirectXTex/DDS.h index a963681..beca1b5 100644 --- a/DirectXTex/DDS.h +++ b/DirectXTex/DDS.h @@ -26,11 +26,7 @@ #include #endif -// VS 2010's stdint.h conflicts with intsafe.h -#pragma warning(push) -#pragma warning(disable : 4005) #include -#pragma warning(pop) namespace DirectX { diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h index 9eb2aa6..3b67d7e 100644 --- a/DirectXTex/DirectXTex.h +++ b/DirectXTex/DirectXTex.h @@ -19,11 +19,7 @@ #error WIC is not supported on Windows Phone 8.0 #endif -// VS 2010's stdint.h conflicts with intsafe.h -#pragma warning(push) -#pragma warning(disable : 4005) #include -#pragma warning(pop) #include #include @@ -37,26 +33,6 @@ #include -// VS 2010 doesn't support explicit calling convention for std::function -#ifndef DIRECTX_STD_CALLCONV -#if defined(_MSC_VER) && (_MSC_VER < 1700) -#define DIRECTX_STD_CALLCONV -#else -#define DIRECTX_STD_CALLCONV __cdecl -#endif -#endif - -// VS 2010/2012 do not support =default =delete -#ifndef DIRECTX_CTOR_DEFAULT -#if defined(_MSC_VER) && (_MSC_VER < 1800) -#define DIRECTX_CTOR_DEFAULT {} -#define DIRECTX_CTOR_DELETE ; -#else -#define DIRECTX_CTOR_DEFAULT =default; -#define DIRECTX_CTOR_DELETE =delete; -#endif -#endif - #define DIRECTX_TEX_VERSION 134 struct IWICImagingFactory; @@ -240,11 +216,11 @@ namespace DirectX HRESULT __cdecl GetMetadataFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, _Out_ TexMetadata& metadata, - _In_opt_ std::function getMQR = nullptr); + _In_opt_ std::function getMQR = nullptr); HRESULT __cdecl GetMetadataFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags, _Out_ TexMetadata& metadata, - _In_opt_ std::function getMQR = nullptr); + _In_opt_ std::function getMQR = nullptr); //--------------------------------------------------------------------------------- // Bitmap image container @@ -364,24 +340,24 @@ namespace DirectX // WIC operations HRESULT __cdecl LoadFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image, - _In_opt_ std::function getMQR = nullptr); + _In_opt_ std::function getMQR = nullptr); HRESULT __cdecl LoadFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image, - _In_opt_ std::function getMQR = nullptr); + _In_opt_ std::function getMQR = nullptr); HRESULT __cdecl SaveToWICMemory( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr ); + _In_opt_ std::function setCustomProps = nullptr ); HRESULT __cdecl SaveToWICMemory( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr ); + _In_opt_ std::function setCustomProps = nullptr ); HRESULT __cdecl SaveToWICFile( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _In_z_ LPCWSTR szFile, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr ); + _In_opt_ std::function setCustomProps = nullptr ); HRESULT __cdecl SaveToWICFile( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _In_z_ LPCWSTR szFile, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr ); + _In_opt_ std::function setCustomProps = nullptr ); //--------------------------------------------------------------------------------- // Texture conversion, resizing, mipmap generation, and block compression @@ -588,7 +564,7 @@ namespace DirectX size_t w; size_t h; - Rect() DIRECTX_CTOR_DEFAULT + Rect() = default; Rect( size_t _x, size_t _y, size_t _w, size_t _h ) : x(_x), y(_y), w(_w), h(_h) {} }; diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index e5d155f..3a14ee8 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -20,28 +20,6 @@ using Microsoft::WRL::ComPtr; namespace { -#if DIRECTX_MATH_VERSION < 306 - inline float round_to_nearest( float x ) - { - // Round to nearest (even) - float i = floorf(x); - x -= i; - if(x < 0.5f) - return i; - if(x > 0.5f) - return i + 1.f; - - float int_part; - modff( i / 2.f, &int_part ); - if ( (2.f*int_part) == i ) - { - return i; - } - - return i + 1.f; - } -#endif - inline uint32_t FloatTo7e3(float Value) { uint32_t IValue = reinterpret_cast(&Value)[0]; @@ -845,35 +823,7 @@ _Use_decl_annotations_ bool _LoadScanline( XMVECTOR* pDestination, size_t count, LOAD_SCANLINE( XMUDECN4, XMLoadUDecN4 ); case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: -#if DIRECTX_MATH_VERSION >= 306 LOAD_SCANLINE( XMUDECN4, XMLoadUDecN4_XR ); -#else - if ( size >= sizeof(XMUDECN4) ) - { - const XMUDECN4 * __restrict sPtr = reinterpret_cast(pSource); - for( size_t icount = 0; icount < ( size - sizeof(XMUDECN4) + 1 ); icount += sizeof(XMUDECN4) ) - { - if ( dPtr >= ePtr ) break; - - int32_t ElementX = sPtr->v & 0x3FF; - int32_t ElementY = (sPtr->v >> 10) & 0x3FF; - int32_t ElementZ = (sPtr->v >> 20) & 0x3FF; - - XMVECTORF32 vResult = { - (float)(ElementX - 0x180) / 510.0f, - (float)(ElementY - 0x180) / 510.0f, - (float)(ElementZ - 0x180) / 510.0f, - (float)(sPtr->v >> 30) / 3.0f - }; - - ++sPtr; - - *(dPtr++) = vResult.v; - } - return true; - } - return false; -#endif case DXGI_FORMAT_R10G10B10A2_UINT: LOAD_SCANLINE( XMUDEC4, XMLoadUDec4 ); @@ -1162,31 +1112,7 @@ _Use_decl_annotations_ bool _LoadScanline( XMVECTOR* pDestination, size_t count, return false; case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: -#if DIRECTX_MATH_VERSION >= 306 LOAD_SCANLINE3( XMFLOAT3SE, XMLoadFloat3SE, g_XMIdentityR3 ) -#else - if ( size >= sizeof(XMFLOAT3SE) ) - { - const XMFLOAT3SE * __restrict sPtr = reinterpret_cast(pSource); - for( size_t icount = 0; icount < ( size - sizeof(XMFLOAT3SE) + 1 ); icount += sizeof(XMFLOAT3SE) ) - { - union { float f; int32_t i; } fi; - fi.i = 0x33800000 + (sPtr->e << 23); - float Scale = fi.f; - - XMVECTORF32 v = { - Scale * float( sPtr->xm ), - Scale * float( sPtr->ym ), - Scale * float( sPtr->zm ), - 1.0f }; - - if ( dPtr >= ePtr ) break; - *(dPtr++) = v; - } - return true; - } - return false; -#endif case DXGI_FORMAT_R8G8_B8G8_UNORM: if ( size >= sizeof(XMUBYTEN4) ) @@ -1718,36 +1644,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, STORE_SCANLINE( XMUDECN4, XMStoreUDecN4 ); case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: -#if DIRECTX_MATH_VERSION >= 306 STORE_SCANLINE( XMUDECN4, XMStoreUDecN4_XR ); -#else - if ( size >= sizeof(XMUDECN4) ) - { - static const XMVECTORF32 Scale = { 510.0f, 510.0f, 510.0f, 3.0f }; - static const XMVECTORF32 Bias = { 384.0f, 384.0f, 384.0f, 0.0f }; - static const XMVECTORF32 C = { 1023.f, 1023.f, 1023.f, 3.f }; - - XMUDECN4 * __restrict dPtr = reinterpret_cast(pDestination); - for( size_t icount = 0; icount < ( size - sizeof(XMUDECN4) + 1 ); icount += sizeof(XMUDECN4) ) - { - if ( sPtr >= ePtr ) break; - - XMVECTOR N = XMVectorMultiplyAdd( *sPtr++, Scale, Bias ); - N = XMVectorClamp( N, g_XMZero, C ); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, N ); - - dPtr->v = ((uint32_t)tmp.w << 30) - | (((uint32_t)tmp.z & 0x3FF) << 20) - | (((uint32_t)tmp.y & 0x3FF) << 10) - | (((uint32_t)tmp.x & 0x3FF)); - ++dPtr; - } - return true; - } - return false; -#endif case DXGI_FORMAT_R10G10B10A2_UINT: STORE_SCANLINE( XMUDEC4, XMStoreUDec4 ); @@ -2054,49 +1951,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, return false; case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: -#if DIRECTX_MATH_VERSION >= 306 STORE_SCANLINE( XMFLOAT3SE, XMStoreFloat3SE ) -#else - if ( size >= sizeof(XMFLOAT3SE) ) - { - static const float maxf9 = float(0x1FF << 7); - static const float minf9 = float(1.f / (1 << 16)); - - XMFLOAT3SE * __restrict dPtr = reinterpret_cast(pDestination); - for( size_t icount = 0; icount < ( size - sizeof(XMFLOAT3SE) + 1 ); icount += sizeof(XMFLOAT3SE) ) - { - if ( sPtr >= ePtr ) break; - - XMFLOAT3 rgb; - XMStoreFloat3( &rgb, *(sPtr++) ); - - float r = (rgb.x >= 0.f) ? ( (rgb.x > maxf9) ? maxf9 : rgb.x ) : 0.f; - float g = (rgb.y >= 0.f) ? ( (rgb.y > maxf9) ? maxf9 : rgb.y ) : 0.f; - float b = (rgb.z >= 0.f) ? ( (rgb.z > maxf9) ? maxf9 : rgb.z ) : 0.f; - - const float max_rg = (r > g) ? r : g; - const float max_rgb = (max_rg > b) ? max_rg : b; - - const float maxColor = (max_rgb > minf9) ? max_rgb : minf9; - - union { float f; INT32 i; } fi; - fi.f = maxColor; - fi.i &= 0xFF800000; // cut off fraction - - dPtr->e = (fi.i - 0x37800000) >> 23; - - fi.i = 0x83000000 - fi.i; - float ScaleR = fi.f; - - dPtr->xm = static_cast( round_to_nearest(r * ScaleR) ); - dPtr->ym = static_cast( round_to_nearest(g * ScaleR) ); - dPtr->zm = static_cast( round_to_nearest(b * ScaleR) ); - ++dPtr; - } - return true; - } - return false; -#endif case DXGI_FORMAT_R8G8_B8G8_UNORM: if ( size >= sizeof(XMUBYTEN4) ) @@ -2715,24 +2570,6 @@ HRESULT _ConvertFromR32G32B32A32( const Image* srcImages, size_t nimages, const // if C_linear > 0.0031308 -> C_srgb = ( 1 + a ) * pow( C_Linear, 1 / 2.4 ) - a // where a = 0.055 //------------------------------------------------------------------------------------- -#if DIRECTX_MATH_VERSION < 306 -static inline XMVECTOR XMColorRGBToSRGB( FXMVECTOR rgb ) -{ - static const XMVECTORF32 Cutoff = { 0.0031308f, 0.0031308f, 0.0031308f, 1.f }; - static const XMVECTORF32 Linear = { 12.92f, 12.92f, 12.92f, 1.f }; - static const XMVECTORF32 Scale = { 1.055f, 1.055f, 1.055f, 1.f }; - static const XMVECTORF32 Bias = { 0.055f, 0.055f, 0.055f, 0.f }; - static const XMVECTORF32 InvGamma = { 1.0f/2.4f, 1.0f/2.4f, 1.0f/2.4f, 1.f }; - - XMVECTOR V = XMVectorSaturate(rgb); - XMVECTOR V0 = XMVectorMultiply( V, Linear ); - XMVECTOR V1 = Scale * XMVectorPow( V, InvGamma ) - Bias; - XMVECTOR select = XMVectorLess( V, Cutoff ); - V = XMVectorSelect( V1, V0, select ); - return XMVectorSelect( rgb, V, g_XMSelect1110 ); -} -#endif - _Use_decl_annotations_ bool _StoreScanlineLinear( LPVOID pDestination, size_t size, DXGI_FORMAT format, XMVECTOR* pSource, size_t count, DWORD flags, float threshold ) @@ -2803,24 +2640,6 @@ bool _StoreScanlineLinear( LPVOID pDestination, size_t size, DXGI_FORMAT format, // if C_srgb > 0.04045 -> C_linear = pow( ( C_srgb + a ) / ( 1 + a ), 2.4 ) // where a = 0.055 //------------------------------------------------------------------------------------- -#if DIRECTX_MATH_VERSION < 306 -static inline XMVECTOR XMColorSRGBToRGB( FXMVECTOR srgb ) -{ - static const XMVECTORF32 Cutoff = { 0.04045f, 0.04045f, 0.04045f, 1.f }; - static const XMVECTORF32 ILinear = { 1.f/12.92f, 1.f/12.92f, 1.f/12.92f, 1.f }; - static const XMVECTORF32 Scale = { 1.f/1.055f, 1.f/1.055f, 1.f/1.055f, 1.f }; - static const XMVECTORF32 Bias = { 0.055f, 0.055f, 0.055f, 0.f }; - static const XMVECTORF32 Gamma = { 2.4f, 2.4f, 2.4f, 1.f }; - - XMVECTOR V = XMVectorSaturate(srgb); - XMVECTOR V0 = XMVectorMultiply( V, ILinear ); - XMVECTOR V1 = XMVectorPow( (V + Bias) * Scale, Gamma ); - XMVECTOR select = XMVectorGreater( V, Cutoff ); - V = XMVectorSelect( V0, V1, select ); - return XMVectorSelect( srgb, V, g_XMSelect1110 ); -} -#endif - _Use_decl_annotations_ bool _LoadScanlineLinear( XMVECTOR* pDestination, size_t count, LPCVOID pSource, size_t size, DXGI_FORMAT format, DWORD flags ) diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index 63c3b25..931eb5d 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -23,6 +23,10 @@ namespace { public: auto_delete_file(HANDLE hFile) : m_handle(hFile) {} + + auto_delete_file(const auto_delete_file&) = delete; + auto_delete_file& operator=(const auto_delete_file&) = delete; + ~auto_delete_file() { if (m_handle) @@ -37,9 +41,6 @@ namespace private: HANDLE m_handle; - - auto_delete_file(const auto_delete_file&) DIRECTX_CTOR_DELETE; - auto_delete_file& operator=(const auto_delete_file&) DIRECTX_CTOR_DELETE; }; } diff --git a/DirectXTex/DirectXTexP.h b/DirectXTex/DirectXTexP.h index f541abe..0bd91c5 100644 --- a/DirectXTex/DirectXTexP.h +++ b/DirectXTex/DirectXTexP.h @@ -44,12 +44,7 @@ #include "directxtex.h" -// VS 2010's stdint.h conflicts with intsafe.h -#pragma warning(push) -#pragma warning(disable : 4005) #include -#include -#pragma warning(pop) #include