2018-10-02 14:37:30 -07:00
|
|
|
/*
|
2020-01-21 15:24:52 +01:00
|
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
2018-10-02 14:37:30 -07:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
|
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
|
#include "shared/source/utilities/tag_allocator.h"
|
2018-10-02 14:37:30 -07:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
using namespace NEO;
|
2018-10-02 14:37:30 -07:00
|
|
|
|
|
|
|
|
void TimestampPacketContainer::add(Node *timestampPacketNode) {
|
|
|
|
|
timestampPacketNodes.push_back(timestampPacketNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimestampPacketContainer::~TimestampPacketContainer() {
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : timestampPacketNodes) {
|
|
|
|
|
node->returnTag();
|
2018-10-02 14:37:30 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimestampPacketContainer::swapNodes(TimestampPacketContainer ×tampPacketContainer) {
|
|
|
|
|
timestampPacketNodes.swap(timestampPacketContainer.timestampPacketNodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimestampPacketContainer::resolveDependencies(bool clearAllDependencies) {
|
|
|
|
|
std::vector<Node *> pendingNodes;
|
|
|
|
|
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : timestampPacketNodes) {
|
2019-12-02 08:37:42 +01:00
|
|
|
if (node->canBeReleased() || clearAllDependencies) {
|
2018-11-27 13:07:41 +01:00
|
|
|
node->returnTag();
|
2018-10-02 14:37:30 -07:00
|
|
|
} else {
|
|
|
|
|
pendingNodes.push_back(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::swap(timestampPacketNodes, pendingNodes);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:07:41 +01:00
|
|
|
void TimestampPacketContainer::assignAndIncrementNodesRefCounts(const TimestampPacketContainer &inputTimestampPacketContainer) {
|
2018-10-05 12:51:57 -07:00
|
|
|
auto &inputNodes = inputTimestampPacketContainer.peekNodes();
|
|
|
|
|
std::copy(inputNodes.begin(), inputNodes.end(), std::back_inserter(timestampPacketNodes));
|
|
|
|
|
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : inputNodes) {
|
2018-10-02 14:37:30 -07:00
|
|
|
node->incRefCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimestampPacketContainer::makeResident(CommandStreamReceiver &commandStreamReceiver) {
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : timestampPacketNodes) {
|
2019-02-08 10:27:48 +01:00
|
|
|
commandStreamReceiver.makeResident(*node->getBaseGraphicsAllocation());
|
2018-10-02 14:37:30 -07:00
|
|
|
}
|
|
|
|
|
}
|