@@ -1584,8 +1584,8 @@ HWTEST2_F(ImmediateCommandListTest, givenImmediateCmdListWhenAppendingRegularThe
15841584 auto startStream = static_cast <L0::CommandQueueImp *>(commandListImmediate->cmdQImmediate )->getStartingCmdBuffer ();
15851585
15861586 if (commandListImmediate->getCmdListBatchBufferFlag ()) {
1587- auto expectedStream = commandList->getCmdContainer ().getCommandStream ();
1588- EXPECT_EQ (expectedStream , startStream);
1587+ auto expectedStreamAllocation = commandList->getCmdContainer ().getCommandStream ()-> getGraphicsAllocation ();
1588+ EXPECT_EQ (expectedStreamAllocation , startStream-> getGraphicsAllocation () );
15891589 } else {
15901590 auto expectedStream = commandListImmediate->getCmdContainer ().getCommandStream ();
15911591 EXPECT_EQ (expectedStream, startStream);
@@ -1696,5 +1696,66 @@ HWTEST2_F(ImmediateCommandListTest,
16961696 EXPECT_NE (cmdList.end (), iterator);
16971697}
16981698
1699+ HWTEST2_F (ImmediateCommandListTest,
1700+ givenImmediateCmdListWithPrimaryBatchBufferWhenAppendingRegularCmdListWithWaitEventThenDispatchSemaphoreAndJumpFromImmediateToRegular, MatchAny) {
1701+ using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
1702+ using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
1703+
1704+ ze_event_pool_desc_t eventPoolDesc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC};
1705+ eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE;
1706+ eventPoolDesc.count = 2 ;
1707+
1708+ ze_event_desc_t eventDesc = {ZE_STRUCTURE_TYPE_EVENT_DESC};
1709+ eventDesc.index = 0 ;
1710+ eventDesc.wait = 0 ;
1711+ eventDesc.signal = 0 ;
1712+
1713+ ze_result_t returnValue;
1714+ std::unique_ptr<EventPool> eventPool = std::unique_ptr<EventPool>(static_cast <EventPool *>(EventPool::create (driverHandle.get (), context, 0 , nullptr , &eventPoolDesc, returnValue)));
1715+ std::unique_ptr<L0::Event> event = std::unique_ptr<L0::Event>(getHelper<L0GfxCoreHelper>().createEvent (eventPool.get (), &eventDesc, device));
1716+ auto eventHandle = event->toHandle ();
1717+
1718+ commandList->close ();
1719+ auto cmdListHandle = commandList->toHandle ();
1720+
1721+ auto regularCmdBufferStream = commandList->getCmdContainer ().getCommandStream ();
1722+ auto regularCmdBufferAllocation = regularCmdBufferStream->getGraphicsAllocation ();
1723+
1724+ auto cmdQImmediate = static_cast <WhiteBox<::L0::CommandQueue> *>(commandListImmediate->cmdQImmediate );
1725+
1726+ commandListImmediate->dispatchCmdListBatchBufferAsPrimary = true ;
1727+ cmdQImmediate->dispatchCmdListBatchBufferAsPrimary = true ;
1728+
1729+ // first append can carry preamble
1730+ returnValue = commandListImmediate->appendCommandLists (1 , &cmdListHandle, nullptr , 0 , nullptr );
1731+ EXPECT_EQ (ZE_RESULT_SUCCESS, returnValue);
1732+
1733+ auto immediateCmdBufferStream = commandListImmediate->getCmdContainer ().getCommandStream ();
1734+ auto offsetBefore = immediateCmdBufferStream->getUsed ();
1735+
1736+ // no preamble but wait event as first, then bb_start jumping to regular cmdlist
1737+ returnValue = commandListImmediate->appendCommandLists (1 , &cmdListHandle, nullptr , 1 , &eventHandle);
1738+ EXPECT_EQ (ZE_RESULT_SUCCESS, returnValue);
1739+
1740+ auto offsetAfter = immediateCmdBufferStream->getUsed ();
1741+
1742+ GenCmdList cmdList;
1743+ ASSERT_TRUE (FamilyType::Parse::parseCommandBuffer (
1744+ cmdList,
1745+ ptrOffset (immediateCmdBufferStream->getCpuBase (), offsetBefore),
1746+ offsetAfter - offsetBefore));
1747+
1748+ auto iteratorWait = find<MI_SEMAPHORE_WAIT *>(cmdList.begin (), cmdList.end ());
1749+ ASSERT_NE (cmdList.end (), iteratorWait);
1750+
1751+ auto iteratorBbStart = find<MI_BATCH_BUFFER_START *>(iteratorWait, cmdList.end ());
1752+ ASSERT_NE (cmdList.end (), iteratorBbStart);
1753+
1754+ auto bbStart = genCmdCast<MI_BATCH_BUFFER_START *>(*iteratorBbStart);
1755+
1756+ EXPECT_EQ (regularCmdBufferAllocation->getGpuAddress (), bbStart->getBatchBufferStartAddress ());
1757+ EXPECT_EQ (MI_BATCH_BUFFER_START::SECOND_LEVEL_BATCH_BUFFER::SECOND_LEVEL_BATCH_BUFFER_FIRST_LEVEL_BATCH, bbStart->getSecondLevelBatchBuffer ());
1758+ }
1759+
16991760} // namespace ult
17001761} // namespace L0
0 commit comments