@@ -153,6 +153,19 @@ CommandStreamReceiver &CommandQueue::getCommandStreamReceiver(bool blitAllowed)
153153 return getGpgpuCommandStreamReceiver ();
154154}
155155
156+ CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation (const CsrSelectionArgs &args) const {
157+ const bool blitAllowed = blitEnqueueAllowed (args);
158+ const bool blitPreferred = blitEnqueuePreferred (args);
159+ const bool blitRequired = isCopyOnly;
160+ const bool blit = blitAllowed && (blitPreferred || blitRequired);
161+
162+ if (blit) {
163+ return *bcsEngine->commandStreamReceiver ;
164+ } else {
165+ return getGpgpuCommandStreamReceiver ();
166+ }
167+ }
168+
156169Device &CommandQueue::getDevice () const noexcept {
157170 return device->getDevice ();
158171}
@@ -725,46 +738,46 @@ bool CommandQueue::queueDependenciesClearRequired() const {
725738 return isOOQEnabled () || DebugManager.flags .OmitTimestampPacketDependencies .get ();
726739}
727740
728- bool CommandQueue::blitEnqueueAllowed (cl_command_type cmdType) const {
729- auto blitterSupported = bcsEngine != nullptr ;
741+ bool CommandQueue::blitEnqueueAllowed (const CsrSelectionArgs &args) const {
742+ if (bcsEngine == nullptr ) {
743+ return false ;
744+ }
730745
731746 bool blitEnqueueAllowed = getGpgpuCommandStreamReceiver ().peekTimestampPacketWriteEnabled () || this ->isCopyOnly ;
732747 if (DebugManager.flags .EnableBlitterForEnqueueOperations .get () != -1 ) {
733748 blitEnqueueAllowed = DebugManager.flags .EnableBlitterForEnqueueOperations .get ();
734749 }
750+ if (!blitEnqueueAllowed) {
751+ return false ;
752+ }
735753
736- switch (cmdType) {
754+ switch (args. cmdType ) {
737755 case CL_COMMAND_READ_BUFFER:
738756 case CL_COMMAND_WRITE_BUFFER:
739757 case CL_COMMAND_COPY_BUFFER:
740758 case CL_COMMAND_READ_BUFFER_RECT:
741759 case CL_COMMAND_WRITE_BUFFER_RECT:
742760 case CL_COMMAND_COPY_BUFFER_RECT:
743761 case CL_COMMAND_SVM_MEMCPY:
762+ case CL_COMMAND_SVM_MAP:
763+ case CL_COMMAND_SVM_UNMAP:
764+ return true ;
744765 case CL_COMMAND_READ_IMAGE:
766+ return blitEnqueueImageAllowed (args.srcResource .imageOrigin , args.size , *args.srcResource .image );
745767 case CL_COMMAND_WRITE_IMAGE:
768+ return blitEnqueueImageAllowed (args.dstResource .imageOrigin , args.size , *args.dstResource .image );
769+
746770 case CL_COMMAND_COPY_IMAGE:
747- return blitterSupported && blitEnqueueAllowed;
771+ return blitEnqueueImageAllowed (args.srcResource .imageOrigin , args.size , *args.srcResource .image ) &&
772+ blitEnqueueImageAllowed (args.dstResource .imageOrigin , args.size , *args.dstResource .image );
773+
748774 default :
749775 return false ;
750776 }
751777}
752778
753- bool CommandQueue::blitEnqueuePreferred (cl_command_type cmdType, const BuiltinOpParams &builtinOpParams) const {
754- bool isLocalToLocal = false ;
755-
756- if (cmdType == CL_COMMAND_COPY_BUFFER &&
757- builtinOpParams.srcMemObj ->getGraphicsAllocation (device->getRootDeviceIndex ())->isAllocatedInLocalMemoryPool () &&
758- builtinOpParams.dstMemObj ->getGraphicsAllocation (device->getRootDeviceIndex ())->isAllocatedInLocalMemoryPool ()) {
759- isLocalToLocal = true ;
760- }
761- if (cmdType == CL_COMMAND_SVM_MEMCPY &&
762- builtinOpParams.srcSvmAlloc ->isAllocatedInLocalMemoryPool () &&
763- builtinOpParams.dstSvmAlloc ->isAllocatedInLocalMemoryPool ()) {
764- isLocalToLocal = true ;
765- }
766-
767- if (isLocalToLocal) {
779+ bool CommandQueue::blitEnqueuePreferred (const CsrSelectionArgs &args) const {
780+ if (args.direction == TransferDirection::LocalToLocal) {
768781 if (DebugManager.flags .PreferCopyEngineForCopyBufferToBuffer .get () != -1 ) {
769782 return static_cast <bool >(DebugManager.flags .PreferCopyEngineForCopyBufferToBuffer .get ());
770783 }
@@ -775,7 +788,7 @@ bool CommandQueue::blitEnqueuePreferred(cl_command_type cmdType, const BuiltinOp
775788 return true ;
776789}
777790
778- bool CommandQueue::blitEnqueueImageAllowed (const size_t *origin, const size_t *region, const Image &image) {
791+ bool CommandQueue::blitEnqueueImageAllowed (const size_t *origin, const size_t *region, const Image &image) const {
779792 const auto &hwInfo = device->getHardwareInfo ();
780793 const auto &hwHelper = HwHelper::get (hwInfo.platform .eRenderCoreFamily );
781794 auto blitEnqueueImageAllowed = hwHelper.isBlitterForImagesSupported (hwInfo);
0 commit comments