xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/vp/hal/pipeline/vp_pipeline.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2018-2024, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     vp_pipeline.cpp
24 //! \brief    Defines the common interface for vp pipeline
25 //!           this file is for the base interface which is shared by all features.
26 //!
27 
28 #include "vp_pipeline.h"
29 #include "vp_scaling_filter.h"
30 #include "vp_csc_filter.h"
31 #include "vp_rot_mir_filter.h"
32 #include "media_scalability_defs.h"
33 #include "vp_feature_manager.h"
34 #include "vp_packet_pipe.h"
35 #include "vp_platform_interface.h"
36 #include "vp_utils.h"
37 #include "vp_user_feature_control.h"
38 using namespace vp;
39 
VpPipeline(PMOS_INTERFACE osInterface)40 VpPipeline::VpPipeline(PMOS_INTERFACE osInterface) :
41     MediaPipeline(osInterface)
42 {
43 }
44 
~VpPipeline()45 VpPipeline::~VpPipeline()
46 {
47     // Delete m_featureManager before m_resourceManager, since
48     // m_resourceManager is referenced by m_featureManager.
49     MOS_Delete(m_featureManager);
50     for (auto ctx : m_vpPipeContexts)
51     {
52         MOS_Delete(ctx);
53     }
54     m_vpPipeContexts.clear();
55     // Delete m_pPacketPipeFactory before m_pPacketFactory, since
56     // m_pPacketFactory is referenced by m_pPacketPipeFactory.
57     MOS_Delete(m_pPacketPipeFactory);
58     MOS_Delete(m_pPacketFactory);
59     DeletePackets();
60     DeleteTasks();
61 
62     MOS_Delete(m_vpInterface);
63     MOS_Delete(m_kernelSet);
64     MOS_Delete(m_paramChecker);
65     MOS_Delete(m_mmc);
66 #if (_DEBUG || _RELEASE_INTERNAL)
67     DestroySurface();
68 #endif
69     MOS_Delete(m_allocator);
70     MOS_Delete(m_statusReport);
71     MOS_Delete(m_packetSharedContext);
72     if (m_vpMhwInterface.m_reporting && this != m_vpMhwInterface.m_reporting->owner)
73     {
74         m_reporting = nullptr;
75     }
76     else
77     {
78         MOS_Delete(m_reporting);
79         m_vpMhwInterface.m_reporting = nullptr;
80     }
81 #if ((_DEBUG || _RELEASE_INTERNAL) && !EMUL)
82     VP_DEBUG_INTERFACE_DESTROY(m_debugInterface);
83 #endif
84     if (m_mediaContext)
85     {
86         MOS_Delete(m_mediaContext);
87         m_mediaContext = nullptr;
88     }
89 
90     if (m_vpSettings)
91     {
92         MOS_FreeMemory(m_vpSettings);
93         m_vpSettings = nullptr;
94     }
95 
96     if (m_userFeatureControl &&
97         (this == m_userFeatureControl->m_owner || nullptr == m_userFeatureControl->m_owner))
98     {
99         MOS_Delete(m_userFeatureControl);
100         m_vpMhwInterface.m_userFeatureControl = nullptr;
101     }
102     if (m_pipelineParamFactory)
103     {
104         MOS_Delete(m_pipelineParamFactory);
105     }
106 }
107 
GetStatusReport(void * status,uint16_t numStatus)108 MOS_STATUS VpPipeline::GetStatusReport(void *status, uint16_t numStatus)
109 {
110     VP_FUNC_CALL();
111 
112     return MOS_STATUS_SUCCESS;
113 }
114 
Destroy()115 MOS_STATUS VpPipeline::Destroy()
116 {
117     VP_FUNC_CALL();
118 
119     return MOS_STATUS_SUCCESS;
120 }
121 
122 #if (_DEBUG || _RELEASE_INTERNAL)
DestroySurface()123 MOS_STATUS VpPipeline::DestroySurface()
124 {
125     VP_FUNC_CALL();
126 
127     if (m_tempTargetSurface)
128     {
129         m_allocator->FreeResource(&m_tempTargetSurface->OsResource);
130         MOS_FreeMemAndSetNull(m_tempTargetSurface);
131     }
132 
133     return MOS_STATUS_SUCCESS;
134 }
135 #endif
136 
137 #if (_DEBUG || _RELEASE_INTERNAL)
ReportIFNCC(bool bStart)138 MOS_STATUS VpPipeline::ReportIFNCC(bool bStart)
139 {
140     //INTER_FRAME_MEMORY_NINJA_START_COUNTER will be reported in Prepare function
141     //INTER_FRAME_MEMORY_NINJA_END_COUNTER will be reported in UserFeatureReport() function which runs in Execute()
142     VP_FUNC_CALL();
143     int32_t memninjaCounter = 0;
144     memninjaCounter         = *MosUtilities::m_mosMemAllocCounter + *MosUtilities::m_mosMemAllocCounterGfx - *MosUtilities::m_mosMemAllocFakeCounter;
145     if (MOS_IS_MEMORY_FOOT_PRINT_ENABLED())
146     {
147         if (bStart)
148         {
149             MT_LOG2(MT_MOS_MEMORY_NINJA_COUNTER, MT_NORMAL, MT_MEMORY_NINJA_IS_START, bStart, MT_MEMORY_NINJA_START_COUNTER, memninjaCounter);
150             VP_PUBLIC_NORMALMESSAGE("MT_MOS_MEMORY_NINJA_COUNTER, MT_MEMORY_NINJA_IS_START :%d, MT_MEMORY_NINJA_START_COUNTER: %d", bStart, memninjaCounter);
151         }
152         else
153         {
154             MT_LOG2(MT_MOS_MEMORY_NINJA_COUNTER, MT_NORMAL, MT_MEMORY_NINJA_IS_START, bStart, MT_MEMORY_NINJA_END_COUNTER, memninjaCounter);
155             VP_PUBLIC_NORMALMESSAGE("MT_MOS_MEMORY_NINJA_COUNTER, MT_MEMORY_NINJA_IS_START :%d, MT_MEMORY_NINJA_END_COUNTER: %d", bStart, memninjaCounter);
156         }
157     }
158     if (m_userFeatureControl->EnableIFNCC() &&
159         MosUtilities::m_mosMemAllocCounter &&
160         MosUtilities::m_mosMemAllocCounterGfx &&
161         MosUtilities::m_mosMemAllocFakeCounter)
162     {
163         ReportUserSettingForDebug(
164             m_userSettingPtr,
165             bStart ? __MEDIA_USER_FEATURE_VALUE_INTER_FRAME_MEMORY_NINJA_START_COUNTER : __MEDIA_USER_FEATURE_VALUE_INTER_FRAME_MEMORY_NINJA_END_COUNTER,
166             memninjaCounter,
167             MediaUserSetting::Group::Sequence);
168     }
169     return MOS_STATUS_SUCCESS;
170 }
171 #endif
172 
UserFeatureReport()173 MOS_STATUS VpPipeline::UserFeatureReport()
174 {
175     VP_FUNC_CALL();
176 
177     if (m_reporting)
178     {
179         if (m_vpPipeContexts.size() > 0)
180         {
181             VP_PUBLIC_CHK_NULL_RETURN(m_vpPipeContexts[0]);
182             m_reporting->GetFeatures().outputPipeMode = m_vpPipeContexts[0]->GetOutputPipe();
183             m_reporting->GetFeatures().veFeatureInUse = m_vpPipeContexts[0]->IsVeboxInUse();
184             m_reporting->GetFeatures().packetReused   = m_vpPipeContexts[0]->IsPacketReUsed();
185         }
186 
187         if (m_mmc)
188         {
189             m_reporting->GetFeatures().vpMMCInUse = m_mmc->IsMmcEnabled();
190         }
191 
192         if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
193         {
194             PVP_PIPELINE_PARAMS params = m_pvpParams.renderParams;
195             VP_PUBLIC_CHK_NULL_RETURN(params);
196             if (params->pSrc[0] && params->pSrc[0]->bCompressible)
197             {
198                 m_reporting->GetFeatures().primaryCompressible = true;
199                 m_reporting->GetFeatures().primaryCompressMode = (uint8_t)(params->pSrc[0]->CompressionMode);
200             }
201 
202             if (params->pTarget[0]->bCompressible)
203             {
204                 m_reporting->GetFeatures().rtCompressible = true;
205                 m_reporting->GetFeatures().rtCompressMode = (uint8_t)(params->pTarget[0]->CompressionMode);
206             }
207 
208             m_reporting->GetFeatures().rtCacheSetting = (uint8_t)(params->pTarget[0]->CacheSetting);
209 #if (_DEBUG || _RELEASE_INTERNAL)
210             if (m_reporting->GetFeatures().outputPipeMode == VPHAL_OUTPUT_PIPE_MODE_SFC)
211             {
212                 if (m_vpMhwInterface.m_sfcInterface)
213                 {
214                     m_reporting->GetFeatures().rtOldCacheSetting = (uint8_t)((m_vpMhwInterface.m_sfcInterface->m_outputSurfCtrl.Value >> 1) & 0x0000003f);
215                 }
216             }
217             else if (m_vpMhwInterface.m_renderHal)
218             {
219                 m_reporting->GetFeatures().rtOldCacheSetting = (uint8_t)(m_vpMhwInterface.m_renderHal->oldCacheSettingForTargetSurface);
220             }
221             if (m_reporting->GetFeatures().isL03DLut)
222             {
223                 VP_PUBLIC_NORMALMESSAGE("VP L0 3DLut Enabled");
224                 ReportUserSettingForDebug(
225                     m_userSettingPtr,
226                     __MEDIA_USER_FEATURE_VALUE_VP_L0_3DLUT_ENABLED,
227                     1,
228                     MediaUserSetting::Group::Sequence);
229             }
230 #endif
231         }
232 #if (_DEBUG || _RELEASE_INTERNAL)
233         if (m_reporting->GetFeatures().isL0FC)
234         {
235             VP_PUBLIC_NORMALMESSAGE("VP L0 FC Enabled");
236             ReportUserSettingForDebug(
237                 m_userSettingPtr,
238                 __MEDIA_USER_FEATURE_VALUE_VP_L0_FC_ENABLED,
239                 1,
240                 MediaUserSetting::Group::Sequence);
241 
242             ReportUserSettingForDebug(
243                 m_userSettingPtr,
244                 __MEDIA_USER_FEATURE_VALUE_VP_L0_FC_REPORT,
245                 m_reporting->GetFeatures().diffLogL0FC,
246                 MediaUserSetting::Group::Sequence);
247         }
248 #endif
249 
250         m_reporting->GetFeatures().VPApogeios = m_currentFrameAPGEnabled;
251     }
252     MediaPipeline::UserFeatureReport();
253 
254 
255 #if (_DEBUG || _RELEASE_INTERNAL)
256     //INTER_FRAME_MEMORY_NINJA_START_COUNTER will be reported in ReportIFNCC(true) function which runs in VpPipeline::Prepare()
257     ReportIFNCC(false);
258 #endif
259     return MOS_STATUS_SUCCESS;
260 }
261 
CreatePacketSharedContext()262 MOS_STATUS VpPipeline::CreatePacketSharedContext()
263 {
264     VP_FUNC_CALL();
265 
266     m_packetSharedContext = MOS_New(VP_PACKET_SHARED_CONTEXT);
267     VP_PUBLIC_CHK_NULL_RETURN(m_packetSharedContext);
268     return MOS_STATUS_SUCCESS;
269 }
270 
CreateUserFeatureControl()271 MOS_STATUS VpPipeline::CreateUserFeatureControl()
272 {
273     VP_FUNC_CALL();
274 
275     VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
276     m_userFeatureControl = MOS_New(VpUserFeatureControl, *m_osInterface, m_vpMhwInterface.m_vpPlatformInterface, this);
277     VP_PUBLIC_CHK_NULL_RETURN(m_userFeatureControl);
278     return MOS_STATUS_SUCCESS;
279 }
280 
CreateVPDebugInterface()281 MOS_STATUS VpPipeline::CreateVPDebugInterface()
282 {
283     VP_FUNC_CALL();
284 
285 #if ((_DEBUG || _RELEASE_INTERNAL) && !EMUL)
286     VP_DEBUG_INTERFACE_CREATE(m_debugInterface);
287     SkuWaTable_DUMP_XML(m_skuTable, m_waTable);
288 #endif
289     return MOS_STATUS_SUCCESS;
290 }
291 
Init(void * mhwInterface)292 MOS_STATUS VpPipeline::Init(void *mhwInterface)
293 {
294     VP_FUNC_CALL();
295     VP_PUBLIC_CHK_NULL_RETURN(mhwInterface);
296     VP_PUBLIC_CHK_NULL_RETURN(((PVP_MHWINTERFACE)mhwInterface)->m_vpPlatformInterface);
297 
298     m_vpMhwInterface = *(PVP_MHWINTERFACE)mhwInterface;
299 
300     if (m_vpMhwInterface.m_userFeatureControl)
301     {
302         m_userFeatureControl = m_vpMhwInterface.m_userFeatureControl;
303     }
304     else
305     {
306         VP_PUBLIC_CHK_STATUS_RETURN(CreateUserFeatureControl());
307         m_vpMhwInterface.m_userFeatureControl = m_userFeatureControl;
308     }
309     if (m_userFeatureControl && m_vpMhwInterface.m_settings)
310     {
311         m_userFeatureControl->SetClearVideoViewMode(((VP_SETTINGS *)m_vpMhwInterface.m_settings)->clearVideoViewMode);
312     }
313 
314     VP_PUBLIC_CHK_STATUS_RETURN(m_vpMhwInterface.m_vpPlatformInterface->ConfigVirtualEngine());
315 
316     VP_PUBLIC_CHK_STATUS_RETURN(m_vpMhwInterface.m_vpPlatformInterface->ConfigureVpScalability(m_vpMhwInterface));
317 
318     VP_PUBLIC_CHK_STATUS_RETURN(MediaPipeline::InitPlatform());
319 
320     VP_PUBLIC_CHK_STATUS_RETURN(MediaPipeline::CreateMediaCopyWrapper());
321 
322     VP_PUBLIC_CHK_NULL_RETURN(m_mediaCopyWrapper);
323 
324     if (m_mediaCopyWrapper->MediaCopyStateIsNull())
325     {
326         // Only for legacy media copy creation
327         m_mediaCopyWrapper->SetMediaCopyState(m_vpMhwInterface.m_vpPlatformInterface->CreateMediaCopy());
328     }
329 
330     VP_PUBLIC_CHK_STATUS_RETURN(CreateFeatureReport());
331 
332     m_mediaContext = MOS_New(MediaContext, scalabilityVp, &m_vpMhwInterface, m_osInterface);
333     VP_PUBLIC_CHK_NULL_RETURN(m_mediaContext);
334 
335     m_mmc = MOS_New(VPMediaMemComp, m_osInterface, m_vpMhwInterface);
336     VP_PUBLIC_CHK_NULL_RETURN(m_mmc);
337 
338     m_allocator = MOS_New(VpAllocator, m_osInterface, m_mmc);
339     VP_PUBLIC_CHK_NULL_RETURN(m_allocator);
340 
341     m_statusReport = MOS_New(VPStatusReport, m_osInterface);
342     VP_PUBLIC_CHK_NULL_RETURN(m_statusReport);
343 
344     VP_PUBLIC_CHK_STATUS_RETURN(CreateVPDebugInterface());
345 
346     m_vpMhwInterface.m_debugInterface = (void*)m_debugInterface;
347 
348     m_pPacketFactory = MOS_New(PacketFactory, m_vpMhwInterface.m_vpPlatformInterface);
349     VP_PUBLIC_CHK_NULL_RETURN(m_pPacketFactory);
350 
351     VP_PUBLIC_CHK_STATUS_RETURN(CreatePacketSharedContext());
352     VP_PUBLIC_CHK_STATUS_RETURN(CreateVpKernelSets());
353     // Create active tasks
354     MediaTask *pTask = GetTask(MediaTask::TaskType::cmdTask);
355     VP_PUBLIC_CHK_NULL_RETURN(pTask);
356     VP_PUBLIC_CHK_STATUS_RETURN(m_pPacketFactory->Initialize(pTask, &m_vpMhwInterface, m_allocator, m_mmc, m_packetSharedContext, m_kernelSet, m_debugInterface));
357 
358     m_pPacketPipeFactory = MOS_New(PacketPipeFactory, *m_pPacketFactory);
359     VP_PUBLIC_CHK_NULL_RETURN(m_pPacketPipeFactory);
360 
361     if (m_vpPipeContexts.size() == 0)
362     {
363         VP_PUBLIC_CHK_STATUS_RETURN(CreateSinglePipeContext());
364     }
365     VpResourceManager *resourceManager = m_vpPipeContexts[0]->GetVpResourceManager();
366     VP_PUBLIC_CHK_STATUS_RETURN(CreateFeatureManager(resourceManager));
367     VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
368 
369     VP_PUBLIC_CHK_STATUS_RETURN(GetSystemVeboxNumber());
370 
371     VP_PUBLIC_CHK_STATUS_RETURN(SetVideoProcessingSettings(m_vpMhwInterface.m_settings));
372 
373     m_vpMhwInterface.m_settings = m_vpSettings;
374     if (m_vpMhwInterface.m_vpPlatformInterface->IsGpuContextCreatedInPipelineInit())
375     {
376         if (m_numVebox > 0 && !(m_vpSettings && m_vpSettings->clearVideoViewMode))
377         {
378             VP_PUBLIC_NORMALMESSAGE("Create GpuContext for Vebox.");
379             VP_PUBLIC_CHK_STATUS_RETURN(PacketPipe::SwitchContext(VP_PIPELINE_PACKET_VEBOX, m_scalability,
380                 m_mediaContext, MOS_VE_SUPPORTED(m_osInterface), m_numVebox));
381         }
382 
383         bool computeContextEnabled = m_userFeatureControl->IsComputeContextEnabled();
384         auto packetId              = computeContextEnabled ? VP_PIPELINE_PACKET_COMPUTE : VP_PIPELINE_PACKET_RENDER;
385         VP_PUBLIC_NORMALMESSAGE("Create GpuContext for Compute/Render (PacketId: %d).", packetId);
386         VP_PUBLIC_CHK_STATUS_RETURN(PacketPipe::SwitchContext(packetId, m_scalability,
387             m_mediaContext, MOS_VE_SUPPORTED(m_osInterface), m_numVebox));
388 
389         // create SinglePipe GpuContext for multi Vebox system to avoid first frame long latency issue
390         if (m_numVebox > 1 && !(m_vpSettings && m_vpSettings->clearVideoViewMode))
391         {
392             VP_PUBLIC_NORMALMESSAGE("Create Single Pipe GpuContext for Vebox.");
393             VP_PUBLIC_CHK_STATUS_RETURN(PacketPipe::SwitchContext(VP_PIPELINE_PACKET_VEBOX, m_scalability,
394                 m_mediaContext, MOS_VE_SUPPORTED(m_osInterface), 1));
395         }
396     }
397 
398     return MOS_STATUS_SUCCESS;
399 }
400 
IsVeboxSfcFormatSupported(MOS_FORMAT formatInput,MOS_FORMAT formatOutput)401 bool VpPipeline::IsVeboxSfcFormatSupported(MOS_FORMAT formatInput, MOS_FORMAT formatOutput)
402 {
403     VP_FUNC_CALL();
404 
405     VpFeatureManagerNext *featureManagerNext = dynamic_cast<VpFeatureManagerNext *>(m_featureManager);
406     if (nullptr == featureManagerNext)
407     {
408         VP_PUBLIC_ASSERTMESSAGE("m_featureManager equals to nullptr!");
409         return false;
410     }
411     return featureManagerNext->IsVeboxSfcFormatSupported(formatInput, formatOutput);
412 }
413 
UpdateRectForNegtiveDstTopLeft(PVP_PIPELINE_PARAMS params)414 MOS_STATUS VpPipeline::UpdateRectForNegtiveDstTopLeft(PVP_PIPELINE_PARAMS params)
415 {
416     VP_FUNC_CALL();
417 
418     for (uint32_t index = 0; (index < params->uSrcCount) && (index < VPHAL_MAX_SOURCES); index++)
419     {
420         PVPHAL_SURFACE pcSrc = params->pSrc[index];
421 
422         if (pcSrc)
423         {
424             if (pcSrc->rcDst.top < 0 || pcSrc->rcDst.left < 0)
425             {
426                 VP_PUBLIC_NORMALMESSAGE("negtive value on rcDst top or left, top: %d, left: %d.", pcSrc->rcDst.top, pcSrc->rcDst.left);
427                 bool isVerticalRotation = VpUtils::IsVerticalRotation(pcSrc->Rotation);
428 
429                 uint32_t srcHeight = pcSrc->rcSrc.bottom - pcSrc->rcSrc.top;
430                 uint32_t srcWidth  = pcSrc->rcSrc.right - pcSrc->rcSrc.left;
431                 uint32_t dstHeight = pcSrc->rcDst.bottom - pcSrc->rcDst.top;
432                 uint32_t dstWidth  = pcSrc->rcDst.right - pcSrc->rcDst.left;
433 
434                 float fScaleX = isVerticalRotation ? (float)dstHeight / (float)srcWidth : (float)dstWidth / (float)srcWidth;
435                 float fScaleY = isVerticalRotation ? (float)dstWidth / (float)srcHeight : (float)dstHeight / (float)srcHeight;
436 
437                 if (pcSrc->rcDst.top < 0)
438                 {
439                     pcSrc->rcDst.top = 0;
440 
441                     if (isVerticalRotation)
442                     {
443                         uint32_t newDstHight = pcSrc->rcDst.bottom;
444                         uint32_t newSrcWidth = MOS_UF_ROUND(newDstHight / fScaleX);
445                         pcSrc->rcSrc.left    = pcSrc->rcSrc.right - newSrcWidth;
446                     }
447                     else
448                     {
449                         uint32_t newDstHight = pcSrc->rcDst.bottom;
450                         uint32_t newSrcHight = MOS_UF_ROUND(newDstHight / fScaleY);
451                         pcSrc->rcSrc.top     = pcSrc->rcSrc.bottom - newSrcHight;
452                     }
453                 }
454                 if (pcSrc->rcDst.left < 0)
455                 {
456                     pcSrc->rcDst.left = 0;
457                     if (isVerticalRotation)
458                     {
459                         uint32_t newDstWidth = pcSrc->rcDst.right;
460                         uint32_t newSrcHight = MOS_UF_ROUND(newDstWidth / fScaleY);
461                         pcSrc->rcSrc.top     = pcSrc->rcSrc.bottom - newSrcHight;
462                     }
463                     else
464                     {
465                         uint32_t newDstWidth = pcSrc->rcDst.right;
466                         uint32_t newSrcWidth = MOS_UF_ROUND(newDstWidth / fScaleX);
467                         pcSrc->rcSrc.left    = pcSrc->rcSrc.right - newSrcWidth;
468                     }
469                 }
470                 VP_PUBLIC_NORMALMESSAGE("updated source rectangle region: [%d,%d,%d,%d].", pcSrc->rcSrc.left, pcSrc->rcSrc.top, pcSrc->rcSrc.right, pcSrc->rcSrc.bottom);
471                 VP_PUBLIC_NORMALMESSAGE("updated destination rectangle region: [%d,%d,%d,%d].", pcSrc->rcDst.left, pcSrc->rcDst.top, pcSrc->rcDst.right, pcSrc->rcDst.bottom);
472             }
473         }
474     }
475 
476     return MOS_STATUS_SUCCESS;
477 }
478 
ExecuteVpPipeline()479 MOS_STATUS VpPipeline::ExecuteVpPipeline()
480 {
481     VP_FUNC_CALL();
482 
483     MOS_STATUS                 eStatus   = MOS_STATUS_SUCCESS;
484     PacketPipe                 *pPacketPipe = nullptr;
485     std::vector<SwFilterPipe*> swFilterPipes;
486     VpFeatureManagerNext       *featureManagerNext = dynamic_cast<VpFeatureManagerNext *>(m_featureManager);
487     bool                       isBypassNeeded     = false;
488     PVP_PIPELINE_PARAMS        params = nullptr;
489     Policy                     *policy = nullptr;
490 
491     VP_PUBLIC_CHK_NULL_RETURN(featureManagerNext);
492     VP_PUBLIC_CHK_NULL_RETURN(m_pPacketPipeFactory);
493     VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
494 
495     if (m_vpPipeContexts.size() < 1 || m_vpPipeContexts[0] == nullptr)
496     {
497         VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
498     }
499 
500     MT_LOG1(MT_VP_FEATURE_GRAPH_EXECUTE_VPPIPELINE_START, MT_NORMAL,
501             MT_VP_FEATURE_GRAPH_FILTER_SWFILTERPIPE_COUNT, (int64_t)swFilterPipes.size());
502     VP_PUBLIC_NORMALMESSAGE("Feature Graph: Execute VP Pipeline Start, swfilterPipes count:%d", (int64_t)swFilterPipes.size());
503 
504     if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
505     {
506         params = m_pvpParams.renderParams;
507         VP_PUBLIC_CHK_NULL_RETURN(params);
508         // Get the OptimizeCpuTiming flag from params
509         m_osInterface->bOptimizeCpuTiming = params->bOptimizeCpuTiming;
510         // Set Pipeline status Table
511         m_statusReport->SetPipeStatusReportParams(params, m_vpMhwInterface.m_statusTable);
512 
513 #if ((_DEBUG || _RELEASE_INTERNAL) && !EMUL)
514         VP_PARAMETERS_DUMPPER_DUMP_XML(m_debugInterface,
515             params,
516             m_vpPipeContexts[0]->GetFrameCounter());
517 
518         for (uint32_t uiLayer = 0; uiLayer < params->uSrcCount && uiLayer < VPHAL_MAX_SOURCES; uiLayer++)
519         {
520             VP_SURFACE_DUMP(m_debugInterface,
521                 params->pSrc[uiLayer],
522                 m_vpPipeContexts[0]->GetFrameCounter(),
523                 uiLayer,
524                 VPHAL_DUMP_TYPE_PRE_ALL,
525                 VPHAL_SURF_DUMP_DDI_VP_BLT);
526         }
527 #endif
528         UpdateRectForNegtiveDstTopLeft(params);
529         // Predication
530         SetPredicationParams(params);
531 
532         eStatus = ProcessBypassHandler(params, isBypassNeeded);
533         VP_PUBLIC_CHK_STATUS_RETURN(eStatus);
534         if (isBypassNeeded)
535         {
536             MT_LOG2(MT_VP_FEATURE_GRAPH_EXECUTE_VPPIPELINE_END, MT_NORMAL,
537                     MT_VP_FEATURE_GRAPH_FILTER_SWFILTERPIPE_COUNT, (int64_t)swFilterPipes.size(),
538                     MT_VP_FEATURE_GRAPH_FILTER_PIPELINEBYPASS, isBypassNeeded);
539             VP_PUBLIC_NORMALMESSAGE("Feature Graph: Execute VP Pipeline End, swfilterPipes count:%d, isBypassNeeded:%d",
540                                      (int64_t)swFilterPipes.size(),
541                                      isBypassNeeded);
542             return MOS_STATUS_SUCCESS;
543         }
544     }
545     VP_PUBLIC_CHK_STATUS_RETURN(UpdateFrameTracker());
546     VP_PUBLIC_CHK_STATUS_RETURN(CreateSwFilterPipe(m_pvpParams, swFilterPipes));
547 
548     // Increment frame ID for performance measurement
549     m_osInterface->pfnIncPerfFrameID(m_osInterface);
550 
551     for (uint32_t pipeIdx = 0; pipeIdx < swFilterPipes.size(); pipeIdx++)
552     {
553         auto &pipe = swFilterPipes[pipeIdx];
554         if (pipeIdx >= m_vpPipeContexts.size())
555         {
556             VP_PUBLIC_CHK_STATUS_RETURN(CreateSinglePipeContext());
557         }
558         MT_LOG2(MT_VP_FEATURE_GRAPH_EXECUTE_SINGLE_VPPIPELINE_START, MT_NORMAL,
559                 MT_VP_FEATURE_GRAPH_FILTER_FRAMEID, m_vpPipeContexts[pipeIdx]->GetFrameCounter(),
560                 MT_VP_FEATURE_GRAPH_FILTER_PIPEID, pipeIdx);
561         VP_PUBLIC_NORMALMESSAGE("Feature Graph: Execute VP Single Pipeline Start, frameid:%d, pipeid:%d",
562                                  m_vpPipeContexts[pipeIdx]->GetFrameCounter(),
563                                  pipeIdx);
564         if (pipe)
565         {
566             pipe->AddRTLog();
567         }
568         auto &singlePipeCtx = m_vpPipeContexts[pipeIdx];
569         VP_PUBLIC_CHK_NULL_RETURN(singlePipeCtx->GetVpResourceManager());
570         VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface->SwitchResourceManager(singlePipeCtx->GetVpResourceManager()));
571 
572         VP_PUBLIC_CHK_STATUS_RETURN(ExecuteSingleswFilterPipe(singlePipeCtx, pipe, pPacketPipe, featureManagerNext));
573         // FrameCounter will be increased inside ExecuteSingleswFilterPipe, so m_vpPipeContexts[pipeIdx]->GetFrameCounter() - 1 is needed.
574         MT_LOG2(MT_VP_FEATURE_GRAPH_EXECUTE_SINGLE_VPPIPELINE_END, MT_NORMAL,
575                 MT_VP_FEATURE_GRAPH_FILTER_FRAMEID, m_vpPipeContexts[pipeIdx]->GetFrameCounter() - 1,
576                 MT_VP_FEATURE_GRAPH_FILTER_PIPEID, pipeIdx);
577         VP_PUBLIC_NORMALMESSAGE("Feature Graph: Execute VP Single Pipeline End, frameid:%d, pipeid:%d",
578                                  m_vpPipeContexts[pipeIdx]->GetFrameCounter() - 1,
579                                  pipeIdx);
580     }
581 
582     MT_LOG2(MT_VP_FEATURE_GRAPH_EXECUTE_VPPIPELINE_END, MT_NORMAL,
583             MT_VP_FEATURE_GRAPH_FILTER_SWFILTERPIPE_COUNT, (int64_t)swFilterPipes.size(),
584             MT_VP_FEATURE_GRAPH_FILTER_PIPELINEBYPASS, isBypassNeeded);
585     VP_PUBLIC_NORMALMESSAGE("Feature Graph: Execute VP Pipeline End, swfilterPipes count:%d, isBypassNeeded:%d",
586                              (int64_t)swFilterPipes.size(),
587                              isBypassNeeded);
588     return eStatus;
589 }
590 
ExecuteSingleswFilterPipe(VpSinglePipeContext * singlePipeCtx,SwFilterPipe * & pipe,PacketPipe * pPacketPipe,VpFeatureManagerNext * featureManagerNext)591 MOS_STATUS VpPipeline::ExecuteSingleswFilterPipe(VpSinglePipeContext *singlePipeCtx, SwFilterPipe *&pipe, PacketPipe *pPacketPipe, VpFeatureManagerNext *featureManagerNext)
592 {
593     VP_FUNC_CALL();
594     VpResourceManager    *resourceManager = singlePipeCtx->GetVpResourceManager();
595     VpPacketReuseManager *packetReuseMgr  = singlePipeCtx->GetPacketReUseManager();
596     uint32_t              frameCounter    = singlePipeCtx->GetFrameCounter();
597     MOS_STATUS            eStatus         = MOS_STATUS_SUCCESS;
598 
599     auto retHandler = [&]() {
600         m_pPacketPipeFactory->ReturnPacketPipe(pPacketPipe);
601         m_vpInterface->GetSwFilterPipeFactory().Destory(pipe);
602         m_statusReport->UpdateStatusTableAfterSubmit(eStatus);
603         // Notify resourceManager for end of new frame processing.
604         resourceManager->OnNewFrameProcessEnd();
605         MT_LOG1(MT_VP_HAL_ONNEWFRAME_PROC_END, MT_NORMAL, MT_VP_HAL_ONNEWFRAME_COUNTER, frameCounter);
606         singlePipeCtx->AddFrameCount();
607     };
608 
609     auto chkStatusHandler = [&](MOS_STATUS status) {
610         if (MOS_FAILED(status))
611         {
612             retHandler();
613         }
614         return status;
615     };
616 
617     auto chkNullHandler = [&](void *p) {
618         if (nullptr == p)
619         {
620             retHandler();
621         }
622         return p;
623     };
624 
625     // Notify resourceManager for start of new frame processing.
626     MT_LOG1(MT_VP_HAL_ONNEWFRAME_PROC_START, MT_NORMAL, MT_VP_HAL_ONNEWFRAME_COUNTER, frameCounter);
627     VP_PUBLIC_CHK_STATUS_RETURN(chkStatusHandler(resourceManager->OnNewFrameProcessStart(*pipe)));
628 
629     Policy *policy = featureManagerNext->GetPolicy();
630     VP_PUBLIC_CHK_NULL_RETURN(chkNullHandler(policy));
631 
632     bool isPacketPipeReused = false;
633     VP_PUBLIC_CHK_NULL_RETURN(m_pvpParams.renderParams);
634     VP_PUBLIC_CHK_STATUS_RETURN(chkStatusHandler(packetReuseMgr->PreparePacketPipeReuse(pipe, *policy, *resourceManager, isPacketPipeReused, m_pvpParams.renderParams->bOptimizeCpuTiming)));
635 
636     if (isPacketPipeReused)
637     {
638         VP_PUBLIC_NORMALMESSAGE("Packet reused.");
639         MT_LOG(MT_VP_FEATURE_GRAPH_FEATUREPIPE_REUSE, MT_NORMAL);
640         singlePipeCtx->SetPacketReused(true);
641 
642         PacketPipe *pipeReused = packetReuseMgr->GetPacketPipeReused();
643         VP_PUBLIC_CHK_NULL_RETURN(chkNullHandler(pipeReused));
644 
645         // Update output pipe mode.
646         singlePipeCtx->SetOutputPipeMode(pipeReused->GetOutputPipeMode());
647         singlePipeCtx->SetIsVeboxFeatureInuse(pipeReused->IsVeboxFeatureInuse());
648         // MediaPipeline::m_statusReport is always nullptr in VP APO path right now.
649         eStatus = pipeReused->Execute(MediaPipeline::m_statusReport, m_scalability, m_mediaContext, MOS_VE_SUPPORTED(m_osInterface), m_numVebox);
650         MT_LOG1(MT_VP_HAL_VEBOXNUM_CHECK, MT_NORMAL, MT_VP_HAL_VEBOX_NUMBER, m_numVebox)
651         VP_PUBLIC_NORMALMESSAGE("Vebox Number for check %d", m_numVebox);
652         if (MOS_SUCCEEDED(eStatus))
653         {
654             VP_PUBLIC_CHK_STATUS_RETURN(chkStatusHandler(UpdateExecuteStatus(frameCounter)));
655         }
656 
657         m_vpInterface->GetSwFilterPipeFactory().Destory(pipe);
658 
659         m_statusReport->UpdateStatusTableAfterSubmit(eStatus);
660         // Notify resourceManager for end of new frame processing.
661         resourceManager->OnNewFrameProcessEnd();
662         MT_LOG1(MT_VP_HAL_ONNEWFRAME_PROC_END, MT_NORMAL, MT_VP_HAL_ONNEWFRAME_COUNTER, frameCounter);
663         singlePipeCtx->AddFrameCount();
664         return eStatus;
665     }
666     else
667     {
668         singlePipeCtx->SetPacketReused(false);
669     }
670 
671     pPacketPipe = m_pPacketPipeFactory->CreatePacketPipe();
672     VP_PUBLIC_CHK_NULL_RETURN(chkNullHandler(pPacketPipe));
673 
674     eStatus = featureManagerNext->InitPacketPipe(*pipe, *pPacketPipe);
675     m_vpInterface->GetSwFilterPipeFactory().Destory(pipe);
676     VP_PUBLIC_CHK_STATUS_RETURN(chkStatusHandler(eStatus));
677 
678     // Update output pipe mode.
679     singlePipeCtx->SetOutputPipeMode(pPacketPipe->GetOutputPipeMode());
680     singlePipeCtx->SetIsVeboxFeatureInuse(pPacketPipe->IsVeboxFeatureInuse());
681 
682     // MediaPipeline::m_statusReport is always nullptr in VP APO path right now.
683     eStatus = pPacketPipe->Execute(MediaPipeline::m_statusReport, m_scalability, m_mediaContext, MOS_VE_SUPPORTED(m_osInterface), m_numVebox);
684     MT_LOG1(MT_VP_HAL_VEBOXNUM_CHECK, MT_NORMAL, MT_VP_HAL_VEBOX_NUMBER, m_numVebox)
685     VP_PUBLIC_NORMALMESSAGE("Vebox Number for check %d", m_numVebox);
686     if (MOS_SUCCEEDED(eStatus))
687     {
688         VP_PUBLIC_CHK_STATUS_RETURN(chkStatusHandler(packetReuseMgr->UpdatePacketPipeConfig(pPacketPipe)));
689         VP_PUBLIC_CHK_STATUS_RETURN(chkStatusHandler(UpdateExecuteStatus(frameCounter)));
690     }
691 
692     m_pPacketPipeFactory->ReturnPacketPipe(pPacketPipe);
693     retHandler();
694 
695     return eStatus;
696 }
697 
UpdateExecuteStatus(uint32_t frameCnt)698 MOS_STATUS VpPipeline::UpdateExecuteStatus(uint32_t frameCnt)
699 {
700     VP_FUNC_CALL();
701 
702     MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
703 #if ((_DEBUG || _RELEASE_INTERNAL))
704     if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
705     {
706         PVP_PIPELINE_PARAMS params = m_pvpParams.renderParams;
707         VP_PUBLIC_CHK_NULL(params);
708         VP_SURFACE_PTRS_DUMP(m_debugInterface,
709             params->pTarget,
710             VPHAL_MAX_TARGETS,
711             params->uDstCount,
712             frameCnt,
713             VPHAL_DUMP_TYPE_POST_ALL,
714             params->uSrcCount > 0 ? VPHAL_SURF_DUMP_DDI_VP_BLT : VPHAL_SURF_DUMP_DDI_CLEAR_VIEW);
715 
716         // Decompre output surface for debug
717         bool uiForceDecompressedOutput = false;
718         uiForceDecompressedOutput = m_userFeatureControl->IsForceDecompressedOutput();
719 
720         if (uiForceDecompressedOutput)
721         {
722             VP_PUBLIC_NORMALMESSAGE("uiForceDecompressedOutput: %d", uiForceDecompressedOutput);
723             m_mmc->DecompressVPResource(params->pTarget[0]);
724         }
725     }
726 finish:
727 #endif
728     return eStatus;
729 }
730 
CreateSwFilterPipe(VP_PARAMS & params,std::vector<SwFilterPipe * > & swFilterPipe)731 MOS_STATUS VpPipeline::CreateSwFilterPipe(VP_PARAMS &params, std::vector<SwFilterPipe*> &swFilterPipe)
732 {
733     VP_FUNC_CALL();
734     switch (m_pvpParams.type)
735     {
736     case PIPELINE_PARAM_TYPE_LEGACY:
737         VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface->GetSwFilterPipeFactory().Create(m_pvpParams.renderParams, swFilterPipe, m_pipelineParamFactory));
738         break;
739     case PIPELINE_PARAM_TYPE_MEDIA_SFC_INTERFACE:
740         VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface->GetSwFilterPipeFactory().Create(m_pvpParams.sfcParams, swFilterPipe));
741         break;
742     default:
743         VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
744     }
745 
746     if (swFilterPipe.size() == 0)
747     {
748         VP_PUBLIC_ASSERTMESSAGE("Fail to create SwFilterPipe.");
749         return MOS_STATUS_NULL_POINTER;
750     }
751 
752     return MOS_STATUS_SUCCESS;
753 }
754 
UpdateFrameTracker()755 MOS_STATUS VpPipeline::UpdateFrameTracker()
756 {
757     VP_FUNC_CALL();
758 
759     VP_PUBLIC_CHK_NULL_RETURN(m_vpMhwInterface.m_vpPlatformInterface);
760     VP_PUBLIC_CHK_STATUS_RETURN(m_vpMhwInterface.m_vpPlatformInterface->InitFrameTracker());
761     return MOS_STATUS_SUCCESS;
762 }
763 
UpdateVeboxNumberforScalability()764 MOS_STATUS VpPipeline::UpdateVeboxNumberforScalability()
765 {
766     VP_FUNC_CALL();
767 
768     VP_PUBLIC_CHK_NULL_RETURN(m_vpMhwInterface.m_vpPlatformInterface);
769 
770     // Check whether scalability being disabled.
771     int32_t enableVeboxScalability = 0;
772 
773     if (m_numVebox <= 0)
774     {
775         VP_PUBLIC_NORMALMESSAGE("Vebox Number of Enabled %d", m_numVebox);
776         return MOS_STATUS_SUCCESS;
777     }
778 
779     MOS_STATUS statusKey = MOS_STATUS_SUCCESS;
780     statusKey = ReadUserSetting(
781         m_userSettingPtr,
782         enableVeboxScalability,
783         __MEDIA_USER_FEATURE_VALUE_ENABLE_VEBOX_SCALABILITY_MODE,
784         MediaUserSetting::Group::Device);
785 
786     bool disableScalability = false;
787     if (statusKey == MOS_STATUS_SUCCESS)
788     {
789         disableScalability = enableVeboxScalability ? false : true;
790         if (disableScalability == false)
791         {
792             m_forceMultiplePipe = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_DEFAULT;
793         }
794         else
795         {
796             m_forceMultiplePipe = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_FALSE;
797         }
798     }
799     else
800     {
801         m_forceMultiplePipe = MOS_SCALABILITY_ENABLE_MODE_DEFAULT;
802     }
803 
804     if (disableScalability == true)
805     {
806         m_numVebox = 1;
807         VP_PUBLIC_NORMALMESSAGE("DisableScalability Vebox Number of Enabled %d", m_numVebox);
808         return MOS_STATUS_SUCCESS;
809     }
810     else if (m_forceMultiplePipe == MOS_SCALABILITY_ENABLE_MODE_DEFAULT)
811     {
812         if (m_vpMhwInterface.m_vpPlatformInterface->IsVeboxScalabilityWith4KNotSupported(m_vpMhwInterface) == true)
813         {
814             m_numVebox = 1;
815             VP_PUBLIC_NORMALMESSAGE("ForceMultiplePipe Vebox Number of Enabled %d", m_numVebox);
816             return MOS_STATUS_SUCCESS;
817         }
818     }
819 
820     return MOS_STATUS_SUCCESS;
821 }
822 
GetSystemVeboxNumber()823 MOS_STATUS VpPipeline::GetSystemVeboxNumber()
824 {
825     VP_FUNC_CALL();
826 
827     // Get vebox number from meida sys info.
828     MEDIA_ENGINE_INFO mediaSysInfo = {};
829     MOS_STATUS        eStatus      = m_osInterface->pfnGetMediaEngineInfo(m_osInterface, mediaSysInfo);
830     if (MOS_SUCCEEDED(eStatus))
831     {
832         // Both VE mode and media solo mode should be able to get the VEBOX number via the same interface
833         m_numVebox = (uint8_t)(mediaSysInfo.VEBoxInfo.NumberOfVEBoxEnabled);
834         VP_PUBLIC_NORMALMESSAGE("Vebox Number of Enabled %d", m_numVebox);
835         if (m_numVebox == 0 && !IsGtEnv())
836         {
837             VP_PUBLIC_ASSERTMESSAGE("Fail to get the m_numVebox with value 0");
838             VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
839         }
840         else if (m_numVebox == 0 && MEDIA_IS_SKU(m_osInterface->pfnGetSkuTable(m_osInterface), FtrVERing))
841         {
842             m_numVebox = 1;
843         }
844     }
845     else
846     {
847         m_numVebox = 1;
848     }
849 
850     VP_PUBLIC_CHK_STATUS_RETURN(UpdateVeboxNumberforScalability());
851 
852     m_numVeboxOriginal = m_numVebox;
853 
854     return MOS_STATUS_SUCCESS;
855 }
856 
CreateSinglePipeContext()857 MOS_STATUS VpPipeline::CreateSinglePipeContext()
858 {
859     VP_FUNC_CALL();
860     VpSinglePipeContext *singlePipeCtx = MOS_New(VpSinglePipeContext);
861     VP_PUBLIC_CHK_NULL_RETURN(singlePipeCtx);
862     MOS_STATUS status = singlePipeCtx->Init(m_osInterface, m_allocator, m_reporting, m_vpMhwInterface.m_vpPlatformInterface, m_pPacketPipeFactory, m_userFeatureControl, m_mediaCopyWrapper);
863     if (MOS_FAILED(status))
864     {
865         MOS_Delete(singlePipeCtx);
866         VP_PUBLIC_CHK_STATUS_RETURN(status);
867     }
868     else
869     {
870         m_vpPipeContexts.push_back(singlePipeCtx);
871     }
872     return status;
873 }
874 
CreateFeatureManager(VpResourceManager * vpResourceManager)875 MOS_STATUS VpPipeline::CreateFeatureManager(VpResourceManager *vpResourceManager)
876 {
877     VP_FUNC_CALL();
878 
879     VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
880     VP_PUBLIC_CHK_NULL_RETURN(m_allocator);
881     VP_PUBLIC_CHK_NULL_RETURN(m_reporting);
882     VP_PUBLIC_CHK_NULL_RETURN(m_vpMhwInterface.m_vpPlatformInterface);
883     VP_PUBLIC_CHK_NULL_RETURN(vpResourceManager);
884 
885     // Add CheckFeatures api later in FeatureManagerNext.
886     m_paramChecker = m_vpMhwInterface.m_vpPlatformInterface->CreateFeatureChecker(&m_vpMhwInterface);
887     VP_PUBLIC_CHK_NULL_RETURN(m_paramChecker);
888 
889     m_vpInterface = MOS_New(VpInterface, &m_vpMhwInterface, *m_allocator, vpResourceManager);
890 
891     VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface);
892 
893     m_featureManager = MOS_New(VpFeatureManagerNext, *m_vpInterface);
894     VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
895 
896     VP_PUBLIC_CHK_STATUS_RETURN(((VpFeatureManagerNext *)m_featureManager)->Init(nullptr));
897 
898     m_pipelineParamFactory = MOS_New(VpPipelineParamFactory);
899     VP_PUBLIC_CHK_NULL_RETURN(m_pipelineParamFactory);
900 
901     return MOS_STATUS_SUCCESS;
902 }
903 
CreateVpKernelSets()904 MOS_STATUS VpPipeline::CreateVpKernelSets()
905 {
906     VP_FUNC_CALL();
907     if (nullptr == m_kernelSet)
908     {
909         m_kernelSet = MOS_New(VpKernelSet, &m_vpMhwInterface, m_allocator);
910         VP_PUBLIC_CHK_NULL_RETURN(m_kernelSet);
911     }
912     return MOS_STATUS_SUCCESS;
913 }
914 
CheckFeatures(void * params,bool & bapgFuncSupported)915 MOS_STATUS VpPipeline::CheckFeatures(void *params, bool &bapgFuncSupported)
916 {
917     VP_FUNC_CALL();
918 
919     VP_PUBLIC_CHK_NULL_RETURN(m_paramChecker);
920     return m_paramChecker->CheckFeatures(params, bapgFuncSupported);
921 }
922 
CreateFeatureReport()923 MOS_STATUS VpPipeline::CreateFeatureReport()
924 {
925     VP_FUNC_CALL();
926 
927     if (m_vpMhwInterface.m_reporting)
928     {
929         if (m_reporting && m_reporting->owner == this && m_vpMhwInterface.m_reporting != m_reporting)
930         {
931             MOS_FreeMemory(m_reporting);
932         }
933         m_reporting = m_vpMhwInterface.m_reporting;
934     }
935     else
936     {
937         if (m_reporting == nullptr)
938         {
939             VP_PUBLIC_CHK_STATUS_RETURN(CreateReport());
940         }
941         m_vpMhwInterface.m_reporting = m_reporting;
942     }
943 
944     VP_PUBLIC_CHK_NULL_RETURN(m_reporting);
945     return MOS_STATUS_SUCCESS;
946 }
947 
948 #if (_DEBUG || _RELEASE_INTERNAL)
AllocateTempTargetSurface(VPHAL_SURFACE * m_tempTargetSurface)949 VPHAL_SURFACE *VpPipeline::AllocateTempTargetSurface(VPHAL_SURFACE *m_tempTargetSurface)
950 {
951     VP_FUNC_CALL();
952 
953     m_tempTargetSurface = (VPHAL_SURFACE *)MOS_AllocAndZeroMemory(sizeof(VPHAL_SURFACE));
954     if (!m_tempTargetSurface)
955     {
956         return nullptr;
957     }
958     return m_tempTargetSurface;
959 }
960 
SurfaceReplace(PVP_PIPELINE_PARAMS params)961 MOS_STATUS VpPipeline::SurfaceReplace(PVP_PIPELINE_PARAMS params)
962 {
963     MOS_STATUS                  eStatus = MOS_STATUS_SUCCESS;
964     bool                        allocated;
965 
966     MEDIA_FEATURE_TABLE *skuTable = nullptr;
967     skuTable                      = m_vpMhwInterface.m_osInterface->pfnGetSkuTable(m_vpMhwInterface.m_osInterface);
968     VP_PUBLIC_CHK_NULL_RETURN(skuTable);
969     VP_PUBLIC_CHK_NULL_RETURN(m_userFeatureControl);
970 
971     if (m_userFeatureControl->EnabledSFCNv12P010LinearOutput() &&
972         MOS_TILE_LINEAR != params->pTarget[0]->TileType &&
973         (Format_P010 == params->pTarget[0]->Format || Format_NV12 == params->pTarget[0]->Format) &&
974         MEDIA_IS_SKU(skuTable, FtrSFC420LinearOutputSupport))
975     {
976         if (!m_tempTargetSurface)
977         {
978             m_tempTargetSurface = AllocateTempTargetSurface(m_tempTargetSurface);
979         }
980         VP_PUBLIC_CHK_NULL_RETURN(m_tempTargetSurface);
981         eStatus = m_allocator->ReAllocateSurface(
982             m_tempTargetSurface,
983             "TempTargetSurface",
984             params->pTarget[0]->Format,
985             MOS_GFXRES_2D,
986             MOS_TILE_LINEAR,
987             params->pTarget[0]->dwWidth,
988             params->pTarget[0]->dwHeight,
989             false,
990             MOS_MMC_DISABLED,
991             &allocated);
992 
993         m_tempTargetSurface->ColorSpace = params->pTarget[0]->ColorSpace;
994         m_tempTargetSurface->rcSrc      = params->pTarget[0]->rcSrc;
995         m_tempTargetSurface->rcDst      = params->pTarget[0]->rcDst;
996         m_tempTargetSurface->rcMaxSrc   = params->pTarget[0]->rcMaxSrc;
997 
998         if (eStatus == MOS_STATUS_SUCCESS)
999         {
1000             params->pTarget[0] = m_tempTargetSurface;    //params is the copy of pcRenderParams which will not cause the memleak,
1001         }
1002     }
1003 
1004     typedef struct _RGBFormatConfig
1005     {
1006         MOS_FORMAT      format;
1007         MOS_TILE_TYPE   tielType;
1008     } RGBFormatConfig;
1009 
1010     static const RGBFormatConfig rgbCfg[VP_RGB_OUTPUT_OVERRIDE_ID_MAX] = {
1011         {Format_Invalid, MOS_TILE_INVALID},
1012         {Format_RGBP, MOS_TILE_LINEAR},
1013         {Format_RGBP, MOS_TILE_Y},
1014         {Format_R8G8B8, MOS_TILE_LINEAR},
1015         {Format_BGRP, MOS_TILE_LINEAR},
1016         {Format_BGRP, MOS_TILE_Y}
1017     };
1018 
1019     if (m_userFeatureControl->EnabledSFCRGBPRGB24Output() == VP_RGB_OUTPUT_OVERRIDE_ID_INVALID ||
1020         m_userFeatureControl->EnabledSFCRGBPRGB24Output() >= VP_RGB_OUTPUT_OVERRIDE_ID_MAX)
1021     {
1022         return MOS_STATUS_SUCCESS;
1023     }
1024 
1025     if (rgbCfg[m_userFeatureControl->EnabledSFCRGBPRGB24Output()].format != params->pTarget[0]->Format &&
1026         MEDIA_IS_SKU(skuTable, FtrSFCRGBPRGB24OutputSupport))
1027     {
1028         if (!m_tempTargetSurface)
1029         {
1030             m_tempTargetSurface = AllocateTempTargetSurface(m_tempTargetSurface);
1031         }
1032         VP_PUBLIC_CHK_NULL_RETURN(m_tempTargetSurface);
1033         eStatus = m_allocator->ReAllocateSurface(
1034             m_tempTargetSurface,
1035             "TempTargetSurface",
1036             rgbCfg[m_userFeatureControl->EnabledSFCRGBPRGB24Output()].format,
1037             MOS_GFXRES_2D,
1038             rgbCfg[m_userFeatureControl->EnabledSFCRGBPRGB24Output()].tielType,
1039             params->pTarget[0]->dwWidth,
1040             params->pTarget[0]->dwHeight,
1041             false,
1042             MOS_MMC_DISABLED,
1043             &allocated);
1044 
1045         m_tempTargetSurface->ColorSpace = params->pTarget[0]->ColorSpace;
1046         m_tempTargetSurface->rcSrc      = params->pTarget[0]->rcSrc;
1047         m_tempTargetSurface->rcDst      = params->pTarget[0]->rcDst;
1048         m_tempTargetSurface->rcMaxSrc   = params->pTarget[0]->rcMaxSrc;
1049 
1050         if (eStatus == MOS_STATUS_SUCCESS)
1051         {
1052             params->pTarget[0] = m_tempTargetSurface;  //params is the copy of pcRenderParams which will not cause the memleak,
1053         }
1054     }
1055 
1056     return eStatus;
1057 }
1058 #endif
1059 
PrepareVpPipelineParams(PVP_PIPELINE_PARAMS params)1060 MOS_STATUS VpPipeline::PrepareVpPipelineParams(PVP_PIPELINE_PARAMS params)
1061 {
1062     VP_FUNC_CALL();
1063     VP_PUBLIC_CHK_NULL_RETURN(params);
1064 
1065 #if (_DEBUG || _RELEASE_INTERNAL)
1066     SurfaceReplace(params);    // replace output surface from Tile-Y to Linear
1067 #endif
1068 
1069     if ((m_vpMhwInterface.m_osInterface != nullptr))
1070     {
1071         // Set the component info
1072         m_vpMhwInterface.m_osInterface->Component = params->Component;
1073 
1074         // Init component(DDI entry point) info for perf measurement
1075         m_vpMhwInterface.m_osInterface->pfnSetPerfTag(m_vpMhwInterface.m_osInterface, VPHAL_NONE);
1076     }
1077 
1078     PMOS_RESOURCE ppSource[VPHAL_MAX_SOURCES] = {nullptr};
1079     PMOS_RESOURCE ppTarget[VPHAL_MAX_TARGETS] = {nullptr};
1080 
1081     VP_PUBLIC_CHK_NULL_RETURN(params->pTarget[0]);
1082     VP_PUBLIC_CHK_NULL_RETURN(m_allocator);
1083     VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
1084 
1085     // Can be removed, as all info can be gotten during AllocateVpSurface.
1086     VPHAL_GET_SURFACE_INFO  info = {};
1087     for (uint32_t i = 0; i < params->uSrcCount; ++i)
1088     {
1089         MOS_ZeroMemory(&info, sizeof(VPHAL_GET_SURFACE_INFO));
1090         VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(
1091             params->pSrc[i],
1092             info));
1093     }
1094 
1095     MOS_ZeroMemory(&info, sizeof(VPHAL_GET_SURFACE_INFO));
1096     VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(
1097         params->pTarget[0],
1098         info));
1099 
1100     if (params->uSrcCount>0)
1101     {
1102         if (params->pSrc[0]->pBwdRef && params->pSrc[0]->uBwdRefCount > 0)
1103         {
1104             MOS_ZeroMemory(&info, sizeof(VPHAL_GET_SURFACE_INFO));
1105 
1106             VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(
1107                 params->pSrc[0]->pBwdRef,
1108                 info));
1109         }
1110 
1111         if (!RECT1_CONTAINS_RECT2(params->pSrc[0]->rcMaxSrc, params->pSrc[0]->rcSrc))
1112         {
1113             params->pSrc[0]->rcMaxSrc = params->pSrc[0]->rcSrc;
1114         }
1115     }
1116 
1117     bool bApgFuncSupported = false;
1118     VP_PUBLIC_CHK_STATUS_RETURN(CheckFeatures(params, bApgFuncSupported));
1119 
1120     if (!bApgFuncSupported)
1121     {
1122         VP_PUBLIC_NORMALMESSAGE("Features are not supported on APG now \n");
1123 
1124         if (m_currentFrameAPGEnabled)
1125         {
1126             params->bAPGWorkloadEnable = true;
1127             m_currentFrameAPGEnabled        = false;
1128         }
1129         else
1130         {
1131             params->bAPGWorkloadEnable = false;
1132         }
1133 
1134         return MOS_STATUS_UNIMPLEMENTED;
1135     }
1136     else
1137     {
1138         m_currentFrameAPGEnabled        = true;
1139         params->bAPGWorkloadEnable = false;
1140         VP_PUBLIC_NORMALMESSAGE("Features can be enabled on APG");
1141     }
1142 
1143     // Init Resource Max Rect for primary video
1144 
1145     if ((nullptr != m_vpMhwInterface.m_osInterface) &&
1146         (nullptr != m_vpMhwInterface.m_osInterface->osCpInterface))
1147     {
1148         for (uint32_t uiIndex = 0; uiIndex < params->uSrcCount; uiIndex++)
1149         {
1150             ppSource[uiIndex] = &(params->pSrc[uiIndex]->OsResource);
1151         }
1152         for (uint32_t uiIndex = 0; uiIndex < params->uDstCount; uiIndex++)
1153         {
1154             ppTarget[uiIndex] = &(params->pTarget[uiIndex]->OsResource);
1155         }
1156         m_vpMhwInterface.m_osInterface->osCpInterface->PrepareResources(
1157             (void **)ppSource, params->uSrcCount, (void **)ppTarget, params->uDstCount);
1158     }
1159 
1160     PrepareVpPipelineScalabilityParams(params);
1161 
1162     for (uint32_t uiIndex = 0; uiIndex < params->uSrcCount; uiIndex++)
1163     {
1164         // Add Procamp limitation before Render pass selected
1165         // Brightness[-100.0,100.0], Contrast & Saturation[0.0,10.0]
1166         PVPHAL_PROCAMP_PARAMS pProcampParams = params->pSrc[uiIndex]->pProcampParams;
1167         if (pProcampParams && pProcampParams->bEnabled)
1168         {
1169             pProcampParams->fBrightness = MOS_MIN(MOS_MAX(-100.0f, pProcampParams->fBrightness), 100.0f);
1170             pProcampParams->fContrast   = MOS_MIN(MOS_MAX(0.0f, pProcampParams->fContrast), 10.0f);
1171             pProcampParams->fSaturation = MOS_MIN(MOS_MAX(0.0f, pProcampParams->fSaturation), 10.0f);
1172         }
1173     }
1174 
1175     return MOS_STATUS_SUCCESS;
1176 }
1177 
1178 //!
1179 //! \brief  prepare execution params for vp scalability pipeline
1180 //! \param  [in] params
1181 //!         src and dst surface's width and height
1182 //! \return MOS_STATUS
1183 //!         MOS_STATUS_SUCCESS if success, else fail reason
1184 //!
PrepareVpPipelineScalabilityParams(uint32_t srcWidth,uint32_t srcHeight,uint32_t dstWidth,uint32_t dstHeight)1185 MOS_STATUS VpPipeline::PrepareVpPipelineScalabilityParams(uint32_t srcWidth, uint32_t srcHeight, uint32_t dstWidth, uint32_t dstHeight)
1186 {
1187     VP_FUNC_CALL();
1188     VP_PUBLIC_NORMALMESSAGE("Reset m_numVebox %d -> %d", m_numVebox, m_numVeboxOriginal);
1189     m_numVebox = m_numVeboxOriginal;
1190     MT_LOG1(MT_VP_HAL_VEBOXNUM_RESET, MT_NORMAL, MT_VP_HAL_VEBOX_NUMBER, m_numVebox)
1191 
1192     // Disable vesfc scalability when reg key "Enable Vebox Scalability" was set to zero
1193     if (m_forceMultiplePipe == (MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_FALSE))
1194     {
1195         m_numVebox = 1;
1196     }
1197     else
1198     {
1199         if (((srcWidth > m_scalability_threshWidth) &&
1200              (srcHeight > m_scalability_threshHeight)) ||
1201             ((dstWidth > m_scalability_threshWidth) &&
1202              (dstHeight > m_scalability_threshHeight)))
1203         {
1204             // Enable vesfc scalability only with 4k+ clips
1205         }
1206         else
1207         {
1208             // disable vesfc scalability with 4k- resolution clips if reg "Enable Vebox Scalability" was not set as true
1209             if (m_forceMultiplePipe != (MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_DEFAULT))
1210             {
1211                 m_numVebox = 1;
1212             }
1213         }
1214     }
1215 
1216     return MOS_STATUS_SUCCESS;
1217 }
1218 
1219 //!
1220 //! \brief  prepare execution params for vp scalability pipeline
1221 //! \param  [in] params
1222 //!         Pointer to VP scalability pipeline params
1223 //! \return MOS_STATUS
1224 //!         MOS_STATUS_SUCCESS if success, else fail reason
1225 //!
PrepareVpPipelineScalabilityParams(VEBOX_SFC_PARAMS * params)1226 MOS_STATUS VpPipeline::PrepareVpPipelineScalabilityParams(VEBOX_SFC_PARAMS* params)
1227 {
1228     VP_FUNC_CALL();
1229     VP_PUBLIC_CHK_NULL_RETURN(params);
1230     VP_PUBLIC_CHK_NULL_RETURN(params->input.surface);
1231     VP_PUBLIC_CHK_NULL_RETURN(params->output.surface);
1232 
1233     VP_PUBLIC_CHK_STATUS_RETURN(PrepareVpPipelineScalabilityParams(
1234         MOS_MIN(params->input.surface->dwWidth, (uint32_t)params->input.rcSrc.right),
1235         MOS_MIN(params->input.surface->dwHeight, (uint32_t)params->input.rcSrc.bottom),
1236         MOS_MIN(params->output.surface->dwWidth, (uint32_t)params->output.rcDst.right),
1237         MOS_MIN(params->output.surface->dwHeight, (uint32_t)params->output.rcDst.bottom)));
1238 
1239     return MOS_STATUS_SUCCESS;
1240 }
1241 
1242 //!
1243 //! \brief  prepare execution params for vp scalability pipeline
1244 //! \param  [in] params
1245 //!         Pointer to VP scalability pipeline params
1246 //! \return MOS_STATUS
1247 //!         MOS_STATUS_SUCCESS if success, else fail reason
1248 //!
PrepareVpPipelineScalabilityParams(PVP_PIPELINE_PARAMS params)1249 MOS_STATUS VpPipeline::PrepareVpPipelineScalabilityParams(PVP_PIPELINE_PARAMS params)
1250 {
1251     VP_FUNC_CALL();
1252     VP_PUBLIC_CHK_NULL_RETURN(params);
1253     if (params->pSrc[0] == nullptr)
1254     {
1255         VP_PUBLIC_NORMALMESSAGE("No input will not need scalability! ");
1256         return MOS_STATUS_SUCCESS;
1257     }
1258 
1259     VP_PUBLIC_CHK_NULL_RETURN(params->pTarget[0]);
1260 
1261     VP_PUBLIC_CHK_STATUS_RETURN(PrepareVpPipelineScalabilityParams(
1262         MOS_MIN(params->pSrc[0]->dwWidth, (uint32_t)params->pSrc[0]->rcSrc.right),
1263         MOS_MIN(params->pSrc[0]->dwHeight, (uint32_t)params->pSrc[0]->rcSrc.bottom),
1264         MOS_MIN(params->pTarget[0]->dwWidth, (uint32_t)params->pTarget[0]->rcSrc.right),
1265         MOS_MIN(params->pTarget[0]->dwHeight, (uint32_t)params->pTarget[0]->rcSrc.bottom)));
1266 
1267     // Disable DN when vesfc scalability was enabled for output mismatch issue
1268     if (IsMultiple())
1269     {
1270         if (params->pSrc[0]->pDenoiseParams)
1271         {
1272             params->pSrc[0]->pDenoiseParams->bAutoDetect   = false;
1273             params->pSrc[0]->pDenoiseParams->bEnableChroma = false;
1274             params->pSrc[0]->pDenoiseParams->bEnableLuma   = false;
1275         }
1276     }
1277 
1278     return MOS_STATUS_SUCCESS;
1279 }
1280 
Prepare(void * params)1281 MOS_STATUS VpPipeline::Prepare(void * params)
1282 {
1283     MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
1284 
1285     VP_FUNC_CALL();
1286 
1287     VP_PUBLIC_CHK_NULL_RETURN(params);
1288     VP_PUBLIC_CHK_NULL_RETURN(m_userFeatureControl);
1289 
1290     m_pvpParams = *(VP_PARAMS *)params;
1291 
1292 #if (_DEBUG || _RELEASE_INTERNAL)
1293     // INTER_FRAME_MEMORY_NINJA_END_COUNTER will be reported in UserFeatureReport() function which runs in Execute()
1294     ReportIFNCC(true);
1295 #endif
1296     // Get Output Pipe for Features. It should be configured in ExecuteVpPipeline.
1297     if (m_vpPipeContexts.size() <= 0 || m_vpPipeContexts[0] == nullptr)
1298     {
1299         VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
1300     }
1301 
1302     m_vpPipeContexts[0]->InitializeOutputPipe();
1303 
1304     if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
1305     {
1306         m_userFeatureControl->Update((PVP_PIPELINE_PARAMS)m_pvpParams.renderParams);
1307         // VP Execution Params Prepare
1308         eStatus = PrepareVpPipelineParams(m_pvpParams.renderParams);
1309         if (eStatus != MOS_STATUS_SUCCESS)
1310         {
1311             if (eStatus == MOS_STATUS_UNIMPLEMENTED)
1312             {
1313                 VP_PUBLIC_NORMALMESSAGE("Features are UNIMPLEMENTED on APG now \n");
1314                 return eStatus;
1315             }
1316             else
1317             {
1318                 VP_PUBLIC_CHK_STATUS_RETURN(eStatus);
1319             }
1320         }
1321     }
1322     else if (PIPELINE_PARAM_TYPE_MEDIA_SFC_INTERFACE == m_pvpParams.type)
1323     {
1324         VEBOX_SFC_PARAMS *sfcParams = m_pvpParams.sfcParams;
1325         VP_PUBLIC_CHK_NULL_RETURN(sfcParams);
1326 
1327         VP_PUBLIC_CHK_STATUS_RETURN(PrepareVpPipelineScalabilityParams(sfcParams));
1328     }
1329 
1330     return MOS_STATUS_SUCCESS;
1331 }
1332 
Execute()1333 MOS_STATUS VpPipeline::Execute()
1334 {
1335     VP_FUNC_CALL();
1336 
1337     VP_PUBLIC_CHK_STATUS_RETURN(ExecuteVpPipeline())
1338     VP_PUBLIC_CHK_STATUS_RETURN(UserFeatureReport());
1339 
1340     bool veboxFeatureInuse = (m_vpPipeContexts.size() >= 1) && (m_vpPipeContexts[0]) && (m_vpPipeContexts[0]->IsVeboxInUse());
1341     if (m_packetSharedContext && m_packetSharedContext->isVeboxFirstFrame && veboxFeatureInuse)
1342     {
1343         m_packetSharedContext->isVeboxFirstFrame = false;
1344     }
1345 
1346     return MOS_STATUS_SUCCESS;
1347 }
1348 
1349 /****************************************************************************************************/
1350 /*                                      VpSinglePipeContext                                         */
1351 /****************************************************************************************************/
1352 
VpSinglePipeContext()1353 VpSinglePipeContext::VpSinglePipeContext()
1354 {
1355 }
1356 
~VpSinglePipeContext()1357 VpSinglePipeContext::~VpSinglePipeContext()
1358 {
1359     MOS_Delete(m_packetReuseMgr);
1360     MOS_Delete(m_resourceManager);
1361 }
1362 
Init(PMOS_INTERFACE osInterface,VpAllocator * allocator,VphalFeatureReport * reporting,vp::VpPlatformInterface * vpPlatformInterface,PacketPipeFactory * packetPipeFactory,VpUserFeatureControl * userFeatureControl,MediaCopyWrapper * mediaCopyWrapper)1363 MOS_STATUS VpSinglePipeContext::Init(PMOS_INTERFACE osInterface, VpAllocator *allocator, VphalFeatureReport *reporting, vp::VpPlatformInterface *vpPlatformInterface, PacketPipeFactory *packetPipeFactory, VpUserFeatureControl *userFeatureControl, MediaCopyWrapper *mediaCopyWrapper)
1364 {
1365     VP_FUNC_CALL();
1366     VP_PUBLIC_CHK_STATUS_RETURN(CreateResourceManager(osInterface, allocator, reporting, vpPlatformInterface, userFeatureControl, mediaCopyWrapper));
1367     VP_PUBLIC_CHK_NULL_RETURN(m_resourceManager);
1368     VP_PUBLIC_CHK_STATUS_RETURN(CreatePacketReuseManager(packetPipeFactory, userFeatureControl));
1369     VP_PUBLIC_CHK_NULL_RETURN(m_packetReuseMgr);
1370 
1371     return MOS_STATUS_SUCCESS;
1372 }
1373 
1374 //!
1375 //! \brief  create reource manager
1376 //! \return MOS_STATUS
1377 //!         MOS_STATUS_SUCCESS if success, else fail reason
1378 //!
CreateResourceManager(PMOS_INTERFACE osInterface,VpAllocator * allocator,VphalFeatureReport * reporting,vp::VpPlatformInterface * vpPlatformInterface,vp::VpUserFeatureControl * userFeatureControl,MediaCopyWrapper * mediaCopyWrapper)1379 MOS_STATUS VpSinglePipeContext::CreateResourceManager(PMOS_INTERFACE osInterface, VpAllocator *allocator, VphalFeatureReport *reporting, vp::VpPlatformInterface *vpPlatformInterface, vp::VpUserFeatureControl *userFeatureControl, MediaCopyWrapper *mediaCopyWrapper)
1380 {
1381     VP_FUNC_CALL();
1382     if (nullptr == m_resourceManager)
1383     {
1384         m_resourceManager = MOS_New(VpResourceManager, *osInterface, *allocator, *reporting, *vpPlatformInterface, mediaCopyWrapper, userFeatureControl);
1385         VP_PUBLIC_CHK_NULL_RETURN(m_resourceManager);
1386     }
1387 
1388     return MOS_STATUS_SUCCESS;
1389 }
1390 
CreatePacketReuseManager(PacketPipeFactory * pPacketPipeFactory,VpUserFeatureControl * userFeatureControl)1391 MOS_STATUS VpSinglePipeContext::CreatePacketReuseManager(PacketPipeFactory *pPacketPipeFactory, VpUserFeatureControl *userFeatureControl)
1392 {
1393     VP_FUNC_CALL();
1394     if (nullptr == m_packetReuseMgr)
1395     {
1396         m_packetReuseMgr = NewVpPacketReuseManagerObj(pPacketPipeFactory, userFeatureControl);
1397         VP_PUBLIC_CHK_NULL_RETURN(m_packetReuseMgr);
1398         VP_PUBLIC_CHK_STATUS_RETURN(m_packetReuseMgr->RegisterFeatures());
1399     }
1400     return MOS_STATUS_SUCCESS;
1401 }
1402