1 /*
2 * Copyright (c) 2018-2021, 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_pPacketPipeFactory before m_pPacketFactory, since
48 // m_pPacketFactory is referenced by m_pPacketPipeFactory.
49 MOS_Delete(m_pPacketPipeFactory);
50 MOS_Delete(m_pPacketFactory);
51 DeletePackets();
52 DeleteTasks();
53 // Delete m_featureManager before m_resourceManager, since
54 // m_resourceManager is referenced by m_featureManager.
55 MOS_Delete(m_featureManager);
56 MOS_Delete(m_vpInterface);
57 MOS_Delete(m_resourceManager);
58 MOS_Delete(m_kernelSet);
59 MOS_Delete(m_paramChecker);
60 MOS_Delete(m_mmc);
61 #if (_DEBUG || _RELEASE_INTERNAL)
62 DestroySurface();
63 #endif
64 MOS_Delete(m_allocator);
65 MOS_Delete(m_statusReport);
66 MOS_Delete(m_packetSharedContext);
67 if (m_vpMhwInterface.m_reporting && this != m_vpMhwInterface.m_reporting->owner)
68 {
69 m_reporting = nullptr;
70 }
71 else
72 {
73 MOS_Delete(m_reporting);
74 m_vpMhwInterface.m_reporting = nullptr;
75 }
76 VP_DEBUG_INTERFACE_DESTROY(m_debugInterface);
77
78 if (m_mediaContext)
79 {
80 MOS_Delete(m_mediaContext);
81 m_mediaContext = nullptr;
82 }
83
84 if (m_vpSettings)
85 {
86 MOS_FreeMemory(m_vpSettings);
87 m_vpSettings = nullptr;
88 }
89
90 if (m_userFeatureControl &&
91 (this == m_userFeatureControl->m_owner || nullptr == m_userFeatureControl->m_owner))
92 {
93 MOS_Delete(m_userFeatureControl);
94 m_vpMhwInterface.m_userFeatureControl = nullptr;
95 }
96 }
97
GetStatusReport(void * status,uint16_t numStatus)98 MOS_STATUS VpPipeline::GetStatusReport(void *status, uint16_t numStatus)
99 {
100 VP_FUNC_CALL();
101
102 return MOS_STATUS_SUCCESS;
103 }
104
Destroy()105 MOS_STATUS VpPipeline::Destroy()
106 {
107 VP_FUNC_CALL();
108
109 return MOS_STATUS_SUCCESS;
110 }
111
112 #if (_DEBUG || _RELEASE_INTERNAL)
DestroySurface()113 MOS_STATUS VpPipeline::DestroySurface()
114 {
115 VP_FUNC_CALL();
116
117 if (m_tempTargetSurface)
118 {
119 m_allocator->FreeResource(&m_tempTargetSurface->OsResource);
120 MOS_FreeMemAndSetNull(m_tempTargetSurface);
121 }
122
123 return MOS_STATUS_SUCCESS;
124 }
125 #endif
126
UserFeatureReport()127 MOS_STATUS VpPipeline::UserFeatureReport()
128 {
129 VP_FUNC_CALL();
130
131 if (m_reporting)
132 {
133 m_reporting->GetFeatures().outputPipeMode = m_vpOutputPipe;
134 m_reporting->GetFeatures().veFeatureInUse = m_veboxFeatureInuse;
135
136 if (m_mmc)
137 {
138 m_reporting->GetFeatures().vpMMCInUse = m_mmc->IsMmcEnabled();
139 }
140
141 if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
142 {
143 PVP_PIPELINE_PARAMS params = m_pvpParams.renderParams;
144 VP_PUBLIC_CHK_NULL_RETURN(params);
145 if (params->pSrc[0] && params->pSrc[0]->bCompressible)
146 {
147 m_reporting->GetFeatures().primaryCompressible = true;
148 m_reporting->GetFeatures().primaryCompressMode = (uint8_t)(params->pSrc[0]->CompressionMode);
149 }
150
151 if (params->pTarget[0]->bCompressible)
152 {
153 m_reporting->GetFeatures().rtCompressible = true;
154 m_reporting->GetFeatures().rtCompressMode = (uint8_t)(params->pTarget[0]->CompressionMode);
155 }
156 }
157 }
158
159 MediaPipeline::UserFeatureReport();
160
161 #if (_DEBUG || _RELEASE_INTERNAL)
162 if (m_currentFrameAPGEnabled)
163 {
164 WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_VPP_APOGEIOS_ENABLE_ID, 1, m_osInterface->pOsContext);
165 }
166 else
167 {
168 WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_VPP_APOGEIOS_ENABLE_ID, 0, m_osInterface->pOsContext);
169 }
170 #endif
171 return MOS_STATUS_SUCCESS;
172 }
173
CreatePacketSharedContext()174 MOS_STATUS VpPipeline::CreatePacketSharedContext()
175 {
176 VP_FUNC_CALL();
177
178 m_packetSharedContext = MOS_New(VP_PACKET_SHARED_CONTEXT);
179 VP_PUBLIC_CHK_NULL_RETURN(m_packetSharedContext);
180 return MOS_STATUS_SUCCESS;
181 }
182
CreateUserFeatureControl()183 MOS_STATUS VpPipeline::CreateUserFeatureControl()
184 {
185 VP_FUNC_CALL();
186
187 VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
188 m_userFeatureControl = MOS_New(VpUserFeatureControl, *m_osInterface, this);
189 VP_PUBLIC_CHK_NULL_RETURN(m_userFeatureControl);
190 return MOS_STATUS_SUCCESS;
191 }
192
Init(void * mhwInterface)193 MOS_STATUS VpPipeline::Init(void *mhwInterface)
194 {
195 VP_FUNC_CALL();
196 VP_PUBLIC_CHK_NULL_RETURN(mhwInterface);
197 VP_PUBLIC_CHK_NULL_RETURN(((PVP_MHWINTERFACE)mhwInterface)->m_vpPlatformInterface);
198
199 m_vpMhwInterface = *(PVP_MHWINTERFACE)mhwInterface;
200
201 VP_PUBLIC_CHK_STATUS_RETURN(MediaPipeline::InitPlatform());
202 VP_PUBLIC_CHK_STATUS_RETURN(MediaPipeline::CreateMediaCopy());
203
204 VP_PUBLIC_CHK_STATUS_RETURN(CreateFeatureReport());
205
206 m_mediaContext = MOS_New(MediaContext, scalabilityVp, &m_vpMhwInterface, m_osInterface);
207 VP_PUBLIC_CHK_NULL_RETURN(m_mediaContext);
208
209 m_mmc = MOS_New(VPMediaMemComp, m_osInterface, m_vpMhwInterface);
210 VP_PUBLIC_CHK_NULL_RETURN(m_mmc);
211
212 m_allocator = MOS_New(VpAllocator, m_osInterface, m_mmc);
213 VP_PUBLIC_CHK_NULL_RETURN(m_allocator);
214
215 m_statusReport = MOS_New(VPStatusReport, m_osInterface);
216 VP_PUBLIC_CHK_NULL_RETURN(m_statusReport);
217
218 VP_PUBLIC_CHK_STATUS_RETURN(CreateFeatureManager());
219 VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
220 VP_PUBLIC_CHK_STATUS_RETURN(InitUserFeatureSetting());
221 #if (_DEBUG || _RELEASE_INTERNAL)
222 VP_DEBUG_INTERFACE_CREATE(m_debugInterface)
223 SkuWaTable_DUMP_XML(m_skuTable, m_waTable)
224 #endif
225
226 m_vpMhwInterface.m_debugInterface = (void*)m_debugInterface;
227
228 m_pPacketFactory = MOS_New(PacketFactory, m_vpMhwInterface.m_vpPlatformInterface);
229 VP_PUBLIC_CHK_NULL_RETURN(m_pPacketFactory);
230
231 VP_PUBLIC_CHK_STATUS_RETURN(CreatePacketSharedContext());
232 VP_PUBLIC_CHK_STATUS_RETURN(CreateVpKernelSets());
233 // Create active tasks
234 MediaTask *pTask = GetTask(MediaTask::TaskType::cmdTask);
235 VP_PUBLIC_CHK_NULL_RETURN(pTask);
236 VP_PUBLIC_CHK_STATUS_RETURN(m_pPacketFactory->Initialize(pTask, &m_vpMhwInterface, m_allocator, m_mmc, m_packetSharedContext, m_kernelSet, m_debugInterface));
237
238 m_pPacketPipeFactory = MOS_New(PacketPipeFactory, *m_pPacketFactory);
239 VP_PUBLIC_CHK_NULL_RETURN(m_pPacketPipeFactory);
240
241 VP_PUBLIC_CHK_STATUS_RETURN(GetSystemVeboxNumber());
242
243 VP_PUBLIC_CHK_STATUS_RETURN(SetVideoProcessingSettings(m_vpMhwInterface.m_settings));
244
245 m_vpMhwInterface.m_settings = m_vpSettings;
246
247 if (m_vpMhwInterface.m_userFeatureControl)
248 {
249 m_userFeatureControl = m_vpMhwInterface.m_userFeatureControl;
250 }
251 else
252 {
253 VP_PUBLIC_CHK_STATUS_RETURN(CreateUserFeatureControl());
254 m_vpMhwInterface.m_userFeatureControl = m_userFeatureControl;
255 }
256
257 return MOS_STATUS_SUCCESS;
258 }
259
IsVeboxSfcFormatSupported(MOS_FORMAT formatInput,MOS_FORMAT formatOutput)260 bool VpPipeline::IsVeboxSfcFormatSupported(MOS_FORMAT formatInput, MOS_FORMAT formatOutput)
261 {
262 VP_FUNC_CALL();
263
264 VpFeatureManagerNext *featureManagerNext = dynamic_cast<VpFeatureManagerNext *>(m_featureManager);
265 if (nullptr == featureManagerNext)
266 {
267 VP_PUBLIC_ASSERTMESSAGE("m_featureManager equals to nullptr!");
268 return false;
269 }
270 return featureManagerNext->IsVeboxSfcFormatSupported(formatInput, formatOutput);
271 }
272
ExecuteVpPipeline()273 MOS_STATUS VpPipeline::ExecuteVpPipeline()
274 {
275 VP_FUNC_CALL();
276
277 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
278 PacketPipe *pPacketPipe = nullptr;
279 std::vector<SwFilterPipe*> swFilterPipes;
280 VpFeatureManagerNext *featureManagerNext = dynamic_cast<VpFeatureManagerNext *>(m_featureManager);
281
282 VP_PUBLIC_CHK_NULL_RETURN(featureManagerNext);
283 VP_PUBLIC_CHK_NULL_RETURN(m_pPacketPipeFactory);
284
285 if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
286 {
287 PVP_PIPELINE_PARAMS params = m_pvpParams.renderParams;
288 VP_PUBLIC_CHK_NULL(params);
289 // Set Pipeline status Table
290 m_statusReport->SetPipeStatusReportParams(params, m_vpMhwInterface.m_statusTable);
291
292 VP_PARAMETERS_DUMPPER_DUMP_XML(m_debugInterface,
293 params,
294 m_frameCounter);
295
296 for (uint32_t uiLayer = 0; uiLayer < params->uSrcCount && uiLayer < VPHAL_MAX_SOURCES; uiLayer++)
297 {
298 VP_SURFACE_DUMP(m_debugInterface,
299 params->pSrc[uiLayer],
300 m_frameCounter,
301 uiLayer,
302 VPHAL_DUMP_TYPE_PRE_ALL);
303 }
304 // Predication
305 SetPredicationParams(params);
306
307 }
308
309 VP_PUBLIC_CHK_STATUS_RETURN(CreateSwFilterPipe(m_pvpParams, swFilterPipes));
310 // Notify resourceManager for start of new frame processing.
311 MT_LOG1(MT_VP_HAL_ONNEWFRAME_PROC_START, MT_NORMAL, MT_VP_HAL_ONNEWFRAME_COUNTER, m_frameCounter);
312 VP_PUBLIC_CHK_STATUS_RETURN(m_resourceManager->OnNewFrameProcessStart(*swFilterPipes[0]));
313
314 for (auto &pipe : swFilterPipes)
315 {
316 pPacketPipe = m_pPacketPipeFactory->CreatePacketPipe();
317 VP_PUBLIC_CHK_NULL(pPacketPipe);
318
319 eStatus = featureManagerNext->InitPacketPipe(*pipe, *pPacketPipe);
320 m_vpInterface->GetSwFilterPipeFactory().Destory(pipe);
321 VP_PUBLIC_CHK_STATUS(eStatus);
322
323 // Update output pipe mode.
324 m_vpOutputPipe = pPacketPipe->GetOutputPipeMode();
325 m_veboxFeatureInuse = pPacketPipe->IsVeboxFeatureInuse();
326
327 // MediaPipeline::m_statusReport is always nullptr in VP APO path right now.
328 eStatus = pPacketPipe->Execute(MediaPipeline::m_statusReport, m_scalability, m_mediaContext, MOS_VE_SUPPORTED(m_osInterface), m_numVebox);
329
330 m_pPacketPipeFactory->ReturnPacketPipe(pPacketPipe);
331
332 if (MOS_SUCCEEDED(eStatus))
333 {
334 VP_PUBLIC_CHK_STATUS(UpdateExecuteStatus());
335 }
336 }
337
338 finish:
339 m_pPacketPipeFactory->ReturnPacketPipe(pPacketPipe);
340 for (auto &pipe : swFilterPipes)
341 {
342 m_vpInterface->GetSwFilterPipeFactory().Destory(pipe);
343 }
344 m_statusReport->UpdateStatusTableAfterSubmit(eStatus);
345 // Notify resourceManager for end of new frame processing.
346 m_resourceManager->OnNewFrameProcessEnd();
347 MT_LOG1(MT_VP_HAL_ONNEWFRAME_PROC_END, MT_NORMAL, MT_VP_HAL_ONNEWFRAME_COUNTER, m_frameCounter);
348 m_frameCounter++;
349 return eStatus;
350 }
351
UpdateExecuteStatus()352 MOS_STATUS VpPipeline::UpdateExecuteStatus()
353 {
354 VP_FUNC_CALL();
355
356 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
357 if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
358 {
359 PVP_PIPELINE_PARAMS params = m_pvpParams.renderParams;
360 VP_PUBLIC_CHK_NULL(params);
361 VP_SURFACE_PTRS_DUMP(m_debugInterface,
362 params->pTarget,
363 VPHAL_MAX_TARGETS,
364 params->uDstCount,
365 m_frameCounter,
366 VPHAL_DUMP_TYPE_POST_ALL);
367
368 #if ((_DEBUG || _RELEASE_INTERNAL) && !EMUL)
369 // Decompre output surface for debug
370 MOS_USER_FEATURE_VALUE_DATA userFeatureData;
371 bool uiForceDecompressedOutput = false;
372 MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
373
374 MOS_STATUS eStatus1 = MOS_UserFeature_ReadValue_ID(
375 nullptr,
376 __VPHAL_RNDR_FORCE_VP_DECOMPRESSED_OUTPUT_ID,
377 &userFeatureData,
378 m_osInterface->pOsContext);
379
380 if (eStatus1 == MOS_STATUS_SUCCESS)
381 {
382 uiForceDecompressedOutput = userFeatureData.u32Data;
383 }
384 else
385 {
386 uiForceDecompressedOutput = false;
387 }
388
389 if (uiForceDecompressedOutput)
390 {
391 VP_PUBLIC_NORMALMESSAGE("uiForceDecompressedOutput: %d", uiForceDecompressedOutput);
392 m_mmc->DecompressVPResource(params->pTarget[0]);
393 }
394 #endif
395 }
396 finish:
397 return eStatus;
398 }
399
CreateSwFilterPipe(VP_PARAMS & params,std::vector<SwFilterPipe * > & swFilterPipe)400 MOS_STATUS VpPipeline::CreateSwFilterPipe(VP_PARAMS ¶ms, std::vector<SwFilterPipe*> &swFilterPipe)
401 {
402 VP_FUNC_CALL();
403
404 switch (m_pvpParams.type)
405 {
406 case PIPELINE_PARAM_TYPE_LEGACY:
407 VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface->GetSwFilterPipeFactory().Create(m_pvpParams.renderParams, swFilterPipe));
408 break;
409 case PIPELINE_PARAM_TYPE_MEDIA_SFC_INTERFACE:
410 VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface->GetSwFilterPipeFactory().Create(m_pvpParams.sfcParams, swFilterPipe));
411 break;
412 default:
413 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
414 break;
415 }
416
417 if (swFilterPipe.size() == 0)
418 {
419 VP_PUBLIC_ASSERTMESSAGE("Fail to create SwFilterPipe.");
420 return MOS_STATUS_NULL_POINTER;
421 }
422
423 return MOS_STATUS_SUCCESS;
424 }
425
GetSystemVeboxNumber()426 MOS_STATUS VpPipeline::GetSystemVeboxNumber()
427 {
428 VP_FUNC_CALL();
429
430 // Check whether scalability being disabled.
431 MOS_USER_FEATURE_VALUE_DATA userFeatureData;
432 MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
433
434 MOS_STATUS statusKey = MOS_STATUS_SUCCESS;
435 statusKey = MOS_UserFeature_ReadValue_ID(
436 nullptr,
437 __MEDIA_USER_FEATURE_VALUE_ENABLE_VEBOX_SCALABILITY_MODE_ID,
438 &userFeatureData,
439 m_osInterface->pOsContext);
440
441 bool disableScalability = false;
442 if (statusKey == MOS_STATUS_SUCCESS)
443 {
444 disableScalability = userFeatureData.i32Data ? false : true;
445 if (disableScalability == false)
446 {
447 m_forceMultiplePipe = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_DEFAULT;
448 }
449 else
450 {
451 m_forceMultiplePipe = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_FALSE;
452 }
453 }
454 else
455 {
456 m_forceMultiplePipe = MOS_SCALABILITY_ENABLE_MODE_DEFAULT;
457 }
458
459 if (disableScalability == true)
460 {
461 m_numVebox = 1;
462 return MOS_STATUS_SUCCESS;
463 }
464 else if (m_forceMultiplePipe == MOS_SCALABILITY_ENABLE_MODE_DEFAULT)
465 {
466 if (m_vpMhwInterface.m_veboxInterface && !(m_vpMhwInterface.m_veboxInterface->m_veboxScalabilitywith4K))
467 {
468 m_numVebox = 1;
469 return MOS_STATUS_SUCCESS;
470 }
471 }
472
473 // Get vebox number from meida sys info.
474 MEDIA_ENGINE_INFO mediaSysInfo = {};
475 MOS_STATUS eStatus = m_osInterface->pfnGetMediaEngineInfo(m_osInterface, mediaSysInfo);
476 if (MOS_SUCCEEDED(eStatus))
477 {
478 // Both VE mode and media solo mode should be able to get the VEBOX number via the same interface
479 m_numVebox = (uint8_t)(mediaSysInfo.VEBoxInfo.NumberOfVEBoxEnabled);
480 VP_PUBLIC_NORMALMESSAGE("Vebox Number of Enabled %d", m_numVebox);
481 if (m_numVebox == 0 && !IsGtEnv())
482 {
483 VP_PUBLIC_ASSERTMESSAGE("Fail to get the m_numVebox with value 0");
484 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
485 }
486 else if (m_numVebox == 0 && MEDIA_IS_SKU(m_osInterface->pfnGetSkuTable(m_osInterface), FtrVERing))
487 {
488 m_numVebox = 1;
489 }
490 }
491 else
492 {
493 m_numVebox = 1;
494 }
495
496 return MOS_STATUS_SUCCESS;
497 }
498
CreateFeatureManager()499 MOS_STATUS VpPipeline::CreateFeatureManager()
500 {
501 VP_FUNC_CALL();
502
503 VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
504 VP_PUBLIC_CHK_NULL_RETURN(m_allocator);
505 VP_PUBLIC_CHK_NULL_RETURN(m_reporting);
506 VP_PUBLIC_CHK_NULL_RETURN(m_vpMhwInterface.m_vpPlatformInterface);
507
508 // Add CheckFeatures api later in FeatureManagerNext.
509 m_paramChecker = m_vpMhwInterface.m_vpPlatformInterface->CreateFeatureChecker(&m_vpMhwInterface);
510 VP_PUBLIC_CHK_NULL_RETURN(m_paramChecker);
511
512 VP_PUBLIC_CHK_STATUS_RETURN(CreateResourceManager());
513
514 m_vpInterface = MOS_New(VpInterface, &m_vpMhwInterface, *m_allocator, m_resourceManager);
515 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface);
516
517 m_featureManager = MOS_New(VpFeatureManagerNext, *m_vpInterface);
518 VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
519
520 VP_PUBLIC_CHK_STATUS_RETURN(((VpFeatureManagerNext *)m_featureManager)->Init(nullptr));
521
522 return MOS_STATUS_SUCCESS;
523 }
524
CreateVpKernelSets()525 MOS_STATUS VpPipeline::CreateVpKernelSets()
526 {
527 VP_FUNC_CALL();
528 if (nullptr == m_kernelSet)
529 {
530 m_kernelSet = MOS_New(VpKernelSet, &m_vpMhwInterface, m_allocator);
531 VP_PUBLIC_CHK_NULL_RETURN(m_kernelSet);
532 }
533 return MOS_STATUS_SUCCESS;
534 }
535
536 //!
537 //! \brief create reource manager
538 //! \return MOS_STATUS
539 //! MOS_STATUS_SUCCESS if success, else fail reason
540 //!
CreateResourceManager()541 MOS_STATUS VpPipeline::CreateResourceManager()
542 {
543 VP_FUNC_CALL();
544
545 if (nullptr == m_resourceManager)
546 {
547 m_resourceManager = MOS_New(VpResourceManager, *m_osInterface, *m_allocator, *m_reporting, *m_vpMhwInterface.m_vpPlatformInterface);
548 VP_PUBLIC_CHK_NULL_RETURN(m_resourceManager);
549 }
550 return MOS_STATUS_SUCCESS;
551 }
552
CheckFeatures(void * params,bool & bapgFuncSupported)553 MOS_STATUS VpPipeline::CheckFeatures(void *params, bool &bapgFuncSupported)
554 {
555 VP_FUNC_CALL();
556
557 VP_PUBLIC_CHK_NULL_RETURN(m_paramChecker);
558 return m_paramChecker->CheckFeatures(params, bapgFuncSupported);
559 }
560
CreateFeatureReport()561 MOS_STATUS VpPipeline::CreateFeatureReport()
562 {
563 VP_FUNC_CALL();
564
565 if (m_vpMhwInterface.m_reporting)
566 {
567 if (m_reporting && m_reporting->owner == this && m_vpMhwInterface.m_reporting != m_reporting)
568 {
569 MOS_FreeMemory(m_reporting);
570 }
571 m_reporting = m_vpMhwInterface.m_reporting;
572 }
573 else
574 {
575 if (m_reporting == nullptr)
576 {
577 VP_PUBLIC_CHK_STATUS_RETURN(CreateReport());
578 }
579 m_vpMhwInterface.m_reporting = m_reporting;
580 }
581
582 VP_PUBLIC_CHK_NULL_RETURN(m_reporting);
583 return MOS_STATUS_SUCCESS;
584 }
585
586 #if (_DEBUG || _RELEASE_INTERNAL)
AllocateTempTargetSurface(VPHAL_SURFACE * m_tempTargetSurface)587 VPHAL_SURFACE *VpPipeline::AllocateTempTargetSurface(VPHAL_SURFACE *m_tempTargetSurface)
588 {
589 VP_FUNC_CALL();
590
591 m_tempTargetSurface = (VPHAL_SURFACE *)MOS_AllocAndZeroMemory(sizeof(VPHAL_SURFACE));
592 if (!m_tempTargetSurface)
593 {
594 return nullptr;
595 }
596 return m_tempTargetSurface;
597 }
598 #endif
599
InitUserFeatureSetting()600 MOS_STATUS VpPipeline::InitUserFeatureSetting()
601 {
602 VP_FUNC_CALL();
603
604 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
605 MOS_USER_FEATURE_VALUE_DATA userFeatureData = {0};
606
607 #if (_DEBUG || _RELEASE_INTERNAL)
608 //SFC NV12/P010 Linear Output.
609 MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
610 MOS_UserFeature_ReadValue_ID(
611 nullptr,
612 __VPHAL_ENABLE_SFC_NV12_P010_LINEAR_OUTPUT_ID,
613 &userFeatureData,
614 m_vpMhwInterface.m_osInterface->pOsContext);
615 m_userFeatureSetting.enableSFCNv12P010LinearOutput = userFeatureData.bData;
616
617 //SFC RGBP Linear/Tile RGB24 Linear Output.
618 MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
619 MOS_UserFeature_ReadValue_ID(
620 nullptr,
621 __VPHAL_ENABLE_SFC_RGBP_RGB24_OUTPUT_ID,
622 &userFeatureData,
623 m_vpMhwInterface.m_osInterface->pOsContext);
624 m_userFeatureSetting.enableSFCRGBPRGB24Output = userFeatureData.u32Data;
625 #endif
626 return eStatus;
627 }
628
629 #if (_DEBUG || _RELEASE_INTERNAL)
SurfaceReplace(PVP_PIPELINE_PARAMS params)630 MOS_STATUS VpPipeline::SurfaceReplace(PVP_PIPELINE_PARAMS params)
631 {
632 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
633 bool allocated;
634
635 MEDIA_FEATURE_TABLE *skuTable = nullptr;
636 skuTable = m_vpMhwInterface.m_osInterface->pfnGetSkuTable(m_vpMhwInterface.m_osInterface);
637 VP_PUBLIC_CHK_NULL_RETURN(skuTable);
638
639 if (m_userFeatureSetting.enableSFCNv12P010LinearOutput &&
640 MOS_TILE_LINEAR != params->pTarget[0]->TileType &&
641 (Format_P010 == params->pTarget[0]->Format || Format_NV12 == params->pTarget[0]->Format) &&
642 MEDIA_IS_SKU(skuTable, FtrSFC420LinearOutputSupport))
643 {
644 if (!m_tempTargetSurface)
645 {
646 m_tempTargetSurface = AllocateTempTargetSurface(m_tempTargetSurface);
647 }
648 VP_PUBLIC_CHK_NULL_RETURN(m_tempTargetSurface);
649 eStatus = m_allocator->ReAllocateSurface(
650 m_tempTargetSurface,
651 "TempTargetSurface",
652 params->pTarget[0]->Format,
653 MOS_GFXRES_2D,
654 MOS_TILE_LINEAR,
655 params->pTarget[0]->dwWidth,
656 params->pTarget[0]->dwHeight,
657 false,
658 MOS_MMC_DISABLED,
659 &allocated);
660
661 m_tempTargetSurface->ColorSpace = params->pTarget[0]->ColorSpace;
662 m_tempTargetSurface->rcSrc = params->pTarget[0]->rcSrc;
663 m_tempTargetSurface->rcDst = params->pTarget[0]->rcDst;
664 m_tempTargetSurface->rcMaxSrc = params->pTarget[0]->rcMaxSrc;
665
666 if (eStatus == MOS_STATUS_SUCCESS)
667 {
668 params->pTarget[0] = m_tempTargetSurface; //params is the copy of pcRenderParams which will not cause the memleak,
669 }
670 }
671
672 typedef struct _RGBFormatConfig
673 {
674 MOS_FORMAT format;
675 MOS_TILE_TYPE tielType;
676 } RGBFormatConfig;
677
678 static const RGBFormatConfig rgbCfg[VP_RGB_OUTPUT_OVERRIDE_ID_MAX] = {
679 {Format_Invalid, MOS_TILE_INVALID},
680 {Format_RGBP, MOS_TILE_LINEAR},
681 {Format_RGBP, MOS_TILE_Y},
682 {Format_R8G8B8, MOS_TILE_LINEAR},
683 {Format_BGRP, MOS_TILE_LINEAR},
684 {Format_BGRP, MOS_TILE_Y}
685 };
686
687 if (m_userFeatureSetting.enableSFCRGBPRGB24Output == VP_RGB_OUTPUT_OVERRIDE_ID_INVALID ||
688 m_userFeatureSetting.enableSFCRGBPRGB24Output >= VP_RGB_OUTPUT_OVERRIDE_ID_MAX)
689 {
690 return MOS_STATUS_SUCCESS;
691 }
692
693 if (rgbCfg[m_userFeatureSetting.enableSFCRGBPRGB24Output].format != params->pTarget[0]->Format &&
694 MEDIA_IS_SKU(skuTable, FtrSFCRGBPRGB24OutputSupport))
695 {
696 if (!m_tempTargetSurface)
697 {
698 m_tempTargetSurface = AllocateTempTargetSurface(m_tempTargetSurface);
699 }
700 VP_PUBLIC_CHK_NULL_RETURN(m_tempTargetSurface);
701 eStatus = m_allocator->ReAllocateSurface(
702 m_tempTargetSurface,
703 "TempTargetSurface",
704 rgbCfg[m_userFeatureSetting.enableSFCRGBPRGB24Output].format,
705 MOS_GFXRES_2D,
706 rgbCfg[m_userFeatureSetting.enableSFCRGBPRGB24Output].tielType,
707 params->pTarget[0]->dwWidth,
708 params->pTarget[0]->dwHeight,
709 false,
710 MOS_MMC_DISABLED,
711 &allocated);
712
713 m_tempTargetSurface->ColorSpace = params->pTarget[0]->ColorSpace;
714 m_tempTargetSurface->rcSrc = params->pTarget[0]->rcSrc;
715 m_tempTargetSurface->rcDst = params->pTarget[0]->rcDst;
716 m_tempTargetSurface->rcMaxSrc = params->pTarget[0]->rcMaxSrc;
717
718 if (eStatus == MOS_STATUS_SUCCESS)
719 {
720 params->pTarget[0] = m_tempTargetSurface; //params is the copy of pcRenderParams which will not cause the memleak,
721 }
722 }
723
724 return eStatus;
725 }
726 #endif
727
PrepareVpPipelineParams(PVP_PIPELINE_PARAMS params)728 MOS_STATUS VpPipeline::PrepareVpPipelineParams(PVP_PIPELINE_PARAMS params)
729 {
730 VP_FUNC_CALL();
731 VP_PUBLIC_CHK_NULL_RETURN(params);
732
733 #if (_DEBUG || _RELEASE_INTERNAL)
734 SurfaceReplace(params); // replace output surface from Tile-Y to Linear
735 #endif
736
737 if ((m_vpMhwInterface.m_osInterface != nullptr))
738 {
739 // Set the component info
740 m_vpMhwInterface.m_osInterface->Component = params->Component;
741
742 // Init component(DDI entry point) info for perf measurement
743 m_vpMhwInterface.m_osInterface->pfnSetPerfTag(m_vpMhwInterface.m_osInterface, VPHAL_NONE);
744 }
745
746 PMOS_RESOURCE ppSource[VPHAL_MAX_SOURCES] = {nullptr};
747 PMOS_RESOURCE ppTarget[VPHAL_MAX_TARGETS] = {nullptr};
748
749 VP_PUBLIC_CHK_NULL_RETURN(params->pTarget[0]);
750 VP_PUBLIC_CHK_NULL_RETURN(m_allocator);
751 VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
752
753 // Can be removed, as all info can be gotten during AllocateVpSurface.
754 VPHAL_GET_SURFACE_INFO info = {};
755 for (uint32_t i = 0; i < params->uSrcCount; ++i)
756 {
757 MOS_ZeroMemory(&info, sizeof(VPHAL_GET_SURFACE_INFO));
758 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(
759 params->pSrc[i],
760 info));
761 }
762
763 MOS_ZeroMemory(&info, sizeof(VPHAL_GET_SURFACE_INFO));
764 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(
765 params->pTarget[0],
766 info));
767
768 if (params->uSrcCount>0)
769 {
770 if (params->pSrc[0]->pBwdRef)
771 {
772 MOS_ZeroMemory(&info, sizeof(VPHAL_GET_SURFACE_INFO));
773
774 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(
775 params->pSrc[0]->pBwdRef,
776 info));
777 }
778
779 if (!RECT1_CONTAINS_RECT2(params->pSrc[0]->rcMaxSrc, params->pSrc[0]->rcSrc))
780 {
781 params->pSrc[0]->rcMaxSrc = params->pSrc[0]->rcSrc;
782 }
783 }
784
785 bool bApgFuncSupported = false;
786 VP_PUBLIC_CHK_STATUS_RETURN(CheckFeatures(params, bApgFuncSupported));
787 if (!bApgFuncSupported)
788 {
789 VP_PUBLIC_NORMALMESSAGE("Features are not supported on APG now \n");
790
791 if (m_currentFrameAPGEnabled)
792 {
793 params->bAPGWorkloadEnable = true;
794 m_currentFrameAPGEnabled = false;
795 }
796 else
797 {
798 params->bAPGWorkloadEnable = false;
799 }
800
801 return MOS_STATUS_UNIMPLEMENTED;
802 }
803 else
804 {
805 m_currentFrameAPGEnabled = true;
806 params->bAPGWorkloadEnable = false;
807 VP_PUBLIC_NORMALMESSAGE("Features can be enabled on APG");
808 }
809
810 // Init Resource Max Rect for primary video
811
812 if ((nullptr != m_vpMhwInterface.m_osInterface) &&
813 (nullptr != m_vpMhwInterface.m_osInterface->osCpInterface))
814 {
815 for (uint32_t uiIndex = 0; uiIndex < params->uSrcCount; uiIndex++)
816 {
817 ppSource[uiIndex] = &(params->pSrc[uiIndex]->OsResource);
818 }
819 for (uint32_t uiIndex = 0; uiIndex < params->uDstCount; uiIndex++)
820 {
821 ppTarget[uiIndex] = &(params->pTarget[uiIndex]->OsResource);
822 }
823 m_vpMhwInterface.m_osInterface->osCpInterface->PrepareResources(
824 (void **)ppSource, params->uSrcCount, (void **)ppTarget, params->uDstCount);
825 }
826
827 PrepareVpPipelineScalabilityParams(params);
828
829 return MOS_STATUS_SUCCESS;
830 }
831
832 //!
833 //! \brief prepare execution params for vp scalability pipeline
834 //! \param [in] params
835 //! Pointer to VP scalability pipeline params
836 //! \return MOS_STATUS
837 //! MOS_STATUS_SUCCESS if success, else fail reason
838 //!
PrepareVpPipelineScalabilityParams(PVP_PIPELINE_PARAMS params)839 MOS_STATUS VpPipeline::PrepareVpPipelineScalabilityParams(PVP_PIPELINE_PARAMS params)
840 {
841 VP_FUNC_CALL();
842 VP_PUBLIC_CHK_NULL_RETURN(params);
843 if (params->pSrc[0] == nullptr)
844 {
845 VP_PUBLIC_NORMALMESSAGE("No input will not need scalability! ");
846 return MOS_STATUS_SUCCESS;
847 }
848
849 VP_PUBLIC_CHK_NULL_RETURN(params->pTarget[0]);
850
851 // Disable vesfc scalability when reg key "Enable Vebox Scalability" was set to zero
852 if (m_forceMultiplePipe == (MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_FALSE))
853 {
854 m_numVebox = 1;
855 }
856 else
857 {
858 if (((MOS_MIN(params->pSrc[0]->dwWidth, (uint32_t)params->pSrc[0]->rcSrc.right) > m_4k_content_width) &&
859 (MOS_MIN(params->pSrc[0]->dwHeight, (uint32_t)params->pSrc[0]->rcSrc.bottom) > m_4k_content_height)) ||
860 ((MOS_MIN(params->pTarget[0]->dwWidth, (uint32_t)params->pTarget[0]->rcSrc.right) > m_4k_content_width) &&
861 (MOS_MIN(params->pTarget[0]->dwHeight, (uint32_t)params->pTarget[0]->rcSrc.bottom) > m_4k_content_height)))
862 {
863 // Enable vesfc scalability only with 4k+ clips
864 }
865 else
866 {
867 // disable vesfc scalability with 4k- resolution clips if reg "Enable Vebox Scalability" was not set as true
868 if (m_forceMultiplePipe != (MOS_SCALABILITY_ENABLE_MODE_USER_FORCE | MOS_SCALABILITY_ENABLE_MODE_DEFAULT))
869 {
870 m_numVebox = 1;
871 }
872 }
873
874 // Disable DN when vesfc scalability was enabled for output mismatch issue
875 if (IsMultiple())
876 {
877 if (params->pSrc[0]->pDenoiseParams)
878 {
879 params->pSrc[0]->pDenoiseParams->bAutoDetect = false;
880 params->pSrc[0]->pDenoiseParams->bEnableChroma = false;
881 params->pSrc[0]->pDenoiseParams->bEnableLuma = false;
882 }
883 }
884 }
885
886 return MOS_STATUS_SUCCESS;
887 }
888
Prepare(void * params)889 MOS_STATUS VpPipeline::Prepare(void * params)
890 {
891 MOS_STATUS eStatus = MOS_STATUS_UNKNOWN;
892
893 VP_FUNC_CALL();
894
895 VP_PUBLIC_CHK_NULL_RETURN(params);
896 VP_PUBLIC_CHK_NULL_RETURN(m_userFeatureControl);
897
898 m_pvpParams = *(VP_PARAMS *)params;
899 // Get Output Pipe for Features. It should be configured in ExecuteVpPipeline.
900 m_vpOutputPipe = VPHAL_OUTPUT_PIPE_MODE_INVALID;
901 m_veboxFeatureInuse = false;
902
903 if (PIPELINE_PARAM_TYPE_LEGACY == m_pvpParams.type)
904 {
905 m_userFeatureControl->Update((PVP_PIPELINE_PARAMS)m_pvpParams.renderParams);
906 // VP Execution Params Prepare
907 eStatus = PrepareVpPipelineParams(m_pvpParams.renderParams);
908 if (eStatus != MOS_STATUS_SUCCESS)
909 {
910 if (eStatus == MOS_STATUS_UNIMPLEMENTED)
911 {
912 VP_PUBLIC_NORMALMESSAGE("Features are UNIMPLEMENTED on APG now \n");
913 return eStatus;
914 }
915 else
916 {
917 VP_PUBLIC_CHK_STATUS_RETURN(eStatus);
918 }
919 }
920 }
921
922 return MOS_STATUS_SUCCESS;
923 }
924
Execute()925 MOS_STATUS VpPipeline::Execute()
926 {
927 VP_FUNC_CALL();
928
929 VP_PUBLIC_CHK_STATUS_RETURN(ExecuteVpPipeline())
930 VP_PUBLIC_CHK_STATUS_RETURN(UserFeatureReport());
931
932 if (m_packetSharedContext && m_packetSharedContext->bFirstFrame)
933 {
934 m_packetSharedContext->bFirstFrame = false;
935 }
936
937 return MOS_STATUS_SUCCESS;
938 }
939