2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-02-17 01:36:27 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2020-07-10 17:21:53 +08:00
|
|
|
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
2020-11-02 22:54:01 +08:00
|
|
|
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2020-06-03 18:31:33 +08:00
|
|
|
|
|
|
|
constexpr uint32_t mockRootDeviceIndex = 0u;
|
|
|
|
constexpr DeviceBitfield mockDeviceBitfield(0b1);
|
|
|
|
|
2019-04-18 21:30:47 +08:00
|
|
|
class MockGraphicsAllocation : public MemoryAllocation {
|
2018-11-07 16:33:55 +08:00
|
|
|
public:
|
2021-06-29 00:45:06 +08:00
|
|
|
using MemoryAllocation::allocationOffset;
|
2022-02-17 01:36:27 +08:00
|
|
|
using MemoryAllocation::allocationType;
|
2019-08-07 00:01:26 +08:00
|
|
|
using MemoryAllocation::aubInfo;
|
2022-09-23 21:05:43 +08:00
|
|
|
using MemoryAllocation::cpuPtr;
|
2021-06-29 00:45:06 +08:00
|
|
|
using MemoryAllocation::gpuAddress;
|
2019-04-18 21:30:47 +08:00
|
|
|
using MemoryAllocation::MemoryAllocation;
|
2021-02-11 22:30:05 +08:00
|
|
|
using MemoryAllocation::memoryPool;
|
2019-04-18 21:30:47 +08:00
|
|
|
using MemoryAllocation::objectNotResident;
|
|
|
|
using MemoryAllocation::objectNotUsed;
|
2021-06-29 00:45:06 +08:00
|
|
|
using MemoryAllocation::size;
|
2019-04-18 21:30:47 +08:00
|
|
|
using MemoryAllocation::usageInfos;
|
2018-05-14 17:25:18 +08:00
|
|
|
|
2019-02-26 18:37:51 +08:00
|
|
|
MockGraphicsAllocation()
|
2022-06-03 19:48:45 +08:00
|
|
|
: MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu) {}
|
2019-02-26 18:37:51 +08:00
|
|
|
|
|
|
|
MockGraphicsAllocation(void *buffer, size_t sizeIn)
|
2021-09-21 01:39:16 +08:00
|
|
|
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {}
|
2019-02-26 18:37:51 +08:00
|
|
|
|
|
|
|
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn)
|
2021-09-21 01:39:16 +08:00
|
|
|
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {}
|
2018-12-04 22:11:29 +08:00
|
|
|
|
2020-07-14 03:59:16 +08:00
|
|
|
MockGraphicsAllocation(uint32_t rootDeviceIndex, void *buffer, size_t sizeIn)
|
2021-09-21 01:39:16 +08:00
|
|
|
: MemoryAllocation(rootDeviceIndex, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {}
|
2020-07-14 03:59:16 +08:00
|
|
|
|
2018-12-04 22:11:29 +08:00
|
|
|
void resetInspectionIds() {
|
|
|
|
for (auto &usageInfo : usageInfos) {
|
|
|
|
usageInfo.inspectionId = 0u;
|
|
|
|
}
|
2018-05-14 17:25:18 +08:00
|
|
|
}
|
2018-12-04 22:11:29 +08:00
|
|
|
|
2022-06-02 05:13:52 +08:00
|
|
|
void overrideMemoryPool(MemoryPool pool) {
|
2018-07-23 17:03:05 +08:00
|
|
|
this->memoryPool = pool;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2020-07-10 17:21:53 +08:00
|
|
|
|
2022-05-05 20:01:59 +08:00
|
|
|
class MockGraphicsAllocationTaskCount : public MockGraphicsAllocation {
|
|
|
|
public:
|
|
|
|
uint32_t getTaskCount(uint32_t contextId) const override {
|
|
|
|
getTaskCountCalleedTimes++;
|
|
|
|
return MockGraphicsAllocation::getTaskCount(contextId);
|
|
|
|
}
|
|
|
|
void updateTaskCount(uint32_t newTaskCount, uint32_t contextId) override {
|
|
|
|
updateTaskCountCalleedTimes++;
|
|
|
|
MockGraphicsAllocation::updateTaskCount(newTaskCount, contextId);
|
|
|
|
}
|
|
|
|
static uint32_t getTaskCountCalleedTimes;
|
|
|
|
uint32_t updateTaskCountCalleedTimes = 0;
|
|
|
|
};
|
|
|
|
|
2020-07-10 17:21:53 +08:00
|
|
|
namespace GraphicsAllocationHelper {
|
|
|
|
|
|
|
|
static inline MultiGraphicsAllocation toMultiGraphicsAllocation(GraphicsAllocation *graphicsAllocation) {
|
|
|
|
MultiGraphicsAllocation multiGraphicsAllocation(graphicsAllocation->getRootDeviceIndex());
|
|
|
|
multiGraphicsAllocation.addAllocation(graphicsAllocation);
|
|
|
|
return multiGraphicsAllocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace GraphicsAllocationHelper
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|