@@ -384,8 +384,8 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC
384384 csr.taskCount = newTaskCount - 1 ;
385385 EXPECT_EQ (0u , csr.recursiveLockCounter .load ());
386386 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
387- csr, buffer->getGraphicsAllocation (), 0 , hostPtr, 0 , true ,
388- 0 , bltSize);
387+ csr, buffer->getGraphicsAllocation (), 0 , nullptr , hostPtr ,
388+ 0 , true , 0 , bltSize);
389389
390390 csr.blitBuffer (blitProperties);
391391 EXPECT_EQ (newTaskCount, csr.taskCount );
@@ -444,8 +444,8 @@ HWTEST_F(BcsTests, givenCsrDependenciesWhenProgrammingCommandStreamThenAddSemaph
444444 size_t numberNodesPerContainer = 5 ;
445445
446446 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
447- csr, buffer->getGraphicsAllocation (), 0 , hostPtr, 0 , true ,
448- 0 , 1 );
447+ csr, buffer->getGraphicsAllocation (), 0 , nullptr , hostPtr ,
448+ 0 , true , 0 , 1 );
449449
450450 MockTimestampPacketContainer timestamp0 (*csr.getTimestampPacketAllocator (), numberNodesPerContainer);
451451 MockTimestampPacketContainer timestamp1 (*csr.getTimestampPacketAllocator (), numberNodesPerContainer);
@@ -493,8 +493,8 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
493493 EXPECT_EQ (0u , csr.makeSurfacePackNonResidentCalled );
494494
495495 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
496- csr, buffer->getGraphicsAllocation (), 0 , hostPtr, 0 , true ,
497- 0 , 1 );
496+ csr, buffer->getGraphicsAllocation (), 0 , nullptr , hostPtr, 0 ,
497+ true , 0 , 1 );
498498
499499 csr.blitBuffer (blitProperties);
500500
@@ -522,8 +522,8 @@ HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
522522 csr.taskCount = newTaskCount - 1 ;
523523
524524 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
525- csr, buffer->getGraphicsAllocation (), 0 , hostPtr, 0 , true ,
526- 0 , 1 );
525+ csr, buffer->getGraphicsAllocation (), 0 , nullptr , hostPtr ,
526+ 0 , true , 0 , 1 );
527527
528528 csr.blitBuffer (blitProperties);
529529
@@ -571,8 +571,8 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
571571 void *hostPtr = reinterpret_cast <void *>(0x12340000 );
572572
573573 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
574- *myMockCsr, buffer->getGraphicsAllocation (), 0 , hostPtr, 0 ,
575- false , 0 , 1 );
574+ *myMockCsr, buffer->getGraphicsAllocation (), 0 , nullptr ,
575+ hostPtr, 0 , false , 0 , 1 );
576576
577577 myMockCsr->blitBuffer (blitProperties);
578578
@@ -602,8 +602,8 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) {
602602 EXPECT_EQ (0u , mockInternalAllocationsStorage->cleanAllocationsCalled );
603603
604604 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
605- bcsCsr, buffer->getGraphicsAllocation (), 0 , hostPtr, 0 ,
606- false , 0 , 1 );
605+ bcsCsr, buffer->getGraphicsAllocation (), 0 , nullptr , hostPtr ,
606+ 0 , false , 0 , 1 );
607607
608608 bcsCsr.blitBuffer (blitProperties);
609609
@@ -636,7 +636,7 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
636636 HardwareParse hwParser;
637637 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
638638 csr, subBuffer1->getGraphicsAllocation (), subBuffer1Offset,
639- hostPtr, hostPtrOffset, true , 0 , 1 );
639+ nullptr , hostPtr, hostPtrOffset, true , 0 , 1 );
640640
641641 csr.blitBuffer (blitProperties);
642642
@@ -655,7 +655,7 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
655655 auto offset = csr.commandStream .getUsed ();
656656 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::BufferToHostPtr,
657657 csr, subBuffer1->getGraphicsAllocation (), subBuffer1Offset,
658- hostPtr, hostPtrOffset, true , 0 , 1 );
658+ nullptr , hostPtr, hostPtrOffset, true , 0 , 1 );
659659
660660 csr.blitBuffer (blitProperties);
661661
@@ -687,6 +687,104 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
687687 }
688688}
689689
690+ HWTEST_F (BcsTests, givenMapAllocationWhenDispatchReadWriteOperationThenSetValidGpuAddress) {
691+ auto &csr = pDevice->getUltCommandStreamReceiver <FamilyType>();
692+ auto memoryManager = csr.getMemoryManager ();
693+
694+ AllocationProperties properties{false , 1234 , GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false };
695+ GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties (properties, reinterpret_cast <void *>(0x12340000 ));
696+
697+ auto mapAllocationOffset = 0x1234 ;
698+ auto mapPtr = reinterpret_cast <void *>(mapAllocation->getGpuAddress () + mapAllocationOffset);
699+
700+ cl_int retVal = CL_SUCCESS;
701+ auto buffer = clUniquePtr<Buffer>(Buffer::create (context.get (), CL_MEM_READ_WRITE, 100 , nullptr , retVal));
702+
703+ const size_t hostPtrOffset = 0x1234 ;
704+
705+ {
706+ // from hostPtr
707+ HardwareParse hwParser;
708+ auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
709+ csr, buffer->getGraphicsAllocation (), 0 ,
710+ mapAllocation, mapPtr, hostPtrOffset, true , 0 , 1 );
711+
712+ csr.blitBuffer (blitProperties);
713+
714+ hwParser.parseCommands <FamilyType>(csr.commandStream );
715+
716+ auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList .begin ());
717+ EXPECT_NE (nullptr , bltCmd);
718+ if (pDevice->isFullRangeSvm ()) {
719+ EXPECT_EQ (reinterpret_cast <uint64_t >(ptrOffset (mapPtr, hostPtrOffset)), bltCmd->getSourceBaseAddress ());
720+ }
721+ EXPECT_EQ (buffer->getGraphicsAllocation ()->getGpuAddress (), bltCmd->getDestinationBaseAddress ());
722+ }
723+
724+ {
725+ // to hostPtr
726+ HardwareParse hwParser;
727+ auto offset = csr.commandStream .getUsed ();
728+ auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::BufferToHostPtr,
729+ csr, buffer->getGraphicsAllocation (), 0 ,
730+ mapAllocation, mapPtr, hostPtrOffset, true , 0 , 1 );
731+
732+ csr.blitBuffer (blitProperties);
733+
734+ hwParser.parseCommands <FamilyType>(csr.commandStream , offset);
735+
736+ auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList .begin ());
737+ EXPECT_NE (nullptr , bltCmd);
738+ if (pDevice->isFullRangeSvm ()) {
739+ EXPECT_EQ (reinterpret_cast <uint64_t >(ptrOffset (mapPtr, hostPtrOffset)), bltCmd->getDestinationBaseAddress ());
740+ }
741+ EXPECT_EQ (buffer->getGraphicsAllocation ()->getGpuAddress (), bltCmd->getSourceBaseAddress ());
742+ }
743+
744+ memoryManager->freeGraphicsMemory (mapAllocation);
745+ }
746+
747+ HWTEST_F (BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItAsSourceOrDstAllocation) {
748+ auto &csr = pDevice->getUltCommandStreamReceiver <FamilyType>();
749+ auto memoryManager = csr.getMemoryManager ();
750+
751+ AllocationProperties properties{false , 1234 , GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false };
752+ GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties (properties, reinterpret_cast <void *>(0x12340000 ));
753+
754+ auto mapAllocationOffset = 0x1234 ;
755+ auto mapPtr = reinterpret_cast <void *>(mapAllocation->getGpuAddress () + mapAllocationOffset);
756+
757+ cl_int retVal = CL_SUCCESS;
758+ auto buffer = clUniquePtr<Buffer>(Buffer::create (context.get (), CL_MEM_READ_WRITE, 100 , nullptr , retVal));
759+
760+ {
761+ // from hostPtr
762+ BuiltinOpParams builtinOpParams = {};
763+ builtinOpParams.dstMemObj = buffer.get ();
764+ builtinOpParams.srcPtr = mapPtr;
765+ builtinOpParams.size .x = 1 ;
766+ builtinOpParams.mapAllocation = mapAllocation;
767+
768+ auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
769+ csr, builtinOpParams, true );
770+ EXPECT_EQ (mapAllocation, blitProperties.srcAllocation );
771+ }
772+ {
773+ // to hostPtr
774+ BuiltinOpParams builtinOpParams = {};
775+ builtinOpParams.srcMemObj = buffer.get ();
776+ builtinOpParams.dstPtr = mapPtr;
777+ builtinOpParams.size .x = 1 ;
778+ builtinOpParams.mapAllocation = mapAllocation;
779+
780+ auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::BufferToHostPtr,
781+ csr, builtinOpParams, true );
782+ EXPECT_EQ (mapAllocation, blitProperties.dstAllocation );
783+ }
784+
785+ memoryManager->freeGraphicsMemory (mapAllocation);
786+ }
787+
690788HWTEST_F (BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrectGpuAddresses) {
691789 auto &csr = pDevice->getUltCommandStreamReceiver <FamilyType>();
692790
@@ -703,8 +801,8 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
703801 HardwareParse hwParser;
704802 auto offset = csr.commandStream .getUsed ();
705803 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::HostPtrToBuffer,
706- csr, buffer1->getGraphicsAllocation (), 0 , hostPtr ,
707- 0 , true , buffer1Offset, 1 );
804+ csr, buffer1->getGraphicsAllocation (), 0 , nullptr ,
805+ hostPtr, 0 , true , buffer1Offset, 1 );
708806
709807 csr.blitBuffer (blitProperties);
710808
@@ -722,8 +820,8 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
722820 HardwareParse hwParser;
723821 auto offset = csr.commandStream .getUsed ();
724822 auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection::BufferToHostPtr,
725- csr, buffer1->getGraphicsAllocation (), 0 , hostPtr ,
726- 0 , true , buffer1Offset, 1 );
823+ csr, buffer1->getGraphicsAllocation (), 0 , nullptr ,
824+ hostPtr, 0 , true , buffer1Offset, 1 );
727825
728826 csr.blitBuffer (blitProperties);
729827
0 commit comments