1 /*
2 * Copyright (c) 2017, 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_g10.cpp
24 //! \brief    VPHAL top level rendering component and the entry to low level renderers
25 //! \details  The top renderer is responsible for coordinating the sequence of calls to low level renderers, e.g. DNDI or Comp
26 //!
27 #include "vphal_renderer_g10.h"
28 #if defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
29 #include "igvpkrn_g10.h"
30 #endif
31 #include "vphal_render_vebox_g10_base.h"
32 #include "vphal_render_composite_g10.h"
33 
34 extern const Kdll_RuleEntry         g_KdllRuleTable_g10[];
35 
GetCacheCntl(PMOS_INTERFACE pOsInterface,PLATFORM * pPlatform,MEDIA_FEATURE_TABLE * pSkuTable,PVPHAL_RENDER_CACHE_CNTL pSettings)36 void VphalRendererG10::GetCacheCntl(
37     PMOS_INTERFACE                      pOsInterface,
38     PLATFORM                            *pPlatform,
39     MEDIA_FEATURE_TABLE                 *pSkuTable,
40     PVPHAL_RENDER_CACHE_CNTL            pSettings)
41 {
42     MOS_HW_RESOURCE_DEF                 Usage;
43     MEMORY_OBJECT_CONTROL_STATE         MemObjCtrl;
44 
45     if (pSettings->bCompositing)
46     {
47         pSettings->Composite.bL3CachingEnabled = true;
48 
49         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Composite.PrimaryInputSurfMemObjCtl,   MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
50         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Composite.InputSurfMemObjCtl,          MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
51         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Composite.TargetSurfMemObjCtl,         MOS_MP_RESOURCE_USAGE_DEFAULT);
52     }
53     if (pSettings->bDnDi)
54     {
55         pSettings->DnDi.bL3CachingEnabled = true;
56 
57         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.CurrentInputSurfMemObjCtl,        MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
58         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.PreviousInputSurfMemObjCtl,       MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
59         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.STMMInputSurfMemObjCtl,           MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
60         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.STMMOutputSurfMemObjCtl,          MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
61         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.DnOutSurfMemObjCtl,               MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
62         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.CurrentOutputSurfMemObjCtl,       MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
63         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.StatisticsOutputSurfMemObjCtl,    MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
64         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.AlphaOrVignetteSurfMemObjCtl,     MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
65         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.LaceOrAceOrRgbHistogramSurfCtrl,  MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
66         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.SkinScoreSurfMemObjCtl,           MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
67         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.LaceLookUpTablesSurfMemObjCtl,    MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
68         VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.Vebox3DLookUpTablesSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
69     }
70     if (pSettings->bLace)
71     {
72         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.FrameHistogramSurfaceMemObjCtl,                       MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
73         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.AggregatedHistogramSurfaceMemObjCtl,                  MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
74         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.StdStatisticsSurfaceMemObjCtl,                        MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
75         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.PwlfInSurfaceMemObjCtl,                               MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
76         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.PwlfOutSurfaceMemObjCtl,                              MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
77         VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.WeitCoefSurfaceMemObjCtl,                             MOS_MP_RESOURCE_USAGE_AGE3_SurfaceState);
78     }
79 }
80 
AllocateRenderComponents(PMHW_VEBOX_INTERFACE pVeboxInterface,PMHW_SFC_INTERFACE pSfcInterface)81 MOS_STATUS VphalRendererG10::AllocateRenderComponents(
82     PMHW_VEBOX_INTERFACE                pVeboxInterface,
83     PMHW_SFC_INTERFACE                  pSfcInterface)
84 {
85     MOS_STATUS              eStatus;
86     PMHW_SFC_INTERFACE      pParamSfcInterface;
87     VPHAL_RENDER_CACHE_CNTL CacheCntl;
88 
89     VPHAL_RENDER_CHK_NULL_RETURN(m_pRenderHal);
90 
91     eStatus = MOS_STATUS_SUCCESS;
92 
93 #if __VPHAL_SFC_SUPPORTED
94     pParamSfcInterface = pSfcInterface;
95 #else
96     // Disable SFC SKU as it is not supported in this build
97     MEDIA_WR_SKU(m_pRenderHal->pSkuTable, FtrSFCPipe, 0);
98     pParamSfcInterface = nullptr;
99 #endif
100 
101     // Get the cache settings
102     MOS_ZeroMemory(&CacheCntl, sizeof(CacheCntl));
103 
104     CacheCntl.bDnDi        = true;
105     CacheCntl.bCompositing = true;
106     CacheCntl.bLace        = MEDIA_IS_SKU(m_pSkuTable, FtrLace);
107 
108     VPHAL_RENDERER_GET_CACHE_CNTL(this,
109         m_pOsInterface,
110         &m_pRenderHal->Platform,
111         m_pSkuTable,
112         &CacheCntl);
113 
114     // Initialize Advanced Processing Interface
115     pRender[VPHAL_RENDER_ID_VEBOX] = MOS_New(
116         VPHAL_VEBOX_STATE_G10_BASE,
117         m_pOsInterface,
118         pVeboxInterface,
119         pParamSfcInterface,
120         m_pRenderHal,
121         &VeboxExecState[0],
122         &PerfData,
123         CacheCntl.DnDi,
124         &eStatus);
125     if (!pRender[VPHAL_RENDER_ID_VEBOX] ||
126         (eStatus != MOS_STATUS_SUCCESS))
127     {
128         eStatus = MOS_STATUS_NO_SPACE;
129         VPHAL_RENDER_ASSERTMESSAGE("Allocate Vebox Render Fail.");
130         return eStatus;
131     }
132 
133     pRender[VPHAL_RENDER_ID_VEBOX2] = MOS_New(
134         VPHAL_VEBOX_STATE_G10_BASE,
135         m_pOsInterface,
136         pVeboxInterface,
137         pParamSfcInterface,
138         m_pRenderHal,
139         &VeboxExecState[1],
140         &PerfData,
141         CacheCntl.DnDi,
142         &eStatus);
143     if (!pRender[VPHAL_RENDER_ID_VEBOX2] ||
144         (eStatus != MOS_STATUS_SUCCESS))
145     {
146         eStatus = MOS_STATUS_NO_SPACE;
147         VPHAL_RENDER_ASSERTMESSAGE("Allocate Vebox Render Fail.");
148         return eStatus;
149     }
150 
151     // Allocate Composite State
152     pRender[VPHAL_RENDER_ID_COMPOSITE] = MOS_New(
153         CompositeStateG10,
154         m_pOsInterface,
155         m_pRenderHal,
156         &PerfData,
157         CacheCntl.Composite,
158         &eStatus);
159     if (!pRender[VPHAL_RENDER_ID_COMPOSITE] ||
160         (eStatus != MOS_STATUS_SUCCESS))
161     {
162         eStatus = MOS_STATUS_NO_SPACE;
163         VPHAL_RENDER_ASSERTMESSAGE("Allocate Composite Render Fail.");
164         return eStatus;
165     }
166     return eStatus;
167 }
168 
InitKdllParam()169 MOS_STATUS VphalRendererG10::InitKdllParam()
170 {
171     MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
172 
173     // Set KDLL parameters (Platform dependent)
174 #if defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
175     pKernelDllRules         = g_KdllRuleTable_g10;
176     pcKernelBin             = (const void*)IGVPKRN_G10;
177     dwKernelBinSize         = IGVPKRN_G10_SIZE;
178 #endif
179     return eStatus;
180 }
181 
182