1010#include " shared/source/memory_manager/allocations_list.h"
1111#include " shared/test/common/fixtures/device_fixture.h"
1212#include " shared/test/common/helpers/debug_manager_state_restore.h"
13- #include " shared/test/common/mocks/mock_command_container.h"
1413#include " shared/test/common/mocks/mock_graphics_allocation.h"
1514#include " shared/test/common/mocks/mock_memory_manager.h"
1615#include " shared/test/common/test_macros/test.h"
@@ -28,17 +27,18 @@ class CommandContainerTest : public DeviceFixture,
2827 DeviceFixture::SetUp ();
2928 }
3029 void TearDown () override {
31- allocList.freeAllGraphicsAllocations (pDevice);
32-
3330 DeviceFixture::TearDown ();
3431 ::testing::Test::TearDown ();
3532 }
36-
37- AllocationsList allocList;
3833};
3934
4035struct CommandContainerHeapStateTests : public ::testing::Test {
41- MockCommandContainer myCommandContainer;
36+ class MyMockCommandContainer : public CommandContainer {
37+ public:
38+ using CommandContainer::dirtyHeaps;
39+ };
40+
41+ MyMockCommandContainer myCommandContainer;
4242};
4343
4444TEST_F (CommandContainerHeapStateTests, givenDirtyHeapsWhenSettingStateForAllThenValuesAreCorrect) {
@@ -173,6 +173,7 @@ TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemor
173173}
174174
175175TEST_F (CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) {
176+ AllocationsList allocList;
176177 auto cmdContainer = std::make_unique<CommandContainer>();
177178 cmdContainer->initialize (pDevice, &allocList);
178179 auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations ();
@@ -202,6 +203,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
202203 cmdContainer.reset ();
203204 EXPECT_EQ (memoryManager->handleFenceCompletionCalled , 3u );
204205 EXPECT_FALSE (allocList.peekIsEmpty ());
206+ allocList.freeAllGraphicsAllocations (pDevice);
205207}
206208
207209TEST_F (CommandContainerTest, givenCommandContainerDuringInitWhenAllocateHeapMemoryFailsThenErrorIsReturned) {
@@ -726,49 +728,4 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBuf
726728 EXPECT_EQ (cmdContainer.getCmdBufferAllocations ().size (), 1u );
727729 cmdContainer.closeAndAllocateNextCommandBuffer ();
728730 EXPECT_EQ (cmdContainer.getCmdBufferAllocations ().size (), 2u );
729- }
730-
731- TEST_F (CommandContainerTest, givenFlushTaskCmdContainerWithAllocationListWhenNewCmdBufferAllocatedThenOldCmdBufferIsStored) {
732- auto cmdContainer = std::make_unique<MockCommandContainer>();
733- cmdContainer->isFlushTaskUsedForImmediate = true ;
734- cmdContainer->initialize (pDevice, &allocList);
735-
736- auto &cmdBufferAllocs = cmdContainer->cmdBufferAllocations ;
737- auto memoryManager = static_cast <MockMemoryManager *>(pDevice->getMemoryManager ());
738- EXPECT_EQ (0u , memoryManager->handleFenceCompletionCalled );
739- EXPECT_EQ (1u , cmdBufferAllocs.size ());
740- EXPECT_TRUE (allocList.peekIsEmpty ());
741- GraphicsAllocation *oldAllocation = cmdContainer->getCommandStream ()->getGraphicsAllocation ();
742-
743- cmdContainer->allocateNextCommandBuffer ();
744- EXPECT_EQ (1u , cmdBufferAllocs.size ());
745-
746- auto cmdBuffer0 = cmdBufferAllocs[0 ];
747- EXPECT_EQ (cmdBuffer0, cmdContainer->getCommandStream ()->getGraphicsAllocation ());
748- EXPECT_NE (cmdBuffer0, oldAllocation);
749-
750- EXPECT_EQ (0u , memoryManager->freeGraphicsMemoryCalled );
751- EXPECT_EQ (1u , memoryManager->handleFenceCompletionCalled );
752- EXPECT_FALSE (allocList.peekIsEmpty ());
753- }
754-
755- TEST_F (CommandContainerTest, givenFlushTaskCmdContainerWithoutAllocationListWhenNewCmdBufferAllocatedThenOldCmdBufferIsFreed) {
756- auto cmdContainer = std::make_unique<MockCommandContainer>();
757- cmdContainer->isFlushTaskUsedForImmediate = true ;
758- cmdContainer->initialize (pDevice, nullptr );
759-
760- auto &cmdBufferAllocs = cmdContainer->cmdBufferAllocations ;
761- auto memoryManager = static_cast <MockMemoryManager *>(pDevice->getMemoryManager ());
762- EXPECT_EQ (0u , memoryManager->handleFenceCompletionCalled );
763- EXPECT_EQ (1u , cmdBufferAllocs.size ());
764- GraphicsAllocation *oldAllocation = cmdContainer->getCommandStream ()->getGraphicsAllocation ();
765-
766- cmdContainer->allocateNextCommandBuffer ();
767- EXPECT_EQ (1u , cmdBufferAllocs.size ());
768-
769- auto cmdBuffer0 = cmdBufferAllocs[0 ];
770- EXPECT_EQ (cmdBuffer0, cmdContainer->getCommandStream ()->getGraphicsAllocation ());
771- EXPECT_NE (cmdBuffer0, oldAllocation);
772-
773- EXPECT_EQ (1u , memoryManager->freeGraphicsMemoryCalled );
774- }
731+ }
0 commit comments