Files
compute-runtime/shared/test/common/mocks/mock_graphics_allocation.h
Maciej Dziuban 98ff3cc0a9 Do not use blitter for local->local SVM and USM copies
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
Related-To: NEO-5549
2021-02-11 16:24:57 +01:00

62 lines
2.2 KiB
C++

/*
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/multi_graphics_allocation.h"
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
namespace NEO {
constexpr uint32_t mockRootDeviceIndex = 0u;
constexpr DeviceBitfield mockDeviceBitfield(0b1);
constexpr size_t mockMaxOsContextCount = 3u;
class MockGraphicsAllocation : public MemoryAllocation {
public:
using MemoryAllocation::aubInfo;
using MemoryAllocation::MemoryAllocation;
using MemoryAllocation::memoryPool;
using MemoryAllocation::objectNotResident;
using MemoryAllocation::objectNotUsed;
using MemoryAllocation::usageInfos;
MockGraphicsAllocation()
: MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
MockGraphicsAllocation(void *buffer, size_t sizeIn)
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn)
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
MockGraphicsAllocation(uint32_t rootDeviceIndex, void *buffer, size_t sizeIn)
: MemoryAllocation(rootDeviceIndex, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
void resetInspectionIds() {
for (auto &usageInfo : usageInfos) {
usageInfo.inspectionId = 0u;
}
}
void overrideMemoryPool(MemoryPool::Type pool) {
this->memoryPool = pool;
}
};
namespace GraphicsAllocationHelper {
static inline MultiGraphicsAllocation toMultiGraphicsAllocation(GraphicsAllocation *graphicsAllocation) {
MultiGraphicsAllocation multiGraphicsAllocation(graphicsAllocation->getRootDeviceIndex());
multiGraphicsAllocation.addAllocation(graphicsAllocation);
return multiGraphicsAllocation;
}
} // namespace GraphicsAllocationHelper
} // namespace NEO