Fix start and dispatch blitter commands in direct mode

Related-To: NEO-5010

Change-Id: I3d03ef39325adb2beba26a989906381f5eccc4ff
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-10-19 15:36:57 +02:00
committed by sys_ocldev
parent 5d9467b753
commit 27c281a044
13 changed files with 343 additions and 37 deletions

View File

@@ -77,6 +77,10 @@ bool DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Reside
memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1), true);
return this->directSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get());
}
if (this->blitterDirectSubmission.get()) {
memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1), true);
return this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get());
}
this->flushStamp->setStamp(bb->peekHandle());
this->flushInternal(batchBuffer, allocationsForResidency);

View File

@@ -77,6 +77,9 @@ bool WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Resid
if (directSubmission.get()) {
return directSubmission->dispatchCommandBuffer(batchBuffer, *(flushStamp.get()));
}
if (blitterDirectSubmission.get()) {
return blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(flushStamp.get()));
}
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandBufferHeader);
pHeader->RequiresCoherency = batchBuffer.requiresCoherency;

View File

@@ -222,8 +222,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterNotSuppo
properties.engineSupported = false;
properties.submitOnInit = false;
bool startOnInit = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit));
bool startInContext = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterSupportedThenExpectTrueReturned) {
@@ -233,8 +235,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenNoBlitterOverrideWhenBlitterSupporte
properties.engineSupported = true;
properties.submitOnInit = true;
bool startOnInit = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit, startInContext));
EXPECT_TRUE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideEnableWhenBlitterNotSupportedThenExpectTrueReturned) {
@@ -246,8 +250,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideEnableWhenBlitterNotS
properties.engineSupported = false;
properties.submitOnInit = false;
bool startOnInit = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit, startInContext));
EXPECT_TRUE(startOnInit);
EXPECT_TRUE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideEnableAndNoStartWhenBlitterNotSupportedThenExpectTrueReturnedStartOnInitSetToTrue) {
@@ -259,8 +265,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideEnableAndNoStartWhenB
properties.engineSupported = false;
properties.submitOnInit = true;
bool startOnInit = true;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_TRUE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideDisableWhenBlitterSupportedThenExpectFalseReturned) {
@@ -272,8 +280,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenBlitterOverrideDisableWhenBlitterSup
properties.engineSupported = true;
properties.submitOnInit = false;
bool startOnInit = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit));
bool startInContext = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_BCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderNotSupportedThenExpectFalseReturned) {
@@ -283,8 +293,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderNotSupport
properties.engineSupported = false;
properties.submitOnInit = false;
bool startOnInit = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit));
bool startInContext = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderSupportedThenExpectTrueReturned) {
@@ -294,8 +306,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenNoRenderOverrideWhenRenderSupportedT
properties.engineSupported = true;
properties.submitOnInit = true;
bool startOnInit = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit, startInContext));
EXPECT_TRUE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideEnableWhenRenderNotSupportedThenExpectTrueReturned) {
@@ -307,8 +321,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideEnableWhenRenderNotSup
properties.engineSupported = false;
properties.submitOnInit = false;
bool startOnInit = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit, startInContext));
EXPECT_TRUE(startOnInit);
EXPECT_TRUE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideEnableAndNoStartWhenRenderNotSupportedThenExpectTrueReturnedAndStartOnInitSetFalse) {
@@ -320,8 +336,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideEnableAndNoStartWhenRe
properties.engineSupported = false;
properties.submitOnInit = true;
bool startOnInit = true;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_TRUE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideDisableWhenRenderSupportedThenExpectFalseReturned) {
@@ -333,8 +351,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenRenderOverrideDisableWhenRenderSuppo
properties.engineSupported = true;
properties.submitOnInit = false;
bool startOnInit = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit));
bool startInContext = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_RCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeNotSupportedThenExpectFalseReturned) {
@@ -344,8 +364,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeNotSuppo
properties.engineSupported = false;
properties.submitOnInit = false;
bool startOnInit = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit));
bool startInContext = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeSupportedThenExpectTrueReturned) {
@@ -355,8 +377,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenNoComputeOverrideWhenComputeSupporte
properties.engineSupported = true;
properties.submitOnInit = true;
bool startOnInit = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit, startInContext));
EXPECT_TRUE(startOnInit);
EXPECT_FALSE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideEnableWhenComputeNotSupportedThenExpectTrueReturned) {
@@ -368,8 +392,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideEnableWhenComputeNotS
properties.engineSupported = false;
properties.submitOnInit = false;
bool startOnInit = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit, startInContext));
EXPECT_TRUE(startOnInit);
EXPECT_TRUE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideEnableAndNoStartWhenComputeNotSupportedThenExpectTrueReturnedAndStartOnInitSetToFalse) {
@@ -381,8 +407,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideEnableAndNoStartWhenC
properties.engineSupported = false;
properties.submitOnInit = true;
bool startOnInit = true;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit));
bool startInContext = false;
EXPECT_TRUE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_TRUE(startInContext);
}
HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideDisableWhenComputeSupportedThenExpectFalseReturned) {
@@ -394,8 +422,10 @@ HWTEST_F(UltCommandStreamReceiverTest, givenComputeOverrideDisableWhenComputeSup
properties.engineSupported = true;
properties.submitOnInit = false;
bool startOnInit = true;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit));
bool startInContext = false;
EXPECT_FALSE(commandStreamReceiver.checkDirectSubmissionSupportsEngine(properties, aub_stream::ENGINE_CCS, startOnInit, startInContext));
EXPECT_FALSE(startOnInit);
EXPECT_FALSE(startInContext);
}
typedef UltCommandStreamReceiverTest CommandStreamReceiverFlushTests;
@@ -574,7 +604,7 @@ HWTEST_F(BcsTests, whenAskingForCmdSizeForMiFlushDwWithMemoryWriteThenReturnCorr
EXPECT_EQ(miFlushDwSize + additionalSize, totalSize);
}
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeThenCalculateForAllAttachedProperites) {
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenEstimatingCommandsSizeThenCalculateForAllAttachedProperites) {
const auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
const uint32_t numberOfBlts = 3;
const size_t bltSize = (3 * max2DBlitSize);
@@ -598,12 +628,41 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeThenCa
expectedAlignedSize = alignUp(expectedAlignedSize, MemoryConstants::cacheLineSize);
auto alignedEstimatedSize = BlitCommandsHelper<FamilyType>::estimateBlitCommandsSize(
blitPropertiesContainer, false, false, pClDevice->getRootDeviceEnvironment());
blitPropertiesContainer, false, false, false, pClDevice->getRootDeviceEnvironment());
EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize);
}
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeForWriteReadBufferRectThenCalculateForAllAttachedProperites) {
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectsubmissionEnabledEstimatingCommandsSizeThenCalculateForAllAttachedProperites) {
const auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
const uint32_t numberOfBlts = 3;
const size_t bltSize = (3 * max2DBlitSize);
const uint32_t numberOfBlitOperations = 4;
auto baseSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_START);
constexpr size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts;
auto expectedAlignedSize = baseSize + MemorySynchronizationCommands<FamilyType>::getSizeForAdditonalSynchronization(pDevice->getHardwareInfo());
BlitPropertiesContainer blitPropertiesContainer;
for (uint32_t i = 0; i < numberOfBlitOperations; i++) {
BlitProperties blitProperties;
blitProperties.copySize = {bltSize, 1, 1};
blitPropertiesContainer.push_back(blitProperties);
expectedAlignedSize += expectedBlitInstructionsSize;
}
expectedAlignedSize = alignUp(expectedAlignedSize, MemoryConstants::cacheLineSize);
auto alignedEstimatedSize = BlitCommandsHelper<FamilyType>::estimateBlitCommandsSize(
blitPropertiesContainer, false, false, true, pClDevice->getRootDeviceEnvironment());
EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize);
}
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenEstimatingCommandsSizeForWriteReadBufferRectThenCalculateForAllAttachedProperites) {
constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
const Vec3<size_t> bltSize = {(3 * max2DBlitSize), 4, 2};
const size_t numberOfBlts = 3 * bltSize.y * bltSize.z;
@@ -627,7 +686,36 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeForWri
expectedAlignedSize = alignUp(expectedAlignedSize, MemoryConstants::cacheLineSize);
auto alignedEstimatedSize = BlitCommandsHelper<FamilyType>::estimateBlitCommandsSize(
blitPropertiesContainer, false, false, pClDevice->getRootDeviceEnvironment());
blitPropertiesContainer, false, false, false, pClDevice->getRootDeviceEnvironment());
EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize);
}
HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenDirectSubmissionEnabledEstimatingCommandsSizeForWriteReadBufferRectThenCalculateForAllAttachedProperites) {
constexpr auto max2DBlitSize = BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight;
const Vec3<size_t> bltSize = {(3 * max2DBlitSize), 4, 2};
const size_t numberOfBlts = 3 * bltSize.y * bltSize.z;
const size_t numberOfBlitOperations = 4 * bltSize.y * bltSize.z;
const size_t cmdsSizePerBlit = sizeof(typename FamilyType::XY_COPY_BLT) + sizeof(typename FamilyType::MI_ARB_CHECK);
auto baseSize = EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_START);
auto expectedBlitInstructionsSize = cmdsSizePerBlit * numberOfBlts;
auto expectedAlignedSize = baseSize + MemorySynchronizationCommands<FamilyType>::getSizeForAdditonalSynchronization(pDevice->getHardwareInfo());
BlitPropertiesContainer blitPropertiesContainer;
for (uint32_t i = 0; i < numberOfBlitOperations; i++) {
BlitProperties blitProperties;
blitProperties.copySize = bltSize;
blitPropertiesContainer.push_back(blitProperties);
expectedAlignedSize += expectedBlitInstructionsSize;
}
expectedAlignedSize = alignUp(expectedAlignedSize, MemoryConstants::cacheLineSize);
auto alignedEstimatedSize = BlitCommandsHelper<FamilyType>::estimateBlitCommandsSize(
blitPropertiesContainer, false, false, true, pClDevice->getRootDeviceEnvironment());
EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize);
}

