From 6299388b71e4dc6cc552ae83c4050fda5206bcd5 Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Tue, 17 Apr 2018 07:34:53 +0200 Subject: [PATCH] [30/n] Internal 4GB allocator. - Add support for patching indirect state with internal heaps. Change-Id: Ib5748beb462be1786134a0a81bb649dd279816ec --- runtime/helpers/kernel_commands.inl | 2 +- unit_tests/helpers/kernel_commands_tests.cpp | 25 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) 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);