From 4106398002690ff96549679db1d23dded8991b9a Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Tue, 9 Apr 2024 11:43:41 +0000 Subject: [PATCH] fix: Restore main command stream when reset cmd list Signed-off-by: Lukasz Jobczyk --- .../unit_tests/sources/cmdlist/test_cmdlist_5.cpp | 5 +++++ shared/source/command_container/cmdcontainer.cpp | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp index b93300af98..69ce6c4772 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp @@ -930,6 +930,11 @@ HWTEST2_F(CommandListCreate, givenSecondaryCommandStreamForImmediateCmdListWhenC EXPECT_EQ(commandList->getCmdContainer().getCommandStream(), secondaryCmdStream); EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(commandList->getCmdContainer().getCommandStream()->getGraphicsAllocation()->getMemoryPool())); + + commandList->reset(); + + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(commandList->getCmdContainer().getCommandStream()->getGraphicsAllocation()->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(reinterpret_cast(&commandList->getCmdContainer())->secondaryCommandStreamForImmediateCmdList->getGraphicsAllocation()->getMemoryPool())); } HWTEST2_F(CommandListCreate, givenNoSecondaryCommandStreamForImmediateCmdListWhenCheckAvailableSpaceThenNotSwapCommandStreams, IsAtLeastSkl) { diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index 995d2ca173..526ef033d0 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -195,8 +195,18 @@ void CommandContainer::reset() { getDeallocationContainer().clear(); sshAllocations.clear(); - this->handleCmdBufferAllocations(1u); - cmdBufferAllocations.erase(cmdBufferAllocations.begin() + 1, cmdBufferAllocations.end()); + auto defaultCmdBuffersCnt = 1u + this->useSecondaryCommandStream; + + this->handleCmdBufferAllocations(defaultCmdBuffersCnt); + cmdBufferAllocations.erase(cmdBufferAllocations.begin() + defaultCmdBuffersCnt, cmdBufferAllocations.end()); + + if (this->useSecondaryCommandStream) { + if (!NEO::MemoryPoolHelper::isSystemMemoryPool(this->getCommandStream()->getGraphicsAllocation()->getMemoryPool())) { + this->swapStreams(); + } + setCmdBuffer(cmdBufferAllocations[1]); + this->swapStreams(); + } setCmdBuffer(cmdBufferAllocations[0]);