| 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_g12_base.cpp |
| 24 | //! \brief implementation of Gen12 hardware functions |
| 25 | //! \details Render functions |
| 26 | //! |
| 27 | |
| 28 | #include "renderhal_legacy.h" |
| 29 | #include "renderhal_g12_base.h" |
| 30 | #include "mhw_mi_g12_X.h" |
| 31 | #include "media_common_defs.h" |
| 32 | #include "media_skuwa_specific.h" |
| 33 | #include "mhw_mi.h" |
| 34 | #include "mhw_render.h" |
| 35 | #include "mhw_state_heap_g12.h" |
| 36 | #include "mhw_utilities_next.h" |
| 37 | #include "mos_defs_specific.h" |
| 38 | #include "mos_os.h" |
| 39 | #include "mos_os_hw.h" |
| 40 | #include "mos_utilities.h" |
| 41 | #include "mos_utilities_common.h" |
| 42 | #include "renderhal_dsh.h" |
| 43 | |
| 44 | //! |
| 45 | //! \brief GSH settings for G12 |
| 46 | //! |
| 47 | #define RENDERHAL_SAMPLERS_AVS_G12 6 |
| 48 | |
| 49 | extern const RENDERHAL_STATE_HEAP_SETTINGS g_cRenderHal_State_Heap_Settings_g12 = |
| 50 | { |
| 51 | // Global GSH Allocation parameters |
| 52 | RENDERHAL_SYNC_SIZE, //!< iSyncSize |
| 53 | |
| 54 | // Media State Allocation parameters |
| 55 | RENDERHAL_MEDIA_STATES, //!< iMediaStateHeaps - Set by Initialize |
| 56 | RENDERHAL_MEDIA_IDS, //!< iMediaIDs |
| 57 | RENDERHAL_CURBE_SIZE, //!< iCurbeSize |
| 58 | RENDERHAL_SAMPLERS, //!< iSamplers |
| 59 | RENDERHAL_SAMPLERS_AVS_G12, //!< iSamplersAVS |
| 60 | RENDERHAL_SAMPLERS_VA, //!< iSamplersVA |
| 61 | RENDERHAL_KERNEL_COUNT, //!< iKernelCount |
| 62 | RENDERHAL_KERNEL_HEAP, //!< iKernelHeapSize |
| 63 | RENDERHAL_KERNEL_BLOCK_SIZE, //!< iKernelBlockSize |
| 64 | |
| 65 | // Media VFE/ID configuration, limits |
| 66 | 0, //!< iPerThreadScratchSize |
| 67 | RENDERHAL_MAX_SIP_SIZE, //!< iSipSize |
| 68 | |
| 69 | // Surface State Heap Settings |
| 70 | RENDERHAL_SSH_INSTANCES, //!< iSurfaceStateHeaps |
| 71 | RENDERHAL_SSH_BINDING_TABLES, //!< iBindingTables |
| 72 | RENDERHAL_SSH_SURFACE_STATES, //!< iSurfaceStates |
| 73 | RENDERHAL_SSH_SURFACES_PER_BT, //!< iSurfacesPerBT |
| 74 | RENDERHAL_SSH_BINDING_TABLE_ALIGN, //!< iBTAlignment |
| 75 | MOS_CODEC_RESOURCE_USAGE_BEGIN_CODEC //!< heapUsageType |
| 76 | }; |
| 77 | |
| 78 | const uint32_t g_cLookup_RotationMode_g12[8] = |
| 79 | { |
| 80 | ROTATION_IDENTITY, // 0 - MHW_ROTATION_IDENTITY |
| 81 | ROTATION_90, // 1 - MHW_ROTATION_90 |
| 82 | ROTATION_180, // 2 - MHW_ROTATION_180 |
| 83 | ROTATION_270, // 3 - MHW_ROTATION_270 |
| 84 | ROTATION_IDENTITY, // 4 - MHW_MIRROR_HORIZONTAL |
| 85 | ROTATION_180, // 5 - MHW_MIRROR_VERTICAL |
| 86 | ROTATION_270, // 6 - MHW_ROTATE_90_MIRROR_VERTICAL |
| 87 | ROTATION_90 // 7 - MHW_ROTATE_90_MIRROR_HORIZONTAL |
| 88 | }; |
| 89 | |
| 90 | #define RENDERHAL_NS_PER_TICK_RENDER_G12 (83.333) // Assume it same as SKL, 83.333 nano seconds per tick in render engine |
| 91 | |
| 92 | //! |
| 93 | //! DSH State Heap settings for G12 |
| 94 | //! |
| 95 | const RENDERHAL_DYN_HEAP_SETTINGS g_cRenderHal_DSH_Settings_g12 = |
| 96 | { |
| 97 | 0x0080000, // dwDshInitialSize = 512MB |
| 98 | 0x0080000, // dwDshSizeIncrement = 512kB |
| 99 | 0x8000000, // dwDshMaximumSize = 128MB (all heaps) |
| 100 | 0x0100000, // dwIshInitialSize = 1M |
| 101 | 0x0040000, // dwIshSizeIncrement = 256kB |
| 102 | 0x0400000, // dwIshMaximumSize = 4MB |
| 103 | 16, // iMinMediaStates |
| 104 | 256, // iMaxMediaStates |
| 105 | 16, // iMinKernels |
| 106 | 2048 // iMaxKernels |
| 107 | }; |
| 108 | |
| 109 | XRenderHal_Interface_G12_Base::XRenderHal_Interface_G12_Base() |
| 110 | { |
| 111 | MOS_ZeroMemory(&m_scratchSpaceResource, sizeof(m_scratchSpaceResource)); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | //! |
| 116 | //! \brief Setup Surface State |
| 117 | //! \details Setup Surface State for Gen11 |
| 118 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 119 | //! [in] Pointer to Hardware Interface Structure |
| 120 | //! \param PRENDERHAL_SURFACE pRenderHalSurface |
| 121 | //! [in] Pointer to Render Hal Surface |
| 122 | //! \param PRENDERHAL_SURFACE_STATE_PARAMS pParams |
| 123 | //! [in] Pointer to Surface State Params |
| 124 | //! \param int32_t *piNumEntries |
| 125 | //! [out] Pointer to Number of Surface State Entries (Num Planes) |
| 126 | //! \param PRENDERHAL_SURFACE_STATE_ENTRY * ppSurfaceEntries |
| 127 | //! [out] Array of Surface State Entries |
| 128 | //! \param PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride |
| 129 | //! [in] Ignored (not used in Gen11) |
| 130 | //! \return MOS_STATUS |
| 131 | //! |
| 132 | MOS_STATUS XRenderHal_Interface_G12_Base::SetupSurfaceState ( |
| 133 | PRENDERHAL_INTERFACE pRenderHal, |
| 134 | PRENDERHAL_SURFACE pRenderHalSurface, |
| 135 | PRENDERHAL_SURFACE_STATE_PARAMS pParams, |
| 136 | int32_t *piNumEntries, |
| 137 | PRENDERHAL_SURFACE_STATE_ENTRY *ppSurfaceEntries, |
| 138 | PRENDERHAL_OFFSET_OVERRIDE pOffsetOverride) |
| 139 | { |
| 140 | PRENDERHAL_SURFACE_STATE_ENTRY pSurfaceEntry; |
| 141 | PMOS_PLANE_OFFSET pPlaneOffset; |
| 142 | MHW_SURFACE_STATE_PARAMS SurfStateParams; |
| 143 | PMOS_SURFACE pSurface; |
| 144 | int32_t i; |
| 145 | uint32_t dwPixelsPerSampleUV; |
| 146 | uint32_t dwSurfaceSize; |
| 147 | MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 148 | |
| 149 | //----------------------------------------- |
| 150 | MHW_RENDERHAL_UNUSED(pOffsetOverride); |
| 151 | MHW_RENDERHAL_CHK_NULL(pRenderHal); |
| 152 | MHW_RENDERHAL_CHK_NULL(pRenderHalSurface); |
| 153 | MHW_RENDERHAL_CHK_NULL(pParams); |
| 154 | MHW_RENDERHAL_CHK_NULL(ppSurfaceEntries); |
| 155 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pStateHeap); |
| 156 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pHwSizes); |
| 157 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pMhwStateHeap); |
| 158 | MHW_RENDERHAL_ASSERT(pRenderHalSurface->Rotation >= MHW_ROTATION_IDENTITY && |
| 159 | pRenderHalSurface->Rotation <= MHW_ROTATE_90_MIRROR_HORIZONTAL); |
| 160 | //----------------------------------------- |
| 161 | |
| 162 | dwSurfaceSize = pRenderHal->pHwSizes->dwSizeSurfaceState; |
| 163 | |
| 164 | MOS_ZeroMemory(&SurfStateParams, sizeof(SurfStateParams)); |
| 165 | |
| 166 | // Get the Surface State Entries |
| 167 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pfnGetSurfaceStateEntries( |
| 168 | pRenderHal, |
| 169 | pRenderHalSurface, |
| 170 | pParams, |
| 171 | piNumEntries, |
| 172 | ppSurfaceEntries)); |
| 173 | |
| 174 | for (i = 0; i < *piNumEntries; i++) |
| 175 | { |
| 176 | // Pointer to surface state entry for current plane |
| 177 | pSurfaceEntry = ppSurfaceEntries[i]; |
| 178 | |
| 179 | pSurface = pSurfaceEntry->pSurface; |
| 180 | MHW_RENDERHAL_CHK_NULL(pSurface); |
| 181 | |
| 182 | // Set the Surface State Offset from base of SSH |
| 183 | pSurfaceEntry->dwSurfStateOffset = pRenderHal->pStateHeap->iSurfaceStateOffset + // Offset to Base Of Current Surface State Area |
| 184 | pSurfaceEntry->iSurfStateID * dwSurfaceSize; // Offset to Surface State within the area |
| 185 | |
| 186 | // Obtain the Pointer to the Surface state from SSH Buffer |
| 187 | SurfStateParams.pSurfaceState = pSurfaceEntry->pSurfaceState; |
| 188 | SurfStateParams.bUseAdvState = pSurfaceEntry->bAVS; |
| 189 | SurfStateParams.dwWidth = pSurfaceEntry->dwWidth; |
| 190 | SurfStateParams.dwHeight = pSurfaceEntry->dwHeight; |
| 191 | SurfStateParams.dwFormat = pSurfaceEntry->dwFormat; |
| 192 | SurfStateParams.dwPitch = pSurfaceEntry->dwPitch; |
| 193 | SurfStateParams.dwQPitch = pSurfaceEntry->dwQPitch; |
| 194 | SurfStateParams.bTiledSurface = pSurfaceEntry->bTiledSurface; |
| 195 | SurfStateParams.bTileWalk = pSurfaceEntry->bTileWalk; |
| 196 | SurfStateParams.dwCacheabilityControl = pRenderHal->pfnGetSurfaceMemoryObjectControl(pRenderHal, pParams); |
| 197 | SurfStateParams.RotationMode = g_cLookup_RotationMode_g12[pRenderHalSurface->Rotation]; |
| 198 | |
| 199 | #if !EMUL |
| 200 | if (pRenderHal->pOsInterface !=nullptr) |
| 201 | { |
| 202 | GMM_RESOURCE_FLAG gmmFlags = {0}; |
| 203 | gmmFlags = pSurface->OsResource.pGmmResInfo->GetResFlags(); |
| 204 | if (gmmFlags.Gpu.CameraCapture) |
| 205 | { |
| 206 | SurfStateParams.dwCacheabilityControl = pRenderHal->pOsInterface->pfnCachePolicyGetMemoryObject( |
| 207 | MOS_MHW_GMM_RESOURCE_USAGE_CAMERA_CAPTURE, |
| 208 | pRenderHal->pOsInterface->pfnGetGmmClientContext(pRenderHal->pOsInterface)).DwordValue; |
| 209 | MHW_RENDERHAL_NORMALMESSAGE(" disable CameraCapture caches on render path "); |
| 210 | } |
| 211 | |
| 212 | // use RESOURCE_USAGE_CCS_MEDIA_WRITABLE to ensure displayable output LLC write-uncached |
| 213 | if (pParams->isOutput && gmmFlags.Gpu.FlipChain && pSurface->MmcState == MOS_MEMCOMP_MC) |
| 214 | { |
| 215 | SurfStateParams.dwCacheabilityControl = pRenderHal->pOsInterface->pfnCachePolicyGetMemoryObject( |
| 216 | MOS_RESOURCE_USAGE_CCS_MEDIA_WRITABLE, |
| 217 | pRenderHal->pOsInterface->pfnGetGmmClientContext(pRenderHal->pOsInterface)) |
| 218 | .DwordValue; |
| 219 | MHW_RENDERHAL_NORMALMESSAGE(" MOS_RESOURCE_USAGE_CCS_MEDIA_WRITABLE is queried, and target SurfStateParams.dwCacheabilityControl = %d \n", SurfStateParams.dwCacheabilityControl); |
| 220 | } |
| 221 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 222 | pSurface->OsResource.memObjCtrlState.DwordValue = SurfStateParams.dwCacheabilityControl; |
| 223 | pParams->MemObjCtl = SurfStateParams.dwCacheabilityControl; |
| 224 | pSurface->oldCacheSetting = (SurfStateParams.dwCacheabilityControl >> 1) & 0x0000003f; |
| 225 | if (pParams->isOutput) |
| 226 | { |
| 227 | pRenderHal->oldCacheSettingForTargetSurface = pSurface->oldCacheSetting; |
| 228 | } |
| 229 | #endif |
| 230 | } |
| 231 | #endif |
| 232 | if (IsFormatMMCSupported(pSurface->Format) && |
| 233 | m_renderHalMMCEnabled) |
| 234 | { |
| 235 | // Set surface compression states |
| 236 | if (pSurface->MmcState == MOS_MEMCOMP_RC && pParams->isOutput) |
| 237 | { |
| 238 | // bCompressionEnabled/bCompressionMode is deprecated on Gen12+, use MmcState instead. |
| 239 | // RC compression mode is not supported on render output surface on tgllp. |
| 240 | SurfStateParams.MmcState = MOS_MEMCOMP_DISABLED; |
| 241 | SurfStateParams.dwCompressionFormat = 0; |
| 242 | } |
| 243 | else if(pSurface->MmcState == MOS_MEMCOMP_MC || |
| 244 | pSurface->MmcState == MOS_MEMCOMP_RC) |
| 245 | { |
| 246 | SurfStateParams.MmcState = pSurface->MmcState; |
| 247 | |
| 248 | if (pSurfaceEntry->YUVPlane == MHW_U_PLANE && |
| 249 | (pSurface->Format == Format_NV12 || |
| 250 | pSurface->Format == Format_P010 || |
| 251 | pSurface->Format == Format_P016)) |
| 252 | { |
| 253 | SurfStateParams.dwCompressionFormat = (uint32_t)(0x00000010) |
| 254 | | (pSurface->CompressionFormat & 0x0f); |
| 255 | } |
| 256 | else if ((pSurface->Format == Format_R8G8UN) && |
| 257 | (pSurface->MmcState == MOS_MEMCOMP_MC)) |
| 258 | { |
| 259 | /* it will be an issue if the R8G8UN surface with MC enable |
| 260 | is not chroma plane from NV12 surface, so far there is no |
| 261 | such case |
| 262 | */ |
| 263 | SurfStateParams.dwCompressionFormat = (uint32_t)(0x00000010) |
| 264 | | (pSurface->CompressionFormat & 0x0f); |
| 265 | } |
| 266 | else |
| 267 | { |
| 268 | SurfStateParams.dwCompressionFormat = pSurface->CompressionFormat & 0x1f; |
| 269 | } |
| 270 | } |
| 271 | else |
| 272 | { |
| 273 | MHW_RENDERHAL_NORMALMESSAGE("Unsupported Compression Mode for Render Engine."); |
| 274 | SurfStateParams.MmcState = MOS_MEMCOMP_DISABLED; |
| 275 | SurfStateParams.dwCompressionFormat = 0; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if (pSurfaceEntry->bAVS) |
| 280 | { |
| 281 | SurfStateParams.bHalfPitchChroma = pSurfaceEntry->bHalfPitchChroma; |
| 282 | SurfStateParams.bInterleaveChroma = pSurfaceEntry->bInterleaveChroma; |
| 283 | SurfStateParams.UVPixelOffsetUDirection = pSurfaceEntry->DirectionU; |
| 284 | SurfStateParams.UVPixelOffsetVDirection = pSurfaceEntry->DirectionV; |
| 285 | |
| 286 | // On SNB+, when VDI Walker is enabled, Input surface width should be 16 pixel aligned |
| 287 | if (pParams->bWidth16Align) |
| 288 | { |
| 289 | SurfStateParams.dwWidth = MOS_ALIGN_CEIL(pSurfaceEntry->dwWidth, 16); |
| 290 | } |
| 291 | |
| 292 | if (pSurfaceEntry->YUVPlane == MHW_U_PLANE) // AVS U plane |
| 293 | { |
| 294 | // Lockoffset is the offset from base address of Y plane to the origin of U/V plane. |
| 295 | // So, We can get XOffsetforU by Lockoffset % pSurface->dwPitch, and get YOffsetForU by Lockoffset / pSurface->dwPitch |
| 296 | SurfStateParams.dwXOffsetForU = (uint32_t)pSurface->UPlaneOffset.iLockSurfaceOffset % pSurface->dwPitch; |
| 297 | SurfStateParams.dwYOffsetForU = (uint32_t)pSurface->UPlaneOffset.iLockSurfaceOffset / pSurface->dwPitch; |
| 298 | SurfStateParams.dwXOffsetForV = 0; |
| 299 | SurfStateParams.dwYOffsetForV = 0; |
| 300 | SurfStateParams.iXOffset = pSurface->UPlaneOffset.iXOffset; |
| 301 | SurfStateParams.iYOffset = pSurface->UPlaneOffset.iYOffset; |
| 302 | } |
| 303 | else if (pSurfaceEntry->YUVPlane == MHW_V_PLANE) // AVS V plane |
| 304 | { |
| 305 | SurfStateParams.dwXOffsetForU = 0; |
| 306 | SurfStateParams.dwYOffsetForU = 0; |
| 307 | SurfStateParams.dwXOffsetForV = (uint32_t)pSurface->VPlaneOffset.iLockSurfaceOffset % pSurface->dwPitch; |
| 308 | SurfStateParams.dwYOffsetForV = (uint32_t)pSurface->VPlaneOffset.iLockSurfaceOffset / pSurface->dwPitch; |
| 309 | SurfStateParams.iXOffset = pSurface->VPlaneOffset.iXOffset; |
| 310 | SurfStateParams.iYOffset = pSurface->VPlaneOffset.iYOffset; |
| 311 | } |
| 312 | else // AVS/DNDI Y plane |
| 313 | { |
| 314 | SurfStateParams.dwXOffsetForU = pSurfaceEntry->wUXOffset; |
| 315 | SurfStateParams.dwYOffsetForU = pSurfaceEntry->wUYOffset; |
| 316 | SurfStateParams.dwXOffsetForV = pSurfaceEntry->wVXOffset; |
| 317 | SurfStateParams.dwYOffsetForV = pSurfaceEntry->wVYOffset; |
| 318 | SurfStateParams.iXOffset = 0; |
| 319 | SurfStateParams.iYOffset = pSurface->YPlaneOffset.iYOffset; |
| 320 | } |
| 321 | if (pRenderHalSurface->bInterlacedScaling) |
| 322 | { |
| 323 | SurfStateParams.bVerticalLineStrideOffset = pSurfaceEntry->bVertStrideOffs; |
| 324 | SurfStateParams.bVerticalLineStride = pSurfaceEntry->bVertStride; |
| 325 | } |
| 326 | } |
| 327 | else // 2D/3D Surface (non-AVS) |
| 328 | { |
| 329 | SurfStateParams.SurfaceType3D = (pSurface->dwDepth > 1) ? |
| 330 | GFX3DSTATE_SURFACETYPE_3D : |
| 331 | GFX3DSTATE_SURFACETYPE_2D; |
| 332 | SurfStateParams.dwDepth = MOS_MAX(1, pSurface->dwDepth); |
| 333 | SurfStateParams.bVerticalLineStrideOffset = pSurfaceEntry->bVertStrideOffs; |
| 334 | SurfStateParams.bVerticalLineStride = pSurfaceEntry->bVertStride; |
| 335 | SurfStateParams.bHalfPitchChroma = pSurfaceEntry->bHalfPitchChroma; |
| 336 | SurfStateParams.bBoardColorOGL = pParams->bWidthInDword_UV ? false : true; //sampler surface |
| 337 | |
| 338 | // Setup surface g9 surface state |
| 339 | if (pSurfaceEntry->YUVPlane == MHW_U_PLANE || |
| 340 | pSurfaceEntry->YUVPlane == MHW_V_PLANE) |
| 341 | { |
| 342 | pPlaneOffset = (pSurfaceEntry->YUVPlane == MHW_U_PLANE) ? |
| 343 | &pSurface->UPlaneOffset : &pSurface->VPlaneOffset; |
| 344 | |
| 345 | // Get Pixels Per Sample if we use dataport read |
| 346 | if(pParams->bWidthInDword_UV) |
| 347 | { |
| 348 | RenderHal_GetPixelsPerSample(pSurface->Format, &dwPixelsPerSampleUV); |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | // If the kernel uses sampler - do not change width (it affects coordinates) |
| 353 | dwPixelsPerSampleUV = 1; |
| 354 | } |
| 355 | |
| 356 | if(dwPixelsPerSampleUV == 1) |
| 357 | { |
| 358 | SurfStateParams.iXOffset = pPlaneOffset->iXOffset; |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | SurfStateParams.iXOffset = pPlaneOffset->iXOffset/sizeof(uint32_t); |
| 363 | } |
| 364 | |
| 365 | SurfStateParams.iYOffset = pPlaneOffset->iYOffset; |
| 366 | } |
| 367 | else // Y plane |
| 368 | { |
| 369 | pPlaneOffset = &pSurface->YPlaneOffset; |
| 370 | |
| 371 | SurfStateParams.iXOffset = pPlaneOffset->iXOffset/sizeof(uint32_t); |
| 372 | SurfStateParams.iYOffset = pPlaneOffset->iYOffset; |
| 373 | |
| 374 | if((pSurfaceEntry->YUVPlane == MHW_Y_PLANE) && |
| 375 | (pSurfaceEntry->dwFormat == MHW_GFX3DSTATE_SURFACEFORMAT_PLANAR_420_8)) |
| 376 | { |
| 377 | if (pSurface->Format == Format_YV12) |
| 378 | { |
| 379 | SurfStateParams.bSeperateUVPlane = true; |
| 380 | SurfStateParams.dwXOffsetForU = 0; |
| 381 | SurfStateParams.dwYOffsetForU = pSurface->dwHeight * 2 + pSurface->dwHeight / 2; |
| 382 | SurfStateParams.dwXOffsetForV = 0; |
| 383 | SurfStateParams.dwYOffsetForV = pSurface->dwHeight * 2; |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | SurfStateParams.bSeperateUVPlane = false; |
| 388 | SurfStateParams.dwXOffsetForU = 0; |
| 389 | SurfStateParams.dwYOffsetForU = (uint32_t)((pSurface->UPlaneOffset.iSurfaceOffset - pSurface->YPlaneOffset.iSurfaceOffset) / pSurface->dwPitch) + pSurface->UPlaneOffset.iYOffset; |
| 390 | SurfStateParams.dwXOffsetForV = 0; |
| 391 | SurfStateParams.dwYOffsetForV = 0; |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | if((pSurfaceEntry->YUVPlane == MHW_Y_PLANE) && |
| 396 | (pSurfaceEntry->dwFormat == MHW_GFX3DSTATE_SURFACEFORMAT_PLANAR_420_16)) |
| 397 | { |
| 398 | SurfStateParams.bSeperateUVPlane = false; |
| 399 | SurfStateParams.dwXOffsetForU = 0; |
| 400 | SurfStateParams.dwYOffsetForU = (uint32_t)((pSurface->UPlaneOffset.iSurfaceOffset - pSurface->YPlaneOffset.iSurfaceOffset) / pSurface->dwPitch) + pSurface->UPlaneOffset.iYOffset; |
| 401 | SurfStateParams.dwXOffsetForV = 0; |
| 402 | SurfStateParams.dwYOffsetForV = 0; |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | // Call MHW to setup the Surface State Heap entry |
| 408 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pMhwStateHeap->SetSurfaceStateEntry(&SurfStateParams)); |
| 409 | |
| 410 | // Setup OS specific states |
| 411 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pfnSetupSurfaceStatesOs(pRenderHal, pParams, pSurfaceEntry)); |
| 412 | } |
| 413 | |
| 414 | eStatus = MOS_STATUS_SUCCESS; |
| 415 | |
| 416 | finish: |
| 417 | return eStatus; |
| 418 | } |
| 419 | |
| 420 | //! |
| 421 | //! \brief Encode SLM Size for Interface Descriptor |
| 422 | //! \details Setup SLM size |
| 423 | //! \param uint32_t SLMSize |
| 424 | //! [in] SLM size in 1K |
| 425 | //! \return encoded output |
| 426 | //! |
| 427 | uint32_t XRenderHal_Interface_G12_Base::EncodeSLMSize(uint32_t SLMSize) |
| 428 | { |
| 429 | uint32_t EncodedValue; |
| 430 | if (SLMSize <= 2) |
| 431 | { |
| 432 | EncodedValue = SLMSize; |
| 433 | } |
| 434 | else |
| 435 | { |
| 436 | EncodedValue = 0; |
| 437 | do |
| 438 | { |
| 439 | SLMSize >>= 1; |
| 440 | EncodedValue++; |
| 441 | } while (SLMSize); |
| 442 | } |
| 443 | return EncodedValue; |
| 444 | } |
| 445 | |
| 446 | //! |
| 447 | //! \brief Convert To Nano Seconds |
| 448 | //! \details Convert to Nano Seconds |
| 449 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 450 | //! [in] Pointer to Hardware Interface Structure |
| 451 | //! \param uint64_t iTicks |
| 452 | //! [in] Ticks |
| 453 | //! \param uint64_t *piNs |
| 454 | //! [in] Nano Seconds |
| 455 | //! \return void |
| 456 | //! |
| 457 | void XRenderHal_Interface_G12_Base::ConvertToNanoSeconds( |
| 458 | PRENDERHAL_INTERFACE pRenderHal, |
| 459 | uint64_t iTicks, |
| 460 | uint64_t *piNs) |
| 461 | { |
| 462 | //----------------------------- |
| 463 | MHW_RENDERHAL_UNUSED(pRenderHal); |
| 464 | MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal); |
| 465 | MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(piNs); |
| 466 | //----------------------------- |
| 467 | *piNs = (uint64_t)(iTicks * RENDERHAL_NS_PER_TICK_RENDER_G12); |
| 468 | } |
| 469 | |
| 470 | //! |
| 471 | //! \brief Setup Chroma direction for Gen11 |
| 472 | //! \details Setup Chroma direction |
| 473 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 474 | //! [in] Pointer to HW Interface |
| 475 | //! \param PRENDERHAL_SURFACE pSurface |
| 476 | //! [in] Pointer to surface |
| 477 | //! \return uint8_t |
| 478 | //! |
| 479 | uint8_t XRenderHal_Interface_G12_Base::SetChromaDirection( |
| 480 | PRENDERHAL_INTERFACE pRenderHal, |
| 481 | PRENDERHAL_SURFACE pRenderHalSurface) |
| 482 | { |
| 483 | uint8_t Direction; |
| 484 | MHW_RENDERHAL_UNUSED(pRenderHal); |
| 485 | |
| 486 | MHW_RENDERHAL_ASSERT(pRenderHal); |
| 487 | MHW_RENDERHAL_ASSERT(pRenderHalSurface); |
| 488 | |
| 489 | Direction = 0; |
| 490 | |
| 491 | if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_HORZ_CENTER) |
| 492 | { |
| 493 | Direction = CHROMA_SITING_UDIRECTION_CENTER; |
| 494 | } |
| 495 | else |
| 496 | { |
| 497 | Direction = CHROMA_SITING_UDIRECTION_LEFT; |
| 498 | } |
| 499 | |
| 500 | // Combined U/V direction together in one uint8_t, 1 bit for U direction, 3 bits for V direction. |
| 501 | Direction = Direction << 3; |
| 502 | |
| 503 | if (pRenderHalSurface->pDeinterlaceParams || pRenderHalSurface->bQueryVariance) |
| 504 | { |
| 505 | if ((pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD) || |
| 506 | (pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD)) |
| 507 | { |
| 508 | if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_TOP) |
| 509 | { |
| 510 | Direction |= CHROMA_SITING_VDIRECTION_1_2; |
| 511 | } |
| 512 | else if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_BOTTOM) |
| 513 | { |
| 514 | Direction |= CHROMA_SITING_VDIRECTION_1; |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | Direction |= CHROMA_SITING_VDIRECTION_3_4; |
| 519 | } |
| 520 | } |
| 521 | else if ((pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD) || |
| 522 | (pRenderHalSurface->SampleType == RENDERHAL_SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD)) |
| 523 | { |
| 524 | if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_TOP) |
| 525 | { |
| 526 | Direction |= CHROMA_SITING_VDIRECTION_0; |
| 527 | } |
| 528 | else if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_BOTTOM) |
| 529 | { |
| 530 | Direction |= CHROMA_SITING_VDIRECTION_1_2; |
| 531 | } |
| 532 | else |
| 533 | { |
| 534 | Direction |= CHROMA_SITING_VDIRECTION_1_4; |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | else |
| 539 | { |
| 540 | if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_TOP) |
| 541 | { |
| 542 | Direction |= CHROMA_SITING_VDIRECTION_0; |
| 543 | } |
| 544 | else if (pRenderHalSurface->ChromaSiting & MHW_CHROMA_SITING_VERT_BOTTOM) |
| 545 | { |
| 546 | Direction |= CHROMA_SITING_VDIRECTION_1; |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | Direction |= CHROMA_SITING_VDIRECTION_1_2; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | return Direction; |
| 555 | } |
| 556 | |
| 557 | //! |
| 558 | //! \brief Initialize the State Heap Settings per platform |
| 559 | //! \param PRENDERHAL_STATE_HEAP_SETTINGS pSettings |
| 560 | //! [out] Pointer to PRENDERHAL_STATE_HEAP_SETTINGSStructure |
| 561 | //! \return void |
| 562 | //! |
| 563 | void XRenderHal_Interface_G12_Base::InitStateHeapSettings( |
| 564 | PRENDERHAL_INTERFACE pRenderHal) |
| 565 | { |
| 566 | MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal); |
| 567 | // Set State Heap settings for g12 |
| 568 | pRenderHal->StateHeapSettings = g_cRenderHal_State_Heap_Settings_g12; |
| 569 | } |
| 570 | |
| 571 | //! |
| 572 | //! \brief Initialize the default surface type and advanced surface type per platform |
| 573 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 574 | //! [out] Pointer to PRENDERHAL_INTERFACE |
| 575 | //! \return void |
| 576 | //! |
| 577 | void XRenderHal_Interface_G12_Base::InitSurfaceTypes( |
| 578 | PRENDERHAL_INTERFACE pRenderHal) |
| 579 | { |
| 580 | MHW_RENDERHAL_CHK_NULL_NO_STATUS_RETURN(pRenderHal); |
| 581 | // Set default / advanced surface types |
| 582 | pRenderHal->SurfaceTypeDefault = RENDERHAL_SURFACE_TYPE_G10; |
| 583 | pRenderHal->SurfaceTypeAdvanced = RENDERHAL_SURFACE_TYPE_ADV_G10; |
| 584 | } |
| 585 | |
| 586 | //! |
| 587 | //! \brief Enables L3 cacheing flag and sets related registers/values |
| 588 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 589 | //! [in] Pointer to Hardware Interface |
| 590 | //! \param pCacheSettings |
| 591 | //! [in] L3 Cache Configurations |
| 592 | //! \return MOS_STATUS |
| 593 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 594 | //! |
| 595 | MOS_STATUS XRenderHal_Interface_G12_Base::EnableL3Caching( |
| 596 | PRENDERHAL_INTERFACE pRenderHal, |
| 597 | PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings) |
| 598 | { |
| 599 | MOS_STATUS eStatus; |
| 600 | MHW_RENDER_ENGINE_L3_CACHE_SETTINGS_G12 mHwL3CacheConfig = {}; |
| 601 | PMHW_RENDER_ENGINE_L3_CACHE_SETTINGS pCacheConfig; |
| 602 | MhwRenderInterface *pMhwRender; |
| 603 | PRENDERHAL_INTERFACE_LEGACY pRenderHalLegacy = (PRENDERHAL_INTERFACE_LEGACY)pRenderHal; |
| 604 | |
| 605 | MHW_RENDERHAL_CHK_NULL(pRenderHalLegacy); |
| 606 | pMhwRender = pRenderHalLegacy->pMhwRenderInterface; |
| 607 | MHW_RENDERHAL_CHK_NULL(pMhwRender); |
| 608 | |
| 609 | if (nullptr == pCacheSettings) |
| 610 | { |
| 611 | MHW_RENDERHAL_CHK_STATUS(pMhwRender->EnableL3Caching(nullptr)); |
| 612 | goto finish; |
| 613 | } |
| 614 | |
| 615 | // customize the cache config for renderhal and let mhw_render overwrite it |
| 616 | pCacheConfig = &mHwL3CacheConfig; |
| 617 | |
| 618 | mHwL3CacheConfig.dwAllocReg = RENDERHAL_L3_CACHE_CONFIG_CNTLREG_VALUE_G12LP_RENDERHAL; |
| 619 | |
| 620 | // Override L3 cache configuration |
| 621 | if (pCacheSettings->bOverride) |
| 622 | { |
| 623 | if (pCacheSettings->bCntlRegOverride) |
| 624 | { |
| 625 | mHwL3CacheConfig.dwAllocReg = pCacheSettings->dwCntlReg; |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | MHW_RENDERHAL_CHK_STATUS(pMhwRender->EnableL3Caching(pCacheConfig)); |
| 630 | |
| 631 | finish: |
| 632 | return eStatus; |
| 633 | } |
| 634 | |
| 635 | //! |
| 636 | //! \brief Get offset and/or pointer to sampler state |
| 637 | //! \details Get offset and/or pointer to sampler state in General State Heap |
| 638 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 639 | //! [in] Pointer to RenderHal Interface |
| 640 | //! \param int32_t iMediaID |
| 641 | //! [in] Media ID associated with sampler |
| 642 | //! \param int32_t iSamplerID |
| 643 | //! [in] Sampler ID |
| 644 | //! \param uint32_t *pdwSamplerOffset |
| 645 | //! [out] optional; offset of sampler state from GSH base |
| 646 | //! \param void **ppSampler |
| 647 | //! [out] optional; pointer to sampler state in GSH |
| 648 | //! \return MOS_STATUS |
| 649 | //! |
| 650 | MOS_STATUS XRenderHal_Interface_G12_Base::GetSamplerOffsetAndPtr_DSH( |
| 651 | PRENDERHAL_INTERFACE pRenderHal, |
| 652 | int32_t iMediaID, |
| 653 | int32_t iSamplerID, |
| 654 | PMHW_SAMPLER_STATE_PARAM pSamplerParams, |
| 655 | uint32_t *pdwSamplerOffset, |
| 656 | void **ppSampler) |
| 657 | { |
| 658 | PRENDERHAL_STATE_HEAP pStateHeap; |
| 659 | PRENDERHAL_DYNAMIC_STATE pDynamicState; |
| 660 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 661 | uint32_t dwSamplerIndirect; |
| 662 | uint32_t dwOffset; |
| 663 | MHW_SAMPLER_TYPE SamplerType; |
| 664 | |
| 665 | MHW_RENDERHAL_CHK_NULL(pRenderHal); |
| 666 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pStateHeap); |
| 667 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pStateHeap->pCurMediaState); |
| 668 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pHwSizes); |
| 669 | |
| 670 | pStateHeap = pRenderHal->pStateHeap; |
| 671 | pDynamicState = ((PRENDERHAL_MEDIA_STATE_LEGACY)pStateHeap->pCurMediaState)->pDynamicState; |
| 672 | |
| 673 | MHW_RENDERHAL_CHK_NULL(pDynamicState); |
| 674 | |
| 675 | MHW_RENDERHAL_ASSERT(iMediaID < pDynamicState->MediaID.iCount); |
| 676 | |
| 677 | dwOffset = iMediaID * pDynamicState->dwSizeSamplers; // Go to Media ID sampler offset |
| 678 | |
| 679 | SamplerType = (pSamplerParams) ? pSamplerParams->SamplerType : MHW_SAMPLER_TYPE_3D; |
| 680 | |
| 681 | switch (SamplerType) |
| 682 | { |
| 683 | case MHW_SAMPLER_TYPE_AVS: |
| 684 | MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->SamplerAVS.iCount); |
| 685 | dwOffset += pDynamicState->SamplerAVS.dwOffset + // Go to AVS sampler area |
| 686 | iSamplerID * MHW_SAMPLER_STATE_AVS_INC_G12; // 16: size of one element, 128 elements for SKL |
| 687 | break; |
| 688 | |
| 689 | case MHW_SAMPLER_TYPE_CONV: |
| 690 | MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->SamplerConv.iCount); |
| 691 | dwOffset = pDynamicState->SamplerConv.dwOffset; // Goto Conv sampler base |
| 692 | if ( pSamplerParams->Convolve.ui8ConvolveType == 0 && pSamplerParams->Convolve.skl_mode ) |
| 693 | { // 2D convolve |
| 694 | dwOffset += iSamplerID * MHW_SAMPLER_STATE_CONV_INC_G12; // 16: size of one element, 128 elements for SKL |
| 695 | } |
| 696 | else if ( pSamplerParams->Convolve.ui8ConvolveType == 1 ) |
| 697 | { // 1D convolve |
| 698 | dwOffset += iSamplerID * MHW_SAMPLER_STATE_CONV_1D_INC; // 16: size of one element, 8 elements for SKL |
| 699 | } |
| 700 | else |
| 701 | { // 1P convolve (same as gen8) and 2D convolve BDW mode |
| 702 | dwOffset += iSamplerID * MHW_SAMPLER_STATE_CONV_INC_LEGACY; // 16: size of one element, 32: 32 entry |
| 703 | } |
| 704 | break; |
| 705 | |
| 706 | case MHW_SAMPLER_TYPE_MISC: |
| 707 | MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->SamplerMisc.iCount); |
| 708 | dwOffset += pDynamicState->Sampler3D.dwOffset + // Goto sampler base |
| 709 | iSamplerID * MHW_SAMPLER_STATE_VA_INC; // 16: size of one element, 2: 2 entries |
| 710 | break; |
| 711 | |
| 712 | case MHW_SAMPLER_TYPE_3D: |
| 713 | case MHW_SAMPLER_TYPE_VME: |
| 714 | default: |
| 715 | MHW_RENDERHAL_ASSERT(iSamplerID < pDynamicState->Sampler3D.iCount); |
| 716 | dwSamplerIndirect = dwOffset; |
| 717 | dwOffset += pDynamicState->Sampler3D.dwOffset + // Go 3D Sampler base |
| 718 | iSamplerID * pRenderHal->pHwSizes->dwSizeSamplerState; // Goto to "samplerID" sampler state |
| 719 | |
| 720 | if (pSamplerParams) |
| 721 | { |
| 722 | dwSamplerIndirect += pDynamicState->SamplerInd.dwOffset + // offset to indirect sampler area |
| 723 | iSamplerID * pRenderHal->pHwSizes->dwSizeSamplerIndirectState; // Goto to "samplerID" indirect state |
| 724 | pSamplerParams->Unorm.IndirectStateOffset = dwSamplerIndirect; |
| 725 | } |
| 726 | |
| 727 | break; |
| 728 | } |
| 729 | |
| 730 | if (pdwSamplerOffset) |
| 731 | { |
| 732 | *pdwSamplerOffset = dwOffset; |
| 733 | } |
| 734 | |
| 735 | finish: |
| 736 | return eStatus; |
| 737 | } |
| 738 | |
| 739 | //! |
| 740 | //! \brief Initialize the DSH Settings |
| 741 | //! \details Initialize the structure DynamicHeapSettings in pRenderHal |
| 742 | //! \param PRENDERHAL_INTERFACE pRenderHal |
| 743 | //! [in] Pointer to HW interface |
| 744 | //! \return void |
| 745 | //! |
| 746 | void XRenderHal_Interface_G12_Base::InitDynamicHeapSettings( |
| 747 | PRENDERHAL_INTERFACE pRenderHal) |
| 748 | { |
| 749 | PRENDERHAL_INTERFACE_LEGACY pRenderHalLegacy = static_cast<PRENDERHAL_INTERFACE_LEGACY>(pRenderHal); |
| 750 | MHW_RENDERHAL_ASSERT(pRenderHalLegacy); |
| 751 | // Additional Dynamic State Heap settings for g12 |
| 752 | pRenderHalLegacy->DynamicHeapSettings = g_cRenderHal_DSH_Settings_g12; |
| 753 | } |
| 754 | |
| 755 | void XRenderHal_Interface_G12_Base::SetFusedEUDispatch(bool enable) |
| 756 | { |
| 757 | m_vfeStateParams.bFusedEuDispatch = enable? true : false; |
| 758 | } |
| 759 | |
| 760 | MOS_STATUS XRenderHal_Interface_G12_Base::SetNumOfWalkers(uint32_t numOfWalkers) |
| 761 | { |
| 762 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 763 | // value: [0,1] - One or two active walkers per context. |
| 764 | if (numOfWalkers > 2) |
| 765 | { |
| 766 | m_vfeStateParams.numOfWalkers = 1; |
| 767 | } |
| 768 | else if (numOfWalkers > 0) |
| 769 | { |
| 770 | m_vfeStateParams.numOfWalkers = numOfWalkers - 1; |
| 771 | } |
| 772 | return eStatus; |
| 773 | } |
| 774 | |
| 775 | //! |
| 776 | //! \brief Set Power Option Status |
| 777 | //! \param [in] pRenderHal |
| 778 | //! Pointer to Hardware Interface |
| 779 | //! \param [in,out] pCmdBuffer |
| 780 | //! Pointer to Command Buffer |
| 781 | //! \return MOS_STATUS |
| 782 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 783 | //! |
| 784 | MOS_STATUS XRenderHal_Interface_G12_Base::SetPowerOptionStatus( |
| 785 | PRENDERHAL_INTERFACE pRenderHal, |
| 786 | PMOS_COMMAND_BUFFER pCmdBuffer) |
| 787 | { |
| 788 | PMOS_INTERFACE pOsInterface; |
| 789 | MOS_STATUS eStatus; |
| 790 | MEDIA_SYSTEM_INFO *pGtSystemInfo; |
| 791 | |
| 792 | MHW_RENDERHAL_CHK_NULL(pRenderHal); |
| 793 | MHW_RENDERHAL_CHK_NULL(pCmdBuffer); |
| 794 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pOsInterface); |
| 795 | |
| 796 | eStatus = MOS_STATUS_SUCCESS; |
| 797 | pOsInterface = pRenderHal->pOsInterface; |
| 798 | pGtSystemInfo = pOsInterface->pfnGetGtSystemInfo(pOsInterface); |
| 799 | MHW_RENDERHAL_CHK_NULL(pGtSystemInfo); |
| 800 | |
| 801 | // Check if Slice Shutdown can be enabled |
| 802 | if (pRenderHal->bRequestSingleSlice) |
| 803 | { |
| 804 | pCmdBuffer->Attributes.dwNumRequestedEUSlices = 1; |
| 805 | } |
| 806 | else if (pRenderHal->bEUSaturationNoSSD) |
| 807 | { |
| 808 | pCmdBuffer->Attributes.dwNumRequestedEUSlices = 2; |
| 809 | } |
| 810 | |
| 811 | if ((pRenderHal->pSkuTable) && (MEDIA_IS_SKU(pRenderHal->pSkuTable, FtrSSEUPowerGating) || MEDIA_IS_SKU(pRenderHal->pSkuTable, FtrSSEUPowerGatingControlByUMD))) |
| 812 | { |
| 813 | // VP does not request subslice shutdown according to the array VpHalDefaultSSEUTableGxx |
| 814 | if (((pRenderHal->PowerOption.nSlice != 0) || (pRenderHal->PowerOption.nSubSlice != 0) || (pRenderHal->PowerOption.nEU != 0)) && |
| 815 | ((pGtSystemInfo->SliceCount != 0) && (pGtSystemInfo->SubSliceCount != 0))) |
| 816 | { |
| 817 | pCmdBuffer->Attributes.dwNumRequestedEUSlices = MOS_MIN(pRenderHal->PowerOption.nSlice, pGtSystemInfo->SliceCount); |
| 818 | pCmdBuffer->Attributes.dwNumRequestedSubSlices = MOS_MIN(pRenderHal->PowerOption.nSubSlice, (pGtSystemInfo->SubSliceCount / pGtSystemInfo->SliceCount)); |
| 819 | pCmdBuffer->Attributes.dwNumRequestedEUs = MOS_MIN(pRenderHal->PowerOption.nEU, (pGtSystemInfo->EUCount / pGtSystemInfo->SubSliceCount)); |
| 820 | pCmdBuffer->Attributes.bValidPowerGatingRequest = true; |
| 821 | pCmdBuffer->Attributes.bUmdSSEUEnable = true; |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | finish: |
| 826 | return eStatus; |
| 827 | } |
| 828 | |
| 829 | //! |
| 830 | //! \brief Set Composite Prolog CMD |
| 831 | //! \param [in] pRenderHal |
| 832 | //! Pointer to Hardware Interface |
| 833 | //! \param [in,out] pCmdBuffer |
| 834 | //! Pointer to Command Buffer |
| 835 | //! \return MOS_STATUS |
| 836 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 837 | //! |
| 838 | MOS_STATUS XRenderHal_Interface_G12_Base::SetCompositePrologCmd( |
| 839 | PRENDERHAL_INTERFACE pRenderHal, |
| 840 | PMOS_COMMAND_BUFFER pCmdBuffer) |
| 841 | { |
| 842 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 843 | uint64_t auxTableBaseAddr = 0; |
| 844 | |
| 845 | MHW_RENDERHAL_CHK_NULL(pRenderHal); |
| 846 | MHW_RENDERHAL_CHK_NULL(pCmdBuffer); |
| 847 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pOsInterface); |
| 848 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pMhwMiInterface); |
| 849 | |
| 850 | auxTableBaseAddr = pRenderHal->pOsInterface->pfnGetAuxTableBaseAddr(pRenderHal->pOsInterface); |
| 851 | |
| 852 | if (auxTableBaseAddr) |
| 853 | { |
| 854 | MHW_MI_LOAD_REGISTER_IMM_PARAMS lriParams; |
| 855 | MOS_ZeroMemory(&lriParams, sizeof(MHW_MI_LOAD_REGISTER_IMM_PARAMS)); |
| 856 | |
| 857 | lriParams.dwRegister = MhwMiInterfaceG12::m_mmioRcsAuxTableBaseLow; |
| 858 | lriParams.dwData = (auxTableBaseAddr & 0xffffffff); |
| 859 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pMhwMiInterface->AddMiLoadRegisterImmCmd(pCmdBuffer, &lriParams)); |
| 860 | |
| 861 | lriParams.dwRegister = MhwMiInterfaceG12::m_mmioRcsAuxTableBaseHigh; |
| 862 | lriParams.dwData = ((auxTableBaseAddr >> 32) & 0xffffffff); |
| 863 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pMhwMiInterface->AddMiLoadRegisterImmCmd(pCmdBuffer, &lriParams)); |
| 864 | |
| 865 | lriParams.dwRegister = MhwMiInterfaceG12::m_mmioCcs0AuxTableBaseLow; |
| 866 | lriParams.dwData = (auxTableBaseAddr & 0xffffffff); |
| 867 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pMhwMiInterface->AddMiLoadRegisterImmCmd(pCmdBuffer, &lriParams)); |
| 868 | |
| 869 | lriParams.dwRegister = MhwMiInterfaceG12::m_mmioCcs0AuxTableBaseHigh; |
| 870 | lriParams.dwData = ((auxTableBaseAddr >> 32) & 0xffffffff); |
| 871 | MHW_RENDERHAL_CHK_STATUS(pRenderHal->pMhwMiInterface->AddMiLoadRegisterImmCmd(pCmdBuffer, &lriParams)); |
| 872 | |
| 873 | } |
| 874 | |
| 875 | finish: |
| 876 | return eStatus; |
| 877 | } |
| 878 | |
| 879 | MOS_STATUS XRenderHal_Interface_G12_Base::IsRenderHalMMCEnabled( |
| 880 | PRENDERHAL_INTERFACE pRenderHal) |
| 881 | { |
| 882 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 883 | MOS_USER_FEATURE_VALUE_DATA UserFeatureData; |
| 884 | |
| 885 | MHW_RENDERHAL_CHK_NULL_NO_STATUS(pRenderHal); |
| 886 | |
| 887 | // Read user feature key to set MMC for Fast Composition surfaces |
| 888 | MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData)); |
| 889 | |
| 890 | UserFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE; |
| 891 | #if (LINUX) && (!WDDM_LINUX) |
| 892 | UserFeatureData.bData = !MEDIA_IS_WA(pRenderHal->pWaTable, WaDisableVPMmc) || !MEDIA_IS_WA(pRenderHal->pWaTable, WaDisableCodecMmc); // Enable MMC on Linux based on platforms settings |
| 893 | #else |
| 894 | UserFeatureData.bData = true; // init as default value to enable MMCD on Gen12LP |
| 895 | #endif |
| 896 | MOS_USER_FEATURE_INVALID_KEY_ASSERT(MOS_UserFeature_ReadValue_ID( |
| 897 | nullptr, |
| 898 | __MEDIA_USER_FEATURE_ENABLE_RENDER_ENGINE_MMC_ID, |
| 899 | &UserFeatureData, |
| 900 | pRenderHal->pOsInterface->pOsContext)); |
| 901 | |
| 902 | m_renderHalMMCEnabled = UserFeatureData.bData && MEDIA_IS_SKU(pRenderHal->pSkuTable, FtrE2ECompression); |
| 903 | pRenderHal->isMMCEnabled = m_renderHalMMCEnabled; |
| 904 | |
| 905 | finish: |
| 906 | return eStatus; |
| 907 | } |
| 908 | |
| 909 | //! |
| 910 | //! \brief Check if Override is needed or not |
| 911 | //! \param [in] pRenderHal |
| 912 | //! Pointer to Hardware Interface |
| 913 | //! \param [in,out] pCmdBuffer |
| 914 | //! Pointer to Command Buffer |
| 915 | //! \param [in] pGenericPrologParam |
| 916 | //! Pointer to MHW generic prolog parameters |
| 917 | //! \return MOS_STATUS |
| 918 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 919 | //! |
| 920 | MOS_STATUS XRenderHal_Interface_G12_Base::IsOvrdNeeded( |
| 921 | PRENDERHAL_INTERFACE pRenderHal, |
| 922 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 923 | PRENDERHAL_GENERIC_PROLOG_PARAMS pGenericPrologParams) |
| 924 | { |
| 925 | PMOS_INTERFACE pOsInterface; |
| 926 | MOS_STATUS eStatus; |
| 927 | PMOS_CMD_BUF_ATTRI_VE pAttriVe; |
| 928 | PRENDERHAL_GENERIC_PROLOG_PARAMS_G12 pGenericPrologParamsG12; |
| 929 | uint8_t i; |
| 930 | |
| 931 | MHW_RENDERHAL_CHK_NULL(pRenderHal); |
| 932 | MHW_RENDERHAL_CHK_NULL(pCmdBuffer); |
| 933 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pOsInterface); |
| 934 | MHW_RENDERHAL_CHK_NULL(pRenderHal->pRenderHalPltInterface); |
| 935 | |
| 936 | eStatus = MOS_STATUS_SUCCESS; |
| 937 | pOsInterface = pRenderHal->pOsInterface; |
| 938 | pAttriVe = (PMOS_CMD_BUF_ATTRI_VE)(pCmdBuffer->Attributes.pAttriVe); |
| 939 | pGenericPrologParamsG12 = dynamic_cast<PRENDERHAL_GENERIC_PROLOG_PARAMS_G12>(pGenericPrologParams); |
| 940 | |
| 941 | // Split Frame |
| 942 | if (pOsInterface->VEEnable) |
| 943 | { |
| 944 | #if !EMUL |
| 945 | if (pGenericPrologParamsG12) |
| 946 | #else |
| 947 | if (pGenericPrologParamsG12 && pAttriVe != nullptr) |
| 948 | #endif |
| 949 | { |
| 950 | // Split Frame |
| 951 | if (pGenericPrologParamsG12->VEngineHintParams.BatchBufferCount > 1) |
| 952 | { |
| 953 | pAttriVe->bUseVirtualEngineHint = true; |
| 954 | pAttriVe->VEngineHintParams = pGenericPrologParamsG12->VEngineHintParams; |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 959 | #if !EMUL |
| 960 | if (pOsInterface->bEnableDbgOvrdInVE) |
| 961 | #else |
| 962 | if (pOsInterface->bEnableDbgOvrdInVE && pAttriVe != nullptr) |
| 963 | #endif |
| 964 | { |
| 965 | if (pOsInterface->bVeboxScalabilityMode) |
| 966 | { |
| 967 | pAttriVe->VEngineHintParams.DebugOverride = true; |
| 968 | #if !EMUL |
| 969 | if (pGenericPrologParamsG12) |
| 970 | #else |
| 971 | if (pGenericPrologParamsG12 && pAttriVe != nullptr) |
| 972 | #endif |
| 973 | { |
| 974 | pAttriVe->VEngineHintParams.BatchBufferCount = pGenericPrologParamsG12->VEngineHintParams.BatchBufferCount; |
| 975 | for (i = 0; i < pGenericPrologParamsG12->VEngineHintParams.BatchBufferCount; i++) |
| 976 | { |
| 977 | pAttriVe->VEngineHintParams.EngineInstance[i] = i; |
| 978 | } |
| 979 | } |
| 980 | } |
| 981 | else if (pOsInterface->eForceVebox) |
| 982 | { |
| 983 | pAttriVe->VEngineHintParams.DebugOverride = true; |
| 984 | pAttriVe->VEngineHintParams.BatchBufferCount = 1; |
| 985 | pAttriVe->VEngineHintParams.EngineInstance[0] = pOsInterface->eForceVebox - 1; |
| 986 | } |
| 987 | } |
| 988 | #endif |
| 989 | } |
| 990 | |
| 991 | finish: |
| 992 | return eStatus; |
| 993 | }; |
| 994 | |
| 995 | //! \brief Set L3 cache override config parameters |
| 996 | //! \param [in] pRenderHal |
| 997 | //! Pointer to RenderHal Interface Structure |
| 998 | //! \param [in,out] pCacheSettings |
| 999 | //! Pointer to pCacheSettings |
| 1000 | //! \param [in] bEnableSLM |
| 1001 | //! Flag to enable SLM |
| 1002 | //! \return MOS_STATUS |
| 1003 | //! MOS_STATUS_SUCCESS if success. Error code otherwise |
| 1004 | //! |
| 1005 | MOS_STATUS XRenderHal_Interface_G12_Base::SetCacheOverrideParams( |
| 1006 | PRENDERHAL_INTERFACE pRenderHal, |
| 1007 | PRENDERHAL_L3_CACHE_SETTINGS pCacheSettings, |
| 1008 | bool bEnableSLM) |
| 1009 | { |
| 1010 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1011 | |
| 1012 | MHW_RENDERHAL_CHK_NULL(pCacheSettings); |
| 1013 | MHW_RENDERHAL_CHK_NULL(pRenderHal); |
| 1014 | |
| 1015 | pCacheSettings->dwCntlReg = RENDERHAL_L3_CACHE_CONFIG_CNTLREG_VALUE_G12LP_RENDERHAL; |
| 1016 | pCacheSettings->bCntlRegOverride = true; |
| 1017 | |
| 1018 | finish: |
| 1019 | return eStatus; |
| 1020 | } |
| 1021 | |
| 1022 | //! \brief Get the size of Render Surface State Command |
| 1023 | //! \return size_t |
| 1024 | //! the size of render surface state command |
| 1025 | size_t XRenderHal_Interface_G12_Base::GetSurfaceStateCmdSize() |
| 1026 | { |
| 1027 | return MOS_ALIGN_CEIL( MOS_MAX(mhw_state_heap_g12_X::RENDER_SURFACE_STATE_CMD::byteSize, |
| 1028 | mhw_state_heap_g12_X::MEDIA_SURFACE_STATE_CMD::byteSize), MHW_SURFACE_STATE_ALIGN); |
| 1029 | } |
| 1030 | |
| 1031 | //! \brief Get Surface Compression support caps |
| 1032 | //! \param [in] format |
| 1033 | //! surface format |
| 1034 | //! \return bool |
| 1035 | //! true or false |
| 1036 | bool XRenderHal_Interface_G12_Base::IsFormatMMCSupported(MOS_FORMAT format) |
| 1037 | { |
| 1038 | // Check if Sample Format is supported |
| 1039 | if ((format != Format_YUY2) && |
| 1040 | (format != Format_Y410) && |
| 1041 | (format != Format_Y216) && |
| 1042 | (format != Format_Y210) && |
| 1043 | (format != Format_Y416) && |
| 1044 | (format != Format_P010) && |
| 1045 | (format != Format_P016) && |
| 1046 | (format != Format_AYUV) && |
| 1047 | (format != Format_NV21) && |
| 1048 | (format != Format_NV12) && |
| 1049 | (format != Format_UYVY) && |
| 1050 | (format != Format_YUYV) && |
| 1051 | (format != Format_A8B8G8R8) && |
| 1052 | (format != Format_X8B8G8R8) && |
| 1053 | (format != Format_A8R8G8B8) && |
| 1054 | (format != Format_X8R8G8B8) && |
| 1055 | (format != Format_B10G10R10A2) && |
| 1056 | (format != Format_R10G10B10A2) && |
| 1057 | (format != Format_A16R16G16B16F) && |
| 1058 | (format != Format_A16B16G16R16F) && |
| 1059 | (format != Format_IMC3) && |
| 1060 | (format != Format_444P) && |
| 1061 | (format != Format_422H) && |
| 1062 | (format != Format_422V) && |
| 1063 | (format != Format_411P) && |
| 1064 | (format != Format_411R) && |
| 1065 | (format != Format_444P) && |
| 1066 | (format != Format_RGBP) && |
| 1067 | (format != Format_BGRP) && |
| 1068 | (format != Format_400P) && |
| 1069 | (format != Format_420O) && |
| 1070 | (format != Format_R8UN) && |
| 1071 | (format != Format_A8) && |
| 1072 | (format != Format_R8G8UN)) |
| 1073 | { |
| 1074 | MHW_RENDERHAL_NORMALMESSAGE("Unsupported Format '0x%08x' for Render MMC.", format); |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | return true; |
| 1079 | } |
| 1080 | |
| 1081 | MOS_STATUS XRenderHal_Interface_G12_Base::AllocateScratchSpaceBuffer( |
| 1082 | uint32_t perThreadScratchSpace, |
| 1083 | RENDERHAL_INTERFACE *renderHal) |
| 1084 | { |
| 1085 | return MOS_STATUS_UNIMPLEMENTED; |
| 1086 | } |
| 1087 | |
| 1088 | static const uint32_t FIXED_SCRATCH_SPACE_BUFFER_INDEX = 6; |
| 1089 | |
| 1090 | MOS_STATUS XRenderHal_Interface_G12_Base::SetScratchSpaceBufferState( |
| 1091 | RENDERHAL_INTERFACE *renderHal, |
| 1092 | uint32_t indexOfBindingTable) |
| 1093 | { |
| 1094 | if (m_scratchSpaceResource.iSize <= 0) |
| 1095 | { |
| 1096 | return MOS_STATUS_SUCCESS; // Scratch space is not allocated. No need to set states. |
| 1097 | } |
| 1098 | |
| 1099 | RENDERHAL_SURFACE renderhal_surface; |
| 1100 | MOS_ZeroMemory(&renderhal_surface, sizeof(renderhal_surface)); |
| 1101 | renderhal_surface.OsSurface.OsResource = m_scratchSpaceResource; |
| 1102 | renderhal_surface.OsSurface.dwWidth = m_scratchSpaceResource.iSize; |
| 1103 | renderhal_surface.OsSurface.dwHeight = 1; |
| 1104 | renderhal_surface.OsSurface.Format = Format_RAW; |
| 1105 | renderhal_surface.OsSurface.Type = MOS_GFXRES_SCRATCH; |
| 1106 | renderhal_surface.rcSrc.right = m_scratchSpaceResource.iSize;; |
| 1107 | renderhal_surface.rcSrc.bottom = 1; |
| 1108 | renderhal_surface.rcDst = renderhal_surface.rcSrc; |
| 1109 | |
| 1110 | MOS_STATUS result = renderHal->pOsInterface->pfnRegisterResource( |
| 1111 | renderHal->pOsInterface, &(renderhal_surface.OsSurface.OsResource), |
| 1112 | true, true); |
| 1113 | if (MOS_STATUS_SUCCESS != result) |
| 1114 | { |
| 1115 | return result; |
| 1116 | } |
| 1117 | |
| 1118 | RENDERHAL_SURFACE_STATE_PARAMS renderhal_surface_state_param; |
| 1119 | MOS_ZeroMemory(&renderhal_surface_state_param, |
| 1120 | sizeof(renderhal_surface_state_param)); |
| 1121 | renderhal_surface_state_param.isOutput = 1; |
| 1122 | renderhal_surface_state_param.MemObjCtl = 2; |
| 1123 | |
| 1124 | RENDERHAL_SURFACE_STATE_ENTRY *renderhal_surface_state_entry = nullptr; |
| 1125 | renderHal->pfnSetupBufferSurfaceState(renderHal, &renderhal_surface, |
| 1126 | &renderhal_surface_state_param, |
| 1127 | &renderhal_surface_state_entry); |
| 1128 | m_vfeStateParams.scratchStateOffset |
| 1129 | = renderhal_surface_state_entry->dwSurfStateOffset; |
| 1130 | |
| 1131 | renderHal->pfnBindSurfaceState(renderHal, |
| 1132 | indexOfBindingTable, |
| 1133 | FIXED_SCRATCH_SPACE_BUFFER_INDEX, |
| 1134 | renderhal_surface_state_entry); |
| 1135 | return MOS_STATUS_SUCCESS; |
| 1136 | } |
| 1137 | |
| 1138 | MOS_STATUS XRenderHal_Interface_G12_Base::FreeScratchSpaceBuffer( |
| 1139 | RENDERHAL_INTERFACE *renderHal) |
| 1140 | { |
| 1141 | MOS_GFXRES_FREE_FLAGS resFreeFlags = {0}; |
| 1142 | |
| 1143 | resFreeFlags.AssumeNotInUse = 1; |
| 1144 | |
| 1145 | if (m_scratchSpaceResource.iSize <= 0) |
| 1146 | { |
| 1147 | return MOS_STATUS_SUCCESS; // Scratch space is not allocated. No need to free resources. |
| 1148 | } |
| 1149 | |
| 1150 | renderHal->pOsInterface |
| 1151 | ->pfnFreeResourceWithFlag(renderHal->pOsInterface, |
| 1152 | &m_scratchSpaceResource, |
| 1153 | resFreeFlags.Value); |
| 1154 | renderHal->pOsInterface |
| 1155 | ->pfnResetResourceAllocationIndex(renderHal->pOsInterface, |
| 1156 | &m_scratchSpaceResource); |
| 1157 | return MOS_STATUS_SUCCESS; |
| 1158 | } |