Skip to content

Commit

Permalink
D3DCommon: Remove unused GetDebugObjectName and tidy up SetDebugObjec…
Browse files Browse the repository at this point in the history
…tName
  • Loading branch information
CookiePLMonster committed Nov 10, 2019
1 parent 8445644 commit a68789a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
41 changes: 5 additions & 36 deletions Source/Core/VideoBackends/D3DCommon/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions Source/Core/VideoBackends/D3DCommon/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.