From c8bb338548a66e5714151218a8361a09ac433788 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Tue, 11 Dec 2012 13:26:14 -0800 Subject: [PATCH] DirectXTex: converted DDSTextureLoader & WICTextureLoader to SAL2 --- DDSTextureLoader/DDSTextureLoader.cpp | 76 ++++++++++++++------------- DDSTextureLoader/DDSTextureLoader.h | 14 ++++- WICTextureLoader/WICTextureLoader.cpp | 76 ++++++++++++++------------- WICTextureLoader/WICTextureLoader.h | 14 ++++- 4 files changed, 104 insertions(+), 76 deletions(-) diff --git a/DDSTextureLoader/DDSTextureLoader.cpp b/DDSTextureLoader/DDSTextureLoader.cpp index 6341163..f436c5d 100644 --- a/DDSTextureLoader/DDSTextureLoader.cpp +++ b/DDSTextureLoader/DDSTextureLoader.cpp @@ -755,12 +755,12 @@ static HRESULT FillInitData( _In_ size_t width, _In_ DXGI_FORMAT format, _In_ size_t maxsize, _In_ size_t bitSize, - _In_bytecount_(bitSize) const uint8_t* bitData, + _In_reads_bytes_(bitSize) const uint8_t* bitData, _Out_ size_t& twidth, _Out_ size_t& theight, _Out_ size_t& tdepth, _Out_ size_t& skipMip, - _Out_cap_x_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData ) + _Out_writes_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData ) { if ( !bitData || !initData ) return E_POINTER; @@ -853,7 +853,7 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice, _In_ unsigned int miscFlags, _In_ bool forceSRGB, _In_ bool isCubeMap, - _In_count_x_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData, + _In_reads_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData, _Out_opt_ ID3D11Resource** texture, _Out_opt_ ID3D11ShaderResourceView** textureView ) { @@ -1084,7 +1084,7 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice, //-------------------------------------------------------------------------------------- static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice, _In_ const DDS_HEADER* header, - _In_bytecount_(bitSize) const uint8_t* bitData, + _In_reads_bytes_(bitSize) const uint8_t* bitData, _In_ size_t bitSize, _In_ size_t maxsize, _In_ D3D11_USAGE usage, @@ -1317,29 +1317,31 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice, } //-------------------------------------------------------------------------------------- -HRESULT DirectX::CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, - _In_bytecount_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize ) +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromMemory( ID3D11Device* d3dDevice, + const uint8_t* ddsData, + size_t ddsDataSize, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) { return CreateDDSTextureFromMemoryEx( d3dDevice, ddsData, ddsDataSize, maxsize, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, texture, textureView ); } -HRESULT DirectX::CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, - _In_bytecount_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView ) +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromMemoryEx( ID3D11Device* d3dDevice, + const uint8_t* ddsData, + size_t ddsDataSize, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) { if (!d3dDevice || !ddsData || (!texture && !textureView)) { @@ -1404,27 +1406,29 @@ HRESULT DirectX::CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, } //-------------------------------------------------------------------------------------- -HRESULT DirectX::CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, - _In_z_ const wchar_t* fileName, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize ) +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromFile( ID3D11Device* d3dDevice, + const wchar_t* fileName, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) { return CreateDDSTextureFromFileEx( d3dDevice, fileName, maxsize, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, texture, textureView ); } -HRESULT DirectX::CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, - _In_z_ const wchar_t* fileName, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView ) +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromFileEx( ID3D11Device* d3dDevice, + const wchar_t* fileName, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) { if (!d3dDevice || !fileName || (!texture && !textureView)) { diff --git a/DDSTextureLoader/DDSTextureLoader.h b/DDSTextureLoader/DDSTextureLoader.h index 1cdf69f..0b099f8 100644 --- a/DDSTextureLoader/DDSTextureLoader.h +++ b/DDSTextureLoader/DDSTextureLoader.h @@ -29,10 +29,20 @@ #include #pragma warning(pop) +#if defined(_MSC_VER) && (_MSC_VER<1610) && !defined(_In_reads_) +#define _In_reads_(exp) +#define _Out_writes_(exp) +#define _In_reads_bytes_(exp) +#endif + +#ifndef _Use_decl_annotations_ +#define _Use_decl_annotations_ +#endif + namespace DirectX { HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, - _In_bytecount_(ddsDataSize) const uint8_t* ddsData, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _Out_opt_ ID3D11Resource** texture, _Out_opt_ ID3D11ShaderResourceView** textureView, @@ -47,7 +57,7 @@ namespace DirectX ); HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, - _In_bytecount_(ddsDataSize) const uint8_t* ddsData, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _In_ size_t maxsize, _In_ D3D11_USAGE usage, diff --git a/WICTextureLoader/WICTextureLoader.cpp b/WICTextureLoader/WICTextureLoader.cpp index 8f3c0e5..2f4a6a8 100644 --- a/WICTextureLoader/WICTextureLoader.cpp +++ b/WICTextureLoader/WICTextureLoader.cpp @@ -673,31 +673,33 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice, } //-------------------------------------------------------------------------------------- -HRESULT DirectX::CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_bytecount_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize ) +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromMemory( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, + const uint8_t* wicData, + size_t wicDataSize, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) { return CreateWICTextureFromMemoryEx( d3dDevice, d3dContext, wicData, wicDataSize, maxsize, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, texture, textureView ); } -HRESULT DirectX::CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_bytecount_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView ) +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromMemoryEx( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, + const uint8_t* wicData, + size_t wicDataSize, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) { if (!d3dDevice || !wicData || (!texture && !textureView)) { @@ -759,29 +761,31 @@ HRESULT DirectX::CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, } //-------------------------------------------------------------------------------------- -HRESULT DirectX::CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_z_ const wchar_t* fileName, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize ) +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromFile( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, + const wchar_t* fileName, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) { return CreateWICTextureFromFileEx( d3dDevice, d3dContext, fileName, maxsize, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, texture, textureView ); } -HRESULT DirectX::CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_z_ const wchar_t* fileName, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Out_opt_ ID3D11Resource** texture, - _Out_opt_ ID3D11ShaderResourceView** textureView ) +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromFileEx( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, + const wchar_t* fileName, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) { if (!d3dDevice || !fileName || (!texture && !textureView)) { diff --git a/WICTextureLoader/WICTextureLoader.h b/WICTextureLoader/WICTextureLoader.h index 2cc1028..1447d2f 100644 --- a/WICTextureLoader/WICTextureLoader.h +++ b/WICTextureLoader/WICTextureLoader.h @@ -40,11 +40,21 @@ #include #pragma warning(pop) +#if defined(_MSC_VER) && (_MSC_VER<1610) && !defined(_In_reads_) +#define _In_reads_(exp) +#define _Out_writes_(exp) +#define _In_reads_bytes_(exp) +#endif + +#ifndef _Use_decl_annotations_ +#define _Use_decl_annotations_ +#endif + namespace DirectX { HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, - _In_bytecount_(wicDataSize) const uint8_t* wicData, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, _In_ size_t wicDataSize, _Out_opt_ ID3D11Resource** texture, _Out_opt_ ID3D11ShaderResourceView** textureView, @@ -61,7 +71,7 @@ namespace DirectX HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, - _In_bytecount_(wicDataSize) const uint8_t* wicData, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, _In_ size_t wicDataSize, _In_ size_t maxsize, _In_ D3D11_USAGE usage,