2020-01-15 17:02:47 +01:00
|
|
|
/*
|
2021-01-21 13:10:13 +01:00
|
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
2020-01-15 17:02:47 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/direct_submission/direct_submission_hw.h"
|
2020-03-27 16:32:07 +01:00
|
|
|
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2021-09-03 11:40:34 +00:00
|
|
|
#include "shared/test/common/mocks/mock_memory_operations_handler.h"
|
2020-01-15 17:02:47 +01:00
|
|
|
namespace NEO {
|
|
|
|
|
|
2020-03-26 20:13:10 +01:00
|
|
|
template <typename GfxFamily, typename Dispatcher>
|
|
|
|
|
struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher> {
|
|
|
|
|
using BaseClass = DirectSubmissionHw<GfxFamily, Dispatcher>;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::allocateResources;
|
|
|
|
|
using BaseClass::completionRingBuffers;
|
|
|
|
|
using BaseClass::cpuCachelineFlush;
|
|
|
|
|
using BaseClass::currentQueueWorkCount;
|
|
|
|
|
using BaseClass::currentRingBuffer;
|
|
|
|
|
using BaseClass::deallocateResources;
|
|
|
|
|
using BaseClass::device;
|
2020-03-27 16:32:07 +01:00
|
|
|
using BaseClass::diagnostic;
|
2020-03-26 20:13:10 +01:00
|
|
|
using BaseClass::DirectSubmissionHw;
|
2020-03-27 16:32:07 +01:00
|
|
|
using BaseClass::disableCacheFlush;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::disableCpuCacheFlush;
|
2020-03-27 16:32:07 +01:00
|
|
|
using BaseClass::disableMonitorFence;
|
2020-08-18 13:54:23 +02:00
|
|
|
using BaseClass::dispatchDisablePrefetcher;
|
|
|
|
|
using BaseClass::dispatchPrefetchMitigation;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::dispatchSemaphoreSection;
|
|
|
|
|
using BaseClass::dispatchStartSection;
|
|
|
|
|
using BaseClass::dispatchSwitchRingBufferSection;
|
2020-03-18 14:14:04 +01:00
|
|
|
using BaseClass::dispatchWorkloadSection;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::getCommandBufferPositionGpuAddress;
|
2020-05-18 18:48:43 +02:00
|
|
|
using BaseClass::getDiagnosticModeSection;
|
2020-08-18 13:54:23 +02:00
|
|
|
using BaseClass::getSizeDisablePrefetcher;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::getSizeDispatch;
|
|
|
|
|
using BaseClass::getSizeEnd;
|
2020-08-18 13:54:23 +02:00
|
|
|
using BaseClass::getSizePrefetchMitigation;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::getSizeSemaphoreSection;
|
|
|
|
|
using BaseClass::getSizeStartSection;
|
|
|
|
|
using BaseClass::getSizeSwitchRingBufferSection;
|
2020-03-18 14:14:04 +01:00
|
|
|
using BaseClass::hwInfo;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::osContext;
|
2020-03-27 16:32:07 +01:00
|
|
|
using BaseClass::performDiagnosticMode;
|
2020-01-15 17:02:47 +01:00
|
|
|
using BaseClass::ringBuffer;
|
|
|
|
|
using BaseClass::ringBuffer2;
|
|
|
|
|
using BaseClass::ringCommandStream;
|
|
|
|
|
using BaseClass::ringStart;
|
|
|
|
|
using BaseClass::semaphoreData;
|
|
|
|
|
using BaseClass::semaphoreGpuVa;
|
|
|
|
|
using BaseClass::semaphorePtr;
|
|
|
|
|
using BaseClass::semaphores;
|
|
|
|
|
using BaseClass::setReturnAddress;
|
|
|
|
|
using BaseClass::stopRingBuffer;
|
|
|
|
|
using BaseClass::switchRingBuffersAllocations;
|
2020-03-27 16:32:07 +01:00
|
|
|
using BaseClass::workloadMode;
|
|
|
|
|
using BaseClass::workloadModeOneExpectedValue;
|
|
|
|
|
using BaseClass::workloadModeOneStoreAddress;
|
2020-01-15 17:02:47 +01:00
|
|
|
using typename BaseClass::RingBufferUse;
|
|
|
|
|
|
2020-02-20 14:43:22 +01:00
|
|
|
~MockDirectSubmissionHw() override {
|
2020-01-15 17:02:47 +01:00
|
|
|
if (ringStart) {
|
|
|
|
|
stopRingBuffer();
|
|
|
|
|
}
|
|
|
|
|
deallocateResources();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 11:28:59 +02:00
|
|
|
bool allocateOsResources() override {
|
2020-01-15 17:02:47 +01:00
|
|
|
return allocateOsResourcesReturn;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 11:28:59 +02:00
|
|
|
bool makeResourcesResident(DirectSubmissionAllocations &allocations) override {
|
2021-09-03 11:40:34 +00:00
|
|
|
if (callBaseResident) {
|
|
|
|
|
return BaseClass::makeResourcesResident(allocations);
|
|
|
|
|
}
|
2020-07-17 11:28:59 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-15 17:02:47 +01:00
|
|
|
bool submit(uint64_t gpuAddress, size_t size) override {
|
|
|
|
|
submitGpuAddress = gpuAddress;
|
|
|
|
|
submitSize = size;
|
|
|
|
|
submitCount++;
|
|
|
|
|
return submitReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool handleResidency() override {
|
|
|
|
|
handleResidencyCount++;
|
|
|
|
|
return handleResidencyReturn;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 11:28:59 +02:00
|
|
|
void handleSwitchRingBuffers() override {}
|
2020-01-15 17:02:47 +01:00
|
|
|
|
|
|
|
|
uint64_t updateTagValue() override {
|
|
|
|
|
return updateTagValueReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getTagAddressValue(TagData &tagData) override {
|
|
|
|
|
tagData.tagAddress = tagAddressSetValue;
|
|
|
|
|
tagData.tagValue = tagValueSetValue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 16:32:07 +01:00
|
|
|
void performDiagnosticMode() override {
|
|
|
|
|
if (!NEO::directSubmissionDiagnosticAvailable) {
|
|
|
|
|
disabledDiagnosticCalled++;
|
|
|
|
|
}
|
|
|
|
|
uint32_t add = 1;
|
|
|
|
|
if (diagnostic.get()) {
|
|
|
|
|
add += diagnostic->getExecutionsCount();
|
|
|
|
|
}
|
|
|
|
|
*static_cast<volatile uint32_t *>(workloadModeOneStoreAddress) = workloadModeOneExpectedValue + add;
|
|
|
|
|
BaseClass::performDiagnosticMode();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-15 17:02:47 +01:00
|
|
|
uint64_t updateTagValueReturn = 1ull;
|
|
|
|
|
uint64_t tagAddressSetValue = MemoryConstants::pageSize;
|
|
|
|
|
uint64_t tagValueSetValue = 1ull;
|
|
|
|
|
uint64_t submitGpuAddress = 0ull;
|
2020-03-27 16:32:07 +01:00
|
|
|
size_t submitSize = 0u;
|
|
|
|
|
uint32_t submitCount = 0u;
|
|
|
|
|
uint32_t handleResidencyCount = 0u;
|
|
|
|
|
uint32_t disabledDiagnosticCalled = 0u;
|
|
|
|
|
bool allocateOsResourcesReturn = true;
|
|
|
|
|
bool submitReturn = true;
|
|
|
|
|
bool handleResidencyReturn = true;
|
2021-09-03 11:40:34 +00:00
|
|
|
bool callBaseResident = false;
|
2020-01-15 17:02:47 +01:00
|
|
|
};
|
|
|
|
|
} // namespace NEO
|