mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 08:07:19 +08:00
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:
committed by
sys_ocldev
parent
5d9467b753
commit
27c281a044
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user