Fix unnecessary memory allocations within D3D object debug name assignment

This commit is contained in:
2026-04-27 14:27:32 +02:00
parent dcb9b5150f
commit c33ada2715
@@ -175,16 +175,13 @@ inline void SetDebugObjectName(T* resource, const Char* data, UINT size)
if (data && size > 0) if (data && size > 0)
resource->SetName(data); resource->SetName(data);
#else #else
char* ansi = (char*)Allocator::Allocate(size + 1); const StringAsANSI<> nameANSI(data, size);
StringUtils::ConvertUTF162ANSI(data, ansi, size); SetDebugObjectName(resource, nameANSI.Get(), size);
ansi[size] = '\0';
SetDebugObjectName(resource, ansi, size);
Allocator::Free(ansi);
#endif #endif
} }
template<typename T> template<typename T>
inline void SetDebugObjectName(T* resource, const String& name) inline void SetDebugObjectName(T* resource, const StringView& name)
{ {
SetDebugObjectName(resource, *name, name.Length()); SetDebugObjectName(resource, *name, name.Length());
} }
@@ -208,7 +205,7 @@ inline void SetDebugObjectName(ComPtr<T> resource, const Char (&name)[NameLength
} }
template<typename T> template<typename T>
inline void SetDebugObjectName(ComPtr<T> resource, const String& name) inline void SetDebugObjectName(ComPtr<T> resource, const StringView& name)
{ {
SetDebugObjectName(resource.Get(), *name, name.Length()); SetDebugObjectName(resource.Get(), *name, name.Length());
} }