DDSTextureLoader & WICTextureLoader updated to use SetDebugObjectName template introduced in Oct 12 2012 DirectXTK release

This commit is contained in:
walbourn_cp 2012-10-12 12:48:53 -07:00
parent e57fcf3817
commit c7594d5265
2 changed files with 36 additions and 42 deletions

View File

@ -29,6 +29,10 @@
#define DXGI_1_2_FORMATS
#endif
#if defined(_DEBUG) || defined(PROFILE)
#pragma comment(lib,"dxguid.lib")
#endif
//--------------------------------------------------------------------------------------
// Macros
//--------------------------------------------------------------------------------------
@ -131,6 +135,16 @@ typedef public std::unique_ptr<void, handle_closer> ScopedHandle;
inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; }
//--------------------------------------------------------------------------------------
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength])
{
#if defined(_DEBUG) || defined(PROFILE)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
#endif
}
//--------------------------------------------------------------------------------------
static HRESULT LoadTextureDataFromFile( _In_z_ const wchar_t* fileName,
std::unique_ptr<uint8_t[]>& ddsData,
@ -866,11 +880,7 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
}
else
{
#if defined(_DEBUG) || defined(PROFILE)
tex->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("DDSTextureLoader")-1,
"DDSTextureLoader" );
#endif
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
}
}
@ -950,12 +960,7 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
}
else
{
#if defined(_DEBUG) || defined(PROFILE)
tex->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("DDSTextureLoader")-1,
"DDSTextureLoader"
);
#endif
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
}
}
@ -1007,11 +1012,7 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
}
else
{
#if defined(_DEBUG) || defined(PROFILE)
tex->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("DDSTextureLoader")-1,
"DDSTextureLoader" );
#endif
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
}
}
@ -1310,23 +1311,15 @@ HRESULT DirectX::CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice,
maxsize
);
#if defined(_DEBUG) || defined(PROFILE)
if (texture != 0 && *texture != 0)
{
(*texture)->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("DDSTextureLoader")-1,
"DDSTextureLoader"
);
SetDebugObjectName(*texture, "DDSTextureLoader");
}
if (textureView != 0 && *textureView != 0)
{
(*textureView)->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("DDSTextureLoader")-1,
"DDSTextureLoader"
);
SetDebugObjectName(*textureView, "DDSTextureLoader");
}
#endif
return hr;
}

View File

@ -44,6 +44,10 @@
#define DXGI_1_2_FORMATS
#endif
#if defined(_DEBUG) || defined(PROFILE)
#pragma comment(lib,"dxguid.lib")
#endif
//---------------------------------------------------------------------------------
template<class T> class ScopedObject
{
@ -75,6 +79,16 @@ private:
T* _pointer;
};
//--------------------------------------------------------------------------------------
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength])
{
#if defined(_DEBUG) || defined(PROFILE)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
#endif
}
//-------------------------------------------------------------------------------------
// WIC Pixel Format Translation Data
//-------------------------------------------------------------------------------------
@ -544,12 +558,7 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice,
}
else
{
#if defined(_DEBUG) || defined(PROFILE)
tex->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("WICTextureLoader")-1,
"WICTextureLoader"
);
#endif
SetDebugObjectName(tex, "WICTextureLoader");
tex->Release();
}
}
@ -611,23 +620,15 @@ HRESULT DirectX::CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
if ( FAILED(hr))
return hr;
#if defined(_DEBUG) || defined(PROFILE)
if (texture != 0 && *texture != 0)
{
(*texture)->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("WICTextureLoader")-1,
"WICTextureLoader"
);
SetDebugObjectName(*texture, "WICTextureLoader");
}
if (textureView != 0 && *textureView != 0)
{
(*textureView)->SetPrivateData( WKPDID_D3DDebugObjectName,
sizeof("WICTextureLoader")-1,
"WICTextureLoader"
);
SetDebugObjectName(*textureView, "WICTextureLoader");
}
#endif
return hr;
}