diff --git a/runtime/helpers/kernel_commands.inl b/runtime/helpers/kernel_commands.inl index 29a40d109e..5794d57e09 100644 --- a/runtime/helpers/kernel_commands.inl +++ b/runtime/helpers/kernel_commands.inl @@ -240,7 +240,7 @@ size_t KernelCommandsHelper::sendCrossThreadData( } } - return offsetCrossThreadData; + return offsetCrossThreadData + static_cast(indirectHeap.getHeapGpuStartOffset()); } // Returned binding table pointer is relative to given heap (which is assumed to be the Surface state base addess) diff --git a/unit_tests/helpers/kernel_commands_tests.cpp b/unit_tests/helpers/kernel_commands_tests.cpp index 8e334d12ad..67d1cad6d0 100644 --- a/unit_tests/helpers/kernel_commands_tests.cpp +++ b/unit_tests/helpers/kernel_commands_tests.cpp @@ -204,6 +204,31 @@ HWTEST_F(KernelCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoComment EXPECT_EQ(PatchInfoAllocationType::IndirectObjectHeap, kernel->getPatchInfoDataList()[0].targetType); } +HWTEST_F(KernelCommandsTest, givenIndirectHeapNotAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenOffsetZeroIsReturned) { + CommandQueueHw cmdQ(pContext, pDevice, 0); + auto &indirectHeap = cmdQ.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 8192); + + MockKernelWithInternals mockKernelWithInternal(*pDevice); + auto offset = KernelCommandsHelper::sendCrossThreadData( + indirectHeap, + *mockKernelWithInternal.mockKernel); + EXPECT_EQ(0u, offset); +} + +HWTEST_F(KernelCommandsTest, givenIndirectHeapAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenHeapBaseOffsetIsReturned) { + auto internalAllocation = pDevice->getMemoryManager()->createInternalGraphicsAllocation(nullptr, 4096); + IndirectHeap indirectHeap(internalAllocation, true); + auto expectedOffset = internalAllocation->getGpuAddressToPatch(); + + MockKernelWithInternals mockKernelWithInternal(*pDevice); + auto offset = KernelCommandsHelper::sendCrossThreadData( + indirectHeap, + *mockKernelWithInternal.mockKernel); + EXPECT_EQ(expectedOffset, offset); + + pDevice->getMemoryManager()->freeGraphicsMemory(internalAllocation); +} + HWTEST_F(KernelCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoDataOffsetsAreMoved) { DebugManagerStateRestore dbgRestore; DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);