Skip to content

Commit

Permalink
D3D: Added GetDebugObjectName and parameter checking in SetDebugObjec…
Browse files Browse the repository at this point in the history
…tName
  • Loading branch information
mrgreywater committed Feb 9, 2015
1 parent 97a28a1 commit 98f02c7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Source/Core/VideoBackends/D3D/D3DBase.h
Expand Up @@ -70,10 +70,29 @@ void SetDebugObjectName(T resource, const char* name)
static_assert(std::is_convertible<T, ID3D11DeviceChild*>::value,
"resource must be convertible to ID3D11DeviceChild*");
#if defined(_DEBUG) || defined(DEBUGFAST)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)strlen(name), name);
if (resource)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)(name ? strlen(name) : 0), name);
#endif
}

template <typename T>
std::string GetDebugObjectName(T resource)
{
static_assert(std::is_convertible<T, ID3D11DeviceChild*>::value,
"resource must be convertible to ID3D11DeviceChild*");
std::string name;
#if defined(_DEBUG) || defined(DEBUGFAST)
if (resource)
{
UINT size = 0;
resource->GetPrivateData(WKPDID_D3DDebugObjectName, &size, nullptr); //get required size
name.resize(size);
resource->GetPrivateData(WKPDID_D3DDebugObjectName, &size, const_cast<char*>(name.data()));
}
#endif
return name;
}

} // namespace D3D

typedef HRESULT (WINAPI* CREATEDXGIFACTORY)(REFIID, void**);
Expand Down

0 comments on commit 98f02c7

Please sign in to comment.