2018-07-05 17:23:28 +08:00
|
|
|
/*
|
2023-01-04 23:00:09 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-07-05 17:23:28 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-07-05 17:23:28 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-03-04 03:01:14 +08:00
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
|
|
|
#include "shared/source/command_stream/experimental_command_buffer.h"
|
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
2022-11-10 17:37:42 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2023-02-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2021-12-22 22:11:05 +08:00
|
|
|
#include "shared/source/helpers/pipe_control_args.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2018-07-05 17:23:28 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-07-05 17:23:28 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void ExperimentalCommandBuffer::injectBufferStart(LinearStream &parentStream, size_t cmdBufferOffset) {
|
|
|
|
using MI_BATCH_BUFFER_START = typename GfxFamily::MI_BATCH_BUFFER_START;
|
2019-04-25 16:11:25 +08:00
|
|
|
auto pCmd = parentStream.getSpaceForCmd<MI_BATCH_BUFFER_START>();
|
|
|
|
auto commandStreamReceiverHw = static_cast<CommandStreamReceiverHw<GfxFamily> *>(commandStreamReceiver);
|
2018-07-05 17:23:28 +08:00
|
|
|
commandStreamReceiverHw->addBatchBufferStart(pCmd, currentStream->getGraphicsAllocation()->getGpuAddress() + cmdBufferOffset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t ExperimentalCommandBuffer::getRequiredInjectionSize() noexcept {
|
|
|
|
using MI_BATCH_BUFFER_START = typename GfxFamily::MI_BATCH_BUFFER_START;
|
|
|
|
return sizeof(MI_BATCH_BUFFER_START);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t ExperimentalCommandBuffer::programExperimentalCommandBuffer() {
|
|
|
|
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
|
|
|
|
|
|
|
|
getCS(getTotalExperimentalSize<GfxFamily>());
|
|
|
|
|
|
|
|
size_t returnOffset = currentStream->getUsed();
|
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
// begin timestamp
|
2018-07-05 17:23:28 +08:00
|
|
|
addTimeStampPipeControl<GfxFamily>();
|
|
|
|
|
|
|
|
addExperimentalCommands<GfxFamily>();
|
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
// end timestamp
|
2018-07-05 17:23:28 +08:00
|
|
|
addTimeStampPipeControl<GfxFamily>();
|
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
// end
|
2019-04-25 16:11:25 +08:00
|
|
|
auto pCmd = currentStream->getSpaceForCmd<MI_BATCH_BUFFER_END>();
|
2018-07-05 17:23:28 +08:00
|
|
|
*pCmd = GfxFamily::cmdInitBatchBufferEnd;
|
|
|
|
|
|
|
|
return returnOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t ExperimentalCommandBuffer::getTotalExperimentalSize() noexcept {
|
|
|
|
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
|
|
|
|
|
|
|
|
size_t size = sizeof(MI_BATCH_BUFFER_END) + getTimeStampPipeControlSize<GfxFamily>() + getExperimentalCommandsSize<GfxFamily>();
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t ExperimentalCommandBuffer::getTimeStampPipeControlSize() noexcept {
|
2019-07-11 20:35:40 +08:00
|
|
|
// Two P_C for timestamps
|
2022-07-21 22:28:10 +08:00
|
|
|
return 2 * MemorySynchronizationCommands<GfxFamily>::getSizeForBarrierWithPostSyncOperation(
|
2023-01-26 11:58:18 +08:00
|
|
|
*commandStreamReceiver->peekExecutionEnvironment().rootDeviceEnvironments[commandStreamReceiver->getRootDeviceIndex()], false);
|
2018-07-05 17:23:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void ExperimentalCommandBuffer::addTimeStampPipeControl() {
|
|
|
|
uint64_t timeStampAddress = timestamps->getGpuAddress() + timestampsOffset;
|
2020-04-27 03:48:59 +08:00
|
|
|
PipeControlArgs args;
|
2022-07-21 22:28:10 +08:00
|
|
|
MemorySynchronizationCommands<GfxFamily>::addBarrierWithPostSyncOperation(
|
2020-04-27 03:48:59 +08:00
|
|
|
*currentStream,
|
2022-07-21 22:28:10 +08:00
|
|
|
PostSyncMode::Timestamp,
|
2020-04-27 03:48:59 +08:00
|
|
|
timeStampAddress,
|
|
|
|
0llu,
|
2023-01-26 11:58:18 +08:00
|
|
|
*commandStreamReceiver->peekExecutionEnvironment().rootDeviceEnvironments[commandStreamReceiver->getRootDeviceIndex()],
|
2020-04-27 03:48:59 +08:00
|
|
|
args);
|
2018-07-05 17:23:28 +08:00
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
// moving to next chunk
|
2018-07-05 17:23:28 +08:00
|
|
|
timestampsOffset += sizeof(uint64_t);
|
|
|
|
|
|
|
|
DEBUG_BREAK_IF(timestamps->getUnderlyingBufferSize() < timestampsOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void ExperimentalCommandBuffer::addExperimentalCommands() {
|
|
|
|
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
|
|
|
|
|
2019-04-25 16:11:25 +08:00
|
|
|
uint32_t *semaphoreData = reinterpret_cast<uint32_t *>(ptrOffset(experimentalAllocation->getUnderlyingBuffer(), experimentalAllocationOffset));
|
2018-07-05 17:23:28 +08:00
|
|
|
*semaphoreData = 1;
|
|
|
|
uint64_t gpuAddr = experimentalAllocation->getGpuAddress() + experimentalAllocationOffset;
|
|
|
|
|
2023-03-10 21:49:06 +08:00
|
|
|
EncodeSemaphore<GfxFamily>::programMiSemaphoreWait(currentStream->getSpaceForCmd<MI_SEMAPHORE_WAIT>(),
|
2023-03-04 03:01:14 +08:00
|
|
|
gpuAddr,
|
|
|
|
*semaphoreData,
|
|
|
|
MI_SEMAPHORE_WAIT::COMPARE_OPERATION_SAD_EQUAL_SDD,
|
2023-09-12 19:42:40 +08:00
|
|
|
false, false, false, false);
|
2018-07-05 17:23:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t ExperimentalCommandBuffer::getExperimentalCommandsSize() noexcept {
|
2023-03-10 21:49:06 +08:00
|
|
|
return NEO::EncodeSemaphore<GfxFamily>::getSizeMiSemaphoreWait();
|
2018-07-05 17:23:28 +08:00
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|