/* * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/helpers/flat_batch_buffer_helper.h" #include "shared/source/execution_environment/execution_environment.h" #include "shared/source/memory_manager/graphics_allocation.h" namespace NEO { bool FlatBatchBufferHelper::setPatchInfoData(const PatchInfoData &data) { patchInfoCollection.push_back(data); return true; } bool FlatBatchBufferHelper::removePatchInfoData(uint64_t targetLocation) { for (auto it = patchInfoCollection.begin(); it != patchInfoCollection.end(); ++it) { if (it->targetAllocation + it->targetAllocationOffset == targetLocation) { patchInfoCollection.erase(it); break; } } return true; } bool FlatBatchBufferHelper::registerCommandChunk(uint64_t baseCpu, uint64_t baseGpu, uint64_t startOffset, uint64_t endOffset) { CommandChunk commandChunk; commandChunk.baseAddressGpu = baseGpu; commandChunk.baseAddressCpu = baseCpu; commandChunk.startOffset = startOffset; commandChunk.endOffset = endOffset; return registerCommandChunk(commandChunk); } bool FlatBatchBufferHelper::registerCommandChunk(BatchBuffer &batchBuffer, size_t batchBufferStartCommandSize) { CommandChunk commandChunk; commandChunk.baseAddressGpu = batchBuffer.stream->getGraphicsAllocation()->getGpuAddress(); commandChunk.baseAddressCpu = reinterpret_cast(batchBuffer.stream->getCpuBase()); commandChunk.startOffset = batchBuffer.startOffset; commandChunk.endOffset = batchBuffer.chainedBatchBufferStartOffset + batchBufferStartCommandSize; return registerCommandChunk(commandChunk); } bool FlatBatchBufferHelper::registerCommandChunk(CommandChunk &commandChunk) { commandChunkList.push_back(commandChunk); return true; } bool FlatBatchBufferHelper::registerBatchBufferStartAddress(uint64_t commandAddress, uint64_t startAddress) { batchBufferStartAddressSequence.insert(std::pair(commandAddress, startAddress)); return true; } void FlatBatchBufferHelper::fixCrossThreadDataInfo(std::vector &data, size_t offsetCrossThreadData, uint64_t gpuAddress) { for (auto &patchInfoData : data) { if (patchInfoData.sourceType == PatchInfoAllocationType::KernelArg) { patchInfoData.targetAllocation = gpuAddress; patchInfoData.targetAllocationOffset += offsetCrossThreadData; } } } MemoryManager *FlatBatchBufferHelper::getMemoryManager() const { return executionEnvironment.memoryManager.get(); } }; // namespace NEO