2019-11-18 15:12:22 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "core/helpers/heap_helper.h"
|
|
|
|
|
|
|
|
|
|
#include "core/memory_manager/graphics_allocation.h"
|
|
|
|
|
#include "runtime/memory_manager/internal_allocation_storage.h"
|
|
|
|
|
#include "runtime/memory_manager/memory_manager.h"
|
|
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
GraphicsAllocation *HeapHelper::getHeapAllocation(size_t heapSize, size_t alignment, uint32_t rootDeviceIndex) {
|
|
|
|
|
auto allocation = this->storageForReuse->obtainReusableAllocation(heapSize, GraphicsAllocation::AllocationType::INTERNAL_HEAP);
|
|
|
|
|
if (allocation) {
|
|
|
|
|
return allocation.release();
|
|
|
|
|
}
|
2019-12-10 12:16:07 +01:00
|
|
|
NEO::AllocationProperties properties{rootDeviceIndex,
|
|
|
|
|
true /* allocateMemory*/,
|
|
|
|
|
alignment,
|
2019-11-18 15:12:22 +01:00
|
|
|
GraphicsAllocation::AllocationType::INTERNAL_HEAP,
|
2019-12-10 12:16:07 +01:00
|
|
|
isMultiOsContextCapable,
|
|
|
|
|
false /* isMultiStorageAllocation */,
|
|
|
|
|
{}};
|
2019-11-18 15:12:22 +01:00
|
|
|
|
|
|
|
|
return this->memManager->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
}
|
|
|
|
|
void HeapHelper::storeHeapAllocation(GraphicsAllocation *heapAllocation) {
|
|
|
|
|
this->storageForReuse->storeAllocation(std::unique_ptr<NEO::GraphicsAllocation>(heapAllocation), NEO::AllocationUsage::REUSABLE_ALLOCATION);
|
|
|
|
|
}
|
2019-12-10 12:16:07 +01:00
|
|
|
} // namespace NEO
|