| 1 | /* |
| 2 | * Copyright (c) 2017-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_renderer_g12.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_g12.h" |
| 28 | #include "vphal_render_vebox_g12_base.h" |
| 29 | #include "vphal_render_composite_g12.h" |
| 30 | |
| 31 | // May need update the cache policy once GmmCachePolicyGen11.h is created |
| 32 | void VphalRendererG12::GetCacheCntl( |
| 33 | PMOS_INTERFACE pOsInterface, |
| 34 | PLATFORM *pPlatform, |
| 35 | MEDIA_FEATURE_TABLE *pSkuTable, |
| 36 | PVPHAL_RENDER_CACHE_CNTL pSettings) |
| 37 | |
| 38 | { |
| 39 | MOS_HW_RESOURCE_DEF Usage; |
| 40 | MEMORY_OBJECT_CONTROL_STATE MemObjCtrl; |
| 41 | |
| 42 | if (pSettings->bCompositing) |
| 43 | { |
| 44 | pSettings->Composite.bL3CachingEnabled = true; |
| 45 | |
| 46 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Composite.PrimaryInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 47 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Composite.InputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 48 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Composite.TargetSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_DEFAULT); |
| 49 | } |
| 50 | if (pSettings->bDnDi) |
| 51 | { |
| 52 | pSettings->DnDi.bL3CachingEnabled = true; |
| 53 | |
| 54 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.CurrentInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 55 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.PreviousInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 56 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.STMMInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 57 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.STMMOutputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 58 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.DnOutSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 59 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.CurrentOutputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 60 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.StatisticsOutputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 61 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.AlphaOrVignetteSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 62 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.LaceOrAceOrRgbHistogramSurfCtrl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 63 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.SkinScoreSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 64 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.LaceLookUpTablesSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 65 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->DnDi.Vebox3DLookUpTablesSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 66 | } |
| 67 | if (pSettings->bLace) |
| 68 | { |
| 69 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.FrameHistogramSurfaceMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 70 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.AggregatedHistogramSurfaceMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 71 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.StdStatisticsSurfaceMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 72 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.PwlfInSurfaceMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 73 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.PwlfOutSurfaceMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 74 | VPHAL_SET_SURF_MEMOBJCTL(pSettings->Lace.WeitCoefSurfaceMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | MOS_STATUS VphalRendererG12::AllocateRenderComponents( |
| 79 | PMHW_VEBOX_INTERFACE pVeboxInterface, |
| 80 | PMHW_SFC_INTERFACE pSfcInterface) |
| 81 | { |
| 82 | MOS_STATUS eStatus; |
| 83 | VPHAL_RENDER_CACHE_CNTL CacheCntl; |
| 84 | |
| 85 | VPHAL_RENDER_CHK_NULL_RETURN(m_pRenderHal); |
| 86 | |
| 87 | eStatus = MOS_STATUS_SUCCESS; |
| 88 | |
| 89 | // Get the cache settings |
| 90 | MOS_ZeroMemory(&CacheCntl, sizeof(CacheCntl)); |
| 91 | |
| 92 | CacheCntl.bDnDi = true; |
| 93 | CacheCntl.bCompositing = true; |
| 94 | |
| 95 | VPHAL_RENDERER_GET_CACHE_CNTL(this, |
| 96 | m_pOsInterface, |
| 97 | &m_pRenderHal->Platform, |
| 98 | m_pSkuTable, |
| 99 | &CacheCntl); |
| 100 | |
| 101 | // Initialize Advanced Processing Interface |
| 102 | pRender[VPHAL_RENDER_ID_VEBOX] = MOS_New( |
| 103 | VPHAL_VEBOX_STATE_G12_BASE, |
| 104 | m_pOsInterface, |
| 105 | pVeboxInterface, |
| 106 | pSfcInterface, |
| 107 | m_pRenderHal, |
| 108 | &VeboxExecState[0], |
| 109 | &PerfData, |
| 110 | CacheCntl.DnDi, |
| 111 | &eStatus); |
| 112 | if (!pRender[VPHAL_RENDER_ID_VEBOX] || |
| 113 | (eStatus != MOS_STATUS_SUCCESS)) |
| 114 | { |
| 115 | eStatus = MOS_STATUS_NO_SPACE; |
| 116 | VPHAL_RENDER_ASSERTMESSAGE("Allocate Vebox Render Fail."); |
| 117 | return eStatus; |
| 118 | } |
| 119 | |
| 120 | pRender[VPHAL_RENDER_ID_VEBOX2] = MOS_New( |
| 121 | VPHAL_VEBOX_STATE_G12_BASE, |
| 122 | m_pOsInterface, |
| 123 | pVeboxInterface, |
| 124 | pSfcInterface, |
| 125 | m_pRenderHal, |
| 126 | &VeboxExecState[1], |
| 127 | &PerfData, |
| 128 | CacheCntl.DnDi, |
| 129 | &eStatus); |
| 130 | if (!pRender[VPHAL_RENDER_ID_VEBOX2] || |
| 131 | (eStatus != MOS_STATUS_SUCCESS)) |
| 132 | { |
| 133 | eStatus = MOS_STATUS_NO_SPACE; |
| 134 | VPHAL_RENDER_ASSERTMESSAGE("Allocate Vebox Render Fail."); |
| 135 | return eStatus; |
| 136 | } |
| 137 | |
| 138 | // Allocate Composite State |
| 139 | pRender[VPHAL_RENDER_ID_COMPOSITE] = MOS_New( |
| 140 | CompositeStateG12, |
| 141 | m_pOsInterface, |
| 142 | m_pRenderHal, |
| 143 | &PerfData, |
| 144 | CacheCntl.Composite, |
| 145 | &eStatus); |
| 146 | if (!pRender[VPHAL_RENDER_ID_COMPOSITE] || |
| 147 | (eStatus != MOS_STATUS_SUCCESS)) |
| 148 | { |
| 149 | eStatus = MOS_STATUS_NO_SPACE; |
| 150 | VPHAL_RENDER_ASSERTMESSAGE("Allocate Composite Render Fail."); |
| 151 | return eStatus; |
| 152 | } |
| 153 | |
| 154 | return eStatus; |
| 155 | } |
| 156 | |
| 157 | //! |
| 158 | //! \brief Allocate surface |
| 159 | //! \details Allocate surface according to the attributes of surface except the specified width/height/format. |
| 160 | //! \param [in] RenderParams |
| 161 | //! VPHAL render parameter |
| 162 | //! \param [in] pSurface |
| 163 | //! Pointer to the surface which specifies the attributes except the specified width/height/format. |
| 164 | //! \param [in] pAllocatedSurface |
| 165 | //! Pointer to the allocated surface. |
| 166 | //! \param [in] dwSurfaceWidth |
| 167 | //! The width of allocated surface. |
| 168 | //! \param [in] dwSurfaceHeight |
| 169 | //! The height of allocated surface. |
| 170 | //! \param [in] eFormat |
| 171 | //! The format of allocated surface. |
| 172 | //! \return MOS_STATUS |
| 173 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 174 | //! |
| 175 | MOS_STATUS VphalRendererG12::AllocateSurface( |
| 176 | PCVPHAL_RENDER_PARAMS pcRenderParams, |
| 177 | PVPHAL_SURFACE pSurface, |
| 178 | PVPHAL_SURFACE pAllocatedSurface, |
| 179 | uint32_t dwSurfaceWidth, |
| 180 | uint32_t dwSurfaceHeight, |
| 181 | MOS_FORMAT eFormat) |
| 182 | { |
| 183 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 184 | bool bAllocated = false; |
| 185 | |
| 186 | VPHAL_RENDER_CHK_NULL(pcRenderParams); |
| 187 | VPHAL_RENDER_CHK_NULL(pSurface); |
| 188 | VPHAL_RENDER_CHK_NULL(pAllocatedSurface); |
| 189 | VPHAL_RENDER_CHK_NULL(m_pOsInterface); |
| 190 | |
| 191 | if ((dwSurfaceWidth == 0) || (dwSurfaceHeight == 0) || (eFormat == Format_Any)) |
| 192 | { |
| 193 | VPHAL_RENDER_ASSERTMESSAGE("Invalid width, height, format."); |
| 194 | eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 195 | goto finish; |
| 196 | } |
| 197 | |
| 198 | eStatus = VpHal_ReAllocateSurface( |
| 199 | m_pOsInterface, |
| 200 | pAllocatedSurface, |
| 201 | "RenderIntermediateSurface", |
| 202 | eFormat, |
| 203 | MOS_GFXRES_2D, |
| 204 | pSurface->TileType, |
| 205 | dwSurfaceWidth, |
| 206 | dwSurfaceHeight, |
| 207 | false, |
| 208 | MOS_MMC_DISABLED, |
| 209 | &bAllocated); |
| 210 | |
| 211 | if (MOS_SUCCEEDED(eStatus)) |
| 212 | { |
| 213 | pAllocatedSurface->SurfType = SURF_IN_PRIMARY; |
| 214 | pAllocatedSurface->SampleType = SAMPLE_PROGRESSIVE; |
| 215 | pAllocatedSurface->ColorSpace = pSurface->ColorSpace; |
| 216 | pAllocatedSurface->ExtendedGamut = pSurface->ExtendedGamut; |
| 217 | pAllocatedSurface->ScalingMode = pSurface->ScalingMode; |
| 218 | pAllocatedSurface->ScalingPreference = pSurface->ScalingPreference; |
| 219 | pAllocatedSurface->bIEF = false; |
| 220 | pAllocatedSurface->FrameID = pSurface->FrameID; |
| 221 | pAllocatedSurface->ChromaSiting = pSurface->ChromaSiting; |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | VPHAL_PUBLIC_ASSERTMESSAGE("Failed to create surface, eStatus: %d.\n", eStatus); |
| 226 | } |
| 227 | |
| 228 | finish: |
| 229 | return eStatus; |
| 230 | } |
| 231 |