xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/common/vp/hal/vphal.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2009-2022, 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.h
24 //! \brief    vphal interface clarification
25 //! \details  vphal interface clarification inlcuding:
26 //!           some marcro, enum, structure, function
27 //!
28 #ifndef __VPHAL_H__
29 #define __VPHAL_H__
30 
31 #include "mos_utilities.h"
32 #include "mos_util_debug.h"
33 #include "mhw_vebox.h"
34 #include "mhw_sfc.h"
35 #include "vp_pipeline_adapter_base.h"
36 #include "vphal_common_hdr.h"
37 #include "vp_common.h"
38 #include "vp_base.h"
39 #include "renderhal_legacy.h"
40 
41 // YUV input ranges
42 #define YUV_RANGE_FROM_DDI              3
43 
44 // RGB input ranges
45 #define RGB_RANGE_16_235                1
46 #define RGB_RANGE_0_255                 0
47 
48 //------------------------------------------------------------------------------
49 // Simplified macros for debug message, Assert, Null check and MOS eStatus check
50 // within VPhal without the need to explicitly pass comp and sub-comp name
51 //------------------------------------------------------------------------------
52 
53 //------------------------------------------------------------------------------
54 // Macros specific to MOS_VP_SUBCOMP_HW sub-comp
55 //------------------------------------------------------------------------------
56 #define VPHAL_HW_ASSERT(_expr)                                                       \
57     MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _expr)
58 
59 #define VPHAL_HW_ASSERTMESSAGE(_message, ...)                                        \
60     MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _message, ##__VA_ARGS__)
61 
62 #define VPHAL_HW_NORMALMESSAGE(_message, ...)                                        \
63     MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _message, ##__VA_ARGS__)
64 
65 #define VPHAL_HW_VERBOSEMESSAGE(_message, ...)                                       \
66     MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _message, ##__VA_ARGS__)
67 
68 #define VPHAL_HW_FUNCTION_ENTER                                                      \
69     MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW)
70 
71 #define VPHAL_HW_CHK_STATUS(_stmt)                                                   \
72     MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _stmt)
73 
74 #define VPHAL_HW_CHK_NULL(_ptr)                                                      \
75     MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _ptr)
76 
77 #define VPHAL_HW_CHK_NULL_NO_STATUS(_ptr)                                            \
78     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_HW, _ptr)
79 
80 //------------------------------------------------------------------------------
81 // Macros specific to MOS_VP_SUBCOMP_PUBLIC sub-comp
82 //------------------------------------------------------------------------------
83 #define VPHAL_PUBLIC_ASSERT(_expr)                                                   \
84     MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _expr)
85 
86 #define VPHAL_PUBLIC_ASSERTMESSAGE(_message, ...)                                    \
87     MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _message, ##__VA_ARGS__)
88 
89 #define VPHAL_PUBLIC_NORMALMESSAGE(_message, ...)                                    \
90     MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _message, ##__VA_ARGS__)
91 
92 #define VPHAL_PUBLIC_VERBOSEMESSAGE(_message, ...)                                   \
93     MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _message, ##__VA_ARGS__)
94 
95 #define VPHAL_PUBLIC_FUNCTION_ENTER                                                  \
96     MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC)
97 
98 #define VPHAL_PUBLIC_CHK_STATUS(_stmt)                                               \
99     MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _stmt)
100 
101 #define VPHAL_PUBLIC_CHK_STATUS_RETURN(_stmt)                                        \
102     MOS_CHK_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _stmt)
103 
104 #define VPHAL_PUBLIC_CHK_NULL(_ptr)                                                  \
105     MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _ptr)
106 
107 #define VPHAL_PUBLIC_CHK_NULL_NO_STATUS(_ptr)                                        \
108     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _ptr)
109 
110 #define VPHAL_PUBLIC_CHK_NULL_NO_STATUS_RETURN(_ptr)                                 \
111     MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, _ptr)
112 
113 //------------------------------------------------------------------------------
114 // Macros specific to MOS_VP_SUBCOMP_DEBUG sub-comp
115 //------------------------------------------------------------------------------
116 #define VPHAL_DEBUG_ASSERT(_expr)                                                    \
117     MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _expr)
118 
119 #define VPHAL_DEBUG_ASSERTMESSAGE(_message, ...)                                     \
120     MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _message, ##__VA_ARGS__)
121 
122 #define VPHAL_DEBUG_NORMALMESSAGE(_message, ...)                                     \
123     MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _message, ##__VA_ARGS__)
124 
125 #define VPHAL_DEBUG_VERBOSEMESSAGE(_message, ...)                                    \
126     MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _message, ##__VA_ARGS__)
127 
128 #define VPHAL_DEBUG_FUNCTION_ENTER                                                   \
129     MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG)
130 
131 #define VPHAL_DEBUG_FUNCTION_EXIT                                                    \
132     MOS_FUNCTION_EXIT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG)
133 
134 #define VPHAL_DEBUG_CHK_STATUS(_stmt)                                                \
135     MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _stmt)
136 
137 #define VPHAL_DEBUG_CHK_NULL(_ptr)                                                   \
138     MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _ptr)
139 
140 #define VPHAL_DEBUG_CHK_NULL_NO_STATUS(_ptr)                                         \
141     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DEBUG, _ptr)
142 
143 //------------------------------------------------------------------------------
144 // Macros specific to MOS_VP_SUBCOMP_RENDER sub-comp
145 //------------------------------------------------------------------------------
146 #define VPHAL_RENDER_ASSERT(_expr)                                                   \
147     MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _expr)
148 
149 #define VPHAL_RENDER_ASSERTMESSAGE(_message, ...)                                    \
150     MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
151 
152 #define VPHAL_RENDER_NORMALMESSAGE(_message, ...)                                    \
153     MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
154 
155 #define VPHAL_RENDER_VERBOSEMESSAGE(_message, ...)                                   \
156     MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
157 
158 #define VPHAL_RENDER_FUNCTION_ENTER                                                  \
159     MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER)
160 
161 #define VPHAL_RENDER_EXITMESSAGE(_message, ...)                                      \
162     MOS_DEBUGMESSAGE(MOS_MESSAGE_LVL_FUNCTION_EXIT, MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
163 
164 #define VPHAL_RENDER_CHK_STATUS(_stmt)                                               \
165     MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt)
166 
167 #define VPHAL_RENDER_CHK_STATUS_RETURN(_stmt)                                        \
168     MOS_CHK_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt)
169 
170 #define VPHAL_RENDER_CHK_STATUS_MESSAGE(_stmt, _message, ...)                        \
171     MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt, _message, ##__VA_ARGS__)
172 
173 #define VPHAL_RENDER_CHK_NULL(_ptr)                                                  \
174     MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
175 
176 #define VPHAL_RENDER_CHK_NULL_RETURN(_ptr)                                           \
177     MOS_CHK_NULL_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
178 
179 #define VPHAL_RENDER_CHK_NULL_NO_STATUS(_ptr)                                        \
180     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
181 //!
182 //! \def VPHAL_RENDER_CHK_NULL_NO_STATUS_RETURN(_ptr)
183 //!  MOS_ASSERTMESSAGE \a _ptr with MOS utility comp/subcomp info without returning a status
184 //!
185 #define VPHAL_RENDER_CHK_NULL_NO_STATUS_RETURN(_ptr)                                 \
186     MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
187 
188 //------------------------------------------------------------------------------
189 // Macros specific to MOS_VP_SUBCOMP_DDI sub-comp
190 //------------------------------------------------------------------------------
191 #define VP_DDI_ASSERT(_expr)                                                         \
192     MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _expr)
193 
194 #define VP_DDI_ASSERTMESSAGE(_message, ...)                                          \
195     MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _message, ##__VA_ARGS__)
196 
197 #define VP_DDI_NORMALMESSAGE(_message, ...)                                          \
198     MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _message, ##__VA_ARGS__)
199 
200 #define VP_DDI_VERBOSEMESSAGE(_message, ...)                                         \
201     MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _message, ##__VA_ARGS__)
202 
203 #define VP_DDI_FUNCTION_ENTER                                                        \
204     MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI)
205 
206 #define VP_DDI_CHK_STATUS(_stmt)                                                     \
207     MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _stmt)
208 
209 #define VP_DDI_CHK_STATUS_MESSAGE(_stmt, _message, ...)                              \
210     MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _stmt, _message, ##__VA_ARGS__)
211 
212 #define VP_DDI_CHK_NULL(_ptr)                                                        \
213     MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _ptr)
214 
215 #define VP_DDI_CHK_NULL_NO_STATUS(_ptr)                                              \
216     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _ptr)
217 
218 #define VPHAL_DDI_CHK_HR(_ptr)                                                       \
219     MOS_CHK_HR(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _ptr)
220 
221 #define VPHAL_DDI_CHK_NULL_WITH_HR(_ptr)                                             \
222     MOS_CHK_NULL_WITH_HR(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_DDI, _ptr)
223 
224 //!
225 //! \brief VPHAL SS/EU setting
226 //!
227 struct VphalSseuSetting
228 {
229     uint8_t   numSlices;
230     uint8_t   numSubSlices;
231     uint8_t   numEUs;
232     uint8_t   reserved;       // Place holder for frequency setting
233 };
234 
235 //!
236 //! \brief Gpu context entry
237 //!
238 struct VPHAL_GPU_CONTEXT_ENTRY
239 {
240     MOS_GPU_CONTEXT    gpuCtxForMos          = MOS_GPU_CONTEXT_MAX;
241     GPU_CONTEXT_HANDLE gpuContextHandle      = MOS_GPU_CONTEXT_INVALID_HANDLE;
242     void*              pGpuContext           = nullptr;
243 };
244 
245 //-----------------------------------------------------------------------------
246 // VPHAL-DDI RENDERING INTERFACE
247 //
248 //      Params that may apply to more than one layer are part of VPHAL_SURFACE
249 //      DDI layers must set this interface before calling pfnRender
250 //-----------------------------------------------------------------------------
251 //!
252 //! Structure VphalSettings
253 //! \brief VPHAL Settings - controls allocation of internal resources in VPHAL
254 //!
255 using VphalSettings =  VpSettings;
256 #pragma pack(push)
257 #pragma pack(1)
258 
259 #pragma pack(pop)
260 
261 
262 //!
263 //! Class VphalState
264 //! \brief VPHAL class definition
265 //!
266 class VphalState : public VpBase
267 {
268 public:
269     // Perf Optimize for ClearVideoView DDI
270     bool m_clearVideoViewMode = false;
271 
272     // factory function
273     static VphalState* VphalStateFactory(
274         PMOS_INTERFACE          pOsInterface,
275         PMOS_CONTEXT            pOsDriverContext,
276         MOS_STATUS              *peStatus);
277 
278     //!
279     //! \brief    VphalState Constructor
280     //! \details  Creates instance of VphalState
281     //!           - Caller must call Allocate to allocate all VPHAL states and objects.
282     //! \param    [in] pOsInterface
283     //!           OS interface, if provided externally - may be nullptr
284     //! \param    [in] pOsDriverContext
285     //!           OS driver context (UMD context, pShared, ...)
286     //! \param    [in,out] peStatus
287     //!           Pointer to the MOS_STATUS flag.
288     //!           Will assign this flag to MOS_STATUS_SUCCESS if successful, otherwise failed
289     //!
290     VphalState(
291         PMOS_INTERFACE          pOsInterface,
292         MOS_STATUS              *peStatus);
293 
294     //!
295     //! \brief    Copy constructor
296     //!
297     VphalState(const VphalState&) = delete;
298 
299     //!
300     //! \brief    Copy assignment operator
301     //!
302     VphalState& operator=(const VphalState&) = delete;
303 
304     //!
305     //! \brief    VphalState Destuctor
306     //! \details  Destroys VPHAL and all internal states and objects
307     //!
308     virtual ~VphalState();
309 
310     //!
311     //! \brief    Allocate VPHAL Resources
312     //! \details  Allocate VPHAL Resources
313     //!           - Allocate and initialize HW states
314     //!           - Allocate and initialize renderer states
315     //! \param    [in] pVpHalSettings
316     //!           Pointer to VPHAL Settings
317     //! \return   MOS_STATUS
318     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
319     //!
320     virtual MOS_STATUS Allocate(
321         const VphalSettings *pVpHalSettings) override;
322 
323     //!
324     //! \brief    Performs VP Rendering
325     //! \details  Performs VP Rendering
326     //!           - call default render of video
327     //! \param    [in] pcRenderParams
328     //!           Pointer to Render Params
329     //! \return   MOS_STATUS
330     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
331     //!
332     virtual MOS_STATUS Render(
333         PCVPHAL_RENDER_PARAMS pcRenderParams) override;
334 
335     //!
336     //! \brief    Get feature reporting from renderer
337     //! \details  Get feature reporting from renderer
338     //! \return   VphalFeatureReport*
339     //!           Pointer to VPHAL_FEATURE_REPOR: rendering features reported
340     //!
341     virtual VphalFeatureReport*       GetRenderFeatureReport() override;
342 
343     //!
344     //! \brief    Get Status Report
345     //! \details  Get Status Report, will return back to app indicating if related frame id is done by gpu
346     //! \param    [out] pQueryReport
347     //!           Pointer to pQueryReport, the status query report array.
348     //! \param    [in] wStatusNum
349     //!           The size of array pQueryReport.
350     //! \return   MOS_STATUS
351     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
352     virtual MOS_STATUS GetStatusReport(
353         PQUERY_STATUS_REPORT_APP        pQueryReport,
354         uint16_t                 numStatus) override;
355 
356     //!
357     //! \brief    Get Status Report's entry length from head to tail
358     //! \details  Get Status Report's entry length from head to tail
359     //! \param    [out] puiLength
360     //!           Pointer to the entry length
361     //! \return   MOS_STATUS
362     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
363     //!
364     virtual MOS_STATUS GetStatusReportEntryLength(
365         uint32_t                         *puiLength) override;
366 
GetPlatform()367     virtual PLATFORM &GetPlatform() override
368     {
369         return m_platform;
370     }
371 
GetSkuTable()372     virtual MEDIA_FEATURE_TABLE *GetSkuTable() override
373     {
374         return m_skuTable;
375     }
376 
GetWaTable()377     MEDIA_WA_TABLE* GetWaTable()
378     {
379         return m_waTable;
380     }
381 
GetOsInterface()382     virtual PMOS_INTERFACE GetOsInterface() override
383     {
384         return m_osInterface;
385     }
386 
GetRenderHal()387     virtual PRENDERHAL_INTERFACE GetRenderHal() override
388     {
389         return m_renderHal;
390     }
391 
GetVeboxInterface()392     PMHW_VEBOX_INTERFACE GetVeboxInterface()
393     {
394         return m_veboxInterface;
395     }
396 
GetCpInterface()397     MhwCpInterface* GetCpInterface()
398     {
399         return m_cpInterface;
400     }
401 
GetSfcInterface()402     PMHW_SFC_INTERFACE GetSfcInterface()
403     {
404         return m_sfcInterface;
405     }
406 
GetRenderer()407     VphalRenderer* GetRenderer()
408     {
409         return m_renderer;
410     }
411 
GetStatusTable()412     VPHAL_STATUS_TABLE& GetStatusTable()
413     {
414         return m_statusTable;
415     }
416 
SetMhwVeboxInterface(MhwVeboxInterface * veboxInterface)417     void SetMhwVeboxInterface(MhwVeboxInterface* veboxInterface)
418     {
419         if (veboxInterface == nullptr)
420         {
421             return;
422         }
423 
424         if (m_veboxInterface != nullptr)
425         {
426             m_veboxItf = std::static_pointer_cast<mhw::vebox::Itf>(m_veboxInterface->GetNewVeboxInterface());
427             MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
428 
429             if (m_veboxItf)
430             {
431                 eStatus = m_veboxItf->DestroyHeap();
432                 if (eStatus != MOS_STATUS_SUCCESS)
433                 {
434                     VPHAL_PUBLIC_ASSERTMESSAGE("Failed to destroy Vebox Interface, eStatus:%d.\n", eStatus);
435                 }
436             }
437 
438             eStatus = m_veboxInterface->DestroyHeap();
439             MOS_Delete(m_veboxInterface);
440             m_veboxInterface = nullptr;
441             if (eStatus != MOS_STATUS_SUCCESS)
442             {
443                 VPHAL_PUBLIC_ASSERTMESSAGE("Failed to destroy Vebox Interface, eStatus:%d.\n", eStatus);
444             }
445         }
446 
447         m_veboxInterface = veboxInterface;
448         m_veboxItf = std::static_pointer_cast<mhw::vebox::Itf>(veboxInterface->GetNewVeboxInterface());
449     }
450 
SetMhwSfcInterface(MhwSfcInterface * sfcInterface)451     void SetMhwSfcInterface(MhwSfcInterface* sfcInterface)
452     {
453         if (sfcInterface == nullptr)
454         {
455             return;
456         }
457 
458         if (m_sfcInterface != nullptr)
459         {
460             MOS_Delete(m_sfcInterface);
461             m_sfcInterface = nullptr;
462         }
463 
464         m_sfcInterface = sfcInterface;
465     }
466 
467     virtual MOS_STATUS GetVpMhwInterface(
468         VP_MHWINTERFACE &vpMhwinterface);
469 
470 protected:
471     // Internals
472     PLATFORM                    m_platform;
473     MEDIA_FEATURE_TABLE         *m_skuTable;
474     MEDIA_WA_TABLE              *m_waTable;
475 
476     // States
477     PMOS_INTERFACE              m_osInterface;
478     PRENDERHAL_INTERFACE_LEGACY m_renderHal;
479     PMHW_VEBOX_INTERFACE        m_veboxInterface;
480     MhwCpInterface              *m_cpInterface;
481     PMHW_SFC_INTERFACE          m_sfcInterface;
482     VphalRenderer               *m_renderer;
483     std::shared_ptr<mhw::vebox::Itf> m_veboxItf = nullptr;
484 
485     // Render GPU context/node
486     MOS_GPU_NODE                m_renderGpuNode;
487     MOS_GPU_CONTEXT             m_renderGpuContext;
488 
489     // StatusTable indicating if command is done by gpu or not
490     VPHAL_STATUS_TABLE          m_statusTable = {};
491 
492     MediaUserSettingSharedPtr   m_userSettingPtr = nullptr;  //!< usersettingInstance
493 
494     // Same MOS_GPU_CONTEXT may be created in MediaContext with a different handle,
495     // which will cause the gpuContext created in VphalState missed to be destroyed during
496     // m_osInterface being destroyed. m_gpuContextCheckList is used to store gpu contexts
497     // which may encounter such case.
498     std::vector<VPHAL_GPU_CONTEXT_ENTRY> m_gpuContextCheckList;
499 
500     //!
501     //! \brief    Create instance of VphalRenderer
502     //! \details  Create instance of VphalRenderer
503     //! \return   MOS_STATUS
504     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
505     //!
506     virtual MOS_STATUS CreateRenderer() = 0;
507 
IsApoEnabled()508     virtual bool IsApoEnabled() override
509     {
510         return false;
511     }
512 
IsRenderContextBasedSchedulingNeeded()513     virtual bool IsRenderContextBasedSchedulingNeeded()
514     {
515         return false;
516     }
517 
518 private:
519     //!
520     //! \brief    Put GPU context entry
521     //! \details  Put GPU context entry in the m_gpuContextCheckList
522     //! \param    MOS_GPU_CONTEXT mosGpuConext
523     //!           [in] Mos GPU context
524     //! \return   MOS_STATUS
525     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
526     //!
527     MOS_STATUS AddGpuContextToCheckList(
528         MOS_GPU_CONTEXT mosGpuConext);
529 
530     //!
531     //! \brief    Destroy GPU context entry with invalid handle
532     //! \details  Release these GPU context overwritten by MediaContext
533     //! \return   MOS_STATUS
534     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
535     //!
536     MOS_STATUS DestroyGpuContextWithInvalidHandle();
537 
538     //!
539     //! \brief    Check whether GPU context is reused or not
540     //! \details  Check whether GPU context is reused or not
541     //! \param    MOS_GPU_CONTEXT mosGpuConext
542     //!           [in] Mos GPU context
543     //! \return   bool
544     //!           Return true if is reused, otherwise false
545     //!
546     bool IsGpuContextReused(
547         MOS_GPU_CONTEXT mosGpuContext);
548 };
549 
550 #endif  // __VPHAL_H__
551