Debian Codegraph @

media_softlet/agnostic/common/vp/hal/feature_manager/policy.cpp

raw
1 /*
2 * Copyright (c) 2019-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 //!
24 //! \file policy.cpp
25 //! \brief Defines the common interface for vp features manager
26 //! \details The vp manager is further sub-divided by vp type
27 //! this file is for the base interface which is shared by all components.
28 //!
29 #include "policy.h"
30 #include "vp_obj_factories.h"
31 #include "vp_feature_manager.h"
32 #include "vp_platform_interface.h"
33 #include "sw_filter_handle.h"
34 #include "vp_cgc_filter.h"
35 #include "vp_user_feature_control.h"
36 #include "vp_ai_filter.h"
37
38
39 namespace vp
40 {
41 /****************************************************************************************************/
42 /* Policy */
43 /****************************************************************************************************/
44
45 Policy::Policy(VpInterface &vpInterface) : m_vpInterface(vpInterface)
46 {
47 }
48
49 Policy::~Policy()
50 {
51 UnregisterFeatures();
52 }
53
54 MOS_STATUS Policy::UpdateVpHwCapsBasedOnSku(VP_HW_CAPS &vpHwCaps)
55 {
56 VP_FUNC_CALL();
57
58 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
59 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
60
61 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
62 bool veboxTypeH = userFeatureControl->IsVeboxTypeHMode();
63 if (veboxTypeH)
64 {
65 VP_PUBLIC_WARNINGMESSAGE("Disable vebox features for veboxTypeH.");
66 for (int i = 0; i < Format_Count; i++)
67 {
68 //update caps per sku
69 m_hwCaps.m_veboxHwEntry[i].capturePipeSupported = false;
70 m_hwCaps.m_veboxHwEntry[i].denoiseSupported = false;
71 m_hwCaps.m_veboxHwEntry[i].deinterlaceSupported = false;
72 m_hwCaps.m_veboxHwEntry[i].laceSupported = false;
73 m_hwCaps.m_veboxHwEntry[i].frontCscSupported = false;
74 m_hwCaps.m_veboxHwEntry[i].backEndCscSupported = false;
75 m_hwCaps.m_veboxHwEntry[i].iecp = false;
76 m_hwCaps.m_veboxHwEntry[i].tccSupported = false;
77 m_hwCaps.m_veboxHwEntry[i].aceSupported = false;
78 m_hwCaps.m_veboxHwEntry[i].steSupported = false;
79 m_hwCaps.m_veboxHwEntry[i].cgcSupported = false;
80 }
81 }
82 return MOS_STATUS_SUCCESS;
83 }
84
85 MOS_STATUS Policy::Initialize()
86 {
87 VP_FUNC_CALL();
88
89 VpPlatformInterface *vpPlatformInterface = (VpPlatformInterface *)m_vpInterface.GetHwInterface()->m_vpPlatformInterface;
90 VP_PUBLIC_CHK_NULL_RETURN(vpPlatformInterface);
91 VP_PUBLIC_CHK_STATUS_RETURN(vpPlatformInterface->InitVpHwCaps(m_hwCaps));
92 //update caps
93 UpdateVpHwCapsBasedOnSku(m_hwCaps);
94 VP_PUBLIC_CHK_STATUS_RETURN(RegisterFeatures());
95 m_initialized = true;
96 return MOS_STATUS_SUCCESS;
97 }
98
99 bool Policy::IsVeboxSfcFormatSupported(MOS_FORMAT formatInput, MOS_FORMAT formatOutput)
100 {
101 VP_FUNC_CALL();
102
103 if (!m_initialized)
104 {
105 return false;
106 }
107 if (m_hwCaps.m_sfcHwEntry[formatInput].inputSupported &&
108 m_hwCaps.m_sfcHwEntry[formatOutput].outputSupported)
109 {
110 return true;
111 }
112 else
113 {
114 return false;
115 }
116 }
117
118 bool Policy::IsAlphaEnabled(FeatureParamScaling* scalingParams)
119 {
120 VP_FUNC_CALL();
121
122 if (scalingParams == nullptr)
123 {
124 return false;
125 }
126
127 return scalingParams->pCompAlpha != nullptr;
128 }
129
130 bool Policy::IsColorfillEnabled(FeatureParamScaling* scalingParams)
131 {
132 VP_FUNC_CALL();
133
134 if (scalingParams == nullptr)
135 {
136 return false;
137 }
138
139 bool isColorFill = false;
140 isColorFill = (scalingParams->pColorFillParams &&
141 (!scalingParams->pColorFillParams->bDisableColorfillinSFC) &&
142 (scalingParams->pColorFillParams->bOnePixelBiasinSFC ?
143 (!RECT1_CONTAINS_RECT2_ONEPIXELBIAS(scalingParams->input.rcDst, scalingParams->output.rcDst)):
144 (!RECT1_CONTAINS_RECT2(scalingParams->input.rcDst, scalingParams->output.rcDst))))
145 ? true
146 : false;
147
148 return isColorFill;
149 }
150
151 MOS_STATUS Policy::RegisterFeatures()
152 {
153 VP_FUNC_CALL();
154
155 UnregisterFeatures();
156
157 // Vebox/Sfc features.
158 PolicyFeatureHandler *p = MOS_New(PolicySfcCscHandler, m_hwCaps);
159 VP_PUBLIC_CHK_NULL_RETURN(p);
160 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeCscOnSfc, p);
161
162 p = MOS_New(PolicySfcRotMirHandler, m_hwCaps);
163 VP_PUBLIC_CHK_NULL_RETURN(p);
164 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeRotMirOnSfc, p);
165
166 p = MOS_New(PolicySfcScalingHandler, m_hwCaps);
167 VP_PUBLIC_CHK_NULL_RETURN(p);
168 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeScalingOnSfc, p);
169
170 p = MOS_New(PolicyVeboxDnHandler, m_hwCaps);
171 VP_PUBLIC_CHK_NULL_RETURN(p);
172 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeDnOnVebox, p);
173
174 p = MOS_New(PolicyRenderDnHVSCalHandler, m_hwCaps);
175 VP_PUBLIC_CHK_NULL_RETURN(p);
176 m_RenderFeatureHandlers.emplace(FeatureTypeDnHVSCalOnRender, p);
177
178 p = MOS_New(PolicyVeboxCscHandler, m_hwCaps);
179 VP_PUBLIC_CHK_NULL_RETURN(p);
180 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeCscOnVebox, p);
181
182 p = MOS_New(PolicyVeboxSteHandler, m_hwCaps);
183 VP_PUBLIC_CHK_NULL_RETURN(p);
184 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeSteOnVebox, p);
185
186 p = MOS_New(PolicyVeboxTccHandler, m_hwCaps);
187 VP_PUBLIC_CHK_NULL_RETURN(p);
188 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeTccOnVebox, p);
189
190 p = MOS_New(PolicyVeboxProcampHandler, m_hwCaps);
191 VP_PUBLIC_CHK_NULL_RETURN(p);
192 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeProcampOnVebox, p);
193
194 p = MOS_New(PolicyVeboxHdrHandler, m_hwCaps);
195 VP_PUBLIC_CHK_NULL_RETURN(p);
196 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeHdrOnVebox, p);
197
198 p = MOS_New(PolicyRenderHdr3DLutCalHandler, m_hwCaps);
199 VP_PUBLIC_CHK_NULL_RETURN(p);
200 m_RenderFeatureHandlers.emplace(FeatureTypeHdr3DLutCalOnRender, p);
201
202 {
203 #ifdef _MEDIA_RESERVED
204 VpPlatformInterface *vpPlatformInterface = (VpPlatformInterface *)m_vpInterface.GetHwInterface()->m_vpPlatformInterface;
205 if (vpPlatformInterface && vpPlatformInterface->GetVpFeatureSupportBits().vpFeatureSupportBitsHdrLite)
206 {
207 p = MOS_New(PolicyRenderHdrLiteHandler, m_hwCaps);
208 }
209 else
210 #endif
211 {
212 p = MOS_New(PolicyRenderHdrHandler, m_hwCaps);
213 }
214 VP_PUBLIC_CHK_NULL_RETURN(p);
215 m_RenderFeatureHandlers.emplace(FeatureTypeHdrOnRender, p);
216 }
217
218 p = MOS_New(PolicyDiHandler, m_hwCaps);
219 VP_PUBLIC_CHK_NULL_RETURN(p);
220 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeDiOnVebox, p);
221
222 p = MOS_New(PolicySfcColorFillHandler, m_hwCaps);
223 VP_PUBLIC_CHK_NULL_RETURN(p);
224 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeColorFillOnSfc, p);
225
226 p = MOS_New(PolicySfcAlphaHandler, m_hwCaps);
227 VP_PUBLIC_CHK_NULL_RETURN(p);
228 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeAlphaOnSfc, p);
229
230 VP_PUBLIC_CHK_STATUS_RETURN(RegisterFcFeatures());
231
232 p = MOS_New(PolicyVeboxCgcHandler, m_hwCaps);
233 VP_PUBLIC_CHK_NULL_RETURN(p);
234 m_VeboxSfcFeatureHandlers.emplace(FeatureTypeCgcOnVebox, p);
235
236 // FeatureTypeAiOnRender and FeatureTypeAiOnNpu will not be added in sw filter pipe
237 // They will not be in registeredFeatures
238 // To get Ai SwFilter, need to use pipe.GetAiSwFilter
239 p = MOS_New(PolicyAiHandler, m_hwCaps, m_vpInterface.GetGraphManager());
240 VP_PUBLIC_CHK_NULL_RETURN(p);
241 m_RenderFeatureHandlers.insert(std::make_pair(FeatureTypeAiOnRender, p));
242
243 p = MOS_New(PolicyAiHandler, m_hwCaps, m_vpInterface.GetGraphManager());
244 VP_PUBLIC_CHK_NULL_RETURN(p);
245 m_NpuFeatureHandlers.insert(std::make_pair(FeatureTypeAiOnNpu, p));
246
247 // Next step to add a table to trace all SW features based on platforms
248 m_featurePool.push_back(FeatureTypeCsc);
249 m_featurePool.push_back(FeatureTypeScaling);
250 m_featurePool.push_back(FeatureTypeRotMir);
251 m_featurePool.push_back(FeatureTypeDn);
252 m_featurePool.push_back(FeatureTypeSte);
253 m_featurePool.push_back(FeatureTypeTcc);
254 m_featurePool.push_back(FeatureTypeProcamp);
255 m_featurePool.push_back(FeatureTypeHdr);
256 m_featurePool.push_back(FeatureTypeDi);
257 m_featurePool.push_back(FeatureTypeFc);
258 m_featurePool.push_back(FeatureTypeLumakey);
259 m_featurePool.push_back(FeatureTypeBlending);
260 m_featurePool.push_back(FeatureTypeColorFill);
261 m_featurePool.push_back(FeatureTypeAlpha);
262 m_featurePool.push_back(FeatureTypeCgc);
263 m_featurePool.push_back(FeatureTypeAi);
264
265 return MOS_STATUS_SUCCESS;
266 }
267
268 void Policy::UnregisterFeatures()
269 {
270 while (!m_VeboxSfcFeatureHandlers.empty())
271 {
272 std::map<FeatureType, PolicyFeatureHandler*>::iterator it = m_VeboxSfcFeatureHandlers.begin();
273 MOS_Delete(it->second);
274 m_VeboxSfcFeatureHandlers.erase(it);
275 }
276
277 while (!m_RenderFeatureHandlers.empty())
278 {
279 std::map<FeatureType, PolicyFeatureHandler*>::iterator it = m_RenderFeatureHandlers.begin();
280 MOS_Delete(it->second);
281 m_RenderFeatureHandlers.erase(it);
282 }
283
284 while (!m_NpuFeatureHandlers.empty())
285 {
286 std::map<FeatureType, PolicyFeatureHandler *>::iterator it = m_NpuFeatureHandlers.begin();
287 MOS_Delete(it->second);
288 m_NpuFeatureHandlers.erase(it);
289 }
290
291 m_featurePool.clear();
292 }
293
294 MOS_STATUS Policy::RegisterFcFeatures()
295 {
296 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface())
297 VpUserFeatureControl *vpUserFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
298 VP_PUBLIC_CHK_NULL_RETURN(vpUserFeatureControl);
299 bool enableOclFC = vpUserFeatureControl->EnableOclFC();
300
301 //Legacy Fc and OCL FC switching will be done in the wrapper handler class
302 //It will use Legacy FC if vpUserFeatureControl->EnableOclFC() is not true, which means specific platform not support OCL FC
303 //It will fall back to legacy FC when vp execute caps show bLegacyFC is true, which means some formats OCL FC not supported yet
304 //In the future, after all caps formats added for OCL FC, the wrapper will be removed and only register specific OCL/Legacy FC handler
305 PolicyFeatureHandler *p = MOS_New(PolicyFcWrapHandler, m_hwCaps, enableOclFC);
306 VP_PUBLIC_CHK_NULL_RETURN(p);
307 m_RenderFeatureHandlers.emplace(FeatureTypeFcOnRender, p);
308
309 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
310 VP_PUBLIC_CHK_NULL_RETURN(p);
311 m_RenderFeatureHandlers.emplace(FeatureTypeLumakeyOnRender, p);
312
313 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
314 VP_PUBLIC_CHK_NULL_RETURN(p);
315 m_RenderFeatureHandlers.emplace(FeatureTypeBlendingOnRender, p);
316
317 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
318 VP_PUBLIC_CHK_NULL_RETURN(p);
319 m_RenderFeatureHandlers.emplace(FeatureTypeColorFillOnRender, p);
320
321 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
322 VP_PUBLIC_CHK_NULL_RETURN(p);
323 m_RenderFeatureHandlers.emplace(FeatureTypeAlphaOnRender, p);
324
325 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
326 VP_PUBLIC_CHK_NULL_RETURN(p);
327 m_RenderFeatureHandlers.emplace(FeatureTypeCscOnRender, p);
328
329 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
330 VP_PUBLIC_CHK_NULL_RETURN(p);
331 m_RenderFeatureHandlers.emplace(FeatureTypeScalingOnRender, p);
332
333 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
334 VP_PUBLIC_CHK_NULL_RETURN(p);
335 m_RenderFeatureHandlers.emplace(FeatureTypeRotMirOnRender, p);
336
337 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
338 VP_PUBLIC_CHK_NULL_RETURN(p);
339 m_RenderFeatureHandlers.emplace(FeatureTypeDiOnRender, p);
340
341 p = MOS_New(PolicyFcFeatureWrapHandler, m_hwCaps, enableOclFC);
342 VP_PUBLIC_CHK_NULL_RETURN(p);
343 m_RenderFeatureHandlers.emplace(FeatureTypeProcampOnRender, p);
344
345 #if (_DEBUG || _RELEASE_INTERNAL)
346 VpFeatureReport *vpFeatureReport = m_vpInterface.GetHwInterface()->m_reporting;
347 if (vpFeatureReport)
348 {
349 vpFeatureReport->GetFeatures().isOclFC = enableOclFC;
350 }
351 #endif
352
353 return MOS_STATUS_SUCCESS;
354 }
355
356 /* Enable SwFilterPipe */
357
358 MOS_STATUS Policy::CreateHwFilter(SwFilterPipe &subSwFilterPipe, HwFilter *&pFilter)
359 {
360 VP_FUNC_CALL();
361
362 if (subSwFilterPipe.IsEmpty())
363 {
364 pFilter = nullptr;
365 return MOS_STATUS_SUCCESS;
366 }
367
368 HW_FILTER_PARAMS param = {};
369
370 MT_LOG(MT_VP_FEATURE_GRAPH_SETUPEXECUTESWFILTER_START, MT_NORMAL);
371 VP_PUBLIC_NORMALMESSAGE("Feature Graph: Setup ExecutePipe Start");
372 MOS_STATUS status = GetHwFilterParam(subSwFilterPipe, param);
373
374 if (MOS_FAILED(status))
375 {
376 VP_PUBLIC_ASSERTMESSAGE("Create HW Filter Failed, Return Error");
377 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, status, MT_CODE_LINE, __LINE__);
378 return status;
379 }
380
381 pFilter = m_vpInterface.GetHwFilterFactory().Create(param);
382
383 ReleaseHwFilterParam(param);
384
385 if (!pFilter)
386 {
387 VP_PUBLIC_ASSERTMESSAGE("Create HW Filter Failed, Return Error");
388 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, MOS_STATUS_UNIMPLEMENTED, MT_CODE_LINE, __LINE__);
389 if (m_vpInterface.GetHwInterface()->m_userFeatureControl->Is3DLutKernelOnly())
390 {
391 VP_PUBLIC_NORMALMESSAGE("Bypass This Workload due to 3dlut kenrel test, Return True");
392 return MOS_STATUS_SUCCESS;
393 }
394 return MOS_STATUS_UNIMPLEMENTED;
395 }
396 MT_LOG(MT_VP_FEATURE_GRAPH_SETUPEXECUTESWFILTER_END, MT_NORMAL);
397 VP_PUBLIC_NORMALMESSAGE("Feature Graph: Setup ExecutePipe End");
398 return MOS_STATUS_SUCCESS;
399 }
400
401 MOS_STATUS Policy::GetHwFilterParam(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params)
402 {
403 VP_FUNC_CALL();
404
405 MOS_STATUS status = MOS_STATUS_SUCCESS;
406
407 params.Type = EngineTypeInvalid;
408
409 // Create and clear executedFilters.
410 if (params.executedFilters)
411 {
412 params.executedFilters->Clean();
413 }
414 else
415 {
416 status = m_vpInterface.GetSwFilterPipeFactory().Create(params.executedFilters);
417
418 if (status != MOS_STATUS_SUCCESS)
419 {
420 m_vpInterface.GetSwFilterPipeFactory().Destory(params.executedFilters);
421 VP_PUBLIC_ASSERTMESSAGE("Create Executed Filter Failed, Return Error");
422 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, status, MT_CODE_LINE, __LINE__);
423 return status;
424 }
425 }
426
427 params.executedFilters->SetExePipeFlag(true);
428
429 status = GetExecuteCaps(subSwFilterPipe, params);
430
431 if (status != MOS_STATUS_SUCCESS)
432 {
433 m_vpInterface.GetSwFilterPipeFactory().Destory(params.executedFilters);
434 VP_PUBLIC_ASSERTMESSAGE("Create Executed Filter Failed, Return Error");
435 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, status, MT_CODE_LINE, __LINE__);
436 return status;
437 }
438
439 return MOS_STATUS_SUCCESS;
440 }
441
442 MOS_STATUS Policy::GetExecuteCaps(SwFilterPipe& subSwFilterPipe, HW_FILTER_PARAMS& params)
443 {
444 VP_FUNC_CALL();
445
446 VP_EngineEntry engineCapsCombinedAllPipes = {};
447 SwFilterSubPipe* pipe = nullptr;
448 uint32_t index = 0;
449 uint32_t inputSurfCount = subSwFilterPipe.GetSurfaceCount(true);
450 uint32_t outputSurfCount = subSwFilterPipe.GetSurfaceCount(false);
451
452 VP_PUBLIC_NORMALMESSAGE("Only Support primary layer for advanced processing");
453
454 bool isAiPipe = false;
455 VP_PUBLIC_CHK_STATUS_RETURN(subSwFilterPipe.QuerySwAiFilter(isAiPipe));
456
457 engineCapsCombinedAllPipes.value = 0;
458
459 for (index = 0; index < inputSurfCount; ++index)
460 {
461 VP_PUBLIC_CHK_STATUS_RETURN(BuildExecutionEngines(subSwFilterPipe, true, index, isAiPipe, engineCapsCombinedAllPipes));
462 }
463
464 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExecuteEngineCapsForCrossPipeFeatures(subSwFilterPipe, engineCapsCombinedAllPipes));
465
466 for (index = 0; index < outputSurfCount; ++index)
467 {
468 VP_PUBLIC_CHK_STATUS_RETURN(BuildExecutionEngines(subSwFilterPipe, false, index, isAiPipe, engineCapsCombinedAllPipes));
469 }
470
471 VP_PUBLIC_CHK_STATUS_RETURN(BuildFilters(subSwFilterPipe, params));
472
473 return MOS_STATUS_SUCCESS;
474 }
475
476 MOS_STATUS Policy::GetExecutionCapsForSingleFeature(FeatureType featureType, SwFilterSubPipe& swFilterPipe, VP_EngineEntry& engineCapsCombined)
477 {
478 VP_FUNC_CALL();
479
480 SwFilter* feature = swFilterPipe.GetSwFilter(featureType);
481 SwFilter* di = nullptr;
482 SwFilter* hdr = nullptr;
483 SwFilter* cgc = nullptr;
484 SwFilter* scaling = nullptr;
485 VPHAL_CSPACE cscInputColorSpaceCheck = CSpace_None;
486
487 auto getDeinterlaceExecutionCaps = [&](SwFilter *_di)
488 {
489 bool forceDIToRender = false;
490 VP_PUBLIC_CHK_NULL_RETURN(_di);
491 scaling = scaling ? scaling : dynamic_cast<SwFilterScaling*>(swFilterPipe.GetSwFilter(FeatureType(FeatureTypeScaling)));
492 if (scaling)
493 {
494 // No need check HDR for DI case.
495 VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(scaling, false, true));
496 forceDIToRender = scaling->GetFilterEngineCaps().RenderNeeded && scaling->GetFilterEngineCaps().sfcNotSupported;
497 }
498 return GetDeinterlaceExecutionCaps(_di, forceDIToRender);
499 };
500
501 if (!feature)
502 {
503 VP_PUBLIC_VERBOSEMESSAGE("Feature %d is not enabled in current pipe", featureType);
504 return MOS_STATUS_SUCCESS;
505 }
506 else
507 {
508 VP_PUBLIC_NORMALMESSAGE("Feature %d is enabled in current pipe", featureType);
509 }
510
511 // Always clean engine caps before Query. For next step, need to add new caps variable in swFilter
512 // for forcing engine case.
513 // feature->GetFilterEngineCaps().value = 0;
514
515 switch (featureType)
516 {
517 case FeatureTypeCsc:
518 hdr = swFilterPipe.GetSwFilter(FeatureTypeHdr);
519 di = swFilterPipe.GetSwFilter(FeatureTypeDi);
520 cgc = dynamic_cast<SwFilterCgc *>(swFilterPipe.GetSwFilter(FeatureType(FeatureTypeCgc)));
521 cscInputColorSpaceCheck = (&((SwFilterCsc *)feature)->GetSwFilterParams())->input.colorSpace;
522 if (hdr)
523 {
524 VP_PUBLIC_CHK_STATUS_RETURN(GetCSCExecutionCapsHdr(hdr, feature));
525 }
526 else if (IS_COLOR_SPACE_BT2020_YUV(cscInputColorSpaceCheck) && cgc)
527 {
528 VP_PUBLIC_CHK_STATUS_RETURN(GetCSCExecutionCapsBT2020ToRGB(cgc, feature));
529 }
530 else if (di)
531 {
532 VP_PUBLIC_CHK_STATUS_RETURN(getDeinterlaceExecutionCaps(di));
533
534 VP_EngineEntry *diEngine = &di->GetFilterEngineCaps();
535 if (diEngine->bEnabled && diEngine->VeboxNeeded)
536 {
537 VP_PUBLIC_CHK_STATUS_RETURN(GetCSCExecutionCapsDi(feature));
538 }
539 else
540 {
541 VP_PUBLIC_CHK_STATUS_RETURN(GetCSCExecutionCaps(feature, false));
542 }
543 }
544 else
545 {
546 VP_PUBLIC_CHK_STATUS_RETURN(GetCSCExecutionCaps(feature, false));
547 }
548 break;
549 case FeatureTypeScaling:
550 hdr = dynamic_cast<SwFilterHdr *>(swFilterPipe.GetSwFilter(FeatureType(FeatureTypeHdr)));
551 if (hdr)
552 {
553 VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCapsHdr(feature));
554 }
555 else
556 {
557 di = swFilterPipe.GetSwFilter(FeatureTypeDi);
558 VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, di != nullptr));
559 }
560 break;
561 case FeatureTypeRotMir:
562 VP_PUBLIC_CHK_STATUS_RETURN(GetRotationExecutionCaps(feature));
563 break;
564 case FeatureTypeDn:
565 VP_PUBLIC_CHK_STATUS_RETURN(GetDenoiseExecutionCaps(feature));
566 break;
567 case FeatureTypeSte:
568 VP_PUBLIC_CHK_STATUS_RETURN(GetSteExecutionCaps(feature));
569 break;
570 case FeatureTypeTcc:
571 VP_PUBLIC_CHK_STATUS_RETURN(GetTccExecutionCaps(feature));
572 break;
573 case FeatureTypeProcamp:
574 VP_PUBLIC_CHK_STATUS_RETURN(GetProcampExecutionCaps(feature));
575 break;
576 case FeatureTypeHdr:
577 VP_PUBLIC_CHK_STATUS_RETURN(GetHdrExecutionCaps(feature));
578 break;
579 case FeatureTypeDi:
580 VP_PUBLIC_CHK_STATUS_RETURN(getDeinterlaceExecutionCaps(feature));
581 break;
582 case FeatureTypeLumakey:
583 VP_PUBLIC_CHK_STATUS_RETURN(GetLumakeyExecutionCaps(feature));
584 break;
585 case FeatureTypeBlending:
586 VP_PUBLIC_CHK_STATUS_RETURN(GetBlendingExecutionCaps(feature));
587 break;
588 case FeatureTypeColorFill:
589 VP_PUBLIC_CHK_STATUS_RETURN(GetColorFillExecutionCaps(feature));
590 break;
591 case FeatureTypeAlpha:
592 VP_PUBLIC_CHK_STATUS_RETURN(GetAlphaExecutionCaps(feature));
593 break;
594 case FeatureTypeCgc:
595 VP_PUBLIC_CHK_STATUS_RETURN(GetCgcExecutionCaps(feature));
596 break;
597 default:
598 VP_PUBLIC_CHK_STATUS_RETURN(GetExecutionCaps(feature));
599 VP_PUBLIC_ASSERTMESSAGE("Feature is not supported by driver, bypass it");
600 break;
601 }
602
603 VP_EngineEntry& engineCaps = feature->GetFilterEngineCaps();
604
605 if (engineCaps.value == 0)
606 {
607 // Return success after all feature enabled and fully switched to APO path.
608 VP_PUBLIC_NORMALMESSAGE("No engine being assigned for feature %d. Will bypass it.", featureType);
609 }
610
611 engineCapsCombined.value |= engineCaps.value;
612
613 MT_LOG7(MT_VP_HAL_POLICY_GET_EXTCAPS4FTR, MT_NORMAL, MT_VP_HAL_FEATUERTYPE, featureType, MT_VP_HAL_ENGINECAPS, int64_t(engineCaps.value),
614 MT_VP_HAL_ENGINECAPS_EN, int64_t(engineCaps.bEnabled), MT_VP_HAL_ENGINECAPS_VE_NEEDED, int64_t(engineCaps.VeboxNeeded),
615 MT_VP_HAL_ENGINECAPS_SFC_NEEDED, int64_t(engineCaps.SfcNeeded), MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, int64_t(engineCaps.RenderNeeded),
616 MT_VP_HAL_ENGINECAPS_FC_SUPPORT, int64_t(engineCaps.fcSupported));
617
618 return MOS_STATUS_SUCCESS;
619 }
620
621 MOS_STATUS Policy::UpdateExecuteEngineCapsForHDR(SwFilterPipe &swFilterPipe, VP_EngineEntry &engineCapsCombinedAllPipes)
622 {
623 VP_FUNC_CALL();
624
625 uint32_t pipeCount = swFilterPipe.GetSurfaceCount(true);
626 std::vector<SwFilterHdr *> hdrFilters;
627 bool isHdrKernelNeeded = false;
628 auto outputSurf = swFilterPipe.GetSurface(false, 0);
629 VP_PUBLIC_CHK_NULL_RETURN(outputSurf);
630
631 if (1 == pipeCount)
632 {
633 return MOS_STATUS_SUCCESS;
634 }
635
636 bool isNonBt2020Exists = false;
637 for (uint32_t i = 0; i < pipeCount; ++i)
638 {
639 auto inputSurf = swFilterPipe.GetSurface(true, i);
640 VP_PUBLIC_CHK_NULL_RETURN(inputSurf);
641 isNonBt2020Exists |= !IS_COLOR_SPACE_BT2020(inputSurf->ColorSpace);
642 auto filter = (SwFilterHdr *)swFilterPipe.GetSwFilter(true, i, FeatureTypeHdr);
643 if (nullptr == filter)
644 {
645 continue;
646 }
647
648 if (!filter->GetFilterEngineCaps().bEnabled)
649 {
650 continue;
651 }
652
653 hdrFilters.push_back(filter);
654 }
655
656 // Multi-layer S2H or H2H case.
657 if (pipeCount > 1 && IS_COLOR_SPACE_BT2020(outputSurf->ColorSpace))
658 {
659 if (isNonBt2020Exists || hdrFilters.size() > 0)
660 {
661 VP_PUBLIC_NORMALMESSAGE("multi-layer non-BT2020 to BT2020 csc or multi-layer H2H case, use HDR kernel.");
662 isHdrKernelNeeded = true;
663 }
664 }
665 else
666 {
667 // 1 H2S layer, use vebox 3DLut + fc or HDR kernel based on hdrKernelNeeded flag on hdr filter.
668 if (hdrFilters.size() <= 1)
669 {
670 return MOS_STATUS_SUCCESS;
671 }
672 VP_PUBLIC_NORMALMESSAGE("multi-layer H2S, use HDR kernel.");
673 isHdrKernelNeeded = true;
674 }
675
676 if (isHdrKernelNeeded)
677 {
678 for (auto filter : hdrFilters)
679 {
680 auto &engineCaps = filter->GetFilterEngineCaps();
681 if (!filter->GetFilterEngineCaps().hdrKernelNeeded)
682 {
683 engineCaps.VeboxNeeded = 0;
684 engineCaps.RenderNeeded = 1;
685 engineCaps.hdrKernelNeeded = 1;
686 engineCaps.hdrKernelSupported = 1;
687 VP_PUBLIC_NORMALMESSAGE("Update HDR filter to use HDR kernel.");
688 PrintFeatureExecutionCaps(__FUNCTION__, engineCaps);
689 }
690 }
691 engineCapsCombinedAllPipes.RenderNeeded = 1;
692 engineCapsCombinedAllPipes.hdrKernelNeeded = 1;
693 engineCapsCombinedAllPipes.hdrKernelSupported = 1;
694
695 for (uint32_t i = 0; i < pipeCount; ++i)
696 {
697 SwFilterSubPipe *pipe = nullptr;
698 pipe = swFilterPipe.GetSwFilterSubPipe(true, i);
699 // All layers will be processed by hdr kernel if hdr kernel being used. The features not supported by hdr kernel in all pipes will be filtered out.
700 VP_PUBLIC_CHK_STATUS_RETURN(FilterFeatureCombinationForHDRKernel(pipe));
701
702 }
703 }
704
705 return MOS_STATUS_SUCCESS;
706 }
707
708 MOS_STATUS Policy::UpdateExecuteEngineCapsForCrossPipeFeatures(SwFilterPipe &swFilterPipe, VP_EngineEntry &engineCapsCombinedAllPipes)
709 {
710 VP_FUNC_CALL();
711
712 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExecuteEngineCapsForHDR(swFilterPipe, engineCapsCombinedAllPipes));
713 return MOS_STATUS_SUCCESS;
714 }
715
716 MOS_STATUS Policy::BuildExecutionEngines(SwFilterPipe &swFilterPipe, bool isInputPipe, uint32_t index, bool isAiPipe, VP_EngineEntry &engineCapsCombinedAllPipes)
717 {
718 VP_FUNC_CALL();
719
720 SwFilterSubPipe *pipe = nullptr;
721 SwFilter * feature = nullptr;
722 pipe = swFilterPipe.GetSwFilterSubPipe(isInputPipe, index);
723 VP_EngineEntry engineCapsCombined = {};
724
725 engineCapsCombined.value = 0;
726
727 VP_PUBLIC_NORMALMESSAGE("isInputPipe %d, index %d", (isInputPipe ? 1 : 0), index);
728
729 if (pipe)
730 {
731 if (isAiPipe)
732 {
733 SwFilterAiBase *swAiFilter = nullptr;
734 VP_PUBLIC_CHK_STATUS_RETURN(pipe->GetAiSwFilter(swAiFilter));
735 // If the sw filter pipe contains SwFilterAiBase, then it is an AI sw filter sub pipe
736 // For AI sw filter sub pipe, only AI feature will be executed, other features will be bypass
737 // If it is not an AI sw filter sub pipe, then go into the normal GetExecutionCapsForSingleFeature
738 if (swAiFilter && isInputPipe)
739 {
740 VP_PUBLIC_CHK_STATUS_RETURN(GetExecutionCapsForAiSwFilterSubPipe(swAiFilter, engineCapsCombined));
741 }
742 }
743 else
744 {
745 for (auto filterID : m_featurePool)
746 {
747 VP_PUBLIC_CHK_STATUS_RETURN(GetExecutionCapsForSingleFeature(filterID, *pipe, engineCapsCombined));
748 }
749 }
750 engineCapsCombinedAllPipes.value |= engineCapsCombined.value;
751 VP_PUBLIC_CHK_STATUS_RETURN(FilterFeatureCombination(swFilterPipe, isInputPipe, index, engineCapsCombined, engineCapsCombinedAllPipes));
752 }
753 return MOS_STATUS_SUCCESS;
754 }
755
756 MOS_STATUS Policy::Update3DLutoutputColorAndFormat(FeatureParamCsc *cscParams, FeatureParamHdr *hdrParams, MOS_FORMAT Format, VPHAL_CSPACE CSpace)
757 {
758 // For vebox + render, e.g. BT2020 P010->SRGB, if not correct the format here, since forceCscToRender being enabled, outputFormat in csc filter of
759 // first pass will be set to P010 in PolicyVeboxCscHandler::UpdateFeaturePipe(). It will cause the wrong format being used for intermediate surface
760 // in VpResourceManager::GetIntermediaOutputSurfaceColorAndFormat().
761 // For vebox + sfc, GetSfcInputFormat in VpCscFilter::CalculateSfcEngineParams() will ensure the right format being used, although the format
762 // in csc will be overwritten in params.executedFilters->Update() in Policy::BuildExecuteFilter.
763 hdrParams->formatOutput = Format;
764 hdrParams->dstColorSpace = CSpace;
765 cscParams->formatInput = Format;
766 cscParams->input.colorSpace = CSpace;
767
768 return MOS_STATUS_SUCCESS;
769 }
770
771 MOS_STATUS Policy::GetCSCExecutionCapsHdr(SwFilter *HDR, SwFilter *CSC)
772 {
773 VP_FUNC_CALL();
774
775 SwFilterHdr *hdr = nullptr;
776 SwFilterCsc *csc = nullptr;
777 FeatureParamHdr *hdrParams = nullptr;
778 FeatureParamCsc *cscParams = nullptr;
779 VP_EngineEntry *cscEngine = nullptr;
780
781 VP_PUBLIC_CHK_NULL_RETURN(HDR);
782 VP_PUBLIC_CHK_NULL_RETURN(CSC);
783 hdr = (SwFilterHdr *)HDR;
784 csc = (SwFilterCsc *)CSC;
785
786 hdrParams = &hdr->GetSwFilterParams();
787 cscParams = &csc->GetSwFilterParams();
788 cscEngine = &csc->GetFilterEngineCaps();
789
790 // Clean usedForNextPass flag.
791 if (cscEngine->usedForNextPass)
792 {
793 cscEngine->usedForNextPass = false;
794 }
795 if (cscEngine->value != 0)
796 {
797 VP_PUBLIC_NORMALMESSAGE("CSC Feature Already been processed, Skip further process");
798
799 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
800 return MOS_STATUS_SUCCESS;
801 }
802
803 MOS_FORMAT hdrFormat = Format_Any;
804 VPHAL_CSPACE hdrCSpace = CSpace_Any;
805 if (cscParams->isFullRgbG10P709 && IS_RGB64_FLOAT_FORMAT(cscParams->formatOutput))
806 {
807 if (hdrParams->hdrMode == VPHAL_HDR_MODE_H2H)
808 {
809 hdrCSpace = CSpace_BT2020_RGB;
810 }
811 else if (hdrParams->hdrMode == VPHAL_HDR_MODE_TONE_MAPPING)
812 {
813 hdrCSpace = CSpace_sRGB;
814 }
815 else
816 {
817 VP_PUBLIC_ASSERTMESSAGE("Invalid HDR Mode %d!", hdrParams->hdrMode);
818 }
819 hdrFormat = Format_A16B16G16R16;
820 }
821 else
822 {
823 hdrCSpace = IS_COLOR_SPACE_BT2020(cscParams->output.colorSpace) ? CSpace_BT2020_RGB : CSpace_sRGB;
824 hdrFormat = IS_COLOR_SPACE_BT2020(cscParams->output.colorSpace) ? Format_R10G10B10A2 : Format_A8R8G8B8;
825 }
826 VP_PUBLIC_CHK_STATUS_RETURN(Update3DLutoutputColorAndFormat(cscParams, hdrParams, hdrFormat, hdrCSpace));
827
828 // for HDR case, vebox input format support is checking by GetHdrExecutionCaps
829 if (m_hwCaps.m_veboxHwEntry[cscParams->formatOutput].outputSupported &&
830 m_hwCaps.m_veboxHwEntry[hdrFormat].frontCscSupported &&
831 (hdrFormat != cscParams->formatOutput || hdrCSpace != cscParams->output.colorSpace))
832 {
833 // front end csc can be used to do the left csc feature when no sfc is needed
834 cscEngine->bEnabled = 1;
835 cscEngine->frontEndCscNeeded = 1;
836 cscEngine->VeboxNeeded = 1;
837 cscEngine->hdrKernelSupported = 1;
838 }
839 if (m_hwCaps.m_sfcHwEntry[hdrFormat].inputSupported &&
840 m_hwCaps.m_sfcHwEntry[cscParams->formatOutput].outputSupported &&
841 m_hwCaps.m_sfcHwEntry[hdrFormat].cscSupported)
842 {
843 //sfc or render can be used to do the left csc feature
844 if (hdrFormat == cscParams->formatOutput && hdrCSpace == cscParams->output.colorSpace)
845 {
846 VP_PUBLIC_NORMALMESSAGE("Skip CSC for HDR case.");
847 cscEngine->forceEnableForSfc = 1;
848 cscEngine->forceEnableForHdrKernel = 1;
849 }
850 else
851 {
852 cscEngine->bEnabled = 1;
853 cscEngine->SfcNeeded = 1;
854 cscEngine->RenderNeeded = 1;
855 cscEngine->fcSupported = 1;
856 cscEngine->hdrKernelSupported = 1;
857
858 }
859 }
860 if (!cscEngine->bEnabled && !cscEngine->forceEnableForSfc)
861 {
862 VP_PUBLIC_ASSERTMESSAGE("Post CSC for HDR not supported by SFC or FECSC(VEBOX)");
863 return MOS_STATUS_INVALID_PARAMETER;
864 }
865
866 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
867 return MOS_STATUS_SUCCESS;
868 }
869
870 MOS_STATUS Policy::GetCSCExecutionCapsDi(SwFilter* feature)
871 {
872 VP_FUNC_CALL();
873
874 VP_PUBLIC_CHK_NULL_RETURN(feature);
875
876 SwFilterCsc* csc = dynamic_cast<SwFilterCsc*>(feature);
877 VP_PUBLIC_CHK_NULL_RETURN(csc);
878 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
879 bool disableSfc = userFeatureControl->IsSfcDisabled();
880
881 VP_PUBLIC_CHK_STATUS_RETURN(GetCSCExecutionCaps(feature, false));
882
883 VP_EngineEntry *cscEngine = &csc->GetFilterEngineCaps();
884 VP_PUBLIC_CHK_NULL_RETURN(cscEngine);
885 if (!disableSfc && (cscEngine->bEnabled && (cscEngine->SfcNeeded || cscEngine->VeboxNeeded)) ||
886 !cscEngine->bEnabled && cscEngine->forceEnableForSfc)
887 {
888 cscEngine->bEnabled = 1;
889 cscEngine->SfcNeeded = 1;
890 cscEngine->VeboxNeeded = 0;
891 cscEngine->RenderNeeded = 0;
892 }
893 else
894 {
895 cscEngine->bEnabled = 1;
896 cscEngine->SfcNeeded = 0;
897 cscEngine->VeboxNeeded = 0;
898 cscEngine->RenderNeeded = 1;
899 cscEngine->fcSupported = 1;
900 }
901
902 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
903 return MOS_STATUS_SUCCESS;
904 }
905
906
907 MOS_STATUS Policy::GetCSCExecutionCapsBT2020ToRGB(SwFilter *cgc, SwFilter *csc)
908 {
909 VP_FUNC_CALL();
910 VP_PUBLIC_CHK_NULL_RETURN(csc);
911 VP_PUBLIC_CHK_NULL_RETURN(cgc);
912 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
913 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
914 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
915 bool disableVeboxOutput = userFeatureControl->IsVeboxOutputDisabled();
916 bool disableSfc = userFeatureControl->IsSfcDisabled();
917 MOS_FORMAT midFormat = Format_A8R8G8B8;
918
919 if (!((SwFilterCgc *)cgc)->IsBt2020ToRGBEnabled())
920 {
921 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_UNIMPLEMENTED);
922 }
923
924 if(userFeatureControl->IsVeboxTypeHMode())
925 {
926 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_PLATFORM_NOT_SUPPORTED);
927 }
928
929 FeatureParamCsc *cscParams = &((SwFilterCsc *)csc)->GetSwFilterParams();
930
931 VP_EngineEntry *cscEngine = &((SwFilterCsc *)csc)->GetFilterEngineCaps();
932
933 FeatureParamCgc *cgcParams = &((SwFilterCgc *)cgc)->GetSwFilterParams();
934
935 // Clean usedForNextPass flag.
936 if (cscEngine->usedForNextPass)
937 {
938 cscEngine->usedForNextPass = false;
939 }
940 if (cscEngine->value != 0)
941 {
942 VP_PUBLIC_NORMALMESSAGE("CSC Feature Already been processed, Skip further process");
943
944 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
945 return MOS_STATUS_SUCCESS;
946 }
947
948 if (m_hwCaps.m_sfcHwEntry[midFormat].cscSupported &&
949 m_hwCaps.m_sfcHwEntry[cscParams->formatOutput].outputSupported &&
950 m_hwCaps.m_sfcHwEntry[midFormat].inputSupported)
951 {
952 // Vebox GC + SFC/Render. The csc parameter below if for sfc or render.
953 cgcParams->formatOutput = midFormat;
954 cgcParams->dstColorSpace = CSpace_sRGB;
955 cscParams->formatforCUS = cscParams->formatInput;
956 cscParams->formatInput = cgcParams->formatOutput;
957 cscParams->input.colorSpace = cgcParams->dstColorSpace;
958
959 cscEngine->bEnabled = 1;
960 if (disableSfc)
961 {
962 cscEngine->SfcNeeded = 0;
963 }
964 else
965 {
966 cscEngine->SfcNeeded = 1;
967 }
968 cscEngine->VeboxNeeded = 0;
969 cscEngine->RenderNeeded = 1;
970 cscEngine->fcSupported = 1;
971 }
972 else
973 {
974 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
975 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
976 }
977
978 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
979 return MOS_STATUS_SUCCESS;
980 }
981
982 bool Policy::IsDemosaicValidOutputFormat(MOS_FORMAT format)
983 {
984 return (format == Format_R10G10B10A2 || format == Format_A8R8G8B8);
985 }
986
987 bool IsBeCscNeededForAlphaFill(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha)
988 {
989 VP_FUNC_CALL();
990 if (nullptr == compAlpha)
991 {
992 VP_PUBLIC_NORMALMESSAGE("No alpha setting exists.");
993 return false;
994 }
995
996 if (!IS_ALPHA_FORMAT(formatOutput))
997 {
998 VP_PUBLIC_NORMALMESSAGE("Alpha setting can be ignored for non-alpha output format.");
999 return false;
1000 }
1001
1002 if (VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM == compAlpha->AlphaMode)
1003 {
1004 VP_PUBLIC_NORMALMESSAGE("No need BeCsc for VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM when output from vebox.");
1005 return false;
1006 }
1007
1008 if (VPHAL_ALPHA_FILL_MODE_OPAQUE == compAlpha->AlphaMode && !IS_ALPHA_FORMAT(formatInput))
1009 {
1010 // In such case, vebox will fill the alpha field with 0xff by default.
1011 VP_PUBLIC_NORMALMESSAGE("No need BeCsc for VPHAL_ALPHA_FILL_MODE_OPAQUE with non-alpha input format.");
1012 return false;
1013 }
1014
1015 return true;
1016 }
1017
1018 bool Policy::IsAlphaSettingSupportedBySfc(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha)
1019 {
1020 VP_FUNC_CALL();
1021 if (!IS_ALPHA_FORMAT(formatOutput))
1022 {
1023 VP_PUBLIC_NORMALMESSAGE("Alpha setting can be ignored for non-alpha output format.");
1024 return true;
1025 }
1026
1027 if (compAlpha && VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM == compAlpha->AlphaMode)
1028 {
1029 if (IS_ALPHA_FORMAT(formatInput))
1030 {
1031 VP_PUBLIC_NORMALMESSAGE("VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM is not supported by SFC.");
1032 if (Format_Y410 == formatOutput)
1033 {
1034 // Y410 is also not supported by FC Save_444Scale16_SrcY410 kernel for Alpha Source Mode.
1035 // Ignore Alpha Source Mode if sfc/render being needed.
1036 VP_PUBLIC_NORMALMESSAGE("Ignore VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM for Y410.");
1037 return true;
1038 }
1039 return false;
1040 }
1041 else
1042 {
1043 VP_PUBLIC_NORMALMESSAGE("VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM can be ignored since no alpha info in input surface.");
1044 return true;
1045 }
1046 }
1047 else if (compAlpha && VPHAL_ALPHA_FILL_MODE_BACKGROUND == compAlpha->AlphaMode)
1048 {
1049 if (IS_ALPHA_FORMAT_RGB8(formatOutput) || IS_ALPHA_FORMAT_RGB10(formatOutput))
1050 {
1051 VP_PUBLIC_NORMALMESSAGE("VPHAL_ALPHA_FILL_MODE_BACKGROUND is supported by SFC for RGB8 and RGB10.");
1052 return true;
1053 }
1054 else
1055 {
1056 VP_PUBLIC_NORMALMESSAGE("VPHAL_ALPHA_FILL_MODE_BACKGROUND is not supported for format %d.", formatOutput);
1057 if (Format_Y410 == formatOutput)
1058 {
1059 // Y410 is also not supported by FC Save_444Scale16_SrcY410 kernel for Alpha Background Mode.
1060 // Ignore Alpha Background Mode if sfc/render being needed.
1061 VP_PUBLIC_NORMALMESSAGE("Ignore VPHAL_ALPHA_FILL_MODE_BACKGROUND for Y410.");
1062 return true;
1063 }
1064 return false;
1065 }
1066 }
1067
1068 if (compAlpha)
1069 {
1070 VP_PUBLIC_NORMALMESSAGE("true for AlphaMode %d.", compAlpha->AlphaMode);
1071 }
1072 else
1073 {
1074 VP_PUBLIC_NORMALMESSAGE("compAlpha == nullptr. Just return true");
1075 }
1076
1077 return true;
1078 }
1079
1080 bool Policy::IsAlphaSettingSupportedByVebox(MOS_FORMAT formatInput, MOS_FORMAT formatOutput, PVPHAL_ALPHA_PARAMS compAlpha)
1081 {
1082 if (!IS_ALPHA_FORMAT(formatOutput))
1083 {
1084 VP_PUBLIC_NORMALMESSAGE("Alpha setting can be ignored for non-alpha output format.");
1085 return true;
1086 }
1087
1088 if (compAlpha && VPHAL_ALPHA_FILL_MODE_BACKGROUND == compAlpha->AlphaMode)
1089 {
1090 VP_PUBLIC_NORMALMESSAGE("Alpha Background Mode is not supported by Vebox.");
1091 return false;
1092 }
1093 else
1094 {
1095 if (compAlpha)
1096 {
1097 VP_PUBLIC_NORMALMESSAGE("true for AlphaMode %d.", compAlpha->AlphaMode);
1098 }
1099 else
1100 {
1101 VP_PUBLIC_NORMALMESSAGE("compAlpha == nullptr. Just return true");
1102 }
1103 return true;
1104 }
1105 }
1106
1107 MOS_STATUS Policy::GetCSCExecutionCaps(SwFilter* feature, bool isCamPipeWithBayerInput)
1108 {
1109 VP_FUNC_CALL();
1110 VP_PUBLIC_CHK_NULL_RETURN(feature);
1111 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
1112 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
1113
1114 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
1115 bool disableVeboxOutput = userFeatureControl->IsVeboxOutputDisabled();
1116 bool disableSfc = userFeatureControl->IsSfcDisabled();
1117 bool veboxTypeH = userFeatureControl->IsVeboxTypeHMode();
1118 SwFilterCsc* csc = (SwFilterCsc*)feature;
1119
1120 FeatureParamCsc *cscParams = &csc->GetSwFilterParams();
1121
1122 MOS_FORMAT midFormat = Format_Any;
1123
1124 VP_EngineEntry *cscEngine = &csc->GetFilterEngineCaps();
1125
1126 cscEngine->isBayerInputInUse = false;
1127 // Clean usedForNextPass flag.
1128 if (cscEngine->usedForNextPass)
1129 {
1130 cscEngine->usedForNextPass = false;
1131 }
1132 if (cscEngine->value != 0)
1133 {
1134 VP_PUBLIC_NORMALMESSAGE("CSC Feature Already been processed, Skip further process");
1135
1136 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
1137 return MOS_STATUS_SUCCESS;
1138 }
1139
1140 bool isAlphaSettingSupportedBySfc =
1141 IsAlphaSettingSupportedBySfc(cscParams->formatInput, cscParams->formatOutput, cscParams->pAlphaParams);
1142 bool isAlphaSettingSupportedByVebox =
1143 IsAlphaSettingSupportedByVebox(cscParams->formatInput, cscParams->formatOutput, cscParams->pAlphaParams);
1144
1145 if (cscParams->formatInput == cscParams->formatOutput &&
1146 cscParams->input.colorSpace == cscParams->output.colorSpace &&
1147 cscParams->input.chromaSiting == cscParams->output.chromaSiting &&
1148 nullptr == cscParams->pIEFParams &&
1149 isAlphaSettingSupportedByVebox)
1150 {
1151 bool veboxSupported = m_hwCaps.m_veboxHwEntry[cscParams->formatInput].inputSupported;
1152 bool sfcSupported = veboxSupported && m_hwCaps.m_sfcHwEntry[cscParams->formatInput].inputSupported;
1153
1154 if (!veboxSupported)
1155 {
1156 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since format %d not supported by vebox. Force to render.", cscParams->formatInput);
1157 cscEngine->bEnabled = 1;
1158 cscEngine->SfcNeeded = 0;
1159 cscEngine->VeboxNeeded = 0;
1160 cscEngine->RenderNeeded = 1;
1161 cscEngine->fcSupported = 1;
1162 cscEngine->sfcNotSupported = 1;
1163 }
1164 else if (disableVeboxOutput)
1165 {
1166 VP_PUBLIC_NORMALMESSAGE("Non-csc cases with vebox output disabled. Still keep csc filter to avoid output from vebox.");
1167 cscEngine->bEnabled = 1;
1168 cscEngine->SfcNeeded = (disableSfc || !sfcSupported) ? 0 : 1;
1169 cscEngine->VeboxNeeded = 0;
1170 cscEngine->RenderNeeded = 1;
1171 cscEngine->fcSupported = 1;
1172 }
1173 else if (IsBeCscNeededForAlphaFill(cscParams->formatInput, cscParams->formatOutput, cscParams->pAlphaParams))
1174 {
1175 VP_PUBLIC_NORMALMESSAGE("BeCsc is needed by Alpha when output from vebox. Keep csc filter.");
1176 cscEngine->bEnabled = 1;
1177 cscEngine->SfcNeeded = disableSfc ? 0 : 1;
1178 cscEngine->RenderNeeded = 1;
1179 cscEngine->fcSupported = 1;
1180 if (veboxTypeH)
1181 {
1182 cscEngine->VeboxNeeded = 0;
1183 VP_PUBLIC_WARNINGMESSAGE("Not use vebox to do csc for veboxTypeH.");
1184 }
1185 else
1186 {
1187 cscEngine->VeboxNeeded = 1;
1188 }
1189 }
1190 else
1191 {
1192 // for non-csc cases, all engine supported
1193 cscEngine->bEnabled = 0;
1194 cscEngine->SfcNeeded = 0;
1195 cscEngine->VeboxNeeded = 0;
1196 cscEngine->RenderNeeded = 0;
1197 if (sfcSupported && !disableSfc)
1198 {
1199 cscEngine->forceEnableForSfc = 1;
1200 }
1201 else
1202 {
1203 cscEngine->sfcNotSupported = 1;
1204 }
1205 }
1206
1207 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
1208 return MOS_STATUS_SUCCESS;
1209 }
1210
1211 if (IS_COLOR_SPACE_BT2020_YUV(cscParams->input.colorSpace))
1212 {
1213 if ((cscParams->output.colorSpace == CSpace_BT601) ||
1214 (cscParams->output.colorSpace == CSpace_BT709) ||
1215 (cscParams->output.colorSpace == CSpace_BT601_FullRange) ||
1216 (cscParams->output.colorSpace == CSpace_BT709_FullRange) ||
1217 (cscParams->output.colorSpace == CSpace_stRGB) ||
1218 (cscParams->output.colorSpace == CSpace_sRGB))
1219 {
1220 // Should not come here for BT2020 support.
1221 VP_PUBLIC_ASSERTMESSAGE("not support BT2020 input.");
1222 return MOS_STATUS_UNIMPLEMENTED;
1223 }
1224 }
1225
1226 cscEngine->bEnabled = 1;
1227 cscEngine->RenderNeeded = 1;
1228 cscEngine->fcSupported = 1;
1229
1230 // SFC CSC enabling check
1231 if (!disableSfc &&
1232 m_hwCaps.m_sfcHwEntry[cscParams->formatInput].inputSupported &&
1233 (m_hwCaps.m_sfcHwEntry[cscParams->formatOutput].outputSupported &
1234 VpGetFormatTileSupport(cscParams->output.tileMode)) &&
1235 m_hwCaps.m_sfcHwEntry[cscParams->formatInput].cscSupported &&
1236 isAlphaSettingSupportedBySfc)
1237 {
1238 cscEngine->SfcNeeded = 1;
1239 }
1240
1241 if (disableVeboxOutput)
1242 {
1243 // If vebox output disabled, then such mega feature like CSC will not take effect in Vebox.
1244 // then CSC will must be assign to SFC/Render path for execution.
1245 VP_PUBLIC_NORMALMESSAGE("Force to use sfc or render for csc.");
1246 }
1247 else
1248 {
1249 if (!cscParams->pIEFParams &&
1250 m_hwCaps.m_veboxHwEntry[cscParams->formatInput].inputSupported &&
1251 (m_hwCaps.m_veboxHwEntry[cscParams->formatOutput].outputSupported ||
1252 (isCamPipeWithBayerInput && IsDemosaicValidOutputFormat(cscParams->formatOutput))) &&
1253 m_hwCaps.m_veboxHwEntry[cscParams->formatInput].iecp &&
1254 m_hwCaps.m_veboxHwEntry[cscParams->formatInput].backEndCscSupported &&
1255 isAlphaSettingSupportedByVebox)
1256 {
1257 cscEngine->VeboxNeeded = 1;
1258 }
1259 else
1260 {
1261 VP_PUBLIC_NORMALMESSAGE("vebox cannot be selected. For vebox selection, cscParams->pIEFParams (%p) expected nulptr, \
1262 veboxHwCap[format %d].inputSupported (%d) expected 1, \
1263 (veboxHwCap[format %d].outputSupported (%d) || \
1264 (isCamPipeWithBayerInput(%d) && IsDemosaicValidOutputFormat(cscParams->formatOutput(Format %d))(%d))) expected 1, \
1265 veboxHwCap[Format %d].iecp (%d) expect 1, \
1266 veboxHwCap[format %d].backEndCscSupported (%d) expect 1 \
1267 isAlphaSettingSupportedByVebox (%d) expect 1" ,
1268 cscParams->pIEFParams,
1269 cscParams->formatInput, m_hwCaps.m_veboxHwEntry[cscParams->formatInput].inputSupported,
1270 cscParams->formatOutput, m_hwCaps.m_veboxHwEntry[cscParams->formatOutput].outputSupported,
1271 isCamPipeWithBayerInput,cscParams->formatOutput,IsDemosaicValidOutputFormat(cscParams->formatOutput),
1272 cscParams->formatInput, m_hwCaps.m_veboxHwEntry[cscParams->formatInput].iecp,
1273 cscParams->formatInput, m_hwCaps.m_veboxHwEntry[cscParams->formatInput].backEndCscSupported,
1274 isAlphaSettingSupportedByVebox);
1275
1276 }
1277 }
1278
1279 PrintFeatureExecutionCaps(__FUNCTION__, *cscEngine);
1280 return MOS_STATUS_SUCCESS;
1281 }
1282
1283 MOS_STATUS Policy::GetScalingExecutionCapsHdr(SwFilter *feature)
1284 {
1285 VP_FUNC_CALL();
1286 VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, true, false));
1287 return MOS_STATUS_SUCCESS;
1288 }
1289
1290 MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature, bool isDIEnabled)
1291 {
1292 VP_FUNC_CALL();
1293 VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, false, isDIEnabled));
1294 return MOS_STATUS_SUCCESS;
1295 }
1296
1297 MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled, bool isDIEnabled)
1298 {
1299 VP_FUNC_CALL();
1300
1301 uint32_t dwSurfaceWidth = 0, dwSurfaceHeight = 0;
1302 uint32_t dwOutputSurfaceWidth = 0, dwOutputSurfaceHeight = 0;
1303 uint32_t veboxMinWidth = 0, veboxMaxWidth = 0;
1304 uint32_t veboxMinHeight = 0, veboxMaxHeight = 0;
1305 uint32_t dwSfcInputMinWidth = 0, dwSfcMaxWidth = 0;
1306 uint32_t dwSfcInputMinHeight = 0, dwSfcMaxHeight = 0;
1307 uint32_t dwSfcOutputMinWidth = 0, dwSfcOutputMinHeight = 0;
1308 uint32_t dwDstMinHeight = 0;
1309 float fScaleMin = 0, fScaleMax = 0;
1310 float fScaleMin2Pass = 0, fScaleMax2Pass = 0;
1311 float fScaleX = 0, fScaleY = 0;
1312
1313 VP_PUBLIC_CHK_NULL_RETURN(feature);
1314 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
1315 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
1316 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_reporting);
1317
1318 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
1319 bool disableSfc = userFeatureControl->IsSfcDisabled();
1320 bool fallbackScalingToRender8K = userFeatureControl->IsFallbackScalingToRender8K();
1321 auto reporting = m_vpInterface.GetHwInterface()->m_reporting;
1322 SwFilterScaling* scaling = (SwFilterScaling*)feature;
1323 FeatureParamScaling *scalingParams = &scaling->GetSwFilterParams();
1324 VP_EngineEntry *scalingEngine = &scaling->GetFilterEngineCaps();
1325 bool isAlphaSettingSupportedBySfc =
1326 IsAlphaSettingSupportedBySfc(scalingParams->formatInput, scalingParams->formatOutput, scalingParams->pCompAlpha);
1327 bool isAlphaSettingSupportedByVebox =
1328 IsAlphaSettingSupportedByVebox(scalingParams->formatInput, scalingParams->formatOutput, scalingParams->pCompAlpha);
1329
1330 if (scalingParams->formatOutput == Format_422H)
1331 {
1332 VP_PUBLIC_ASSERTMESSAGE("Scaling not support 422H format output.");
1333 return MOS_STATUS_UNIMPLEMENTED;
1334 }
1335
1336 // Clean usedForNextPass flag.
1337 if (scalingEngine->usedForNextPass)
1338 {
1339 scalingEngine->usedForNextPass = false;
1340 }
1341
1342 if (scalingEngine->value != 0)
1343 {
1344 VP_PUBLIC_NORMALMESSAGE("Scaling Feature Already been processed, Skip further process");
1345
1346 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1347 return MOS_STATUS_SUCCESS;
1348 }
1349
1350 // For AVS sampler not enabled case, HQ/Fast scaling should go to SFC.
1351 // And Ief should only be done by SFC.
1352 if (!m_hwCaps.m_rules.isAvsSamplerSupported &&
1353 scalingParams->scalingPreference != VPHAL_SCALING_PREFER_SFC)
1354 {
1355 VP_PUBLIC_NORMALMESSAGE("Force scalingPreference from %d to SFC", scalingParams->scalingPreference);
1356 scalingParams->scalingPreference = VPHAL_SCALING_PREFER_SFC;
1357 }
1358
1359 if (userFeatureControl->IsSFCLinearOutputByTileConvertEnabled() &&
1360 scalingParams->output.dwWidth <= 1152 &&
1361 scalingParams->output.dwPitch != 128 &&
1362 scalingParams->output.dwPitch != 256 &&
1363 (scalingParams->output.dwPitch % 1024) !=0 &&
1364 !(scalingParams->formatOutput == Format_RGBP ||
1365 scalingParams->formatOutput == Format_BGRP ||
1366 scalingParams->formatOutput == Format_R8G8B8) &&
1367 scalingParams->output.tileMode == MOS_TILE_LINEAR_GMM)
1368 {
1369 scalingEngine->enableSFCLinearOutputByTileConvert = true;
1370 VP_PUBLIC_NORMALMESSAGE("enable sfcLinearOutputByTileConvert, output width %d, output pitch %d, output tilemode %d", scalingParams->output.dwWidth, scalingParams->output.dwPitch, scalingParams->output.tileMode);
1371 }
1372 dwSurfaceWidth = scalingParams->input.dwWidth;
1373 dwSurfaceHeight = scalingParams->input.dwHeight;
1374 dwOutputSurfaceWidth = scalingParams->output.dwWidth;
1375 dwOutputSurfaceHeight = scalingParams->output.dwHeight;
1376
1377 // Region of the input frame which needs to be processed by SFC
1378 uint32_t dwSourceRegionHeight = MOS_ALIGN_FLOOR(
1379 MOS_MIN((uint32_t)(scalingParams->input.rcSrc.bottom - scalingParams->input.rcSrc.top), dwSurfaceHeight),
1380 m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].verticalAlignUnit);
1381 uint32_t dwSourceRegionWidth = MOS_ALIGN_FLOOR(
1382 MOS_MIN((uint32_t)(scalingParams->input.rcSrc.right - scalingParams->input.rcSrc.left), dwSurfaceWidth),
1383 m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].horizontalAlignUnit);
1384
1385 // Size of the Output Region over the Render Target
1386 uint32_t dwOutputRegionHeight = MOS_ALIGN_CEIL(
1387 (uint32_t)(scalingParams->input.rcDst.bottom - scalingParams->input.rcDst.top),
1388 m_hwCaps.m_sfcHwEntry[scalingParams->formatOutput].verticalAlignUnit);
1389 uint32_t dwOutputRegionWidth = MOS_ALIGN_CEIL(
1390 (uint32_t)(scalingParams->input.rcDst.right - scalingParams->input.rcDst.left),
1391 m_hwCaps.m_sfcHwEntry[scalingParams->formatOutput].horizontalAlignUnit);
1392
1393 bool isScalingNeeded = (dwOutputRegionHeight != dwSourceRegionHeight || dwOutputRegionWidth != dwSourceRegionWidth);
1394
1395 if (!m_hwCaps.m_veboxHwEntry[scalingParams->formatInput].inputSupported)
1396 {
1397 // For non-scaling cases with vebox unsupported format, will force to use fc.
1398 scalingEngine->bEnabled = isScalingNeeded;
1399 scalingEngine->SfcNeeded = 0;
1400 scalingEngine->VeboxNeeded = 0;
1401 scalingEngine->RenderNeeded = 1;
1402 scalingEngine->fcSupported = 1;
1403 scalingEngine->hdrKernelSupported = 1;
1404 scalingEngine->forceEnableForSfc = 0;
1405 scalingEngine->forceEnableForFc = 1;
1406 scalingEngine->veboxNotSupported = 1;
1407 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since Vebox does not support input format %d. Force to render.", scalingParams->formatInput);
1408 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1409 return MOS_STATUS_SUCCESS;
1410 }
1411
1412 veboxMinWidth = m_hwCaps.m_veboxHwEntry[scalingParams->formatInput].minWidth;
1413 veboxMaxWidth = m_hwCaps.m_veboxHwEntry[scalingParams->formatInput].maxWidth;
1414 veboxMinHeight = m_hwCaps.m_veboxHwEntry[scalingParams->formatInput].minHeight;
1415 veboxMaxHeight = m_hwCaps.m_veboxHwEntry[scalingParams->formatInput].maxHeight;
1416 dwSfcInputMinWidth = m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].inputMinResolution;
1417 dwSfcMaxWidth = m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].maxResolution;
1418 dwSfcInputMinHeight = m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].inputMinResolution;
1419 dwSfcMaxHeight = m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].maxResolution;
1420 dwSfcOutputMinWidth = m_hwCaps.m_sfcHwEntry[scalingParams->formatOutput].outputMinResolution;
1421 dwSfcOutputMinHeight = m_hwCaps.m_sfcHwEntry[scalingParams->formatOutput].outputMinResolution;
1422 fScaleMin = m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].minScalingRatio;
1423 fScaleMax = m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].maxScalingRatio;
1424 if (m_hwCaps.m_rules.sfcMultiPassSupport.scaling.enable)
1425 {
1426 fScaleMin2Pass = fScaleMin * m_hwCaps.m_rules.sfcMultiPassSupport.scaling.downScaling.minRatioEnlarged;
1427 fScaleMax2Pass = fScaleMax * m_hwCaps.m_rules.sfcMultiPassSupport.scaling.upScaling.maxRatioEnlarged;
1428 }
1429
1430 if (scalingParams->interlacedScalingType == ISCALING_FIELD_TO_INTERLEAVED)
1431 {
1432 dwDstMinHeight = dwSfcOutputMinHeight * 2;
1433 }
1434 else
1435 {
1436 dwDstMinHeight = dwSfcOutputMinHeight;
1437 }
1438
1439 if (OUT_OF_BOUNDS(dwSurfaceWidth, veboxMinWidth, veboxMaxWidth) ||
1440 OUT_OF_BOUNDS(dwSurfaceHeight, veboxMinHeight, veboxMaxHeight))
1441 {
1442 // For non-scaling cases with vebox unsupported format, will force to use fc.
1443 scalingEngine->bEnabled = isScalingNeeded;
1444 scalingEngine->SfcNeeded = 0;
1445 scalingEngine->VeboxNeeded = 0;
1446 scalingEngine->forceEnableForSfc = 0;
1447 scalingEngine->RenderNeeded = 1;
1448 scalingEngine->fcSupported = 1;
1449 scalingEngine->hdrKernelSupported = 1;
1450 scalingEngine->forceEnableForFc = 1;
1451 scalingEngine->veboxNotSupported = 1;
1452
1453 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since the surface resolution (%d x %d) is not supported by vebox (%d x %d) ~ (%d x %d).",
1454 dwSurfaceWidth, dwSurfaceHeight, veboxMinWidth, veboxMinHeight, veboxMaxWidth, veboxMaxHeight);
1455
1456 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1457 return MOS_STATUS_SUCCESS;
1458 }
1459
1460 if (fallbackScalingToRender8K == true &&
1461 scalingParams->input.dwHeight > 3072 &&
1462 isScalingNeeded)
1463 {
1464 // For sfc input height > 3072 case, will force to use fc.
1465 scalingEngine->bEnabled = 1;
1466 scalingEngine->SfcNeeded = 0;
1467 scalingEngine->VeboxNeeded = 0;
1468 scalingEngine->RenderNeeded = 1;
1469 scalingEngine->hdrKernelSupported = 1;
1470 scalingEngine->fcSupported = 1;
1471 scalingEngine->forceEnableForSfc = 0;
1472 scalingEngine->forceEnableForFc = 1;
1473 scalingEngine->sfcNotSupported = 1;
1474 #if (_DEBUG || _RELEASE_INTERNAL)
1475 reporting->GetFeatures().fallbackScalingToRender8K = fallbackScalingToRender8K;
1476 #endif
1477
1478 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since fallbackScalingToRender8K is true and the input height %d is greater than 3072.", scalingParams->input.dwHeight);
1479
1480 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1481 return MOS_STATUS_SUCCESS;
1482 }
1483
1484 // Calculate the scaling ratio
1485 // Both source region and scaled region are pre-rotated
1486 // Need to take Interlace scaling into consideration next step
1487 fScaleX = (float)dwOutputRegionWidth / (float)dwSourceRegionWidth;
1488 fScaleY = (float)dwOutputRegionHeight / (float)dwSourceRegionHeight;
1489
1490 auto isSfcIscalingNotSupported = [&]()
1491 {
1492 return ISCALING_INTERLEAVED_TO_INTERLEAVED == scalingParams->interlacedScalingType &&
1493 (scalingParams->input.rcSrc.left != 0 ||
1494 scalingParams->input.rcSrc.top != 0 ||
1495 scalingParams->input.rcDst.left != 0 ||
1496 scalingParams->input.rcDst.top != 0 ||
1497 scalingParams->rotation.rotationNeeded);
1498 };
1499
1500 if (fScaleX == 1.0f && fScaleY == 1.0f &&
1501 // Only support vebox crop from left-top, which is to align with legacy path.
1502 0 == scalingParams->input.rcSrc.left && 0 == scalingParams->input.rcSrc.top &&
1503 SAME_SIZE_RECT(scalingParams->input.rcDst, scalingParams->output.rcDst) &&
1504 // If alpha is not supported by vebox, which should go SFC pipe.
1505 isAlphaSettingSupportedByVebox &&
1506 // If Colorfill enabled, which should go SFC pipe.
1507 !IsColorfillEnabled(scalingParams) &&
1508 scalingParams->interlacedScalingType != ISCALING_INTERLEAVED_TO_FIELD &&
1509 scalingParams->interlacedScalingType != ISCALING_FIELD_TO_INTERLEAVED)
1510 {
1511 if (OUT_OF_BOUNDS(dwSurfaceWidth, dwSfcInputMinWidth, dwSfcMaxWidth) ||
1512 OUT_OF_BOUNDS(dwSurfaceHeight, dwSfcInputMinHeight, dwSfcMaxHeight))
1513 {
1514 // for non-Scaling cases, all engine supported
1515 scalingEngine->bEnabled = 0;
1516 scalingEngine->SfcNeeded = 0;
1517 scalingEngine->VeboxNeeded = 0;
1518 scalingEngine->RenderNeeded = 0;
1519 scalingEngine->forceEnableForSfc = 0;
1520 scalingEngine->forceEnableForFc = 1;
1521 scalingEngine->fcSupported = 1;
1522 scalingEngine->hdrKernelSupported = 1;
1523 scalingEngine->sfcNotSupported = 1;
1524 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since the surface resolution (%d x %d) is not supported by sfc (%d x %d) ~ (%d x %d).",
1525 dwSurfaceWidth, dwSurfaceHeight, dwSfcInputMinWidth, dwSfcInputMinHeight, dwSfcMaxWidth, dwSfcMaxHeight);
1526 }
1527 else if (isSfcIscalingNotSupported())
1528 {
1529 scalingEngine->bEnabled = 1;
1530 scalingEngine->SfcNeeded = 0;
1531 scalingEngine->VeboxNeeded = 0;
1532 scalingEngine->RenderNeeded = 1;
1533 scalingEngine->fcSupported = 1;
1534 scalingEngine->sfcNotSupported = 1;
1535 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since interlaced scaling cannot support offset, rotate or mirror by SFC pipe, fallback to FC.");
1536 }
1537 else if (scalingParams->input.rcDst.left > 0 ||
1538 scalingParams->input.rcDst.top > 0)
1539 {
1540 // for dst left and top non zero cases, should go SFC or Render Pipe
1541 scalingEngine->bEnabled = 1;
1542 scalingEngine->SfcNeeded = !disableSfc && isAlphaSettingSupportedBySfc;
1543 scalingEngine->VeboxNeeded = 0;
1544 scalingEngine->RenderNeeded = 1;
1545 scalingEngine->fcSupported = 1;
1546 scalingEngine->hdrKernelSupported = 1;
1547 VP_PUBLIC_NORMALMESSAGE("The dst left and top non zero is not supported by vebox ");
1548 }
1549 else
1550 {
1551 // for non-Scaling cases, all engine supported
1552 scalingEngine->bEnabled = 0;
1553 scalingEngine->SfcNeeded = 0;
1554 scalingEngine->VeboxNeeded = 0;
1555 scalingEngine->RenderNeeded = 0;
1556 scalingEngine->forceEnableForSfc = isAlphaSettingSupportedBySfc;
1557 scalingEngine->forceEnableForFc = 1;
1558 scalingEngine->fcSupported = 1;
1559 scalingEngine->hdrKernelSupported = 1;
1560 scalingEngine->sfcNotSupported = disableSfc || !isAlphaSettingSupportedBySfc;
1561 }
1562
1563 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1564 return MOS_STATUS_SUCCESS;
1565 }
1566
1567 if (disableSfc)
1568 {
1569 scalingEngine->bEnabled = 1;
1570 scalingEngine->RenderNeeded = 1;
1571 scalingEngine->fcSupported = 1;
1572 scalingEngine->hdrKernelSupported = 1;
1573 scalingEngine->SfcNeeded = 0;
1574 // Set sfcNotSupported to 1 to avoid SFC being selected without scaling filter.
1575 scalingEngine->sfcNotSupported = 1;
1576 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since force scaling to FC. disableSfc %d", disableSfc);
1577 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1578 return MOS_STATUS_SUCCESS;
1579 }
1580
1581 // SFC Scaling enabling check
1582 if (m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].inputSupported &&
1583 (m_hwCaps.m_sfcHwEntry[scalingParams->formatOutput].outputSupported & VpGetFormatTileSupport(scalingParams->output.tileMode) ) &&
1584 m_hwCaps.m_sfcHwEntry[scalingParams->formatInput].scalingSupported)
1585 {
1586 if (!(OUT_OF_BOUNDS(dwSurfaceWidth, dwSfcInputMinWidth, dwSfcMaxWidth) ||
1587 OUT_OF_BOUNDS(dwSurfaceHeight, dwSfcInputMinHeight, dwSfcMaxHeight) ||
1588 OUT_OF_BOUNDS(dwSourceRegionWidth, dwSfcInputMinWidth, dwSfcMaxWidth) ||
1589 OUT_OF_BOUNDS(dwSourceRegionHeight, dwSfcInputMinHeight, dwSfcMaxHeight) ||
1590 OUT_OF_BOUNDS(dwOutputRegionWidth, dwSfcOutputMinWidth, dwSfcMaxWidth) ||
1591 OUT_OF_BOUNDS(dwOutputRegionHeight, dwSfcOutputMinHeight, dwSfcMaxHeight) ||
1592 OUT_OF_BOUNDS(dwOutputSurfaceWidth, dwSfcOutputMinWidth, dwSfcMaxWidth) ||
1593 OUT_OF_BOUNDS(dwOutputSurfaceHeight, dwDstMinHeight, dwSfcMaxHeight)))
1594 {
1595 if ((m_hwCaps.m_rules.sfcMultiPassSupport.scaling.enable &&
1596 (OUT_OF_BOUNDS(fScaleX, fScaleMin2Pass, fScaleMax2Pass) ||
1597 OUT_OF_BOUNDS(fScaleY, fScaleMin2Pass, fScaleMax2Pass))) ||
1598 ((!m_hwCaps.m_rules.sfcMultiPassSupport.scaling.enable ||
1599 isHdrEnabled) && // Ve HDR + (8, 16] && [1/16, 1/8) scaling on render, not use 2 Pass SFC for scaling,
1600 (OUT_OF_BOUNDS(fScaleX, fScaleMin, fScaleMax) || // since A10R10G10B10/ARGB8 cannot be used as the input of vebox when global IECP being enabled.
1601 OUT_OF_BOUNDS(fScaleY, fScaleMin, fScaleMax))) ||
1602 (scalingParams->scalingPreference == VPHAL_SCALING_PREFER_COMP))
1603 {
1604 // Render Pipe, need to add more conditions next step for multiple SFC mode
1605 // if Render didn't have AVS but Scaling quality mode needed
1606 scalingEngine->bEnabled = 1;
1607 scalingEngine->RenderNeeded = 1;
1608 scalingEngine->fcSupported = 1;
1609 scalingEngine->hdrKernelSupported = 1;
1610 scalingEngine->SfcNeeded = 0;
1611 // Set sfcNotSupported to 1 to avoid SFC being selected without scaling filter.
1612 scalingEngine->sfcNotSupported = 1;
1613 VP_PUBLIC_NORMALMESSAGE("Fc selected. fScaleX %f, fScaleY %f, scalingPreference %d",
1614 fScaleX, fScaleY, scalingParams->scalingPreference);
1615 }
1616 else if (isSfcIscalingNotSupported())
1617 {
1618 scalingEngine->bEnabled = 1;
1619 scalingEngine->RenderNeeded = 1;
1620 scalingEngine->fcSupported = 1;
1621 scalingEngine->SfcNeeded = 0;
1622 scalingEngine->sfcNotSupported = 1;
1623 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since interlaced scaling cannot support offset, rotate or mirror by SFC pipe, fallback to FC.");
1624 }
1625 // SFC feasible
1626 else
1627 {
1628 bool sfc2PassScalingNeededX = OUT_OF_BOUNDS(fScaleX, fScaleMin, fScaleMax);
1629 bool sfc2PassScalingNeededY = OUT_OF_BOUNDS(fScaleY, fScaleMin, fScaleMax);
1630 bool multiPassNeeded= sfc2PassScalingNeededX || sfc2PassScalingNeededY;
1631
1632 scalingEngine->bEnabled = 1;
1633
1634 if (multiPassNeeded && isDIEnabled)
1635 {
1636 scalingEngine->RenderNeeded = 1;
1637 scalingEngine->fcSupported = 1;
1638 // Set sfcNotSupported to 1 to avoid SFC being selected without scaling filter.
1639 scalingEngine->sfcNotSupported = 1;
1640 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since force 2 pass scaling + DI switch to render path.");
1641 }
1642 else if (!m_hwCaps.m_rules.isAvsSamplerSupported && scalingParams->isPrimary && isAlphaSettingSupportedBySfc)
1643 {
1644 // For primary layer, force to use sfc for better quailty.
1645 scalingEngine->SfcNeeded = 1;
1646 scalingEngine->sfc2PassScalingNeededX = sfc2PassScalingNeededX ? 1 : 0;
1647 scalingEngine->sfc2PassScalingNeededY = sfc2PassScalingNeededY ? 1 : 0;
1648 scalingEngine->multiPassNeeded = multiPassNeeded;
1649
1650 if (1 == fScaleX && 1 == fScaleY)
1651 {
1652 VP_PUBLIC_NORMALMESSAGE("Fc can be selected for scale ratio being 1 case on primary, e.g. crop only case.");
1653 scalingEngine->RenderNeeded = 1;
1654 scalingEngine->fcSupported = 1;
1655 scalingEngine->hdrKernelSupported = 1;
1656 }
1657 else
1658 {
1659 scalingEngine->hdrKernelSupported = 1;
1660 }
1661 }
1662 else
1663 {
1664 scalingEngine->RenderNeeded = 1;
1665 scalingEngine->fcSupported = 1;
1666 scalingEngine->hdrKernelSupported = 1;
1667 // For non-primary layer, only consider sfc for non-2-pass case.
1668 if (!sfc2PassScalingNeededX && !sfc2PassScalingNeededY)
1669 {
1670 scalingEngine->SfcNeeded = isAlphaSettingSupportedBySfc;
1671 if (!isAlphaSettingSupportedBySfc)
1672 {
1673 VP_PUBLIC_NORMALMESSAGE("Sfc cannot be used for scaling as alpha not supported by SFC.");
1674 }
1675 }
1676 else
1677 {
1678 // Set sfcNotSupported to 1 to avoid SFC being selected without scaling filter.
1679 scalingEngine->sfcNotSupported = 1;
1680 VP_PUBLIC_NORMALMESSAGE("sfcNotSupported is set to 1 for 2-pass scaling being needed.");
1681 }
1682 }
1683 }
1684 }
1685 else
1686 {
1687 scalingEngine->bEnabled = 1;
1688 scalingEngine->RenderNeeded = 1;
1689 scalingEngine->fcSupported = 1;
1690 scalingEngine->hdrKernelSupported = 1;
1691 scalingEngine->SfcNeeded = 0;
1692 // Set sfcNotSupported to 1 to avoid SFC being selected without scaling filter.
1693 scalingEngine->sfcNotSupported = 1;
1694 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since scaling parameters are not supported by SFC. Switch to Render.");
1695 }
1696 }
1697 else
1698 {
1699 scalingEngine->bEnabled = 1;
1700 scalingEngine->RenderNeeded = 1;
1701 scalingEngine->fcSupported = 1;
1702 scalingEngine->hdrKernelSupported = 1;
1703 scalingEngine->SfcNeeded = 0;
1704 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since format is not supported by SFC. Switch to Render.");
1705 }
1706
1707 PrintFeatureExecutionCaps(__FUNCTION__, *scalingEngine);
1708 return MOS_STATUS_SUCCESS;
1709 }
1710
1711 bool Policy::IsSfcRotationSupported(FeatureParamRotMir *rotationParams)
1712 {
1713 VP_FUNC_CALL();
1714
1715 bool isSfcRotationSupported = false;
1716 if (m_hwCaps.m_sfcHwEntry[rotationParams->formatInput].inputSupported &&
1717 m_hwCaps.m_sfcHwEntry[rotationParams->formatOutput].outputSupported)
1718 {
1719 if (VPHAL_ROTATION_IDENTITY == rotationParams->rotation)
1720 {
1721 isSfcRotationSupported = true;
1722 }
1723 else if (VPHAL_MIRROR_HORIZONTAL == rotationParams->rotation)
1724 {
1725 if (m_hwCaps.m_sfcHwEntry[rotationParams->formatInput].mirrorSupported)
1726 {
1727 isSfcRotationSupported = true;
1728 }
1729 }
1730 else if (rotationParams->rotation <= VPHAL_ROTATION_270)
1731 {
1732 // Rotation w/o mirror case
1733 if (m_hwCaps.m_sfcHwEntry[rotationParams->formatInput].rotationSupported &&
1734 rotationParams->surfInfo.tileOutput == MOS_TILE_Y)
1735 {
1736 isSfcRotationSupported = true;
1737 }
1738 }
1739 else
1740 {
1741 // Rotation w/ mirror case
1742 if (m_hwCaps.m_sfcHwEntry[rotationParams->formatInput].mirrorSupported &&
1743 m_hwCaps.m_sfcHwEntry[rotationParams->formatInput].rotationSupported &&
1744 rotationParams->surfInfo.tileOutput == MOS_TILE_Y)
1745 {
1746 isSfcRotationSupported = true;
1747 }
1748 }
1749 }
1750
1751 VP_PUBLIC_NORMALMESSAGE("Is rotation supported by sfc: %d", isSfcRotationSupported ? 1 : 0);
1752 return isSfcRotationSupported;
1753 }
1754
1755 MOS_STATUS Policy::GetRotationExecutionCaps(SwFilter* feature)
1756 {
1757 VP_FUNC_CALL();
1758
1759 VP_PUBLIC_CHK_NULL_RETURN(feature);
1760 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
1761 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
1762
1763 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
1764 bool disableSfc = userFeatureControl->IsSfcDisabled();
1765 SwFilterRotMir* rotation = (SwFilterRotMir*)feature;
1766 FeatureParamRotMir *rotationParams = &rotation->GetSwFilterParams();
1767 VP_EngineEntry *rotationEngine = &rotation->GetFilterEngineCaps();
1768
1769 // Clean usedForNextPass flag.
1770 if (rotationEngine->usedForNextPass)
1771 {
1772 rotationEngine->usedForNextPass = false;
1773 }
1774 if (rotationEngine->value != 0)
1775 {
1776 VP_PUBLIC_NORMALMESSAGE("Scaling Feature Already been processed, Skip further process");
1777
1778 PrintFeatureExecutionCaps(__FUNCTION__, *rotationEngine);
1779 return MOS_STATUS_SUCCESS;
1780 }
1781
1782 if (rotationParams->rotation == VPHAL_ROTATION_IDENTITY)
1783 {
1784 // for non-rotation cases, all engine supported
1785 rotationEngine->bEnabled = 0;
1786 rotationEngine->VeboxNeeded = 0;
1787 rotationEngine->SfcNeeded = 0;
1788 rotationEngine->RenderNeeded = 0;
1789 rotationEngine->forceEnableForSfc = 1;
1790 rotationEngine->forceEnableForHdrKernel = 1;
1791 PrintFeatureExecutionCaps(__FUNCTION__, *rotationEngine);
1792 return MOS_STATUS_SUCCESS;
1793 }
1794
1795 rotationEngine->bEnabled = 1;
1796 rotationEngine->RenderNeeded = 1;
1797 rotationEngine->fcSupported = 1;
1798 rotationEngine->hdrKernelSupported = 1;
1799
1800 if (disableSfc)
1801 {
1802 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since force rotation to FC. disableSfc %d", disableSfc);
1803 PrintFeatureExecutionCaps(__FUNCTION__, *rotationEngine);
1804 return MOS_STATUS_SUCCESS;
1805 }
1806
1807 rotationEngine->SfcNeeded = IsSfcRotationSupported(rotationParams);
1808
1809 PrintFeatureExecutionCaps(__FUNCTION__, *rotationEngine);
1810 return MOS_STATUS_SUCCESS;
1811 }
1812
1813 MOS_STATUS Policy::GetDenoiseExecutionCaps(SwFilter* feature)
1814 {
1815 VP_FUNC_CALL();
1816 VP_PUBLIC_CHK_NULL_RETURN(feature);
1817
1818 SwFilterDenoise* denoise = dynamic_cast<SwFilterDenoise*>(feature);
1819 VP_PUBLIC_CHK_NULL_RETURN(denoise);
1820
1821 FeatureParamDenoise& denoiseParams = denoise->GetSwFilterParams();
1822 VP_EngineEntry& denoiseEngine = denoise->GetFilterEngineCaps();
1823 MOS_FORMAT inputformat = denoiseParams.formatInput;
1824
1825 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
1826 if (inputformat < 0)
1827 {
1828 inputformat = Format_Any;
1829 }
1830
1831 uint32_t widthAlignUint = m_hwCaps.m_veboxHwEntry[inputformat].horizontalAlignUnit;
1832 uint32_t heightAlignUnit = m_hwCaps.m_veboxHwEntry[inputformat].verticalAlignUnit;
1833
1834 if (denoiseEngine.value != 0)
1835 {
1836 VP_PUBLIC_NORMALMESSAGE("Scaling Feature Already been processed, Skip further process");
1837 PrintFeatureExecutionCaps(__FUNCTION__, denoiseEngine);
1838 return MOS_STATUS_SUCCESS;
1839 }
1840
1841 if (m_hwCaps.m_veboxHwEntry[inputformat].denoiseSupported)
1842 {
1843 if (denoiseParams.denoiseParams.bEnableHVSDenoise)
1844 {
1845 denoiseParams.stage = DN_STAGE_HVS_KERNEL;
1846 denoiseEngine.bEnabled = 1;
1847 denoiseEngine.isolated = 1;
1848 denoiseEngine.RenderNeeded = 1;
1849 denoise->SetRenderTargetType(RenderTargetType::RenderTargetTypeParameter);
1850 VP_PUBLIC_NORMALMESSAGE("DN_STAGE_HVS_KERNEL");
1851 }
1852 else
1853 {
1854 denoiseParams.stage = DN_STAGE_DEFAULT;
1855 widthAlignUint = MOS_ALIGN_CEIL(m_hwCaps.m_veboxHwEntry[inputformat].horizontalAlignUnit, 2);
1856
1857 if (inputformat == Format_NV12 ||
1858 inputformat == Format_P010 ||
1859 inputformat == Format_P016)
1860 {
1861 heightAlignUnit = MOS_ALIGN_CEIL(m_hwCaps.m_veboxHwEntry[inputformat].verticalAlignUnit, 4);
1862 }
1863 else
1864 {
1865 heightAlignUnit = MOS_ALIGN_CEIL(m_hwCaps.m_veboxHwEntry[inputformat].verticalAlignUnit, 2);
1866 }
1867
1868 if (MOS_IS_ALIGNED(MOS_MIN(denoiseParams.heightInput, denoiseParams.srcBottom), heightAlignUnit))
1869 {
1870 denoiseEngine.bEnabled = 1;
1871 denoiseEngine.VeboxNeeded = 1;
1872 }
1873 else
1874 {
1875 VP_PUBLIC_NORMALMESSAGE("Denoise Feature is disabled since min of heightInput (%d) and srcBottom (%d) not being %d aligned.", denoiseParams.heightInput, denoiseParams.srcBottom, heightAlignUnit);
1876 }
1877 }
1878 }
1879
1880 denoiseParams.widthAlignUnitInput = widthAlignUint;
1881 denoiseParams.heightAlignUnitInput = heightAlignUnit;
1882
1883 PrintFeatureExecutionCaps(__FUNCTION__, denoiseEngine);
1884 return MOS_STATUS_SUCCESS;
1885 }
1886
1887 MOS_STATUS Policy::GetDeinterlaceExecutionCaps(SwFilter* feature, bool forceDIToRender)
1888 {
1889 VP_FUNC_CALL();
1890 VP_PUBLIC_CHK_NULL_RETURN(feature);
1891
1892 SwFilterDeinterlace *swFilterDi = dynamic_cast<SwFilterDeinterlace*>(feature);
1893 VP_PUBLIC_CHK_NULL_RETURN(swFilterDi);
1894 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
1895 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
1896 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
1897 bool disableVeboxOutput = userFeatureControl->IsVeboxOutputDisabled();
1898 bool disableSfc = userFeatureControl->IsSfcDisabled();
1899
1900 FeatureParamDeinterlace &diParams = swFilterDi->GetSwFilterParams();
1901 VP_EngineEntry &diEngine = swFilterDi->GetFilterEngineCaps();
1902 MOS_FORMAT inputformat = diParams.formatInput;
1903
1904 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
1905 if (inputformat < 0)
1906 {
1907 inputformat = Format_Any;
1908 }
1909
1910 if (diEngine.value != 0)
1911 {
1912 VP_PUBLIC_NORMALMESSAGE("DI Feature Already been processed, Skip further process.");
1913 PrintFeatureExecutionCaps(__FUNCTION__, diEngine);
1914 return MOS_STATUS_SUCCESS;
1915 }
1916
1917 if (!m_hwCaps.m_veboxHwEntry[inputformat].deinterlaceSupported)
1918 {
1919 diEngine.bEnabled = 1;
1920 diEngine.RenderNeeded = 1;
1921 diEngine.fcSupported = 1;
1922 diEngine.VeboxNeeded = 0;
1923 PrintFeatureExecutionCaps(__FUNCTION__, diEngine);
1924 return MOS_STATUS_SUCCESS;
1925 }
1926
1927 if (nullptr == diParams.diParams ||
1928 (!MOS_IS_ALIGNED(MOS_MIN((uint32_t)diParams.heightInput, (uint32_t)diParams.rcSrc.bottom), 4) &&
1929 (diParams.formatInput == Format_P010 ||
1930 diParams.formatInput == Format_P016 ||
1931 diParams.formatInput == Format_NV12)))
1932 {
1933 diEngine.bEnabled = 0;
1934 diEngine.RenderNeeded = 0;
1935 diEngine.fcSupported = 0;
1936 diEngine.VeboxNeeded = 0;
1937 PrintFeatureExecutionCaps(__FUNCTION__, diEngine);
1938 return MOS_STATUS_SUCCESS;
1939 }
1940
1941 if (forceDIToRender && diParams.diParams)
1942 {
1943 diEngine.bEnabled = 1;
1944 diEngine.RenderNeeded = 1;
1945 diEngine.fcSupported = 1;
1946 diEngine.VeboxNeeded = 0;
1947 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since force to render for 2 pass scaling + DI.");
1948 PrintFeatureExecutionCaps(__FUNCTION__, diEngine);
1949 return MOS_STATUS_SUCCESS;
1950 }
1951
1952 if (m_vpInterface.GetResourceManager()->IsRefValid() &&
1953 m_vpInterface.GetResourceManager()->IsSameSamples())
1954 {
1955 diEngine.bypassVeboxFeatures = 1;
1956 diEngine.diProcess2ndField = 1;
1957 }
1958 else
1959 {
1960 if (diParams.diParams->DIMode == DI_MODE_BOB)
1961 {
1962 diEngine.bEnabled = 1;
1963 diEngine.RenderNeeded = 1;
1964 diEngine.fcSupported = 1;
1965
1966 // to align with case design, if disableSfc == 1, force di to render
1967 if (disableSfc)
1968 {
1969 diEngine.VeboxNeeded = 0;
1970 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) since force DI to render.");
1971 }
1972 else
1973 {
1974 diEngine.VeboxNeeded = 1;
1975 }
1976 }
1977 else
1978 {
1979 diEngine.bEnabled = 1;
1980 diEngine.RenderNeeded = 0;
1981 diEngine.fcSupported = 0;
1982 diEngine.VeboxNeeded = 1;
1983 }
1984 }
1985
1986 PrintFeatureExecutionCaps(__FUNCTION__, diEngine);
1987 VP_PUBLIC_NORMALMESSAGE("Di mode = %d", diParams.diParams->DIMode);
1988 return MOS_STATUS_SUCCESS;
1989 }
1990
1991 MOS_STATUS Policy::GetSteExecutionCaps(SwFilter* feature)
1992 {
1993 VP_FUNC_CALL();
1994 VP_PUBLIC_CHK_NULL_RETURN(feature);
1995
1996 SwFilterSte* steFilter = dynamic_cast<SwFilterSte*>(feature);
1997 VP_PUBLIC_CHK_NULL_RETURN(steFilter);
1998
1999 FeatureParamSte& steParams = steFilter->GetSwFilterParams();
2000 VP_EngineEntry& steEngine = steFilter->GetFilterEngineCaps();
2001 MOS_FORMAT inputformat = steParams.formatInput;
2002
2003 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2004 if (inputformat < 0)
2005 {
2006 inputformat = Format_Any;
2007 }
2008
2009 if (steEngine.value != 0)
2010 {
2011 VP_PUBLIC_NORMALMESSAGE("ACE Feature Already been processed, Skip further process");
2012 PrintFeatureExecutionCaps(__FUNCTION__, steEngine);
2013 return MOS_STATUS_SUCCESS;
2014 }
2015
2016 if (m_hwCaps.m_veboxHwEntry[inputformat].steSupported &&
2017 m_hwCaps.m_veboxHwEntry[inputformat].inputSupported &&
2018 m_hwCaps.m_veboxHwEntry[inputformat].iecp)
2019 {
2020 steEngine.bEnabled = 1;
2021 steEngine.VeboxNeeded = 1;
2022 steEngine.VeboxIECPNeeded = 1;
2023 }
2024
2025 PrintFeatureExecutionCaps(__FUNCTION__, steEngine);
2026 return MOS_STATUS_SUCCESS;
2027 }
2028
2029 MOS_STATUS Policy::GetTccExecutionCaps(SwFilter* feature)
2030 {
2031 VP_FUNC_CALL();
2032 VP_PUBLIC_CHK_NULL_RETURN(feature);
2033
2034 SwFilterTcc* tccFilter = dynamic_cast<SwFilterTcc*>(feature);
2035 VP_PUBLIC_CHK_NULL_RETURN(tccFilter);
2036
2037 FeatureParamTcc& tccParams = tccFilter->GetSwFilterParams();
2038 VP_EngineEntry& tccEngine = tccFilter->GetFilterEngineCaps();
2039 MOS_FORMAT inputformat = tccParams.formatInput;
2040
2041 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2042 if (inputformat < 0)
2043 {
2044 inputformat = Format_Any;
2045 }
2046
2047 if (tccEngine.value != 0)
2048 {
2049 VP_PUBLIC_NORMALMESSAGE("TCC Feature Already been processed, Skip further process");
2050 PrintFeatureExecutionCaps(__FUNCTION__, tccEngine);
2051 return MOS_STATUS_SUCCESS;
2052 }
2053
2054 if (m_hwCaps.m_veboxHwEntry[inputformat].inputSupported &&
2055 m_hwCaps.m_veboxHwEntry[inputformat].iecp &&
2056 m_hwCaps.m_veboxHwEntry[inputformat].tccSupported)
2057 {
2058 tccEngine.bEnabled = 1;
2059 tccEngine.VeboxNeeded = 1;
2060 tccEngine.VeboxIECPNeeded = 1;
2061 }
2062
2063 PrintFeatureExecutionCaps(__FUNCTION__, tccEngine);
2064 return MOS_STATUS_SUCCESS;
2065 }
2066
2067 MOS_STATUS Policy::GetProcampExecutionCaps(SwFilter* feature)
2068 {
2069 VP_FUNC_CALL();
2070 VP_PUBLIC_CHK_NULL_RETURN(feature);
2071
2072 SwFilterProcamp* procampFilter = dynamic_cast<SwFilterProcamp*>(feature);
2073 VP_PUBLIC_CHK_NULL_RETURN(procampFilter);
2074 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
2075 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
2076
2077 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
2078 FeatureParamProcamp& procampParams = procampFilter->GetSwFilterParams();
2079 VP_EngineEntry& procampEngine = procampFilter->GetFilterEngineCaps();
2080 MOS_FORMAT inputformat = procampParams.formatInput;
2081
2082 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2083 if (inputformat < 0)
2084 {
2085 inputformat = Format_Any;
2086 }
2087
2088 if (procampEngine.value != 0)
2089 {
2090 VP_PUBLIC_NORMALMESSAGE("Procamp Feature Already been processed, Skip further process");
2091 PrintFeatureExecutionCaps(__FUNCTION__, procampEngine);
2092 return MOS_STATUS_SUCCESS;
2093 }
2094
2095 procampEngine.bEnabled = 1;
2096 procampEngine.RenderNeeded = 1;
2097 procampEngine.fcSupported = 1;
2098
2099 if (m_hwCaps.m_veboxHwEntry[inputformat].inputSupported &&
2100 m_hwCaps.m_veboxHwEntry[inputformat].iecp)
2101 {
2102 procampEngine.VeboxNeeded = 1;
2103 procampEngine.VeboxIECPNeeded = 1;
2104 }
2105
2106 PrintFeatureExecutionCaps(__FUNCTION__, procampEngine);
2107 return MOS_STATUS_SUCCESS;
2108 }
2109
2110 MOS_STATUS Policy::GetHdrExecutionCaps(SwFilter *feature)
2111 {
2112 VP_FUNC_CALL();
2113 VP_PUBLIC_CHK_NULL_RETURN(feature);
2114 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
2115 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
2116
2117 SwFilterHdr *hdrFilter = dynamic_cast<SwFilterHdr *>(feature);
2118 VP_PUBLIC_CHK_NULL_RETURN(hdrFilter);
2119
2120 FeatureParamHdr *hdrParams = &hdrFilter->GetSwFilterParams();
2121
2122 VP_EngineEntry *pHDREngine = &hdrFilter->GetFilterEngineCaps();
2123 MOS_FORMAT inputformat = hdrParams->formatInput;
2124 uint32_t dwSurfaceWidth = 0, dwSurfaceHeight = 0;
2125 uint32_t veboxMinWidth = 0, veboxMaxWidth = 0;
2126 uint32_t veboxMinHeight = 0, veboxMaxHeight = 0;
2127 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
2128 bool disableVeboxOutput = userFeatureControl->IsVeboxOutputDisabled();
2129 bool disableSfc = userFeatureControl->IsSfcDisabled();
2130
2131 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2132 if (inputformat < 0)
2133 {
2134 inputformat = Format_Any;
2135 }
2136
2137 if (pHDREngine->value != 0)
2138 {
2139 VP_PUBLIC_NORMALMESSAGE("HDR Feature Already been processed, Skip further process");
2140 if (HDR_STAGE_VEBOX_3DLUT_UPDATE == hdrParams->stage)
2141 {
2142 VP_PUBLIC_NORMALMESSAGE("HDR_STAGE_VEBOX_3DLUT_UPDATE");
2143 }
2144 PrintFeatureExecutionCaps(__FUNCTION__, *pHDREngine);
2145 return MOS_STATUS_SUCCESS;
2146 }
2147
2148 veboxMinWidth = m_hwCaps.m_veboxHwEntry[hdrParams->formatInput].minWidth;
2149 veboxMaxWidth = m_hwCaps.m_veboxHwEntry[hdrParams->formatInput].maxWidth;
2150 veboxMinHeight = m_hwCaps.m_veboxHwEntry[hdrParams->formatInput].minHeight;
2151 veboxMaxHeight = m_hwCaps.m_veboxHwEntry[hdrParams->formatInput].maxHeight;
2152
2153
2154 if (disableVeboxOutput && disableSfc ||
2155 OUT_OF_BOUNDS(hdrParams->widthInput, veboxMinWidth, veboxMaxWidth) ||
2156 OUT_OF_BOUNDS(hdrParams->heightInput, veboxMinHeight, veboxMaxHeight) ||
2157 !m_hwCaps.m_veboxHwEntry[hdrParams->formatInput].inputSupported ||
2158 !m_hwCaps.m_veboxHwEntry[hdrParams->formatInput].hdrSupported)
2159 {
2160 pHDREngine->bEnabled = 1;
2161 pHDREngine->VeboxNeeded = 0;
2162 pHDREngine->RenderNeeded = 1;
2163 pHDREngine->hdrKernelNeeded = 1;
2164 pHDREngine->hdrKernelSupported = 1;
2165 VP_PUBLIC_NORMALMESSAGE("Hdr render is selected. Input Resolution %dx%d, Input Format %d",
2166 hdrParams->widthInput, hdrParams->heightInput, hdrParams->formatInput);
2167 PrintFeatureExecutionCaps(__FUNCTION__, *pHDREngine);
2168 return MOS_STATUS_SUCCESS;
2169 }
2170
2171 if (IsHDR33LutSizeSupported() && (hdrParams->hdrMode == VPHAL_HDR_MODE_H2H))
2172 {
2173 hdrParams->lutSize = LUT33_SEG_SIZE;
2174 pHDREngine->isHdr33LutSizeEnabled = true;
2175 VP_RENDER_NORMALMESSAGE("3DLut table is used 33 lutsize.");
2176 }
2177 else
2178 {
2179 hdrParams->lutSize = LUT65_SEG_SIZE;
2180 pHDREngine->isHdr33LutSizeEnabled = false;
2181 VP_RENDER_NORMALMESSAGE("3DLut table is used 65 lutsize.");
2182 }
2183
2184 pHDREngine->is1K1DLutSurfaceInUse = m_hwCaps.m_rules.is1K1DLutSurfaceInUse;
2185 if (hdrParams->external3DLutParams && userFeatureControl->IsExternal3DLutSupport())
2186 {
2187 hdrParams->stage = HDR_STAGE_VEBOX_EXTERNAL_3DLUT;
2188 pHDREngine->bEnabled = 1;
2189 pHDREngine->VeboxNeeded = 1;
2190 if (hdrParams->formatOutput == Format_A8B8G8R8 || hdrParams->formatOutput == Format_A8R8G8B8)
2191 {
2192 pHDREngine->VeboxARGBOut = 1;
2193 }
2194 else if (hdrParams->formatOutput == Format_B10G10R10A2 || hdrParams->formatOutput == Format_R10G10B10A2)
2195 {
2196 pHDREngine->VeboxARGB10bitOutput = 1;
2197 }
2198 VP_PUBLIC_NORMALMESSAGE("3DLUT table setup by API, use HDR_STAGE_VEBOX_EXTERNAL_3DLUT.");
2199 return MOS_STATUS_SUCCESS;
2200 }
2201 else if (Is3DLutKernelSupported())
2202 {
2203 if (userFeatureControl->Is3DLutKernelOnly())
2204 {
2205 hdrParams->is3DLutKernelOnly = true;
2206 }
2207
2208 if (hdrParams->uiMaxContentLevelLum != m_savedMaxCLL || hdrParams->uiMaxDisplayLum != m_savedMaxDLL ||
2209 hdrParams->hdrMode != m_savedHdrMode)
2210 {
2211 m_savedMaxCLL = hdrParams->uiMaxContentLevelLum;
2212 m_savedMaxDLL = hdrParams->uiMaxDisplayLum;
2213 m_savedHdrMode = hdrParams->hdrMode;
2214
2215 hdrParams->stage = HDR_STAGE_3DLUT_KERNEL;
2216 pHDREngine->bEnabled = 1;
2217 pHDREngine->isolated = 1;
2218 pHDREngine->RenderNeeded = 1;
2219 hdrFilter->SetRenderTargetType(RenderTargetType::RenderTargetTypeParameter);
2220 VP_PUBLIC_NORMALMESSAGE("HDR_STAGE_3DLUT_KERNEL");
2221 // For next stage, will be updated during UpdateFeaturePipe.
2222 }
2223 else
2224 {
2225 hdrParams->stage = HDR_STAGE_VEBOX_3DLUT_NO_UPDATE;
2226 pHDREngine->bEnabled = 1;
2227 pHDREngine->VeboxNeeded = 1;
2228 hdrFilter->SetRenderTargetType(RenderTargetType::RenderTargetTypeSurface);
2229 if (hdrParams->formatOutput == Format_A8B8G8R8 || hdrParams->formatOutput == Format_A8R8G8B8)
2230 {
2231 pHDREngine->VeboxARGBOut = 1;
2232 }
2233 else if (hdrParams->formatOutput == Format_B10G10R10A2 || hdrParams->formatOutput == Format_R10G10B10A2)
2234 {
2235 pHDREngine->VeboxARGB10bitOutput = 1;
2236 }
2237
2238 pHDREngine->isH2S = hdrParams->hdrMode == VPHAL_HDR_MODE_TONE_MAPPING;
2239
2240 VP_PUBLIC_NORMALMESSAGE("HDR_STAGE_VEBOX_3DLUT_NO_UPDATE");
2241 }
2242 }
2243 else
2244 {
2245 hdrParams->stage = HDR_STAGE_DEFAULT;
2246 pHDREngine->bEnabled = 1;
2247 pHDREngine->VeboxNeeded = 1;
2248 if (hdrParams->formatOutput == Format_A8B8G8R8 || hdrParams->formatOutput == Format_A8R8G8B8)
2249 {
2250 pHDREngine->VeboxARGBOut = 1;
2251 }
2252 else if (hdrParams->formatOutput == Format_B10G10R10A2 || hdrParams->formatOutput == Format_R10G10B10A2)
2253 {
2254 pHDREngine->VeboxARGB10bitOutput = 1;
2255 }
2256
2257 pHDREngine->isH2S = hdrParams->hdrMode == VPHAL_HDR_MODE_TONE_MAPPING;
2258
2259 VP_PUBLIC_NORMALMESSAGE("HDR_STAGE_DEFAULT");
2260 }
2261
2262 PrintFeatureExecutionCaps(__FUNCTION__, *pHDREngine);
2263 return MOS_STATUS_SUCCESS;
2264 }
2265
2266 MOS_STATUS Policy::GetColorFillExecutionCaps(SwFilter* feature)
2267 {
2268 VP_FUNC_CALL();
2269 VP_PUBLIC_CHK_NULL_RETURN(feature);
2270
2271 SwFilterColorFill* filter = dynamic_cast<SwFilterColorFill*>(feature);
2272 VP_PUBLIC_CHK_NULL_RETURN(filter);
2273 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
2274 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
2275
2276 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
2277 bool disableSfc = userFeatureControl->IsSfcDisabled();
2278 FeatureParamColorFill& params = filter->GetSwFilterParams();
2279 VP_EngineEntry& engine = filter->GetFilterEngineCaps();
2280 MOS_FORMAT inputformat = params.formatInput;
2281
2282 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2283 if (inputformat < 0)
2284 {
2285 inputformat = Format_Any;
2286 }
2287
2288 if (engine.value != 0)
2289 {
2290 VP_PUBLIC_NORMALMESSAGE("ColorFill Feature Already been processed, Skip further process");
2291 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2292 return MOS_STATUS_SUCCESS;
2293 }
2294
2295 engine.bEnabled = 1;
2296 engine.RenderNeeded = 1;
2297 engine.fcSupported = 1;
2298 // For disableSfc case, sfc will be filtered in SwFilterColorFill::GetCombinedFilterEngineCaps
2299 // with scaling setting.
2300 engine.SfcNeeded = !disableSfc; // For SFC, the parameter in scaling is used.
2301
2302 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2303 return MOS_STATUS_SUCCESS;
2304 }
2305
2306 MOS_STATUS Policy::GetAlphaExecutionCaps(SwFilter* feature)
2307 {
2308 VP_FUNC_CALL();
2309 VP_PUBLIC_CHK_NULL_RETURN(feature);
2310
2311 SwFilterAlpha* filter = dynamic_cast<SwFilterAlpha*>(feature);
2312 VP_PUBLIC_CHK_NULL_RETURN(filter);
2313 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
2314 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
2315
2316 auto userFeatureControl = m_vpInterface.GetHwInterface()->m_userFeatureControl;
2317 bool disableSfc = userFeatureControl->IsSfcDisabled();
2318 FeatureParamAlpha& params = filter->GetSwFilterParams();
2319 VP_EngineEntry& engine = filter->GetFilterEngineCaps();
2320 MOS_FORMAT inputformat = params.formatInput;
2321
2322 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2323 if (inputformat < 0)
2324 {
2325 inputformat = Format_Any;
2326 }
2327
2328 if (engine.value != 0)
2329 {
2330 VP_PUBLIC_NORMALMESSAGE("Alpha Feature Already been processed, Skip further process");
2331 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2332 return MOS_STATUS_SUCCESS;
2333 }
2334 engine.bEnabled = 1;
2335 engine.RenderNeeded = 1;
2336 engine.fcSupported = 1;
2337
2338 // For Vebox, the alpha parameter in csc is used.
2339 engine.VeboxNeeded = IsAlphaSettingSupportedByVebox(params.formatInput, params.formatOutput, params.compAlpha);
2340
2341 if (disableSfc)
2342 {
2343 engine.SfcNeeded = false;
2344 }
2345 else
2346 {
2347 // For SFC, the alpha parameter in scaling is used.
2348 engine.SfcNeeded = IsAlphaSettingSupportedBySfc(params.formatInput, params.formatOutput, params.compAlpha);
2349 }
2350
2351 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2352 return MOS_STATUS_SUCCESS;
2353 }
2354
2355 MOS_STATUS Policy::GetLumakeyExecutionCaps(SwFilter* feature)
2356 {
2357 VP_FUNC_CALL();
2358 VP_PUBLIC_CHK_NULL_RETURN(feature);
2359
2360 SwFilterLumakey* filter = dynamic_cast<SwFilterLumakey*>(feature);
2361 VP_PUBLIC_CHK_NULL_RETURN(filter);
2362
2363 FeatureParamLumakey& params = filter->GetSwFilterParams();
2364 VP_EngineEntry& engine = filter->GetFilterEngineCaps();
2365 MOS_FORMAT inputformat = params.formatInput;
2366
2367 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2368 if (inputformat < 0)
2369 {
2370 inputformat = Format_Any;
2371 }
2372
2373 if (engine.value != 0)
2374 {
2375 VP_PUBLIC_NORMALMESSAGE("Lumakey Feature Already been processed, Skip further process");
2376 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2377 return MOS_STATUS_SUCCESS;
2378 }
2379
2380 engine.bEnabled = 1;
2381 engine.RenderNeeded = 1;
2382 engine.fcSupported = 1;
2383
2384 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2385 return MOS_STATUS_SUCCESS;
2386 }
2387
2388 MOS_STATUS Policy::GetBlendingExecutionCaps(SwFilter* feature)
2389 {
2390 VP_FUNC_CALL();
2391 VP_PUBLIC_CHK_NULL_RETURN(feature);
2392
2393 SwFilterBlending* filter = dynamic_cast<SwFilterBlending*>(feature);
2394 VP_PUBLIC_CHK_NULL_RETURN(filter);
2395
2396 FeatureParamBlending& params = filter->GetSwFilterParams();
2397 VP_EngineEntry& engine = filter->GetFilterEngineCaps();
2398 MOS_FORMAT inputformat = params.formatInput;
2399
2400 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2401 if (inputformat < 0)
2402 {
2403 inputformat = Format_Any;
2404 }
2405
2406 if (engine.value != 0)
2407 {
2408 VP_PUBLIC_NORMALMESSAGE("Blending Feature Already been processed, Skip further process");
2409 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2410 return MOS_STATUS_SUCCESS;
2411 }
2412
2413 engine.bEnabled = 1;
2414 engine.RenderNeeded = 1;
2415 engine.fcSupported = 1;
2416
2417 PrintFeatureExecutionCaps(__FUNCTION__, engine);
2418 return MOS_STATUS_SUCCESS;
2419 }
2420
2421 MOS_STATUS Policy::GetCgcExecutionCaps(SwFilter* feature)
2422 {
2423 VP_FUNC_CALL();
2424 VP_PUBLIC_CHK_NULL_RETURN(feature);
2425
2426 SwFilterCgc* cgcFilter = dynamic_cast<SwFilterCgc*>(feature);
2427 VP_PUBLIC_CHK_NULL_RETURN(cgcFilter);
2428
2429 FeatureParamCgc& cgcParams = cgcFilter->GetSwFilterParams();
2430 VP_EngineEntry& cgcEngine = cgcFilter->GetFilterEngineCaps();
2431 MOS_FORMAT inputformat = cgcParams.formatInput;
2432
2433 // MOS_FORMAT is [-14,103], cannot use -14~-1 as index for m_veboxHwEntry
2434 if (inputformat < 0)
2435 {
2436 inputformat = Format_Any;
2437 }
2438
2439 if (cgcEngine.value != 0)
2440 {
2441 VP_PUBLIC_NORMALMESSAGE("CGC Feature Already been processed, Skip further process");
2442 PrintFeatureExecutionCaps(__FUNCTION__, cgcEngine);
2443 return MOS_STATUS_SUCCESS;
2444 }
2445
2446 if (m_hwCaps.m_veboxHwEntry[inputformat].inputSupported &&
2447 m_hwCaps.m_veboxHwEntry[inputformat].iecp &&
2448 m_hwCaps.m_veboxHwEntry[inputformat].cgcSupported)
2449 {
2450 cgcEngine.bEnabled = 1;
2451 cgcEngine.VeboxNeeded = 1;
2452 cgcEngine.VeboxIECPNeeded = 1;
2453 cgcEngine.bt2020ToRGB = cgcParams.bBt2020ToRGB;
2454 }
2455
2456 PrintFeatureExecutionCaps(__FUNCTION__, cgcEngine);
2457 return MOS_STATUS_SUCCESS;
2458 }
2459
2460 MOS_STATUS Policy::GetExecutionCapsForAiSwFilterSubPipe(SwFilterAiBase *swAiFilter, VP_EngineEntry &engineCapsCombined)
2461 {
2462 VP_FUNC_CALL();
2463 VP_PUBLIC_CHK_NULL_RETURN(swAiFilter);
2464 FeatureParamAi &aiParams = swAiFilter->GetSwFilterParams();
2465 VP_EngineEntry &aiEngine = swAiFilter->GetFilterEngineCaps();
2466
2467 if (aiEngine.value != 0)
2468 {
2469 VP_PUBLIC_NORMALMESSAGE("AI Feature %d Already been processed, Skip further process", swAiFilter->GetFeatureType());
2470 PrintFeatureExecutionCaps(__FUNCTION__, aiEngine);
2471 }
2472 else
2473 {
2474 uint32_t index = 0;
2475 if (aiParams.stageIndex == 0)
2476 {
2477 index = 0;
2478 }
2479 else if (aiParams.splitGroupIndex.size() > (aiParams.stageIndex - 1))
2480 {
2481 VP_PUBLIC_ASSERTMESSAGE("The stage index > 0 should be processed in PolicyAiHandler::UpdateFeaturePipe");
2482 index = aiParams.splitGroupIndex.at(aiParams.stageIndex - 1);
2483 }
2484 else
2485 {
2486 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
2487 }
2488
2489 if (aiParams.settings.size() > index)
2490 {
2491 aiEngine.bEnabled = true;
2492 aiEngine.isolated = true;
2493 aiEngine.multiPassNeeded = aiParams.stageIndex < aiParams.splitGroupIndex.size();
2494 if (aiParams.splitGroupIndex.empty())
2495 {
2496 aiEngine.isOutputPipeNeeded = true;
2497 }
2498 if (aiParams.settings.at(index)->engine == FEATURE_AI_ENGINE::NPU)
2499 {
2500 aiEngine.npuNeeded = true;
2501 }
2502 else
2503 {
2504 aiEngine.RenderNeeded = true;
2505 }
2506 }
2507 else
2508 {
2509 VP_PUBLIC_ASSERTMESSAGE(
2510 "This SwFilterSubPipe contains a SwFilterAiFilter, but the Ai Kernel Pipe Setting inside this SwFilterAiFilter is empty. \
2511 This will result in not only bypassing all other features, but also the AI feature itself will not execute anything. Feature Type %d",
2512 swAiFilter->GetFeatureType());
2513 }
2514 PrintFeatureExecutionCaps(__FUNCTION__, aiEngine);
2515 }
2516
2517 engineCapsCombined.value |= aiEngine.value;
2518
2519 MT_LOG7(MT_VP_HAL_POLICY_GET_EXTCAPS4FTR, MT_NORMAL, MT_VP_HAL_FEATUERTYPE, swAiFilter->GetFeatureType(), MT_VP_HAL_ENGINECAPS, int64_t(aiEngine.value),
2520 MT_VP_HAL_ENGINECAPS_EN, int64_t(aiEngine.bEnabled), MT_VP_HAL_ENGINECAPS_VE_NEEDED, int64_t(aiEngine.VeboxNeeded),
2521 MT_VP_HAL_ENGINECAPS_SFC_NEEDED, int64_t(aiEngine.SfcNeeded), MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, int64_t(aiEngine.RenderNeeded),
2522 MT_VP_HAL_ENGINECAPS_FC_SUPPORT, int64_t(aiEngine.fcSupported));
2523
2524 return MOS_STATUS_SUCCESS;
2525 }
2526
2527 MOS_STATUS Policy::GetExecutionCaps(SwFilter* feature)
2528 {
2529 VP_FUNC_CALL();
2530
2531 VP_PUBLIC_CHK_NULL_RETURN(feature);
2532
2533 VP_EngineEntry &defaultEngine = feature->GetFilterEngineCaps();
2534 defaultEngine.value = 0;
2535
2536 PrintFeatureExecutionCaps(__FUNCTION__, defaultEngine);
2537 return MOS_STATUS_SUCCESS;
2538 }
2539
2540 MOS_STATUS Policy::InitExecuteCaps(VP_EXECUTE_CAPS &caps, VP_EngineEntry &engineCapsInputPipe, VP_EngineEntry &engineCapsOutputPipe)
2541 {
2542 caps.value = 0;
2543
2544 if (0 == engineCapsInputPipe.value)
2545 {
2546 caps.bOutputPipeFeatureInuse = engineCapsOutputPipe.bEnabled;
2547 // For color fill w/o input surface case, engineCapsOutputPipe.fcOnlyFeatureExists should be set.
2548 if (0 == engineCapsOutputPipe.value || engineCapsOutputPipe.nonFcFeatureExists || !engineCapsOutputPipe.fcOnlyFeatureExists)
2549 {
2550 caps.bVebox = true;
2551 caps.bIECP = engineCapsOutputPipe.VeboxIECPNeeded;
2552 caps.bSFC = engineCapsOutputPipe.nonVeboxFeatureExists;
2553 }
2554 else
2555 {
2556 caps.bRender = 1;
2557 caps.bComposite = 1;
2558 }
2559 }
2560 else if (engineCapsInputPipe.isolated)
2561 {
2562 caps.bTemperalInputInuse = engineCapsInputPipe.bTemperalInputInuse;
2563 if (engineCapsInputPipe.VeboxNeeded != 0 || engineCapsInputPipe.SfcNeeded != 0)
2564 {
2565 caps.bVebox = true;
2566 caps.bIECP = engineCapsInputPipe.VeboxIECPNeeded;
2567 caps.bSFC = engineCapsInputPipe.SfcNeeded != 0;
2568 }
2569 else if (engineCapsInputPipe.RenderNeeded)
2570 {
2571 caps.bRender = 1;
2572
2573 if (engineCapsInputPipe.isOutputPipeNeeded)
2574 {
2575 caps.bOutputPipeFeatureInuse = true;
2576 }
2577 }
2578 else if (engineCapsInputPipe.npuNeeded)
2579 {
2580 caps.bNpu = 1;
2581 if (engineCapsInputPipe.isOutputPipeNeeded)
2582 {
2583 caps.bOutputPipeFeatureInuse = true;
2584 }
2585 }
2586 else
2587 {
2588 // No valid engine selected.
2589 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
2590 }
2591 }
2592 else if (engineCapsInputPipe.hdrKernelNeeded)
2593 {
2594 caps.bRender = 1;
2595 caps.bRenderHdr = engineCapsInputPipe.hdrKernelNeeded;
2596 caps.bOutputPipeFeatureInuse = true;
2597 }
2598 else if (engineCapsInputPipe.nonFcFeatureExists)
2599 {
2600 VP_EngineEntry engineCaps = engineCapsInputPipe;
2601 bool multiPassNeeded = false;
2602 if (!engineCaps.fcOnlyFeatureExists && !engineCapsOutputPipe.fcOnlyFeatureExists &&
2603 !engineCaps.multiPassNeeded)
2604 {
2605 caps.bOutputPipeFeatureInuse = true;
2606 engineCaps.value |= engineCapsOutputPipe.value;
2607 }
2608 caps.bVebox = true;
2609 caps.bIECP = engineCaps.VeboxIECPNeeded;
2610 caps.bDiProcess2ndField = engineCaps.diProcess2ndField;
2611 caps.bTemperalInputInuse = engineCaps.bTemperalInputInuse;
2612 caps.b1K1DLutInUse = engineCaps.is1K1DLutSurfaceInUse;
2613 caps.bDemosaicInUse = engineCaps.isBayerInputInUse;
2614
2615 if (engineCaps.fcOnlyFeatureExists)
2616 {
2617 // For vebox/sfc+render case, use 2nd workload (render) to do csc for better performance
2618 // in most VP common cases, e.g. NV12->RGB, to save the memory bandwidth.
2619 caps.bForceCscToRender = true;
2620 // Force procamp to render if both enable Lumaykey and procamp on the same layer
2621 // Lumaykey should be top-priority
2622 if (engineCaps.outputWithLumaKey)
2623 {
2624 caps.bForceProcampToRender = true;
2625 }
2626 else
2627 {
2628 // For vebox/sfc+render case, use 2nd workload (render) to do Procamp,
2629 // especially for the scenario including Lumakey feature, which will ensure the Procamp can be done after Lumakey.
2630 caps.bForceProcampToRender = false;
2631 }
2632 // For vebox + render with features, which can be done on both sfc and render,
2633 // and sfc is not must have, sfc should not be selected and those features should be done on render.
2634 caps.bSFC = engineCaps.nonVeboxFeatureExists && engineCaps.sfcOnlyFeatureExists;
2635 // For OCL FC not supported formats, fallback to legacy FC
2636 caps.bFallbackLegacyFC = engineCaps.forceLegacyFC;
2637
2638 }
2639 else
2640 {
2641 caps.bSFC = !engineCapsOutputPipe.sfcNotSupported && engineCaps.nonVeboxFeatureExists;
2642 }
2643 }
2644 else if (engineCapsInputPipe.forceBypassWorkload)
2645 {
2646 caps.bVebox = 0;
2647 caps.bSFC = 0;
2648 caps.bRender = 0;
2649 caps.forceBypassWorkload = 1;
2650 }
2651 else
2652 {
2653 if (!engineCapsInputPipe.fcSupported)
2654 {
2655 // Should be only fc feature here.
2656 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
2657 }
2658 VP_EngineEntry engineCaps = engineCapsInputPipe;
2659 engineCaps.value |= engineCapsOutputPipe.value;
2660 caps.bOutputPipeFeatureInuse = true;
2661 // Fc cases.
2662 if (!engineCaps.fcOnlyFeatureExists && !engineCaps.veboxNotSupported)
2663 {
2664 // If all feature can support both vebox/sfc and fc.
2665 caps.bVebox = true;
2666 caps.bIECP = engineCapsInputPipe.VeboxIECPNeeded;
2667 caps.bSFC = engineCapsInputPipe.nonVeboxFeatureExists;
2668 }
2669 else
2670 {
2671 caps.bRender = 1;
2672 caps.bComposite = 1;
2673 }
2674
2675 caps.bDiProcess2ndField = engineCaps.diProcess2ndField;
2676 caps.bTemperalInputInuse = engineCaps.bTemperalInputInuse;
2677 caps.b1K1DLutInUse = engineCaps.is1K1DLutSurfaceInUse;
2678 caps.bFallbackLegacyFC = engineCaps.forceLegacyFC;
2679 }
2680 if (caps.bSFC && engineCapsInputPipe.enableSFCLinearOutputByTileConvert)
2681 {
2682 caps.enableSFCLinearOutputByTileConvert = engineCapsInputPipe.enableSFCLinearOutputByTileConvert;
2683 }
2684 VP_PUBLIC_NORMALMESSAGE("Execute Caps, value 0x%llx (bVebox %d, bSFC %d, bRender %d, bComposite %d, bNpu %d, bOutputPipeFeatureInuse %d, bIECP %d, bForceCscToRender %d, bDiProcess2ndField %d)",
2685 caps.value, caps.bVebox, caps.bSFC, caps.bRender, caps.bComposite, caps.bNpu, caps.bOutputPipeFeatureInuse, caps.bIECP,
2686 caps.bForceCscToRender, caps.bDiProcess2ndField);
2687 PrintFeatureExecutionCaps("engineCapsInputPipe", engineCapsInputPipe);
2688 PrintFeatureExecutionCaps("engineCapsOutputPipe", engineCapsOutputPipe);
2689
2690 MT_LOG7(MT_VP_HAL_POLICY_INIT_EXECCAPS, MT_NORMAL, MT_VP_HAL_EXECCAPS, (int64_t)caps.value, MT_VP_HAL_EXECCAPS_VE, (int64_t)caps.bVebox, MT_VP_HAL_EXECCAPS_SFC, (int64_t)caps.bSFC, MT_VP_HAL_EXECCAPS_RENDER,
2691 (int64_t)caps.bRender, MT_VP_HAL_EXECCAPS_COMP, (int64_t)caps.bComposite, MT_VP_HAL_EXECCAPS_OUTPIPE_FTRINUSE, (int64_t)caps.bOutputPipeFeatureInuse, MT_VP_HAL_EXECCAPS_IECP, (int64_t)caps.bIECP);
2692 MT_LOG7(MT_VP_HAL_POLICY_GET_INPIPECAPS, MT_NORMAL, MT_VP_HAL_ENGINECAPS, (int64_t)engineCapsInputPipe.value, MT_VP_HAL_ENGINECAPS_EN, (int64_t)engineCapsInputPipe.bEnabled, MT_VP_HAL_ENGINECAPS_VE_NEEDED,
2693 (int64_t)engineCapsInputPipe.VeboxNeeded, MT_VP_HAL_ENGINECAPS_SFC_NEEDED, (int64_t)engineCapsInputPipe.SfcNeeded, MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, (int64_t)engineCapsInputPipe.RenderNeeded, MT_VP_HAL_ENGINECAPS_FC_SUPPORT, (int64_t)engineCapsInputPipe.fcSupported, MT_VP_HAL_ENGINECAPS_ISOLATED, (int64_t)engineCapsInputPipe.isolated);
2694 MT_LOG7(MT_VP_HAL_POLICY_GET_OUTPIPECAPS, MT_NORMAL, MT_VP_HAL_ENGINECAPS, (int64_t)engineCapsOutputPipe.value, MT_VP_HAL_ENGINECAPS_EN, (int64_t)engineCapsOutputPipe.bEnabled, MT_VP_HAL_ENGINECAPS_VE_NEEDED, (int64_t)engineCapsOutputPipe.VeboxNeeded, MT_VP_HAL_ENGINECAPS_SFC_NEEDED, (int64_t)engineCapsOutputPipe.SfcNeeded, MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, (int64_t)engineCapsOutputPipe.RenderNeeded,
2695 MT_VP_HAL_ENGINECAPS_FC_SUPPORT, (int64_t)engineCapsOutputPipe.fcSupported, MT_VP_HAL_ENGINECAPS_ISOLATED, (int64_t)engineCapsOutputPipe.isolated);
2696
2697 if (caps.bRender)
2698 {
2699 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
2700 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_vpPlatformInterface);
2701
2702 if (m_vpInterface.GetHwInterface()->m_vpPlatformInterface->IsRenderDisabled())
2703 {
2704 VP_PUBLIC_ASSERTMESSAGE("Render needed. Rejected for render disabled!");
2705 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_PLATFORM_NOT_SUPPORTED);
2706 }
2707 }
2708
2709 return MOS_STATUS_SUCCESS;
2710 }
2711
2712 MOS_STATUS Policy::GetOutputPipeEngineCaps(SwFilterPipe& featurePipe, VP_EngineEntry &engineCapsOutputPipe, SwFilterSubPipe *inputPipeSelected)
2713 {
2714 SwFilterSubPipe *featureSubPipe = featurePipe.GetSwFilterSubPipe(false, 0);
2715 VP_PUBLIC_CHK_NULL_RETURN(featureSubPipe);
2716
2717 engineCapsOutputPipe.value = 0;
2718
2719 for (auto featureType : m_featurePool)
2720 {
2721 SwFilter *swFilter = featureSubPipe->GetSwFilter(featureType);
2722
2723 if (nullptr == swFilter)
2724 {
2725 continue;
2726 }
2727
2728 VP_EngineEntry engineCaps = swFilter->GetCombinedFilterEngineCaps(inputPipeSelected);
2729
2730 if (!engineCaps.bEnabled)
2731 {
2732 continue;
2733 }
2734
2735 if (engineCaps.isolated || !engineCaps.RenderNeeded || !engineCaps.fcSupported)
2736 {
2737 // No support for non-fc supported feature in current stage.
2738 // Will add it if needed.
2739 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
2740 }
2741
2742 if (!engineCaps.SfcNeeded && !engineCaps.VeboxNeeded && !engineCaps.bypassIfVeboxSfcInUse)
2743 {
2744 engineCapsOutputPipe.fcOnlyFeatureExists = true;
2745 }
2746 engineCapsOutputPipe.value |= engineCaps.value;
2747 engineCapsOutputPipe.nonVeboxFeatureExists |= (!engineCaps.VeboxNeeded && !engineCaps.bypassIfVeboxSfcInUse);
2748 }
2749
2750 PrintFeatureExecutionCaps(__FUNCTION__, engineCapsOutputPipe);
2751 MT_LOG7(MT_VP_HAL_POLICY_GET_OUTPIPECAPS, MT_NORMAL, MT_VP_HAL_ENGINECAPS, (int64_t)engineCapsOutputPipe.value, MT_VP_HAL_ENGINECAPS_EN, (int64_t)engineCapsOutputPipe.bEnabled,
2752 MT_VP_HAL_ENGINECAPS_VE_NEEDED, (int64_t)engineCapsOutputPipe.VeboxNeeded, MT_VP_HAL_ENGINECAPS_SFC_NEEDED, (int64_t)engineCapsOutputPipe.SfcNeeded,
2753 MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, (int64_t)engineCapsOutputPipe.RenderNeeded, MT_VP_HAL_ENGINECAPS_FC_SUPPORT, (int64_t)engineCapsOutputPipe.fcSupported,
2754 MT_VP_HAL_ENGINECAPS_ISOLATED, (int64_t)engineCapsOutputPipe.isolated);
2755
2756 return MOS_STATUS_SUCCESS;
2757 }
2758
2759 bool Policy::IsExcludedFeatureForHdr(FeatureType feature)
2760 {
2761 return (FeatureTypeTcc == feature ||
2762 FeatureTypeSte == feature ||
2763 FeatureTypeProcamp == feature);
2764 }
2765
2766 bool Policy::IsIsolateFeatureOutputPipeNeeded(SwFilterSubPipe *featureSubPipe, SwFilter *swFilter)
2767 {
2768 if (RenderTargetTypeSurface == swFilter->GetRenderTargetType())
2769 {
2770 bool isIsolateFeatureOutputPipeNeeded = true;
2771 for (auto featureType : m_featurePool)
2772 {
2773 SwFilter *curSwFilter = featureSubPipe->GetSwFilter(featureType);
2774 if (nullptr != curSwFilter)
2775 {
2776 VP_EngineEntry caps = curSwFilter->GetFilterEngineCaps();
2777 if (caps.bEnabled == true && featureType != swFilter->GetFeatureType())
2778 {
2779 auto renderTargetType = curSwFilter->GetRenderTargetType();
2780 if (renderTargetType == RenderTargetTypeSurface)
2781 {
2782 isIsolateFeatureOutputPipeNeeded = false;
2783 break;
2784 }
2785 }
2786 }
2787 }
2788 return isIsolateFeatureOutputPipeNeeded;
2789 }
2790 else
2791 {
2792 return false;
2793 }
2794 }
2795
2796 MOS_STATUS Policy::GetInputPipeEngineCaps(SwFilterPipe& featurePipe, VP_EngineEntry &engineCapsInputPipe,
2797 SwFilterSubPipe *&singlePipeSelected, bool &isSingleSubPipe, uint32_t &selectedPipeIndex)
2798 {
2799 // Priority for selecting features to be processed in current workload.
2800 // 1. Features with isolated flag. One isolated feature can only be processed without any other features involved.
2801 // 2. Features without fc supported flag.
2802 // 3. For single layer, select vebox, if all vebox == 1
2803 // select sfc, if all sfc/vebox == 1 and sfc == 1/vebox == 0 exists
2804 // For multi layer, select FC
2805 // Add support for ordered pipe later.
2806 isSingleSubPipe = featurePipe.GetSurfaceCount(true) <= 1;
2807 singlePipeSelected = isSingleSubPipe ? featurePipe.GetSwFilterSubPipe(true, 0) : nullptr;
2808 selectedPipeIndex = 0;
2809
2810 VP_EngineEntry engineCapsIsolated = {}; // Input pipe engine caps for isolated feature exists case.
2811 VP_EngineEntry engineCapsForVeboxSfc = {}; // Input pipe engine caps for non-fc feature exists case.
2812 VP_EngineEntry engineCapsForFc = {}; // Input pipe engine caps for fc supported by all features cases.
2813 VP_EngineEntry engineCapsForHdrKernel = {0}; // Input pipe engine caps for hdr kernel supported by all features cases.
2814 for (uint32_t pipeIndex = 0; pipeIndex < featurePipe.GetSurfaceCount(true); ++pipeIndex)
2815 {
2816 SwFilterSubPipe *featureSubPipe = featurePipe.GetSwFilterSubPipe(true, pipeIndex);
2817 VP_PUBLIC_CHK_NULL_RETURN(featureSubPipe);
2818
2819 bool isSfcNeeded = false;
2820 engineCapsForVeboxSfc.value = 0;
2821
2822 for (auto featureType : m_featurePool)
2823 {
2824 SwFilter *swFilter = featureSubPipe->GetSwFilter(featureType);
2825 if (nullptr == swFilter)
2826 {
2827 continue;
2828 }
2829
2830 VP_EngineEntry &engineCaps = swFilter->GetFilterEngineCaps();
2831
2832 if (!engineCaps.bEnabled)
2833 {
2834 // Some features need to be bypassed with requirement on workload, e.g. 2nd field for DI.
2835 if (engineCaps.bypassVeboxFeatures || engineCaps.diProcess2ndField)
2836 {
2837 isSingleSubPipe = true;
2838 selectedPipeIndex = pipeIndex;
2839 singlePipeSelected = featureSubPipe;
2840 engineCapsForVeboxSfc.value |= engineCaps.value;
2841 engineCapsForFc.value |= engineCaps.value;
2842 }
2843 if (engineCaps.sfcNotSupported)
2844 {
2845 // sfc cannot be selected. Resolution limit is checked with scaling filter, even scaling
2846 // feature itself not being enabled.
2847 engineCapsForVeboxSfc.sfcNotSupported = engineCaps.sfcNotSupported;
2848 engineCapsForFc.sfcNotSupported = engineCaps.sfcNotSupported;
2849 VP_PUBLIC_NORMALMESSAGE("sfcNotSupported flag is set.");
2850 }
2851 if (engineCaps.veboxNotSupported)
2852 {
2853 // vebox cannot be selected. Resolution limit is checked with scaling filter, even scaling
2854 // feature itself not being enabled.
2855 engineCapsForVeboxSfc.veboxNotSupported = engineCaps.veboxNotSupported;
2856 engineCapsForFc.veboxNotSupported = engineCaps.veboxNotSupported;
2857 VP_PUBLIC_NORMALMESSAGE("veboxNotSupported flag is set.");
2858 }
2859 if (engineCaps.forceBypassWorkload)
2860 {
2861 engineCapsInputPipe.forceBypassWorkload = engineCaps.forceBypassWorkload;
2862 VP_PUBLIC_NORMALMESSAGE("Set engineCapsInputPipe forceDisableForVebox true.");
2863 }
2864 continue;
2865 }
2866
2867 if (engineCaps.isolated)
2868 {
2869 // 1. Process feature with isolated flag firstly.
2870 isSingleSubPipe = true;
2871 selectedPipeIndex = pipeIndex;
2872 singlePipeSelected = featureSubPipe;
2873 engineCapsIsolated = engineCaps;
2874 engineCapsIsolated.isOutputPipeNeeded = IsIsolateFeatureOutputPipeNeeded(featureSubPipe, swFilter);
2875 break;
2876 }
2877 else if (!engineCaps.fcSupported)
2878 {
2879 // 2. Process non-fc features by vebox/sfc.
2880 if (engineCaps.RenderNeeded && !engineCaps.hdrKernelNeeded)
2881 {
2882 // Non-FC render feature should be isolated.
2883 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
2884 }
2885
2886 if (engineCaps.hdrKernelSupported)
2887 {
2888 engineCapsForHdrKernel.value |= engineCaps.value;
2889 }
2890
2891 if (engineCaps.hdrKernelNeeded)
2892 {
2893 VP_PUBLIC_NORMALMESSAGE("HDR kernel is needed.");
2894 }
2895 else
2896 {
2897 if (!engineCaps.SfcNeeded && !engineCaps.VeboxNeeded)
2898 {
2899 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER)
2900 }
2901 if (engineCaps.sfcNotSupported)
2902 {
2903 // sfc cannot be selected. Resolution limit is checked with scaling filter, even scaling
2904 // feature itself not being enabled.
2905 engineCapsForVeboxSfc.sfcNotSupported = engineCaps.sfcNotSupported;
2906 engineCapsForFc.sfcNotSupported = engineCaps.sfcNotSupported;
2907 VP_PUBLIC_NORMALMESSAGE("sfcNotSupported flag is set.");
2908 }
2909
2910 if ((engineCaps.SfcNeeded && !engineCaps.RenderNeeded && !engineCaps.VeboxNeeded))
2911 {
2912 engineCapsForVeboxSfc.sfcOnlyFeatureExists = 1;
2913 }
2914
2915 isSingleSubPipe = true;
2916 selectedPipeIndex = pipeIndex;
2917 singlePipeSelected = featureSubPipe;
2918 engineCapsForVeboxSfc.value |= engineCaps.value;
2919 engineCapsForVeboxSfc.nonFcFeatureExists = true;
2920 engineCapsForVeboxSfc.nonVeboxFeatureExists |= !engineCaps.VeboxNeeded;
2921
2922 SwFilter *lumakey = featureSubPipe->GetSwFilter(FeatureTypeLumakey);
2923 if (lumakey && lumakey->GetFilterEngineCaps().bEnabled)
2924 {
2925 engineCapsForVeboxSfc.outputWithLumaKey = true;
2926 VP_PUBLIC_NORMALMESSAGE("outputWithLumaKey flag is set.");
2927 }
2928 else
2929 {
2930 engineCapsForVeboxSfc.outputWithLumaKey = false;
2931 }
2932 }
2933 }
2934 else
2935 {
2936 if (engineCaps.hdrKernelSupported)
2937 {
2938 engineCapsForHdrKernel.value |= engineCaps.value;
2939 }
2940
2941 if (engineCaps.hdrKernelNeeded)
2942 {
2943 VP_PUBLIC_ASSERTMESSAGE("hdrKernelNeeded and fcSupported should not be set at same time.");
2944 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER)
2945 }
2946
2947 // 3. Process features support FC.
2948 if (engineCaps.SfcNeeded || engineCaps.VeboxNeeded)
2949 {
2950 engineCapsForVeboxSfc.value |= engineCaps.value;
2951 engineCapsForVeboxSfc.nonVeboxFeatureExists |= !engineCaps.VeboxNeeded;
2952 }
2953 else
2954 {
2955 // Set fcOnlyFeatureExists flag for engineCapsForVeboxSfc to indicate that
2956 // not all features in input pipe can be processed by vebox/sfc and
2957 // features in output pipe cannot be combined to vebox/sfc workload.
2958 engineCapsForVeboxSfc.fcOnlyFeatureExists = true;
2959 engineCapsForFc.fcOnlyFeatureExists = true;
2960 }
2961 if (engineCaps.sfcNotSupported)
2962 {
2963 // sfc cannot be selected. Resolution limit is checked with scaling filter, even scaling
2964 // feature itself not being enabled.
2965 engineCapsForVeboxSfc.sfcNotSupported = engineCaps.sfcNotSupported;
2966 engineCapsForFc.sfcNotSupported = engineCaps.sfcNotSupported;
2967 VP_PUBLIC_NORMALMESSAGE("sfcNotSupported flag is set.");
2968 }
2969
2970 engineCapsForFc.value |= engineCaps.value;
2971 engineCapsForFc.nonVeboxFeatureExists |= !engineCaps.VeboxNeeded;
2972 }
2973 }
2974
2975 SwFilterAiBase *swAiFilter = nullptr;
2976 VP_PUBLIC_CHK_STATUS_RETURN(featureSubPipe->GetAiSwFilter(swAiFilter));
2977 if (swAiFilter)
2978 {
2979 VP_EngineEntry &engineCaps = swAiFilter->GetFilterEngineCaps();
2980 isSingleSubPipe = true;
2981 selectedPipeIndex = pipeIndex;
2982 singlePipeSelected = featureSubPipe;
2983 engineCapsIsolated = engineCaps;
2984 engineCapsIsolated.isOutputPipeNeeded = engineCaps.isOutputPipeNeeded;
2985 }
2986
2987 if (isSingleSubPipe)
2988 {
2989 break;
2990 }
2991 }
2992
2993 // For multi-layer case or color fill case, force to set fcOnlyFeatureExists flag.
2994 engineCapsForFc.fcOnlyFeatureExists = engineCapsForFc.fcOnlyFeatureExists ||
2995 featurePipe.GetSurfaceCount(true) > 1 ||
2996 featurePipe.GetSurfaceCount(true) == 0 ||
2997 engineCapsForFc.nonVeboxFeatureExists && engineCapsForFc.sfcNotSupported;
2998
2999 if (engineCapsForVeboxSfc.nonVeboxFeatureExists && engineCapsForVeboxSfc.sfcNotSupported)
3000 {
3001 VP_PUBLIC_NORMALMESSAGE("Clear nonVeboxFeatureExists flag to avoid sfc being selected, since sfcNotSupported == 1.");
3002 engineCapsForVeboxSfc.nonVeboxFeatureExists = 0;
3003 }
3004
3005 // If want to disable vebox/sfc output to output surface with color fill directly for multilayer case,
3006 // fcOnlyFeatureExists need be set for vebox sfc for multi layer case here.
3007 engineCapsForVeboxSfc.fcOnlyFeatureExists = engineCapsForFc.fcOnlyFeatureExists;
3008
3009 if (engineCapsIsolated.isolated)
3010 {
3011 VP_PUBLIC_NORMALMESSAGE("engineCapsIsolated selected.");
3012 engineCapsInputPipe = engineCapsIsolated;
3013 }
3014 else if (engineCapsForHdrKernel.hdrKernelNeeded)
3015 {
3016 VP_PUBLIC_NORMALMESSAGE("engineCapsForHdrKernel selected.");
3017 engineCapsInputPipe = engineCapsForHdrKernel;
3018 }
3019 else if (engineCapsForVeboxSfc.nonFcFeatureExists)
3020 {
3021 VP_PUBLIC_NORMALMESSAGE("engineCapsForVeboxSfc selected.");
3022 engineCapsInputPipe = engineCapsForVeboxSfc;
3023 }
3024 else if (engineCapsInputPipe.forceBypassWorkload)
3025 {
3026 VP_PUBLIC_NORMALMESSAGE("Still use engineCapsInputPipe forceBypassWorkload set true.");
3027 }
3028 else
3029 {
3030 VP_PUBLIC_NORMALMESSAGE("engineCapsForFc selected.");
3031 if (0 == engineCapsForFc.bEnabled)
3032 {
3033 engineCapsForFc.fcSupported = true;
3034 // Decision on choosing between vebox/sfc and render will be made in InitExecuteCaps.
3035 VP_PUBLIC_NORMALMESSAGE("Surface copy with no feature enabled. Force set fcSupported flag.");
3036 }
3037 engineCapsInputPipe = engineCapsForFc;
3038 }
3039
3040 PrintFeatureExecutionCaps(__FUNCTION__, engineCapsInputPipe);
3041 MT_LOG7(MT_VP_HAL_POLICY_GET_INPIPECAPS, MT_NORMAL, MT_VP_HAL_ENGINECAPS, (int64_t)engineCapsInputPipe.value,
3042 MT_VP_HAL_ENGINECAPS_EN, (int64_t)engineCapsInputPipe.bEnabled, MT_VP_HAL_ENGINECAPS_VE_NEEDED, (int64_t)engineCapsInputPipe.VeboxNeeded,
3043 MT_VP_HAL_ENGINECAPS_SFC_NEEDED, (int64_t)engineCapsInputPipe.SfcNeeded, MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, (int64_t)engineCapsInputPipe.RenderNeeded,
3044 MT_VP_HAL_ENGINECAPS_FC_SUPPORT, (int64_t)engineCapsInputPipe.fcSupported, MT_VP_HAL_ENGINECAPS_ISOLATED, (int64_t)engineCapsInputPipe.isolated);
3045
3046 return MOS_STATUS_SUCCESS;
3047 }
3048
3049 MOS_STATUS Policy::BypassVeboxFeatures(SwFilterSubPipe *featureSubPipe, VP_EngineEntry &engineCaps)
3050 {
3051 VP_FUNC_CALL();
3052 VP_PUBLIC_CHK_NULL_RETURN(featureSubPipe);
3053
3054 for (auto filterID : m_featurePool)
3055 {
3056 SwFilter *feature = featureSubPipe->GetSwFilter(FeatureType(filterID));
3057
3058 if (nullptr == feature)
3059 {
3060 continue;
3061 }
3062
3063 if (feature->GetFilterEngineCaps().VeboxNeeded)
3064 {
3065 // Disable vebox features and avoid it run into render path.
3066 feature->GetFilterEngineCaps().VeboxNeeded = 0;
3067 feature->GetFilterEngineCaps().RenderNeeded = 0;
3068 feature->GetFilterEngineCaps().bEnabled = feature->GetFilterEngineCaps().SfcNeeded;
3069 }
3070 }
3071
3072 engineCaps.nonVeboxFeatureExists = true;
3073 VP_PUBLIC_NORMALMESSAGE("Set nonVeboxFeatureExists to 1 for BypassVeboxFeatures.");
3074
3075 return MOS_STATUS_SUCCESS;
3076 }
3077
3078 MOS_STATUS Policy::BuildExecuteCaps(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS &caps, VP_EngineEntry &engineCapsInputPipe, VP_EngineEntry &engineCapsOutputPipe,
3079 bool &isSingleSubPipe, uint32_t &selectedPipeIndex)
3080 {
3081 VP_FUNC_CALL();
3082 SwFilterSubPipe *singlePipeSelected = nullptr;
3083
3084 caps.value = 0;
3085 engineCapsOutputPipe.value = 0;
3086 engineCapsInputPipe.value = 0;
3087 isSingleSubPipe = false;
3088 selectedPipeIndex = 0;
3089
3090 VP_PUBLIC_CHK_STATUS_RETURN(GetInputPipeEngineCaps(featurePipe, engineCapsInputPipe,
3091 singlePipeSelected, isSingleSubPipe, selectedPipeIndex));
3092 VP_PUBLIC_CHK_STATUS_RETURN(GetOutputPipeEngineCaps(featurePipe, engineCapsOutputPipe, singlePipeSelected));
3093
3094 if (engineCapsInputPipe.bypassVeboxFeatures)
3095 {
3096 if (engineCapsInputPipe.isolated)
3097 {
3098 // isolated feature case should not come here.
3099 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3100 }
3101 VP_PUBLIC_CHK_STATUS_RETURN(BypassVeboxFeatures(singlePipeSelected, engineCapsInputPipe));
3102 }
3103
3104 VP_PUBLIC_CHK_STATUS_RETURN(InitExecuteCaps(caps, engineCapsInputPipe, engineCapsOutputPipe));
3105
3106 return MOS_STATUS_SUCCESS;
3107 }
3108
3109 MOS_STATUS Policy::BuildFilters(SwFilterPipe& featurePipe, HW_FILTER_PARAMS& params)
3110 {
3111 VP_FUNC_CALL();
3112
3113 VP_EngineEntry engineCaps = {};
3114 VP_EXECUTE_CAPS caps = {};
3115 VP_EngineEntry engineCapsInputPipe = {};
3116 VP_EngineEntry engineCapsOutputPipe = {};
3117 bool isSingleSubPipe = false;
3118 uint32_t selectedPipeIndex = 0;
3119
3120 VP_PUBLIC_CHK_STATUS_RETURN(BuildExecuteCaps(featurePipe, caps, engineCapsInputPipe, engineCapsOutputPipe, isSingleSubPipe, selectedPipeIndex));
3121
3122 std::vector<int> layerIndexes;
3123 VP_PUBLIC_CHK_STATUS_RETURN(LayerSelectForProcess(layerIndexes, featurePipe, isSingleSubPipe, selectedPipeIndex, caps));
3124
3125 if (IsVeboxSecurePathEnabled(featurePipe, caps))
3126 {
3127 // Process Vebox Secure workload
3128 VP_PUBLIC_CHK_STATUS_RETURN(BuildVeboxSecureFilters(featurePipe, caps, params));
3129
3130 VP_PUBLIC_CHK_STATUS_RETURN(SetupFilterResource(featurePipe, layerIndexes, caps, params));
3131
3132 VP_PUBLIC_CHK_STATUS_RETURN(BuildExecuteHwFilter(caps, params));
3133 return MOS_STATUS_SUCCESS;
3134 }
3135
3136 // Set feature types with engine for selected features
3137 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeatureTypeWithEngine(layerIndexes, featurePipe, caps, engineCapsInputPipe.isolated, caps.bOutputPipeFeatureInuse/*engineCapsOutputPipe.bEnabled*/));
3138
3139 VP_PUBLIC_CHK_STATUS_RETURN(BuildExecuteFilter(featurePipe, layerIndexes, caps, params));
3140 VP_PUBLIC_CHK_STATUS_RETURN(featurePipe.ResetSecureFlag());
3141
3142 /* Place Holder for Resource Manager to manage intermedia surface or HW needed surface in policy*/
3143
3144 return MOS_STATUS_SUCCESS;
3145 }
3146
3147 MOS_STATUS Policy::FilterFeatureCombination(SwFilterPipe &swFilterPipe, bool isInputPipe, uint32_t index, VP_EngineEntry &engineCapsCombined, VP_EngineEntry &engineCapsCombinedAllPipes)
3148 {
3149 VP_FUNC_CALL();
3150
3151 SwFilterSubPipe *pipe = nullptr;
3152 pipe = swFilterPipe.GetSwFilterSubPipe(isInputPipe, index);
3153 VP_PUBLIC_CHK_NULL_RETURN(pipe);
3154
3155 // Filter out vebox/sfc only features.
3156 if (engineCapsCombined.veboxNotSupported)
3157 {
3158 for (auto filterID : m_featurePool)
3159 {
3160 auto feature = pipe->GetSwFilter(FeatureType(filterID));
3161 if (feature && feature->GetFilterEngineCaps().bEnabled &&
3162 (feature->GetFilterEngineCaps().VeboxNeeded ||
3163 feature->GetFilterEngineCaps().SfcNeeded) &&
3164 !feature->GetFilterEngineCaps().RenderNeeded)
3165 {
3166 feature->GetFilterEngineCaps().bEnabled = 0;
3167 feature->GetFilterEngineCaps().VeboxNeeded = 0;
3168 feature->GetFilterEngineCaps().SfcNeeded = 0;
3169 feature->GetFilterEngineCaps().forceEnableForSfc = 0;
3170 VP_PUBLIC_NORMALMESSAGE("Disable feature 0x%x since vebox cannot be used.", filterID);
3171 PrintFeatureExecutionCaps("Disable feature since vebox cannot be used", feature->GetFilterEngineCaps());
3172 }
3173 }
3174 }
3175 else if (engineCapsCombined.forceBypassWorkload)
3176 {
3177 for (auto filterID : m_featurePool)
3178 {
3179 auto feature = pipe->GetSwFilter(FeatureType(filterID));
3180 if (feature && feature->GetFilterEngineCaps().bEnabled)
3181 {
3182 feature->GetFilterEngineCaps().bEnabled = 0;
3183 feature->GetFilterEngineCaps().VeboxNeeded = 0;
3184 feature->GetFilterEngineCaps().SfcNeeded = 0;
3185 feature->GetFilterEngineCaps().RenderNeeded = 0;
3186 feature->GetFilterEngineCaps() = {0};
3187 feature->GetFilterEngineCaps().forceBypassWorkload = 1;
3188 VP_PUBLIC_NORMALMESSAGE("Disable feature 0x%x because of bypass this workload.", filterID);
3189 PrintFeatureExecutionCaps("Disable feature because of bypass this workload.", feature->GetFilterEngineCaps());
3190 }
3191 }
3192 }
3193
3194 // For DI on render with scaling case, force to do scaling on render.
3195 if (engineCapsCombined.SfcNeeded)
3196 {
3197 auto di = pipe->GetSwFilter(FeatureType(FeatureTypeDi));
3198
3199 if (di && di->GetFilterEngineCaps().bEnabled &&
3200 !di->GetFilterEngineCaps().VeboxNeeded && di->GetFilterEngineCaps().RenderNeeded)
3201 {
3202 for (auto filterID : m_featurePool)
3203 {
3204 auto feature = pipe->GetSwFilter(FeatureType(filterID));
3205 if (nullptr == feature || !feature->GetFilterEngineCaps().bEnabled)
3206 {
3207 continue;
3208 }
3209 if (FeatureType(filterID) == FeatureTypeScaling &&
3210 feature->GetFilterEngineCaps().SfcNeeded &&
3211 !feature->GetFilterEngineCaps().RenderNeeded &&
3212 !m_hwCaps.m_rules.isAvsSamplerSupported)
3213 {
3214 feature->GetFilterEngineCaps().SfcNeeded = 0;
3215 feature->GetFilterEngineCaps().RenderNeeded = 1;
3216 feature->GetFilterEngineCaps().fcSupported = 1;
3217 PrintFeatureExecutionCaps("Update scaling caps for render DI", feature->GetFilterEngineCaps());
3218 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0) for render DI");
3219 }
3220 else if (!feature->GetFilterEngineCaps().VeboxNeeded &&
3221 feature->GetFilterEngineCaps().SfcNeeded &&
3222 feature->GetFilterEngineCaps().RenderNeeded)
3223 {
3224 feature->GetFilterEngineCaps().SfcNeeded = 0;
3225 VP_PUBLIC_NORMALMESSAGE("VPOutputPipe will be render(0), since force feature 0x%x to render for render DI", filterID);
3226 MT_LOG2(MT_VP_HAL_POLICY_FLITER_FTR_COMBINE, MT_NORMAL, MT_VP_HAL_FEATUERTYPE, filterID, MT_VP_HAL_EXECCAPS_FORCE_DI2RENDER, (int64_t)feature->GetFilterEngineCaps().RenderNeeded);
3227 auto engineCaps = feature->GetFilterEngineCaps();
3228 PrintFeatureExecutionCaps("Force feature to render for render DI", engineCaps);
3229 MT_LOG7(MT_VP_HAL_POLICY_FLITER_FTR_COMBINE, MT_NORMAL, MT_VP_HAL_FEATUERTYPE, filterID, MT_VP_HAL_ENGINECAPS, (int64_t)engineCaps.value, MT_VP_HAL_ENGINECAPS_EN, (int64_t)engineCaps.bEnabled,
3230 MT_VP_HAL_ENGINECAPS_VE_NEEDED, (int64_t)engineCaps.VeboxNeeded, MT_VP_HAL_ENGINECAPS_SFC_NEEDED, (int64_t)engineCaps.SfcNeeded,
3231 MT_VP_HAL_ENGINECAPS_RENDER_NEEDED, (int64_t)engineCaps.RenderNeeded, MT_VP_HAL_ENGINECAPS_FC_SUPPORT, (int64_t)engineCaps.fcSupported);
3232 }
3233 }
3234 }
3235 }
3236
3237 if (engineCapsCombinedAllPipes.hdrKernelNeeded)
3238 {
3239 VP_PUBLIC_CHK_STATUS_RETURN(FilterFeatureCombinationForHDRKernel(pipe));
3240 }
3241 else
3242 {
3243 auto hdr = pipe->GetSwFilter(FeatureTypeHdr);
3244
3245 if (nullptr != hdr)
3246 {
3247 for (auto filterID : m_featurePool)
3248 {
3249 if (IsExcludedFeatureForHdr(filterID))
3250 {
3251 auto feature = pipe->GetSwFilter(FeatureType(filterID));
3252 if (feature && feature->GetFilterEngineCaps().bEnabled)
3253 {
3254 feature->GetFilterEngineCaps().bEnabled = false;
3255 VP_PUBLIC_NORMALMESSAGE("Disable feature 0x%x for HDR.", filterID);
3256 PrintFeatureExecutionCaps("Disable feature for HDR", feature->GetFilterEngineCaps());
3257 }
3258 }
3259
3260 if (filterID == FeatureTypeCsc)
3261 {
3262 SwFilterCsc *feature = (SwFilterCsc *)pipe->GetSwFilter(FeatureType(filterID));
3263 if (feature)
3264 {
3265 auto &params = feature->GetSwFilterParams();
3266 params.pIEFParams = nullptr;
3267 PrintFeatureExecutionCaps("Disable IEF for HDR", feature->GetFilterEngineCaps());
3268 }
3269 }
3270 }
3271 }
3272 }
3273
3274 return MOS_STATUS_SUCCESS;
3275 }
3276
3277 MOS_STATUS Policy::FilterFeatureCombinationForHDRKernel(SwFilterSubPipe *pipe)
3278 {
3279 VP_FUNC_CALL();
3280
3281 for (auto filterID : m_featurePool)
3282 {
3283 auto feature = pipe->GetSwFilter(FeatureType(filterID));
3284 if (feature && feature->GetFilterEngineCaps().bEnabled &&
3285 !feature->GetFilterEngineCaps().hdrKernelSupported)
3286 {
3287 auto feature = pipe->GetSwFilter(FeatureType(filterID));
3288 if (feature && feature->GetFilterEngineCaps().bEnabled)
3289 {
3290 feature->GetFilterEngineCaps().bEnabled = false;
3291 VP_PUBLIC_NORMALMESSAGE("Disable feature 0x%x for HDR.", filterID);
3292 PrintFeatureExecutionCaps("Disable feature for HDR", feature->GetFilterEngineCaps());
3293 }
3294 }
3295 }
3296 return MOS_STATUS_SUCCESS;
3297 }
3298
3299 MOS_STATUS Policy::BuildExecuteFilter(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params)
3300 {
3301 VP_FUNC_CALL();
3302
3303 params.Type = EngineTypeInvalid;
3304 // params.vpExecuteCaps will be assigned in Policy::BuildExecuteHwFilter.
3305 params.vpExecuteCaps.value = 0;
3306
3307 VP_PUBLIC_CHK_STATUS_RETURN(SetupExecuteFilter(featurePipe, layerIndexes, caps, params));
3308
3309 // Build Execute surface needed
3310 VP_PUBLIC_CHK_STATUS_RETURN(SetupFilterResource(featurePipe, layerIndexes, caps, params));
3311
3312 VP_PUBLIC_CHK_STATUS_RETURN(featurePipe.Update());
3313 VP_PUBLIC_CHK_STATUS_RETURN(params.executedFilters->Update());
3314
3315 if (featurePipe.IsEmpty())
3316 {
3317 caps.lastSubmission = true;
3318 }
3319
3320 VP_PUBLIC_CHK_STATUS_RETURN(BuildExecuteHwFilter(caps, params));
3321
3322 if (params.executedFilters)
3323 {
3324 params.executedFilters->AddRTLog();
3325 }
3326
3327 return MOS_STATUS_SUCCESS;
3328 }
3329
3330 MOS_STATUS Policy::BuildExecuteHwFilter(VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params)
3331 {
3332 VP_FUNC_CALL();
3333
3334 if (caps.bVebox || caps.bSFC)
3335 {
3336 params.Type = caps.bSFC ? EngineTypeVeboxSfc : EngineTypeVebox;
3337 params.vpExecuteCaps = caps;
3338 auto it = m_VeboxSfcFeatureHandlers.begin();
3339 for (; it != m_VeboxSfcFeatureHandlers.end(); ++it)
3340 {
3341 if ((*(it->second)).IsFeatureEnabled(caps))
3342 {
3343 HwFilterParameter* pHwFilterParam = (*(it->second)).CreateHwFilterParam(caps, *params.executedFilters, m_vpInterface.GetHwInterface());
3344
3345 if (pHwFilterParam)
3346 {
3347 params.Params.push_back(pHwFilterParam);
3348 }
3349 else
3350 {
3351 VP_PUBLIC_ASSERTMESSAGE("Create HW Filter Failed, Return Error");
3352 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, MOS_STATUS_NO_SPACE, MT_CODE_LINE, __LINE__);
3353 return MOS_STATUS_NO_SPACE;
3354 }
3355 }
3356 }
3357 }
3358 else if (caps.bRender)
3359 {
3360 params.Type = EngineTypeRender;
3361 params.vpExecuteCaps = caps;
3362
3363 auto it = m_RenderFeatureHandlers.begin();
3364 for (; it != m_RenderFeatureHandlers.end(); ++it)
3365 {
3366 if ((*(it->second)).IsFeatureEnabled(caps))
3367 {
3368 HwFilterParameter* pHwFilterParam = (*(it->second)).CreateHwFilterParam(caps, *params.executedFilters, m_vpInterface.GetHwInterface());
3369
3370 if (pHwFilterParam)
3371 {
3372 params.Params.push_back(pHwFilterParam);
3373 }
3374 else
3375 {
3376 VP_PUBLIC_ASSERTMESSAGE("Create HW Filter Failed, Return Error");
3377 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, MOS_STATUS_NO_SPACE, MT_CODE_LINE, __LINE__);
3378 return MOS_STATUS_NO_SPACE;
3379 }
3380 }
3381 }
3382 }
3383 else if (caps.bNpu)
3384 {
3385 params.Type = EngineTypeNpu;
3386 params.vpExecuteCaps = caps;
3387 auto it = m_NpuFeatureHandlers.begin();
3388 for (; it != m_NpuFeatureHandlers.end(); ++it)
3389 {
3390 if ((*(it->second)).IsFeatureEnabled(caps))
3391 {
3392 HwFilterParameter *pHwFilterParam = (*(it->second)).CreateHwFilterParam(caps, *params.executedFilters, m_vpInterface.GetHwInterface());
3393
3394 if (pHwFilterParam)
3395 {
3396 params.Params.push_back(pHwFilterParam);
3397 }
3398 else
3399 {
3400 VP_PUBLIC_ASSERTMESSAGE("Create HW Filter Failed, Return Error");
3401 MT_ERR2(MT_VP_HAL_POLICY, MT_ERROR_CODE, MOS_STATUS_NO_SPACE, MT_CODE_LINE, __LINE__);
3402 return MOS_STATUS_NO_SPACE;
3403 }
3404 }
3405 }
3406 }
3407 else if (caps.forceBypassWorkload)
3408 {
3409 VP_PUBLIC_NORMALMESSAGE("No engine is assigned. Skip this process for test usage.");
3410 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_SUCCESS);
3411 }
3412 else
3413 {
3414 VP_PUBLIC_ASSERTMESSAGE("No engine is assigned.");
3415 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3416 }
3417
3418 return MOS_STATUS_SUCCESS;
3419 }
3420
3421 MOS_STATUS Policy::UpdateFeatureTypeWithEngine(std::vector<int> &layerIndexes, SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps,
3422 bool isolatedFeatureSelected, bool outputPipeNeeded)
3423 {
3424 VP_FUNC_CALL();
3425 int inputSurfCount = featurePipe.GetSurfaceCount(true);
3426 int outputSurfCount = featurePipe.GetSurfaceCount(false);
3427 SwFilterSubPipe* featureSubPipe = nullptr;
3428
3429 for (uint32_t i = 0; i < layerIndexes.size(); ++i)
3430 {
3431 featureSubPipe = featurePipe.GetSwFilterSubPipe(true, layerIndexes[i]);
3432 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeatureTypeWithEngineSingleLayer(featureSubPipe, caps, isolatedFeatureSelected));
3433 }
3434
3435 if (outputPipeNeeded)
3436 {
3437 featureSubPipe = featurePipe.GetSwFilterSubPipe(false, 0);
3438 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeatureTypeWithEngineSingleLayer(featureSubPipe, caps, false));
3439 }
3440
3441 return MOS_STATUS_SUCCESS;
3442 }
3443
3444 MOS_STATUS Policy::UpdateFeatureTypeWithEngineSingleLayer(SwFilterSubPipe *featureSubPipe, VP_EXECUTE_CAPS& caps, bool isolatedFeatureSelected)
3445 {
3446 VP_FUNC_CALL();
3447 bool isolatedFeatureFound = false;
3448 // Set feature types with engine
3449 for (auto filterID : m_featurePool)
3450 {
3451 auto feature = featureSubPipe->GetSwFilter(FeatureType(filterID));
3452 if (feature)
3453 {
3454 VP_EngineEntry *engineCaps = &(feature->GetFilterEngineCaps());
3455
3456 if (isolatedFeatureSelected != engineCaps->isolated)
3457 {
3458 continue;
3459 }
3460
3461 // if SFC enabled, Vebox is must as SFC need connect with Vebox
3462 if (caps.bSFC &&
3463 (engineCaps->forceEnableForSfc ||
3464 engineCaps->bEnabled && (engineCaps->VeboxNeeded || engineCaps->SfcNeeded)))
3465 {
3466 if (engineCaps->forceEnableForSfc)
3467 {
3468 engineCaps->bEnabled = 1;
3469 engineCaps->SfcNeeded = 1;
3470 caps.enableSFCLinearOutputByTileConvert |= engineCaps->enableSFCLinearOutputByTileConvert;
3471 }
3472 // Choose SFC as execution engine
3473 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(feature, caps, engineCaps->SfcNeeded ? EngineTypeVeboxSfc : EngineTypeVebox));
3474 }
3475 // Vebox only cases
3476 else if (caps.bVebox &&
3477 (engineCaps->bEnabled && engineCaps->VeboxNeeded || caps.bIECP && filterID == FeatureTypeCsc))
3478 {
3479 if (filterID == FeatureTypeCsc && IsHDRfilterExist(featureSubPipe) && !engineCaps->frontEndCscNeeded)
3480 {
3481 // When front end csc is enabled and set to needed, CSC is handled in vebox FECSC. So in such case, no need to leave the CSC filter to be added in AddFiltersBasedOnCaps
3482 // When front end csc is not enabled and HDR filter exist, handle CSC previous to HDR in AddFiltersBasedOnCaps
3483 VP_PUBLIC_NORMALMESSAGE("HDR exist, handle CSC previous to HDR in AddFiltersBasedOnCaps");
3484 continue;
3485 }
3486
3487 if (!engineCaps->bEnabled && caps.bIECP && filterID == FeatureTypeCsc)
3488 {
3489 engineCaps->bEnabled = 1;
3490 engineCaps->VeboxNeeded = 1;
3491 }
3492
3493 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(feature, caps, EngineTypeVebox));
3494 }
3495 else if (caps.bRender && caps.bRenderHdr &&
3496 (engineCaps->forceEnableForHdrKernel ||
3497 engineCaps->bEnabled && engineCaps->hdrKernelSupported))
3498 {
3499 if (engineCaps->forceEnableForHdrKernel)
3500 {
3501 engineCaps->bEnabled = 1;
3502 engineCaps->RenderNeeded = 1;
3503 engineCaps->hdrKernelSupported = 1;
3504 }
3505 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(feature, caps, EngineTypeRender));
3506 }
3507 else if (caps.bRender &&
3508 (engineCaps->forceEnableForFc ||
3509 engineCaps->bEnabled && engineCaps->RenderNeeded))
3510 {
3511 if (engineCaps->forceEnableForFc)
3512 {
3513 engineCaps->bEnabled = 1;
3514 engineCaps->RenderNeeded = 1;
3515 }
3516 // use render path to implement feature.
3517 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(feature, caps, EngineTypeRender));
3518 }
3519
3520 if (engineCaps->isolated)
3521 {
3522 isolatedFeatureFound = true;
3523 break;
3524 }
3525 }
3526 }
3527
3528 SwFilterAiBase *swAiFilter = nullptr;
3529 VP_PUBLIC_CHK_STATUS_RETURN(featureSubPipe->GetAiSwFilter(swAiFilter));
3530 if (swAiFilter)
3531 {
3532 VP_EngineEntry &engineCaps = swAiFilter->GetFilterEngineCaps();
3533 if (isolatedFeatureSelected == engineCaps.isolated)
3534 {
3535 if (caps.bRender && engineCaps.bEnabled && engineCaps.RenderNeeded)
3536 {
3537 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(swAiFilter, caps, EngineTypeRender));
3538 if (engineCaps.isolated)
3539 {
3540 isolatedFeatureFound = true;
3541 }
3542 }
3543 else if (caps.bNpu && engineCaps.bEnabled && engineCaps.npuNeeded)
3544 {
3545 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(swAiFilter, caps, EngineTypeNpu));
3546 if (engineCaps.isolated)
3547 {
3548 isolatedFeatureFound = true;
3549 }
3550 }
3551 }
3552 }
3553
3554 if (isolatedFeatureSelected && !isolatedFeatureFound)
3555 {
3556 VP_PUBLIC_ASSERTMESSAGE("Isolated feature is not found!");
3557 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3558 }
3559
3560 return MOS_STATUS_SUCCESS;
3561 }
3562
3563 MOS_STATUS Policy::LayerSelectForProcess(std::vector<int> &layerIndexes, SwFilterPipe& featurePipe, bool isSingleSubPipe, uint32_t pipeIndex, VP_EXECUTE_CAPS& caps)
3564 {
3565 VP_FUNC_CALL();
3566 layerIndexes.clear();
3567 if (isSingleSubPipe && !caps.bComposite && !caps.bRenderHdr)
3568 {
3569 layerIndexes.push_back(pipeIndex);
3570 return MOS_STATUS_SUCCESS;
3571 }
3572
3573 if (caps.bRenderHdr)
3574 {
3575 auto it = m_RenderFeatureHandlers.find(FeatureTypeHdrOnRender);
3576 if (m_RenderFeatureHandlers.end() == it)
3577 {
3578 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3579 }
3580 #ifdef _MEDIA_RESERVED
3581 VpPlatformInterface *vpPlatformInterface = (VpPlatformInterface *)m_vpInterface.GetHwInterface()->m_vpPlatformInterface;
3582 if (vpPlatformInterface && vpPlatformInterface->GetVpFeatureSupportBits().vpFeatureSupportBitsHdrLite)
3583 {
3584 PolicyRenderHdrLiteHandler *hdrHandler = dynamic_cast<PolicyRenderHdrLiteHandler *>(it->second);
3585 VP_PUBLIC_CHK_NULL_RETURN(hdrHandler);
3586 VP_PUBLIC_CHK_STATUS_RETURN(hdrHandler->LayerSelectForProcess(layerIndexes, featurePipe, caps));
3587 }
3588 else
3589 #endif
3590 {
3591 PolicyRenderHdrHandler *hdrHandler = dynamic_cast<PolicyRenderHdrHandler *>(it->second);
3592 VP_PUBLIC_CHK_NULL_RETURN(hdrHandler);
3593 VP_PUBLIC_CHK_STATUS_RETURN(hdrHandler->LayerSelectForProcess(layerIndexes, featurePipe, caps));
3594 }
3595 return MOS_STATUS_SUCCESS;
3596 }
3597
3598 if (!caps.bComposite)
3599 {
3600 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3601 }
3602
3603 auto it = m_RenderFeatureHandlers.find(FeatureTypeFcOnRender);
3604 if (m_RenderFeatureHandlers.end() == it)
3605 {
3606 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3607 }
3608
3609 auto osInterface = m_vpInterface.GetHwInterface()->m_osInterface;
3610
3611 for (uint32_t i = 0; i < featurePipe.GetSurfaceCount(true); ++i)
3612 {
3613 VP_SURFACE *input = featurePipe.GetSurface(true, i);
3614 VP_PUBLIC_CHK_NULL_RETURN(input);
3615 VP_PUBLIC_CHK_NULL_RETURN(input->osSurface);
3616 uint64_t gpuVa = osInterface->pfnGetResourceGfxAddress(osInterface, &input->osSurface->OsResource);
3617
3618 VP_PUBLIC_NORMALMESSAGE("layer %d, gpuVa = 0x%llx", i, gpuVa);
3619 }
3620
3621 VP_SURFACE *output = featurePipe.GetSurface(false, 0);
3622 VP_PUBLIC_CHK_NULL_RETURN(output);
3623 VP_PUBLIC_CHK_NULL_RETURN(output->osSurface);
3624 uint64_t gpuVa = osInterface->pfnGetResourceGfxAddress(osInterface, &output->osSurface->OsResource);
3625 VP_PUBLIC_NORMALMESSAGE("target, gpuVa = 0x%llx", gpuVa);
3626
3627 PolicyFcWrapHandler *fcHandler = dynamic_cast<PolicyFcWrapHandler *>(it->second);
3628 VP_PUBLIC_CHK_NULL_RETURN(fcHandler);
3629 VP_PUBLIC_CHK_STATUS_RETURN(fcHandler->LayerSelectForProcess(layerIndexes, featurePipe, caps));
3630
3631 if (layerIndexes.size() < featurePipe.GetSurfaceCount(true))
3632 {
3633 // Multi pass needed.
3634 VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface.GetResourceManager()->PrepareFcIntermediateSurface(featurePipe));
3635 }
3636
3637 return MOS_STATUS_SUCCESS;
3638 }
3639
3640 MOS_STATUS Policy::AddInputSurfaceForSingleLayer(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t &executePipeIndex, VP_EXECUTE_CAPS& caps)
3641 {
3642 VP_FUNC_CALL();
3643 // Single layer add input surface
3644 if (caps.value)
3645 {
3646 // Move surfaces from subSwFilterPipe to executedFilters.
3647 VP_SURFACE *surfInput = featurePipe.GetSurface(true, pipeIndex);
3648 if (surfInput)
3649 {
3650 PVP_SURFACE pastRefSurface = nullptr;
3651 PVP_SURFACE futureRefSurface = nullptr;
3652 // surface should be added before swFilters, since empty feature pipe will be allocated accordingly when surface being added.
3653 executePipeIndex = executedFilters.GetSurfaceCount(true);
3654 VP_PUBLIC_CHK_STATUS_RETURN(executedFilters.AddSurface(surfInput, true, executePipeIndex));
3655 if (caps.bAiPath)
3656 {
3657 // For AI path, past/future ref surfaces may be used during multi passes.
3658 // So copy the past/future surfaces into execute pipe instead of move them into execute pipe
3659 // If common pipe also need this logic in the future, remove the "if (caps.bAiPath)" and combine the code
3660 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
3661 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_osInterface);
3662 PVP_SURFACE tmpPastSurface = featurePipe.GetPastSurface(pipeIndex);
3663 PVP_SURFACE tmpFutureSurface = featurePipe.GetFutureSurface(pipeIndex);
3664 if (nullptr != tmpPastSurface && 0 != tmpPastSurface->GetAllocationHandle(m_vpInterface.GetHwInterface()->m_osInterface))
3665 {
3666 pastRefSurface = m_vpInterface.GetAllocator().AllocateVpSurface(*tmpPastSurface);
3667 }
3668 if (nullptr != tmpFutureSurface && 0 != tmpFutureSurface->GetAllocationHandle(m_vpInterface.GetHwInterface()->m_osInterface))
3669 {
3670 futureRefSurface = m_vpInterface.GetAllocator().AllocateVpSurface(*tmpFutureSurface);
3671 }
3672 }
3673 else
3674 {
3675 pastRefSurface = featurePipe.RemovePastSurface(pipeIndex);
3676 futureRefSurface = featurePipe.RemoveFutureSurface(pipeIndex);
3677 }
3678 executedFilters.SetPastSurface(executePipeIndex, pastRefSurface);
3679 executedFilters.SetFutureSurface(executePipeIndex, futureRefSurface);
3680 executedFilters.SetLinkedLayerIndex(executePipeIndex, pipeIndex);
3681 }
3682 else
3683 {
3684 VP_PUBLIC_ASSERTMESSAGE("No input for current pipe");
3685 }
3686 }
3687 return MOS_STATUS_SUCCESS;
3688 }
3689
3690 MOS_STATUS Policy::SetupExecuteFilter(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params)
3691 {
3692 VP_FUNC_CALL();
3693
3694 VP_PUBLIC_CHK_NULL_RETURN(params.executedFilters);
3695
3696 for (uint32_t i = 0; i < layerIndexes.size(); ++i)
3697 {
3698 VP_PUBLIC_CHK_STATUS_RETURN(AddInputSurfaceForSingleLayer(featurePipe, layerIndexes[i], *params.executedFilters, i, caps));
3699 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeaturePipeSingleLayer(featurePipe, layerIndexes[i], *params.executedFilters, i, caps));
3700 VP_PUBLIC_CHK_STATUS_RETURN(AddFiltersBasedOnCaps(featurePipe, layerIndexes[i], caps, *params.executedFilters, i));
3701 }
3702
3703 /* Place Holder: order pipe need to be insert in next step*/
3704
3705 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeatureOutputPipe(layerIndexes, featurePipe, *params.executedFilters, caps));
3706
3707 return MOS_STATUS_SUCCESS;
3708 }
3709
3710 MOS_STATUS Policy::UpdateFeaturePipe(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t executePipeIndex,
3711 bool isInputPipe, VP_EXECUTE_CAPS& caps)
3712 {
3713 VP_FUNC_CALL();
3714 SwFilterSubPipe* featureSubPipe = featurePipe.GetSwFilterSubPipe(isInputPipe, pipeIndex);
3715 uint32_t featureSelected = 0;
3716
3717 VP_PUBLIC_CHK_NULL_RETURN(featureSubPipe);
3718 // Move swfilter from feature sub pipe to params.executedFilters
3719 for (auto filterID : m_featurePool)
3720 {
3721 SwFilter *feature = (SwFilter*)featureSubPipe->GetSwFilter(FeatureType(filterID));
3722 if (feature)
3723 {
3724 VP_EngineEntry *engineCaps = &(feature->GetFilterEngineCaps());
3725
3726 if (engineCaps->usedForNextPass)
3727 {
3728 continue;
3729 }
3730
3731 if ((caps.bSFC || caps.bVebox) && engineCaps->bEnabled && IS_FEATURE_TYPE_ON_VEBOX_SFC(feature->GetFeatureType()) &&
3732 m_VeboxSfcFeatureHandlers.end() != m_VeboxSfcFeatureHandlers.find(feature->GetFeatureType()))
3733 {
3734 // Engine has been assigned to feature.
3735 auto it = m_VeboxSfcFeatureHandlers.find(feature->GetFeatureType());
3736 if (m_VeboxSfcFeatureHandlers.end() == it)
3737 {
3738 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_NULL_POINTER);
3739 }
3740 PolicyFeatureHandler *handler = it->second;
3741 VP_PUBLIC_CHK_STATUS_RETURN(handler->UpdateFeaturePipe(caps, *feature, featurePipe, executedFilters, isInputPipe, executePipeIndex));
3742 if (!engineCaps->bEnabled)
3743 {
3744 VP_PUBLIC_NORMALMESSAGE("filter is disable during UpdateFeaturePipe");
3745 }
3746 ++featureSelected;
3747 }
3748 else if (caps.bRender && engineCaps->bEnabled && IS_FEATURE_TYPE_ON_RENDER(feature->GetFeatureType()) &&
3749 m_RenderFeatureHandlers.end() != m_RenderFeatureHandlers.find(feature->GetFeatureType()))
3750 {
3751 auto it = m_RenderFeatureHandlers.find(feature->GetFeatureType());
3752 if (m_RenderFeatureHandlers.end() == it)
3753 {
3754 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_NULL_POINTER);
3755 }
3756 PolicyFeatureHandler *handler = it->second;
3757
3758 VP_PUBLIC_CHK_STATUS_RETURN(handler->UpdateFeaturePipe(caps, *feature, featurePipe, executedFilters, isInputPipe, executePipeIndex));
3759 if (!engineCaps->bEnabled)
3760 {
3761 VP_PUBLIC_NORMALMESSAGE("filter is disable during UpdateFeaturePipe");
3762 }
3763 ++featureSelected;
3764 }
3765 else
3766 {
3767 auto *handlers = (caps.bSFC || caps.bVebox) ? &m_VeboxSfcFeatureHandlers : &m_RenderFeatureHandlers;
3768 auto it = handlers->find(feature->GetFeatureType());
3769 if (handlers->end() != it)
3770 {
3771 PolicyFeatureHandler *handler = it->second;
3772 VP_PUBLIC_CHK_STATUS_RETURN(handler->UpdateUnusedFeature(caps, *feature, featurePipe, executedFilters, isInputPipe, executePipeIndex));
3773 }
3774 }
3775
3776 if (!engineCaps->bEnabled && !engineCaps->usedForNextPass)
3777 {
3778 // Feature may be disabled during UpdateFeaturePipe, such as colorfill and alpha, which will
3779 // be combined into scaling in sfc.
3780 SwFilterFeatureHandler *handler = m_vpInterface.GetSwFilterHandler(feature->GetFeatureType());
3781 if (!handler)
3782 {
3783 VP_PUBLIC_ASSERTMESSAGE("no Feature Handle, Return Pipe Init Error");
3784 return MOS_STATUS_INVALID_HANDLE;
3785 }
3786
3787 featurePipe.RemoveSwFilter(feature);
3788 handler->Destory(feature);
3789 VP_PUBLIC_NORMALMESSAGE("filter is disable during UpdateFeaturePipe");
3790 }
3791 }
3792 }
3793
3794 SwFilterAiBase *swAiFilter = nullptr;
3795 VP_PUBLIC_CHK_STATUS_RETURN(featureSubPipe->GetAiSwFilter(swAiFilter));
3796 if (swAiFilter)
3797 {
3798 VP_EngineEntry &engineCaps = swAiFilter->GetFilterEngineCaps();
3799 if (engineCaps.bEnabled && isInputPipe &&
3800 caps.bRender && IS_FEATURE_TYPE_ON_RENDER(swAiFilter->GetFeatureType()) &&
3801 m_RenderFeatureHandlers.end() != m_RenderFeatureHandlers.find(FeatureTypeAi))
3802 {
3803 auto it = m_RenderFeatureHandlers.find(FeatureTypeAi);
3804 PolicyFeatureHandler *handler = it->second;
3805 VP_PUBLIC_CHK_STATUS_RETURN(handler->UpdateFeaturePipe(caps, *swAiFilter, featurePipe, executedFilters, isInputPipe, executePipeIndex));
3806 ++featureSelected;
3807 }
3808 else if (engineCaps.bEnabled && isInputPipe &&
3809 caps.bNpu && IS_FEATURE_TYPE_ON_NPU(swAiFilter->GetFeatureType()) &&
3810 m_NpuFeatureHandlers.end() != m_NpuFeatureHandlers.find(FeatureTypeAi))
3811 {
3812 auto it = m_NpuFeatureHandlers.find(FeatureTypeAi);
3813 PolicyFeatureHandler *handler = it->second;
3814 VP_PUBLIC_CHK_STATUS_RETURN(handler->UpdateFeaturePipe(caps, *swAiFilter, featurePipe, executedFilters, isInputPipe, executePipeIndex));
3815 ++featureSelected;
3816 }
3817 else
3818 {
3819 SwFilterFeatureHandler *handler = m_vpInterface.GetSwFilterHandler(swAiFilter->GetFeatureType());
3820 VP_PUBLIC_CHK_NULL_RETURN(handler);
3821 SwFilter *swFilter = swAiFilter;
3822 featurePipe.RemoveSwFilter(swFilter);
3823 handler->Destory(swFilter);
3824 }
3825 }
3826
3827 if (!isInputPipe && featureSelected && !featureSubPipe->IsEmpty() && featurePipe.IsAllInputPipeSurfaceFeatureEmpty())
3828 {
3829 VP_PUBLIC_ASSERTMESSAGE("Not all output features being selected!");
3830 }
3831
3832 return MOS_STATUS_SUCCESS;
3833 }
3834
3835 MOS_STATUS Policy::UpdateFeaturePipeSingleLayer(SwFilterPipe &featurePipe, uint32_t pipeIndex, SwFilterPipe &executedFilters, uint32_t executePipeIndex, VP_EXECUTE_CAPS& caps)
3836 {
3837 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeaturePipe(featurePipe, pipeIndex, executedFilters, executePipeIndex, true, caps));
3838
3839 return MOS_STATUS_SUCCESS;
3840 }
3841
3842 MOS_STATUS Policy::UpdateFeatureOutputPipe(std::vector<int> &layerIndexes, SwFilterPipe &featurePipe, SwFilterPipe &executedFilters, VP_EXECUTE_CAPS& caps)
3843 {
3844 VP_FUNC_CALL();
3845 if (!caps.bOutputPipeFeatureInuse)
3846 {
3847 return MOS_STATUS_SUCCESS;
3848 }
3849
3850 if (!featurePipe.IsAllInputPipeSurfaceFeatureEmpty(layerIndexes))
3851 {
3852 VP_PUBLIC_ASSERTMESSAGE("bOutputPipeFeatureInuse being set but input pipe is not empty.");
3853 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
3854 }
3855
3856 VP_PUBLIC_CHK_STATUS_RETURN(UpdateFeaturePipe(featurePipe, 0, executedFilters, 0, false, caps));
3857
3858 return MOS_STATUS_SUCCESS;
3859 }
3860
3861 MOS_STATUS Policy::SetupFilterResource(SwFilterPipe& featurePipe, std::vector<int> &layerIndexes, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params)
3862 {
3863 VP_FUNC_CALL();
3864
3865 VP_SURFACE* surfInput = nullptr;
3866 VP_SURFACE* surfOutput = nullptr;
3867 uint32_t i = 0;
3868
3869 if (featurePipe.IsEmpty())
3870 {
3871 // If all subpipes are empty, which means no swfilter exists in featurePipe, just move output surface from featurePipe to executedFilters.
3872 // In such case, processing complete.
3873 // Update the input feature surfaces
3874 surfOutput = featurePipe.RemoveSurface(false, 0);
3875 VP_PUBLIC_CHK_NULL_RETURN(surfOutput);
3876 // surface should be added before swFilters, since empty feature pipe will be allocated accordingly when surface being added.
3877 VP_PUBLIC_CHK_STATUS_RETURN(params.executedFilters->AddSurface(surfOutput, false, 0));
3878 VP_PUBLIC_NORMALMESSAGE("Output surface in use, since no filters left in featurePipe.");
3879 }
3880 else if (RenderTargetTypeParameter == featurePipe.GetRenderTargetType() ||
3881 RenderTargetTypeParameter == params.executedFilters->GetRenderTargetType() ||
3882 caps.bAiPath)
3883 {
3884 surfOutput = featurePipe.GetSurface(false, 0);
3885 VP_PUBLIC_CHK_NULL_RETURN(surfOutput);
3886 VP_SURFACE *surfOutput2 = m_vpInterface.GetAllocator().AllocateVpSurface(*surfOutput);
3887 VP_PUBLIC_CHK_NULL_RETURN(surfOutput2);
3888 VP_PUBLIC_CHK_STATUS_RETURN(params.executedFilters->AddSurface(surfOutput2, false, 0));
3889 VP_PUBLIC_NORMALMESSAGE("Output surface in use, since only parameter filters in featurePipe.");
3890 }
3891 else if (caps.bOutputPipeFeatureInuse)
3892 {
3893 // Use intermedia surfaces for multi layer case, or color fill during composition may not
3894 // act correctly.
3895 VP_PUBLIC_NORMALMESSAGE("Intermedia surface in use with 1 == bOutputPipeFeatureInuse.");
3896 }
3897 else if (IsSecureResourceNeeded(caps))
3898 {
3899 VP_PUBLIC_CHK_STATUS_RETURN(UpdateSecureExecuteResource(featurePipe, caps, params));
3900 }
3901 else
3902 {
3903 // If not assign output surface, intermedia surface will be assigned in AssignExecuteResource.
3904 }
3905 VP_PUBLIC_CHK_STATUS_RETURN(AssignExecuteResource(caps, params));
3906
3907 SwFilterSubPipe *subPipe = nullptr;
3908
3909 if (1 == layerIndexes.size())
3910 {
3911 subPipe = featurePipe.GetSwFilterSubPipe(true, layerIndexes[0]);
3912 }
3913
3914 if (featurePipe.IsEmpty())
3915 {
3916 // Update the input feature surfaces
3917 for (i = 0; i < layerIndexes.size(); ++i)
3918 {
3919 surfInput = featurePipe.RemoveSurface(true, layerIndexes[i]);
3920 }
3921 }
3922 else if (subPipe && RenderTargetTypeParameter == subPipe->GetRenderTargetType() ||
3923 RenderTargetTypeParameter == params.executedFilters->GetRenderTargetType() ||
3924 caps.bAiPath)
3925 {
3926 surfInput = featurePipe.GetSurface(true, layerIndexes[0]);
3927 VP_PUBLIC_CHK_NULL_RETURN(surfInput);
3928 VP_SURFACE* input = m_vpInterface.GetAllocator().AllocateVpSurface(*surfInput);
3929 VP_PUBLIC_CHK_NULL_RETURN(input);
3930 input->SurfType = SURF_IN_PRIMARY;
3931 featurePipe.ReplaceSurface(input, true, layerIndexes[0]);
3932 if (caps.bAiPath && subPipe)
3933 {
3934 VP_SURFACE *output = featurePipe.GetSurface(false, 0);
3935 VP_PUBLIC_CHK_STATUS_RETURN(AddCommonFilters(*subPipe, surfInput, output));
3936 }
3937 }
3938 else if (IsSecureResourceNeeded(caps))
3939 {
3940 VP_PUBLIC_NORMALMESSAGE("Secure Process Enabled, no need further process");
3941 }
3942 else
3943 {
3944 auto osInterface = m_vpInterface.GetHwInterface()->m_osInterface;
3945 auto outputSurfaceExePipe = params.executedFilters->GetSurface(false, 0);
3946 VP_PUBLIC_CHK_NULL_RETURN(outputSurfaceExePipe);
3947 auto outputSurface = featurePipe.GetSurface(false, 0);
3948 VP_PUBLIC_CHK_NULL_RETURN(outputSurface);
3949 bool outputSurfaceInuse =
3950 outputSurfaceExePipe->GetAllocationHandle(osInterface) == outputSurface->GetAllocationHandle(osInterface);
3951
3952 if (outputSurfaceInuse)
3953 {
3954 // Update the input feature surfaces
3955 for (i = 0; i < layerIndexes.size(); ++i)
3956 {
3957 surfInput = featurePipe.RemoveSurface(true, layerIndexes[i]);
3958 }
3959 }
3960 else
3961 {
3962 // multi-pass with intermedia surface case.
3963 auto intermediaSurface = outputSurfaceExePipe;
3964 VP_SURFACE *input = m_vpInterface.GetAllocator().AllocateVpSurface(*intermediaSurface);
3965 VP_PUBLIC_CHK_NULL_RETURN(input);
3966
3967 // For FC, also reuse first pipe for the composition layer in previous steps.
3968 auto originInput = featurePipe.GetSurface(true, layerIndexes[0]);
3969 if (originInput == nullptr)
3970 {
3971 m_vpInterface.GetAllocator().DestroyVpSurface(input);
3972 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_NULL_POINTER);
3973 }
3974
3975 input->SurfType = originInput->SurfType;
3976 featurePipe.ReplaceSurface(input, true, layerIndexes[0]);
3977
3978 // Update other input surfaces
3979 for (i = 1; i < layerIndexes.size(); ++i)
3980 {
3981 surfInput = featurePipe.RemoveSurface(true, layerIndexes[i]);
3982 }
3983
3984 auto swFilterSubPipe = featurePipe.GetSwFilterSubPipe(true, layerIndexes[0]);
3985 VP_PUBLIC_CHK_NULL_RETURN(swFilterSubPipe);
3986
3987 VP_SURFACE *output = featurePipe.GetSurface(false, 0);
3988 VP_PUBLIC_CHK_NULL_RETURN(output);
3989
3990 // swFilters will be updated later in Policy::BuildExecuteFilter.
3991 VP_PUBLIC_CHK_STATUS_RETURN(AddCommonFilters(*swFilterSubPipe, input, output));
3992 }
3993 }
3994
3995 return MOS_STATUS_SUCCESS;
3996 }
3997
3998 MOS_STATUS Policy::AddCommonFilters(SwFilterSubPipe &swFilterSubPipe, VP_SURFACE *input, VP_SURFACE *output)
3999 {
4000 VP_FUNC_CALL();
4001 VP_PUBLIC_CHK_NULL_RETURN(input);
4002 VP_PUBLIC_CHK_NULL_RETURN(output);
4003
4004 MOS_STATUS status = MOS_STATUS_SUCCESS;
4005 FeatureType featureList[] = { FeatureTypeScaling };
4006 int32_t featureCount = sizeof(featureList) / sizeof(featureList[0]);
4007 VP_EXECUTE_CAPS caps = {};
4008
4009 for (int32_t i = 0; i < featureCount; ++i)
4010 {
4011 FeatureType featureType = featureList[i];
4012
4013 SwFilter *swFilter = swFilterSubPipe.GetSwFilter(featureType);
4014 if (nullptr != swFilter)
4015 {
4016 continue;
4017 }
4018
4019 VP_PUBLIC_NORMALMESSAGE("Feature %d is added.", FeatureTypeScaling);
4020
4021 caps.value = 0;
4022
4023 SwFilterFeatureHandler *handler = m_vpInterface.GetSwFilterHandler(featureType);
4024 VP_PUBLIC_CHK_NULL_RETURN(handler);
4025 swFilter = handler->CreateSwFilter();
4026 VP_PUBLIC_CHK_NULL_RETURN(swFilter);
4027
4028 status = swFilter->Configure(input, output, caps);
4029 if (MOS_FAILED(status))
4030 {
4031 handler->Destory(swFilter);
4032 VP_PUBLIC_CHK_STATUS_RETURN(status);
4033 }
4034 status = swFilterSubPipe.AddSwFilterUnordered(swFilter);
4035 if (MOS_FAILED(status))
4036 {
4037 handler->Destory(swFilter);
4038 VP_PUBLIC_CHK_STATUS_RETURN(status);
4039 }
4040 }
4041
4042 return MOS_STATUS_SUCCESS;
4043 }
4044
4045 MOS_STATUS Policy::UpdateExeCaps(SwFilter* feature, VP_EXECUTE_CAPS& caps, EngineType Type)
4046 {
4047 VP_FUNC_CALL();
4048 VP_PUBLIC_CHK_NULL_RETURN(feature);
4049
4050 FeatureType featureType = feature->GetFeatureType();
4051
4052 if (Type == EngineTypeVeboxSfc)
4053 {
4054 switch (featureType)
4055 {
4056 case FeatureTypeCsc:
4057 caps.bSfcCsc = 1;
4058 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Csc, Sfc)));
4059 break;
4060 case FeatureTypeScaling:
4061 caps.bSfcScaling = 1;
4062 if (feature->GetFilterEngineCaps().sfc2PassScalingNeededX || feature->GetFilterEngineCaps().sfc2PassScalingNeededY)
4063 {
4064 caps.b1stPassOfSfc2PassScaling = true;
4065 }
4066 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Scaling, Sfc)));
4067 break;
4068 case FeatureTypeRotMir:
4069 caps.bSfcRotMir = 1;
4070 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(RotMir, Sfc)));
4071 break;
4072 case FeatureTypeColorFill:
4073 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(ColorFill, Sfc)));
4074 break;
4075 case FeatureTypeAlpha:
4076 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Alpha, Sfc)));
4077 break;
4078 default:
4079 break;
4080 }
4081 }
4082
4083 if (Type == EngineTypeVebox)
4084 {
4085 switch (featureType)
4086 {
4087 case FeatureTypeDn:
4088 caps.bDN = 1;
4089 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Dn, Vebox)));
4090 break;
4091 case FeatureTypeSte:
4092 caps.bSTE = 1;
4093 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Ste, Vebox)));
4094 break;
4095 case FeatureTypeDi:
4096 caps.bDI = 1;
4097 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Di, Vebox)));
4098 break;
4099 case FeatureTypeTcc:
4100 caps.bTCC = 1;
4101 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Tcc, Vebox)));
4102 break;
4103 case FeatureTypeProcamp:
4104 if (caps.bForceProcampToRender)
4105 {
4106 caps.bProcamp = 0;
4107 break;
4108 }
4109 caps.bProcamp = 1;
4110 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Procamp, Vebox)));
4111 break;
4112 case FeatureTypeCsc:
4113 if (feature->GetFilterEngineCaps().frontEndCscNeeded)
4114 {
4115 caps.bFeCSC = 1;
4116 }
4117 else
4118 {
4119 caps.bBeCSC = 1;
4120 }
4121 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Csc, Vebox)));
4122 break;
4123 case FeatureTypeHdr:
4124 caps.bHDR3DLUT = 1;
4125 caps.b3DlutOutput |= 1;
4126 caps.bHdr33lutsize = feature->GetFilterEngineCaps().isHdr33LutSizeEnabled;
4127 caps.bH2S = feature->GetFilterEngineCaps().isH2S;
4128 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Hdr, Vebox)));
4129 break;
4130 case FeatureTypeCgc:
4131 caps.bCGC = 1;
4132 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Cgc, Vebox)));
4133 VP_PUBLIC_CHK_STATUS_RETURN(UpdateCGCMode(feature, caps, Type));
4134 break;
4135 default:
4136 break;
4137 }
4138 }
4139
4140 if (Type == EngineTypeRender)
4141 {
4142 switch (featureType)
4143 {
4144 case FeatureTypeCsc:
4145 caps.bComposite = caps.bRenderHdr ? 0 : 1;
4146 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Csc, Render)));
4147 break;
4148 case FeatureTypeScaling:
4149 caps.bComposite = caps.bRenderHdr ? 0 : 1;
4150 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Scaling, Render)));
4151 break;
4152 case FeatureTypeRotMir:
4153 caps.bComposite = caps.bRenderHdr ? 0 : 1;
4154 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(RotMir, Render)));
4155 break;
4156 case FeatureTypeProcamp:
4157 caps.bComposite = 1;
4158 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Procamp, Render)));
4159 break;
4160 case FeatureTypeDi:
4161 caps.bDI = 1;
4162 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Di, Render)));
4163 break;
4164 case FeatureTypeLumakey:
4165 caps.bComposite = 1;
4166 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Lumakey, Render)));
4167 break;
4168 case FeatureTypeBlending:
4169 caps.bComposite = 1;
4170 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Blending, Render)));
4171 break;
4172 case FeatureTypeColorFill:
4173 caps.bComposite = 1;
4174 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(ColorFill, Render)));
4175 break;
4176 case FeatureTypeAlpha:
4177 caps.bComposite = 1;
4178 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Alpha, Render)));
4179 break;
4180 case FeatureTypeHdr:
4181 if (feature->GetFilterEngineCaps().isolated)
4182 {
4183 caps.b3DLutCalc = 1;
4184 if (feature->GetFilterEngineCaps().isHdr33LutSizeEnabled)
4185 {
4186 caps.bHdr33lutsize = 1;
4187 }
4188 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Hdr3DLutCal, Render)));
4189 }
4190 else
4191 {
4192 caps.bHdr = 1;
4193 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(Hdr, Render)));
4194 }
4195 break;
4196 case FeatureTypeDn:
4197 if (feature->GetFilterEngineCaps().isolated)
4198 {
4199 caps.bHVSCalc = 1;
4200 feature->SetFeatureType(FeatureType(FEATURE_TYPE_EXECUTE(DnHVSCal, Render)));
4201 }
4202 else
4203 {
4204 VP_PUBLIC_ASSERTMESSAGE("DN HVS Kernel has not been enabled in APO path");
4205 }
4206 break;
4207 default:
4208 if (dynamic_cast<SwFilterAiBase*>(feature) != nullptr)
4209 {
4210 // For AI features, they have different kinds of feature types, but they all go through VpAiFilter through caps.bAiPath
4211 if (feature->GetFilterEngineCaps().isolated)
4212 {
4213 caps.bAiPath = 1;
4214 feature->SetFeatureType(FeatureType(featureType | FEATURE_TYPE_ENGINE_BITS_RENDER));
4215 }
4216 else
4217 {
4218 VP_PUBLIC_ASSERTMESSAGE("AI Kernel must be isolated");
4219 }
4220 }
4221 break;
4222 }
4223
4224 if (caps.bComposite + caps.bRenderHdr + caps.bAiPath > 1)
4225 {
4226 VP_PUBLIC_ASSERTMESSAGE("FC and Render HDR and Render AI should not be selected at same time.");
4227 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
4228 }
4229 }
4230
4231 if (Type == EngineTypeNpu)
4232 {
4233 if (dynamic_cast<SwFilterAiBase *>(feature) != nullptr)
4234 {
4235 // For AI features, they have different kinds of feature types, but they all go through VpAiFilter through caps.bAiPath
4236 if (feature->GetFilterEngineCaps().isolated)
4237 {
4238 caps.bAiPath = 1;
4239 feature->SetFeatureType(FeatureType(featureType | FEATURE_TYPE_ENGINE_BITS_NPU));
4240 }
4241 else
4242 {
4243 VP_PUBLIC_ASSERTMESSAGE("AI Kernel must be isolated");
4244 }
4245 }
4246 }
4247
4248 return MOS_STATUS_SUCCESS;
4249 }
4250
4251 MOS_STATUS Policy::UpdateCGCMode(SwFilter* feature, VP_EXECUTE_CAPS& caps, EngineType Type)
4252 {
4253 VP_FUNC_CALL();
4254
4255 VP_PUBLIC_CHK_NULL_RETURN(feature);
4256 SwFilterCgc *cgcFilter = dynamic_cast<SwFilterCgc*>(feature);
4257 VP_PUBLIC_CHK_NULL_RETURN(cgcFilter);
4258
4259 caps.bBt2020ToRGB = (caps.bCGC && cgcFilter->IsBt2020ToRGBEnabled()) ? 1 : 0;
4260
4261 return MOS_STATUS_SUCCESS;
4262 }
4263
4264 MOS_STATUS Policy::AssignExecuteResource(VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params)
4265 {
4266 VP_FUNC_CALL();
4267 VP_PUBLIC_CHK_NULL_RETURN(params.executedFilters);
4268 VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetResourceManager());
4269 VP_PUBLIC_CHK_STATUS_RETURN(m_vpInterface.GetResourceManager()->AssignExecuteResource(m_featurePool, caps, *params.executedFilters));
4270 return MOS_STATUS_SUCCESS;
4271 }
4272
4273 MOS_STATUS Policy::BuildVeboxSecureFilters(SwFilterPipe& featurePipe, VP_EXECUTE_CAPS& caps, HW_FILTER_PARAMS& params)
4274 {
4275 VP_FUNC_CALL();
4276
4277 return MOS_STATUS_SUCCESS;
4278 }
4279
4280 MOS_STATUS Policy::ReleaseHwFilterParam(HW_FILTER_PARAMS &params)
4281 {
4282 VP_FUNC_CALL();
4283
4284 if (EngineTypeInvalid == params.Type || params.Params.empty())
4285 {
4286 params.Type = EngineTypeInvalid;
4287 while (!params.Params.empty())
4288 {
4289 HwFilterParameter *p = params.Params.back();
4290 params.Params.pop_back();
4291 MOS_Delete(p);
4292 }
4293
4294 m_vpInterface.GetSwFilterPipeFactory().Destory(params.executedFilters);
4295
4296 return MOS_STATUS_SUCCESS;
4297 }
4298
4299 std::map<FeatureType, PolicyFeatureHandler*> &featureHandler =
4300 (EngineTypeVebox == params.Type || EngineTypeVeboxSfc == params.Type) ? m_VeboxSfcFeatureHandlers : m_RenderFeatureHandlers;
4301
4302 params.Type = EngineTypeInvalid;
4303 while (!params.Params.empty())
4304 {
4305 HwFilterParameter *p = params.Params.back();
4306 params.Params.pop_back();
4307 if (p)
4308 {
4309 auto it = featureHandler.find(p->GetFeatureType());
4310 if (featureHandler.end() == it)
4311 {
4312 MOS_Delete(p);
4313 }
4314 else
4315 {
4316 it->second->ReleaseHwFeatureParameter(p);
4317 }
4318 }
4319 }
4320
4321 m_vpInterface.GetSwFilterPipeFactory().Destory(params.executedFilters);
4322
4323 return MOS_STATUS_SUCCESS;
4324 }
4325
4326 MOS_STATUS Policy::AddFiltersBasedOnCaps(
4327 SwFilterPipe& featurePipe,
4328 uint32_t pipeIndex,
4329 VP_EXECUTE_CAPS& caps,
4330 SwFilterPipe& executedFilters,
4331 uint32_t executedPipeIndex)
4332 {
4333 VP_FUNC_CALL();
4334
4335 // Create and Add CSC filter for VEBOX IECP chromasiting config
4336 // HDR State holder: To keep same as Legacy path -- for VE 3DLut HDR, enable VE chroma up sampling when ONLY VE output.
4337 // When FeCSC is enabled, it means the csc is done in vebox front end csc. This only happens when ONLY VE output and the platform supports 4bpp FeCSC. Then there is no need to add a new backend csc
4338 if (!caps.bBeCSC && ((caps.bSFC && (caps.bIECP || caps.bDI)) || (!caps.bSFC && (caps.bIECP || caps.b3DlutOutput || caps.bBt2020ToRGB) && !caps.bFeCSC)))
4339 {
4340 VP_PUBLIC_CHK_STATUS_RETURN(AddNewFilterOnVebox(featurePipe, pipeIndex, caps, executedFilters, executedPipeIndex, FeatureTypeCsc));
4341 }
4342 else
4343 {
4344 if (caps.bBeCSC && caps.bHDR3DLUT)
4345 {
4346 // bBeCSC won't be set in GetCSCExecutionCaps for HDR case
4347 VP_PUBLIC_ASSERTMESSAGE("bBeCSC shouldn't be set in GetCSCExecutionCaps for HDR case");
4348 VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
4349 }
4350 }
4351 return MOS_STATUS_SUCCESS;
4352 }
4353
4354 MOS_STATUS Policy::AddNewFilterOnVebox(
4355 SwFilterPipe& featurePipe,
4356 uint32_t pipeIndex,
4357 VP_EXECUTE_CAPS& caps,
4358 SwFilterPipe& executedFilters,
4359 uint32_t executedPipeIndex,
4360 FeatureType featureType)
4361 {
4362 VP_FUNC_CALL();
4363
4364 MOS_STATUS status = MOS_STATUS_SUCCESS;
4365 PVP_SURFACE pSurfInput = featurePipe.GetSurface(true, pipeIndex);
4366 PVP_SURFACE pSurfOutput = featurePipe.GetSurface(false, 0);
4367 VP_PUBLIC_CHK_NULL_RETURN(pSurfInput);
4368 VP_PUBLIC_CHK_NULL_RETURN(pSurfOutput);
4369
4370 auto handler = m_vpInterface.GetSwFilterHandler(featureType);
4371
4372 if (!handler)
4373 {
4374 VP_PUBLIC_ASSERTMESSAGE("no Feature Handle, Return Pipe Init Error");
4375 return MOS_STATUS_INVALID_HANDLE;
4376 }
4377
4378 SwFilter* swfilter = handler->CreateSwFilter();
4379 VP_PUBLIC_CHK_NULL_RETURN(swfilter);
4380
4381 if (featureType == FeatureTypeCsc)
4382 {
4383 SwFilterCsc *csc = (SwFilterCsc *)swfilter;
4384 FeatureParamCsc cscParams = csc->GetSwFilterParams();
4385 status = GetCscParamsOnCaps(pSurfInput, pSurfOutput, caps, cscParams);
4386 if (MOS_FAILED(status))
4387 {
4388 handler->Destory(swfilter);
4389 VP_PUBLIC_CHK_STATUS_RETURN(status);
4390 }
4391 else
4392 {
4393 status = csc->Configure(cscParams);
4394 }
4395 }
4396 else if (featureType == FeatureTypeDn)
4397 {
4398 SwFilterDenoise *dn = (SwFilterDenoise *)swfilter;
4399 FeatureParamDenoise dnParams = dn->GetSwFilterParams();
4400 status = GetDnParamsOnCaps(pSurfInput, pSurfOutput, caps, dnParams);
4401 if (MOS_FAILED(status))
4402 {
4403 handler->Destory(swfilter);
4404 VP_PUBLIC_CHK_STATUS_RETURN(status);
4405 }
4406 else
4407 {
4408 status = dn->Configure(dnParams);
4409 }
4410 }
4411 else
4412 {
4413 status = swfilter->Configure(pSurfInput, pSurfOutput, caps);
4414 }
4415
4416 if (MOS_FAILED(status))
4417 {
4418 handler->Destory(swfilter);
4419 VP_PUBLIC_CHK_STATUS_RETURN(status);
4420 }
4421
4422 VP_PUBLIC_CHK_STATUS_RETURN(UpdateExeCaps(swfilter, caps, EngineTypeVebox));
4423
4424 status = executedFilters.AddSwFilterUnordered(swfilter, true, executedPipeIndex);
4425 VP_PUBLIC_CHK_STATUS_RETURN(status);
4426
4427 return status;
4428 }
4429
4430 MOS_STATUS GetVeboxOutputParams(VP_EXECUTE_CAPS &executeCaps, MOS_FORMAT inputFormat, MOS_TILE_TYPE inputTileType, MOS_FORMAT outputFormat, MOS_FORMAT &veboxOutputFormat, MOS_TILE_TYPE &veboxOutputTileType, VPHAL_CSPACE colorSpaceOutput);
4431
4432 MOS_STATUS Policy::GetCscParamsOnCaps(PVP_SURFACE surfInput, PVP_SURFACE surfOutput, VP_EXECUTE_CAPS &caps, FeatureParamCsc &cscParams)
4433 {
4434 VP_FUNC_CALL();
4435 if (caps.bHDR3DLUT)
4436 {
4437 cscParams.input.colorSpace = surfInput->ColorSpace;
4438 cscParams.formatInput = surfInput->osSurface->Format;
4439 cscParams.formatforCUS = Format_None;
4440 cscParams.input.chromaSiting = surfInput->ChromaSiting;
4441
4442 // CSC before HDR converts BT2020 P010 to ARGB10
4443 cscParams.output.colorSpace = CSpace_BT2020_RGB;
4444 cscParams.formatOutput = Format_B10G10R10A2;
4445 cscParams.output.chromaSiting = surfOutput->ChromaSiting;
4446
4447 cscParams.pAlphaParams = nullptr;
4448 cscParams.pIEFParams = nullptr;
4449
4450 return MOS_STATUS_SUCCESS;
4451 }
4452 else if (caps.bSFC)
4453 {
4454 MOS_FORMAT veboxOutputFormat = surfInput->osSurface->Format;
4455 MOS_TILE_TYPE veboxOutputTileType = surfInput->osSurface->TileType;
4456
4457 GetVeboxOutputParams(caps, surfInput->osSurface->Format, surfInput->osSurface->TileType, surfOutput->osSurface->Format, veboxOutputFormat, veboxOutputTileType, surfOutput->ColorSpace);
4458 cscParams.input.colorSpace = surfInput->ColorSpace;
4459 cscParams.output.colorSpace = surfInput->ColorSpace;
4460
4461 cscParams.formatInput = surfInput->osSurface->Format;
4462 cscParams.formatforCUS = Format_None;
4463 cscParams.formatOutput = veboxOutputFormat;
4464 cscParams.input.chromaSiting = surfInput->ChromaSiting;
4465 cscParams.output.chromaSiting = surfOutput->ChromaSiting;
4466
4467 cscParams.pAlphaParams = nullptr;
4468 cscParams.pIEFParams = nullptr;
4469
4470 return MOS_STATUS_SUCCESS;
4471 }
4472 else if (caps.bBt2020ToRGB || caps.bIECP)
4473 {
4474 // For BeCsc filter added in policy based on caps, it's for chroma-sitting and
4475 // SetVeboxIecpStateBecsc to use.
4476 // For BT2020 to RGB case, the VeboxInterface_BT2020YUVToRGB will be used for BeCsc setting,
4477 // which will overwritten the one by SetVeboxIecpStateBecsc.
4478 // So in GetCscParamsOnCaps for BT2020ToRGB case,
4479 // we just need to use same format and colorspace for both input and output,
4480 // just use the input format to ensure chroma-sitting parameters being correct.
4481 cscParams.input.colorSpace = surfInput->ColorSpace;
4482 cscParams.formatInput = surfInput->osSurface->Format;
4483 cscParams.formatforCUS = Format_None;
4484 cscParams.input.chromaSiting = surfInput->ChromaSiting;
4485
4486 cscParams.output.colorSpace = surfInput->ColorSpace;
4487 cscParams.formatOutput = surfInput->osSurface->Format;
4488 cscParams.output.chromaSiting = surfOutput->ChromaSiting;
4489
4490 cscParams.pAlphaParams = nullptr;
4491 cscParams.pIEFParams = nullptr;
4492
4493 return MOS_STATUS_SUCCESS;
4494 }
4495
4496 return MOS_STATUS_UNIMPLEMENTED;
4497 }
4498
4499 MOS_STATUS Policy::GetDnParamsOnCaps(PVP_SURFACE surfInput, PVP_SURFACE surfOutput, VP_EXECUTE_CAPS &caps, FeatureParamDenoise &dnParams)
4500 {
4501 VP_FUNC_CALL();
4502 dnParams.formatInput = surfInput->osSurface->Format;
4503 dnParams.heightInput = surfInput->osSurface->dwHeight;
4504 dnParams.formatOutput = Format_NV12;
4505 dnParams.sampleTypeInput = SAMPLE_PROGRESSIVE;
4506
4507 dnParams.denoiseParams.bEnableLuma = true;
4508 dnParams.denoiseParams.bEnableChroma = true;
4509 dnParams.denoiseParams.bEnableHVSDenoise = false;
4510 dnParams.denoiseParams.bAutoDetect = false;
4511 dnParams.denoiseParams.fDenoiseFactor = 64.0f;
4512
4513 #if !EMUL
4514 GMM_RESOURCE_INFO *pSrcGmmResInfo = surfInput->osSurface->OsResource.pGmmResInfo;
4515 GMM_RESOURCE_INFO *pTargetGmmResInfo = surfOutput->osSurface->OsResource.pGmmResInfo;
4516 VP_PUBLIC_CHK_NULL_RETURN(pSrcGmmResInfo);
4517 VP_PUBLIC_CHK_NULL_RETURN(pTargetGmmResInfo);
4518
4519 bool inputProtected = pSrcGmmResInfo->GetSetCpSurfTag(0, 0);
4520 bool outputProtected = pTargetGmmResInfo->GetSetCpSurfTag(0, 0);
4521
4522 if (inputProtected || outputProtected ||
4523 (m_vpInterface.GetHwInterface()->m_osInterface->osCpInterface &&
4524 m_vpInterface.GetHwInterface()->m_osInterface->osCpInterface->IsHMEnabled()))
4525 {
4526 dnParams.secureDnNeeded = true;
4527 }
4528 #endif
4529
4530 return MOS_STATUS_SUCCESS;
4531 }
4532
4533 void Policy::PrintFeatureExecutionCaps(const char *name, VP_EngineEntry &engineCaps)
4534 {
4535 VP_PUBLIC_NORMALMESSAGE("%s, value 0x%x (bEnabled %d, VeboxNeeded %d, SfcNeeded %d, RenderNeeded %d, fcSupported %d, isolated %d, veboxNotSupported %d, sfcNotSupported %d, NpuNeeded %d, isH2S %d)",
4536 name,
4537 engineCaps.value,
4538 engineCaps.bEnabled,
4539 engineCaps.VeboxNeeded,
4540 engineCaps.SfcNeeded,
4541 engineCaps.RenderNeeded,
4542 engineCaps.fcSupported,
4543 engineCaps.isolated,
4544 engineCaps.veboxNotSupported,
4545 engineCaps.sfcNotSupported,
4546 engineCaps.npuNeeded,
4547 engineCaps.isH2S);
4548 }
4549
4550 };