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