From cee58c4aed328fc45c4a95225601d225564161ce Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Fri, 7 Dec 2012 17:30:49 -0800 Subject: [PATCH] DirectXTex: Added VS 2010+Windows SDK 8.0 projects; updated to use SAL2 annotation --- DDSView/DDSView_Desktop_2010_SDK80.sln | 45 ++ DDSView/DDSView_Desktop_2010_SDK80.vcxproj | 371 ++++++++++++++++ ...DDSView_Desktop_2010_SDK80.vcxproj.filters | 20 + DirectXTex/BC.cpp | 40 +- DirectXTex/BC.h | 144 +++---- DirectXTex/BC4BC5.cpp | 26 +- DirectXTex/BC6HBC7.cpp | 137 +++--- DirectXTex/DirectXTex.h | 92 ++-- DirectXTex/DirectXTex.inl | 12 +- DirectXTex/DirectXTexCompress.cpp | 5 + DirectXTex/DirectXTexConvert.cpp | 22 +- DirectXTex/DirectXTexD3D11.cpp | 7 +- DirectXTex/DirectXTexDDS.cpp | 24 +- DirectXTex/DirectXTexFlipRotate.cpp | 2 + DirectXTex/DirectXTexImage.cpp | 13 + DirectXTex/DirectXTexMipmaps.cpp | 11 +- DirectXTex/DirectXTexMisc.cpp | 4 +- DirectXTex/DirectXTexNormalMaps.cpp | 4 +- DirectXTex/DirectXTexP.h | 38 +- DirectXTex/DirectXTexResize.cpp | 2 + DirectXTex/DirectXTexTGA.cpp | 18 +- DirectXTex/DirectXTexUtil.cpp | 24 +- DirectXTex/DirectXTexWIC.cpp | 10 +- DirectXTex/DirectXTex_Desktop_2010_SDK80.sln | 31 ++ .../DirectXTex_Desktop_2010_SDK80.vcxproj | 403 ++++++++++++++++++ ...ectXTex_Desktop_2010_SDK80.vcxproj.filters | 37 ++ Texconv/Texconv_Desktop_2010_SDK80.sln | 45 ++ Texconv/Texconv_Desktop_2010_SDK80.vcxproj | 370 ++++++++++++++++ ...Texconv_Desktop_2010_SDK80.vcxproj.filters | 17 + Windows8SDK_x64.props | 12 + Windows8SDK_x86.props | 12 + 31 files changed, 1769 insertions(+), 229 deletions(-) create mode 100644 DDSView/DDSView_Desktop_2010_SDK80.sln create mode 100644 DDSView/DDSView_Desktop_2010_SDK80.vcxproj create mode 100644 DDSView/DDSView_Desktop_2010_SDK80.vcxproj.filters create mode 100644 DirectXTex/DirectXTex_Desktop_2010_SDK80.sln create mode 100644 DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj create mode 100644 DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj.filters create mode 100644 Texconv/Texconv_Desktop_2010_SDK80.sln create mode 100644 Texconv/Texconv_Desktop_2010_SDK80.vcxproj create mode 100644 Texconv/Texconv_Desktop_2010_SDK80.vcxproj.filters create mode 100644 Windows8SDK_x64.props create mode 100644 Windows8SDK_x86.props diff --git a/DDSView/DDSView_Desktop_2010_SDK80.sln b/DDSView/DDSView_Desktop_2010_SDK80.sln new file mode 100644 index 0000000..685bc5e --- /dev/null +++ b/DDSView/DDSView_Desktop_2010_SDK80.sln @@ -0,0 +1,45 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDSView", "DDSView_Desktop_2010_SDK80.vcxproj", "{9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "..\DirectXTex\DirectXTex_Desktop_2010_SDK80.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Profile|Win32 = Profile|Win32 + Profile|x64 = Profile|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|Win32.ActiveCfg = Debug|Win32 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|Win32.Build.0 = Debug|Win32 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x64.ActiveCfg = Debug|x64 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x64.Build.0 = Debug|x64 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|Win32.ActiveCfg = Profile|Win32 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|Win32.Build.0 = Profile|Win32 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x64.ActiveCfg = Profile|x64 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x64.Build.0 = Profile|x64 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|Win32.ActiveCfg = Release|Win32 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|Win32.Build.0 = Release|Win32 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x64.ActiveCfg = Release|x64 + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x64.Build.0 = Release|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Win32.ActiveCfg = Debug|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Win32.Build.0 = Debug|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Win32.ActiveCfg = Profile|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Win32.Build.0 = Profile|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Win32.ActiveCfg = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Win32.Build.0 = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DDSView/DDSView_Desktop_2010_SDK80.vcxproj b/DDSView/DDSView_Desktop_2010_SDK80.vcxproj new file mode 100644 index 0000000..80e1b8e --- /dev/null +++ b/DDSView/DDSView_Desktop_2010_SDK80.vcxproj @@ -0,0 +1,371 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Profile + Win32 + + + Profile + x64 + + + Release + Win32 + + + Release + x64 + + + + DDSView + {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84} + DDSView + Win32Proj + + + + Application + Unicode + + + Application + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + true + true + + + false + true + + + false + true + + + false + true + + + false + true + + + + Level4 + Disabled + MultiThreadedDebugDLL + false + true + Fast + StreamingSIMDExtensions2 + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + EditAndContinue + EnableFastChecks + + + %(AdditionalOptions) + d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + Windows + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + Disabled + MultiThreadedDebugDLL + false + true + Fast + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + EnableFastChecks + + + %(AdditionalOptions) + d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + Windows + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + StreamingSIMDExtensions2 + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;_WINDOWS;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;_WINDOWS;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + StreamingSIMDExtensions2 + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;PROFILE;_WINDOWS;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;PROFILE;_WINDOWS;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + + + + + + + {371b9fa9-4c90-4ac6-a123-aced756d6c77} + + + + + + + + \ No newline at end of file diff --git a/DDSView/DDSView_Desktop_2010_SDK80.vcxproj.filters b/DDSView/DDSView_Desktop_2010_SDK80.vcxproj.filters new file mode 100644 index 0000000..e546d45 --- /dev/null +++ b/DDSView/DDSView_Desktop_2010_SDK80.vcxproj.filters @@ -0,0 +1,20 @@ + + + + + {8e114980-c1a3-4ada-ad7c-83caadf5daeb} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + + + + Resource Files + + + + + + \ No newline at end of file diff --git a/DirectXTex/BC.cpp b/DirectXTex/BC.cpp index 431867d..8205b86 100644 --- a/DirectXTex/BC.cpp +++ b/DirectXTex/BC.cpp @@ -21,6 +21,10 @@ #include "BC.h" +#ifndef USE_XNAMATH +using namespace DirectX::PackedVector; +#endif + namespace DirectX { @@ -63,7 +67,7 @@ inline static uint16_t Encode565(_In_ const HDRColorA *pColor) //------------------------------------------------------------------------------------- static void OptimizeRGB(_Out_ HDRColorA *pX, _Out_ HDRColorA *pY, - _In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pPoints, _In_ size_t cSteps, _In_ DWORD flags) + _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pPoints, _In_ size_t cSteps, _In_ DWORD flags) { 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 }; @@ -317,7 +321,7 @@ static void OptimizeRGB(_Out_ HDRColorA *pX, _Out_ HDRColorA *pY, //------------------------------------------------------------------------------------- -inline static void DecodeBC1( _Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_ const D3DX_BC1 *pBC, _In_ bool isbc1 ) +inline static void DecodeBC1( _Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_ const D3DX_BC1 *pBC, _In_ bool isbc1 ) { assert( pColor && pBC ); static_assert( sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes" ); @@ -330,8 +334,8 @@ inline static void DecodeBC1( _Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor clr0 = XMVectorMultiply( clr0, s_Scale ); clr1 = XMVectorMultiply( clr1, s_Scale ); - clr0 = XMVectorSwizzle( clr0, 2, 1, 0, 3 ); - clr1 = XMVectorSwizzle( clr1, 2, 1, 0, 3 ); + clr0 = XMVectorSwizzle<2, 1, 0, 3>( clr0 ); + clr1 = XMVectorSwizzle<2, 1, 0, 3>( clr1 ); clr0 = XMVectorSelect( g_XMIdentityR3, clr0, g_XMSelect1110 ); clr1 = XMVectorSelect( g_XMIdentityR3, clr1, g_XMSelect1110 ); @@ -368,7 +372,7 @@ inline static void DecodeBC1( _Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor //------------------------------------------------------------------------------------- #pragma warning(disable: 4616 6001 6201) -static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor, +static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor, _In_ bool bColorKey, _In_ float alphaRef, _In_ DWORD flags) { assert( pBC && pColor ); @@ -446,7 +450,7 @@ static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) co if(3 != (i & 3)) { assert( i < 15 ); - __analysis_assume( i < 15 ); + _Analysis_assume_( i < 15 ); Error[i + 1].r += Diff.r * (7.0f / 16.0f); Error[i + 1].g += Diff.g * (7.0f / 16.0f); Error[i + 1].b += Diff.b * (7.0f / 16.0f); @@ -468,7 +472,7 @@ static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) co if(3 != (i & 3)) { assert( i < 11 ); - __analysis_assume(i < 11 ); + _Analysis_assume_( i < 11 ); Error[i + 5].r += Diff.r * (1.0f / 16.0f); Error[i + 5].g += Diff.g * (1.0f / 16.0f); Error[i + 5].b += Diff.b * (1.0f / 16.0f); @@ -677,7 +681,7 @@ static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) co //------------------------------------------------------------------------------------- #ifdef COLOR_WEIGHTS -static void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor) +static void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor) { #ifdef COLOR_AVG_0WEIGHTS // Compute avg color @@ -717,12 +721,14 @@ static void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_count_c_(NUM_PIXELS_PER_BLOC //------------------------------------------------------------------------------------- // BC1 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC1(XMVECTOR *pColor, const uint8_t *pBC) { const D3DX_BC1 *pBC1 = reinterpret_cast(pBC); DecodeBC1( pColor, pBC1, true ); } +_Use_decl_annotations_ void D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef, DWORD flags) { assert( pBC && pColor ); @@ -751,7 +757,7 @@ void D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef, DWORD f if(3 != (i & 3)) { assert( i < 15 ); - __analysis_assume( i < 15 ); + _Analysis_assume_( i < 15 ); fError[i + 1] += fDiff * (7.0f / 16.0f); } @@ -765,7 +771,7 @@ void D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef, DWORD f if(3 != (i & 3)) { assert( i < 11 ); - __analysis_assume( i < 11 ); + _Analysis_assume_( i < 11 ); fError[i + 5] += fDiff * (1.0f / 16.0f); } } @@ -787,6 +793,7 @@ void D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef, DWORD f //------------------------------------------------------------------------------------- // BC2 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -809,6 +816,7 @@ void D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) pColor[i] = XMVectorSetW( pColor[i], (float) (dw & 0xf) * (1.0f / 15.0f) ); } +_Use_decl_annotations_ void D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) { assert( pBC && pColor ); @@ -848,7 +856,7 @@ void D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) if(3 != (i & 3)) { assert( i < 15 ); - __analysis_assume( i < 15 ); + _Analysis_assume_( i < 15 ); fError[i + 1] += fDiff * (7.0f / 16.0f); } @@ -862,7 +870,7 @@ void D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) if(3 != (i & 3)) { assert( i < 11 ); - __analysis_assume( i < 11 ); + _Analysis_assume_( i < 11 ); fError[i + 5] += fDiff * (1.0f / 16.0f); } } @@ -885,6 +893,7 @@ void D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) //------------------------------------------------------------------------------------- // BC3 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -926,6 +935,7 @@ void D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) pColor[i] = XMVectorSetW( pColor[i], fAlpha[dw & 0x7] ); } +_Use_decl_annotations_ void D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) { assert( pBC && pColor ); @@ -971,7 +981,7 @@ void D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) if(3 != (i & 3)) { assert( i < 15 ); - __analysis_assume( i < 15 ); + _Analysis_assume_( i < 15 ); fError[i + 1] += fDiff * (7.0f / 16.0f); } @@ -985,7 +995,7 @@ void D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) if(3 != (i & 3)) { assert( i < 11 ); - __analysis_assume( i < 11 ); + _Analysis_assume_( i < 11 ); fError[i + 5] += fDiff * (1.0f / 16.0f); } } @@ -1128,4 +1138,4 @@ void D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) } } -} // namespace \ No newline at end of file +} // namespace diff --git a/DirectXTex/BC.h b/DirectXTex/BC.h index 83e8139..3d30244 100644 --- a/DirectXTex/BC.h +++ b/DirectXTex/BC.h @@ -50,7 +50,7 @@ const uint16_t F16S_MASK = 0x8000; // f16 sign mask const uint16_t F16EM_MASK = 0x7fff; // f16 exp & mantissa mask const uint16_t F16MAX = 0x7bff; // MAXFLT bit pattern for XMHALF -#define SIGN_EXTEND(x,nb) ((((x)&(1<<((nb)-1)))?((~0)<<(nb)):0)|(x)) +#define SIGN_EXTEND(x,nb) ((((x)&(1<<((nb)-1)))?((~0)<<(nb)):0)|(x)) // Because these are used in SAL annotations, they need to remain macros rather than const values #define NUM_PIXELS_PER_BLOCK 16 @@ -120,14 +120,14 @@ public: LDRColorA operator = (_In_ const HDRColorA& c); - static void InterpolateRGB(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ 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) { const int* aWeights = nullptr; switch(wcprec) { - case 2: aWeights = g_aWeights2; assert( wc < 4 ); __analysis_assume( wc < 4 ); break; - case 3: aWeights = g_aWeights3; assert( wc < 8 ); __analysis_assume( wc < 8 ); break; - case 4: aWeights = g_aWeights4; assert( wc < 16 ); __analysis_assume( wc < 16 ); break; + case 2: aWeights = g_aWeights2; assert( wc < 4 ); _Analysis_assume_( wc < 4 ); break; + case 3: aWeights = g_aWeights3; assert( wc < 8 ); _Analysis_assume_( wc < 8 ); break; + case 4: aWeights = g_aWeights4; assert( wc < 16 ); _Analysis_assume_( wc < 16 ); break; default: assert(false); out.r = out.g = out.b = 0; return; } out.r = uint8_t((uint32_t(c0.r) * uint32_t(BC67_WEIGHT_MAX - aWeights[wc]) + uint32_t(c1.r) * uint32_t(aWeights[wc]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); @@ -135,20 +135,20 @@ public: 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_ 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) { const int* aWeights = nullptr; switch(waprec) { - case 2: aWeights = g_aWeights2; assert( wa < 4 ); __analysis_assume( wa < 4 ); break; - case 3: aWeights = g_aWeights3; assert( wa < 8 ); __analysis_assume( wa < 8 ); break; - case 4: aWeights = g_aWeights4; assert( wa < 16 ); __analysis_assume( wa < 16 ); break; + case 2: aWeights = g_aWeights2; assert( wa < 4 ); _Analysis_assume_( wa < 4 ); break; + case 3: aWeights = g_aWeights3; assert( wa < 8 ); _Analysis_assume_( wa < 8 ); break; + case 4: aWeights = g_aWeights4; assert( wa < 16 ); _Analysis_assume_( wa < 16 ); break; default: assert(false); out.a = 0; return; } 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_ size_t wcprec, _In_ 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) { InterpolateRGB(c0, c1, wc, wcprec, out); InterpolateA(c0, c1, wa, waprec, out); @@ -360,7 +360,7 @@ public: int& operator [] ( _In_ uint8_t i ) { assert(i < sizeof(INTColor) / sizeof(int)); - __analysis_assume(i < sizeof(INTColor) / sizeof(int)); + _Analysis_assume_(i < sizeof(INTColor) / sizeof(int)); return ((int*) this)[i]; } @@ -392,7 +392,7 @@ public: return *this; } - void ToF16(_Out_cap_c_(3) HALF aF16[3], _In_ bool bSigned) const + void ToF16(_Out_writes_(3) HALF aF16[3], _In_ bool bSigned) const { aF16[0] = INT2F16(r, bSigned); aF16[1] = INT2F16(g, bSigned); @@ -458,7 +458,7 @@ public: uint8_t GetBit(_Inout_ size_t& uStartBit) const { assert(uStartBit < 128); - __analysis_assume(uStartBit < 128); + _Analysis_assume_(uStartBit < 128); size_t uIndex = uStartBit >> 3; uint8_t ret = (m_uBits[uIndex] >> (uStartBit - (uIndex << 3))) & 0x01; uStartBit++; @@ -469,7 +469,7 @@ public: { if(uNumBits == 0) return 0; assert(uStartBit + uNumBits <= 128 && uNumBits <= 8); - __analysis_assume(uStartBit + uNumBits <= 128 && uNumBits <= 8); + _Analysis_assume_(uStartBit + uNumBits <= 128 && uNumBits <= 8); uint8_t ret; size_t uIndex = uStartBit >> 3; size_t uBase = uStartBit - (uIndex << 3); @@ -491,7 +491,7 @@ public: void SetBit(_Inout_ size_t& uStartBit, _In_ uint8_t uValue) { assert(uStartBit < 128 && uValue < 2); - __analysis_assume(uStartBit < 128 && uValue < 2); + _Analysis_assume_(uStartBit < 128 && uValue < 2); size_t uIndex = uStartBit >> 3; size_t uBase = uStartBit - (uIndex << 3); m_uBits[uIndex] &= ~(1 << uBase); @@ -504,7 +504,7 @@ public: if(uNumBits == 0) return; assert(uStartBit + uNumBits <= 128 && uNumBits <= 8); - __analysis_assume(uStartBit + uNumBits <= 128 && uNumBits <= 8); + _Analysis_assume_(uStartBit + uNumBits <= 128 && uNumBits <= 8); assert(uValue < (1 << uNumBits)); size_t uIndex = uStartBit >> 3; size_t uBase = uStartBit - (uIndex << 3); @@ -536,8 +536,8 @@ private: class D3DX_BC6H : private CBits< 16 > { public: - void Decode(_In_ bool bSigned, _Out_cap_c_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const; - void Encode(_In_ bool bSigned, _In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn); + 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); private: enum EField : uint8_t @@ -598,30 +598,30 @@ private: static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned); static int FinishUnquantize(_In_ int comp, _In_ bool bSigned); - static bool EndPointsFit(_In_ const EncodeParams* pEP, _In_count_c_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[]); + static bool EndPointsFit(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[]); void GeneratePaletteQuantized(_In_ const EncodeParams* pEP, _In_ const INTEndPntPair& endPts, - _Out_cap_c_(BC6H_MAX_INDICES) INTColor aPalette[]) const; - float MapColorsQuantized(_In_ const EncodeParams* pEP, _In_count_(np) const INTColor aColors[], _In_ size_t np, _In_ const INTEndPntPair &endPts) const; - float PerturbOne(_In_ const EncodeParams* pEP, _In_count_(np) const INTColor aColors[], _In_ size_t np, _In_ uint8_t ch, + _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; + 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; - void OptimizeOne(_In_ const EncodeParams* pEP, _In_count_(np) const INTColor aColors[], _In_ size_t np, _In_ float aOrgErr, + 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; - void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_count_c_(BC6H_MAX_REGIONS) const float aOrgErr[], - _In_count_c_(BC6H_MAX_REGIONS) const INTEndPntPair aOrgEndPts[], - _Inout_count_c_(BC6H_MAX_REGIONS) INTEndPntPair aOptEndPts[]) const; - static void SwapIndices(_In_ const EncodeParams* pEP, _Inout_count_c_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], - _In_count_c_(NUM_PIXELS_PER_BLOCK) size_t aIndices[]); - void AssignIndices(_In_ const EncodeParams* pEP, _In_count_c_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[], - _Out_cap_c_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], - _Out_cap_c_(BC6H_MAX_REGIONS) float aTotErr[]) const; - void QuantizeEndPts(_In_ const EncodeParams* pEP, _Out_cap_c_(BC6H_MAX_REGIONS) INTEndPntPair* qQntEndPts) const; - void EmitBlock(_In_ const EncodeParams* pEP, _In_count_c_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[], - _In_count_c_(NUM_PIXELS_PER_BLOCK) const size_t aIndices[]); + void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const float aOrgErr[], + _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aOrgEndPts[], + _Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aOptEndPts[]) const; + static void SwapIndices(_In_ const EncodeParams* pEP, _Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], + _In_reads_(NUM_PIXELS_PER_BLOCK) size_t aIndices[]); + 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; + 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); - static void GeneratePaletteUnquantized(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _Out_cap_c_(BC6H_MAX_INDICES) INTColor aPalette[]); - float MapColors(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _In_ size_t np, _In_count_(np) const size_t* auIndex) const; + 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; private: @@ -634,8 +634,8 @@ private: class D3DX_BC7 : private CBits< 16 > { public: - void Decode(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const; - void Encode(_In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn); + void Decode(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const; + void Encode(_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn); private: struct ModeInfo @@ -699,29 +699,29 @@ private: } void GeneratePaletteQuantized(_In_ const EncodeParams* pEP, _In_ size_t uIndexMode, _In_ const LDREndPntPair& endpts, - _Out_cap_c_(BC7_MAX_INDICES) LDRColorA aPalette[]) const; - float PerturbOne(_In_ const EncodeParams* pEP, _In_count_(np) const LDRColorA colors[], _In_ size_t np, _In_ size_t uIndexMode, + _Out_writes_(BC7_MAX_INDICES) LDRColorA aPalette[]) const; + 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; - void Exhaustive(_In_ const EncodeParams* pEP, _In_count_(np) const LDRColorA aColors[], _In_ size_t np, _In_ size_t uIndexMode, + 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; - void OptimizeOne(_In_ const EncodeParams* pEP, _In_count_(np) const LDRColorA colors[], _In_ size_t np, _In_ size_t uIndexMode, + 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; void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode, - _In_count_c_(BC7_MAX_REGIONS) const float orig_err[], - _In_count_c_(BC7_MAX_REGIONS) const LDREndPntPair orig_endpts[], - _Out_cap_c_(BC7_MAX_REGIONS) LDREndPntPair opt_endpts[]) const; + _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; void AssignIndices(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode, - _In_count_c_(BC7_MAX_REGIONS) LDREndPntPair endpts[], - _Out_cap_c_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], _Out_cap_c_(NUM_PIXELS_PER_BLOCK) size_t aIndices2[], - _Out_cap_c_(BC7_MAX_REGIONS) float afTotErr[]) const; + _In_reads_(BC7_MAX_REGIONS) LDREndPntPair endpts[], + _Inout_updates_all_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], _Inout_updates_all_(NUM_PIXELS_PER_BLOCK) size_t aIndices2[], + _Out_writes_(BC7_MAX_REGIONS) float afTotErr[]) const; void EmitBlock(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode, - _In_count_c_(BC7_MAX_REGIONS) const LDREndPntPair aEndPts[], - _In_count_c_(NUM_PIXELS_PER_BLOCK) const size_t aIndex[], - _In_count_c_(NUM_PIXELS_PER_BLOCK) const size_t aIndex2[]); + _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[]); float Refine(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode); - float MapColors(_In_ const EncodeParams* pEP, _In_count_(np) const LDRColorA aColors[], _In_ size_t np, _In_ size_t uIndexMode, + 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); @@ -870,28 +870,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_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(8) const uint8_t *pBC); -void D3DXDecodeBC2(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); -void D3DXDecodeBC3(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); -void D3DXDecodeBC4U(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(8) const uint8_t *pBC); -void D3DXDecodeBC4S(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(8) const uint8_t *pBC); -void D3DXDecodeBC5U(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); -void D3DXDecodeBC5S(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); -void D3DXDecodeBC6HU(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); -void D3DXDecodeBC6HS(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); -void D3DXDecodeBC7(_Out_cap_c_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_count_c_(16) const uint8_t *pBC); +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 D3DXEncodeBC1(_Out_cap_c_(8) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float alphaRef, _In_ DWORD flags); +void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float alphaRef, _In_ DWORD flags); // BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above -void D3DXEncodeBC2(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC3(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC4U(_Out_cap_c_(8) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC4S(_Out_cap_c_(8) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC5U(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC5S(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC6HU(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC6HS(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags); -void D3DXEncodeBC7(_Out_cap_c_(16) uint8_t *pBC, _In_count_c_(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); +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); }; // namespace diff --git a/DirectXTex/BC4BC5.cpp b/DirectXTex/BC4BC5.cpp index b0e230b..651d866 100644 --- a/DirectXTex/BC4BC5.cpp +++ b/DirectXTex/BC4BC5.cpp @@ -164,10 +164,10 @@ static void inline FloatToSNorm( _In_ float fVal, _Out_ int8_t *piSNorm ) fVal = 0; else if( fVal > 1 ) - fVal = 1; // Clamp to 1 + fVal = 1; // Clamp to 1 else if( fVal < -1 ) - fVal = -1; // Clamp to -1 + fVal = -1; // Clamp to -1 fVal = fVal * (int8_t) ( dwMostNeg - 1 ); @@ -181,7 +181,7 @@ static void inline FloatToSNorm( _In_ float fVal, _Out_ int8_t *piSNorm ) //------------------------------------------------------------------------------ -static void FindEndPointsBC4U( _In_count_c_(BLOCK_SIZE) const float theTexelsU[], _Out_ uint8_t &endpointU_0, _Out_ uint8_t &endpointU_1) +static void FindEndPointsBC4U( _In_reads_(BLOCK_SIZE) const float theTexelsU[], _Out_ uint8_t &endpointU_0, _Out_ uint8_t &endpointU_1) { // The boundary of codec for signed/unsigned format float MIN_NORM; @@ -235,7 +235,7 @@ static void FindEndPointsBC4U( _In_count_c_(BLOCK_SIZE) const float theTexelsU[] } } -static void FindEndPointsBC4S(_In_count_c_(BLOCK_SIZE) const float theTexelsU[], _Out_ int8_t &endpointU_0, _Out_ int8_t &endpointU_1) +static void FindEndPointsBC4S(_In_reads_(BLOCK_SIZE) const float theTexelsU[], _Out_ int8_t &endpointU_0, _Out_ int8_t &endpointU_1) { // The boundary of codec for signed/unsigned format float MIN_NORM; @@ -291,7 +291,7 @@ static void FindEndPointsBC4S(_In_count_c_(BLOCK_SIZE) const float theTexelsU[], //------------------------------------------------------------------------------ -static inline void FindEndPointsBC5U( _In_count_c_(BLOCK_SIZE) const float theTexelsU[], _In_count_c_(BLOCK_SIZE) const float theTexelsV[], +static inline void FindEndPointsBC5U( _In_reads_(BLOCK_SIZE) const float theTexelsU[], _In_reads_(BLOCK_SIZE) const float theTexelsV[], _Out_ uint8_t &endpointU_0, _Out_ uint8_t &endpointU_1, _Out_ uint8_t &endpointV_0, _Out_ uint8_t &endpointV_1) { //Encoding the U and V channel by BC4 codec separately. @@ -299,7 +299,7 @@ static inline void FindEndPointsBC5U( _In_count_c_(BLOCK_SIZE) const float theTe FindEndPointsBC4U( theTexelsV, endpointV_0, endpointV_1); } -static inline void FindEndPointsBC5S( _In_count_c_(BLOCK_SIZE) const float theTexelsU[], _In_count_c_(BLOCK_SIZE) const float theTexelsV[], +static inline void FindEndPointsBC5S( _In_reads_(BLOCK_SIZE) const float theTexelsU[], _In_reads_(BLOCK_SIZE) const float theTexelsV[], _Out_ int8_t &endpointU_0, _Out_ int8_t &endpointU_1, _Out_ int8_t &endpointV_0, _Out_ int8_t &endpointV_1) { //Encoding the U and V channel by BC4 codec separately. @@ -309,7 +309,7 @@ static inline void FindEndPointsBC5S( _In_count_c_(BLOCK_SIZE) const float theTe //------------------------------------------------------------------------------ -static void FindClosestUNORM(_Inout_ BC4_UNORM* pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) +static void FindClosestUNORM(_Inout_ BC4_UNORM* pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) { float rGradient[8]; int i; @@ -334,7 +334,7 @@ static void FindClosestUNORM(_Inout_ BC4_UNORM* pBC, _In_count_c_(NUM_PIXELS_PER } } -static void FindClosestSNORM(_Inout_ BC4_SNORM* pBC, _In_count_c_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) +static void FindClosestSNORM(_Inout_ BC4_SNORM* pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) { float rGradient[8]; int i; @@ -367,6 +367,7 @@ static void FindClosestSNORM(_Inout_ BC4_SNORM* pBC, _In_count_c_(NUM_PIXELS_PER //------------------------------------------------------------------------------------- // BC4 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC4U( XMVECTOR *pColor, const uint8_t *pBC ) { assert( pColor && pBC ); @@ -380,6 +381,7 @@ void D3DXDecodeBC4U( XMVECTOR *pColor, const uint8_t *pBC ) } } +_Use_decl_annotations_ void D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -393,6 +395,7 @@ void D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) } } +_Use_decl_annotations_ void D3DXEncodeBC4U( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) { UNREFERENCED_PARAMETER( flags ); @@ -413,6 +416,7 @@ void D3DXEncodeBC4U( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) FindClosestUNORM(pBC4, theTexelsU); } +_Use_decl_annotations_ void D3DXEncodeBC4S( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) { UNREFERENCED_PARAMETER( flags ); @@ -437,6 +441,7 @@ void D3DXEncodeBC4S( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) //------------------------------------------------------------------------------------- // BC5 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -451,6 +456,7 @@ void D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) } } +_Use_decl_annotations_ void D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -465,6 +471,7 @@ void D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) } } +_Use_decl_annotations_ void D3DXEncodeBC5U( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) { UNREFERENCED_PARAMETER( flags ); @@ -498,6 +505,7 @@ void D3DXEncodeBC5U( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) FindClosestUNORM(pBCG, theTexelsV); } +_Use_decl_annotations_ void D3DXEncodeBC5S( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) { UNREFERENCED_PARAMETER( flags ); @@ -531,4 +539,4 @@ void D3DXEncodeBC5S( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags ) FindClosestSNORM(pBCG, theTexelsV); } -} // namespace \ No newline at end of file +} // namespace diff --git a/DirectXTex/BC6HBC7.cpp b/DirectXTex/BC6HBC7.cpp index e46f469..568bf3b 100644 --- a/DirectXTex/BC6HBC7.cpp +++ b/DirectXTex/BC6HBC7.cpp @@ -571,7 +571,7 @@ inline static void Swap( T& a, T& b ) inline static bool IsFixUpOffset(_In_range_(0,2) size_t uPartitions, _In_range_(0,63) size_t uShape, _In_range_(0,15) size_t uOffset) { assert(uPartitions < 3 && uShape < 64 && uOffset < 16); - __analysis_assume(uPartitions < 3 && uShape < 64 && uOffset < 16); + _Analysis_assume_(uPartitions < 3 && uShape < 64 && uOffset < 16); for(size_t p = 0; p <= uPartitions; p++) { if(uOffset == g_aFixUp[uPartitions][uShape][p]) @@ -605,14 +605,14 @@ inline static float ErrorMetric(_In_ const LDRColorA& a, _In_ const LDRColorA& b return ErrorMetricRGB(a, b) + ErrorMetricAlpha(a, b); } -inline static void TransformForward(_Inout_count_c_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[]) +inline static void TransformForward(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[]) { aEndPts[0].B -= aEndPts[0].A; aEndPts[1].A -= aEndPts[0].A; aEndPts[1].B -= aEndPts[0].A; } -inline static void TransformInverse(_Inout_count_c_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], _In_ const LDRColorA& Prec, _In_ bool bSigned) +inline static void TransformInverse(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], _In_ const LDRColorA& Prec, _In_ bool bSigned) { INTColor WrapMask((1 << Prec.r) - 1, (1 << Prec.g) - 1, (1 << Prec.b) - 1); aEndPts[0].B += aEndPts[0].A; aEndPts[0].B &= WrapMask; @@ -657,9 +657,9 @@ inline static int NBits(_In_ int n, _In_ bool bIsSigned) //------------------------------------------------------------------------------------- -static float OptimizeRGB(_In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints, +static float OptimizeRGB(_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints, _Out_ HDRColorA* pX, _Out_ HDRColorA* pY, - _In_ size_t cSteps, _In_ size_t cPixels, _In_count_(cPixels) const size_t* pIndex) + _In_ size_t cSteps, _In_ size_t cPixels, _In_reads_(cPixels) const size_t* pIndex) { float fError = FLT_MAX; const float *pC = (3 == cSteps) ? pC3 : pC4; @@ -849,9 +849,9 @@ static float OptimizeRGB(_In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA* con //------------------------------------------------------------------------------------- -static float OptimizeRGBA(_In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints, +static float OptimizeRGBA(_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints, _Out_ HDRColorA* pX, _Out_ HDRColorA* pY, - _In_ size_t cSteps, _In_ size_t cPixels, _In_count_(cPixels) const size_t* pIndex) + _In_ size_t cSteps, _In_ size_t cPixels, _In_reads_(cPixels) const size_t* pIndex) { float fError = FLT_MAX; const float *pC = (3 == cSteps) ? pC3 : pC4; @@ -1016,7 +1016,7 @@ static float OptimizeRGBA(_In_count_c_(NUM_PIXELS_PER_BLOCK) const HDRColorA* co //------------------------------------------------------------------------------------- #pragma warning(disable: 4616 6001 6297) -static float ComputeError(_Inout_ const LDRColorA& pixel, _In_count_x_(1 << uIndexPrec) const LDRColorA aPalette[], +static float ComputeError(_Inout_ const LDRColorA& pixel, _In_reads_(1 << uIndexPrec) const LDRColorA aPalette[], _In_ uint8_t uIndexPrec, _In_ uint8_t uIndexPrec2, _Out_opt_ size_t* pBestIndex = nullptr, _Out_opt_ size_t* pBestIndex2 = nullptr) { const size_t uNumIndices = 1 << uIndexPrec; @@ -1080,7 +1080,7 @@ static float ComputeError(_Inout_ const LDRColorA& pixel, _In_count_x_(1 << uInd } -inline static void FillWithErrorColors( _Out_cap_c_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut ) +inline static void FillWithErrorColors( _Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut ) { for(size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) { @@ -1098,6 +1098,7 @@ inline static void FillWithErrorColors( _Out_cap_c_(NUM_PIXELS_PER_BLOCK) HDRCol //------------------------------------------------------------------------------------- // BC6H Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const { assert(pOut ); @@ -1110,16 +1111,16 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const } assert( uMode < 32 ); - __analysis_assume( uMode < 32 ); + _Analysis_assume_( uMode < 32 ); if ( ms_aModeToInfo[uMode] >= 0 ) { assert(ms_aModeToInfo[uMode] < ARRAYSIZE(ms_aInfo)); - __analysis_assume(ms_aModeToInfo[uMode] < ARRAYSIZE(ms_aInfo)); + _Analysis_assume_(ms_aModeToInfo[uMode] < ARRAYSIZE(ms_aInfo)); const ModeDescriptor* desc = ms_aDesc[ms_aModeToInfo[uMode]]; assert(ms_aModeToInfo[uMode] < ARRAYSIZE(ms_aDesc)); - __analysis_assume(ms_aModeToInfo[uMode] < ARRAYSIZE(ms_aDesc)); + _Analysis_assume_(ms_aModeToInfo[uMode] < ARRAYSIZE(ms_aDesc)); const ModeInfo& info = ms_aInfo[ms_aModeToInfo[uMode]]; INTEndPntPair aEndPts[BC6H_MAX_REGIONS]; @@ -1161,7 +1162,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const } assert( uShape < 64 ); - __analysis_assume( uShape < 64 ); + _Analysis_assume_( uShape < 64 ); // Sign extend necessary end points if(bSigned) @@ -1171,7 +1172,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const if(bSigned || info.bTransformed) { assert( info.uPartitions < BC6H_MAX_REGIONS ); - __analysis_assume( info.uPartitions < BC6H_MAX_REGIONS ); + _Analysis_assume_( info.uPartitions < BC6H_MAX_REGIONS ); for(size_t p = 0; p <= info.uPartitions; ++p) { if(p != 0) @@ -1213,7 +1214,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const size_t uRegion = g_aPartitionTable[info.uPartitions][uShape][i]; assert( uRegion < BC6H_MAX_REGIONS ); - __analysis_assume( uRegion < BC6H_MAX_REGIONS ); + _Analysis_assume_( uRegion < BC6H_MAX_REGIONS ); // Unquantize endpoints and interpolate int r1 = Unquantize(aEndPts[uRegion].A.r, info.RGBAPrec[0][0].r, bSigned); @@ -1246,6 +1247,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const } } +_Use_decl_annotations_ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) { assert( pIn ); @@ -1292,6 +1294,7 @@ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ int D3DX_BC6H::Quantize(int iValue, int prec, bool bSigned) { assert(prec > 1); // didn't bother to make it work for 1 @@ -1319,6 +1322,7 @@ int D3DX_BC6H::Quantize(int iValue, int prec, bool bSigned) return q; } +_Use_decl_annotations_ int D3DX_BC6H::Unquantize(int comp, uint8_t uBitsPerComp, bool bSigned) { int unq = 0, s = 0; @@ -1354,6 +1358,7 @@ int D3DX_BC6H::Unquantize(int comp, uint8_t uBitsPerComp, bool bSigned) return unq; } +_Use_decl_annotations_ int D3DX_BC6H::FinishUnquantize(int comp, bool bSigned) { if(bSigned) @@ -1368,6 +1373,7 @@ int D3DX_BC6H::FinishUnquantize(int comp, bool bSigned) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ bool D3DX_BC6H::EndPointsFit(const EncodeParams* pEP, const INTEndPntPair aEndPts[]) { assert( pEP ); @@ -1408,13 +1414,14 @@ bool D3DX_BC6H::EndPointsFit(const EncodeParams* pEP, const INTEndPntPair aEndPt return true; } +_Use_decl_annotations_ void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPntPair& endPts, INTColor aPalette[]) const { assert( pEP ); const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; const size_t uNumIndices = 1 << uIndexPrec; assert( uNumIndices > 0 ); - __analysis_assume( uNumIndices > 0 ); + _Analysis_assume_( uNumIndices > 0 ); const LDRColorA& Prec = ms_aInfo[pEP->uMode].RGBAPrec[0][0]; // scale endpoints @@ -1430,8 +1437,8 @@ void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPn const int* aWeights = nullptr; switch(uIndexPrec) { - case 3: aWeights = g_aWeights3; assert(uNumIndices <= 8); __analysis_assume(uNumIndices <= 8); break; - case 4: aWeights = g_aWeights4; assert(uNumIndices <= 16); __analysis_assume(uNumIndices <= 16); break; + case 3: aWeights = g_aWeights3; assert(uNumIndices <= 8); _Analysis_assume_(uNumIndices <= 8); break; + case 4: aWeights = g_aWeights4; assert(uNumIndices <= 16); _Analysis_assume_(uNumIndices <= 16); break; default: assert(false); for(size_t i=0; i < uNumIndices; ++i) aPalette[i] = INTColor(0,0,0); return; } @@ -1450,6 +1457,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 { assert( pEP ); @@ -1474,6 +1482,7 @@ float D3DX_BC6H::MapColorsQuantized(const EncodeParams* pEP, const INTColor aCol return fTotErr; } +_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 { @@ -1533,6 +1542,7 @@ float D3DX_BC6H::PerturbOne(const EncodeParams* pEP, const INTColor aColors[], s return fMinErr; } +_Use_decl_annotations_ void D3DX_BC6H::OptimizeOne(const EncodeParams* pEP, const INTColor aColors[], size_t np, float aOrgErr, const INTEndPntPair &aOrgEndPts, INTEndPntPair &aOptEndPts) const { @@ -1584,12 +1594,13 @@ 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 { assert( pEP ); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC6H_MAX_REGIONS ); - __analysis_assume( uPartitions < BC6H_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC6H_MAX_REGIONS ); INTColor aPixels[NUM_PIXELS_PER_BLOCK]; for(size_t p = 0; p <= uPartitions; ++p) @@ -1609,6 +1620,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[]) { assert( pEP ); @@ -1617,7 +1629,7 @@ void D3DX_BC6H::SwapIndices(const EncodeParams* pEP, INTEndPntPair aEndPts[], si const size_t uHighIndexBit = uNumIndices >> 1; assert( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); - __analysis_assume( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); + _Analysis_assume_( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); for(size_t p = 0; p <= uPartitions; ++p) { @@ -1636,6 +1648,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 { assert( pEP ); @@ -1643,7 +1656,7 @@ void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndP const uint8_t uNumIndices = 1 << ms_aInfo[pEP->uMode].uIndexPrec; assert( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); - __analysis_assume( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); + _Analysis_assume_( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); // build list of possibles INTColor aPalette[BC6H_MAX_REGIONS][BC6H_MAX_INDICES]; @@ -1658,7 +1671,7 @@ void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndP { const uint8_t uRegion = g_aPartitionTable[uPartitions][pEP->uShape][i]; assert( uRegion < BC6H_MAX_REGIONS ); - __analysis_assume( uRegion < BC6H_MAX_REGIONS ); + _Analysis_assume_( uRegion < BC6H_MAX_REGIONS ); float fBestErr = Norm(pEP->aIPixels[i], aPalette[uRegion][0]); aIndices[i] = 0; @@ -1676,6 +1689,7 @@ void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndP } } +_Use_decl_annotations_ void D3DX_BC6H::QuantizeEndPts(const EncodeParams* pEP, INTEndPntPair* aQntEndPts) const { assert( pEP && aQntEndPts ); @@ -1683,7 +1697,7 @@ void D3DX_BC6H::QuantizeEndPts(const EncodeParams* pEP, INTEndPntPair* aQntEndPt const LDRColorA& Prec = ms_aInfo[pEP->uMode].RGBAPrec[0][0]; const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC6H_MAX_REGIONS ); - __analysis_assume( uPartitions < BC6H_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC6H_MAX_REGIONS ); for(size_t p = 0; p <= uPartitions; ++p) { @@ -1696,6 +1710,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[]) { assert( pEP ); @@ -1738,12 +1753,13 @@ void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[] assert(uStartBit == 128); } +_Use_decl_annotations_ void D3DX_BC6H::Refine(EncodeParams* pEP) { assert( pEP ); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC6H_MAX_REGIONS ); - __analysis_assume( uPartitions < BC6H_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC6H_MAX_REGIONS ); const bool bTransformed = ms_aInfo[pEP->uMode].bTransformed; float aOrgErr[BC6H_MAX_REGIONS], aOptErr[BC6H_MAX_REGIONS]; @@ -1786,22 +1802,23 @@ void D3DX_BC6H::Refine(EncodeParams* pEP) } } +_Use_decl_annotations_ void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegion, INTColor aPalette[]) { assert( pEP ); assert( uRegion < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); - __analysis_assume( uRegion < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); + _Analysis_assume_( uRegion < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES ); const INTEndPntPair& endPts = pEP->aUnqEndPts[pEP->uShape][uRegion]; const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; const uint8_t uNumIndices = 1 << uIndexPrec; - assert( uNumIndices > 0 ); - __analysis_assume( uNumIndices > 0 ); + assert(uNumIndices > 0); + _Analysis_assume_(uNumIndices > 0); const int* aWeights = nullptr; switch(uIndexPrec) { - case 3: aWeights = g_aWeights3; assert(uNumIndices <= 8); __analysis_assume(uNumIndices <= 8); break; - case 4: aWeights = g_aWeights4; assert(uNumIndices <= 16); __analysis_assume(uNumIndices <= 16); break; + case 3: aWeights = g_aWeights3; assert(uNumIndices <= 8); _Analysis_assume_(uNumIndices <= 8); break; + case 4: aWeights = g_aWeights4; assert(uNumIndices <= 16); _Analysis_assume_(uNumIndices <= 16); break; default: assert(false); for(size_t i = 0; i < uNumIndices; ++i) aPalette[i] = INTColor(0,0,0); return; } @@ -1813,6 +1830,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 { assert( pEP ); @@ -1837,17 +1855,18 @@ float D3DX_BC6H::MapColors(const EncodeParams* pEP, size_t uRegion, size_t np, c return fTotalErr; } +_Use_decl_annotations_ float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const { assert( pEP ); assert( pEP->uShape < BC6H_MAX_SHAPES); - __analysis_assume( pEP->uShape < BC6H_MAX_SHAPES); + _Analysis_assume_( pEP->uShape < BC6H_MAX_SHAPES); INTEndPntPair* aEndPts = pEP->aUnqEndPts[pEP->uShape]; const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC6H_MAX_REGIONS ); - __analysis_assume( uPartitions < BC6H_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC6H_MAX_REGIONS ); size_t auPixIdx[NUM_PIXELS_PER_BLOCK]; @@ -1904,6 +1923,7 @@ float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const //------------------------------------------------------------------------------------- // BC7 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DX_BC7::Decode(HDRColorA* pOut) const { assert( pOut ); @@ -1916,7 +1936,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const { const uint8_t uPartitions = ms_aInfo[uMode].uPartitions; assert( uPartitions < BC7_MAX_REGIONS ); - __analysis_assume( uPartitions < BC7_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC7_MAX_REGIONS ); const uint8_t uNumEndPts = (uPartitions + 1) << 1; const uint8_t uIndexPrec = ms_aInfo[uMode].uIndexPrec; @@ -1926,7 +1946,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const uint8_t P[6]; uint8_t uShape = GetBits(uStartBit, ms_aInfo[uMode].uPartitionBits); assert( uShape < BC7_MAX_SHAPES ); - __analysis_assume( uShape < BC7_MAX_SHAPES ); + _Analysis_assume_( uShape < BC7_MAX_SHAPES ); uint8_t uRotation = GetBits(uStartBit, ms_aInfo[uMode].uRotationBits); assert( uRotation < 4 ); @@ -2002,7 +2022,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const // P-bits assert( ms_aInfo[uMode].uPBits <= 6 ); - __analysis_assume( ms_aInfo[uMode].uPBits <= 6 ); + _Analysis_assume_( ms_aInfo[uMode].uPBits <= 6 ); for(i = 0; i < ms_aInfo[uMode].uPBits; i++) { if ( uStartBit > 127 ) @@ -2111,6 +2131,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const } } +_Use_decl_annotations_ void D3DX_BC7::Encode(const HDRColorA* const pIn) { assert( pIn ); @@ -2131,7 +2152,7 @@ void D3DX_BC7::Encode(const HDRColorA* const pIn) { const size_t uShapes = 1 << ms_aInfo[EP.uMode].uPartitionBits; assert( uShapes <= BC7_MAX_SHAPES ); - __analysis_assume( uShapes <= BC7_MAX_SHAPES ); + _Analysis_assume_( uShapes <= BC7_MAX_SHAPES ); const size_t uNumRots = 1 << ms_aInfo[EP.uMode].uRotationBits; const size_t uNumIdxMode = 1 << ms_aInfo[EP.uMode].uIndexModeBits; @@ -2197,6 +2218,7 @@ void D3DX_BC7::Encode(const HDRColorA* const pIn) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMode, const LDREndPntPair& endPts, LDRColorA aPalette[]) const { assert( pEP ); @@ -2205,9 +2227,9 @@ void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMo const size_t uNumIndices = 1 << uIndexPrec; const size_t uNumIndices2 = 1 << uIndexPrec2; assert( uNumIndices > 0 && uNumIndices2 > 0 ); - __analysis_assume( uNumIndices > 0 && uNumIndices2 > 0 ); + _Analysis_assume_( uNumIndices > 0 && uNumIndices2 > 0 ); assert( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) ); - __analysis_assume( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) ); + _Analysis_assume_( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) ); LDRColorA a = Unquantize(endPts.A, ms_aInfo[pEP->uMode].RGBAPrecWithP); LDRColorA b = Unquantize(endPts.B, ms_aInfo[pEP->uMode].RGBAPrecWithP); @@ -2225,6 +2247,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 { @@ -2266,6 +2289,7 @@ float D3DX_BC7::PerturbOne(const EncodeParams* pEP, const LDRColorA aColors[], s // perturb the endpoints at least -3 to 3. // 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 { @@ -2336,6 +2360,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 { @@ -2401,13 +2426,14 @@ void D3DX_BC7::OptimizeOne(const EncodeParams* pEP, const LDRColorA aColors[], s Exhaustive(pEP, aColors, np, uIndexMode, ch, fOptErr, opt); } +_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 { assert( pEP ); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC7_MAX_REGIONS && uShape < BC7_MAX_SHAPES ); - __analysis_assume( uPartitions < BC7_MAX_REGIONS && uShape < BC7_MAX_SHAPES ); + _Analysis_assume_( uPartitions < BC7_MAX_REGIONS && uShape < BC7_MAX_SHAPES ); LDRColorA aPixels[NUM_PIXELS_PER_BLOCK]; @@ -2423,16 +2449,17 @@ 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 { assert( pEP ); assert( uShape < BC7_MAX_SHAPES ); - __analysis_assume( uShape < BC7_MAX_SHAPES ); + _Analysis_assume_( uShape < BC7_MAX_SHAPES ); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC7_MAX_REGIONS ); - __analysis_assume( uPartitions < BC7_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC7_MAX_REGIONS ); const uint8_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; const uint8_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2; @@ -2440,7 +2467,7 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd const uint8_t uNumIndices2 = 1 << uIndexPrec2; assert( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) ); - __analysis_assume( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) ); + _Analysis_assume_( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) ); const uint8_t uHighestIndexBit = uNumIndices >> 1; const uint8_t uHighestIndexBit2 = uNumIndices2 >> 1; @@ -2458,7 +2485,7 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd { uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i]; assert( uRegion < BC7_MAX_REGIONS ); - __analysis_assume( uRegion < BC7_MAX_REGIONS ); + _Analysis_assume_( uRegion < BC7_MAX_REGIONS ); afTotErr[uRegion] += ComputeError(pEP->aLDRPixels[i], aPalette[uRegion], uIndexPrec, uIndexPrec2, &(aIndices[i]), &(aIndices2[i])); } @@ -2503,12 +2530,13 @@ 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[]) { assert( pEP ); const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC7_MAX_REGIONS ); - __analysis_assume( uPartitions < BC7_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC7_MAX_REGIONS ); const size_t uPBits = ms_aInfo[pEP->uMode].uPBits; const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; @@ -2544,12 +2572,12 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].B[ch] >> 1); size_t idx = ep++ * uPBits / uNumEP; assert(idx < (BC7_MAX_REGIONS << 1)); - __analysis_assume(idx < (BC7_MAX_REGIONS << 1)); + _Analysis_assume_(idx < (BC7_MAX_REGIONS << 1)); aPVote[idx] += aEndPts[i].A[ch] & 0x01; aCount[idx]++; idx = ep++ * uPBits / uNumEP; assert(idx < (BC7_MAX_REGIONS << 1)); - __analysis_assume(idx < (BC7_MAX_REGIONS << 1)); + _Analysis_assume_(idx < (BC7_MAX_REGIONS << 1)); aPVote[idx] += aEndPts[i].B[ch] & 0x01; aCount[idx]++; } @@ -2589,16 +2617,17 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio assert(uStartBit == 128); } +_Use_decl_annotations_ float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode) { assert( pEP ); assert( uShape < BC7_MAX_SHAPES ); - __analysis_assume( uShape < BC7_MAX_SHAPES ); + _Analysis_assume_( uShape < BC7_MAX_SHAPES ); const LDREndPntPair* aEndPts = pEP->aEndPts[uShape]; const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC7_MAX_REGIONS ); - __analysis_assume( uPartitions < BC7_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC7_MAX_REGIONS ); LDREndPntPair aOrgEndPts[BC7_MAX_REGIONS]; LDREndPntPair aOptEndPts[BC7_MAX_REGIONS]; @@ -2637,6 +2666,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 { assert( pEP ); @@ -2659,16 +2689,17 @@ float D3DX_BC7::MapColors(const EncodeParams* pEP, const LDRColorA aColors[], si return fTotalErr; } +_Use_decl_annotations_ float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode) { assert( pEP ); assert( uShape < BC7_MAX_SHAPES ); - __analysis_assume( uShape < BC7_MAX_SHAPES ); + _Analysis_assume_( uShape < BC7_MAX_SHAPES ); LDREndPntPair* aEndPts = pEP->aEndPts[uShape]; const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; assert( uPartitions < BC7_MAX_REGIONS ); - __analysis_assume( uPartitions < BC7_MAX_REGIONS ); + _Analysis_assume_( uPartitions < BC7_MAX_REGIONS ); const uint8_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; const uint8_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2; @@ -2770,6 +2801,7 @@ float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode) //------------------------------------------------------------------------------------- // BC6H Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC6HU(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -2777,6 +2809,7 @@ void D3DXDecodeBC6HU(XMVECTOR *pColor, const uint8_t *pBC) reinterpret_cast< const D3DX_BC6H* >( pBC )->Decode(false, reinterpret_cast(pColor)); } +_Use_decl_annotations_ void D3DXDecodeBC6HS(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -2784,6 +2817,7 @@ void D3DXDecodeBC6HS(XMVECTOR *pColor, const uint8_t *pBC) reinterpret_cast< const D3DX_BC6H* >( pBC )->Decode(true, reinterpret_cast(pColor)); } +_Use_decl_annotations_ void D3DXEncodeBC6HU(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) { UNREFERENCED_PARAMETER(flags); @@ -2792,6 +2826,7 @@ void D3DXEncodeBC6HU(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) reinterpret_cast< D3DX_BC6H* >( pBC )->Encode(false, reinterpret_cast(pColor)); } +_Use_decl_annotations_ void D3DXEncodeBC6HS(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) { UNREFERENCED_PARAMETER(flags); @@ -2804,6 +2839,7 @@ void D3DXEncodeBC6HS(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) //------------------------------------------------------------------------------------- // BC7 Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void D3DXDecodeBC7(XMVECTOR *pColor, const uint8_t *pBC) { assert( pColor && pBC ); @@ -2811,6 +2847,7 @@ void D3DXDecodeBC7(XMVECTOR *pColor, const uint8_t *pBC) reinterpret_cast< const D3DX_BC7* >( pBC )->Decode(reinterpret_cast(pColor)); } +_Use_decl_annotations_ void D3DXEncodeBC7(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) { UNREFERENCED_PARAMETER(flags); @@ -2819,4 +2856,4 @@ void D3DXEncodeBC7(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) reinterpret_cast< D3DX_BC7* >( pBC )->Encode(reinterpret_cast(pColor)); } -} // namespace \ No newline at end of file +} // namespace diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h index 454664e..0e8dee5 100644 --- a/DirectXTex/DirectXTex.h +++ b/DirectXTex/DirectXTex.h @@ -27,10 +27,30 @@ #include #include -#define DIRECTX_TEX_VERSION 100 +#define DIRECTX_TEX_VERSION 101 + +#if defined(_MSC_VER) && (_MSC_VER<1610) && !defined(_In_reads_) +#define _Analysis_assume_(exp) +#define _In_reads_(exp) +#define _In_reads_opt_(exp) +#define _Out_writes_(exp) +#define _Out_writes_opt_(exp) +#define _In_reads_bytes_(exp) +#define _Out_writes_bytes_(exp) +#define _Out_writes_bytes_to_opt_(a,b) +#define _Inout_updates_bytes_(exp) +#define _Inout_updates_all_(exp) +#define _Outptr_ +#define _When_(a,b) +#endif + +#ifndef _Use_decl_annotations_ +#define _Use_decl_annotations_ +#endif namespace DirectX { + //--------------------------------------------------------------------------------- // DXGI Format Utilities bool IsValid( _In_ DXGI_FORMAT fmt ); @@ -66,9 +86,9 @@ namespace DirectX enum TEX_DIMENSION // Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION { - TEX_DIMENSION_TEXTURE1D = 2, - TEX_DIMENSION_TEXTURE2D = 3, - TEX_DIMENSION_TEXTURE3D = 4, + TEX_DIMENSION_TEXTURE1D = 2, + TEX_DIMENSION_TEXTURE2D = 3, + TEX_DIMENSION_TEXTURE3D = 4, }; enum TEX_MISC_FLAG @@ -147,17 +167,17 @@ namespace DirectX // Filtering mode to use for any required image resizing (only needed when loading arrays of differently sized images; defaults to Fant) }; - HRESULT GetMetadataFromDDSMemory( _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, + HRESULT GetMetadataFromDDSMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, _Out_ TexMetadata& metadata ); - HRESULT GetMetadataFromDDSFile( _In_z_ LPCWSTR szFile, DWORD flags, + HRESULT GetMetadataFromDDSFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags, _Out_ TexMetadata& metadata ); - HRESULT GetMetadataFromTGAMemory( _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, + HRESULT GetMetadataFromTGAMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _Out_ TexMetadata& metadata ); HRESULT GetMetadataFromTGAFile( _In_z_ LPCWSTR szFile, _Out_ TexMetadata& metadata ); - HRESULT GetMetadataFromWICMemory( _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, + HRESULT GetMetadataFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, _Out_ TexMetadata& metadata ); HRESULT GetMetadataFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags, _Out_ TexMetadata& metadata ); @@ -188,9 +208,9 @@ namespace DirectX HRESULT InitializeCube( _In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t nCubes, _In_ size_t mipLevels ); HRESULT InitializeFromImage( _In_ const Image& srcImage, _In_ bool allow1D = false ); - HRESULT InitializeArrayFromImages( _In_count_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false ); - HRESULT InitializeCubeFromImages( _In_count_(nImages) const Image* images, _In_ size_t nImages ); - HRESULT Initialize3DFromImages( _In_count_(depth) const Image* images, _In_ size_t depth ); + HRESULT InitializeArrayFromImages( _In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false ); + HRESULT InitializeCubeFromImages( _In_reads_(nImages) const Image* images, _In_ size_t nImages ); + HRESULT Initialize3DFromImages( _In_reads_(depth) const Image* images, _In_ size_t depth ); void Release(); @@ -245,21 +265,21 @@ namespace DirectX // Image I/O // DDS operations - HRESULT LoadFromDDSMemory( _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, + HRESULT LoadFromDDSMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image ); HRESULT LoadFromDDSFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image ); HRESULT SaveToDDSMemory( _In_ const Image& image, _In_ DWORD flags, _Out_ Blob& blob ); - HRESULT SaveToDDSMemory( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD flags, + HRESULT SaveToDDSMemory( _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD flags, _Out_ Blob& blob ); HRESULT SaveToDDSFile( _In_ const Image& image, _In_ DWORD flags, _In_z_ LPCWSTR szFile ); - HRESULT SaveToDDSFile( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD flags, _In_z_ LPCWSTR szFile ); + HRESULT SaveToDDSFile( _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD flags, _In_z_ LPCWSTR szFile ); // TGA operations - HRESULT LoadFromTGAMemory( _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, + HRESULT LoadFromTGAMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image ); HRESULT LoadFromTGAFile( _In_z_ LPCWSTR szFile, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image ); @@ -268,7 +288,7 @@ namespace DirectX HRESULT SaveToTGAFile( _In_ const Image& image, _In_z_ LPCWSTR szFile ); // WIC operations - HRESULT LoadFromWICMemory( _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, + HRESULT LoadFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image ); HRESULT LoadFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image ); @@ -310,7 +330,7 @@ namespace DirectX }; HRESULT FlipRotate( _In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image ); - HRESULT FlipRotate( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT FlipRotate( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DWORD flags, _Out_ ScratchImage& result ); // Flip and/or rotate image @@ -344,27 +364,27 @@ namespace DirectX HRESULT Resize( _In_ const Image& srcImage, _In_ size_t width, _In_ size_t height, _In_ DWORD filter, _Out_ ScratchImage& image ); - HRESULT Resize( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT 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 ); // Resize the image to width x height. Defaults to Fant filtering. // Note for a complex resize, the result will always have mipLevels == 1 HRESULT Convert( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage& image ); - HRESULT Convert( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT Convert( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage& result ); // Convert the image to a new format HRESULT GenerateMipMaps( _In_ const Image& baseImage, _In_ DWORD filter, _In_ size_t levels, - _Out_ ScratchImage& mipChain, bool allow1D = false ); - HRESULT GenerateMipMaps( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DWORD filter, _In_ size_t levels, _Out_ ScratchImage& mipChain ); + _Inout_ ScratchImage& mipChain, _In_ bool allow1D = false ); + HRESULT 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 ); // levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image) // Defaults to Fant filtering which is equivalent to a box filter - HRESULT GenerateMipMaps3D( _In_count_(depth) const Image* baseImages, _In_ size_t depth, _In_ DWORD filter, _In_ size_t levels, + HRESULT GenerateMipMaps3D( _In_reads_(depth) const Image* baseImages, _In_ size_t depth, _In_ DWORD filter, _In_ size_t levels, _Out_ ScratchImage& mipChain ); - HRESULT GenerateMipMaps3D( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT 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 ); // levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image) // Defaults to Fant filtering which is equivalent to a box filter @@ -391,12 +411,12 @@ namespace DirectX HRESULT Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImage ); - HRESULT Compress( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT Compress( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImages ); // Note that alphaRef is only used by BC1. 0.5f is a typical value to use HRESULT Decompress( _In_ const Image& cImage, _In_ DXGI_FORMAT format, _Out_ ScratchImage& image ); - HRESULT Decompress( _In_count_(nimages) const Image* cImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT Decompress( _In_reads_(nimages) const Image* cImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _Out_ ScratchImage& images ); //--------------------------------------------------------------------------------- @@ -428,7 +448,7 @@ namespace DirectX HRESULT ComputeNormalMap( _In_ const Image& srcImage, _In_ DWORD flags, _In_ float amplitude, _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMap ); - HRESULT ComputeNormalMap( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT 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 ); //--------------------------------------------------------------------------------- @@ -447,25 +467,25 @@ namespace DirectX HRESULT CopyRectangle( _In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage, _In_ DWORD filter, _In_ size_t xOffset, _In_ size_t yOffset ); - HRESULT ComputeMSE( _In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_opt_cap_c_(4) float* mseV ); + HRESULT ComputeMSE( _In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV ); //--------------------------------------------------------------------------------- // Direct3D 11 functions bool IsSupportedTexture( _In_ ID3D11Device* pDevice, _In_ const TexMetadata& metadata ); - HRESULT CreateTexture( _In_ ID3D11Device* pDevice, _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _Deref_out_ ID3D11Resource** ppResource ); + HRESULT CreateTexture( _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + _Outptr_ ID3D11Resource** ppResource ); - HRESULT CreateShaderResourceView( _In_ ID3D11Device* pDevice, _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _Deref_out_ ID3D11ShaderResourceView** ppSRV ); + HRESULT CreateShaderResourceView( _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + _Outptr_ ID3D11ShaderResourceView** ppSRV ); - HRESULT CreateTextureEx( _In_ ID3D11Device* pDevice, _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT CreateTextureEx( _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, - _Deref_out_ ID3D11Resource** ppResource ); + _Outptr_ ID3D11Resource** ppResource ); - HRESULT CreateShaderResourceViewEx( _In_ ID3D11Device* pDevice, _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT CreateShaderResourceViewEx( _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, - _Deref_out_ ID3D11ShaderResourceView** ppSRV ); + _Outptr_ ID3D11ShaderResourceView** ppSRV ); HRESULT CaptureTexture( _In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _Out_ ScratchImage& result ); diff --git a/DirectXTex/DirectXTex.inl b/DirectXTex/DirectXTex.inl index 781f90d..58fab3a 100644 --- a/DirectXTex/DirectXTex.inl +++ b/DirectXTex/DirectXTex.inl @@ -21,6 +21,7 @@ // DXGI Format Utilities //===================================================================================== +_Use_decl_annotations_ inline bool IsValid( DXGI_FORMAT fmt ) { #ifdef DXGI_1_2_FORMATS @@ -30,6 +31,7 @@ inline bool IsValid( DXGI_FORMAT fmt ) #endif } +_Use_decl_annotations_ inline bool IsCompressed( DXGI_FORMAT fmt ) { switch ( fmt ) @@ -62,11 +64,14 @@ inline bool IsCompressed( DXGI_FORMAT fmt ) } } +_Use_decl_annotations_ inline bool IsPacked( DXGI_FORMAT fmt ) { return ( (fmt == DXGI_FORMAT_R8G8_B8G8_UNORM) || (fmt == DXGI_FORMAT_G8R8_G8B8_UNORM) ); } + +_Use_decl_annotations_ inline bool IsVideo( DXGI_FORMAT fmt ) { #ifdef DXGI_1_2_FORMATS @@ -102,6 +107,7 @@ inline bool IsVideo( DXGI_FORMAT fmt ) #endif } +_Use_decl_annotations_ inline bool IsSRGB( DXGI_FORMAT fmt ) { switch( fmt ) @@ -120,6 +126,7 @@ inline bool IsSRGB( DXGI_FORMAT fmt ) } } +_Use_decl_annotations_ inline bool IsTypeless( DXGI_FORMAT fmt ) { switch( fmt ) @@ -157,7 +164,8 @@ inline bool IsTypeless( DXGI_FORMAT fmt ) } } -inline size_t ComputeScanlines( _In_ DXGI_FORMAT fmt, _In_ size_t height ) +_Use_decl_annotations_ +inline size_t ComputeScanlines( DXGI_FORMAT fmt, size_t height ) { switch ( fmt ) { @@ -192,6 +200,7 @@ inline size_t ComputeScanlines( _In_ DXGI_FORMAT fmt, _In_ size_t height ) //===================================================================================== // Image I/O //===================================================================================== +_Use_decl_annotations_ inline HRESULT SaveToDDSMemory( const Image& image, DWORD flags, Blob& blob ) { TexMetadata mdata; @@ -207,6 +216,7 @@ inline HRESULT SaveToDDSMemory( const Image& image, DWORD flags, Blob& blob ) return SaveToDDSMemory( &image, 1, mdata, flags, blob ); } +_Use_decl_annotations_ inline HRESULT SaveToDDSFile( const Image& image, DWORD flags, LPCWSTR szFile ) { TexMetadata mdata; diff --git a/DirectXTex/DirectXTexCompress.cpp b/DirectXTex/DirectXTexCompress.cpp index 573d3ad..19e8ec2 100644 --- a/DirectXTex/DirectXTexCompress.cpp +++ b/DirectXTex/DirectXTexCompress.cpp @@ -22,6 +22,7 @@ #include "bc.h" + namespace DirectX { @@ -432,6 +433,7 @@ static HRESULT _DecompressBC( _In_ const Image& cImage, _In_ const Image& result //------------------------------------------------------------------------------------- // Compression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT Compress( const Image& srcImage, DXGI_FORMAT format, DWORD compress, float alphaRef, ScratchImage& image ) { if ( IsCompressed(srcImage.format) || !IsCompressed(format) || IsTypeless(format) ) @@ -490,6 +492,7 @@ HRESULT Compress( const Image& srcImage, DXGI_FORMAT format, DWORD compress, flo return hr; } +_Use_decl_annotations_ HRESULT Compress( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DXGI_FORMAT format, DWORD compress, float alphaRef, ScratchImage& cImages ) { @@ -585,6 +588,7 @@ HRESULT Compress( const Image* srcImages, size_t nimages, const TexMetadata& met //------------------------------------------------------------------------------------- // Decompression //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT Decompress( const Image& cImage, DXGI_FORMAT format, ScratchImage& image ) { if ( IsCompressed(format) || IsTypeless(format) ) @@ -623,6 +627,7 @@ HRESULT Decompress( const Image& cImage, DXGI_FORMAT format, ScratchImage& image return hr; } +_Use_decl_annotations_ HRESULT Decompress( const Image* cImages, size_t nimages, const TexMetadata& metadata, DXGI_FORMAT format, ScratchImage& images ) { diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index 46e6db8..fb7ef23 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -30,7 +30,11 @@ namespace DirectX // Copies an image row with optional clearing of alpha value to 1.0 // (can be used in place as well) otherwise copies the image row unmodified. //------------------------------------------------------------------------------------- -void _CopyScanline( LPVOID pDestination, size_t outSize, LPCVOID pSource, size_t inSize, DXGI_FORMAT format, DWORD flags ) +void _CopyScanline(_When_(pDestination == pSource, _Inout_updates_bytes_(outSize)) + _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) + LPVOID pDestination, _In_ size_t outSize, + _In_reads_bytes_(inSize) LPCVOID pSource, _In_ size_t inSize, + _In_ DXGI_FORMAT format, _In_ DWORD flags) { assert( pDestination && outSize > 0 ); assert( pSource && inSize > 0 ); @@ -253,6 +257,7 @@ void _CopyScanline( LPVOID pDestination, size_t outSize, LPCVOID pSource, size_t // Swizzles (RGB <-> BGR) an image row with optional clearing of alpha value to 1.0 // (can be used in place as well) otherwise copies the image row unmodified. //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void _SwizzleScanline( LPVOID pDestination, size_t outSize, LPCVOID pSource, size_t inSize, DXGI_FORMAT format, DWORD flags ) { assert( pDestination && outSize > 0 ); @@ -365,6 +370,7 @@ void _SwizzleScanline( LPVOID pDestination, size_t outSize, LPCVOID pSource, siz // Converts an image row with optional clearing of alpha value to 1.0 // Returns true if supported, false if expansion case not supported //------------------------------------------------------------------------------------- +_Use_decl_annotations_ bool _ExpandScanline( LPVOID pDestination, size_t outSize, DXGI_FORMAT outFormat, LPCVOID pSource, size_t inSize, DXGI_FORMAT inFormat, DWORD flags ) { @@ -494,6 +500,7 @@ bool _ExpandScanline( LPVOID pDestination, size_t outSize, DXGI_FORMAT outFormat }\ return false; +_Use_decl_annotations_ bool _LoadScanline( XMVECTOR* pDestination, size_t count, LPCVOID pSource, size_t size, DXGI_FORMAT format ) { @@ -973,6 +980,7 @@ bool _LoadScanline( XMVECTOR* pDestination, size_t count, }\ return true; +_Use_decl_annotations_ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, const XMVECTOR* pSource, size_t count ) { @@ -1434,6 +1442,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, //------------------------------------------------------------------------------------- // Convert DXGI image to/from GUID_WICPixelFormat128bppRGBAFloat (no range conversions) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT _ConvertToR32G32B32A32( const Image& srcImage, ScratchImage& image ) { if ( !srcImage.pixels ) @@ -1473,7 +1482,8 @@ HRESULT _ConvertToR32G32B32A32( const Image& srcImage, ScratchImage& image ) return S_OK; } -HRESULT _ConvertFromR32G32B32A32( _In_ const Image& srcImage, _In_ const Image& destImage ) +_Use_decl_annotations_ +HRESULT _ConvertFromR32G32B32A32( const Image& srcImage, const Image& destImage ) { assert( srcImage.format == DXGI_FORMAT_R32G32B32A32_FLOAT ); @@ -1498,6 +1508,7 @@ HRESULT _ConvertFromR32G32B32A32( _In_ const Image& srcImage, _In_ const Image& return S_OK; } +_Use_decl_annotations_ HRESULT _ConvertFromR32G32B32A32( const Image& srcImage, DXGI_FORMAT format, ScratchImage& image ) { if ( !srcImage.pixels ) @@ -1524,6 +1535,7 @@ HRESULT _ConvertFromR32G32B32A32( const Image& srcImage, DXGI_FORMAT format, Scr return S_OK; } +_Use_decl_annotations_ HRESULT _ConvertFromR32G32B32A32( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DXGI_FORMAT format, ScratchImage& result ) { if ( !srcImages ) @@ -1816,6 +1828,7 @@ static int __cdecl _ConvertCompare( void *context, const void* ptr1, const void else return (p1->format < p2->format ) ? -1 : 1; } +_Use_decl_annotations_ DWORD _GetConvertFlags( DXGI_FORMAT format ) { #ifdef _DEBUG @@ -1835,6 +1848,7 @@ DWORD _GetConvertFlags( DXGI_FORMAT format ) return (in) ? in->flags : 0; } +_Use_decl_annotations_ void _ConvertScanline( XMVECTOR* pBuffer, size_t count, DXGI_FORMAT outFormat, DXGI_FORMAT inFormat, DWORD flags ) { assert( pBuffer && count > 0 && (((uintptr_t)pBuffer & 0xF) == 0) ); @@ -2031,7 +2045,7 @@ static HRESULT _ConvertUsingWIC( _In_ const Image& srcImage, _In_ const WICPixel if ( FAILED(hr) ) return hr; - // Need to implement usage of TEX_FILTER_SRGB_IN/TEX_FILTER_SRGB_OUT +// Need to add logic to use TEX_FILTER_SRGB_IN/TEX_FILTER_SRGB_OUT BOOL canConvert = FALSE; hr = FC->CanConvert( pfGUID, targetGUID, &canConvert ); @@ -2247,6 +2261,7 @@ static HRESULT _Convert( _In_ const Image& srcImage, _In_ DWORD filter, _In_ con //------------------------------------------------------------------------------------- // Convert image //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT Convert( const Image& srcImage, DXGI_FORMAT format, DWORD filter, float threshold, ScratchImage& image ) { if ( (srcImage.format == format) || !IsValid( format ) ) @@ -2319,6 +2334,7 @@ HRESULT Convert( const Image& srcImage, DXGI_FORMAT format, DWORD filter, float //------------------------------------------------------------------------------------- // Convert image (complex) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT Convert( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DXGI_FORMAT format, DWORD filter, float threshold, ScratchImage& result ) { diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index e9959a5..97b2b23 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -150,6 +150,7 @@ static HRESULT _Capture( _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource //------------------------------------------------------------------------------------- // Determine if given texture metadata is supported on the given device //------------------------------------------------------------------------------------- +_Use_decl_annotations_ bool IsSupportedTexture( ID3D11Device* pDevice, const TexMetadata& metadata ) { if ( !pDevice ) @@ -336,6 +337,7 @@ bool IsSupportedTexture( ID3D11Device* pDevice, const TexMetadata& metadata ) //------------------------------------------------------------------------------------- // Create a texture resource //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT CreateTexture( ID3D11Device* pDevice, const Image* srcImages, size_t nimages, const TexMetadata& metadata, ID3D11Resource** ppResource ) { @@ -344,6 +346,7 @@ HRESULT CreateTexture( ID3D11Device* pDevice, const Image* srcImages, size_t nim ppResource ); } +_Use_decl_annotations_ HRESULT CreateTextureEx( ID3D11Device* pDevice, const Image* srcImages, size_t nimages, const TexMetadata& metadata, D3D11_USAGE usage, unsigned int bindFlags, unsigned int cpuAccessFlags, unsigned int miscFlags, ID3D11Resource** ppResource ) @@ -530,6 +533,7 @@ HRESULT CreateTextureEx( ID3D11Device* pDevice, const Image* srcImages, size_t n //------------------------------------------------------------------------------------- // Create a shader resource view and associated texture //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT CreateShaderResourceView( ID3D11Device* pDevice, const Image* srcImages, size_t nimages, const TexMetadata& metadata, ID3D11ShaderResourceView** ppSRV ) { @@ -538,7 +542,7 @@ HRESULT CreateShaderResourceView( ID3D11Device* pDevice, const Image* srcImages, ppSRV ); } - +_Use_decl_annotations_ HRESULT CreateShaderResourceViewEx( ID3D11Device* pDevice, const Image* srcImages, size_t nimages, const TexMetadata& metadata, D3D11_USAGE usage, unsigned int bindFlags, unsigned int cpuAccessFlags, unsigned int miscFlags, ID3D11ShaderResourceView** ppSRV ) @@ -627,6 +631,7 @@ HRESULT CreateShaderResourceViewEx( ID3D11Device* pDevice, const Image* srcImage //------------------------------------------------------------------------------------- // Save a texture resource to a DDS file in memory/on disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT CaptureTexture( ID3D11Device* pDevice, ID3D11DeviceContext* pContext, ID3D11Resource* pSource, ScratchImage& result ) { if ( !pDevice || !pContext || !pSource ) diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index fc7ff93..141cac8 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -202,7 +202,7 @@ static DXGI_FORMAT _GetDXGIFormat( const DDS_PIXELFORMAT& ddpf, DWORD flags, _In //------------------------------------------------------------------------------------- // Decodes DDS header including optional DX10 extended header //------------------------------------------------------------------------------------- -static HRESULT _DecodeDDSHeader( _In_bytecount_(size) LPCVOID pSource, size_t size, DWORD flags, _Out_ TexMetadata& metadata, +static HRESULT _DecodeDDSHeader( _In_reads_bytes_(size) LPCVOID pSource, size_t size, DWORD flags, _Out_ TexMetadata& metadata, _Inout_opt_ DWORD* convFlags ) { if ( !pSource ) @@ -417,8 +417,9 @@ static HRESULT _DecodeDDSHeader( _In_bytecount_(size) LPCVOID pSource, size_t si //------------------------------------------------------------------------------------- // Encodes DDS file header (magic value, header, optional DX10 extended header) //------------------------------------------------------------------------------------- -HRESULT _EncodeDDSHeader( _In_ const TexMetadata& metadata, DWORD flags, - _Out_opt_cap_x_(maxsize) LPVOID pDestination, _In_ size_t maxsize, _Out_ size_t& required ) +_Use_decl_annotations_ +HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags, + LPVOID pDestination, size_t maxsize, size_t& required ) { assert( IsValid( metadata.format ) && !IsVideo( metadata.format ) ); @@ -668,9 +669,10 @@ inline static TEXP_LEGACY_FORMAT _FindLegacyFormat( DWORD flags ) return lformat; } -static bool _LegacyExpandScanline( _Out_bytecap_(outSize) LPVOID pDestination, size_t outSize, _In_ DXGI_FORMAT outFormat, - _In_bytecount_(inSize) LPCVOID pSource, size_t inSize, _In_ TEXP_LEGACY_FORMAT inFormat, - _In_opt_count_c_(256) const uint32_t* pal8, _In_ DWORD flags ) +_Success_(return != false) +static bool _LegacyExpandScanline( _Out_writes_bytes_(outSize) LPVOID pDestination, size_t outSize, _In_ DXGI_FORMAT outFormat, + _In_reads_bytes_(inSize) LPCVOID pSource, size_t inSize, _In_ TEXP_LEGACY_FORMAT inFormat, + _In_reads_opt_(256) const uint32_t* pal8, _In_ DWORD flags ) { assert( pDestination && outSize > 0 ); assert( pSource && inSize > 0 ); @@ -881,8 +883,8 @@ static bool _LegacyExpandScanline( _Out_bytecap_(outSize) LPVOID pDestination, s //------------------------------------------------------------------------------------- // Converts or copies image data from pPixels into scratch image data //------------------------------------------------------------------------------------- -static HRESULT _CopyImage( _In_bytecount_(size) const void* pPixels, _In_ size_t size, - _In_ const TexMetadata& metadata, _In_ DWORD cpFlags, _In_ DWORD convFlags, _In_opt_count_c_(256) const uint32_t *pal8, _In_ const ScratchImage& image ) +static HRESULT _CopyImage( _In_reads_bytes_(size) const void* pPixels, _In_ size_t size, + _In_ const TexMetadata& metadata, _In_ DWORD cpFlags, _In_ DWORD convFlags, _In_reads_opt_(256) const uint32_t *pal8, _In_ const ScratchImage& image ) { assert( pPixels ); assert( image.GetPixels() ); @@ -1146,6 +1148,7 @@ static HRESULT _CopyImageInPlace( DWORD convFlags, _In_ const ScratchImage& imag // Obtain metadata from DDS file in memory/on disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT GetMetadataFromDDSMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata& metadata ) { if ( !pSource || size == 0 ) @@ -1154,6 +1157,7 @@ HRESULT GetMetadataFromDDSMemory( LPCVOID pSource, size_t size, DWORD flags, Tex return _DecodeDDSHeader( pSource, size, flags, metadata, 0 ); } +_Use_decl_annotations_ HRESULT GetMetadataFromDDSFile( LPCWSTR szFile, DWORD flags, TexMetadata& metadata ) { if ( !szFile ) @@ -1216,6 +1220,7 @@ HRESULT GetMetadataFromDDSFile( LPCWSTR szFile, DWORD flags, TexMetadata& metada //------------------------------------------------------------------------------------- // Load a DDS file in memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT LoadFromDDSMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata* metadata, ScratchImage& image ) { if ( !pSource || size == 0 ) @@ -1268,6 +1273,7 @@ HRESULT LoadFromDDSMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadat //------------------------------------------------------------------------------------- // Load a DDS file from disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT LoadFromDDSFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, ScratchImage& image ) { if ( !szFile ) @@ -1442,6 +1448,7 @@ HRESULT LoadFromDDSFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, Scr //------------------------------------------------------------------------------------- // Save a DDS file to memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT SaveToDDSMemory( const Image* images, size_t nimages, const TexMetadata& metadata, DWORD flags, Blob& blob ) { if ( !images || (nimages == 0) ) @@ -1569,6 +1576,7 @@ HRESULT SaveToDDSMemory( const Image* images, size_t nimages, const TexMetadata& //------------------------------------------------------------------------------------- // Save a DDS file to disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT SaveToDDSFile( const Image* images, size_t nimages, const TexMetadata& metadata, DWORD flags, LPCWSTR szFile ) { if ( !szFile ) diff --git a/DirectXTex/DirectXTexFlipRotate.cpp b/DirectXTex/DirectXTexFlipRotate.cpp index 34414fb..fdd1fa7 100644 --- a/DirectXTex/DirectXTexFlipRotate.cpp +++ b/DirectXTex/DirectXTexFlipRotate.cpp @@ -126,6 +126,7 @@ static HRESULT _PerformFlipRotateViaF32( _In_ const Image& srcImage, _In_ DWORD //------------------------------------------------------------------------------------- // Flip/rotate image //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT FlipRotate( const Image& srcImage, DWORD flags, ScratchImage& image ) { if ( !srcImage.pixels ) @@ -207,6 +208,7 @@ HRESULT FlipRotate( const Image& srcImage, DWORD flags, ScratchImage& image ) //------------------------------------------------------------------------------------- // Flip/rotate image (complex) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT FlipRotate( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DWORD flags, ScratchImage& result ) { diff --git a/DirectXTex/DirectXTexImage.cpp b/DirectXTex/DirectXTexImage.cpp index ded0362..bc064ce 100644 --- a/DirectXTex/DirectXTexImage.cpp +++ b/DirectXTex/DirectXTexImage.cpp @@ -24,6 +24,7 @@ extern bool _CalculateMipLevels3D( _In_ size_t width, _In_ size_t height, _In_ s //------------------------------------------------------------------------------------- // Determines number of image array entries and pixel size //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void _DetermineImageArray( const TexMetadata& metadata, DWORD cpFlags, size_t& nImages, size_t& pixelSize ) { @@ -102,6 +103,7 @@ void _DetermineImageArray( const TexMetadata& metadata, DWORD cpFlags, //------------------------------------------------------------------------------------- // Fills in the image array entries //------------------------------------------------------------------------------------- +_Use_decl_annotations_ bool _SetupImageArray( uint8_t *pMemory, size_t pixelSize, const TexMetadata& metadata, DWORD cpFlags, Image* images, size_t nImages ) @@ -229,6 +231,7 @@ bool _SetupImageArray( uint8_t *pMemory, size_t pixelSize, //------------------------------------------------------------------------------------- // Methods //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT ScratchImage::Initialize( const TexMetadata& mdata ) { if ( !IsValid(mdata.format) || IsVideo(mdata.format) ) @@ -309,6 +312,7 @@ HRESULT ScratchImage::Initialize( const TexMetadata& mdata ) return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::Initialize1D( DXGI_FORMAT fmt, size_t length, size_t arraySize, size_t mipLevels ) { if ( !IsValid(fmt) || IsVideo(fmt) || !length || !arraySize ) @@ -324,6 +328,7 @@ HRESULT ScratchImage::Initialize1D( DXGI_FORMAT fmt, size_t length, size_t array return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::Initialize2D( DXGI_FORMAT fmt, size_t width, size_t height, size_t arraySize, size_t mipLevels ) { if ( !IsValid(fmt) || IsVideo(fmt) || !width || !height || !arraySize ) @@ -369,6 +374,7 @@ HRESULT ScratchImage::Initialize2D( DXGI_FORMAT fmt, size_t width, size_t height return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::Initialize3D( DXGI_FORMAT fmt, size_t width, size_t height, size_t depth, size_t mipLevels ) { if ( !IsValid(fmt) || IsVideo(fmt) || !width || !height || !depth ) @@ -417,6 +423,7 @@ HRESULT ScratchImage::Initialize3D( DXGI_FORMAT fmt, size_t width, size_t height return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::InitializeCube( DXGI_FORMAT fmt, size_t width, size_t height, size_t nCubes, size_t mipLevels ) { if ( !IsValid(fmt) || IsVideo(fmt) || !width || !height || !nCubes ) @@ -432,6 +439,7 @@ HRESULT ScratchImage::InitializeCube( DXGI_FORMAT fmt, size_t width, size_t heig return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::InitializeFromImage( const Image& srcImage, bool allow1D ) { HRESULT hr = ( srcImage.height > 1 || !allow1D ) @@ -459,6 +467,7 @@ HRESULT ScratchImage::InitializeFromImage( const Image& srcImage, bool allow1D ) return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::InitializeArrayFromImages( const Image* images, size_t nImages, bool allow1D ) { if ( !images || !nImages ) @@ -509,6 +518,7 @@ HRESULT ScratchImage::InitializeArrayFromImages( const Image* images, size_t nIm return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::InitializeCubeFromImages( const Image* images, size_t nImages ) { if ( !images || !nImages ) @@ -527,6 +537,7 @@ HRESULT ScratchImage::InitializeCubeFromImages( const Image* images, size_t nIma return S_OK; } +_Use_decl_annotations_ HRESULT ScratchImage::Initialize3DFromImages( const Image* images, size_t depth ) { if ( !images || !depth ) @@ -594,6 +605,7 @@ void ScratchImage::Release() memset(&_metadata, 0, sizeof(_metadata)); } +_Use_decl_annotations_ bool ScratchImage::OverrideFormat( DXGI_FORMAT f ) { if ( !_image ) @@ -620,6 +632,7 @@ bool ScratchImage::OverrideFormat( DXGI_FORMAT f ) return true; } +_Use_decl_annotations_ const Image* ScratchImage::GetImage(size_t mip, size_t item, size_t slice) const { if ( mip >= _metadata.mipLevels ) diff --git a/DirectXTex/DirectXTexMipmaps.cpp b/DirectXTex/DirectXTexMipmaps.cpp index 9d27361..a77630d 100644 --- a/DirectXTex/DirectXTexMipmaps.cpp +++ b/DirectXTex/DirectXTexMipmaps.cpp @@ -29,7 +29,7 @@ inline static bool ispow2( _In_ size_t x ) return ((x != 0) && !(x & (x - 1))); } -static size_t _CountMips( _In_ size_t width, _In_ size_t height) +static size_t _CountMips( _In_ size_t width, _In_ size_t height ) { size_t mipLevels = 1; @@ -66,7 +66,7 @@ bool _CalculateMipLevels( _In_ size_t width, _In_ size_t height, _Inout_ size_t& return true; } -static size_t _CountMips3D( _In_ size_t width, _In_ size_t height, _In_ size_t depth) +static size_t _CountMips3D( _In_ size_t width, _In_ size_t height, _In_ size_t depth ) { size_t mipLevels = 1; @@ -337,6 +337,7 @@ HRESULT _ResizeSeparateColorAndAlpha( _In_ IWICImagingFactory* pWIC, _In_ IWICBi } else { +#pragma prefast( suppress : 26014, "No overflow possible here" ); memcpy_s( colorWithAlphaData + colorWithAlphaIndex, colorWithAlphaBytesPerPixel, colorData + colorIndex, colorBytesInPixel ); } } @@ -486,7 +487,7 @@ static HRESULT _GenerateMipMapsUsingWIC( _In_ const Image& baseImage, _In_ DWORD //------------------------------------------------------------------------------------- // Generate volume mip-map helpers //------------------------------------------------------------------------------------- -static HRESULT _Setup3DMips( _In_count_(depth) const Image* baseImages, _In_ size_t depth, size_t levels, +static HRESULT _Setup3DMips( _In_reads_(depth) const Image* baseImages, _In_ size_t depth, size_t levels, _Out_ ScratchImage& mipChain ) { if ( !baseImages || !depth ) @@ -841,6 +842,7 @@ static HRESULT _Generate3DMipsBoxFilter( _In_ size_t depth, _In_ size_t levels, //------------------------------------------------------------------------------------- // Generate mipmap chain //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT GenerateMipMaps( const Image& baseImage, DWORD filter, size_t levels, ScratchImage& mipChain, bool allow1D ) { if ( !IsValid( baseImage.format ) ) @@ -908,6 +910,7 @@ HRESULT GenerateMipMaps( const Image& baseImage, DWORD filter, size_t levels, Sc } } +_Use_decl_annotations_ HRESULT GenerateMipMaps( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DWORD filter, size_t levels, ScratchImage& mipChain ) { @@ -1010,6 +1013,7 @@ HRESULT GenerateMipMaps( const Image* srcImages, size_t nimages, const TexMetada //------------------------------------------------------------------------------------- // Generate mipmap chain for volume texture //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT GenerateMipMaps3D( const Image* baseImages, size_t depth, DWORD filter, size_t levels, ScratchImage& mipChain ) { if ( !baseImages || !depth ) @@ -1083,6 +1087,7 @@ HRESULT GenerateMipMaps3D( const Image* baseImages, size_t depth, DWORD filter, } } +_Use_decl_annotations_ HRESULT GenerateMipMaps3D( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DWORD filter, size_t levels, ScratchImage& mipChain ) { diff --git a/DirectXTex/DirectXTexMisc.cpp b/DirectXTex/DirectXTexMisc.cpp index cddf734..118ad0e 100644 --- a/DirectXTex/DirectXTexMisc.cpp +++ b/DirectXTex/DirectXTexMisc.cpp @@ -20,7 +20,7 @@ namespace DirectX //------------------------------------------------------------------------------------- static HRESULT _ComputeMSE( _In_ const Image& image1, _In_ const Image& image2, - _Out_ float& mse, _Out_opt_cap_c_(4) float* mseV ) + _Out_ float& mse, _Out_writes_opt_(4) float* mseV ) { if ( !image1.pixels || !image2.pixels ) return E_POINTER; @@ -89,6 +89,7 @@ static HRESULT _ComputeMSE( _In_ const Image& image1, _In_ const Image& image2, //------------------------------------------------------------------------------------- // Copies a rectangle from one image into another //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT CopyRectangle( const Image& srcImage, const Rect& srcRect, const Image& dstImage, DWORD filter, size_t xOffset, size_t yOffset ) { if ( !srcImage.pixels || !dstImage.pixels ) @@ -193,6 +194,7 @@ HRESULT CopyRectangle( const Image& srcImage, const Rect& srcRect, const Image& //------------------------------------------------------------------------------------- // Computes the Mean-Squared-Error (MSE) between two images //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT ComputeMSE( const Image& image1, const Image& image2, float& mse, float* mseV ) { if ( !image1.pixels || !image2.pixels ) diff --git a/DirectXTex/DirectXTexNormalMaps.cpp b/DirectXTex/DirectXTexNormalMaps.cpp index 19d5a95..7822bdf 100644 --- a/DirectXTex/DirectXTexNormalMaps.cpp +++ b/DirectXTex/DirectXTexNormalMaps.cpp @@ -48,7 +48,7 @@ static inline float _EvaluateColor( _In_ FXMVECTOR val, _In_ DWORD flags ) } } -static void _EvaluateRow( _In_count_(width) const XMVECTOR* pSource, _Out_cap_(width+2) float* pDest, +static void _EvaluateRow( _In_reads_(width) const XMVECTOR* pSource, _Out_writes_(width+2) float* pDest, _In_ size_t width, _In_ DWORD flags ) { assert( pSource && pDest ); @@ -253,6 +253,7 @@ static HRESULT _ComputeNMap( _In_ const Image& srcImage, _In_ DWORD flags, _In_ //------------------------------------------------------------------------------------- // Generates a normal map from a height-map //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT ComputeNormalMap( const Image& srcImage, DWORD flags, float amplitude, DXGI_FORMAT format, ScratchImage& normalMap ) { @@ -301,6 +302,7 @@ HRESULT ComputeNormalMap( const Image& srcImage, DWORD flags, float amplitude, return S_OK; } +_Use_decl_annotations_ HRESULT ComputeNormalMap( const Image* srcImages, size_t nimages, const TexMetadata& metadata, DWORD flags, float amplitude, DXGI_FORMAT format, ScratchImage& normalMaps ) { diff --git a/DirectXTex/DirectXTexP.h b/DirectXTex/DirectXTexP.h index dec2b8c..de1a6c5 100644 --- a/DirectXTex/DirectXTexP.h +++ b/DirectXTex/DirectXTexP.h @@ -122,9 +122,10 @@ namespace DirectX void _DetermineImageArray( _In_ const TexMetadata& metadata, _In_ DWORD cpFlags, _Out_ size_t& nImages, _Out_ size_t& pixelSize ); - bool _SetupImageArray( _In_bytecount_(pixelSize) uint8_t *pMemory, _In_ size_t pixelSize, + _Success_(return != false) + bool _SetupImageArray( _In_reads_bytes_(pixelSize) uint8_t *pMemory, _In_ size_t pixelSize, _In_ const TexMetadata& metadata, _In_ DWORD cpFlags, - _Out_cap_(nImages) Image* images, _In_ size_t nImages ); + _Out_writes_(nImages) Image* images, _In_ size_t nImages ); //--------------------------------------------------------------------------------- // Conversion helper functions @@ -160,38 +161,45 @@ namespace DirectX DWORD _GetConvertFlags( _In_ DXGI_FORMAT format ); - void _CopyScanline( _Out_bytecap_(outSize) LPVOID pDestination, _In_ size_t outSize, - _In_bytecount_(inSize) LPCVOID pSource, _In_ size_t inSize, + void _CopyScanline( _When_(pDestination == pSource, _Inout_updates_bytes_(outSize)) + _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) + LPVOID pDestination, _In_ size_t outSize, + _In_reads_bytes_(inSize) LPCVOID pSource, _In_ size_t inSize, _In_ DXGI_FORMAT format, _In_ DWORD flags ); - void _SwizzleScanline( _Out_bytecap_(outSize) LPVOID pDestination, _In_ size_t outSize, - _In_bytecount_(inSize) LPCVOID pSource, _In_ size_t inSize, + void _SwizzleScanline( _When_(pDestination == pSource, _In_) + _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) + LPVOID pDestination, _In_ size_t outSize, + _In_reads_bytes_(inSize) LPCVOID pSource, _In_ size_t inSize, _In_ DXGI_FORMAT format, _In_ DWORD flags ); - bool _ExpandScanline( _Out_bytecap_(outSize) LPVOID pDestination, _In_ size_t outSize, + _Success_(return != false) + bool _ExpandScanline( _Out_writes_bytes_(outSize) LPVOID pDestination, _In_ size_t outSize, _In_ DXGI_FORMAT outFormat, - _In_bytecount_(inSize) LPCVOID pSource, _In_ size_t inSize, + _In_reads_bytes_(inSize) LPCVOID pSource, _In_ size_t inSize, _In_ DXGI_FORMAT inFormat, _In_ DWORD flags ); - bool _LoadScanline( _Out_cap_(count) XMVECTOR* pDestination, _In_ size_t count, - _In_bytecount_(size) LPCVOID pSource, _In_ size_t size, _In_ DXGI_FORMAT format ); + _Success_(return != false) + bool _LoadScanline( _Out_writes_(count) XMVECTOR* pDestination, _In_ size_t count, + _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DXGI_FORMAT format ); - bool _StoreScanline( _Out_bytecap_(size) LPVOID pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, - _In_count_(count) const XMVECTOR* pSource, _In_ size_t count ); + _Success_(return != false) + bool _StoreScanline( LPVOID pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, + _In_reads_(count) const XMVECTOR* pSource, _In_ size_t count ); HRESULT _ConvertToR32G32B32A32( _In_ const Image& srcImage, _Inout_ ScratchImage& image ); HRESULT _ConvertFromR32G32B32A32( _In_ const Image& srcImage, _In_ const Image& destImage ); HRESULT _ConvertFromR32G32B32A32( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _Inout_ ScratchImage& image ); - HRESULT _ConvertFromR32G32B32A32( _In_count_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, + HRESULT _ConvertFromR32G32B32A32( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _Out_ ScratchImage& result ); - void _ConvertScanline( _Inout_count_(count) XMVECTOR* pBuffer, _In_ size_t count, + void _ConvertScanline( _Inout_updates_all_(count) XMVECTOR* pBuffer, _In_ size_t count, _In_ DXGI_FORMAT outFormat, _In_ DXGI_FORMAT inFormat, _In_ DWORD flags ); //--------------------------------------------------------------------------------- // DDS helper functions HRESULT _EncodeDDSHeader( _In_ const TexMetadata& metadata, DWORD flags, - _Out_opt_cap_x_(maxsize) LPVOID pDestination, _In_ size_t maxsize, _Out_ size_t& required ); + _Out_writes_bytes_to_opt_(maxsize, required) LPVOID pDestination, _In_ size_t maxsize, _Out_ size_t& required ); }; // namespace diff --git a/DirectXTex/DirectXTexResize.cpp b/DirectXTex/DirectXTexResize.cpp index 7952ae4..0991f09 100644 --- a/DirectXTex/DirectXTexResize.cpp +++ b/DirectXTex/DirectXTexResize.cpp @@ -159,6 +159,7 @@ static HRESULT _PerformResizeViaF32( _In_ const Image& srcImage, _In_ DWORD filt //------------------------------------------------------------------------------------- // Resize image //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT Resize( const Image& srcImage, size_t width, size_t height, DWORD filter, ScratchImage& image ) { if ( width == 0 || height == 0 ) @@ -216,6 +217,7 @@ HRESULT Resize( const Image& srcImage, size_t width, size_t height, DWORD filter //------------------------------------------------------------------------------------- // Resize image (complex) //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT Resize( const Image* srcImages, size_t nimages, const TexMetadata& metadata, size_t width, size_t height, DWORD filter, ScratchImage& result ) { diff --git a/DirectXTex/DirectXTexTGA.cpp b/DirectXTex/DirectXTexTGA.cpp index 564d2ee..4de2619 100644 --- a/DirectXTex/DirectXTexTGA.cpp +++ b/DirectXTex/DirectXTexTGA.cpp @@ -116,7 +116,7 @@ namespace DirectX //------------------------------------------------------------------------------------- // Decodes TGA header //------------------------------------------------------------------------------------- -static HRESULT _DecodeTGAHeader( _In_bytecount_(size) LPCVOID pSource, size_t size, _Out_ TexMetadata& metadata, size_t& offset, +static HRESULT _DecodeTGAHeader( _In_reads_bytes_(size) LPCVOID pSource, size_t size, _Out_ TexMetadata& metadata, size_t& offset, _Inout_opt_ DWORD* convFlags ) { if ( !pSource ) @@ -253,7 +253,7 @@ static HRESULT _SetAlphaChannelToOpaque( _In_ const Image* image ) //------------------------------------------------------------------------------------- // Uncompress pixel data from a TGA into the target image //------------------------------------------------------------------------------------- -static HRESULT _UncompressPixels( _In_bytecount_(size) LPCVOID pSource, size_t size, _In_ const Image* image, DWORD convFlags ) +static HRESULT _UncompressPixels( _In_reads_bytes_(size) LPCVOID pSource, size_t size, _In_ const Image* image, _In_ DWORD convFlags ) { assert( pSource && size > 0 ); @@ -573,7 +573,7 @@ static HRESULT _UncompressPixels( _In_bytecount_(size) LPCVOID pSource, size_t s //------------------------------------------------------------------------------------- // Copies pixel data from a TGA into the target image //------------------------------------------------------------------------------------- -static HRESULT _CopyPixels( _In_bytecount_(size) LPCVOID pSource, size_t size, _In_ const Image* image, DWORD convFlags ) +static HRESULT _CopyPixels( _In_reads_bytes_(size) LPCVOID pSource, size_t size, _In_ const Image* image, _In_ DWORD convFlags ) { assert( pSource && size > 0 ); @@ -737,7 +737,7 @@ static HRESULT _CopyPixels( _In_bytecount_(size) LPCVOID pSource, size_t size, _ //------------------------------------------------------------------------------------- // Encodes TGA file header //------------------------------------------------------------------------------------- -static HRESULT _EncodeTGAHeader( _In_ const Image& image, _Out_ TGA_HEADER& header, DWORD& convFlags ) +static HRESULT _EncodeTGAHeader( _In_ const Image& image, _Out_ TGA_HEADER& header, _Inout_ DWORD& convFlags ) { assert( IsValid( image.format ) && !IsVideo( image.format ) ); @@ -802,8 +802,8 @@ static HRESULT _EncodeTGAHeader( _In_ const Image& image, _Out_ TGA_HEADER& head // Copies BGRX data to form BGR 24bpp data //------------------------------------------------------------------------------------- #pragma warning(suppress: 6001 6101) // In the case where outSize is insufficient we do not write to pDestination -static void _Copy24bppScanline( _Out_bytecap_(outSize) LPVOID pDestination, _In_ size_t outSize, - _In_bytecount_(inSize) LPCVOID pSource, _In_ size_t inSize ) +static void _Copy24bppScanline( _Out_writes_bytes_(outSize) LPVOID pDestination, _In_ size_t outSize, + _In_reads_bytes_(inSize) LPCVOID pSource, _In_ size_t inSize ) { assert( pDestination && outSize > 0 ); assert( pSource && inSize > 0 ); @@ -836,6 +836,7 @@ static void _Copy24bppScanline( _Out_bytecap_(outSize) LPVOID pDestination, _In_ //------------------------------------------------------------------------------------- // Obtain metadata from TGA file in memory/on disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT GetMetadataFromTGAMemory( LPCVOID pSource, size_t size, TexMetadata& metadata ) { if ( !pSource || size == 0 ) @@ -845,6 +846,7 @@ HRESULT GetMetadataFromTGAMemory( LPCVOID pSource, size_t size, TexMetadata& met return _DecodeTGAHeader( pSource, size, metadata, offset, 0 ); } +_Use_decl_annotations_ HRESULT GetMetadataFromTGAFile( LPCWSTR szFile, TexMetadata& metadata ) { if ( !szFile ) @@ -906,6 +908,7 @@ HRESULT GetMetadataFromTGAFile( LPCWSTR szFile, TexMetadata& metadata ) //------------------------------------------------------------------------------------- // Load a TGA file in memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT LoadFromTGAMemory( LPCVOID pSource, size_t size, TexMetadata* metadata, ScratchImage& image ) { if ( !pSource || size == 0 ) @@ -959,6 +962,7 @@ HRESULT LoadFromTGAMemory( LPCVOID pSource, size_t size, TexMetadata* metadata, //------------------------------------------------------------------------------------- // Load a TGA file from disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT LoadFromTGAFile( LPCWSTR szFile, TexMetadata* metadata, ScratchImage& image ) { if ( !szFile ) @@ -1208,6 +1212,7 @@ HRESULT LoadFromTGAFile( LPCWSTR szFile, TexMetadata* metadata, ScratchImage& im //------------------------------------------------------------------------------------- // Save a TGA file to memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT SaveToTGAMemory( const Image& image, Blob& blob ) { if ( !image.pixels ) @@ -1273,6 +1278,7 @@ HRESULT SaveToTGAMemory( const Image& image, Blob& blob ) //------------------------------------------------------------------------------------- // Save a TGA file to disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT SaveToTGAFile( const Image& image, LPCWSTR szFile ) { if ( !szFile ) diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index 4ee83c3..842bec0 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -61,6 +61,7 @@ namespace DirectX // WIC Utilities //===================================================================================== +_Use_decl_annotations_ DXGI_FORMAT _WICToDXGI( const GUID& guid ) { for( size_t i=0; i < _countof(g_WICFormats); ++i ) @@ -80,6 +81,7 @@ DXGI_FORMAT _WICToDXGI( const GUID& guid ) return DXGI_FORMAT_UNKNOWN; } +_Use_decl_annotations_ bool _DXGIToWIC( DXGI_FORMAT format, GUID& guid ) { switch( format ) @@ -195,7 +197,8 @@ IWICImagingFactory* _GetWIC() //------------------------------------------------------------------------------------- // Public helper function to get common WIC codec GUIDs //------------------------------------------------------------------------------------- -REFGUID GetWICCodec( _In_ WICCodecs codec ) +_Use_decl_annotations_ +REFGUID GetWICCodec( WICCodecs codec ) { switch( codec ) { @@ -233,6 +236,7 @@ REFGUID GetWICCodec( _In_ WICCodecs codec ) //------------------------------------------------------------------------------------- // Returns bits-per-pixel for a given DXGI format, or 0 on failure //------------------------------------------------------------------------------------- +_Use_decl_annotations_ size_t BitsPerPixel( DXGI_FORMAT fmt ) { switch( fmt ) @@ -359,7 +363,6 @@ size_t BitsPerPixel( DXGI_FORMAT fmt ) return 16; // We don't support the video formats ( see IsVideo function ) - #endif // DXGI_1_2_FORMATS default: @@ -372,6 +375,7 @@ size_t BitsPerPixel( DXGI_FORMAT fmt ) // Computes the image row pitch in bytes, and the slice ptich (size in bytes of the image) // based on DXGI format, width, and height //------------------------------------------------------------------------------------- +_Use_decl_annotations_ void ComputePitch( DXGI_FORMAT fmt, size_t width, size_t height, size_t& rowPitch, size_t& slicePitch, DWORD flags ) { @@ -429,7 +433,8 @@ void ComputePitch( DXGI_FORMAT fmt, size_t width, size_t height, //------------------------------------------------------------------------------------- // Converts to an SRGB equivalent type if available //------------------------------------------------------------------------------------- -DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT fmt ) +_Use_decl_annotations_ +DXGI_FORMAT MakeSRGB( DXGI_FORMAT fmt ) { switch( fmt ) { @@ -463,7 +468,8 @@ DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT fmt ) //------------------------------------------------------------------------------------- // Converts to a format to an equivalent TYPELESS format if available //------------------------------------------------------------------------------------- -DXGI_FORMAT MakeTypeless( _In_ DXGI_FORMAT fmt ) +_Use_decl_annotations_ +DXGI_FORMAT MakeTypeless( DXGI_FORMAT fmt ) { switch( fmt ) { @@ -579,7 +585,8 @@ DXGI_FORMAT MakeTypeless( _In_ DXGI_FORMAT fmt ) //------------------------------------------------------------------------------------- // Converts to a TYPELESS format to an equivalent UNORM format if available //------------------------------------------------------------------------------------- -DXGI_FORMAT MakeTypelessUNORM( _In_ DXGI_FORMAT fmt ) +_Use_decl_annotations_ +DXGI_FORMAT MakeTypelessUNORM( DXGI_FORMAT fmt ) { switch( fmt ) { @@ -637,7 +644,8 @@ DXGI_FORMAT MakeTypelessUNORM( _In_ DXGI_FORMAT fmt ) //------------------------------------------------------------------------------------- // Converts to a TYPELESS format to an equivalent FLOAT format if available //------------------------------------------------------------------------------------- -DXGI_FORMAT MakeTypelessFLOAT( _In_ DXGI_FORMAT fmt ) +_Use_decl_annotations_ +DXGI_FORMAT MakeTypelessFLOAT( DXGI_FORMAT fmt ) { switch( fmt ) { @@ -672,7 +680,8 @@ DXGI_FORMAT MakeTypelessFLOAT( _In_ DXGI_FORMAT fmt ) // TexMetadata //===================================================================================== -size_t TexMetadata::ComputeIndex( _In_ size_t mip, _In_ size_t item, _In_ size_t slice ) const +_Use_decl_annotations_ +size_t TexMetadata::ComputeIndex( size_t mip, size_t item, size_t slice ) const { if ( mip >= mipLevels ) return size_t(-1); @@ -737,6 +746,7 @@ void Blob::Release() _size = 0; } +_Use_decl_annotations_ HRESULT Blob::Initialize( size_t size ) { if ( !size ) diff --git a/DirectXTex/DirectXTexWIC.cpp b/DirectXTex/DirectXTexWIC.cpp index 0c11f5d..911e830 100644 --- a/DirectXTex/DirectXTexWIC.cpp +++ b/DirectXTex/DirectXTexWIC.cpp @@ -522,7 +522,7 @@ static HRESULT _EncodeSingleFrame( _In_ const Image& image, _In_ DWORD flags, //------------------------------------------------------------------------------------- // Encodes an image array //------------------------------------------------------------------------------------- -static HRESULT _EncodeMultiframe( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, +static HRESULT _EncodeMultiframe( _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _Inout_ IStream* stream, _In_opt_ const GUID* targetFormat ) { if ( !stream || nimages < 2 ) @@ -585,6 +585,7 @@ static HRESULT _EncodeMultiframe( _In_count_(nimages) const Image* images, _In_ //------------------------------------------------------------------------------------- // Obtain metadata from WIC-supported file in memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata& metadata ) { if ( !pSource || size == 0 ) @@ -633,6 +634,7 @@ HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, Tex //------------------------------------------------------------------------------------- // Obtain metadata from WIC-supported file on disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT GetMetadataFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata& metadata ) { if ( !szFile ) @@ -665,6 +667,7 @@ HRESULT GetMetadataFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata& metada //------------------------------------------------------------------------------------- // Load a WIC-supported file in memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata* metadata, ScratchImage& image ) { if ( !pSource || size == 0 ) @@ -734,6 +737,7 @@ HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadat //------------------------------------------------------------------------------------- // Load a WIC-supported file from disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT LoadFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, ScratchImage& image ) { if ( !szFile ) @@ -788,6 +792,7 @@ HRESULT LoadFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, Scr //------------------------------------------------------------------------------------- // Save a WIC-supported file to memory //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT SaveToWICMemory( const Image& image, DWORD flags, REFGUID guidContainerFormat, Blob& blob, const GUID* targetFormat ) { if ( !image.pixels ) @@ -833,6 +838,7 @@ HRESULT SaveToWICMemory( const Image& image, DWORD flags, REFGUID guidContainerF return S_OK; } +_Use_decl_annotations_ HRESULT SaveToWICMemory( const Image* images, size_t nimages, DWORD flags, REFGUID guidContainerFormat, Blob& blob, const GUID* targetFormat ) { if ( !images || nimages == 0 ) @@ -886,6 +892,7 @@ HRESULT SaveToWICMemory( const Image* images, size_t nimages, DWORD flags, REFGU //------------------------------------------------------------------------------------- // Save a WIC-supported file to disk //------------------------------------------------------------------------------------- +_Use_decl_annotations_ HRESULT SaveToWICFile( const Image& image, DWORD flags, REFGUID guidContainerFormat, LPCWSTR szFile, const GUID* targetFormat ) { if ( !szFile ) @@ -914,6 +921,7 @@ HRESULT SaveToWICFile( const Image& image, DWORD flags, REFGUID guidContainerFor return S_OK; } +_Use_decl_annotations_ HRESULT SaveToWICFile( const Image* images, size_t nimages, DWORD flags, REFGUID guidContainerFormat, LPCWSTR szFile, const GUID* targetFormat ) { if ( !szFile || !images || nimages == 0 ) diff --git a/DirectXTex/DirectXTex_Desktop_2010_SDK80.sln b/DirectXTex/DirectXTex_Desktop_2010_SDK80.sln new file mode 100644 index 0000000..8f2936d --- /dev/null +++ b/DirectXTex/DirectXTex_Desktop_2010_SDK80.sln @@ -0,0 +1,31 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex_Desktop_2010_SDK80.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Profile|Win32 = Profile|Win32 + Profile|x64 = Profile|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Win32.ActiveCfg = Debug|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Win32.Build.0 = Debug|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Win32.ActiveCfg = Profile|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Win32.Build.0 = Profile|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Win32.ActiveCfg = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Win32.Build.0 = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj b/DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj new file mode 100644 index 0000000..f60fabc --- /dev/null +++ b/DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj @@ -0,0 +1,403 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Profile + Win32 + + + Profile + x64 + + + Release + Win32 + + + Release + x64 + + + + DirectXTex + {371B9FA9-4C90-4AC6-A123-ACED756D6C77} + DirectXTex + Win32Proj + + + + StaticLibrary + Unicode + + + StaticLibrary + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + true + true + + + false + true + + + false + true + + + false + true + + + false + true + + + + Level4 + Disabled + MultiThreadedDebugDLL + true + true + Fast + StreamingSIMDExtensions2 + Sync + %(AdditionalOptions) + WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;DXGI_1_2_FORMATS;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + EditAndContinue + EnableFastChecks + Use + DirectXTexP.h + + + %(AdditionalOptions) + %(AdditionalDependencies) + Windows + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + Disabled + MultiThreadedDebugDLL + true + true + Fast + Sync + %(AdditionalOptions) + WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;DXGI_1_2_FORMATS;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + EnableFastChecks + Use + DirectXTexP.h + + + %(AdditionalOptions) + %(AdditionalDependencies) + Windows + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + true + true + true + Fast + StreamingSIMDExtensions2 + Sync + %(AdditionalOptions) + WIN32;NDEBUG;_WINDOWS;_LIB;DXGI_1_2_FORMATS;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + Use + DirectXTexP.h + + + %(AdditionalOptions) + %(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + true + true + true + Fast + Sync + %(AdditionalOptions) + WIN32;NDEBUG;_WINDOWS;_LIB;DXGI_1_2_FORMATS;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + Use + DirectXTexP.h + + + %(AdditionalOptions) + %(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + true + true + true + Fast + StreamingSIMDExtensions2 + Sync + %(AdditionalOptions) + WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;DXGI_1_2_FORMATS;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + Use + DirectXTexP.h + + + %(AdditionalOptions) + %(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + true + true + true + Fast + Sync + %(AdditionalOptions) + WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;DXGI_1_2_FORMATS;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + Use + DirectXTexP.h + + + %(AdditionalOptions) + %(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj.filters b/DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj.filters new file mode 100644 index 0000000..d528cc8 --- /dev/null +++ b/DirectXTex/DirectXTex_Desktop_2010_SDK80.vcxproj.filters @@ -0,0 +1,37 @@ + + + + +{8e114980-c1a3-4ada-ad7c-83caadf5daeb} +rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Texconv/Texconv_Desktop_2010_SDK80.sln b/Texconv/Texconv_Desktop_2010_SDK80.sln new file mode 100644 index 0000000..787d378 --- /dev/null +++ b/Texconv/Texconv_Desktop_2010_SDK80.sln @@ -0,0 +1,45 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texconv", "Texconv_Desktop_2010_SDK80.vcxproj", "{C3A65381-8FD3-4F69-B29E-654B4B0ED136}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "..\DirectXTex\DirectXTex_Desktop_2010_SDK80.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Profile|Win32 = Profile|Win32 + Profile|x64 = Profile|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|Win32.ActiveCfg = Debug|Win32 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|Win32.Build.0 = Debug|Win32 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x64.ActiveCfg = Debug|x64 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x64.Build.0 = Debug|x64 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|Win32.ActiveCfg = Profile|Win32 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|Win32.Build.0 = Profile|Win32 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x64.ActiveCfg = Profile|x64 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x64.Build.0 = Profile|x64 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|Win32.ActiveCfg = Release|Win32 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|Win32.Build.0 = Release|Win32 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x64.ActiveCfg = Release|x64 + {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x64.Build.0 = Release|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Win32.ActiveCfg = Debug|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Win32.Build.0 = Debug|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Win32.ActiveCfg = Profile|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|Win32.Build.0 = Profile|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Win32.ActiveCfg = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|Win32.Build.0 = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Texconv/Texconv_Desktop_2010_SDK80.vcxproj b/Texconv/Texconv_Desktop_2010_SDK80.vcxproj new file mode 100644 index 0000000..4a72cf7 --- /dev/null +++ b/Texconv/Texconv_Desktop_2010_SDK80.vcxproj @@ -0,0 +1,370 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Profile + Win32 + + + Profile + x64 + + + Release + Win32 + + + Release + x64 + + + + texconv + {C3A65381-8FD3-4F69-B29E-654B4B0ED136} + texconv + Win32Proj + + + + Application + Unicode + + + Application + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + true + true + + + false + true + + + false + true + + + false + true + + + false + true + + + + Level4 + Disabled + MultiThreadedDebugDLL + false + true + Fast + StreamingSIMDExtensions2 + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + EditAndContinue + EnableFastChecks + + + %(AdditionalOptions) + ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + Console + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + Disabled + MultiThreadedDebugDLL + false + true + Fast + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + EnableFastChecks + + + %(AdditionalOptions) + ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + Console + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + StreamingSIMDExtensions2 + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Console + true + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Console + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + StreamingSIMDExtensions2 + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Console + true + true + true + true + true + MachineX86 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreadedDLL + false + true + true + Fast + Sync + ..\XNAMath;..\DirectXTex;%(AdditionalIncludeDirectories) + %(AdditionalOptions) + WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + + %(AdditionalOptions) + ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) + true + Console + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + + + + + + + {371b9fa9-4c90-4ac6-a123-aced756d6c77} + + + + + + + \ No newline at end of file diff --git a/Texconv/Texconv_Desktop_2010_SDK80.vcxproj.filters b/Texconv/Texconv_Desktop_2010_SDK80.vcxproj.filters new file mode 100644 index 0000000..71d78bd --- /dev/null +++ b/Texconv/Texconv_Desktop_2010_SDK80.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {8e114980-c1a3-4ada-ad7c-83caadf5daeb} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + + + + Resource Files + + + \ No newline at end of file diff --git a/Windows8SDK_x64.props b/Windows8SDK_x64.props new file mode 100644 index 0000000..a5ff70f --- /dev/null +++ b/Windows8SDK_x64.props @@ -0,0 +1,12 @@ + + + + + + $(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(ProgramFiles)\Windows Kits\8.0\bin\x86;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH) + $(ProgramFiles)\Windows Kits\8.0\Include\um;$(ProgramFiles)\Windows Kits\8.0\Include\shared;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(FrameworkSDKDir)\include; + $(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(ProgramFiles)\Windows Kits\8.0\lib\win8\um\x64;$(FrameworkSDKDir)\lib\x64 + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(ProgramFiles)\Windows Kits\8.0\Include\um;$(ProgramFiles)\Windows Kits\8.0\Include\shared;$(FrameworkSDKDir)\include;$(MSBuildToolsPath32);$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib; + + + \ No newline at end of file diff --git a/Windows8SDK_x86.props b/Windows8SDK_x86.props new file mode 100644 index 0000000..4aa20c7 --- /dev/null +++ b/Windows8SDK_x86.props @@ -0,0 +1,12 @@ + + + + + + $(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(ProgramFiles)\Windows Kits\8.0\bin\x86;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH) + $(ProgramFiles)\Windows Kits\8.0\Include\um;$(ProgramFiles)\Windows Kits\8.0\Include\shared;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(FrameworkSDKDir)\include; + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(ProgramFiles)\Windows Kits\8.0\lib\win8\um\x86;$(FrameworkSDKDir)\lib + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(ProgramFiles)\Windows Kits\8.0\Include\um;$(ProgramFiles)\Windows Kits\8.0\Include\shared;$(FrameworkSDKDir)\include;$(MSBuildToolsPath32);$(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib; + + + \ No newline at end of file