Debian Codegraph @

media_softlet/agnostic/common/vp/hal/packet/vp_vebox_cmd_packet.cpp

raw
1 /*
2 * Copyright (c) 2018-2023, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file vp_vebox_cmd_packet.cpp
24 //! \brief vebox packet which used in by mediapipline.
25 //! \details vebox packet provide the structures and generate the cmd buffer which mediapipline will used.
26 //!
27
28 #include "vp_vebox_cmd_packet.h"
29 #include "vp_utils.h"
30 #include "mos_resource_defs.h"
31 #include "hal_oca_interface_next.h"
32 #include "vp_render_ief.h"
33 #include "vp_feature_caps.h"
34 #include "vp_platform_interface.h"
35 #include "vp_hal_ddi_utils.h"
36 #include "mhw_vebox_itf.h"
37 #include "mhw_mi_itf.h"
38 #include "mhw_mi_cmdpar.h"
39 #include "mhw_utilities.h"
40 #include "media_scalability_defs.h"
41 #include "renderhal_platform_interface_next.h"
42
43 namespace vp {
44
45 #define INTERP(x0, x1, x, y0, y1) ((uint32_t) floor(y0+(x-x0)*(y1-y0)/(double)(x1-x0)))
46
47 const uint32_t VpVeboxCmdPacket::m_satP1Table[MHW_STE_FACTOR_MAX + 1] = {
48 0x00000000, 0xfffffffe, 0xfffffffc, 0xfffffffa, 0xfffffff6, 0xfffffff4, 0xfffffff2, 0xfffffff0, 0xffffffee, 0xffffffec };
49
50 const uint32_t VpVeboxCmdPacket::m_satS0Table[MHW_STE_FACTOR_MAX + 1] = {
51 0x000000ef, 0x00000100, 0x00000113, 0x00000129, 0x0000017a, 0x000001a2, 0x000001d3, 0x00000211, 0x00000262, 0x000002d1 };
52
53 const uint32_t VpVeboxCmdPacket::m_satS1Table[MHW_STE_FACTOR_MAX + 1] = {
54 0x000000ab, 0x00000080, 0x00000066, 0x00000055, 0x000000c2, 0x000000b9, 0x000000b0, 0x000000a9, 0x000000a2, 0x0000009c };
55
56 void VpVeboxCmdPacket::UpdateCpPrepareResources()
57 {
58 VP_FUNC_CALL();
59
60 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
61 VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(pRenderData);
62 // For 3DLut usage, it update in CpPrepareResources() for kernel usage, should
63 // reupdate here. For other feature usage, it already update in vp_pipeline
64 if (pRenderData->HDR3DLUT.is3DLutTableUpdatedByKernel == true)
65 {
66 VP_RENDER_NORMALMESSAGE("Update CP Prepare Resource for 3DLut kernel.");
67 PMOS_RESOURCE source[VPHAL_MAX_SOURCES] = {nullptr};
68 PMOS_RESOURCE target[VPHAL_MAX_TARGETS] = {nullptr};
69
70 if ((nullptr != m_hwInterface->m_osInterface) &&
71 (nullptr != m_hwInterface->m_osInterface->osCpInterface))
72 {
73 VP_SURFACE *surf = GetSurface(SurfaceTypeVeboxInput);
74 VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(surf);
75 source[0] = &(surf->osSurface->OsResource);
76
77 VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(m_renderTarget);
78 target[0] = &(m_renderTarget->osSurface->OsResource);
79
80 m_hwInterface->m_osInterface->osCpInterface->PrepareResources((void **)source, 1, (void **)target, 1);
81 }
82 }
83 }
84
85 MOS_STATUS VpVeboxCmdPacket::InitCmdBufferWithVeParams(
86 PRENDERHAL_INTERFACE pRenderHal,
87 MOS_COMMAND_BUFFER & CmdBuffer,
88 PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams)
89 {
90 VP_FUNC_CALL();
91
92 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
93 RENDERHAL_GENERIC_PROLOG_PARAMS_NEXT genericPrologParams = {};
94
95 genericPrologParams.bEnableMediaFrameTracking = pGenericPrologParams->bEnableMediaFrameTracking;
96 genericPrologParams.bMmcEnabled = pGenericPrologParams->bMmcEnabled;
97 genericPrologParams.dwMediaFrameTrackingAddrOffset = pGenericPrologParams->dwMediaFrameTrackingAddrOffset;
98 genericPrologParams.dwMediaFrameTrackingTag = pGenericPrologParams->dwMediaFrameTrackingTag;
99 genericPrologParams.presMediaFrameTrackingSurface = pGenericPrologParams->presMediaFrameTrackingSurface;
100
101 genericPrologParams.VEngineHintParams.BatchBufferCount = 2;
102 //genericPrologParams.VEngineHintParams.resScalableBatchBufs[0] = CmdBuffer[0].OsResource;
103 //genericPrologParams.VEngineHintParams.resScalableBatchBufs[1] = CmdBuffer[1].OsResource;
104 genericPrologParams.VEngineHintParams.UsingFrameSplit = true;
105 genericPrologParams.VEngineHintParams.UsingSFC = false;
106 genericPrologParams.VEngineHintParams.EngineInstance[0] = 0;
107 genericPrologParams.VEngineHintParams.EngineInstance[1] = 1;
108 genericPrologParams.VEngineHintParams.NeedSyncWithPrevious = true;
109 genericPrologParams.VEngineHintParams.SameEngineAsLastSubmission = true;
110
111 pRenderHal->pOsInterface->VEEnable = false;
112
113 // Initialize command buffer and insert prolog
114 VP_RENDER_CHK_STATUS_RETURN(pRenderHal->pfnInitCommandBuffer(
115 pRenderHal,
116 &CmdBuffer,
117 (PRENDERHAL_GENERIC_PROLOG_PARAMS)&genericPrologParams));
118
119 return eStatus;
120 }
121
122 bool VpVeboxCmdPacket::IsFormatMMCSupported(MOS_FORMAT Format)
123 {
124 VP_FUNC_CALL();
125
126 // Check if Sample Format is supported
127 if ((Format != Format_YUY2) &&
128 (Format != Format_Y210) &&
129 (Format != Format_Y410) &&
130 (Format != Format_Y216) &&
131 (Format != Format_Y416) &&
132 (Format != Format_P010) &&
133 (Format != Format_P016) &&
134 (Format != Format_AYUV) &&
135 (Format != Format_NV21) &&
136 (Format != Format_NV12) &&
137 (Format != Format_UYVY) &&
138 (Format != Format_YUYV) &&
139 (Format != Format_R10G10B10A2) &&
140 (Format != Format_B10G10R10A2) &&
141 (Format != Format_A8B8G8R8) &&
142 (Format != Format_X8B8G8R8) &&
143 (Format != Format_A8R8G8B8) &&
144 (Format != Format_X8R8G8B8) &&
145 (Format != Format_A16B16G16R16F) &&
146 (Format != Format_A16R16G16B16F))
147 {
148 VP_RENDER_NORMALMESSAGE("Unsupported Format '0x%08x' for VEBOX MMC ouput.", Format);
149 return false;
150 }
151
152 return true;
153 }
154
155 MOS_STATUS VpVeboxCmdPacket::SetSfcMmcParams()
156 {
157 VP_FUNC_CALL();
158 VP_PUBLIC_CHK_NULL_RETURN(m_sfcRender);
159 VP_PUBLIC_CHK_NULL_RETURN(m_renderTarget);
160 VP_PUBLIC_CHK_NULL_RETURN(m_renderTarget->osSurface);
161 VP_PUBLIC_CHK_NULL_RETURN(m_mmc);
162
163 // Decompress resource if surfaces need write from a un-align offset
164 if ((m_renderTarget->osSurface->CompressionMode != MOS_MMC_DISABLED) && m_sfcRender->IsSFCUncompressedWriteNeeded(m_renderTarget))
165 {
166 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
167 MOS_SURFACE details = {};
168
169 eStatus = m_osInterface->pfnGetResourceInfo(m_osInterface, &m_renderTarget->osSurface->OsResource, &details);
170
171 if (eStatus != MOS_STATUS_SUCCESS)
172 {
173 VP_RENDER_ASSERTMESSAGE("Get SFC target surface resource info failed.");
174 }
175
176 if (!m_renderTarget->osSurface->OsResource.bUncompressedWriteNeeded)
177 {
178 eStatus = m_osInterface->pfnDecompResource(m_osInterface, &m_renderTarget->osSurface->OsResource);
179
180 if (eStatus != MOS_STATUS_SUCCESS)
181 {
182 VP_RENDER_ASSERTMESSAGE("inplace decompression failed for sfc target.");
183 }
184 else
185 {
186 VP_RENDER_NORMALMESSAGE("inplace decompression enabled for sfc target RECT is not compression block align.");
187 m_renderTarget->osSurface->OsResource.bUncompressedWriteNeeded = 1;
188 }
189 }
190 }
191
192 VP_PUBLIC_CHK_STATUS_RETURN(m_sfcRender->SetMmcParams(m_renderTarget->osSurface,
193 IsFormatMMCSupported(m_renderTarget->osSurface->Format),
194 m_mmc->IsMmcEnabled()));
195
196 return MOS_STATUS_SUCCESS;
197 }
198
199 VP_SURFACE *VpVeboxCmdPacket::GetSurface(SurfaceType type)
200 {
201 VP_FUNC_CALL();
202
203 auto it = m_surfSetting.surfGroup.find(type);
204 VP_SURFACE *surf = (m_surfSetting.surfGroup.end() != it) ? it->second : nullptr;
205 if (SurfaceTypeVeboxCurrentOutput == type && nullptr == surf && !m_IsSfcUsed)
206 {
207 // Vebox output case.
208 surf = m_renderTarget;
209 }
210 else if (SurfaceTypeVeboxInput == type && surf)
211 {
212 // The vp surface object for external surface will be destroyed by hw filter before packet submit.
213 // Store the vp surface object inside packet.
214 if (MOS_FAILED(m_allocator->CopyVpSurface(*m_currentSurface ,*surf)))
215 {
216 return nullptr;
217 }
218 m_currentSurface->rcMaxSrc = m_currentSurface->rcSrc;
219 surf = m_currentSurface;
220 }
221 else if (SurfaceTypeVeboxPreviousInput == type && surf)
222 {
223 // The vp surface object for external surface will be destroyed by hw filter before packet submit.
224 // Store the vp surface object inside packet.
225 if (MOS_FAILED(m_allocator->CopyVpSurface(*m_previousSurface ,*surf)))
226 {
227 return nullptr;
228 }
229 surf = m_previousSurface;
230 }
231 return surf;
232 }
233
234 bool VpVeboxCmdPacket::UseKernelResource()
235 {
236 VP_FUNC_CALL();
237
238 return false;
239 }
240
241 MOS_STATUS VpVeboxCmdPacket::SendVeboxCmd(MOS_COMMAND_BUFFER* commandBuffer)
242 {
243 VP_FUNC_CALL();
244
245 MOS_STATUS eStatus;
246 int32_t iRemaining;
247 VP_VEBOX_SURFACE_STATE_CMD_PARAMS VeboxSurfaceStateCmdParams;
248 MHW_VEBOX_SURFACE_STATE_CMD_PARAMS MhwVeboxSurfaceStateCmdParams;
249 MHW_MI_FLUSH_DW_PARAMS FlushDwParams;
250 RENDERHAL_GENERIC_PROLOG_PARAMS GenericPrologParams;
251
252 eStatus = MOS_STATUS_SUCCESS;
253 iRemaining = 0;
254
255 VP_RENDER_CHK_NULL_RETURN(commandBuffer);
256
257 eStatus = PrepareVeboxCmd(
258 commandBuffer,
259 GenericPrologParams,
260 iRemaining);
261
262 if (eStatus != MOS_STATUS_SUCCESS)
263 {
264 CmdErrorHanlde(commandBuffer, iRemaining);
265 }
266 else
267 {
268 eStatus = RenderVeboxCmd(
269 commandBuffer,
270 VeboxSurfaceStateCmdParams,
271 MhwVeboxSurfaceStateCmdParams,
272 FlushDwParams,
273 &GenericPrologParams);
274 if (eStatus != MOS_STATUS_SUCCESS)
275 {
276 // Failed -> discard all changes in Command Buffer
277 CmdErrorHanlde(commandBuffer, iRemaining);
278 }
279 }
280
281 return eStatus;
282 }
283
284 void VpVeboxCmdPacket::CmdErrorHanlde(
285 MOS_COMMAND_BUFFER *CmdBuffer,
286 int32_t &iRemaining)
287 {
288 VP_FUNC_CALL();
289
290 int32_t i= 0;
291
292 VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(CmdBuffer);
293 // Buffer overflow - display overflow size
294 if (CmdBuffer->iRemaining < 0)
295 {
296 VP_RENDER_ASSERTMESSAGE("Command Buffer overflow by %d bytes", CmdBuffer->iRemaining);
297 }
298
299 // Move command buffer back to beginning
300 i = iRemaining - CmdBuffer->iRemaining;
301 CmdBuffer->iRemaining = iRemaining;
302 CmdBuffer->iOffset -= i;
303 CmdBuffer->pCmdPtr = CmdBuffer->pCmdBase + CmdBuffer->iOffset / sizeof(uint32_t);
304 }
305
306 MOS_STATUS VpVeboxCmdPacket::PrepareVeboxCmd(
307 MOS_COMMAND_BUFFER* CmdBuffer,
308 RENDERHAL_GENERIC_PROLOG_PARAMS& GenericPrologParams,
309 int32_t& iRemaining)
310 {
311 VP_FUNC_CALL();
312
313 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
314 PMOS_INTERFACE pOsInterface = m_hwInterface->m_osInterface;
315 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
316 PMOS_RESOURCE gpuStatusBuffer = nullptr;
317
318 VP_RENDER_CHK_NULL_RETURN(CmdBuffer);
319 VP_RENDER_CHK_NULL_RETURN(pOsInterface);
320 VP_RENDER_CHK_NULL_RETURN(m_currentSurface);
321 VP_RENDER_CHK_NULL_RETURN(m_currentSurface->osSurface);
322 VP_RENDER_CHK_NULL_RETURN(pRenderData);
323
324 // Set initial state
325 iRemaining = CmdBuffer->iRemaining;
326
327 //---------------------------
328 // Set Performance Tags
329 //---------------------------
330 VP_RENDER_CHK_STATUS_RETURN(VeboxSetPerfTag());
331 pOsInterface->pfnResetPerfBufferID(pOsInterface);
332 pOsInterface->pfnSetPerfTag(pOsInterface, pRenderData->PerfTag);
333
334 MOS_ZeroMemory(&GenericPrologParams, sizeof(GenericPrologParams));
335
336 VP_RENDER_CHK_STATUS_RETURN(SetMediaFrameTracking(GenericPrologParams));
337
338 return eStatus;
339 }
340
341 MOS_STATUS VpVeboxCmdPacket::RenderVeboxCmd(
342 MOS_COMMAND_BUFFER *CmdBuffer,
343 VP_VEBOX_SURFACE_STATE_CMD_PARAMS &VeboxSurfaceStateCmdParams,
344 MHW_VEBOX_SURFACE_STATE_CMD_PARAMS &MhwVeboxSurfaceStateCmdParams,
345 MHW_MI_FLUSH_DW_PARAMS &FlushDwParams,
346 PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams)
347 {
348 VP_FUNC_CALL();
349
350 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
351 PRENDERHAL_INTERFACE pRenderHal;
352 PMOS_INTERFACE pOsInterface;
353 bool bDiVarianceEnable;
354 const MHW_VEBOX_HEAP *pVeboxHeap = nullptr;
355 VpVeboxRenderData * pRenderData = GetLastExecRenderData();
356 MOS_CONTEXT * pOsContext = nullptr;
357 PMHW_MI_MMIOREGISTERS pMmioRegisters = nullptr;
358 MOS_COMMAND_BUFFER CmdBufferInUse;
359 PMOS_COMMAND_BUFFER pCmdBufferInUse = nullptr;
360 uint32_t curPipe = 0;
361 uint8_t inputPipe = 0;
362 uint32_t numPipe = 1;
363 bool bMultipipe = false;
364
365 VP_RENDER_CHK_NULL_RETURN(m_hwInterface);
366 VP_RENDER_CHK_NULL_RETURN(m_hwInterface->m_renderHal);
367 VP_RENDER_CHK_NULL_RETURN(m_miItf);
368 VP_RENDER_CHK_NULL_RETURN(m_hwInterface->m_osInterface);
369 VP_RENDER_CHK_NULL_RETURN(m_hwInterface->m_osInterface->pOsContext);
370 VP_RENDER_CHK_NULL_RETURN(m_miItf->GetMmioRegisters());
371 VP_RENDER_CHK_NULL_RETURN(pRenderData);
372 VP_RENDER_CHK_NULL_RETURN(CmdBuffer);
373 VP_RENDER_CHK_NULL_RETURN(m_veboxItf);
374
375 pRenderHal = m_hwInterface->m_renderHal;
376 pOsInterface = m_hwInterface->m_osInterface;
377 pOsContext = m_hwInterface->m_osInterface->pOsContext;
378 pMmioRegisters = m_miItf->GetMmioRegisters();
379 pCmdBufferInUse = CmdBuffer;
380
381 auto report = (VpFeatureReport *)(m_hwInterface->m_reporting);
382 auto scalability = GetMediaScalability();
383 VP_RENDER_CHK_NULL_RETURN(m_veboxItf);
384 mhw::vebox::VEBOX_STATE_PAR& veboxStateCmdParams = m_veboxItf->MHW_GETPAR_F(VEBOX_STATE)();
385 mhw::vebox::VEB_DI_IECP_PAR& veboxDiIecpCmdParams = m_veboxItf->MHW_GETPAR_F(VEB_DI_IECP)();
386
387 VP_RENDER_CHK_STATUS_RETURN(m_veboxItf->GetVeboxHeapInfo(&pVeboxHeap));
388 VP_RENDER_CHK_NULL_RETURN(pVeboxHeap);
389
390 VP_RENDER_CHK_STATUS_RETURN(SetVeboxProCmd(CmdBuffer));
391
392 // Initialize the scalability
393 curPipe = scalability->GetCurrentPipe();
394 inputPipe = (uint8_t)curPipe;
395 numPipe = scalability->GetPipeNumber();
396 bMultipipe = (numPipe > 1) ? true : false;
397
398 VP_RENDER_CHK_STATUS_RETURN(SetVeboxIndex(0, numPipe, m_IsSfcUsed));
399
400 bDiVarianceEnable = m_PacketCaps.bDI;
401
402 VP_RENDER_CHK_STATUS_RETURN(SetupSurfaceStates(
403 &VeboxSurfaceStateCmdParams));
404
405 VP_RENDER_CHK_STATUS_RETURN(SetupVeboxState(veboxStateCmdParams));
406
407 VP_RENDER_CHK_STATUS_RETURN(SetupDiIecpState(
408 bDiVarianceEnable,
409 veboxDiIecpCmdParams));
410
411 VP_RENDER_CHK_STATUS_RETURN(IsCmdParamsValid(
412 veboxStateCmdParams,
413 veboxDiIecpCmdParams,
414 VeboxSurfaceStateCmdParams));
415
416 // Initialize command buffer and insert prolog
417 VP_RENDER_CHK_STATUS_RETURN(InitCmdBufferWithVeParams(pRenderHal, *CmdBuffer, pGenericPrologParams));
418
419 //---------------------------------
420 // Initialize Vebox Surface State Params
421 //---------------------------------
422 VP_RENDER_CHK_STATUS_RETURN(InitVeboxSurfaceStateCmdParams(
423 &VeboxSurfaceStateCmdParams, &MhwVeboxSurfaceStateCmdParams));
424
425 for (curPipe = 0; curPipe < numPipe; curPipe++)
426 {
427 if (bMultipipe)
428 {
429 // initialize the command buffer struct
430 MOS_ZeroMemory(&CmdBufferInUse, sizeof(MOS_COMMAND_BUFFER));
431 bool frameTrackingRequested = m_PacketCaps.lastSubmission && (numPipe - 1 == curPipe);
432 scalability->SetCurrentPipeIndex((uint8_t)curPipe);
433 scalability->GetCmdBuffer(&CmdBufferInUse, frameTrackingRequested);
434 pCmdBufferInUse = &CmdBufferInUse;
435 }
436 else
437 {
438 pCmdBufferInUse = CmdBuffer;
439 }
440
441 VP_RENDER_CHK_STATUS_RETURN(SetVeboxIndex(curPipe, numPipe, m_IsSfcUsed));
442
443 AddCommonOcaMessage(pCmdBufferInUse, (MOS_CONTEXT_HANDLE)pOsContext, pOsInterface, pRenderHal, pMmioRegisters);
444
445 VP_RENDER_CHK_STATUS_RETURN(pRenderHal->pRenderHalPltInterface->AddPerfCollectStartCmd(pRenderHal, pOsInterface, pCmdBufferInUse));
446
447 VP_RENDER_CHK_STATUS_RETURN(NullHW::StartPredicateNext(pOsInterface, m_miItf, pCmdBufferInUse));
448 #if (_DEBUG || _RELEASE_INTERNAL)
449 VP_RENDER_CHK_STATUS_RETURN(StoreCSEngineIdRegMem(pCmdBufferInUse, pVeboxHeap));
450 #endif
451 // Add compressible info of input/output surface to log
452 if (this->m_currentSurface && VeboxSurfaceStateCmdParams.pSurfOutput)
453 {
454 std::string info = "in_comps = " + std::to_string(int(this->m_currentSurface->osSurface->bCompressible)) + ", out_comps = " + std::to_string(int(VeboxSurfaceStateCmdParams.pSurfOutput->osSurface->bCompressible));
455 const char *ocaLog = info.c_str();
456 HalOcaInterfaceNext::TraceMessage(*pCmdBufferInUse, (MOS_CONTEXT_HANDLE)pOsContext, ocaLog, info.size());
457 }
458
459 if (bMultipipe)
460 {
461 // Insert prolog with VE params
462
463 VP_RENDER_CHK_STATUS_RETURN(SetVeboxProCmd(pCmdBufferInUse));
464
465 MHW_GENERIC_PROLOG_PARAMS genericPrologParams;
466 MOS_ZeroMemory(&genericPrologParams, sizeof(genericPrologParams));
467 genericPrologParams.pOsInterface = pRenderHal->pOsInterface;
468 genericPrologParams.bMmcEnabled = pGenericPrologParams ? pGenericPrologParams->bMmcEnabled : false;
469 VP_RENDER_CHK_STATUS_RETURN(Mhw_SendGenericPrologCmdNext(pCmdBufferInUse, &genericPrologParams, m_miItf));
470
471 VP_RENDER_CHK_STATUS_RETURN(scalability->SyncPipe(syncAllPipes, 0, pCmdBufferInUse));
472
473 // Enable Watchdog Timer
474 VP_RENDER_CHK_STATUS_RETURN(m_miItf->AddWatchdogTimerStartCmd(pCmdBufferInUse));
475
476 #if (_DEBUG || _RELEASE_INTERNAL)
477 // Add noop for simu no output issue
478 if (curPipe > 0)
479 {
480 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
481 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
482 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
483 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
484 if (m_IsSfcUsed)
485 {
486 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
487 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
488 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
489 SETPAR_AND_ADDCMD(MI_NOOP, m_miItf, pCmdBufferInUse);
490 }
491 }
492 #endif
493 }
494
495 //---------------------------------
496 // Send CMD: Vebox_State
497 //---------------------------------
498 VP_RENDER_CHK_STATUS_RETURN(SetVeboxState(
499 pCmdBufferInUse));
500
501 //---------------------------------
502 // Send CMD: Vebox_Surface_State
503 //---------------------------------
504 VP_RENDER_CHK_STATUS_RETURN(SetVeboxSurfaces(
505 pCmdBufferInUse,
506 &MhwVeboxSurfaceStateCmdParams));
507
508 //---------------------------------
509 // Send CMD: SFC pipe commands
510 //---------------------------------
511 if (m_IsSfcUsed)
512 {
513 VP_RENDER_CHK_NULL_RETURN(m_sfcRender);
514
515 VP_RENDER_CHK_STATUS_RETURN(m_sfcRender->SetSfcPipe(curPipe, numPipe));
516
517 VP_RENDER_CHK_STATUS_RETURN(m_sfcRender->SetupSfcState(m_renderTarget));
518
519 bool enableVeboxOutputSurf = false;
520 if (m_vpUserFeatureControl)
521 {
522 enableVeboxOutputSurf = m_vpUserFeatureControl->IsVeboxOutputSurfEnabled();
523 }
524
525 VP_RENDER_CHK_STATUS_RETURN(m_sfcRender->SendSfcCmd(
526 (enableVeboxOutputSurf || pRenderData->DI.bDeinterlace || pRenderData->DN.bDnEnabled),
527 pCmdBufferInUse));
528 }
529
530 pRenderHal->pRenderHalPltInterface->OnDispatch(pRenderHal, pCmdBufferInUse, pOsInterface, pMmioRegisters);
531 //HalOcaInterfaceNext::OnDispatch(*pCmdBufferInUse, *pOsContext, m_miItf, *pMmioRegisters);
532
533 //---------------------------------
534 // Send CMD: Vebox_DI_IECP
535 //---------------------------------
536 VP_RENDER_CHK_STATUS_RETURN(SetVeboxDiIecp(
537 pCmdBufferInUse));
538
539 VP_RENDER_CHK_NULL_RETURN(pOsInterface);
540 VP_RENDER_CHK_NULL_RETURN(pOsInterface->pfnGetSkuTable);
541 auto *skuTable = pOsInterface->pfnGetSkuTable(pOsInterface);
542 if (skuTable && MEDIA_IS_SKU(skuTable, FtrEnablePPCFlush))
543 {
544 // Add PPC fulsh
545 auto &miFlushDwParams = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)();
546 miFlushDwParams = {};
547 miFlushDwParams.bEnablePPCFlush = true;
548 VP_RENDER_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(pCmdBufferInUse));
549 }
550
551 if (bMultipipe)
552 {
553 // MI FlushDw, for vebox output green block issue
554 auto &params = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)();
555 params = {};
556 VP_RENDER_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(pCmdBufferInUse));
557
558 VP_RENDER_CHK_STATUS_RETURN(scalability->SyncPipe(syncAllPipes, 0, pCmdBufferInUse));
559 }
560
561 if (m_PacketCaps.enableSFCLinearOutputByTileConvert)
562 {
563 VP_RENDER_CHK_STATUS_RETURN(AddTileConvertStates(CmdBuffer, MhwVeboxSurfaceStateCmdParams));
564 report->GetFeatures().sfcLinearOutputByTileConvert = true;
565 }
566
567 //---------------------------------
568 // Write GPU Status Tag for Tag based synchronization
569 //---------------------------------
570 #if !EMUL
571 if (!pOsInterface->bEnableKmdMediaFrameTracking)
572 {
573 VP_RENDER_CHK_STATUS_RETURN(SendVecsStatusTag(
574 pOsInterface,
575 pCmdBufferInUse));
576 }
577 #endif
578
579 //---------------------------------
580 // Write Sync tag for Vebox Heap Synchronization
581 // If KMD frame tracking is on, the synchronization of Vebox Heap will use Status tag which
582 // is updated using KMD frame tracking.
583 //---------------------------------
584 if (!pOsInterface->bEnableKmdMediaFrameTracking)
585 {
586 auto &params = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)();
587 params = {};
588 params.pOsResource = (PMOS_RESOURCE)&pVeboxHeap->DriverResource;
589 params.dwResourceOffset = pVeboxHeap->uiOffsetSync;
590 params.dwDataDW1 = pVeboxHeap->dwNextTag;
591 VP_RENDER_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(pCmdBufferInUse));
592 }
593
594 if (bMultipipe)
595 {
596 // Disable Watchdog Timer
597 VP_RENDER_CHK_STATUS_RETURN(m_miItf->AddWatchdogTimerStopCmd(pCmdBufferInUse));
598 }
599
600 VP_RENDER_CHK_STATUS_RETURN(NullHW::StopPredicateNext(pOsInterface, m_miItf, pCmdBufferInUse));
601
602 VP_RENDER_CHK_STATUS_RETURN(pRenderHal->pRenderHalPltInterface->AddPerfCollectEndCmd(pRenderHal, pOsInterface, pCmdBufferInUse));
603
604 #if (_DEBUG || _RELEASE_INTERNAL)
605 VP_RENDER_CHK_STATUS_RETURN(StallBatchBuffer(pCmdBufferInUse));
606 #endif
607
608 HalOcaInterfaceNext::On1stLevelBBEnd(*pCmdBufferInUse, *pOsInterface);
609
610 if (pOsInterface->bNoParsingAssistanceInKmd)
611 {
612 VP_RENDER_CHK_STATUS_RETURN(m_miItf->AddMiBatchBufferEnd(pCmdBufferInUse, nullptr));
613 }
614 else if (RndrCommonIsMiBBEndNeeded(pOsInterface))
615 {
616 // Add Batch Buffer end command (HW/OS dependent)
617 VP_RENDER_CHK_STATUS_RETURN(m_miItf->AddMiBatchBufferEnd(pCmdBufferInUse, nullptr));
618 }
619
620 if (bMultipipe)
621 {
622 VP_RENDER_CHK_STATUS_RETURN(scalability->ReturnCmdBuffer(pCmdBufferInUse));
623 }
624 }
625
626 if (bMultipipe)
627 {
628 scalability->SetCurrentPipeIndex(inputPipe);
629 }
630
631 report->GetFeatures().VeboxScalability = bMultipipe;
632
633 MT_LOG2(MT_VP_HAL_RENDER_VE, MT_NORMAL, MT_VP_MHW_VE_SCALABILITY_EN, bMultipipe, MT_VP_MHW_VE_SCALABILITY_USE_SFC, m_IsSfcUsed);
634
635 return eStatus;
636 }
637 // Meida copy has the same logic, when Format_R10G10B10A2/Format_B10G10R10A2, the output is AYUV, and in this WA there is corruption for these two format.
638 MOS_FORMAT VpVeboxCmdPacket::AdjustFormatForTileConvert(MOS_FORMAT format)
639 {
640 if (format == Format_R10G10B10A2 ||
641 format == Format_B10G10R10A2 ||
642 format == Format_Y410 ||
643 format == Format_Y210)
644 {
645 // RGB10 not supported without IECP. Re-map RGB10/RGB10 as AYUV
646 // Y410/Y210 has HW issue. Remap to AYUV.
647 return Format_AYUV;
648 }
649 else if (format == Format_A8)
650 {
651 return Format_P8;
652 }
653 else
654 {
655 return format;
656 }
657 }
658
659 void VpVeboxCmdPacket::AddCommonOcaMessage(PMOS_COMMAND_BUFFER pCmdBufferInUse, MOS_CONTEXT_HANDLE pOsContext, PMOS_INTERFACE pOsInterface, PRENDERHAL_INTERFACE pRenderHal, PMHW_MI_MMIOREGISTERS pMmioRegisters)
660 {
661 VP_FUNC_CALL();
662
663 HalOcaInterfaceNext::On1stLevelBBStart(*pCmdBufferInUse, pOsContext, pOsInterface->CurrentGpuContextHandle, m_miItf, *pMmioRegisters);
664
665 char ocaMsg[] = "VP APG Vebox Packet";
666 HalOcaInterfaceNext::TraceMessage(*pCmdBufferInUse, pOsContext, ocaMsg, sizeof(ocaMsg));
667
668 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
669 if (pRenderData)
670 {
671 MHW_VEBOX_IECP_PARAMS IecpParams = pRenderData->GetIECPParams();
672 if (pRenderData->IECP.STE.bStdEnabled && IecpParams.ColorPipeParams.StdParams.param)
673 {
674 char ocaMsg_std[] = "Customized STD state is used";
675 HalOcaInterfaceNext::TraceMessage(*pCmdBufferInUse, pOsContext, ocaMsg_std, sizeof(ocaMsg_std));
676 }
677 }
678
679 HalOcaInterfaceNext::TraceOcaSkuValue(*pCmdBufferInUse, *pOsInterface);
680
681 // Add vphal param to log.
682 HalOcaInterfaceNext::DumpVphalParam(*pCmdBufferInUse, pOsContext, pRenderHal->pVphalOcaDumper);
683
684 if (m_vpUserFeatureControl)
685 {
686 HalOcaInterfaceNext::DumpVpUserFeautreControlInfo(*pCmdBufferInUse, pOsContext, m_vpUserFeatureControl->GetOcaFeautreControlInfo());
687 }
688
689 }
690
691 MOS_STATUS VpVeboxCmdPacket::InitVeboxSurfaceStateCmdParams(
692 PVP_VEBOX_SURFACE_STATE_CMD_PARAMS pVpHalVeboxSurfaceStateCmdParams,
693 PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS pMhwVeboxSurfaceStateCmdParams)
694 {
695 VP_FUNC_CALL();
696
697 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
698
699 VP_RENDER_CHK_NULL_RETURN(pVpHalVeboxSurfaceStateCmdParams);
700 VP_RENDER_CHK_NULL_RETURN(pMhwVeboxSurfaceStateCmdParams);
701
702 MOS_ZeroMemory(pMhwVeboxSurfaceStateCmdParams, sizeof(*pMhwVeboxSurfaceStateCmdParams));
703
704 pMhwVeboxSurfaceStateCmdParams->bDIEnable = pVpHalVeboxSurfaceStateCmdParams->bDIEnable;
705 pMhwVeboxSurfaceStateCmdParams->b3DlutEnable = pVpHalVeboxSurfaceStateCmdParams->b3DlutEnable;
706
707 if (pVpHalVeboxSurfaceStateCmdParams->pSurfInput)
708 {
709 VP_RENDER_CHK_NULL_RETURN(pVpHalVeboxSurfaceStateCmdParams->pSurfInput->osSurface);
710 VP_RENDER_CHK_STATUS_RETURN(InitVeboxSurfaceParams(
711 pVpHalVeboxSurfaceStateCmdParams->pSurfInput,
712 &pMhwVeboxSurfaceStateCmdParams->SurfInput));
713 pMhwVeboxSurfaceStateCmdParams->SurfInput.dwYoffset = pVpHalVeboxSurfaceStateCmdParams->pSurfInput->osSurface->YPlaneOffset.iYOffset;
714 MT_LOG2(MT_VP_MHW_VE_SURFSTATE_INPUT, MT_NORMAL, MT_SURF_TILE_MODE, pVpHalVeboxSurfaceStateCmdParams->pSurfInput->osSurface->TileModeGMM,
715 MT_SURF_MOS_FORMAT, pVpHalVeboxSurfaceStateCmdParams->pSurfInput->osSurface->Format);
716 }
717 if (pVpHalVeboxSurfaceStateCmdParams->pSurfOutput)
718 {
719 VP_RENDER_CHK_NULL_RETURN(pVpHalVeboxSurfaceStateCmdParams->pSurfOutput->osSurface);
720 pMhwVeboxSurfaceStateCmdParams->bOutputValid = true;
721 VP_RENDER_CHK_STATUS_RETURN(InitVeboxSurfaceParams(
722 pVpHalVeboxSurfaceStateCmdParams->pSurfOutput,
723 &pMhwVeboxSurfaceStateCmdParams->SurfOutput));
724 pMhwVeboxSurfaceStateCmdParams->SurfOutput.dwYoffset = pVpHalVeboxSurfaceStateCmdParams->pSurfOutput->osSurface->YPlaneOffset.iYOffset;
725 MT_LOG2(MT_VP_MHW_VE_SURFSTATE_OUT, MT_NORMAL, MT_SURF_TILE_MODE, pVpHalVeboxSurfaceStateCmdParams->pSurfOutput->osSurface->TileModeGMM,
726 MT_SURF_MOS_FORMAT, pVpHalVeboxSurfaceStateCmdParams->pSurfOutput->osSurface->Format);
727 }
728 if (pVpHalVeboxSurfaceStateCmdParams->pSurfSTMM)
729 {
730 VP_RENDER_CHK_NULL_RETURN(pVpHalVeboxSurfaceStateCmdParams->pSurfSTMM->osSurface);
731 VP_RENDER_CHK_STATUS_RETURN(InitVeboxSurfaceParams(
732 pVpHalVeboxSurfaceStateCmdParams->pSurfSTMM,
733 &pMhwVeboxSurfaceStateCmdParams->SurfSTMM));
734 MT_LOG2(MT_VP_MHW_VE_SURFSTATE_STMM, MT_NORMAL, MT_SURF_TILE_MODE, pVpHalVeboxSurfaceStateCmdParams->pSurfSTMM->osSurface->TileModeGMM,
735 MT_SURF_MOS_FORMAT, pVpHalVeboxSurfaceStateCmdParams->pSurfSTMM->osSurface->Format);
736 }
737 if (pVpHalVeboxSurfaceStateCmdParams->pSurfDNOutput)
738 {
739 VP_RENDER_CHK_NULL_RETURN(pVpHalVeboxSurfaceStateCmdParams->pSurfDNOutput->osSurface);
740 VP_RENDER_CHK_STATUS_RETURN(InitVeboxSurfaceParams(
741 pVpHalVeboxSurfaceStateCmdParams->pSurfDNOutput,
742 &pMhwVeboxSurfaceStateCmdParams->SurfDNOutput));
743 pMhwVeboxSurfaceStateCmdParams->SurfDNOutput.dwYoffset = pVpHalVeboxSurfaceStateCmdParams->pSurfDNOutput->osSurface->YPlaneOffset.iYOffset;
744 MT_LOG2(MT_VP_MHW_VE_SURFSTATE_DNOUT, MT_NORMAL, MT_SURF_TILE_MODE, pVpHalVeboxSurfaceStateCmdParams->pSurfDNOutput->osSurface->TileModeGMM,
745 MT_SURF_MOS_FORMAT, pVpHalVeboxSurfaceStateCmdParams->pSurfDNOutput->osSurface->Format);
746 }
747 if (pVpHalVeboxSurfaceStateCmdParams->pSurfSkinScoreOutput)
748 {
749 VP_RENDER_CHK_NULL_RETURN(pVpHalVeboxSurfaceStateCmdParams->pSurfSkinScoreOutput->osSurface);
750 VP_RENDER_CHK_STATUS_RETURN(InitVeboxSurfaceParams(
751 pVpHalVeboxSurfaceStateCmdParams->pSurfSkinScoreOutput,
752 &pMhwVeboxSurfaceStateCmdParams->SurfSkinScoreOutput));
753 MT_LOG2(MT_VP_MHW_VE_SURFSTATE_SKINSCORE, MT_NORMAL, MT_SURF_TILE_MODE, pVpHalVeboxSurfaceStateCmdParams->pSurfSkinScoreOutput->osSurface->TileModeGMM,
754 MT_SURF_MOS_FORMAT, pVpHalVeboxSurfaceStateCmdParams->pSurfSkinScoreOutput->osSurface->Format);
755 }
756
757 if (m_inputDepth)
758 {
759 pMhwVeboxSurfaceStateCmdParams->SurfInput.dwBitDepth = m_inputDepth;
760 }
761
762 return eStatus;
763 }
764
765 MOS_STATUS VpVeboxCmdPacket::SendVecsStatusTag(
766 PMOS_INTERFACE pOsInterface,
767 PMOS_COMMAND_BUFFER pCmdBuffer)
768 {
769 VP_FUNC_CALL();
770
771 PMOS_RESOURCE gpuStatusBuffer = nullptr;
772 MHW_MI_FLUSH_DW_PARAMS FlushDwParams;
773 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
774
775 //------------------------------------
776 VP_RENDER_CHK_NULL_RETURN(m_miItf);
777 VP_RENDER_CHK_NULL_RETURN(pOsInterface);
778 VP_RENDER_CHK_NULL_RETURN(pCmdBuffer);
779
780 // Get GPU Status buffer
781 pOsInterface->pfnGetGpuStatusBufferResource(pOsInterface, gpuStatusBuffer);
782 VP_RENDER_CHK_NULL_RETURN(gpuStatusBuffer);
783
784 // Register the buffer
785 VP_RENDER_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource(
786 pOsInterface,
787 gpuStatusBuffer,
788 true,
789 true));
790
791 VP_RENDER_CHK_NULL_RETURN(m_miItf);
792
793 auto &params = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)();
794 params = {};
795 params.pOsResource = gpuStatusBuffer;;
796 params.dwResourceOffset = pOsInterface->pfnGetGpuStatusTagOffset(pOsInterface, MOS_GPU_CONTEXT_VEBOX);
797 params.dwDataDW1 = pOsInterface->pfnGetGpuStatusTag(pOsInterface, MOS_GPU_CONTEXT_VEBOX);
798 VP_RENDER_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(pCmdBuffer));
799
800 // Increase buffer tag for next usage
801 pOsInterface->pfnIncrementGpuStatusTag(pOsInterface, MOS_GPU_CONTEXT_VEBOX);
802
803 return eStatus;
804 }
805
806 bool VpVeboxCmdPacket::RndrCommonIsMiBBEndNeeded(
807 PMOS_INTERFACE pOsInterface)
808 {
809 VP_FUNC_CALL();
810
811 bool needed = false;
812
813 if (nullptr == pOsInterface)
814 return false;
815
816 return needed;
817 }
818
819 MOS_STATUS VpVeboxCmdPacket::InitSfcRender()
820 {
821 VP_FUNC_CALL();
822
823 if (nullptr == m_sfcRender)
824 {
825 VP_RENDER_CHK_NULL_RETURN(m_hwInterface);
826 VP_RENDER_CHK_NULL_RETURN(m_hwInterface->m_vpPlatformInterface);
827 VP_RENDER_CHK_STATUS_RETURN(m_hwInterface->m_vpPlatformInterface->CreateSfcRender(
828 m_sfcRender,
829 *m_hwInterface,
830 m_allocator));
831 VP_RENDER_CHK_NULL_RETURN(m_sfcRender);
832 }
833 VP_PUBLIC_CHK_STATUS_RETURN(m_sfcRender->Init());
834 return MOS_STATUS_SUCCESS;
835 }
836
837 MOS_STATUS VpVeboxCmdPacket::Init()
838 {
839 VP_FUNC_CALL();
840
841 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
842 VP_RENDER_CHK_NULL_RETURN(m_hwInterface);
843 VP_RENDER_CHK_NULL_RETURN(m_hwInterface->m_skuTable);
844
845 VP_RENDER_CHK_STATUS_RETURN(InitSfcRender());
846
847 if (nullptr == m_currentSurface)
848 {
849 m_currentSurface = m_allocator->AllocateVpSurface();
850 VP_CHK_SPACE_NULL_RETURN(m_currentSurface);
851 }
852 else
853 {
854 m_currentSurface->Clean();
855 }
856
857 if (nullptr == m_previousSurface)
858 {
859 m_previousSurface = m_allocator->AllocateVpSurface();
860 VP_CHK_SPACE_NULL_RETURN(m_previousSurface);
861 }
862 else
863 {
864 m_previousSurface->Clean();
865 }
866
867 if (nullptr == m_renderTarget)
868 {
869 m_renderTarget = m_allocator->AllocateVpSurface();
870 VP_CHK_SPACE_NULL_RETURN(m_renderTarget);
871 }
872 else
873 {
874 m_renderTarget->Clean();
875 }
876
877 if (nullptr == m_originalOutput)
878 {
879 m_originalOutput = m_allocator->AllocateVpSurface();
880 VP_CHK_SPACE_NULL_RETURN(m_originalOutput);
881 }
882 else
883 {
884 m_originalOutput->Clean();
885 }
886
887 MOS_ZeroMemory(&m_veboxPacketSurface, sizeof(VEBOX_PACKET_SURFACE_PARAMS));
888 m_surfSetting.Clean();
889
890 return eStatus;
891 }
892
893 MOS_STATUS VpVeboxCmdPacket::Prepare()
894 {
895 VP_FUNC_CALL();
896
897 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
898
899 return eStatus;
900 }
901
902 MOS_STATUS VpVeboxCmdPacket::PrepareState()
903 {
904 VP_FUNC_CALL();
905
906 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
907
908 if (m_packetResourcesPrepared)
909 {
910 VP_RENDER_NORMALMESSAGE("Resource Prepared, skip this time");
911 return MOS_STATUS_SUCCESS;
912 }
913
914 VP_RENDER_CHK_STATUS_RETURN(SetupIndirectStates());
915
916 VP_RENDER_CHK_STATUS_RETURN(UpdateVeboxStates());
917
918 if (m_veboxItf)
919 {
920 const MHW_VEBOX_HEAP *veboxHeap = nullptr;
921
922 VP_RENDER_CHK_STATUS_RETURN(m_veboxItf->GetVeboxHeapInfo(&veboxHeap));
923 VP_RENDER_CHK_NULL_RETURN(veboxHeap);
924
925 m_veboxHeapCurState = veboxHeap->uiCurState;
926 }
927
928 m_packetResourcesPrepared = true;
929
930 return eStatus;
931 }
932
933 MOS_STATUS VpVeboxCmdPacket::SetUpdatedExecuteResource(
934 VP_SURFACE *inputSurface,
935 VP_SURFACE *outputSurface,
936 VP_SURFACE *previousSurface,
937 VP_SURFACE_SETTING &surfSetting)
938 {
939 VP_FUNC_CALL();
940 VP_RENDER_CHK_NULL_RETURN(inputSurface);
941 VP_RENDER_CHK_NULL_RETURN(outputSurface);
942 VP_RENDER_CHK_NULL_RETURN(inputSurface->osSurface);
943 VP_RENDER_CHK_NULL_RETURN(outputSurface->osSurface);
944 m_allocator->UpdateResourceUsageType(&inputSurface->osSurface->OsResource, MOS_HW_RESOURCE_USAGE_VP_INPUT_PICTURE_FF);
945 m_allocator->UpdateResourceUsageType(&outputSurface->osSurface->OsResource, MOS_HW_RESOURCE_USAGE_VP_OUTPUT_PICTURE_FF);
946
947 // Set current src = current primary input
948 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->CopyVpSurface(*m_renderTarget ,*outputSurface));
949
950 // Init packet surface params.
951 m_surfSetting = surfSetting;
952 m_veboxPacketSurface.pCurrInput = GetSurface(SurfaceTypeVeboxInput);
953 m_veboxPacketSurface.pStatisticsOutput = GetSurface(SurfaceTypeStatistics);
954 m_veboxPacketSurface.pCurrOutput = GetSurface(SurfaceTypeVeboxCurrentOutput);
955 m_veboxPacketSurface.pPrevInput = GetSurface(SurfaceTypeVeboxPreviousInput);
956 m_veboxPacketSurface.pSTMMInput = GetSurface(SurfaceTypeSTMMIn);
957 m_veboxPacketSurface.pSTMMOutput = GetSurface(SurfaceTypeSTMMOut);
958 m_veboxPacketSurface.pDenoisedCurrOutput = GetSurface(SurfaceTypeDNOutput);
959 m_veboxPacketSurface.pPrevOutput = GetSurface(SurfaceTypeVeboxPreviousOutput);
960 m_veboxPacketSurface.pAlphaOrVignette = GetSurface(SurfaceTypeAlphaOrVignette);
961 m_veboxPacketSurface.pLaceOrAceOrRgbHistogram = GetSurface(SurfaceTypeLaceAceRGBHistogram);
962 m_veboxPacketSurface.pSurfSkinScoreOutput = GetSurface(SurfaceTypeSkinScore);
963
964 VP_RENDER_CHK_NULL_RETURN(m_veboxPacketSurface.pCurrInput);
965 VP_RENDER_CHK_NULL_RETURN(m_veboxPacketSurface.pStatisticsOutput);
966 VP_RENDER_CHK_NULL_RETURN(m_veboxPacketSurface.pLaceOrAceOrRgbHistogram);
967
968 // Adjust boundary for statistics surface block
969 VP_RENDER_CHK_STATUS_RETURN(AdjustBlockStatistics());
970
971 if (m_PacketCaps.bSFC)
972 {
973 VP_RENDER_CHK_STATUS_RETURN(SetSfcMmcParams());
974 }
975 return MOS_STATUS_SUCCESS;
976 }
977
978 MOS_STATUS VpVeboxCmdPacket::PacketInit(
979 VP_SURFACE *inputSurface,
980 VP_SURFACE *outputSurface,
981 VP_SURFACE *previousSurface,
982 VP_SURFACE_SETTING &surfSetting,
983 VP_EXECUTE_CAPS packetCaps)
984 {
985 VP_FUNC_CALL();
986
987 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
988 m_packetResourcesPrepared = false;
989
990 VP_RENDER_CHK_NULL_RETURN(pRenderData);
991 VP_RENDER_CHK_NULL_RETURN(inputSurface);
992 VP_RENDER_CHK_NULL_RETURN(outputSurface);
993 VP_RENDER_CHK_STATUS_RETURN(pRenderData->Init());
994
995 m_PacketCaps = packetCaps;
996 VP_RENDER_NORMALMESSAGE("m_PacketCaps %x", m_PacketCaps.value);
997
998 VP_RENDER_CHK_STATUS_RETURN(Init());
999 VP_RENDER_CHK_NULL_RETURN(m_allocator);
1000 VP_RENDER_CHK_NULL_RETURN(m_currentSurface);
1001 VP_RENDER_CHK_NULL_RETURN(m_renderTarget);
1002 VP_RENDER_CHK_NULL_RETURN(m_previousSurface);
1003
1004 VP_RENDER_CHK_STATUS_RETURN(InitSurfMemCacheControl(packetCaps));
1005
1006 m_IsSfcUsed = packetCaps.bSFC;
1007
1008 //update VEBOX resource GMM resource usage type
1009 m_allocator->UpdateResourceUsageType(&inputSurface->osSurface->OsResource, MOS_HW_RESOURCE_USAGE_VP_INPUT_PICTURE_FF);
1010 m_allocator->UpdateResourceUsageType(&outputSurface->osSurface->OsResource, MOS_HW_RESOURCE_USAGE_VP_OUTPUT_PICTURE_FF);
1011
1012 // Init packet surface params.
1013 m_surfSetting = surfSetting;
1014 m_veboxPacketSurface.pCurrInput = GetSurface(SurfaceTypeVeboxInput);
1015 m_veboxPacketSurface.pStatisticsOutput = GetSurface(SurfaceTypeStatistics);
1016 m_veboxPacketSurface.pCurrOutput = GetSurface(SurfaceTypeVeboxCurrentOutput);
1017 m_veboxPacketSurface.pPrevInput = GetSurface(SurfaceTypeVeboxPreviousInput);
1018 m_veboxPacketSurface.pSTMMInput = GetSurface(SurfaceTypeSTMMIn);
1019 m_veboxPacketSurface.pSTMMOutput = GetSurface(SurfaceTypeSTMMOut);
1020 m_veboxPacketSurface.pDenoisedCurrOutput = GetSurface(SurfaceTypeDNOutput);
1021 m_veboxPacketSurface.pPrevOutput = GetSurface(SurfaceTypeVeboxPreviousOutput);
1022 m_veboxPacketSurface.pAlphaOrVignette = GetSurface(SurfaceTypeAlphaOrVignette);
1023 m_veboxPacketSurface.pLaceOrAceOrRgbHistogram = GetSurface(SurfaceTypeLaceAceRGBHistogram);
1024 m_veboxPacketSurface.pSurfSkinScoreOutput = GetSurface(SurfaceTypeSkinScore);
1025 m_veboxPacketSurface.pInnerTileConvertInput = GetSurface(SurfaceTypeInnerTileConvertInput);
1026 // Set current src = current primary input
1027 if (m_veboxPacketSurface.pInnerTileConvertInput)
1028 {
1029 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->CopyVpSurface(*m_renderTarget, *m_veboxPacketSurface.pInnerTileConvertInput));
1030
1031 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->CopyVpSurface(*m_originalOutput, *outputSurface));
1032 }
1033 else
1034 {
1035 VP_PUBLIC_CHK_STATUS_RETURN(m_allocator->CopyVpSurface(*m_renderTarget, *outputSurface));
1036 }
1037
1038 VP_RENDER_CHK_NULL_RETURN(m_veboxPacketSurface.pCurrInput);
1039 VP_RENDER_CHK_NULL_RETURN(m_veboxPacketSurface.pStatisticsOutput);
1040 VP_RENDER_CHK_NULL_RETURN(m_veboxPacketSurface.pLaceOrAceOrRgbHistogram);
1041
1042 m_DNDIFirstFrame = (!m_PacketCaps.bRefValid && (m_PacketCaps.bDN || m_PacketCaps.bDI));
1043 m_DIOutputFrames = MEDIA_VEBOX_DI_OUTPUT_CURRENT;
1044
1045 auto curInput = m_veboxPacketSurface.pCurrInput;
1046 auto curOutput = m_veboxPacketSurface.pCurrOutput;
1047 if (!m_IsSfcUsed &&
1048 ((uint32_t)curInput->rcSrc.bottom < curInput->osSurface->dwHeight ||
1049 (uint32_t)curInput->rcSrc.right < curInput->osSurface->dwWidth))
1050 {
1051 curInput->bVEBOXCroppingUsed = true;
1052 VP_RENDER_NORMALMESSAGE("bVEBOXCroppingUsed = true, input: rcSrc.bottom: %d, rcSrc.right: %d; dwHeight: %d, dwHeight: %d;",
1053 (uint32_t)curInput->rcSrc.bottom,
1054 (uint32_t)curInput->rcSrc.right,
1055 curInput->osSurface->dwHeight,
1056 curInput->osSurface->dwWidth);
1057
1058 if (curOutput)
1059 {
1060 curOutput->bVEBOXCroppingUsed = true;
1061 VP_RENDER_NORMALMESSAGE(" output: rcSrc.bottom: %d, rcSrc.right: %d; dwHeight: %d, dwHeight: %d;",
1062 (uint32_t)curOutput->rcSrc.bottom,
1063 (uint32_t)curOutput->rcSrc.right,
1064 curOutput->osSurface->dwHeight,
1065 curOutput->osSurface->dwWidth);
1066 }
1067 }
1068 else
1069 {
1070 curInput->bVEBOXCroppingUsed = false;
1071 if (curOutput)
1072 {
1073 curOutput->bVEBOXCroppingUsed = false;
1074 }
1075 }
1076
1077 if (!m_PacketCaps.bSFC)
1078 {
1079 // Reset ForceInputHeight8AlignedFlag for bSFC == false.
1080 // For bSFC == true, it's configured in VpScalingFilter::CalculateEngineParams.
1081 if (m_veboxItf)
1082 {
1083 m_veboxItf->SetForceInputHeight8AlignedFlag(false);
1084 }
1085 }
1086
1087 // Adjust boundary for statistics surface block
1088 VP_RENDER_CHK_STATUS_RETURN(AdjustBlockStatistics());
1089
1090 // Get Vebox Secure mode form policy
1091 m_useKernelResource = packetCaps.bSecureVebox;
1092
1093 return MOS_STATUS_SUCCESS;
1094 }
1095
1096 MOS_STATUS VpVeboxCmdPacket::Submit(MOS_COMMAND_BUFFER* commandBuffer, uint8_t packetPhase)
1097 {
1098 VP_FUNC_CALL();
1099
1100 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1101 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
1102
1103 // use the StateIndex which was saved in PrepareState() to resolve the 2pass sfc mismatch issue
1104 if (m_veboxItf)
1105 {
1106 m_veboxItf->SetVeboxHeapStateIndex(m_veboxHeapCurState);
1107 }
1108
1109 if (m_currentSurface && m_currentSurface->osSurface)
1110 {
1111 // Ensure the input is ready to be read
1112 // Currently, mos RegisterResourcere cannot sync the 3d resource.
1113 // Temporaly, call sync resource to do the sync explicitly.
1114 // Sync need be done after switching context.
1115 #if MOS_MEDIASOLO_SUPPORTED
1116 if (!m_hwInterface->m_osInterface->bSoloInUse)
1117 #endif
1118 {
1119 m_allocator->SyncOnResource(
1120 &m_currentSurface->osSurface->OsResource,
1121 false);
1122 }
1123 }
1124
1125 // Send vebox command
1126 VP_RENDER_CHK_STATUS_RETURN(SendVeboxCmd(commandBuffer));
1127
1128 #if (_DEBUG || _RELEASE_INTERNAL)
1129 // Debug interface with state heap check
1130 VP_RENDER_CHK_STATUS_RETURN(DumpVeboxStateHeap())
1131 #endif
1132
1133 return eStatus;
1134 }
1135
1136 void VpVeboxCmdPacket::CopySurfaceValue(
1137 VP_SURFACE *pTargetSurface,
1138 VP_SURFACE *pSourceSurface)
1139 {
1140 VP_FUNC_CALL();
1141
1142 if (pTargetSurface == nullptr)
1143 {
1144 VP_RENDER_ASSERTMESSAGE("Input pTargetSurface is null");
1145 return;
1146 }
1147 *pTargetSurface = *pSourceSurface;
1148 }
1149
1150 VpVeboxCmdPacket::VpVeboxCmdPacket(
1151 MediaTask * task,
1152 PVP_MHWINTERFACE hwInterface,
1153 PVpAllocator &allocator,
1154 VPMediaMemComp *mmc) :
1155 CmdPacket(task),
1156 VpCmdPacket(task, hwInterface, allocator, mmc, VP_PIPELINE_PACKET_VEBOX),
1157 VpVeboxCmdPacketBase(task, hwInterface, allocator, mmc)
1158 {
1159 VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(hwInterface);
1160 VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(hwInterface->m_vpPlatformInterface);
1161 m_veboxItf = hwInterface->m_vpPlatformInterface->GetMhwVeboxItf();
1162 m_miItf = hwInterface->m_vpPlatformInterface->GetMhwMiItf();
1163 m_vpUserFeatureControl = hwInterface->m_userFeatureControl;
1164 }
1165
1166 VpVeboxCmdPacket:: ~VpVeboxCmdPacket()
1167 {
1168 VP_FUNC_CALL();
1169
1170 MOS_Delete(m_sfcRender);
1171 MOS_Delete(m_lastExecRenderData);
1172 MOS_Delete(m_surfMemCacheCtl);
1173
1174 m_allocator->DestroyVpSurface(m_currentSurface);
1175 m_allocator->DestroyVpSurface(m_previousSurface);
1176 m_allocator->DestroyVpSurface(m_renderTarget);
1177 m_allocator->DestroyVpSurface(m_originalOutput);
1178 }
1179
1180 bool VpVeboxCmdPacket::IsVeboxGamutStateNeeded()
1181 {
1182 VP_FUNC_CALL();
1183
1184 VpVeboxRenderData *renderData = GetLastExecRenderData();
1185
1186 if (renderData)
1187 {
1188 return renderData->HDR3DLUT.bHdr3DLut || renderData->IECP.CGC.bCGCEnabled;
1189 }
1190 else
1191 {
1192 return false;
1193 }
1194 }
1195
1196 MOS_STATUS VpVeboxCmdPacket::VeboxSetPerfTag()
1197 {
1198 VP_FUNC_CALL();
1199
1200 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1201 PVPHAL_PERFTAG pPerfTag = nullptr;
1202 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
1203
1204 VP_PUBLIC_CHK_NULL_RETURN(pRenderData);
1205 VP_PUBLIC_CHK_NULL_RETURN(m_currentSurface);
1206 VP_PUBLIC_CHK_NULL_RETURN(m_currentSurface->osSurface);
1207
1208 MOS_FORMAT srcFmt = m_currentSurface->osSurface->Format;
1209
1210 pPerfTag = &pRenderData->PerfTag;
1211
1212 switch (srcFmt)
1213 {
1214 case Format_NV12:
1215 return VeboxSetPerfTagNv12();
1216
1217 CASE_PA_FORMAT:
1218 return VeboxSetPerfTagPaFormat();
1219
1220 case Format_P010:
1221 // P010 Input Support for VEBOX, SFC
1222 *pPerfTag = VPHAL_VEBOX_P010;
1223 break;
1224
1225 case Format_P016:
1226 // P016 Input Support for VEBOX, SFC
1227 *pPerfTag = VPHAL_VEBOX_P016;
1228 break;
1229
1230 case Format_P210:
1231 // P210 Input Support for VEBOX, SFC
1232 *pPerfTag = VPHAL_VEBOX_P210;
1233 break;
1234
1235 case Format_P216:
1236 // P216 Input Support for VEBOX, SFC
1237 *pPerfTag = VPHAL_VEBOX_P216;
1238 break;
1239
1240 case Format_Y210:
1241 // Y210 Input Support for VEBOX, SFC
1242 *pPerfTag = VPHAL_VEBOX_Y210;
1243 break;
1244
1245 case Format_Y216:
1246 // Y216 Input Support for VEBOX, SFC
1247 *pPerfTag = VPHAL_VEBOX_Y216;
1248 break;
1249
1250 case Format_Y410:
1251 // Y410 Input Support for VEBOX, SFC
1252 *pPerfTag = VPHAL_VEBOX_Y410;
1253 break;
1254
1255 case Format_Y416:
1256 // Y416 Input Support for VEBOX, SFC
1257 *pPerfTag = VPHAL_VEBOX_Y416;
1258 break;
1259
1260 CASE_RGB32_FORMAT:
1261 *pPerfTag = VPHAL_VEBOX_RGB32;
1262 break;
1263
1264 case Format_AYUV:
1265 *pPerfTag = VPHAL_VEBOX_AYUV;
1266 break;
1267
1268 case Format_A16B16G16R16:
1269 case Format_A16R16G16B16:
1270 case Format_A16B16G16R16F:
1271 case Format_A16R16G16B16F:
1272 *pPerfTag = VPHAL_VEBOX_RGB64;
1273 break;
1274
1275 default:
1276 VP_RENDER_ASSERTMESSAGE("Format Not found.");
1277 *pPerfTag = VPHAL_NONE;
1278 eStatus = MOS_STATUS_INVALID_PARAMETER;
1279 } // switch (srcFmt)
1280
1281 return eStatus;
1282 }
1283
1284 MOS_STATUS VpVeboxCmdPacket::VeboxSetPerfTagNv12()
1285 {
1286 VP_FUNC_CALL();
1287
1288 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1289 PVPHAL_PERFTAG pPerfTag = nullptr;
1290 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
1291
1292 VP_PUBLIC_CHK_NULL_RETURN(pRenderData);
1293 VP_PUBLIC_CHK_NULL_RETURN(m_renderTarget);
1294 VP_PUBLIC_CHK_NULL_RETURN(m_renderTarget->osSurface);
1295
1296 MOS_FORMAT dstFormat = m_renderTarget->osSurface->Format;
1297
1298 pPerfTag = &pRenderData->PerfTag;
1299
1300 if (pRenderData->IsDiEnabled())
1301 {
1302 if (pRenderData->DN.bDnEnabled ||
1303 pRenderData->DN.bChromaDnEnabled)
1304 {
1305 if (IsIECPEnabled())
1306 {
1307 *pPerfTag = VPHAL_NV12_DNDI_422CP;
1308 }
1309 else
1310 {
1311 *pPerfTag = VPHAL_NV12_DNDI_PA;
1312 }
1313 }
1314 else
1315 {
1316 if (IsIECPEnabled())
1317 {
1318 *pPerfTag = VPHAL_PL_DI_422CP;
1319 }
1320 else
1321 {
1322 *pPerfTag = VPHAL_PL_DI_PA;
1323 }
1324 }
1325 }
1326 else
1327 {
1328 if (pRenderData->DN.bDnEnabled ||
1329 pRenderData->DN.bChromaDnEnabled)
1330 {
1331 if (IsOutputPipeVebox())
1332 {
1333 switch (dstFormat)
1334 {
1335 case Format_NV12:
1336 *pPerfTag = VPHAL_NV12_DN_420CP;
1337 break;
1338 CASE_PA_FORMAT:
1339 *pPerfTag = VPHAL_NV12_DN_422CP;
1340 break;
1341 case Format_RGB32:
1342 case Format_A8R8G8B8:
1343 case Format_A8B8G8R8:
1344 *pPerfTag = VPHAL_NV12_DN_RGB32CP;
1345 break;
1346 case Format_P010:
1347 case Format_P016:
1348 case Format_Y410:
1349 case Format_Y416:
1350 case Format_Y210:
1351 case Format_Y216:
1352 case Format_AYUV:
1353 case Format_Y8:
1354 case Format_Y16S:
1355 case Format_Y16U:
1356 case Format_A16B16G16R16F:
1357 case Format_A16R16G16B16F:
1358 *pPerfTag = VPHAL_NONE;
1359 break;
1360 default:
1361 VP_PUBLIC_ASSERTMESSAGE("Output Format Not found.");
1362 return MOS_STATUS_INVALID_PARAMETER;
1363 }
1364 }
1365 else if (IsIECPEnabled())
1366 {
1367 *pPerfTag = VPHAL_NV12_DN_420CP;
1368 }
1369 else
1370 {
1371 *pPerfTag = VPHAL_NV12_DN_NV12;
1372 }
1373 }
1374 else
1375 {
1376 if (IsOutputPipeVebox())
1377 {
1378 switch (dstFormat)
1379 {
1380 case Format_NV12:
1381 *pPerfTag = VPHAL_NV12_420CP;
1382 break;
1383 CASE_PA_FORMAT:
1384 *pPerfTag = VPHAL_NV12_422CP;
1385 break;
1386 case Format_RGB32:
1387 *pPerfTag = VPHAL_NV12_RGB32CP;
1388 break;
1389 case Format_A8R8G8B8:
1390 case Format_A8B8G8R8:
1391 case Format_R10G10B10A2:
1392 case Format_B10G10R10A2:
1393 *pPerfTag = VPHAL_NV12_RGB32CP;
1394 break;
1395 case Format_P010:
1396 case Format_P016:
1397 case Format_Y410:
1398 case Format_Y416:
1399 case Format_Y210:
1400 case Format_Y216:
1401 case Format_AYUV:
1402 case Format_Y8:
1403 case Format_Y16S:
1404 case Format_Y16U:
1405 case Format_A16B16G16R16F:
1406 case Format_A16R16G16B16F:
1407 *pPerfTag = VPHAL_NONE;
1408 break;
1409 default:
1410 VP_RENDER_ASSERTMESSAGE("Output Format Not found.");
1411 return MOS_STATUS_INVALID_PARAMETER;
1412 }
1413 }
1414 else
1415 {
1416 *pPerfTag = VPHAL_NV12_420CP;
1417 }
1418 }
1419 }
1420 return MOS_STATUS_SUCCESS;
1421 }
1422
1423 MOS_STATUS VpVeboxCmdPacket::VeboxSetPerfTagPaFormat()
1424 {
1425 VP_FUNC_CALL();
1426
1427 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1428 PVPHAL_PERFTAG pPerfTag = nullptr;
1429 VpVeboxRenderData *pRenderData = GetLastExecRenderData();
1430
1431 VP_PUBLIC_CHK_NULL_RETURN(pRenderData);
1432 VP_PUBLIC_CHK_NULL_RETURN(m_renderTarget);
1433 VP_PUBLIC_CHK_NULL_RETURN(m_renderTarget->osSurface);
1434
1435 MOS_FORMAT dstFormat = m_renderTarget->osSurface->Format;
1436
1437 pPerfTag = &pRenderData->PerfTag;
1438
1439 if (pRenderData->IsDiEnabled())
1440 {
1441 if (pRenderData->DN.bDnEnabled ||
1442 pRenderData->DN.bChromaDnEnabled)
1443 {
1444 if (IsIECPEnabled())
1445 {
1446 *pPerfTag = VPHAL_PA_DNDI_422CP;
1447 }
1448 else
1449 {
1450 *pPerfTag = VPHAL_PA_DNDI_PA;
1451 }
1452 }
1453 else
1454 {
1455 if (IsIECPEnabled())
1456 {
1457 *pPerfTag = VPHAL_PA_DI_422CP;
1458 }
1459 else
1460 {
1461 *pPerfTag = VPHAL_PA_DI_PA;
1462 }
1463 }
1464 }
1465 else
1466 {
1467 if (pRenderData->DN.bDnEnabled ||
1468 pRenderData->DN.bChromaDnEnabled)
1469 {
1470 if (IsOutputPipeVebox())
1471 {
1472 switch (dstFormat)
1473 {
1474 case Format_NV12:
1475 *pPerfTag = VPHAL_PA_DN_420CP;
1476 break;
1477 CASE_PA_FORMAT:
1478 *pPerfTag = VPHAL_PA_DN_422CP;
1479 break;
1480 case Format_RGB32:
1481 *pPerfTag = VPHAL_PA_DN_RGB32CP;
1482 break;
1483 case Format_A8R8G8B8:
1484 case Format_A8B8G8R8:
1485 case Format_R10G10B10A2:
1486 case Format_B10G10R10A2:
1487 *pPerfTag = VPHAL_PA_RGB32CP;
1488 break;
1489 case Format_P010:
1490 case Format_P016:
1491 case Format_Y410:
1492 case Format_Y416:
1493 case Format_Y210:
1494 case Format_Y216:
1495 case Format_AYUV:
1496 case Format_Y8:
1497 case Format_Y16S:
1498 case Format_Y16U:
1499 case Format_A16B16G16R16F:
1500 case Format_A16R16G16B16F:
1501 *pPerfTag = VPHAL_NONE;
1502 break;
1503 default:
1504 VP_RENDER_ASSERTMESSAGE("Output Format Not found.");
1505 return MOS_STATUS_INVALID_PARAMETER;
1506 }
1507 }
1508 else if (IsIECPEnabled())
1509 {
1510 *pPerfTag = VPHAL_PA_DN_422CP;
1511 }
1512 else
1513 {
1514 *pPerfTag = VPHAL_PA_DN_PA;
1515 }
1516 }
1517 else
1518 {
1519 if (IsOutputPipeVebox())
1520 {
1521 switch (dstFormat)
1522 {
1523 case Format_NV12:
1524 *pPerfTag = VPHAL_PA_420CP;
1525 break;
1526 CASE_PA_FORMAT:
1527 *pPerfTag = VPHAL_PA_422CP;
1528 break;
1529 case Format_RGB32:
1530 *pPerfTag = VPHAL_PA_RGB32CP;
1531 break;
1532 case Format_A8R8G8B8:
1533 case Format_A8B8G8R8:
1534 case Format_R10G10B10A2:
1535 case Format_B10G10R10A2:
1536 *pPerfTag = VPHAL_PA_RGB32CP;
1537 break;
1538 case Format_P010:
1539 case Format_P016:
1540 case Format_Y410:
1541 case Format_Y416:
1542 case Format_Y210:
1543 case Format_Y216:
1544 case Format_AYUV:
1545 case Format_Y8:
1546 case Format_Y16S:
1547 case Format_Y16U:
1548 case Format_A16B16G16R16F:
1549 case Format_A16R16G16B16F:
1550 *pPerfTag = VPHAL_NONE;
1551 break;
1552 default:
1553 VP_RENDER_ASSERTMESSAGE("Output Format Not found.");
1554 return MOS_STATUS_INVALID_PARAMETER;
1555 }
1556 }
1557 else
1558 {
1559 *pPerfTag = VPHAL_PA_422CP;
1560 }
1561 }
1562 }
1563
1564 return MOS_STATUS_SUCCESS;
1565 }
1566
1567 MHW_CSPACE VpVeboxCmdPacket::VpHalCspace2MhwCspace(VPHAL_CSPACE cspace)
1568 {
1569 VP_FUNC_CALL();
1570
1571 switch (cspace)
1572 {
1573 case CSpace_Source:
1574 return MHW_CSpace_Source;
1575
1576 case CSpace_RGB:
1577 return MHW_CSpace_RGB;
1578
1579 case CSpace_YUV:
1580 return MHW_CSpace_YUV;
1581
1582 case CSpace_Gray:
1583 return MHW_CSpace_Gray;
1584
1585 case CSpace_Any:
1586 return MHW_CSpace_Any;
1587
1588 case CSpace_sRGB:
1589 return MHW_CSpace_sRGB;
1590
1591 case CSpace_stRGB:
1592 return MHW_CSpace_stRGB;
1593
1594 case CSpace_BT601:
1595 return MHW_CSpace_BT601;
1596
1597 case CSpace_BT601_FullRange:
1598 return MHW_CSpace_BT601_FullRange;
1599
1600 case CSpace_BT709:
1601 return MHW_CSpace_BT709;
1602
1603 case CSpace_BT709_FullRange:
1604 return MHW_CSpace_BT709_FullRange;
1605
1606 case CSpace_xvYCC601:
1607 return MHW_CSpace_xvYCC601;
1608
1609 case CSpace_xvYCC709:
1610 return MHW_CSpace_xvYCC709;
1611
1612 case CSpace_BT601Gray:
1613 return MHW_CSpace_BT601Gray;
1614
1615 case CSpace_BT601Gray_FullRange:
1616 return MHW_CSpace_BT601Gray_FullRange;
1617
1618 case CSpace_BT2020:
1619 return MHW_CSpace_BT2020;
1620
1621 case CSpace_BT2020_RGB:
1622 return MHW_CSpace_BT2020_RGB;
1623
1624 case CSpace_BT2020_FullRange:
1625 return MHW_CSpace_BT2020_FullRange;
1626
1627 case CSpace_BT2020_stRGB:
1628 return MHW_CSpace_BT2020_stRGB;
1629
1630 case CSpace_None:
1631 default:
1632 return MHW_CSpace_None;
1633 }
1634 }
1635 }