1 /* 2 * Copyright (c) 2016-2020, 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_render_renderstate.h 24 //! \brief VPHAL RenderState class definition 25 //! \details RenderState class defines the interface of render components 26 //! 27 #ifndef __VPHAL_RENDER_RENDERSTATE_H__ 28 #define __VPHAL_RENDER_RENDERSTATE_H__ 29 30 #include "vphal.h" 31 #include "vphal_render_common.h" 32 #include "hal_kerneldll.h" 33 34 //! 35 //! class RenderpassData 36 //! \brief transient data used in single render pass 37 //! 38 class RenderpassData 39 { 40 public: 41 bool bCompNeeded; 42 bool bHdrNeeded; 43 44 uint32_t uiSrcIndex; 45 PVPHAL_SURFACE pSrcSurface; // pSrcSurface points to the original input surface 46 // or the output from previous render 47 PVPHAL_SURFACE pOutSurface; // pOutSurface points to the output surface 48 bool bOutputGenerated; 49 bool b2CSCNeeded; 50 PVPHAL_SURFACE pOriginalSrcSurface; // Pointer to original source surface that is not adv proc'd 51 uint32_t uiPrimaryIndex; 52 PVPHAL_SURFACE pPrimarySurface; // Null of no primary passed by app. 53 54 static const uint32_t TempSurfaceAmount = 2; 55 bool bSFCScalingOnly = false; // whehter use SFC replace AVS do scaling. 56 RenderpassData()57 RenderpassData() : 58 bCompNeeded(false), 59 bHdrNeeded(false), 60 uiSrcIndex(0), 61 pSrcSurface(nullptr), 62 pOutSurface(nullptr), 63 bOutputGenerated(false), 64 b2CSCNeeded(false), 65 pOriginalSrcSurface(nullptr), 66 uiPrimaryIndex(0), 67 pPrimarySurface(nullptr), 68 uiOutSurfaceIndex(0), 69 TempOutputSurfaces() 70 { 71 } 72 ~RenderpassData()73 virtual ~RenderpassData() 74 { 75 for (uint32_t i = 0; i < TempSurfaceAmount; i++) 76 { 77 MOS_FreeMemAndSetNull(TempOutputSurfaces[i]); 78 } 79 } 80 AllocateTempOutputSurfaces()81 virtual MOS_STATUS AllocateTempOutputSurfaces() 82 { 83 for (uint32_t i = 0 ; i < TempSurfaceAmount; i++ ) 84 { 85 // only allocate if it is null 86 if (TempOutputSurfaces[i] == nullptr) 87 { 88 TempOutputSurfaces[i] = (PVPHAL_SURFACE)MOS_AllocAndZeroMemory(sizeof(VPHAL_SURFACE)); 89 90 // if allocation failed 91 if(TempOutputSurfaces[i] == nullptr) 92 { 93 // free all allocated surfaces 94 while (i > 0) 95 { 96 --i; 97 MOS_FreeMemAndSetNull(TempOutputSurfaces[i]); 98 } 99 return MOS_STATUS_NO_SPACE; 100 } 101 } 102 } 103 return MOS_STATUS_SUCCESS; 104 } 105 GetTempOutputSurface()106 PVPHAL_SURFACE GetTempOutputSurface() 107 { 108 return TempOutputSurfaces[uiOutSurfaceIndex]; 109 } 110 MoveToNextTempOutputSurface()111 void MoveToNextTempOutputSurface() 112 { 113 uiOutSurfaceIndex++; 114 uiOutSurfaceIndex %= TempSurfaceAmount; 115 } 116 117 protected: 118 uint32_t uiOutSurfaceIndex; 119 PVPHAL_SURFACE TempOutputSurfaces[TempSurfaceAmount]; 120 121 }; 122 123 //! 124 //! Class RenderState 125 //! \brief abstract the interface of VP render components 126 //! 127 class RenderState 128 { 129 public: 130 //! 131 //! \brief RenderState Constructor 132 //! \details Construct RenderState and allocate member data structure 133 //! \param [in] pOsInterface 134 //! Pointer to MOS interface structure 135 //! \param [in] pRenderHal 136 //! Pointer to RenderHal interface structure 137 //! \param [in] pPerfData 138 //! Pointer to performance data structure 139 //! \param [out] peStatus 140 //! Pointer to MOS status 141 //! 142 RenderState( 143 PMOS_INTERFACE pOsInterface, 144 PRENDERHAL_INTERFACE pRenderHal, 145 PVPHAL_RNDR_PERF_DATA pPerfData, 146 MOS_STATUS *peStatus); 147 148 //! 149 //! \brief Copy constructor 150 //! 151 RenderState(const RenderState&) = delete; 152 153 //! 154 //! \brief Copy assignment operator 155 //! 156 RenderState& operator=(const RenderState&) = delete; 157 158 //! 159 //! \brief RenderState Destructor 160 //! \details Destroy RenderState and release all related RenderState resources 161 //! ~RenderState()162 virtual ~RenderState() { 163 MOS_Delete(m_reporting); 164 }; 165 166 //! 167 //! \brief Initialize RenderState 168 //! \param [in] pSettings 169 //! Pointer to VPHAL Settings 170 //! \param [in] pKernelDllState 171 //! Pointer to KernelDLL State 172 //! \return MOS_STATUS 173 //! Return MOS_STATUS_SUCCESS if successful 174 //! 175 virtual MOS_STATUS Initialize( 176 const VphalSettings *pSettings, 177 Kdll_State *pKernelDllState) = 0; 178 179 //! 180 //! \brief RenderState Destroy 181 //! \details Destroy resource allocated by Render 182 //! Destroy()183 virtual void Destroy() 184 { 185 }; 186 187 //! 188 //! \brief RenderState Rendering 189 //! \details VPHal RenderState entry 190 //! \param [in] pcRenderParams 191 //! Pointer to Render parameters 192 //! \param [in,out] pRenderPassData 193 //! Pointer to Render data 194 //! \return MOS_STATUS 195 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 196 //! 197 virtual MOS_STATUS Render( 198 PCVPHAL_RENDER_PARAMS pcRenderParams, 199 RenderpassData *pRenderPassData) = 0; 200 201 //! 202 //! \brief Judge if render is needed 203 //! \details Check Render parameter/data if render needed 204 //! \param [in] pcRenderParams 205 //! Pointer to Render parameters 206 //! \param [in,out] pRenderPassData 207 //! Pointer to Render data 208 //! \return bool 209 //! true if meeded. Else false 210 //! 211 virtual bool IsNeeded( 212 PCVPHAL_RENDER_PARAMS pcRenderParams, 213 RenderpassData *pRenderPassData) = 0; 214 215 //! 216 //! \brief Judge if render support multiple stream rendering 217 //! \details Judge if render support multiple stream rendering 218 //! \return bool 219 //! true if supported. Else false 220 //! 221 virtual bool IsMultipleStreamSupported() = 0; 222 223 //! 224 //! \brief Set Slice Shutdown Mode 225 //! \param [in] bSingleSlice 226 //! value of Slice Shutdown Mode 227 //! \return void 228 //! SetSingleSliceMode(bool bSingleSlice)229 void SetSingleSliceMode( 230 bool bSingleSlice) 231 { 232 m_bSingleSlice = bSingleSlice; 233 } 234 235 //! 236 //! \brief get Performace data 237 //! \details get Performace data used by this render 238 //! \return PVPHAL_RNDR_PERF_DATA 239 //! Performace data used by this render 240 //! GetPerfData()241 PVPHAL_RNDR_PERF_DATA GetPerfData() 242 { 243 return m_pPerfData; 244 } 245 246 //! 247 //! \brief copy Report data 248 //! \details copy Report data from this render 249 //! \param [out] pReporting 250 //! pointer to the Report data to copy data to 251 //! CopyReporting(VphalFeatureReport * pReporting)252 virtual void CopyReporting(VphalFeatureReport* pReporting) 253 { 254 } 255 256 //! 257 //! \brief get Sku table 258 //! \details get Sku table from this render 259 //! \return MEDIA_FEATURE_TABLE * 260 //! Sku table pointer 261 //! GetSkuTable()262 MEDIA_FEATURE_TABLE *GetSkuTable() 263 { 264 return m_pSkuTable; 265 } 266 267 //! 268 //! \brief get RenderHal interface pointer 269 //! \details get RenderHal interface pointer from this render 270 //! \return PRENDERHAL_INTERFACE 271 //! RenderHal pointer 272 //! GetRenderHalInterface()273 PRENDERHAL_INTERFACE GetRenderHalInterface() 274 { 275 return m_pRenderHal; 276 } 277 278 //! 279 //! \brief get OS interface pointer 280 //! \details get OS interface pointer from this render 281 //! \return PRENDERHAL_INTERFACE 282 //! RenderHal pointer 283 //! GetOsInterface()284 PMOS_INTERFACE GetOsInterface() 285 { 286 return m_pOsInterface; 287 } 288 289 //! 290 //! \brief Set status report parameters 291 //! \param [in] pRenderer 292 //! pointer to the renderer 293 //! \param [in] pRenderParams 294 //! pointer to the render parameters 295 //! 296 void SetStatusReportParams( 297 VphalRenderer *pRenderer, 298 PVPHAL_RENDER_PARAMS pRenderParams); 299 300 //! 301 //! \brief Get render disable flag 302 //! \details Get render disable flag 303 //! \return bool 304 //! return true if Render is disabled, 305 //! return false otherwise. 306 //! GetRenderDisableFlag()307 bool GetRenderDisableFlag() 308 { 309 return m_bDisableRender; 310 }; 311 312 //! 313 //! \brief Set render disable flag 314 //! \param [in] bDisable 315 //! The diable flag. If parameter is true, it will disable render. 316 //! SetRenderDisableFlag(bool bDisable)317 void SetRenderDisableFlag(bool bDisable) 318 { 319 m_bDisableRender = bDisable; 320 }; 321 322 // External components 323 PMOS_INTERFACE m_pOsInterface; 324 PRENDERHAL_INTERFACE_LEGACY m_pRenderHal; 325 326 protected: 327 // External tables 328 MEDIA_FEATURE_TABLE *m_pSkuTable; 329 MEDIA_WA_TABLE *m_pWaTable; 330 331 // Disable Render flag 332 bool m_bDisableRender; 333 334 // Slice Shutdown flag 335 bool m_bSingleSlice; 336 337 // Performance Related item 338 PVPHAL_RNDR_PERF_DATA m_pPerfData; 339 340 // Feature reporting 341 VphalFeatureReport *m_reporting; 342 343 // Status Buffer, Video Pre-Processing Only 344 STATUS_TABLE_UPDATE_PARAMS m_StatusTableUpdateParams = { 0 }; 345 346 // Media user setting instance 347 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; 348 349 }; 350 351 #endif // __VPHAL_RENDER_RENDERSTATE_H__ 352