diff --git a/Source/Core/VideoBackends/D3DCommon/Common.cpp b/Source/Core/VideoBackends/D3DCommon/Common.cpp index 1046cc8cb0..b84fc4a4df 100644 --- a/Source/Core/VideoBackends/D3DCommon/Common.cpp +++ b/Source/Core/VideoBackends/D3DCommon/Common.cpp @@ -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 child11; Microsoft::WRL::ComPtr child12; - if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(&child11)))) + if (SUCCEEDED(resource->QueryInterface(IID_PPV_ARGS(child11.GetAddressOf())))) { child11->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(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(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 child11; - Microsoft::WRL::ComPtr 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 diff --git a/Source/Core/VideoBackends/D3DCommon/Common.h b/Source/Core/VideoBackends/D3DCommon/Common.h index df8ea613b3..5f05c82978 100644 --- a/Source/Core/VideoBackends/D3DCommon/Common.h +++ b/Source/Core/VideoBackends/D3DCommon/Common.h @@ -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