@@ -743,31 +743,33 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
743743 return status;
744744 }
745745
746- auto lock = device->getBuiltinFunctionsLib ()->obtainUniqueOwnership ();
747-
748- Kernel *builtinKernel = nullptr ;
746+ bool isHeaplessEnabled = this ->heaplessModeEnabled ;
747+ ImageBuiltin builtInType = ImageBuiltin::copyBufferToImage3dBytes;
749748
750749 switch (bytesPerPixel) {
751- default :
752- UNRECOVERABLE_IF (true );
753- break ;
754750 case 1u :
755- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyBufferToImage3dBytes);
751+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyBufferToImage3dBytes>(isHeaplessEnabled );
756752 break ;
757753 case 2u :
758- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyBufferToImage3d2Bytes);
754+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyBufferToImage3d2Bytes>(isHeaplessEnabled );
759755 break ;
760756 case 4u :
761- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyBufferToImage3d4Bytes);
757+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyBufferToImage3d4Bytes>(isHeaplessEnabled );
762758 break ;
763759 case 8u :
764- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyBufferToImage3d8Bytes);
760+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyBufferToImage3d8Bytes>(isHeaplessEnabled );
765761 break ;
766762 case 16u :
767- builtinKernel = device->getBuiltinFunctionsLib ()->getImageFunction (ImageBuiltin::copyBufferToImage3d16Bytes);
763+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyBufferToImage3d16Bytes>(isHeaplessEnabled);
764+ break ;
765+ default :
766+ UNRECOVERABLE_IF (true );
768767 break ;
769768 }
770769
770+ auto lock = device->getBuiltinFunctionsLib ()->obtainUniqueOwnership ();
771+ Kernel *builtinKernel = device->getBuiltinFunctionsLib ()->getImageFunction (builtInType);
772+
771773 builtinKernel->setArgBufferWithAlloc (0u , allocationStruct.alignedAllocationPtr ,
772774 allocationStruct.alloc ,
773775 nullptr );
@@ -913,34 +915,36 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
913915 return status;
914916 }
915917
916- auto lock = device->getBuiltinFunctionsLib ()->obtainUniqueOwnership ();
917-
918- Kernel *builtinKernel = nullptr ;
918+ bool isHeaplessEnabled = this ->heaplessModeEnabled ;
919+ ImageBuiltin builtInType = ImageBuiltin::copyBufferToImage3dBytes;
919920
920921 switch (bytesPerPixel) {
921- default : {
922- CREATE_DEBUG_STRING (str, " Invalid bytesPerPixel of size: %u\n " , bytesPerPixel);
923- driverHandle->setErrorDescription (std::string (str.get ()));
924- PRINT_DEBUG_STRING (NEO::debugManager.flags .PrintDebugMessages .get (), stderr, " invalid bytesPerPixel of size: %u\n " , bytesPerPixel);
925- UNRECOVERABLE_IF (true );
926- break ;
927- }
928922 case 1u :
929- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyImage3dToBufferBytes);
923+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyImage3dToBufferBytes>(isHeaplessEnabled );
930924 break ;
931925 case 2u :
932- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyImage3dToBuffer2Bytes);
926+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyImage3dToBuffer2Bytes>(isHeaplessEnabled );
933927 break ;
934928 case 4u :
935- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyImage3dToBuffer4Bytes);
929+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyImage3dToBuffer4Bytes>(isHeaplessEnabled );
936930 break ;
937931 case 8u :
938- builtinKernel = device-> getBuiltinFunctionsLib ()-> getImageFunction ( ImageBuiltin::copyImage3dToBuffer8Bytes);
932+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType< ImageBuiltin::copyImage3dToBuffer8Bytes>(isHeaplessEnabled );
939933 break ;
940934 case 16u :
941- builtinKernel = device->getBuiltinFunctionsLib ()->getImageFunction (ImageBuiltin::copyImage3dToBuffer16Bytes);
935+ builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImage3dToBuffer16Bytes>(isHeaplessEnabled);
936+ break ;
937+ default : {
938+ CREATE_DEBUG_STRING (str, " Invalid bytesPerPixel of size: %u\n " , bytesPerPixel);
939+ driverHandle->setErrorDescription (std::string (str.get ()));
940+ PRINT_DEBUG_STRING (NEO::debugManager.flags .PrintDebugMessages .get (), stderr, " invalid bytesPerPixel of size: %u\n " , bytesPerPixel);
941+ UNRECOVERABLE_IF (true );
942942 break ;
943943 }
944+ }
945+
946+ auto lock = device->getBuiltinFunctionsLib ()->obtainUniqueOwnership ();
947+ Kernel *builtinKernel = device->getBuiltinFunctionsLib ()->getImageFunction (builtInType);
944948
945949 builtinKernel->setArgRedescribedImage (0u , image->toHandle ());
946950 builtinKernel->setArgBufferWithAlloc (1u , allocationStruct.alignedAllocationPtr ,
@@ -1109,9 +1113,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion(ze_image
11091113 return status;
11101114 }
11111115
1112- auto lock = device-> getBuiltinFunctionsLib ()-> obtainUniqueOwnership ( );
1116+ ImageBuiltin builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImageRegion>( this -> heaplessModeEnabled );
11131117
1114- auto kernel = device->getBuiltinFunctionsLib ()->getImageFunction (ImageBuiltin::copyImageRegion);
1118+ auto lock = device->getBuiltinFunctionsLib ()->obtainUniqueOwnership ();
1119+ auto kernel = device->getBuiltinFunctionsLib ()->getImageFunction (builtInType);
11151120
11161121 ze_result_t ret = kernel->suggestGroupSize (groupSizeX, groupSizeY, groupSizeZ, &groupSizeX,
11171122 &groupSizeY, &groupSizeZ);
0 commit comments