xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/common/vp/hal/vphal_renderer.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2009-2021, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     vphal_renderer.h
24 //! \brief    The header file of VPHAL top level rendering component
25 //! \details  The top renderer is responsible for coordinating the sequence of calls to low level renderers, e.g. DNDI or Comp
26 //!
27 #ifndef __VPHAL_RENDERER_H__
28 #define __VPHAL_RENDERER_H__
29 
30 #include "mos_os.h"
31 #include "vphal.h"
32 #include "vphal_render_common.h"
33 #include "vphal_render_renderstate.h"
34 #include "vphal_render_vebox_base.h"
35 #include "vphal_render_16alignment.h"
36 #include "vphal_render_fast1ton.h"
37 #include "vphal_debug.h"
38 #include "vphal_render_hdr_base.h"
39 
40 #define VPHAL_RNDR_TEMP_OUT_SURFS            2
41 
42 // Slice Shutdown Modes
43 #define VPHAL_SSD_DEFAULT 0
44 #define VPHAL_SSD_ENABLE  1
45 #define VPHAL_SSD_DISABLE 2
46 
47 //!
48 //! \brief MACRO to dump surface for the given layer
49 //!
50 #define VPHAL_RNDR_DUMP_SURF(pRenderer, uiLayer, Location, pSurface)            \
51     VPHAL_DBG_SURFACE_DUMP(                                                     \
52     pRenderer->m_surfaceDumper,                                                \
53     pSurface,                                                                   \
54     pRenderer->uiFrameCounter,                                                  \
55     uiLayer,                                                                    \
56     Location)
57 
58 //!
59 //! \brief MACRO to dump all layers
60 //!
61 #define VPHAL_RNDR_DUMP_SURF_PTR_ARRAY(pRenderer, pSurf, surfMax, surfCount, Location)      \
62     VPHAL_DBG_SURFACE_PTRS_DUMP(                                                \
63     pRenderer->m_surfaceDumper,                                                \
64     pSurf,                                                                      \
65     surfMax,                                                                    \
66     surfCount,                                                                  \
67     pRenderer->uiFrameCounter,                                                  \
68     Location)
69 
70 //!
71 //! \brief MACRO to set status report params
72 //!
73 #if (_DEBUG || _RELEASE_INTERNAL)
74 #define VPHAL_RNDR_SET_STATUS_REPORT_PARAMS(pState, pRenderer, pRenderParams) do {                \
75     if (pState)                                                                                   \
76     {                                                                                             \
77         bool bSurfIsRenderTarget = (pRenderParams->pTarget[0]->SurfType == SURF_OUT_RENDERTARGET);\
78         (pState)->StatusTableUpdateParams.bReportStatus       = (pRenderParams->bReportStatus);   \
79         (pState)->StatusTableUpdateParams.bSurfIsRenderTarget = bSurfIsRenderTarget;              \
80         (pState)->StatusTableUpdateParams.pStatusTable        = pRenderer->m_statusTable;          \
81         (pState)->StatusTableUpdateParams.StatusFeedBackID    = pRenderParams->StatusFeedBackID;  \
82         (pState)->StatusTableUpdateParams.bTriggerGPUHang     = pRenderParams->bTriggerGPUHang;   \
83     }                                                                                             \
84 } while(0)
85 #else
86 #define VPHAL_RNDR_SET_STATUS_REPORT_PARAMS(pState, pRenderer, pRenderParams) do {                \
87     if (pState)                                                                                   \
88     {                                                                                             \
89         bool bSurfIsRenderTarget = (pRenderParams->pTarget[0]->SurfType == SURF_OUT_RENDERTARGET);\
90         (pState)->StatusTableUpdateParams.bReportStatus       = (pRenderParams->bReportStatus);   \
91         (pState)->StatusTableUpdateParams.bSurfIsRenderTarget = bSurfIsRenderTarget;              \
92         (pState)->StatusTableUpdateParams.pStatusTable        = pRenderer->m_statusTable;         \
93         (pState)->StatusTableUpdateParams.StatusFeedBackID    = pRenderParams->StatusFeedBackID;  \
94     }                                                                                             \
95 } while(0)
96 #endif
97 
98 //!
99 //! \brief Render ID enum
100 //!
101 enum VPHAL_RENDER_ID
102 {
103     VPHAL_RENDER_ID_VEBOX = 0,
104     VPHAL_RENDER_ID_VEBOX2,
105     VPHAL_RENDER_ID_COMPOSITE,
106     VPHAL_RENDER_ID_COUNT                   //!< Keep this line at the end
107 };
108 C_ASSERT(VPHAL_RENDER_ID_COUNT == 3);      //!< When adding, update assert
109 
110 //!
111 //! \brief VPHAL renderer class
112 //!
113 class VphalRenderer
114 {
115 public:
116     // 16 Bytes Alignment state
117     VPHAL_16_ALIGN_STATE        Align16State;
118     // Fast 1toN state
119     VPHAL_FAST1TON_STATE        Fast1toNState;
120     // Rendering engines
121     VPHAL_VEBOX_EXEC_STATE      VeboxExecState[VPHAL_MAX_CHANNELS];             //!< Vebox Execution State
122 
123     RenderState                 *pRender[VPHAL_RENDER_ID_COUNT];
124 
125     // VpHal surfaces
126     PVPHAL_SURFACE              pPrimaryFwdRef[VPHAL_MAX_FUTURE_FRAMES];
127 
128     bool                        bVeboxUsedForCapPipe;                           //!< VEBOX used for CapPipe
129 
130     // Stereo state.
131     uint32_t                    uiCurrentChannel;                               //!< 0=StereoLeft or nonStereo, 1=StereoRight. N/A in nonStereo
132 
133     // Compositing Kernel DLL/Search state
134     const Kdll_RuleEntry        *pKernelDllRules;
135     Kdll_State                  *pKernelDllState;
136 
137     // Compositing Kernel buffer and size
138     const void                  *pcKernelBin    = nullptr;
139     uint32_t                    dwKernelBinSize = 0;
140 
141     // CM Compositing Kernel patch file buffer and size
142     const void                  *pcFcPatchBin   = nullptr;
143     uint32_t                    dwFcPatchBinSize = 0;
144 
145     // Surface dumper fields (counter and specification)
146     uint32_t                    uiFrameCounter;
147 #if (_DEBUG || _RELEASE_INTERNAL)
148     VphalSurfaceDumper          *m_surfaceDumper;
149     VphalParameterDumper        *m_parameterDumper;
150 #endif
151 
152     // StatusTable indicating if command is done by gpu or not
153     PVPHAL_STATUS_TABLE          m_statusTable;
154 
155     // max src rectangle
156     RECT                        maxSrcRect;
157 
158     // Intermediate surface, currently two usages:
159     // 1) It is for viedo surveillance usage, when applying AVS for multiple surfaces;
160     // 2) It could be VEBOX output or input for HDR processing;
161     VPHAL_SURFACE               IntermediateSurface = {};
162     PVPHAL_HDR_STATE            pHdrState;
163 
164     // Perf Optimize for ClearVideoView DDI
165     bool m_clearVideoViewMode = false;
166 
167 protected:
168     // Renderer private data
169     PRENDERHAL_INTERFACE_LEGACY m_pRenderHal;
170     PMOS_INTERFACE              m_pOsInterface;
171     MediaUserSettingSharedPtr   m_userSettingPtr = nullptr;   //!< usersettingInstance
172     // Auxiliary
173     MEDIA_FEATURE_TABLE           *m_pSkuTable;
174     MEDIA_WA_TABLE              *m_pWaTable;
175 
176     void (*m_modifyKdllFunctionPointers)(PKdll_State);
177 
178     uint32_t                    uiSsdControl;                                   //!< Slice Shutdown Control - read from User feature keys
179     bool                        bDpRotationUsed;                                //!< Dataport-based rotation Used Flag
180     bool                        bSkuDisableVpFor4K;                             //!< Disable VP features for 4K
181     bool                        bSkuDisableLaceFor4K;                           //!< Disable LACE for 4K
182     bool                        bSkuDisableDNFor4K;                             //!< Disable DN for 4K
183 
184     // VDI performance data
185     VPHAL_RNDR_PERF_DATA        PerfData;
186 
187     // Renderer feature reporting
188     VphalFeatureReport          *m_reporting;
189     // Default value for Gpu Context
190     MOS_GPU_CONTEXT             m_renderGpuContext;
191     bool                        m_isApoEnabled = false;
192 
193 public:
194     //!
195     //! \brief    VphalRenderer constructor
196     //! \details  Based on the HW and OS info, initialize the renderer interfaces
197     //! \param    [in] pRenderHal
198     //!           Pointer to RenderHal Interface Structure
199     //! \param    [in,out] pStatus
200     //!           Pointer to the MOS_STATUS flag.
201     //!           Will assign this flag to MOS_STATUS_SUCCESS if successful, otherwise failed
202     //!
203     VphalRenderer(
204         PRENDERHAL_INTERFACE                pRenderHal,
205         MOS_STATUS                          *pStatus);
206 
207     //!
208     //! \brief    Copy constructor
209     //!
210     VphalRenderer(const VphalRenderer&) = delete;
211 
212     //!
213     //! \brief    Copy assignment operator
214     //!
215     VphalRenderer& operator=(const VphalRenderer&) = delete;
216 
217     //!
218     //! \brief    VPHAL renderer destructor
219     //! \details  Destory the resources allocated for the renderers
220     //!           including VEBOX and Composite.
221     //!
222     virtual ~VphalRenderer();
223 
224     //!
225     //! \brief    Get Renderer Cache Settings
226     //! \details  Get cache settings for various VP features
227     //! \param    [in] pOsInterface
228     //!           OS Interface
229     //! \param    [in] pPlatform
230     //!           Platform Pointer
231     //! \param    [in] pSkuTable
232     //!           SKU feature table
233     //! \param    [in,out] pSettings
234     //!           Pointer to Render Cache Control Settings
235     //! \return   void
236     //!
237     virtual void GetCacheCntl(
238         PMOS_INTERFACE                      pOsInterface,
239         PLATFORM                            *pPlatform,
240         MEDIA_FEATURE_TABLE                 *pSkuTable,
241         PVPHAL_RENDER_CACHE_CNTL            pSettings) = 0;
242 
243     //!
244     //! \brief    Allocate render components
245     //! \param    [in] pVeboxInterface
246     //!           Pointer to Vebox Interface Structure
247     //! \param    [in] pSfcInterface
248     //!           Pointer to SFC interface Structure
249     //! \return   MOS_STATUS
250     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
251     //!
252     virtual MOS_STATUS AllocateRenderComponents(
253         PMHW_VEBOX_INTERFACE                pVeboxInterface,
254         PMHW_SFC_INTERFACE                  pSfcInterface) = 0;
255 
256     //!
257     //! \brief    Initialize the VPHAL renderer
258     //! \details  Initialize all the renderers supported including VEBOX, Composite.
259     //! \param    [in] pSettings
260     //!           Const pointer to VPHAL settings
261     //! \return   MOS_STATUS
262     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
263     //!
264     virtual MOS_STATUS Initialize(
265         const VphalSettings                 *pSettings,
266         bool                                isApoEnabled);
267 
268     //!
269     //! \brief    Main render function
270     //! \details  The top level renderer function, which may contain multiple
271     //!           passes of rendering
272     //! \param    [in] pcRenderParams
273     //!           Const pointer to VPHAL render parameter
274     //! \return   MOS_STATUS
275     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
276     //!
277     virtual MOS_STATUS Render(
278         PCVPHAL_RENDER_PARAMS   pcRenderParams);
279 
GetReport()280     VphalFeatureReport* GetReport() {
281         return m_reporting;
282     }
283 
GetOsInterface()284     PMOS_INTERFACE GetOsInterface() {
285         return m_pOsInterface;
286     }
287 
GetSkuTable()288     MEDIA_FEATURE_TABLE* GetSkuTable() {
289         return m_pSkuTable;
290     }
291 
SetStatusReportTable(PVPHAL_STATUS_TABLE statusTable)292     void SetStatusReportTable(PVPHAL_STATUS_TABLE statusTable)
293     {
294         m_statusTable = statusTable;
295     }
296 
297     //!
298     //! \brief    Initialize the KDLL parameters
299     //! \details  Initialize the KDLL parameters
300     //! \return   MOS_STATUS
301     //!
302     virtual MOS_STATUS InitKdllParam() = 0;
303 
304     //!
305     //! \brief    Update Render Gpu Context
306     //! \details  Update Render Gpu Context
307     //! \param    [in] renderGpuContext
308     //! \return   MOS_STATUS
309     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
310     //!
311     virtual MOS_STATUS UpdateRenderGpuContext(MOS_GPU_CONTEXT renderGpuContext);
312 
313     //!
314     //! \brief    set Render Gpu Context
315     //! \details  set Render Gpu Context based on lumakey and CCS status.
316     //! \param    [in] RenderParams
317     //!           VPHAL render parameter
318     //! \return   MOS_STATUS
319     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
320     //!
321     virtual MOS_STATUS SetRenderGpuContext(VPHAL_RENDER_PARAMS& RenderParams);
322 
323     //!
324     //! \brief    Explicitly initialize the maxSrcRect member
325     //! \details  The maxSrcRect member keeps track of the maximum rectangle
326     //!           among a set of source surfaces.  There is a need to
327     //!           explicitly re-initialize this member in VphalState::Render
328     //!           prior to calling the main render function.  This is so that
329     //!           the maxSrcRect value for the last set of surfaces does not
330     //!           get re-used for the current set of surfaces.
331     //! \return   void
332     //!
InitMaxSrcRect()333     void InitMaxSrcRect()
334     {
335         maxSrcRect = {0, 0, 0, 0};
336     }
337 
338 protected:
339     //!
340     //! \brief    Prepare input surface list for top level render processing
341     //! \details  Prepare the inputs, e.g. adjust src/dst rectangles of stereo input or allocate
342     //!           and copy intermediate surfaces.
343     //! \param    [in,out] pRenderParams
344     //!           Pointer to VPHAL render parameter
345     //! \param    [in,out] pSrcLeft
346     //!           Pointer to left frame list
347     //! \param    [in,out] pSrcRight
348     //!           Pointer to right frame list
349     //! \param    [out] puiRenderPasses
350     //!           Pointer to times of the rendering.
351     //!                 The value is 2 for S3D and 1 for the other cases.
352     //! \return   MOS_STATUS
353     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
354     //!
355     virtual MOS_STATUS PrepareSources(
356         PVPHAL_RENDER_PARAMS    pRenderParams,
357         PVPHAL_SURFACE          *pSrcLeft,
358         PVPHAL_SURFACE          *pSrcRight,
359         uint32_t                *puiRenderPasses);
360 
361     //!
362     //! \brief    Render function for the pass
363     //! \details  The render function coordinates the advanced renderers and basic
364     //!           renders in one pass
365     //! \param    [in,out] pRenderParams
366     //!           Pointer to VPHAL render parameter
367     //! \return   MOS_STATUS
368     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
369     //!
370     virtual MOS_STATUS RenderPass(
371         PVPHAL_RENDER_PARAMS    pRenderParams);
372 
373     //!
374     //! \brief    Release intermediate surfaces
375     //! \details  Release intermediate surfaces created for main render function
376     //! \return   MOS_STATUS
377     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
378     //!
379     virtual MOS_STATUS FreeIntermediateSurfaces();
380 
381     //!
382     //! \brief    Process render parameter
383     //! \param    [in,out] pRenderParams
384     //!           Pointer to VPHAL render parameter
385     //! \param    [in,out] pRenderPassData
386     //!           Pointer to the VPHAL render pass data
387     //! \return   MOS_STATUS
388     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
389     //!
390     MOS_STATUS ProcessRenderParameter(
391         PVPHAL_RENDER_PARAMS    pRenderParams,
392         RenderpassData          *pRenderPassData);
393 
394     //!
395     //! \brief    Adjust surface parameter
396     //! \param    [in] pRenderParams
397     //!           Pointer to VPHAL render parameter
398     //! \param    [in,out] pSrcSurface
399     //!           Pointer to VPHAL surface
400     //! \param    [in] pGtSystemInfo
401     //!           Pointer to GT system information structure
402     //! \param    [in] bHybridDecoderFlag
403     //!           Hybrid Decoder or not
404     //! \return   MOS_STATUS
405     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
406     //!
407     MOS_STATUS AdjustSurfaceParam(
408         PVPHAL_RENDER_PARAMS    pRenderParams,
409         PVPHAL_SURFACE          pSrcSurface,
410         MEDIA_SYSTEM_INFO       *pGtSystemInfo,
411         bool                    bHybridDecoderFlag);
412 
413     //!
414     //! \brief    Render single stream
415     //! \param    [in] pRenderParams
416     //!           Pointer to VPHAL render parameter
417     //! \param    [in,out] pRenderPassData
418     //!           Pointer to the VPHAL render pass data
419     //! \return   MOS_STATUS
420     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
421     //!
422     virtual MOS_STATUS RenderSingleStream(
423         PVPHAL_RENDER_PARAMS    pRenderParams,
424         RenderpassData          *pRenderPassData);
425 
426     //!
427     //! \brief    Compose input streams as fast 1toN
428     //! \details  Use composite render to multi output streams
429     //! \param    [in] pRenderParams
430     //!           Pointer to VPHAL render parameter
431     //! \param    [in,out] pRenderPassData
432     //!           Pointer to the VPHAL render pass data
433     //! \return   MOS_STATUS
434     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
435     //!
436     MOS_STATUS RenderFast1toNComposite(
437         PVPHAL_RENDER_PARAMS    pRenderParams,
438         RenderpassData          *pRenderPassData);
439 
440     //!
441     //! \brief    Compose input streams
442     //! \details  Use composite render to compose input streams
443     //! \param    [in] pRenderParams
444     //!           Pointer to VPHAL render parameter
445     //! \param    [in,out] pRenderPassData
446     //!           Pointer to the VPHAL render pass data
447     //! \return   MOS_STATUS
448     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
449     //!
450     MOS_STATUS RenderComposite(
451         PVPHAL_RENDER_PARAMS    pRenderParams,
452         RenderpassData          *pRenderPassData);
453 
454     //!
455     //! \brief    Get surface info for all input source
456     //! \details  Get surface info for the input surface and its reference surfaces
457     //! \param    [in] pRenderParams
458     //!           Pointer to VPHAL render parameter
459     //! \return   MOS_STATUS
460     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
461     //!
462     MOS_STATUS GetSurfaceInfoForSrc(
463         PVPHAL_RENDER_PARAMS    pRenderParams);
464 
465     //!
466     //! \brief    Check if Vphal renderer support some formats
467     //! \param    [in] pcRenderParams
468     //!           Const pointer to VPHAL render parameter
469     //! \return   bool
470     //!           Return true if successful, false failed
471     //!
472     bool IsFormatSupported(
473         PCVPHAL_RENDER_PARAMS   pcRenderParams);
474 
475     //!
476     //! \brief    Update report data
477     //! \details  Update report data from each feature render
478     //! \param    [in] pRenderParams
479     //!           Pointer to VPHAL render parameter
480     //! \param    [in,out] pRenderPassData
481     //!           Pointer to the VPHAL render pass data
482     //!
483     void UpdateReport(
484         PVPHAL_RENDER_PARAMS    pRenderParams,
485         RenderpassData          *pRenderPassData);
486 
487     //!
488     //! \brief    Allocate debug dumper
489     //! \return   MOS_STATUS
490     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
491     //!
492     virtual MOS_STATUS AllocateDebugDumper();
493 
494     //!
495     //! \brief    Allocate surface dumper
496     //! \return   MOS_STATUS
497     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
498     //!
499     virtual MOS_STATUS CreateSurfaceDumper();
500 
501     //!
502     //! \brief    Get Hdr path needed flag
503     //! \details  Get Hdr path needed flag
504     //! \param    pRenderParams
505     //!           [in] Pointer to VPHAL render parameter
506     //! \param    pRenderPassData
507     //!           [in,out] Pointer to the VPHAL render pass data
508     //! \return   MOS_STATUS
509     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
510     //!
511     virtual MOS_STATUS GetHdrPathNeededFlag(
512         PVPHAL_RENDER_PARAMS    pRenderParams,
513         RenderpassData          *pRenderPassData);
514 };
515 
516 #define VPHAL_RENDERER_GET_CACHE_CNTL(obj, pOsInterface, pPlatform, pSkuTable, pSettings)   \
517                 obj->GetCacheCntl(pOsInterface, pPlatform, pSkuTable, pSettings)
518 
519 //!
520 //! \brief    Initialize AVS parameters shared by Renderers
521 //! \details  Initialize the members of the AVS parameter and allocate memory for its coefficient tables
522 //! \param    [in,out] pAVS_Params
523 //!           Pointer to VPHAL AVS parameter
524 //! \param    [in] uiYCoeffTableSize
525 //!           Size of the Y coefficient table
526 //! \param    [in] uiUVCoeffTableSize
527 //!           Size of the UV coefficient table
528 //! \return   MOS_STATUS
529 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
530 //!
531 MOS_STATUS VpHal_RenderInitAVSParams(
532     PMHW_AVS_PARAMS             pAVS_Params,
533     uint32_t                    uiYCoeffTableSize,
534     uint32_t                    uiUVCoeffTableSize);
535 
536 //!
537 //! \brief    Destroy AVS parameters shared by Renderers
538 //! \details  Free the memory of AVS parameter's coefficient tables
539 //! \param    [in,out] pAVS_Params
540 //!           Pointer to VPHAL AVS parameter
541 //! \return   void
542 //!
543 void VpHal_RenderDestroyAVSParams(
544     PMHW_AVS_PARAMS             pAVS_Params);
545 
546 //!
547 //! \brief    Search from existing BBs for a match. If none, allocate new BB
548 //! \details  Based on the params of the BB, search the BB table and try to get
549 //!           the best match. If none, try to get an old unused BB to reuse. If
550 //!           still none, allocate one new BB
551 //! \param    [in] pBatchBufferTable
552 //!           Pointer to the BB table to be searched
553 //! \param    [in] pInputBbParams
554 //!           Pointer to the BB params required for the BB needed
555 //! \param    [in] iBbSize
556 //!           The BB size required for the BB needed
557 //! \param    [in] pRenderHal
558 //!           Pointer to RenderHal Interface Structure
559 //! \param    [out] ppBatchBuffer
560 //!           Pointer to the addr of the available BB. Point to nullptr if there's no
561 //! \return   MOS_STATUS
562 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
563 //!
564 MOS_STATUS VpHal_RenderAllocateBB(
565     PVPHAL_BATCH_BUFFER_TABLE   pBatchBufferTable,
566     PVPHAL_BATCH_BUFFER_PARAMS  pInputBbParams,
567     int32_t                     iBbSize,
568     PRENDERHAL_INTERFACE        pRenderHal,
569     PMHW_BATCH_BUFFER           *ppBatchBuffer);
570 
571 //!
572 //! \brief    Update max src rect in VphalRenderer and primary surface based
573 //!           on src rectangle info from primary video
574 //! \details  Add max src rect for consistent statistics surface layout. Update
575 //!           the max src rect of the surface and its reference surfaces
576 //! \param    [in,out] pRenderer
577 //!           VPHAL renderer pointer
578 //! \param    [in,out] pSurface
579 //!           Pointer to the surface
580 //! \return   void
581 //!
582 void VpHal_RenderInitMaxRect(
583     VphalRenderer               *pRenderer,
584     PVPHAL_SURFACE              pSurface);
585 
586 //!
587 //! \brief    Get the size in byte from that in pixel
588 //! \details  Size_in_byte = size_in_pixel x byte/pixel
589 //! \param    [in] pOsInterface
590 //!           Pointer to OS interface
591 //! \param    [in] Format
592 //!           The format which determines the value of byte/pixel
593 //! \param    [in] dwPixels
594 //!           The size in pixel
595 //! \return   uint32_t
596 //!           Return the size in byte
597 //!
598 uint32_t VpHal_PixelsToBytes(
599     PMOS_INTERFACE      pOsInterface,
600     MOS_FORMAT          Format,
601     uint32_t            dwPixels);
602 
603 //!
604 //! \brief    Save/Restore fwd references for the primary
605 //! \details  Based on the flag passed in to save or restore the forward references
606 //!           of the primary
607 //! \param    [in,out] pRenderer
608 //!           VPHAL renderer pointer
609 //! \param    [in,out] pPrimarySurf
610 //!           Pointer to the primary surface
611 //! \param    [in] bSave
612 //!           Save - true or restore - false the fwd references
613 //! \return   void
614 //!
615 void VpHal_SaveRestorePrimaryFwdRefs(
616     VphalRenderer           *pRenderer,
617     PVPHAL_SURFACE          pPrimarySurf,
618     bool                    bSave);
619 
620 //!
621 //! \brief    Align the src/dst surface rectangle and surface width/height
622 //! \details  The surface rects and width/height need to be aligned according to the surface format
623 //! \param    [in,out] pSurface
624 //!           Pointer to the surface
625 //! \param    [in] formatForDstRect
626 //!           Format for Dst Rect
627 //! \return   MOS_STATUS
628 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
629 //!
630 MOS_STATUS VpHal_RndrRectSurfaceAlignment(
631     PVPHAL_SURFACE       pSurface,
632     MOS_FORMAT           formatForDstRect);
633 
634 //!
635 //! \brief    Search for the best match BB according to the render BB arguments
636 //! \details  Based on the params of the BB, search the BB table and try to get
637 //!           the best match
638 //! \param    [in] pBatchBufferTable
639 //!           Point to the BB table to be searched
640 //! \param    [in] pInputBbParams
641 //!           Point to the BB params required for the BB needed
642 //! \param    [in] iBbSize
643 //!           The BB size required for the BB needed
644 //! \param    [out] ppBatchBuffer
645 //!           Point to the addr of the best matched BB. Point to nullptr if there's no.
646 //! \return   MOS_STATUS
647 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
648 //!
649 MOS_STATUS VpHal_RenderGetBestMatchBB(
650     PVPHAL_BATCH_BUFFER_TABLE       pBatchBufferTable,
651     PVPHAL_BATCH_BUFFER_PARAMS      pInputBbParams,
652     int32_t                         iBbSize,
653     PMHW_BATCH_BUFFER               *ppBatchBuffer);
654 #endif // __VPHAL_RENDER_H__
655