2019-02-14 18:38:04 +08:00
|
|
|
/*
|
2022-04-20 03:24:19 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2019-02-14 18:38:04 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_allocation.h"
|
|
|
|
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
2022-11-15 19:21:56 +08:00
|
|
|
#include "shared/test/common/test_macros/mock_method_macros.h"
|
2019-02-14 18:38:04 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-02-14 18:38:04 +08:00
|
|
|
|
|
|
|
class MockBufferObject : public BufferObject {
|
|
|
|
public:
|
2020-09-14 19:28:47 +08:00
|
|
|
using BufferObject::bindExtHandles;
|
2020-08-11 20:00:41 +08:00
|
|
|
using BufferObject::bindInfo;
|
2020-08-20 19:20:20 +08:00
|
|
|
using BufferObject::BufferObject;
|
2019-02-14 18:38:04 +08:00
|
|
|
using BufferObject::handle;
|
|
|
|
|
2022-04-21 01:32:39 +08:00
|
|
|
struct ExecParams {
|
|
|
|
uint64_t completionGpuAddress = 0;
|
|
|
|
uint32_t completionValue = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<ExecParams> passedExecParams{};
|
2022-04-20 03:24:19 +08:00
|
|
|
MockBufferObject(Drm *drm) : BufferObject(drm, CommonConstants::unsupportedPatIndex, 0, 0, 1) {
|
2019-02-14 18:38:04 +08:00
|
|
|
}
|
2022-04-21 01:32:39 +08:00
|
|
|
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId,
|
2022-05-11 23:06:01 +08:00
|
|
|
BufferObject *const residency[], size_t residencyCount, ExecObject *execObjectsStorage, uint64_t completionGpuAddress, uint32_t completionValue) override {
|
2022-04-21 01:32:39 +08:00
|
|
|
passedExecParams.push_back({completionGpuAddress, completionValue});
|
|
|
|
return BufferObject::exec(used, startOffset, flags, requiresCoherency, osContext, vmHandleId, drmContextId,
|
|
|
|
residency, residencyCount, execObjectsStorage, completionGpuAddress, completionValue);
|
|
|
|
}
|
2019-02-14 18:38:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockDrmAllocation : public DrmAllocation {
|
|
|
|
public:
|
2019-09-02 03:36:15 +08:00
|
|
|
using DrmAllocation::bufferObjects;
|
2021-10-11 17:27:26 +08:00
|
|
|
using DrmAllocation::enabledMemAdviseFlags;
|
2019-02-14 18:38:04 +08:00
|
|
|
using DrmAllocation::memoryPool;
|
2020-09-17 19:27:32 +08:00
|
|
|
using DrmAllocation::registeredBoBindHandles;
|
2019-02-14 18:38:04 +08:00
|
|
|
|
2022-06-02 05:13:52 +08:00
|
|
|
MockDrmAllocation(AllocationType allocationType, MemoryPool pool) : DrmAllocation(0, allocationType, nullptr, nullptr, 0, static_cast<size_t>(0), pool) {
|
2019-02-14 18:38:04 +08:00
|
|
|
}
|
2020-11-19 22:11:37 +08:00
|
|
|
|
|
|
|
void registerBOBindExtHandle(Drm *drm) override {
|
|
|
|
registerBOBindExtHandleCalled = true;
|
|
|
|
DrmAllocation::registerBOBindExtHandle(drm);
|
|
|
|
}
|
|
|
|
|
2021-03-10 07:02:59 +08:00
|
|
|
void markForCapture() override {
|
|
|
|
markedForCapture = true;
|
|
|
|
DrmAllocation::markForCapture();
|
|
|
|
}
|
|
|
|
|
2022-07-29 22:28:59 +08:00
|
|
|
int bindBOs(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind) override {
|
|
|
|
bindBOsCalled = true;
|
|
|
|
DrmAllocation::bindBOs(osContext, vmHandleId, bufferObjects, bind);
|
|
|
|
return bindBOsRetValue;
|
|
|
|
}
|
|
|
|
|
2022-11-15 19:21:56 +08:00
|
|
|
ADDMETHOD_NOBASE(makeBOsResident, int, 0, (OsContext * osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind));
|
|
|
|
|
2020-11-19 22:11:37 +08:00
|
|
|
bool registerBOBindExtHandleCalled = false;
|
2021-03-10 07:02:59 +08:00
|
|
|
bool markedForCapture = false;
|
2022-07-29 22:28:59 +08:00
|
|
|
bool bindBOsCalled = false;
|
|
|
|
int bindBOsRetValue = 0;
|
2019-02-14 18:38:04 +08:00
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|