Add support for WKPDID_D3DDebugObjectNameW

This commit is contained in:
Steve Karolewics
2019-07-02 09:13:37 +01:00
committed by Baldur Karlsson
parent b1e6140747
commit 731b701107
5 changed files with 52 additions and 9 deletions
+21 -9
View File
@@ -187,20 +187,32 @@ inline void SetDebugName(T *pObj, const char *name)
}
template <class T>
inline const char *GetDebugName(T *pObj)
inline std::string GetDebugName(T *pObj)
{
static char tmpBuf[1024] = {0};
UINT size = 1023;
static const UINT DEBUG_NAME_SIZE = 1024;
static wchar_t tmpBuf[DEBUG_NAME_SIZE] = {0}; // Used for both char and wchar_t
if(pObj)
{
HRESULT hr = pObj->GetPrivateData(WKPDID_D3DDebugObjectName, &size, tmpBuf);
if(FAILED(hr))
return "";
// Try char first
UINT size = DEBUG_NAME_SIZE - 1;
HRESULT hr = pObj->GetPrivateData(WKPDID_D3DDebugObjectName, &size, (char *)tmpBuf);
if(SUCCEEDED(hr))
{
return std::string((char *)tmpBuf, size);
}
tmpBuf[size] = 0;
return tmpBuf;
// Try wchar_t
size = (DEBUG_NAME_SIZE - 1) * sizeof(wchar_t);
hr = pObj->GetPrivateData(WKPDID_D3DDebugObjectNameW, &size, tmpBuf);
if(SUCCEEDED(hr))
{
size /= 2; // Convert from bytes read to wide char count
std::wstring sName(tmpBuf, size);
return StringFormat::Wide2UTF8(sName);
}
}
return "";
return std::string();
}
class RefCounter
+7
View File
@@ -302,6 +302,13 @@ public:
m_pDevice->SetResourceName(this, pStrData);
}
}
else if(guid == WKPDID_D3DDebugObjectNameW)
{
const wchar_t *pStrData = (const wchar_t *)pData;
std::wstring wName(pStrData, DataSize / 2);
std::string sName = StringFormat::Wide2UTF8(wName);
m_pDevice->SetResourceName(this, sName.c_str());
}
return m_pReal->SetPrivateData(guid, DataSize, pData);
}
@@ -209,7 +209,15 @@ public:
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
{
if(guid == WKPDID_D3DDebugObjectName)
{
m_pDevice->SetName(this, (const char *)pData);
}
else if(guid == WKPDID_D3DDebugObjectNameW)
{
std::wstring wName((const wchar_t *)pData, DataSize / 2);
std::string sName = StringFormat::Wide2UTF8(wName);
m_pDevice->SetName(this, sName.c_str());
}
return m_pList->SetPrivateData(guid, DataSize, pData);
}
@@ -194,7 +194,15 @@ public:
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
{
if(guid == WKPDID_D3DDebugObjectName)
{
m_pDevice->SetName(this, (const char *)pData);
}
else if(guid == WKPDID_D3DDebugObjectNameW)
{
std::wstring wName((const wchar_t *)pData, DataSize / 2);
std::string sName = StringFormat::Wide2UTF8(wName);
m_pDevice->SetName(this, sName.c_str());
}
return m_pReal->SetPrivateData(guid, DataSize, pData);
}
+8
View File
@@ -295,7 +295,15 @@ public:
return m_pDevice->SetShaderDebugPath(this, (const char *)pData);
if(guid == WKPDID_D3DDebugObjectName)
{
m_pDevice->SetName(this, (const char *)pData);
}
else if(guid == WKPDID_D3DDebugObjectNameW)
{
std::wstring wName((const wchar_t *)pData, DataSize / 2);
std::string sName = StringFormat::Wide2UTF8(wName);
m_pDevice->SetName(this, sName.c_str());
}
if(!m_pReal)
return S_OK;