Files
compute-runtime/opencl/test/unit_test/mocks/mock_graphics_allocation.h
Krzysztof Gibala 6be8d332f4 Pass MultiGraphicsAllocation in Buffer 1/n
Pass MultiGraphicsAllocation in Buffer instead of GraphicsAllocation

Related-To: NEO-4672
Change-Id: I7fb05ab53f54875f41d90f480e7f930b3b9f2fda
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
2020-07-14 16:50:39 +02:00

58 lines
1.8 KiB
C++

/*
* Copyright (C) 2017-2020 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 "opencl/source/memory_manager/os_agnostic_memory_manager.h"
namespace NEO {
constexpr uint32_t mockRootDeviceIndex = 0u;
constexpr DeviceBitfield mockDeviceBitfield(0b1);
class MockGraphicsAllocation : public MemoryAllocation {
public:
using MemoryAllocation::aubInfo;
using MemoryAllocation::MemoryAllocation;
using MemoryAllocation::objectNotResident;
using MemoryAllocation::objectNotUsed;
using MemoryAllocation::usageInfos;
MockGraphicsAllocation()
: MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull) {}
MockGraphicsAllocation(void *buffer, size_t sizeIn)
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull) {}
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn)
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull) {}
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