View File

@@ -6,6 +6,9 @@
*/
#include "shared/source/command_stream/scratch_space_controller_base.h"
#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h"
#include "shared/test/unit_test/helpers/ult_hw_config.h"
#include "shared/test/unit_test/mocks/mock_direct_submission_hw.h"
#include "shared/test/unit_test/utilities/base_object_utils.h"
#include "opencl/source/event/user_event.h"
@@ -66,7 +69,7 @@ HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequir
blitPropertiesContainer.push_back(blitProperties);
auto estimatedSize = BlitCommandsHelper<FamilyType>::estimateBlitCommandsSize(
blitPropertiesContainer, false, true, pClDevice->getRootDeviceEnvironment());
blitPropertiesContainer, false, true, false, pClDevice->getRootDeviceEnvironment());
EXPECT_EQ(expectedSize, estimatedSize);
EXPECT_FALSE(BlitCommandsHelper<FamilyType>::isCopyRegionPreferred(blitProperties.copySize, pClDevice->getRootDeviceEnvironment()));
@@ -1166,6 +1169,50 @@ HWTEST_F(BcsTests, givenInvalidBlitDirectionWhenConstructPropertiesThenException
EXPECT_THROW(ClBlitProperties::constructProperties(static_cast<BlitterConstants::BlitDirection>(7), csr, {}), std::exception);
}
HWTEST_F(BcsTests, givenBlitterDirectSubmissionEnabledWhenProgrammingBlitterThenExpectRingBufferDispatched) {
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
VariableBackup<UltHwConfig> backup(&ultHwConfig);
ultHwConfig.csrBaseCallBlitterDirectSubmissionAvailable = true;
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
using DirectSubmission = MockDirectSubmissionHw<FamilyType, BlitterDispatcher<FamilyType>>;
csr.blitterDirectSubmission = std::make_unique<DirectSubmission>(*pDevice, *csr.osContext);
csr.recordFlusheBatchBuffer = true;
DirectSubmission *directSubmission = reinterpret_cast<DirectSubmission *>(csr.blitterDirectSubmission.get());
bool initRet = directSubmission->initialize(true);
EXPECT_TRUE(initRet);
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
size_t numberNodesPerContainer = 5;
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, graphicsAllocation, nullptr, hostPtr,
graphicsAllocation->getGpuAddress(), 0,
0, 0, {1, 1, 1}, 0, 0, 0, 0);
MockTimestampPacketContainer timestamp0(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
MockTimestampPacketContainer timestamp1(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
blitProperties.csrDependencies.push_back(&timestamp0);
blitProperties.csrDependencies.push_back(&timestamp1);
blitBuffer(&csr, blitProperties, true);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(csr.commandStream, 0u);
ASSERT_NE(nullptr, csr.latestFlushedBatchBuffer.endCmdPtr);
MI_BATCH_BUFFER_START *bbStart = hwParser.getCommand<MI_BATCH_BUFFER_START>();
ASSERT_NE(nullptr, bbStart);
EXPECT_EQ(csr.latestFlushedBatchBuffer.endCmdPtr, bbStart);
EXPECT_EQ(0ull, bbStart->getBatchBufferStartAddressGraphicsaddress472());
}
struct MockScratchSpaceController : ScratchSpaceControllerBase {
using ScratchSpaceControllerBase::privateScratchAllocation;
using ScratchSpaceControllerBase::ScratchSpaceControllerBase;

View File

@@ -322,8 +322,8 @@ HWTEST_F(CommandStreamReceiverTest, whenDirectSubmissionDisabledThenExpectNoFeat
EXPECT_FALSE(csr.isBlitterDirectSubmissionEnabled());
}
struct InitDirectSubmissionTest : public ::testing::Test {
void SetUp() override {
struct InitDirectSubmissionFixture {
void SetUp() {
DebugManager.flags.EnableDirectSubmission.set(1);
executionEnvironment = new MockExecutionEnvironment();
DeviceFactory::prepareDeviceEnvironments(*executionEnvironment);
@@ -333,11 +333,15 @@ struct InitDirectSubmissionTest : public ::testing::Test {
device.reset(new MockDevice(executionEnvironment, 0u));
}
void TearDown() {}
DebugManagerStateRestore restore;
MockExecutionEnvironment *executionEnvironment;
std::unique_ptr<MockDevice> device;
};
using InitDirectSubmissionTest = Test<InitDirectSubmissionFixture>;
HWTEST_F(InitDirectSubmissionTest, whenDirectSubmissionEnabledOnRcsThenExpectFeatureAvailable) {
auto csr = std::make_unique<CommandStreamReceiverHw<FamilyType>>(*device->executionEnvironment, device->getRootDeviceIndex());
std::unique_ptr<OsContext> osContext(OsContext::create(device->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(),
@@ -559,6 +563,27 @@ HWTEST_F(InitDirectSubmissionTest, givenNonDefaultContextContextWhenDirectSubmis
csr.reset();
}
HWTEST_F(InitDirectSubmissionTest, GivenBlitterOverrideEnabledWhenBlitterIsNonDefaultContextThenExpectDirectSubmissionStarted) {
DebugManager.flags.DirectSubmissionOverrideBlitterSupport.set(1);
auto csr = std::make_unique<CommandStreamReceiverHw<FamilyType>>(*device->executionEnvironment, device->getRootDeviceIndex());
std::unique_ptr<OsContext> osContext(OsContext::create(device->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(),
0, device->getDeviceBitfield(), aub_stream::ENGINE_BCS, PreemptionMode::ThreadGroup,
false, false, false));
osContext->setDefaultContext(false);
auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].engineSupported = false;
hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].useNonDefault = false;
hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].submitOnInit = false;
bool ret = csr->initDirectSubmission(*device, *osContext.get());
EXPECT_TRUE(ret);
EXPECT_FALSE(csr->isDirectSubmissionEnabled());
EXPECT_TRUE(csr->isBlitterDirectSubmissionEnabled());
EXPECT_TRUE(osContext->isDirectSubmissionActive());
}
HWTEST_F(CommandStreamReceiverTest, whenCsrIsCreatedThenUseTimestampPacketWriteIfPossible) {
CommandStreamReceiverHw<FamilyType> csr(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
EXPECT_EQ(UnitTestHelper<FamilyType>::isTimestampPacketWriteSupported(), csr.peekTimestampPacketWriteEnabled());

View File

@@ -29,8 +29,10 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
using BaseClass = CommandStreamReceiverHw<GfxFamily>;
public:
using BaseClass::blitterDirectSubmission;
using BaseClass::checkPlatformSupportsGpuIdleImplicitFlush;
using BaseClass::checkPlatformSupportsNewResourceImplicitFlush;
using BaseClass::directSubmission;
using BaseClass::dshState;
using BaseClass::getCmdSizeForPrologue;
using BaseClass::getScratchPatchAddress;

View File

@@ -20,6 +20,7 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
using CommandStreamReceiver::useNewResourceImplicitFlush;
using DrmCommandStreamReceiver<GfxFamily>::residency;
using CommandStreamReceiverHw<GfxFamily>::directSubmission;
using CommandStreamReceiverHw<GfxFamily>::blitterDirectSubmission;
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::lastSentSliceCount;
TestedDrmCommandStreamReceiver(gemCloseWorkerMode mode, ExecutionEnvironment &executionEnvironment)

View File

@@ -1312,11 +1312,39 @@ struct DrmCommandStreamDirectSubmissionTest : public DrmCommandStreamEnhancedTes
DebugManagerStateRestore restorer;
};
struct DrmCommandStreamBlitterDirectSubmissionTest : public DrmCommandStreamDirectSubmissionTest {
template <typename GfxFamily>
void SetUpT() {
DebugManager.flags.DirectSubmissionOverrideBlitterSupport.set(1u);
DebugManager.flags.DirectSubmissionOverrideRenderSupport.set(0u);
DebugManager.flags.DirectSubmissionOverrideComputeSupport.set(0u);
DrmCommandStreamDirectSubmissionTest::SetUpT<GfxFamily>();
osContext.reset(OsContext::create(device->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(),
0, device->getDeviceBitfield(), aub_stream::ENGINE_BCS, PreemptionMode::ThreadGroup,
false, false, false));
csr->initDirectSubmission(*device.get(), *osContext.get());
}
template <typename GfxFamily>
void TearDownT() {
DrmCommandStreamDirectSubmissionTest::TearDownT<GfxFamily>();
}
std::unique_ptr<OsContext> osContext;
};
template <typename GfxFamily>
struct MockDrmDirectSubmission : public DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>> {
using DrmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>::currentTagData;
};
template <typename GfxFamily>
struct MockDrmBlitterDirectSubmission : public DrmDirectSubmission<GfxFamily, BlitterDispatcher<GfxFamily>> {
using DrmDirectSubmission<GfxFamily, BlitterDispatcher<GfxFamily>>::currentTagData;
};
HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmissionWhenFlushThenFlushStampIsNotUpdated) {
auto &cs = csr->getCS();
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
@@ -1331,6 +1359,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmi
EXPECT_EQ(csr->obtainCurrentFlushStamp(), flushStamp);
auto directSubmission = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->directSubmission.get();
ASSERT_NE(nullptr, directSubmission);
static_cast<MockDrmDirectSubmission<FamilyType> *>(directSubmission)->currentTagData.tagValue = 0u;
}
@@ -1348,9 +1377,50 @@ HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmi
EXPECT_EQ(memoryOperationsInterface->isResident(device.get(), *batchBuffer.commandBufferAllocation), MemoryOperationsStatus::SUCCESS);
auto directSubmission = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->directSubmission.get();
ASSERT_NE(nullptr, directSubmission);
static_cast<MockDrmDirectSubmission<FamilyType> *>(directSubmission)->currentTagData.tagValue = 0u;
}
HWTEST_TEMPLATED_F(DrmCommandStreamBlitterDirectSubmissionTest, givenEnabledDirectSubmissionOnBlitterWhenFlushThenFlushStampIsNotUpdated) {
auto &cs = csr->getCS();
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr};
uint8_t bbStart[64];
batchBuffer.endCmdPtr = &bbStart[0];
auto flushStamp = csr->obtainCurrentFlushStamp();
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(csr->obtainCurrentFlushStamp(), flushStamp);
auto directSubmission = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->blitterDirectSubmission.get();
ASSERT_NE(nullptr, directSubmission);
static_cast<MockDrmBlitterDirectSubmission<FamilyType> *>(directSubmission)->currentTagData.tagValue = 0u;
EXPECT_EQ(nullptr, static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->directSubmission.get());
}
HWTEST_TEMPLATED_F(DrmCommandStreamBlitterDirectSubmissionTest, givenEnabledDirectSubmissionOnBlitterWhenFlushThenCommandBufferAllocationIsResident) {
auto &cs = csr->getCS();
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr};
uint8_t bbStart[64];
batchBuffer.endCmdPtr = &bbStart[0];
csr->flush(batchBuffer, csr->getResidencyAllocations());
auto memoryOperationsInterface = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get();
EXPECT_EQ(memoryOperationsInterface->isResident(device.get(), *batchBuffer.commandBufferAllocation), MemoryOperationsStatus::SUCCESS);
auto directSubmission = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->blitterDirectSubmission.get();
ASSERT_NE(nullptr, directSubmission);
static_cast<MockDrmBlitterDirectSubmission<FamilyType> *>(directSubmission)->currentTagData.tagValue = 0u;
EXPECT_EQ(nullptr, static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->directSubmission.get());
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, CheckDrmFree) {
auto &cs = csr->getCS();
auto commandBuffer = static_cast<DrmAllocation *>(cs.getGraphicsAllocation());

View File

@@ -123,10 +123,16 @@ struct MockWddmCsr : public WddmCommandStreamReceiver<GfxFamily> {
}
bool ret = true;
if (DebugManager.flags.EnableDirectSubmission.get() == 1) {
directSubmission = std::make_unique<
MockWddmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>>(device, osContext);
ret = directSubmission->initialize(true);
this->dispatchMode = DispatchMode::ImmediateDispatch;
if (!initBlitterDirectSubmission) {
directSubmission = std::make_unique<
MockWddmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>>(device, osContext);
ret = directSubmission->initialize(true);
this->dispatchMode = DispatchMode::ImmediateDispatch;
} else {
blitterDirectSubmission = std::make_unique<
MockWddmDirectSubmission<GfxFamily, BlitterDispatcher<GfxFamily>>>(device, osContext);
blitterDirectSubmission->initialize(true);
}
}
return ret;
}
@@ -135,6 +141,7 @@ struct MockWddmCsr : public WddmCommandStreamReceiver<GfxFamily> {
std::unique_ptr<CommandBuffer> recordedCommandBuffer = nullptr;
bool callParentInitDirectSubmission = true;
bool initBlitterDirectSubmission = false;
};
class WddmCommandStreamWithMockGdiFixture {
@@ -1042,6 +1049,44 @@ TEST_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnRcsWhenFlushi
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnBcsWhenFlushingCommandBufferThenExpectDirectSubmissionUsed) {
using Dispatcher = BlitterDispatcher<DEFAULT_TEST_FAMILY_NAME>;
using MockSubmission =
MockWddmDirectSubmission<DEFAULT_TEST_FAMILY_NAME, Dispatcher>;
DebugManager.flags.EnableDirectSubmission.set(1);
auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].engineSupported = true;
std::unique_ptr<OsContext> osContext;
osContext.reset(OsContext::create(device->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(),
0, device->getDeviceBitfield(), aub_stream::ENGINE_BCS, PreemptionMode::ThreadGroup,
false, false, false));
csr->callParentInitDirectSubmission = false;
csr->initBlitterDirectSubmission = true;
bool ret = csr->initDirectSubmission(*device.get(), *osContext.get());
EXPECT_TRUE(ret);
EXPECT_FALSE(csr->isDirectSubmissionEnabled());
EXPECT_TRUE(csr->isBlitterDirectSubmissionEnabled());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0,
nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(),
&cs, commandBuffer->getUnderlyingBuffer()};
csr->flush(batchBuffer, csr->getResidencyAllocations());
auto directSubmission = reinterpret_cast<MockSubmission *>(csr->blitterDirectSubmission.get());
EXPECT_TRUE(directSubmission->ringStart);
size_t actualDispatchSize = directSubmission->ringCommandStream.getUsed();
size_t expectedSize = directSubmission->getSizeSemaphoreSection() +
Dispatcher::getSizePreemption() +
directSubmission->getSizeDispatch();
EXPECT_EQ(expectedSize, actualDispatchSize);
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenResidencyLoggingAvailableWhenFlushingCommandBufferThenNotifiesResidencyLogger) {
if (!NEO::wddmResidencyLoggingAvailable) {
GTEST_SKIP();