Created
August 1, 2014 04:33
-
-
Save Cody-Duncan/df88c10b0e13cfe9734d to your computer and use it in GitHub Desktop.
DirectX11 SetDebugObjectName Overloads and ReportLiveObjects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
// If necessary, use this to free raw pointers. | |
// Preferably, use Microsoft::WRL::ComPtr from client.h (http://msdn.microsoft.com/en-us/library/br244983.aspx) | |
#ifndef SAFE_RELEASE | |
#define SAFE_RELEASE(x) \ | |
if(x != NULL) \ | |
{ \ | |
x->Release(); \ | |
x = NULL; \ | |
} | |
#endif | |
template<UINT TNameLength> | |
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength]) | |
{ | |
#if defined(_DEBUG) || defined(PROFILE) | |
HRESULT nameSet = resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); | |
ErrorIf(FAILED(nameSet), "Failed to set debug name"); | |
#endif | |
} | |
template<UINT TNameLength> | |
inline void SetDebugObjectName(_In_ IDXGIObject* resource, _In_z_ const char (&name)[TNameLength]) | |
{ | |
#if defined(_DEBUG) || defined(PROFILE) | |
HRESULT nameSet = resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); | |
ErrorIf(FAILED(nameSet), "Failed to set debug name"); | |
#endif | |
} | |
inline void SetDebugName(_In_ ID3D11DeviceChild* resource, _In_z_ string debugName) | |
{ | |
#if defined(_DEBUG) || defined(PROFILE) | |
HRESULT nameSet = resource->SetPrivateData(WKPDID_D3DDebugObjectName, debugName.size(), debugName.c_str()); | |
ErrorIf(FAILED(nameSet), "Failed to set debug name"); | |
#endif | |
} | |
inline void SetDebugName(_In_ IDXGIObject* resource, _In_z_ string debugName) | |
{ | |
#if defined(_DEBUG) || defined(PROFILE) | |
HRESULT nameSet = resource->SetPrivateData(WKPDID_D3DDebugObjectName, debugName.size(), debugName.c_str()); | |
ErrorIf(FAILED(nameSet), "Failed to set debug name"); | |
#endif | |
} | |
inline void SetDebugName(_In_ ID3D11Device* resource, _In_z_ string debugName) | |
{ | |
#if defined(_DEBUG) || defined(PROFILE) | |
HRESULT nameSet = resource->SetPrivateData(WKPDID_D3DDebugObjectName, debugName.size(), debugName.c_str()); | |
ErrorIf(FAILED(nameSet), "Failed to set debug name"); | |
#endif | |
} | |
inline void ReportLiveObjects(ID3D11Device* device) | |
{ | |
if(device) | |
{ | |
ID3D11Debug* debugDev; | |
device->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&debugDev)); | |
debugDev->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment