Skip to content

Commit 205e2e1

Browse files
Wait for fence before store cmd buffer in reusable pool
Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent 14e338e commit 205e2e1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

shared/source/command_container/cmdcontainer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType hea
213213
void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
214214
for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) {
215215
if (this->reusableAllocationList) {
216+
this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]);
216217
reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]);
217218
} else {
218219
this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);

shared/test/unit_test/command_container/command_container_tests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
176176
auto cmdContainer = std::make_unique<CommandContainer>();
177177
cmdContainer->initialize(pDevice, &allocList);
178178
auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations();
179+
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
180+
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u);
179181
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
180182
EXPECT_TRUE(allocList.peekIsEmpty());
181183

@@ -186,6 +188,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
186188
auto cmdBuffer1 = cmdBufferAllocs[1];
187189

188190
cmdContainer->reset();
191+
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 1u);
189192
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
190193
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
191194
EXPECT_FALSE(allocList.peekIsEmpty());
@@ -197,6 +200,8 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
197200
EXPECT_TRUE(allocList.peekIsEmpty());
198201

199202
cmdContainer.reset();
203+
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 3u);
204+
EXPECT_FALSE(allocList.peekIsEmpty());
200205
allocList.freeAllGraphicsAllocations(pDevice);
201206
}
202207

0 commit comments

Comments
 (0)