2018-10-22 21:17:32 +08:00
|
|
|
/*
|
2023-01-24 23:33:52 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-10-22 21:17:32 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/allocations_list.h"
|
2018-10-22 21:17:32 +08:00
|
|
|
|
2022-07-13 23:05:42 +08:00
|
|
|
#include <array>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-10-22 21:17:32 +08:00
|
|
|
|
|
|
|
class InternalAllocationStorage {
|
|
|
|
public:
|
2018-10-26 19:05:31 +08:00
|
|
|
MOCKABLE_VIRTUAL ~InternalAllocationStorage() = default;
|
2018-10-22 21:17:32 +08:00
|
|
|
InternalAllocationStorage(CommandStreamReceiver &commandStreamReceiver);
|
2022-11-22 21:53:59 +08:00
|
|
|
MOCKABLE_VIRTUAL void cleanAllocationList(TaskCountType waitTaskCount, uint32_t allocationUsage);
|
2021-10-21 20:37:31 +08:00
|
|
|
void storeAllocation(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage);
|
2022-11-22 21:53:59 +08:00
|
|
|
void storeAllocationWithTaskCount(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage, TaskCountType taskCount);
|
2022-02-04 21:59:01 +08:00
|
|
|
std::unique_ptr<GraphicsAllocation> obtainReusableAllocation(size_t requiredSize, AllocationType allocationType);
|
|
|
|
std::unique_ptr<GraphicsAllocation> obtainTemporaryAllocationWithPtr(size_t requiredSize, const void *requiredPtr, AllocationType allocationType);
|
2022-07-13 23:05:42 +08:00
|
|
|
AllocationsList &getTemporaryAllocations() { return allocationLists[TEMPORARY_ALLOCATION]; }
|
|
|
|
AllocationsList &getAllocationsForReuse() { return allocationLists[REUSABLE_ALLOCATION]; }
|
|
|
|
AllocationsList &getDeferredAllocations() { return allocationLists[DEFERRED_DEALLOCATION]; }
|
2020-06-23 17:30:01 +08:00
|
|
|
DeviceBitfield getDeviceBitfield() const;
|
2018-10-22 21:17:32 +08:00
|
|
|
|
2018-10-26 19:05:31 +08:00
|
|
|
protected:
|
2022-11-22 21:53:59 +08:00
|
|
|
void freeAllocationsList(TaskCountType waitTaskCount, AllocationsList &allocationsList);
|
2018-10-22 21:17:32 +08:00
|
|
|
CommandStreamReceiver &commandStreamReceiver;
|
2018-10-29 20:26:58 +08:00
|
|
|
|
2022-07-13 23:05:42 +08:00
|
|
|
std::array<AllocationsList, 3> allocationLists = {AllocationsList(TEMPORARY_ALLOCATION), AllocationsList(REUSABLE_ALLOCATION), AllocationsList(DEFERRED_DEALLOCATION)};
|
2018-10-22 21:17:32 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|