Skip to content
Permalink
Browse files

D3DCommon: Remove unused GetDebugObjectName and tidy up SetDebugObjec…

…tName
  • Loading branch information
CookiePLMonster committed Nov 10, 2019
1 parent 8445644 commit a68789a70c181a3ce424c6b9504678c7bf3624f6
Showing with 6 additions and 38 deletions.
  1. +5 −36 Source/Core/VideoBackends/D3DCommon/Common.cpp
  2. +1 −2 Source/Core/VideoBackends/D3DCommon/Common.h
@@ -268,53 +268,22 @@ AbstractTextureFormat GetAbstractFormatForDXGIFormat(DXGI_FORMAT format)
}
}

void SetDebugObjectName(IUnknown* resource, const char* format, ...)
void SetDebugObjectName(IUnknown* resource, std::string_view name)
{
if (!g_ActiveConfig.bEnableValidationLayer)
return;

std::va_list ap;
va_start(ap, format);
std::string name = StringFromFormatV(format, ap);
va_end(ap);

Microsoft::WRL::ComPtr<ID3D11DeviceChild> child11;
Microsoft::WRL::ComPtr<ID3D12DeviceChild> child12;
if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(&child11))))
if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(child11.GetAddressOf()))))
{
child11->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast<UINT>(name.length()),
name.c_str());
name.data());
}
else if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(&child12))))
else if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(child12.GetAddressOf()))))
{
child12->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast<UINT>(name.length()),
name.c_str());
name.data());
}
}

std::string GetDebugObjectName(IUnknown* resource)
{
if (!g_ActiveConfig.bEnableValidationLayer)
return {};

std::string name;
UINT size = 0;

Microsoft::WRL::ComPtr<ID3D11DeviceChild> child11;
Microsoft::WRL::ComPtr<ID3D12DeviceChild> child12;
if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(&child11))))
{
child11->GetPrivateData(WKPDID_D3DDebugObjectName, &size, nullptr);
name.resize(size);
child11->GetPrivateData(WKPDID_D3DDebugObjectName, &size, name.data());
}
else if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(&child12))))
{
child12->GetPrivateData(WKPDID_D3DDebugObjectName, &size, nullptr);
name.resize(size);
child12->GetPrivateData(WKPDID_D3DDebugObjectName, &size, name.data());
}

return name;
}
} // namespace D3DCommon
@@ -41,6 +41,5 @@ AbstractTextureFormat GetAbstractFormatForDXGIFormat(DXGI_FORMAT format);
// This function will assign a name to the given resource.
// The DirectX debug layer will make it easier to identify resources that way,
// e.g. when listing up all resources who have unreleased references.
void SetDebugObjectName(IUnknown* resource, const char* format, ...);
std::string GetDebugObjectName(IUnknown* resource);
void SetDebugObjectName(IUnknown* resource, std::string_view name);
} // namespace D3DCommon

0 comments on commit a68789a

Please sign in to comment.
You can’t perform that action at this time.