| 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_g8.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_g8.h" |
| 28 | #if defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE) |
| 29 | #include "igvpkrn_g8.h" |
| 30 | #endif |
| 31 | #include "vphal_render_vebox_g8_base.h" |
| 32 | #include "vphal_render_composite_g8.h" |
| 33 | #include "renderhal_g8.h" |
| 34 | |
| 35 | extern const Kdll_RuleEntry g_KdllRuleTable_g8[]; |
| 36 | |
| 37 | // Platform restriction on BDW: Check if the BDW SKU doesn't have EDRAM |
| 38 | // Currently on BDW, if the surface is to be cached in eLLC and |
| 39 | // the HW SKU doesn't have eLLC then it gets cached in LLC. |
| 40 | // That causes thrashing in LLC, |
| 41 | // so need to make such surfaces uncachable if eLLC/eDRAM is not present. |
| 42 | |
| 43 | #define VPHAL_SET_SURF_MEMOBJCTL_GEN8(VpField, GmmUsageEnum) \ |
| 44 | { \ |
| 45 | Usage = GmmUsageEnum; \ |
| 46 | MemObjCtrl = pOsInterface->pfnCachePolicyGetMemoryObject(Usage, pOsInterface->pfnGetGmmClientContext(pOsInterface)); \ |
| 47 | do \ |
| 48 | { \ |
| 49 | if (MemObjCtrl.Gen8.TargetCache == RENDERHAL_MO_TARGET_CACHE_ELLC_G8) \ |
| 50 | { \ |
| 51 | if (!MEDIA_IS_SKU(pSkuTable, FtrEDram)) \ |
| 52 | { \ |
| 53 | MemObjCtrl.Gen8.CacheControl = RENDERHAL_MO_CACHE_CONTROL_UC_G8; \ |
| 54 | } \ |
| 55 | } \ |
| 56 | } while(0); \ |
| 57 | \ |
| 58 | VpField = MemObjCtrl.DwordValue; \ |
| 59 | } |
| 60 | |
| 61 | void VphalRendererG8::GetCacheCntl( |
| 62 | PMOS_INTERFACE pOsInterface, |
| 63 | PLATFORM *pPlatform, |
| 64 | MEDIA_FEATURE_TABLE *pSkuTable, |
| 65 | PVPHAL_RENDER_CACHE_CNTL pSettings) |
| 66 | |
| 67 | { |
| 68 | MOS_HW_RESOURCE_DEF Usage; |
| 69 | MEMORY_OBJECT_CONTROL_STATE MemObjCtrl; |
| 70 | |
| 71 | if (pSettings->bCompositing) |
| 72 | { |
| 73 | pSettings->Composite.bL3CachingEnabled = true; |
| 74 | |
| 75 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->Composite.PrimaryInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 76 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->Composite.InputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_SurfaceState); |
| 77 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->Composite.TargetSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_DEFAULT); |
| 78 | } |
| 79 | if (pSettings->bDnDi) |
| 80 | { |
| 81 | pSettings->DnDi.bL3CachingEnabled = true; |
| 82 | |
| 83 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.CurrentInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_L3_SurfaceState); |
| 84 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.PreviousInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_L3_SurfaceState); |
| 85 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.STMMInputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_L3_SurfaceState); |
| 86 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.STMMOutputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_LLC_L3_SurfaceState); |
| 87 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.DnOutSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_LLC_L3_SurfaceState); |
| 88 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.CurrentOutputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_LLC_L3_SurfaceState); |
| 89 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.StatisticsOutputSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_No_LLC_L3_SurfaceState); |
| 90 | VPHAL_SET_SURF_MEMOBJCTL_GEN8(pSettings->DnDi.AlphaOrVignetteSurfMemObjCtl, MOS_MP_RESOURCE_USAGE_DEFAULT); |
| 91 | } |
| 92 | if (pSettings->bLace) |
| 93 | { |
| 94 | // No cache setting |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | MOS_STATUS VphalRendererG8::AllocateRenderComponents( |
| 99 | PMHW_VEBOX_INTERFACE pVeboxInterface, |
| 100 | PMHW_SFC_INTERFACE pSfcInterface) |
| 101 | { |
| 102 | MOS_STATUS eStatus; |
| 103 | VPHAL_RENDER_CACHE_CNTL CacheCntl; |
| 104 | |
| 105 | VPHAL_RENDER_CHK_NULL_RETURN(m_pRenderHal); |
| 106 | |
| 107 | eStatus = MOS_STATUS_SUCCESS; |
| 108 | |
| 109 | // Get the cache settings |
| 110 | MOS_ZeroMemory(&CacheCntl, sizeof(CacheCntl)); |
| 111 | |
| 112 | CacheCntl.bDnDi = true; |
| 113 | CacheCntl.bCompositing = true; |
| 114 | |
| 115 | VPHAL_RENDERER_GET_CACHE_CNTL(this, |
| 116 | m_pOsInterface, |
| 117 | &m_pRenderHal->Platform, |
| 118 | m_pSkuTable, |
| 119 | &CacheCntl); |
| 120 | |
| 121 | // Initialize Advanced Processing Interface |
| 122 | pRender[VPHAL_RENDER_ID_VEBOX] = MOS_New( |
| 123 | VPHAL_VEBOX_STATE_G8_BASE, |
| 124 | m_pOsInterface, |
| 125 | pVeboxInterface, |
| 126 | m_pRenderHal, |
| 127 | &VeboxExecState[0], |
| 128 | &PerfData, |
| 129 | CacheCntl.DnDi, |
| 130 | &eStatus); |
| 131 | if (!pRender[VPHAL_RENDER_ID_VEBOX] || |
| 132 | (eStatus != MOS_STATUS_SUCCESS)) |
| 133 | { |
| 134 | eStatus = MOS_STATUS_NO_SPACE; |
| 135 | VPHAL_RENDER_ASSERTMESSAGE("Allocate Vebox Render Fail."); |
| 136 | return eStatus; |
| 137 | } |
| 138 | |
| 139 | pRender[VPHAL_RENDER_ID_VEBOX2] = MOS_New( |
| 140 | VPHAL_VEBOX_STATE_G8_BASE, |
| 141 | m_pOsInterface, |
| 142 | pVeboxInterface, |
| 143 | m_pRenderHal, |
| 144 | &VeboxExecState[1], |
| 145 | &PerfData, |
| 146 | CacheCntl.DnDi, |
| 147 | &eStatus); |
| 148 | if (!pRender[VPHAL_RENDER_ID_VEBOX2] || |
| 149 | (eStatus != MOS_STATUS_SUCCESS)) |
| 150 | { |
| 151 | eStatus = MOS_STATUS_NO_SPACE; |
| 152 | VPHAL_RENDER_ASSERTMESSAGE("Allocate Vebox Render Fail."); |
| 153 | return eStatus; |
| 154 | } |
| 155 | |
| 156 | // Allocate Composite State |
| 157 | pRender[VPHAL_RENDER_ID_COMPOSITE] = MOS_New( |
| 158 | CompositeStateG8, |
| 159 | m_pOsInterface, |
| 160 | m_pRenderHal, |
| 161 | &PerfData, |
| 162 | CacheCntl.Composite, |
| 163 | &eStatus); |
| 164 | if (!pRender[VPHAL_RENDER_ID_COMPOSITE] || |
| 165 | (eStatus != MOS_STATUS_SUCCESS)) |
| 166 | { |
| 167 | eStatus = MOS_STATUS_NO_SPACE; |
| 168 | VPHAL_RENDER_ASSERTMESSAGE("Allocate Composite Render Fail."); |
| 169 | return eStatus; |
| 170 | } |
| 171 | |
| 172 | return eStatus; |
| 173 | } |
| 174 | |
| 175 | MOS_STATUS VphalRendererG8::InitKdllParam() |
| 176 | { |
| 177 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 178 | |
| 179 | // Set KDLL parameters (Platform dependent) |
| 180 | #if defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE) |
| 181 | pKernelDllRules = g_KdllRuleTable_g8; |
| 182 | pcKernelBin = (const void*)IGVPKRN_G8; |
| 183 | dwKernelBinSize = IGVPKRN_G8_SIZE; |
| 184 | #endif |
| 185 | |
| 186 | return eStatus; |
| 187 | } |