feature: add method to get command buffer gpu address of ending command

Related-To: NEO-15376

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2025-07-30 12:19:37 +00:00
committed by Compute-Runtime-Automation
parent 2a236d079c
commit 08c34968f8
3 changed files with 18 additions and 0 deletions

View File

@@ -228,6 +228,7 @@ void CommandContainer::reset() {
nextIddInBlock = this->getNumIddPerBlock();
lastPipelineSelectModeRequired = false;
endCmdPtr = nullptr;
endCmdGpuAddress = 0;
alignedPrimarySize = 0;
}
@@ -380,6 +381,7 @@ void CommandContainer::alignPrimaryEnding(void *endPtr, size_t exactUsedSize) {
void CommandContainer::endAlignedPrimaryBuffer() {
this->endCmdPtr = commandStream->getSpace(0u);
this->endCmdGpuAddress = commandStream->getCurrentGpuAddressPosition();
alignPrimaryEnding(this->endCmdPtr, commandStream->getUsed());
}

View File

@@ -200,6 +200,9 @@ class CommandContainer : public NonCopyableAndNonMovableClass {
void *getEndCmdPtr() const {
return endCmdPtr;
}
uint64_t getEndCmdGpuAddress() const {
return endCmdGpuAddress;
}
size_t getAlignedPrimarySize() const {
return this->alignedPrimarySize;
}
@@ -238,6 +241,7 @@ class CommandContainer : public NonCopyableAndNonMovableClass {
uint64_t instructionHeapBaseAddress = 0u;
uint64_t indirectObjectHeapBaseAddress = 0u;
uint64_t currentLinearStreamStartOffset = 0u;
uint64_t endCmdGpuAddress = 0u;
void *iddBlock = nullptr;
Device *device = nullptr;

View File

@@ -1781,9 +1781,11 @@ HWTEST_F(CommandContainerTest,
cmdContainer.endAlignedPrimaryBuffer();
void *endPtr = cmdContainer.getEndCmdPtr();
uint64_t endGpuVa = cmdContainer.getEndCmdGpuAddress();
size_t alignedSize = cmdContainer.getAlignedPrimarySize();
EXPECT_EQ(chainedCmdBufferAllocation->getUnderlyingBuffer(), endPtr);
EXPECT_EQ(chainedCmdBufferAllocation->getGpuAddress(), endGpuVa);
EXPECT_EQ(expectedEndSize, alignedSize);
}
@@ -1834,9 +1836,11 @@ HWTEST_F(CommandContainerTest,
cmdContainer.endAlignedPrimaryBuffer();
void *endPtr = cmdContainer.getEndCmdPtr();
uint64_t endGpuVa = cmdContainer.getEndCmdGpuAddress();
size_t alignedSize = cmdContainer.getAlignedPrimarySize();
EXPECT_EQ(ptrOffset(closingCmdBufferAllocation->getUnderlyingBuffer(), consumedSize), endPtr);
EXPECT_EQ(closingCmdBufferAllocation->getGpuAddress() + consumedSize, endGpuVa);
EXPECT_EQ(expectedEndSize, alignedSize);
}
@@ -1857,17 +1861,21 @@ HWTEST_F(CommandContainerTest,
size_t expectedEndSize = alignUp(sizeof(MI_BATCH_BUFFER_START) + consumedSize, CommandContainer::minCmdBufferPtrAlign);
void *expectedEndPtr = ptrOffset(firstCmdBufferAllocation->getUnderlyingBuffer(), consumedSize);
uint64_t expectedEndGpuVa = firstCmdBufferAllocation->getGpuAddress() + consumedSize;
cmdContainer.endAlignedPrimaryBuffer();
void *endPtr = cmdContainer.getEndCmdPtr();
uint64_t endGpuVa = cmdContainer.getEndCmdGpuAddress();
size_t alignedSize = cmdContainer.getAlignedPrimarySize();
EXPECT_EQ(expectedEndPtr, endPtr);
EXPECT_EQ(expectedEndGpuVa, endGpuVa);
EXPECT_EQ(expectedEndSize, alignedSize);
cmdContainer.reset();
EXPECT_EQ(nullptr, cmdContainer.getEndCmdPtr());
EXPECT_EQ(0u, cmdContainer.getEndCmdGpuAddress());
EXPECT_EQ(0u, cmdContainer.getAlignedPrimarySize());
}
@@ -1899,16 +1907,20 @@ HWTEST_F(CommandContainerTest,
cmdContainer.getCommandStream()->getSpace(consumedSize);
void *expectedEndPtr = ptrOffset(secondCmdBufferAllocation->getUnderlyingBuffer(), consumedSize);
uint64_t expectedEndGpuVa = secondCmdBufferAllocation->getGpuAddress() + consumedSize;
cmdContainer.endAlignedPrimaryBuffer();
void *endPtr = cmdContainer.getEndCmdPtr();
uint64_t endGpuVa = cmdContainer.getEndCmdGpuAddress();
size_t alignedSize = cmdContainer.getAlignedPrimarySize();
EXPECT_EQ(expectedEndPtr, endPtr);
EXPECT_EQ(expectedEndGpuVa, endGpuVa);
EXPECT_EQ(expectedEndSize, alignedSize);
cmdContainer.reset();
EXPECT_EQ(nullptr, cmdContainer.getEndCmdPtr());
EXPECT_EQ(0u, cmdContainer.getEndCmdGpuAddress());
EXPECT_EQ(0u, cmdContainer.getAlignedPrimarySize());
}