/* * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/aub/aub_center.h" #include "shared/source/command_stream/preemption.h" #include "shared/source/command_stream/tbx_command_stream_receiver_hw.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/helpers/hw_info.h" #include "gmock/gmock.h" #include namespace NEO { template class MockTbxCsr : public TbxCommandStreamReceiverHw { public: using TbxCommandStreamReceiverHw::writeMemory; using TbxCommandStreamReceiverHw::allocationsForDownload; MockTbxCsr(ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield) : TbxCommandStreamReceiverHw(executionEnvironment, 0, deviceBitfield) {} void initializeEngine() override { TbxCommandStreamReceiverHw::initializeEngine(); initializeEngineCalled = true; } void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override { CommandStreamReceiverSimulatedHw::writeMemoryWithAubManager(graphicsAllocation); writeMemoryWithAubManagerCalled = true; } void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override { TbxCommandStreamReceiverHw::writeMemory(gpuAddress, cpuAddress, size, memoryBank, entryBits); writeMemoryCalled = true; } void submitBatchBufferTbx(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead) override { TbxCommandStreamReceiverHw::submitBatchBufferTbx(batchBufferGpuAddress, batchBuffer, batchBufferSize, memoryBank, entryBits, overrideRingHead); overrideRingHeadPassed = overrideRingHead; submitBatchBufferCalled = true; } void pollForCompletion() override { TbxCommandStreamReceiverHw::pollForCompletion(); pollForCompletionCalled = true; } void downloadAllocation(GraphicsAllocation &gfxAllocation) override { TbxCommandStreamReceiverHw::downloadAllocation(gfxAllocation); makeCoherentCalled = true; } void dumpAllocation(GraphicsAllocation &gfxAllocation) override { TbxCommandStreamReceiverHw::dumpAllocation(gfxAllocation); dumpAllocationCalled = true; } bool initializeEngineCalled = false; bool writeMemoryWithAubManagerCalled = false; bool writeMemoryCalled = false; bool submitBatchBufferCalled = false; bool overrideRingHeadPassed = false; bool pollForCompletionCalled = false; bool expectMemoryEqualCalled = false; bool expectMemoryNotEqualCalled = false; bool makeCoherentCalled = false; bool dumpAllocationCalled = false; }; template struct MockTbxCsrRegisterDownloadedAllocations : TbxCommandStreamReceiverHw { using CommandStreamReceiver::latestFlushedTaskCount; using CommandStreamReceiver::tagsMultiAllocation; using TbxCommandStreamReceiverHw::TbxCommandStreamReceiverHw; void downloadAllocation(GraphicsAllocation &gfxAllocation) override { *reinterpret_cast(CommandStreamReceiver::getTagAllocation()->getUnderlyingBuffer()) = this->latestFlushedTaskCount; downloadedAllocations.insert(&gfxAllocation); } bool flushBatchedSubmissions() override { flushBatchedSubmissionsCalled = true; return true; } std::set downloadedAllocations; bool flushBatchedSubmissionsCalled = false; }; } // namespace NEO