| 1 | /* |
| 2 | * Copyright (c) 2017-2021, 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 renderhal_g11.h |
| 24 | //! \brief header file of Gen11 hardware functions |
| 25 | //! \details Gen11 hardware functions declare |
| 26 | //! |
| 27 | #ifndef __RENDERHAL_G11_H__ |
| 28 | #define __RENDERHAL_G11_H__ |
| 29 | |
| 30 | #include "renderhal_platform_interface_legacy.h" |
| 31 | #include "mhw_render_hwcmd_g11_X.h" |
| 32 | #include "mhw_state_heap_hwcmd_g11_X.h" |
| 33 | #include "mhw_render_g11_X.h" |
| 34 | |
| 35 | typedef struct _RENDERHAL_GENERIC_PROLOG_PARAMS_G11 : _RENDERHAL_GENERIC_PROLOG_PARAMS |
| 36 | { |
| 37 | MOS_VIRTUALENGINE_HINT_PARAMS VEngineHintParams = {{0}, 0, {{0},{0},{0},{0}}, {0,0,0,0}}; |
| 38 | }RENDERHAL_GENERIC_PROLOG_PARAMS_G11, *PRENDERHAL_GENERIC_PROLOG_PARAMS_G11; |
| 39 | |
| 40 | //! \brief for Gen11 VP and MDF |
| 41 | //! SLM URB DC RO Rest/L3 Client Pool |
| 42 | //! 0 64 0 0 320 (KB chunks based on GT2) |
| 43 | #define RENDERHAL_L3_CACHE_CONFIG_CNTLREG_VALUE_G11_RENDERHAL (0xA0000420) |
| 44 | |
| 45 | #define RENDERHAL_SAMPLERS_AVS_G11 6 |
| 46 | |
| 47 | class XRenderHal_Interface_g11 : public XRenderHal_Platform_Interface_Legacy |
| 48 | { |
| 49 | public: |
| 50 | XRenderHal_Interface_g11() {} |
| 51 | virtual ~XRenderHal_Interface_g11() {} |
| 52 | |
| 53 | //! |
| 54 | //! \brief Setup Surface State |
| 55 | //! \details Setup Surface States for Gen11 |
| 56 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 57 | //! [in] Pointer to Hardware Interface Structure |
| 58 | //! \param PRENDERHAL_SURFACE pRenderHalSurface |
| 59 | //! [in] Pointer to Render Hal Surface |
| 60 | //! \param PRENDERHAL_SURFACE_STATE_PARAMS pParams |
| 61 | //! [in] Pointer to Surface State Params |
| 62 | //! \param int32_t *piNumEntries |
| 63 | //! [out] Pointer to Number of Surface State Entries (Num Planes) |
| 64 | //! \param PRENDERHAL_SURFACE_STATE_ENTRY * ppSurfaceEntries |
| 65 | //! [out] Array of Surface State Entries |
| 66 | //! \param PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride |
| 67 | //! [in] If not nullptr, provides adjustments to Y, UV plane offsets, |
| 68 | //! used for kernel WA in a few cases. nullptr is the most common usage. |
| 69 | //! \return MOS_STATUS |
| 70 | //! |
| 71 | MOS_STATUS SetupSurfaceState( |
| 72 | PRENDERHAL_INTERFACE pRenderHal, |
| 73 | PRENDERHAL_SURFACE pRenderHalSurface, |
| 74 | PRENDERHAL_SURFACE_STATE_PARAMS pParams, |
| 75 | int32_t *piNumEntries, |
| 76 | PRENDERHAL_SURFACE_STATE_ENTRY *ppSurfaceEntries, |
| 77 | PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride); |
| 78 | |
| 79 | //! |
| 80 | //! \brief Check if Sampler128Elements is supported |
| 81 | //! \return true of false |
| 82 | //! |
| 83 | virtual inline bool IsSampler128ElementsSupported() { return true; } |
| 84 | |
| 85 | //! |
| 86 | //! \brief Checks how per thread scratch space size bits in VFE state are interpreted by HW |
| 87 | //! \details For BDW GT1/2/3 A0 steppings, per thread scratch space size in VFE state |
| 88 | //! is 11 bits indicating [2k bytes, 2 Mbytes]: 0=2k, 1=4k, 2=8k ... 10=2M |
| 89 | //! BDW+ excluding A0 step is 12 bits indicating [1k bytes, 2 Mbytes]: 0=1k, 1=2k, 2=4k, 3=8k ... 11=2M |
| 90 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 91 | //! [in] Pointer to RenderHal interface |
| 92 | //! \return true if BDW A0 stepping, false otherwise |
| 93 | //! |
| 94 | bool PerThreadScratchSpaceStart2K(PRENDERHAL_INTERFACE pRenderHal) |
| 95 | { |
| 96 | MOS_UNUSED(pRenderHal); |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | //! |
| 101 | //! \brief Encode SLM Size for Interface Descriptor |
| 102 | //! \details Setup SLM size |
| 103 | //! \param uint32_t SLMSize |
| 104 | //! [in] SLM size in 1K |
| 105 | //! \return encoded output |
| 106 | //! |
| 107 | uint32_t EncodeSLMSize(uint32_t SLMSize); |
| 108 | |
| 109 | //! |
| 110 | //! \brief Set Chroma Direction |
| 111 | //! \details Setup Chroma Direction for G11 |
| 112 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 113 | //! [in] Pointer to Hardware Interface |
| 114 | //! \param PRENDERHAL_SURFACE pRenderHalSurface |
| 115 | //! [in] Pointer to Render Hal Surface |
| 116 | //! \return uint8_t |
| 117 | //! |
| 118 | uint8_t SetChromaDirection( |
| 119 | PRENDERHAL_INTERFACE pRenderHal, |
| 120 | PRENDERHAL_SURFACE pRenderHalSurface); |
| 121 | |
| 122 | //! |
| 123 | //! \brief Convert To Nano Seconds |
| 124 | //! \details Convert to Nano Seconds |
| 125 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 126 | //! [in] Pointer to Hardware Interface Structure |
| 127 | //! \param uint64_t iTicks |
| 128 | //! [in] Ticks |
| 129 | //! \param uint64_t *piNs |
| 130 | //! [in] Nano Seconds |
| 131 | //! \return void |
| 132 | //! |
| 133 | void ConvertToNanoSeconds( |
| 134 | PRENDERHAL_INTERFACE pRenderHal, |
| 135 | uint64_t iTicks, |
| 136 | uint64_t *piNs); |
| 137 | |
| 138 | //! |
| 139 | //! \brief Initialize the State Heap Settings per platform |
| 140 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 141 | //! [out] Pointer to PRENDERHAL_INTERFACE |
| 142 | //! \return void |
| 143 | //! |
| 144 | void InitStateHeapSettings( |
| 145 | PRENDERHAL_INTERFACE pRenderHal); |
| 146 | |
| 147 | //! |
| 148 | //! \brief Initialize the default surface type and advanced surface type per platform |
| 149 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 150 | //! [out] Pointer to PRENDERHAL_INTERFACE |
| 151 | //! \return void |
| 152 | //! |
| 153 | void InitSurfaceTypes( |
| 154 | PRENDERHAL_INTERFACE pRenderHal); |
| 155 | |
| 156 | //! |
| 157 | //! \brief Check if YV12 Single Pass is supported |
| 158 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 159 | //! [in] Pointer to Hardware Interface |
| 160 | //! \return true of false |
| 161 | //! |
| 162 | inline bool IsEnableYV12SinglePass( |
| 163 | PRENDERHAL_INTERFACE pRenderHal) |
| 164 | { |
| 165 | MOS_UNUSED(pRenderHal); |
| 166 | return true; |
| 167 | } |
| 168 | |
| 169 | //! |
| 170 | //! \brief Get the Size of AVS Sampler State |
| 171 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 172 | //! [in] Pointer to Hardware Interface |
| 173 | //! \return size |
| 174 | //! |
| 175 | inline uint32_t GetSizeSamplerStateAvs( |
| 176 | PRENDERHAL_INTERFACE pRenderHal) |
| 177 | { |
| 178 | return 2 * pRenderHal->pHwSizes->dwSizeSamplerStateAvs; // Kernel using 1,3,5 sampler index for AVS sampler state. |
| 179 | } |
| 180 | |
| 181 | //! |
| 182 | //! \brief Enables L3 cacheing flag and sets related registers/values |
| 183 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 184 | //! [in] Pointer to Hardware Interface |
| 185 | //! \param pCacheSettings |
| 186 | //! [in] L3 Cache Configurations |
| 187 | //! \return MOS_STATUS |
| 188 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 189 | //! |
| 190 | virtual MOS_STATUS EnableL3Caching( |
| 191 | PRENDERHAL_INTERFACE pRenderHal, |
| 192 | PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings); |
| 193 | |
| 194 | //! |
| 195 | //! \brief Get offset and/or pointer to sampler state |
| 196 | //! \details Get offset and/or pointer to sampler state in General State Heap |
| 197 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 198 | //! [in] Pointer to RenderHal Interface |
| 199 | //! \param int32_t iMediaID |
| 200 | //! [in] Media ID associated with sampler |
| 201 | //! \param int32_t iSamplerID |
| 202 | //! [in] Sampler ID |
| 203 | //! \param uint32_t *pdwSamplerOffset |
| 204 | //! [out] optional; offset of sampler state from GSH base |
| 205 | //! \param void **ppSampler |
| 206 | //! [out] optional; pointer to sampler state in GSH |
| 207 | //! \return MOS_STATUS |
| 208 | //! |
| 209 | virtual MOS_STATUS GetSamplerOffsetAndPtr_DSH( |
| 210 | PRENDERHAL_INTERFACE pRenderHal, |
| 211 | int32_t iMediaID, |
| 212 | int32_t iSamplerID, |
| 213 | PMHW_SAMPLER_STATE_PARAM pSamplerParams, |
| 214 | uint32_t *pdwSamplerOffset, |
| 215 | void **ppSampler); |
| 216 | |
| 217 | //! |
| 218 | //! \brief Initialize the DSH Settings |
| 219 | //! \details Initialize the structure DynamicHeapSettings in pRenderHal |
| 220 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 221 | //! [in] Pointer to HW interface |
| 222 | //! \return void |
| 223 | //! |
| 224 | virtual void InitDynamicHeapSettings( |
| 225 | PRENDERHAL_INTERFACE pRenderHal); |
| 226 | |
| 227 | //! |
| 228 | //! \brief Get the pointer to the MHW_VFE_PARAMS |
| 229 | //! \return MHW_VFE_PARAMS* |
| 230 | //! pointer to the MHW_VFE_PARAMS |
| 231 | //! |
| 232 | virtual MHW_VFE_PARAMS* GetVfeStateParameters() { return &m_vfeStateParams; } |
| 233 | |
| 234 | //! |
| 235 | //! \brief Set Power Option Status |
| 236 | //! \param [in] pRenderHal |
| 237 | //! Pointer to Hardware Interface |
| 238 | //! \param [in,out] pCmdBuffer |
| 239 | //! Pointer to Command Buffer |
| 240 | //! \return MOS_STATUS |
| 241 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 242 | //! |
| 243 | virtual MOS_STATUS SetPowerOptionStatus( |
| 244 | PRENDERHAL_INTERFACE pRenderHal, |
| 245 | PMOS_COMMAND_BUFFER pCmdBuffer); |
| 246 | |
| 247 | //! |
| 248 | //! \brief Check if Override is needed or not |
| 249 | //! \param [in] pRenderHal |
| 250 | //! Pointer to Hardware Interface |
| 251 | //! \param [in,out] pCmdBuffer |
| 252 | //! Pointer to Command Buffer |
| 253 | //! \param [in] pGenericPrologParam |
| 254 | //! Pointer to MHW generic prolog parameters |
| 255 | //! \return MOS_STATUS |
| 256 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 257 | //! |
| 258 | virtual MOS_STATUS IsOvrdNeeded( |
| 259 | PRENDERHAL_INTERFACE pRenderHal, |
| 260 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 261 | PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams); |
| 262 | |
| 263 | //! \brief Set L3 cache override config parameters |
| 264 | //! \param [in] pRenderHal |
| 265 | //! Pointer to RenderHal Interface Structure |
| 266 | //! \param [in,out] pCacheSettings |
| 267 | //! Pointer to pCacheSettings |
| 268 | //! \param [in] bEnableSLM |
| 269 | //! Flag to enable SLM |
| 270 | //! \return MOS_STATUS |
| 271 | //! MOS_STATUS_SUCCESS if success. Error code otherwise |
| 272 | //! |
| 273 | virtual MOS_STATUS SetCacheOverrideParams( |
| 274 | PRENDERHAL_INTERFACE pRenderHal, |
| 275 | PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings, |
| 276 | bool bEnableSLM); |
| 277 | |
| 278 | //! \brief Get the size of Render Surface State Command |
| 279 | //! \return size_t |
| 280 | //! the size of render surface state command |
| 281 | virtual size_t GetSurfaceStateCmdSize(); |
| 282 | |
| 283 | //! \brief Get the address of the ith Palette Data |
| 284 | //! \param [in] i |
| 285 | //! Index of the palette data |
| 286 | //! \return void * |
| 287 | //! address of the ith palette data table |
| 288 | virtual void* GetPaletteDataAddress(int i) {return &m_paletteData[i];} |
| 289 | |
| 290 | //! \brief Get the size of Binding Table State Command |
| 291 | //! \return size_t |
| 292 | //! the size of binding table state command |
| 293 | virtual size_t GetBTStateCmdSize() {return mhw_state_heap_g11_X::BINDING_TABLE_STATE_CMD::byteSize;} |
| 294 | |
| 295 | //! \brief Check if compute context in use |
| 296 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 297 | //! [in] Pointer to Hardware Interface |
| 298 | //! \return true of false |
| 299 | virtual bool IsComputeContextInUse(PRENDERHAL_INTERFACE pRenderHal) |
| 300 | { |
| 301 | MOS_UNUSED(pRenderHal); |
| 302 | return false; |
| 303 | } |
| 304 | |
| 305 | virtual uint32_t GetGrfSize() override |
| 306 | { |
| 307 | return 32; |
| 308 | } |
| 309 | |
| 310 | protected: |
| 311 | MHW_VFE_PARAMS m_vfeStateParams; |
| 312 | mhw_render_g11_X::PALETTE_ENTRY_CMD |
| 313 | m_paletteData[RENDERHAL_PALETTE_MAX][RENDERHAL_PALETTE_ENTRIES_MAX]; |
| 314 | }; |
| 315 | |
| 316 | #endif // __RENDERHAL_G11_H__ |