2#include <UnCompute/Backend/IBuffer.h>
3#include <UnCompute/Backend/IComputeDevice.h>
4#include <UnCompute/Backend/IDeviceMemory.h>
18 inline ResultCode AllocateMemoryFor(
const ArraySlice<IDeviceObject*>& objects, MemoryKindFlags flags,
19 const char* memoryDebugName, IDeviceMemory** ppMemory)
21 auto* pDevice = objects[0]->GetDevice();
22 if (
auto result = pDevice->CreateMemory(ppMemory); Failed(result))
27 DeviceMemoryDesc desc(memoryDebugName, flags, 0, objects);
28 return (*ppMemory)->Init(desc);
38 inline ResultCode AllocateMemoryFor(IDeviceObject* pObject, MemoryKindFlags flags, IDeviceMemory** ppMemory)
40 auto name = fmt::format(
"Memory for \"{}\"", pObject->GetDebugName());
41 IDeviceObject* objects[] = { pObject };
42 return AllocateMemoryFor(objects, flags, name.c_str(), ppMemory);