| 1 | /* |
| 2 | * Copyright (c) 2014-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 mhw_utilities.c |
| 24 | //! \brief This modules implements utilities which are shared by both the HW interface and the state heap interface. |
| 25 | //! |
| 26 | |
| 27 | #include <math.h> |
| 28 | #include <set> |
| 29 | #include "mhw_utilities_next.h" |
| 30 | #include "mhw_state_heap.h" |
| 31 | #include "mos_interface.h" |
| 32 | #include "hal_oca_interface_next.h" |
| 33 | #include "media_skuwa_specific.h" |
| 34 | #include "mhw_itf.h" |
| 35 | #include "mhw_mi.h" |
| 36 | #include "mhw_mi_cmdpar.h" |
| 37 | #include "mhw_mi_itf.h" |
| 38 | |
| 39 | #define MHW_NS_PER_TICK_RENDER_ENGINE 80 // 80 nano seconds per tick in render engine |
| 40 | |
| 41 | static const std::set<MOS_HW_COMMAND> s_OCAResourceInfoType = { |
| 42 | MOS_MI_BATCH_BUFFER_START, |
| 43 | MOS_VEBOX_STATE, |
| 44 | MOS_VEBOX_DI_IECP, |
| 45 | MOS_VEBOX_TILING_CONVERT, |
| 46 | MOS_SFC_STATE, |
| 47 | MOS_STATE_BASE_ADDR, |
| 48 | MOS_SURFACE_STATE, |
| 49 | MOS_SURFACE_STATE_ADV, |
| 50 | MOS_MFX_PIPE_BUF_ADDR, |
| 51 | MOS_MFX_INDIRECT_OBJ_BASE_ADDR, |
| 52 | MOS_MFX_BSP_BUF_BASE_ADDR, |
| 53 | MOS_MFX_AVC_DIRECT_MODE, |
| 54 | MOS_MFX_VP8_PIC, |
| 55 | MOS_HUC_IND_OBJ_BASE_ADDR, |
| 56 | MOS_HUC_DMEM, |
| 57 | MOS_HUC_VIRTUAL_ADDR, |
| 58 | MOS_VDENC_PIPE_BUF_ADDR, |
| 59 | MOS_BINDLESS_STATELESS_SURFACE, |
| 60 | }; |
| 61 | |
| 62 | //! |
| 63 | //! \brief Set mocs index |
| 64 | //! \details Set mocs index |
| 65 | //! command buffer or indirect state |
| 66 | //! \param PMOS_INTERFACE osInterface |
| 67 | //! [in] OS interface |
| 68 | //! \param PMOS_RESOURCE resource |
| 69 | //! [in] resource |
| 70 | //! \param MHW_MOCS_PARAMS &mocsParams |
| 71 | //! [in] mocsParams |
| 72 | //! \return MOS_STATUS |
| 73 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 74 | //! |
| 75 | MOS_STATUS Mhw_SetMocsTableIndex( |
| 76 | PMOS_INTERFACE osInterface, |
| 77 | PMOS_RESOURCE resource, |
| 78 | MHW_MOCS_PARAMS &mocsParams) |
| 79 | { |
| 80 | MHW_CHK_NULL_RETURN(resource); |
| 81 | MHW_CHK_NULL_RETURN(osInterface); |
| 82 | |
| 83 | // Index is defined in bit 1:6 |
| 84 | const uint8_t indexBitFieldLow = 1; |
| 85 | const uint8_t indexMask = 0x3F; |
| 86 | uint32_t memObjCtrlStateValue = 0; |
| 87 | |
| 88 | uint32_t *data = mocsParams.mocsTableIndex; |
| 89 | uint32_t value = 0; |
| 90 | uint32_t mask = 0; |
| 91 | uint8_t bitFieldLow = mocsParams.bitFieldLow; |
| 92 | uint8_t bitFieldHigh = mocsParams.bitFieldHigh; |
| 93 | |
| 94 | if (data == nullptr) |
| 95 | { |
| 96 | MHW_NORMALMESSAGE("skip to set the mocs"); |
| 97 | return MOS_STATUS_SUCCESS; |
| 98 | } |
| 99 | |
| 100 | if (bitFieldLow > bitFieldHigh || bitFieldHigh > 31) |
| 101 | { |
| 102 | MOS_OS_ASSERTMESSAGE("invalid bit field"); |
| 103 | return MOS_STATUS_INVALID_PARAMETER; |
| 104 | } |
| 105 | |
| 106 | value = *data; |
| 107 | |
| 108 | auto memObjCtrlState = osInterface->pfnGetResourceCachePolicyMemoryObject(osInterface, resource); |
| 109 | memObjCtrlStateValue = (memObjCtrlState.DwordValue >> indexBitFieldLow) & indexMask; |
| 110 | |
| 111 | if (bitFieldHigh == 31) |
| 112 | { |
| 113 | mask = (1 << bitFieldLow) - 1; |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | mask = (~((1 << (bitFieldHigh + 1)) - 1)) | ((1 << bitFieldLow) - 1); |
| 118 | } |
| 119 | value = value & mask; |
| 120 | *data = value | (memObjCtrlStateValue << bitFieldLow); |
| 121 | |
| 122 | return MOS_STATUS_SUCCESS; |
| 123 | } |
| 124 | |
| 125 | //! |
| 126 | //! \brief Adds graphics address of a resource to the command buffer or indirect state |
| 127 | //! \details Internal MHW function to add the graphics address of resources to the |
| 128 | //! command buffer or indirect state |
| 129 | //! \param PMOS_INTERFACE pOsInterface |
| 130 | //! [in] OS interface |
| 131 | //! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 132 | //! [in] Command buffer |
| 133 | //! \param PMHW_RESOURCE_PARAMS pParams |
| 134 | //! [in] Parameters necessary to insert the graphics address |
| 135 | //! \return MOS_STATUS |
| 136 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 137 | //! |
| 138 | MOS_STATUS Mhw_AddResourceToCmd_GfxAddress( |
| 139 | PMOS_INTERFACE pOsInterface, |
| 140 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 141 | PMHW_RESOURCE_PARAMS pParams) |
| 142 | { |
| 143 | uint32_t dwAlign, dwMask; |
| 144 | uint32_t dwGfxAddrBottom, dwGfxAddrTop = 0; |
| 145 | uint64_t ui64GfxAddress, ui64GfxAddressUpperBound; |
| 146 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 147 | int32_t iAllocationIndex = 0; |
| 148 | uint32_t uiPatchOffset = 0; |
| 149 | uint8_t *pbCmdBufBase = nullptr; |
| 150 | |
| 151 | MHW_CHK_NULL_RETURN(pOsInterface); |
| 152 | MHW_CHK_NULL_RETURN(pParams); |
| 153 | MHW_CHK_NULL_RETURN(pParams->presResource); |
| 154 | MHW_CHK_NULL_RETURN(pCmdBuffer); |
| 155 | MHW_CHK_NULL_RETURN(pCmdBuffer->pCmdBase); |
| 156 | |
| 157 | pbCmdBufBase = (uint8_t*)pCmdBuffer->pCmdBase; |
| 158 | |
| 159 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource( |
| 160 | pOsInterface, |
| 161 | pParams->presResource, |
| 162 | pParams->bIsWritable ? true : false, |
| 163 | pParams->bIsWritable ? true : false)); |
| 164 | |
| 165 | dwAlign = ( 1 << pParams->dwLsbNum); |
| 166 | dwMask = (-1 << pParams->dwLsbNum); |
| 167 | |
| 168 | pParams->dwOffset = MOS_ALIGN_CEIL(pParams->dwOffset, dwAlign); |
| 169 | ui64GfxAddress = |
| 170 | pOsInterface->pfnGetResourceGfxAddress(pOsInterface, pParams->presResource) + pParams->dwOffset; |
| 171 | MHW_CHK_COND(ui64GfxAddress == 0, "Driver can't add resource with ui64GfxAddress == 0. DW location in cmd == %d.", pParams->dwLocationInCmd); |
| 172 | |
| 173 | dwGfxAddrBottom = (uint32_t)(ui64GfxAddress & 0x00000000FFFFFFFF); |
| 174 | dwGfxAddrTop = (uint32_t)((ui64GfxAddress & 0xFFFFFFFF00000000) >> 32); |
| 175 | |
| 176 | *pParams->pdwCmd = (*pParams->pdwCmd & ~dwMask) | (dwGfxAddrBottom & dwMask); |
| 177 | // this is next DW for top part of the address |
| 178 | *(pParams->pdwCmd + 1) = dwGfxAddrTop; |
| 179 | |
| 180 | Mhw_SetMocsTableIndex(pOsInterface, pParams->presResource, pParams->mocsParams); |
| 181 | |
| 182 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 183 | { |
| 184 | uint32_t evtData[4] ={(uint32_t)pParams->HwCommandType, pParams->dwLocationInCmd, pParams->dwOffset, pParams->dwSize}; |
| 185 | MOS_TraceEventExt(EVENT_RESOURCE_REGISTER, EVENT_TYPE_INFO2, evtData, sizeof(evtData), &ui64GfxAddress, sizeof(ui64GfxAddress)); |
| 186 | } |
| 187 | #endif |
| 188 | |
| 189 | if (pParams->dwOffsetInSSH > 0) |
| 190 | { |
| 191 | // Calculate the patch offset to command buffer |
| 192 | uiPatchOffset = pParams->dwOffsetInSSH + (pParams->dwLocationInCmd * sizeof(uint32_t)); |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | // Calculate the patch offset to command buffer |
| 197 | uiPatchOffset = pCmdBuffer->iOffset + (pParams->dwLocationInCmd * sizeof(uint32_t)); |
| 198 | } |
| 199 | |
| 200 | MOS_PATCH_ENTRY_PARAMS PatchEntryParams; |
| 201 | |
| 202 | iAllocationIndex = pOsInterface->pfnGetResourceAllocationIndex(pOsInterface, pParams->presResource); |
| 203 | MOS_ZeroMemory(&PatchEntryParams, sizeof(PatchEntryParams)); |
| 204 | PatchEntryParams.uiAllocationIndex = iAllocationIndex; |
| 205 | PatchEntryParams.uiResourceOffset = pParams->dwOffset; |
| 206 | PatchEntryParams.uiPatchOffset = uiPatchOffset; |
| 207 | PatchEntryParams.bWrite = pParams->bIsWritable; |
| 208 | PatchEntryParams.HwCommandType = pParams->HwCommandType; |
| 209 | PatchEntryParams.forceDwordOffset = pParams->dwSharedMocsOffset; |
| 210 | PatchEntryParams.cmdBufBase = pbCmdBufBase; |
| 211 | PatchEntryParams.presResource = pParams->presResource; |
| 212 | PatchEntryParams.cmdBuffer = pCmdBuffer; |
| 213 | |
| 214 | // Add patch entry |
| 215 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnSetPatchEntry( |
| 216 | pOsInterface, |
| 217 | &PatchEntryParams)); |
| 218 | |
| 219 | if (pParams->dwUpperBoundLocationOffsetFromCmd > 0) |
| 220 | { |
| 221 | pParams->dwSize = MOS_ALIGN_CEIL(pParams->dwSize, dwAlign); |
| 222 | |
| 223 | ui64GfxAddressUpperBound = ui64GfxAddress + pParams->dwSize; |
| 224 | dwGfxAddrBottom = (uint32_t)(ui64GfxAddressUpperBound & 0x00000000FFFFFFFF); |
| 225 | dwGfxAddrTop = (uint32_t)((ui64GfxAddressUpperBound & 0xFFFFFFFF00000000) >> 32); |
| 226 | |
| 227 | pParams->pdwCmd += pParams->dwUpperBoundLocationOffsetFromCmd; |
| 228 | *pParams->pdwCmd = (*pParams->pdwCmd & ~dwMask) | (dwGfxAddrBottom & dwMask); |
| 229 | // this is next DW for top part of the address |
| 230 | *(pParams->pdwCmd + 1) = dwGfxAddrTop; |
| 231 | |
| 232 | MOS_PATCH_ENTRY_PARAMS PatchEntryParams; |
| 233 | |
| 234 | // Calculate the patch offset to command buffer |
| 235 | uiPatchOffset += pParams->dwUpperBoundLocationOffsetFromCmd * sizeof(uint32_t); |
| 236 | |
| 237 | MOS_ZeroMemory(&PatchEntryParams, sizeof(PatchEntryParams)); |
| 238 | PatchEntryParams.uiAllocationIndex = iAllocationIndex; |
| 239 | PatchEntryParams.uiResourceOffset = pParams->dwOffset + pParams->dwSize; |
| 240 | PatchEntryParams.uiPatchOffset = uiPatchOffset; |
| 241 | PatchEntryParams.bUpperBoundPatch = true; |
| 242 | PatchEntryParams.presResource = pParams->presResource; |
| 243 | |
| 244 | // Add patch entry (CP won't register this patch point since bUpperBoundPatch = true) |
| 245 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnSetPatchEntry( |
| 246 | pOsInterface, |
| 247 | &PatchEntryParams)); |
| 248 | } |
| 249 | |
| 250 | if (s_OCAResourceInfoType.count(pParams->HwCommandType)) |
| 251 | { |
| 252 | HalOcaInterfaceNext::DumpResourceInfo(*pCmdBuffer, *pOsInterface, *pParams->presResource, pParams->HwCommandType, |
| 253 | pParams->dwLocationInCmd, pParams->dwOffset); |
| 254 | } |
| 255 | |
| 256 | return eStatus; |
| 257 | } |
| 258 | |
| 259 | //! |
| 260 | //! \brief Adds resources to a patch list |
| 261 | //! \details Internal MHW function to put resources to be added to the command |
| 262 | //! buffer or indirect state into a patch list for patch later |
| 263 | //! \param PMOS_INTERFACE pOsInterface |
| 264 | //! [in] OS interface |
| 265 | //! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 266 | //! [in] Command buffer |
| 267 | //! \param PMHW_RESOURCE_PARAMS pParams |
| 268 | //! [in] Parameters necessary to add the resource to the patch list |
| 269 | //! \return MOS_STATUS |
| 270 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 271 | //! |
| 272 | MOS_STATUS Mhw_AddResourceToCmd_PatchList( |
| 273 | PMOS_INTERFACE pOsInterface, |
| 274 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 275 | PMHW_RESOURCE_PARAMS pParams) |
| 276 | { |
| 277 | MOS_GPU_CONTEXT GpuContext; |
| 278 | int32_t iAllocationIndex; |
| 279 | uint32_t dwLsbNum, dwUpperBoundOffset; |
| 280 | uint32_t dwOffset; |
| 281 | uint32_t uiPatchOffset; |
| 282 | MOS_PATCH_ENTRY_PARAMS PatchEntryParams; |
| 283 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 284 | |
| 285 | MHW_CHK_NULL_RETURN(pOsInterface); |
| 286 | MHW_CHK_NULL_RETURN(pParams); |
| 287 | MHW_CHK_NULL_RETURN(pParams->presResource); |
| 288 | MHW_CHK_NULL_RETURN(pCmdBuffer); |
| 289 | |
| 290 | MOS_TraceEventExt(EVENT_RESOURCE_REGISTER, EVENT_TYPE_INFO2, &pParams->HwCommandType, sizeof(uint32_t), &pParams->dwLocationInCmd, sizeof(uint32_t)); |
| 291 | |
| 292 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource( |
| 293 | pOsInterface, |
| 294 | pParams->presResource, |
| 295 | pParams->bIsWritable ? true : false, |
| 296 | pParams->bIsWritable ? true : false)); |
| 297 | |
| 298 | GpuContext = pOsInterface->pfnGetGpuContext(pOsInterface); |
| 299 | iAllocationIndex = pOsInterface->pfnGetResourceAllocationIndex(pOsInterface, pParams->presResource); |
| 300 | dwLsbNum = pParams->dwLsbNum; |
| 301 | |
| 302 | // Offset and command LSB parameters |
| 303 | dwOffset = pParams->dwOffset | ((*pParams->pdwCmd) & ((1 << dwLsbNum) - 1)); |
| 304 | |
| 305 | Mhw_SetMocsTableIndex(pOsInterface, pParams->presResource, pParams->mocsParams); |
| 306 | |
| 307 | if (pParams->dwOffsetInSSH > 0) |
| 308 | { |
| 309 | // Calculate the patch offset to command buffer |
| 310 | uiPatchOffset = pParams->dwOffsetInSSH + (pParams->dwLocationInCmd * sizeof(uint32_t)); |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | // Calculate the patch offset to command buffer |
| 315 | uiPatchOffset = pCmdBuffer->iOffset + (pParams->dwLocationInCmd * sizeof(uint32_t)); |
| 316 | } |
| 317 | |
| 318 | MOS_ZeroMemory(&PatchEntryParams, sizeof(PatchEntryParams)); |
| 319 | PatchEntryParams.uiAllocationIndex = iAllocationIndex; |
| 320 | if(pParams->patchType == MOS_PATCH_TYPE_UV_Y_OFFSET || |
| 321 | pParams->patchType == MOS_PATCH_TYPE_PITCH || |
| 322 | pParams->patchType == MOS_PATCH_TYPE_V_Y_OFFSET) |
| 323 | { |
| 324 | PatchEntryParams.uiResourceOffset = *pParams->pdwCmd; |
| 325 | } |
| 326 | else |
| 327 | { |
| 328 | PatchEntryParams.uiResourceOffset = dwOffset; |
| 329 | } |
| 330 | PatchEntryParams.uiPatchOffset = uiPatchOffset; |
| 331 | PatchEntryParams.bWrite = pParams->bIsWritable; |
| 332 | PatchEntryParams.HwCommandType = pParams->HwCommandType; |
| 333 | PatchEntryParams.forceDwordOffset = pParams->dwSharedMocsOffset; |
| 334 | PatchEntryParams.cmdBufBase = (uint8_t*)pCmdBuffer->pCmdBase; |
| 335 | PatchEntryParams.presResource = pParams->presResource; |
| 336 | PatchEntryParams.patchType = pParams->patchType; |
| 337 | PatchEntryParams.shiftAmount = pParams->shiftAmount; |
| 338 | PatchEntryParams.shiftDirection = pParams->shiftDirection; |
| 339 | PatchEntryParams.offsetInSSH = pParams->dwOffsetInSSH; |
| 340 | PatchEntryParams.cmdBuffer = pCmdBuffer; |
| 341 | |
| 342 | // Add patch entry to patch the address field for this command |
| 343 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnSetPatchEntry( |
| 344 | pOsInterface, |
| 345 | &PatchEntryParams)); |
| 346 | |
| 347 | if (pParams->dwUpperBoundLocationOffsetFromCmd > 0) |
| 348 | { |
| 349 | pParams->pdwCmd += pParams->dwUpperBoundLocationOffsetFromCmd; |
| 350 | dwUpperBoundOffset = pParams->dwUpperBoundLocationOffsetFromCmd; |
| 351 | |
| 352 | // Offset and command LSB parameters |
| 353 | dwOffset = MOS_ALIGN_CEIL((pParams->dwOffset + pParams->dwSize), (1 << dwLsbNum)); |
| 354 | dwOffset = dwOffset | ((*pParams->pdwCmd) & ((1 << dwLsbNum) - 1)); |
| 355 | |
| 356 | // Calculate the patch offset to command buffer |
| 357 | uiPatchOffset += dwUpperBoundOffset * sizeof(uint32_t); |
| 358 | |
| 359 | MOS_ZeroMemory(&PatchEntryParams, sizeof(PatchEntryParams)); |
| 360 | PatchEntryParams.uiAllocationIndex = iAllocationIndex; |
| 361 | PatchEntryParams.uiResourceOffset = dwOffset; |
| 362 | PatchEntryParams.uiPatchOffset = uiPatchOffset; |
| 363 | PatchEntryParams.bUpperBoundPatch = true; |
| 364 | PatchEntryParams.presResource = pParams->presResource; |
| 365 | PatchEntryParams.patchType = pParams->patchType; |
| 366 | PatchEntryParams.shiftAmount = pParams->shiftAmount; |
| 367 | PatchEntryParams.shiftDirection = pParams->shiftDirection; |
| 368 | PatchEntryParams.offsetInSSH = pParams->dwOffsetInSSH; |
| 369 | PatchEntryParams.cmdBuffer = pCmdBuffer; |
| 370 | |
| 371 | if(dwLsbNum) |
| 372 | { |
| 373 | PatchEntryParams.shiftAmount = dwLsbNum; |
| 374 | PatchEntryParams.shiftDirection = 0; |
| 375 | } |
| 376 | |
| 377 | // Add patch entry to patch the address field for this command |
| 378 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnSetPatchEntry( |
| 379 | pOsInterface, |
| 380 | &PatchEntryParams)); |
| 381 | } |
| 382 | |
| 383 | if (s_OCAResourceInfoType.count(pParams->HwCommandType)) |
| 384 | { |
| 385 | HalOcaInterfaceNext::DumpResourceInfo(*pCmdBuffer, *pOsInterface, *pParams->presResource, pParams->HwCommandType, |
| 386 | pParams->dwLocationInCmd, pParams->dwOffset); |
| 387 | } |
| 388 | |
| 389 | return eStatus; |
| 390 | } |
| 391 | |
| 392 | //! |
| 393 | //! \brief Derive Surface Type from Surface Format |
| 394 | //! \details Internal MHW function to dervie surface type from surface format |
| 395 | //! \param uint32_t dwForceSurfaceFormat |
| 396 | //! [in] surface format information |
| 397 | //! \param PMOS_SURFACE psSurface |
| 398 | //! [in] surface which have depth information |
| 399 | //! \param uint32_t* pdwSurfaceType |
| 400 | //! [out] Surface type |
| 401 | //! \return MOS_STATUS |
| 402 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 403 | //! |
| 404 | MOS_STATUS Mhw_SurfaceFormatToType( |
| 405 | uint32_t dwForceSurfaceFormat, |
| 406 | PMOS_SURFACE psSurface, |
| 407 | uint32_t *pdwSurfaceType) |
| 408 | { |
| 409 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 410 | |
| 411 | MHW_FUNCTION_ENTER; |
| 412 | |
| 413 | MHW_CHK_NULL_RETURN(psSurface); |
| 414 | MHW_CHK_NULL_RETURN(pdwSurfaceType); |
| 415 | |
| 416 | switch ( dwForceSurfaceFormat ) |
| 417 | { |
| 418 | // 1D Surface |
| 419 | case MHW_GFX3DSTATE_SURFACEFORMAT_RAW: |
| 420 | case MHW_GFX3DSTATE_SURFACEFORMAT_R32_UINT: |
| 421 | case MHW_GFX3DSTATE_SURFACEFORMAT_L8_UNORM: |
| 422 | *pdwSurfaceType = GFX3DSTATE_SURFACETYPE_BUFFER; |
| 423 | break; |
| 424 | |
| 425 | // 2D Surface for Codec: GFX3DSTATE_SURFACEFORMAT_YCRCB_NORMAL, GFX3DSTATE_SURFACEFORMAT_YCRCB_SWAPY |
| 426 | // GFX3DSTATE_SURFACEFORMAT_R32_UNORM, GFX3DSTATE_SURFACEFORMAT_R16_UNORM, GFX3DSTATE_SURFACEFORMAT_R8_UNORM |
| 427 | |
| 428 | // 2D & 3D Surface |
| 429 | default: |
| 430 | (psSurface->dwDepth > 1) ? |
| 431 | *pdwSurfaceType = GFX3DSTATE_SURFACETYPE_3D: |
| 432 | *pdwSurfaceType = GFX3DSTATE_SURFACETYPE_2D; |
| 433 | } |
| 434 | |
| 435 | return eStatus; |
| 436 | } |
| 437 | |
| 438 | //! |
| 439 | //! \brief Send native fence sync batch buffer start command |
| 440 | //! \details Emits MI_BATCH_BUFFER_START for the native fence sync batch buffer |
| 441 | //! if the GPU context supports sync-by-command. After emitting the |
| 442 | //! command, sets bNativeFenceSyncBBAdded flag on the command buffer |
| 443 | //! to prevent double emission in subsequent prolog functions. |
| 444 | //! This function MUST be called before any other commands |
| 445 | //! (MI_FORCE_WAKEUP, watchdog, cache flush) in the command buffer. |
| 446 | //! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 447 | //! [in] Command buffer |
| 448 | //! \param PMOS_INTERFACE pOsInterface |
| 449 | //! [in] OS interface |
| 450 | //! \param std::shared_ptr<void> pMiItf |
| 451 | //! [in] MI interface |
| 452 | //! \return MOS_STATUS |
| 453 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 454 | //! |
| 455 | MOS_STATUS Mhw_SendNativeFenceSyncBBStartCmd( |
| 456 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 457 | PMOS_INTERFACE pOsInterface, |
| 458 | std::shared_ptr<void> pMiItf) |
| 459 | { |
| 460 | MHW_FUNCTION_ENTER; |
| 461 | |
| 462 | // Skip if not fully initialized |
| 463 | if (pCmdBuffer == nullptr || pOsInterface == nullptr) |
| 464 | { |
| 465 | return MOS_STATUS_SUCCESS; |
| 466 | } |
| 467 | |
| 468 | // Early out if native fence sync is not applicable |
| 469 | if (pOsInterface->pfnIsGpuSyncByCmd == nullptr || |
| 470 | !pOsInterface->pfnIsGpuSyncByCmd(pOsInterface, pOsInterface->CurrentGpuContextHandle) || |
| 471 | pCmdBuffer->syncMhwBatchBuffer == nullptr || |
| 472 | pCmdBuffer->bNativeFenceSyncBBAdded) |
| 473 | { |
| 474 | return MOS_STATUS_SUCCESS; |
| 475 | } |
| 476 | |
| 477 | // Native fence sync is needed - validate MI interface |
| 478 | std::shared_ptr<mhw::mi::Itf> miItf = std::static_pointer_cast<mhw::mi::Itf>(pMiItf); |
| 479 | MHW_CHK_NULL_RETURN(miItf); |
| 480 | |
| 481 | auto &miBatchBufferStartParams = miItf->MHW_GETPAR_F(MI_BATCH_BUFFER_START)(); |
| 482 | uint64_t gfxAddr = pOsInterface->pfnGetResourceGfxAddress(pOsInterface, &pCmdBuffer->OsResource); |
| 483 | pOsInterface->pfnOnNativeFenceSyncBBAdded(pCmdBuffer, gfxAddr); |
| 484 | miBatchBufferStartParams = {}; |
| 485 | MHW_CHK_STATUS_RETURN(miItf->MHW_ADDCMD_F(MI_BATCH_BUFFER_START)(pCmdBuffer, pCmdBuffer->syncMhwBatchBuffer)); |
| 486 | |
| 487 | pCmdBuffer->bNativeFenceSyncBBAdded = true; |
| 488 | |
| 489 | return MOS_STATUS_SUCCESS; |
| 490 | } |
| 491 | |
| 492 | //! |
| 493 | //! \brief Inserts the generic prologue command for a command buffer |
| 494 | //! \details Client facing function to add the generic prologue commands: |
| 495 | //! - the command buffer header (if necessary) |
| 496 | //! - flushes for the read/write caches (MI_FLUSH_DW or PIPE_CONTROL) |
| 497 | //! - CP prologue if necessary |
| 498 | //! \param PMOS_COMMAND_BUFFER pCmdBuffer |
| 499 | //! [in] Command buffer |
| 500 | //! \param PMHW_GENERIC_PROLOG_PARAMS pParams |
| 501 | //! [in] Parameters necessary to add the generic prologue commands |
| 502 | //! \return MOS_STATUS |
| 503 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 504 | //! |
| 505 | MOS_STATUS Mhw_SendGenericPrologCmdNext( |
| 506 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 507 | PMHW_GENERIC_PROLOG_PARAMS pParams, |
| 508 | std::shared_ptr<void> pMiItf, |
| 509 | MHW_MI_MMIOREGISTERS *pMmioReg) |
| 510 | { |
| 511 | PMOS_INTERFACE pOsInterface; |
| 512 | MEDIA_FEATURE_TABLE *pSkuTable; |
| 513 | MEDIA_WA_TABLE *pWaTable; |
| 514 | MOS_GPU_CONTEXT GpuContext; |
| 515 | MHW_PIPE_CONTROL_PARAMS PipeControlParams; |
| 516 | MHW_MI_FLUSH_DW_PARAMS FlushDwParams; |
| 517 | bool bRcsEngineUsed = false; |
| 518 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 519 | std::shared_ptr<mhw::mi::Itf> miItf = std::static_pointer_cast<mhw::mi::Itf>(pMiItf); |
| 520 | MHW_FUNCTION_ENTER; |
| 521 | |
| 522 | MHW_CHK_NULL_RETURN(pCmdBuffer); |
| 523 | MHW_CHK_NULL_RETURN(pParams); |
| 524 | MHW_CHK_NULL_RETURN(pParams->pOsInterface); |
| 525 | MHW_CHK_NULL_RETURN(miItf); |
| 526 | |
| 527 | pOsInterface = pParams->pOsInterface; |
| 528 | |
| 529 | pSkuTable = pOsInterface->pfnGetSkuTable(pOsInterface); |
| 530 | MHW_CHK_NULL_RETURN(pSkuTable); |
| 531 | pWaTable = pOsInterface->pfnGetWaTable(pOsInterface); |
| 532 | MHW_CHK_NULL_RETURN(pWaTable); |
| 533 | GpuContext = pOsInterface->pfnGetGpuContext(pOsInterface); |
| 534 | MHW_CHK_STATUS_RETURN(Mhw_SendNativeFenceSyncBBStartCmd(pCmdBuffer, pOsInterface, pMiItf)); |
| 535 | |
| 536 | if ( pOsInterface->Component != COMPONENT_CM ) |
| 537 | { |
| 538 | if ( GpuContext == MOS_GPU_CONTEXT_RENDER || |
| 539 | GpuContext == MOS_GPU_CONTEXT_RENDER2 || |
| 540 | GpuContext == MOS_GPU_CONTEXT_RENDER3 || |
| 541 | GpuContext == MOS_GPU_CONTEXT_RENDER4 || |
| 542 | GpuContext == MOS_GPU_CONTEXT_VIDEO || |
| 543 | GpuContext == MOS_GPU_CONTEXT_VIDEO2 || |
| 544 | GpuContext == MOS_GPU_CONTEXT_VIDEO3 || |
| 545 | GpuContext == MOS_GPU_CONTEXT_VIDEO4 || |
| 546 | GpuContext == MOS_GPU_CONTEXT_VDBOX2_VIDEO || |
| 547 | GpuContext == MOS_GPU_CONTEXT_VDBOX2_VIDEO2 || |
| 548 | GpuContext == MOS_GPU_CONTEXT_VDBOX2_VIDEO3 || |
| 549 | GpuContext == MOS_GPU_CONTEXT_VEBOX || |
| 550 | GpuContext == MOS_GPU_CONTEXT_VIDEO5 || |
| 551 | GpuContext == MOS_GPU_CONTEXT_VIDEO6 || |
| 552 | GpuContext == MOS_GPU_CONTEXT_VIDEO7 ) |
| 553 | { |
| 554 | MHW_CHK_STATUS_RETURN(miItf->AddWatchdogTimerStartCmd(pCmdBuffer)); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | bRcsEngineUsed = MOS_RCS_ENGINE_USED(GpuContext); |
| 559 | |
| 560 | if (bRcsEngineUsed) |
| 561 | { |
| 562 | auto& par = miItf->MHW_GETPAR_F(PIPE_CONTROL)(); |
| 563 | par = {}; |
| 564 | par.dwFlushMode = MHW_FLUSH_WRITE_CACHE; |
| 565 | MHW_CHK_STATUS_RETURN(miItf->MHW_ADDCMD_F(PIPE_CONTROL)(pCmdBuffer)); |
| 566 | |
| 567 | auto& par1 = miItf->MHW_GETPAR_F(PIPE_CONTROL)(); |
| 568 | par1 = {}; |
| 569 | par1.dwFlushMode = MHW_FLUSH_READ_CACHE; |
| 570 | par1.presDest = pParams->presStoreData; |
| 571 | par1.dwResourceOffset = pParams->dwStoreDataOffset; |
| 572 | par1.dwPostSyncOp = MHW_FLUSH_WRITE_IMMEDIATE_DATA; |
| 573 | MHW_CHK_STATUS_RETURN(miItf->MHW_ADDCMD_F(PIPE_CONTROL)(pCmdBuffer)); |
| 574 | |
| 575 | if(pCmdBuffer->Attributes.bUmdSSEUEnable) |
| 576 | { |
| 577 | MHW_MI_LOAD_REGISTER_IMM_PARAMS MiLoadRegImmParams; |
| 578 | MHW_RENDER_PWR_CLK_STATE_PARAMS params; |
| 579 | |
| 580 | MOS_ZeroMemory(¶ms, sizeof(params)); |
| 581 | params.PowerClkStateEn = true; |
| 582 | params.SCountEn = true; |
| 583 | params.SSCountEn = true; |
| 584 | params.SliceCount = pCmdBuffer->Attributes.dwNumRequestedEUSlices; |
| 585 | params.SubSliceCount = pCmdBuffer->Attributes.dwNumRequestedSubSlices; |
| 586 | params.EUmax = pCmdBuffer->Attributes.dwNumRequestedEUs; |
| 587 | params.EUmin = pCmdBuffer->Attributes.dwNumRequestedEUs; |
| 588 | |
| 589 | auto& par = miItf->MHW_GETPAR_F(MI_LOAD_REGISTER_IMM)(); |
| 590 | par = {}; |
| 591 | par.dwRegister = MHW__PWR_CLK_STATE_REG; |
| 592 | par.dwData = params.Data; |
| 593 | MHW_CHK_STATUS_RETURN(miItf->MHW_ADDCMD_F(MI_LOAD_REGISTER_IMM)(pCmdBuffer)); |
| 594 | } |
| 595 | } |
| 596 | else |
| 597 | { |
| 598 | // Send MI_FLUSH with protection bit off, which will FORCE exit protected mode for MFX |
| 599 | auto& params = miItf->MHW_GETPAR_F(MI_FLUSH_DW)(); |
| 600 | params = {}; |
| 601 | params.bVideoPipelineCacheInvalidate = true; |
| 602 | params.pOsResource = pParams->presStoreData; |
| 603 | params.dwResourceOffset = pParams->dwStoreDataOffset; |
| 604 | params.dwDataDW1 = pParams->dwStoreDataValue; |
| 605 | MHW_CHK_STATUS_RETURN(miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(pCmdBuffer)); |
| 606 | } |
| 607 | |
| 608 | MHW_CHK_STATUS_RETURN(miItf->AddProtectedProlog(pCmdBuffer)); |
| 609 | |
| 610 | if (pMmioReg) |
| 611 | { |
| 612 | HalOcaInterfaceNext::On1stLevelBBStart( |
| 613 | *pCmdBuffer, |
| 614 | (MOS_CONTEXT_HANDLE)pOsInterface->pOsContext, |
| 615 | pOsInterface->CurrentGpuContextHandle, |
| 616 | miItf, |
| 617 | *pMmioReg); |
| 618 | } |
| 619 | |
| 620 | return eStatus; |
| 621 | } |
| 622 | |
| 623 | //! |
| 624 | //! \brief Sets Nearest Mode Table for Gen75/9, across SFC and Render engine to set the sampler states |
| 625 | //! \details This function sets Coefficients for Nearest Mode |
| 626 | //! \param int32_t* iCoefs |
| 627 | //! [out] Polyphase Table to fill |
| 628 | //! \param uint32_t dwPlane |
| 629 | //! [in] Number of Polyphase tables |
| 630 | //! \param bool bBalancedFilter |
| 631 | //! [in] If Filter is balanced, set true |
| 632 | //! \return MOS_STATUS |
| 633 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 634 | //! |
| 635 | MOS_STATUS Mhw_SetNearestModeTable( |
| 636 | int32_t *iCoefs, |
| 637 | uint32_t dwPlane, |
| 638 | bool bBalancedFilter) |
| 639 | { |
| 640 | uint32_t dwNumEntries; |
| 641 | uint32_t dwOffset; |
| 642 | uint32_t i; |
| 643 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 644 | |
| 645 | MHW_FUNCTION_ENTER; |
| 646 | |
| 647 | MHW_CHK_NULL_RETURN(iCoefs); |
| 648 | |
| 649 | if (dwPlane == MHW_GENERIC_PLANE || dwPlane == MHW_Y_PLANE) |
| 650 | { |
| 651 | dwNumEntries = NUM_POLYPHASE_Y_ENTRIES; |
| 652 | dwOffset = 3; |
| 653 | } |
| 654 | else // if (dwPlane == MHW_U_PLANE || dwPlane == MHW_V_PLANE) |
| 655 | { |
| 656 | dwNumEntries = NUM_POLYPHASE_UV_ENTRIES; |
| 657 | dwOffset = 1; |
| 658 | } |
| 659 | |
| 660 | for (i = 0; i <= NUM_HW_POLYPHASE_TABLES / 2; i++) |
| 661 | { |
| 662 | iCoefs[i * dwNumEntries + dwOffset] = 0x40; |
| 663 | } |
| 664 | |
| 665 | if (bBalancedFilter) |
| 666 | { |
| 667 | // Fix offset so that filter is balanced |
| 668 | for (i = (NUM_HW_POLYPHASE_TABLES / 2 + 1); i < NUM_HW_POLYPHASE_TABLES; i++) |
| 669 | { |
| 670 | iCoefs[i * dwNumEntries + dwOffset + 1] = 0x40; |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | return eStatus; |
| 675 | } |
| 676 | |
| 677 | //! |
| 678 | //! \brief Calculate Polyphase tables for Y , across SFC and Render engine to set the sampler states |
| 679 | //! \details Calculate Polyphase tables for Y |
| 680 | //! This function uses 17 phases. |
| 681 | //! MHW_NUM_HW_POLYPHASE_TABLES reflects the phases to program coefficients in HW, and |
| 682 | //! NUM_POLYPHASE_TABLES reflects the number of phases used for internal calculations. |
| 683 | //! \param int32_t* iCoefs |
| 684 | //! [out] Polyphase Table to fill |
| 685 | //! \param float fScaleFactor |
| 686 | //! [in] Scaling factor |
| 687 | //! \param uint32_t dwPlane |
| 688 | //! [in] Plane Info |
| 689 | //! \param MOS_FORMAT srcFmt |
| 690 | //! [in] Source Format |
| 691 | //! \param float fHPStrength |
| 692 | //! [in] High Pass Strength |
| 693 | //! \param bool bUse8x8Filter |
| 694 | //! [in] is 8x8 Filter used |
| 695 | //! \param uint32_t dwHwPhase |
| 696 | //! [in] Number of phases in HW |
| 697 | //! \param float fLanczosT |
| 698 | //! [in] Lanczos factor |
| 699 | //! \return MOS_STATUS |
| 700 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 701 | //! |
| 702 | MOS_STATUS Mhw_CalcPolyphaseTablesY( |
| 703 | int32_t *iCoefs, |
| 704 | float fScaleFactor, |
| 705 | uint32_t dwPlane, |
| 706 | MOS_FORMAT srcFmt, |
| 707 | float fHPStrength, |
| 708 | bool bUse8x8Filter, |
| 709 | uint32_t dwHwPhase, |
| 710 | float fLanczosT) |
| 711 | { |
| 712 | uint32_t dwNumEntries; |
| 713 | uint32_t dwTableCoefUnit; |
| 714 | uint32_t i, j; |
| 715 | int32_t k; |
| 716 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 717 | float fPhaseCoefs[NUM_POLYPHASE_Y_ENTRIES]; |
| 718 | float fPhaseCoefsCopy[NUM_POLYPHASE_Y_ENTRIES]; |
| 719 | float fStartOffset; |
| 720 | float fHPFilter[3], fHPSum, fHPHalfPhase; // Only used for Y_PLANE |
| 721 | float fBase, fPos, fSumCoefs; |
| 722 | int32_t iCenterPixel; |
| 723 | int32_t iSumQuantCoefs; |
| 724 | |
| 725 | MHW_FUNCTION_ENTER; |
| 726 | |
| 727 | MHW_CHK_NULL_RETURN(iCoefs); |
| 728 | MHW_ASSERT((dwHwPhase == MHW_NUM_HW_POLYPHASE_TABLES) || (dwHwPhase == NUM_HW_POLYPHASE_TABLES)); |
| 729 | |
| 730 | if (dwPlane == MHW_GENERIC_PLANE || dwPlane == MHW_Y_PLANE) |
| 731 | { |
| 732 | dwNumEntries = NUM_POLYPHASE_Y_ENTRIES; |
| 733 | } |
| 734 | else // if (dwPlane == MHW_U_PLANE || dwPlane == MHW_V_PLANE) |
| 735 | { |
| 736 | dwNumEntries = NUM_POLYPHASE_UV_ENTRIES; |
| 737 | } |
| 738 | |
| 739 | MOS_ZeroMemory(fPhaseCoefs , sizeof(fPhaseCoefs)); |
| 740 | MOS_ZeroMemory(fPhaseCoefsCopy, sizeof(fPhaseCoefsCopy)); |
| 741 | |
| 742 | dwTableCoefUnit = 1 << MHW_AVS_TBL_COEF_PREC; |
| 743 | iCenterPixel = dwNumEntries / 2 - 1; |
| 744 | fStartOffset = (float)(-iCenterPixel); |
| 745 | |
| 746 | if ((IS_YUV_FORMAT(srcFmt) && |
| 747 | dwPlane != MHW_U_PLANE && |
| 748 | dwPlane != MHW_V_PLANE) || |
| 749 | ((IS_RGB32_FORMAT(srcFmt) || |
| 750 | srcFmt == Format_Y410 || |
| 751 | srcFmt == Format_AYUV) && |
| 752 | dwPlane == MHW_Y_PLANE)) |
| 753 | { |
| 754 | if (fScaleFactor < 1.0F) |
| 755 | { |
| 756 | fLanczosT = 4.0F; |
| 757 | } |
| 758 | else |
| 759 | { |
| 760 | fLanczosT = 8.0F; |
| 761 | } |
| 762 | } |
| 763 | else // if (dwPlane == MHW_U_PLANE || dwPlane == MHW_V_PLANE || (IS_RGB_FORMAT(srcFmt) && dwPlane != MHW_V_PLANE)) |
| 764 | { |
| 765 | fLanczosT = 2.0F; |
| 766 | } |
| 767 | |
| 768 | for (i = 0; i < dwHwPhase; i++) |
| 769 | { |
| 770 | fBase = fStartOffset - (float)i / (float)NUM_POLYPHASE_TABLES; |
| 771 | fSumCoefs = 0.0F; |
| 772 | |
| 773 | for (j = 0; j < dwNumEntries; j++) |
| 774 | { |
| 775 | fPos = fBase + (float)j; |
| 776 | |
| 777 | if (bUse8x8Filter) |
| 778 | { |
| 779 | fPhaseCoefs[j] = fPhaseCoefsCopy[j] = MosUtilities::MosLanczos(fPos * fScaleFactor, dwNumEntries, fLanczosT); |
| 780 | } |
| 781 | else |
| 782 | { |
| 783 | fPhaseCoefs[j] = fPhaseCoefsCopy[j] = MosUtilities::MosLanczosG(fPos * fScaleFactor, NUM_POLYPHASE_5x5_Y_ENTRIES, fLanczosT); |
| 784 | } |
| 785 | |
| 786 | fSumCoefs += fPhaseCoefs[j]; |
| 787 | } |
| 788 | |
| 789 | // Convolve with HP |
| 790 | if (dwPlane == MHW_GENERIC_PLANE || dwPlane == MHW_Y_PLANE) |
| 791 | { |
| 792 | if (i <= NUM_POLYPHASE_TABLES / 2) |
| 793 | { |
| 794 | fHPHalfPhase = (float)i / (float)NUM_POLYPHASE_TABLES; |
| 795 | } |
| 796 | else |
| 797 | { |
| 798 | fHPHalfPhase = (float)(NUM_POLYPHASE_TABLES - i) / (float)NUM_POLYPHASE_TABLES; |
| 799 | } |
| 800 | fHPFilter[0] = fHPFilter[2] = -fHPStrength * MosUtilities::MosSinc(fHPHalfPhase * MOS_PI); |
| 801 | fHPFilter[1] = 1.0F + 2.0F * fHPStrength; |
| 802 | |
| 803 | for (j = 0; j < dwNumEntries; j++) |
| 804 | { |
| 805 | fHPSum = 0.0F; |
| 806 | for (k = -1; k <= 1; k++) |
| 807 | { |
| 808 | if ((((long)j + k) >= 0) && (j + k < dwNumEntries)) |
| 809 | { |
| 810 | fHPSum += fPhaseCoefsCopy[(int32_t)j+k] * fHPFilter[k+1]; |
| 811 | } |
| 812 | fPhaseCoefs[j] = fHPSum; |
| 813 | } |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | // Normalize coefs and save |
| 818 | iSumQuantCoefs = 0; |
| 819 | for (j = 0; j < dwNumEntries; j++) |
| 820 | { |
| 821 | iCoefs[i * dwNumEntries + j] = (int32_t)floor(0.5F + (float)dwTableCoefUnit * fPhaseCoefs[j] / fSumCoefs); |
| 822 | iSumQuantCoefs += iCoefs[i * dwNumEntries + j]; |
| 823 | } |
| 824 | |
| 825 | // Fix center coef so that filter is balanced |
| 826 | if (i <= NUM_POLYPHASE_TABLES / 2) |
| 827 | { |
| 828 | iCoefs[i * dwNumEntries + iCenterPixel] -= iSumQuantCoefs - dwTableCoefUnit; |
| 829 | } |
| 830 | else |
| 831 | { |
| 832 | iCoefs[i * dwNumEntries + iCenterPixel + 1] -= iSumQuantCoefs - dwTableCoefUnit; |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | return eStatus; |
| 837 | } |
| 838 | |
| 839 | //! |
| 840 | //! \brief Calculate Polyphase tables for UV for Gen9, across SFC and Render engine to set the sampler states |
| 841 | //! \details Calculate Polyphase tables for UV |
| 842 | //! \param int32_t* piCoefs |
| 843 | //! [out] Polyphase Table to fill |
| 844 | //! \param float fLanczosT |
| 845 | //! [in] Lanczos modifying factor |
| 846 | //! \param float fInverseScaleFactor |
| 847 | //! [in] Inverse scaling factor |
| 848 | //! \return MOS_STATUS |
| 849 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 850 | //! |
| 851 | MOS_STATUS Mhw_CalcPolyphaseTablesUV( |
| 852 | int32_t *piCoefs, |
| 853 | float fLanczosT, |
| 854 | float fInverseScaleFactor) |
| 855 | { |
| 856 | int32_t phaseCount, tableCoefUnit, centerPixel, sumQuantCoefs; |
| 857 | double phaseCoefs[MHW_SCALER_UV_WIN_SIZE]; |
| 858 | double startOffset, sf, base, sumCoefs, pos; |
| 859 | int32_t minCoef[MHW_SCALER_UV_WIN_SIZE]; |
| 860 | int32_t maxCoef[MHW_SCALER_UV_WIN_SIZE]; |
| 861 | int32_t i, j; |
| 862 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 863 | |
| 864 | MHW_FUNCTION_ENTER; |
| 865 | |
| 866 | MHW_CHK_NULL_RETURN(piCoefs); |
| 867 | |
| 868 | phaseCount = MHW_TABLE_PHASE_COUNT; |
| 869 | centerPixel = (MHW_SCALER_UV_WIN_SIZE / 2) - 1; |
| 870 | startOffset = (double)(-centerPixel); |
| 871 | tableCoefUnit = 1 << MHW_TBL_COEF_PREC; |
| 872 | sf = MOS_MIN(1.0, fInverseScaleFactor); // Sf isn't used for upscaling |
| 873 | |
| 874 | MOS_ZeroMemory(piCoefs, sizeof(int32_t) * MHW_SCALER_UV_WIN_SIZE * phaseCount); |
| 875 | MOS_ZeroMemory(minCoef, sizeof(minCoef)); |
| 876 | MOS_ZeroMemory(maxCoef, sizeof(maxCoef)); |
| 877 | |
| 878 | if (sf < 1.0F) |
| 879 | { |
| 880 | fLanczosT = 2.0F; |
| 881 | } |
| 882 | |
| 883 | for(i = 0; i < phaseCount; ++i, piCoefs += MHW_SCALER_UV_WIN_SIZE) |
| 884 | { |
| 885 | // Write all |
| 886 | // Note - to shift by a half you need to a half to each phase. |
| 887 | base = startOffset - (double)(i) / (double)(phaseCount); |
| 888 | sumCoefs = 0.0; |
| 889 | |
| 890 | for(j = 0; j < MHW_SCALER_UV_WIN_SIZE; ++j) |
| 891 | { |
| 892 | pos = base + (double) j; |
| 893 | phaseCoefs[j] = MosUtilities::MosLanczos((float)(pos * sf), MHW_SCALER_UV_WIN_SIZE, fLanczosT); |
| 894 | sumCoefs += phaseCoefs[j]; |
| 895 | } |
| 896 | // Normalize coefs and save |
| 897 | for(j = 0; j < MHW_SCALER_UV_WIN_SIZE; ++j) |
| 898 | { |
| 899 | piCoefs[j] = (int32_t) floor((0.5 + (double)(tableCoefUnit) * (phaseCoefs[j] / sumCoefs))); |
| 900 | |
| 901 | //For debug purposes: |
| 902 | minCoef[j] = MOS_MIN(minCoef[j], piCoefs[j]); |
| 903 | maxCoef[j] = MOS_MAX(maxCoef[j], piCoefs[j]); |
| 904 | } |
| 905 | |
| 906 | // Recalc center coef |
| 907 | sumQuantCoefs = 0; |
| 908 | for(j = 0; j < MHW_SCALER_UV_WIN_SIZE; ++j) |
| 909 | { |
| 910 | sumQuantCoefs += piCoefs[j]; |
| 911 | } |
| 912 | |
| 913 | // Fix center coef so that filter is balanced |
| 914 | if (i <= phaseCount/2) |
| 915 | { |
| 916 | piCoefs[centerPixel] -= sumQuantCoefs - tableCoefUnit; |
| 917 | } |
| 918 | else |
| 919 | { |
| 920 | piCoefs[centerPixel + 1] -= sumQuantCoefs - tableCoefUnit; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | return eStatus; |
| 925 | } |
| 926 | |
| 927 | //! |
| 928 | //! \brief Calculate polyphase tables UV offset for Gen9, across SFC and Render engine to set the sampler states |
| 929 | //! \details Calculate Polyphase tables for UV with chroma siting for |
| 930 | //! 420 to 444 conversion |
| 931 | //! \param int32_t* piCoefs |
| 932 | //! [out] Polyphase Table to fill |
| 933 | //! \param float fLanczosT |
| 934 | //! [in] Lanczos modifying factor |
| 935 | //! \param float fInverseScaleFactor |
| 936 | //! [in] Inverse scaling factor |
| 937 | //! \param int32_t iUvPhaseOffset |
| 938 | //! [in] UV Phase Offset |
| 939 | //! \return MOS_STATUS |
| 940 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 941 | //! |
| 942 | MOS_STATUS Mhw_CalcPolyphaseTablesUVOffset( |
| 943 | int32_t *piCoefs, |
| 944 | float fLanczosT, |
| 945 | float fInverseScaleFactor, |
| 946 | int32_t iUvPhaseOffset) |
| 947 | { |
| 948 | int32_t phaseCount, tableCoefUnit, centerPixel, sumQuantCoefs; |
| 949 | double phaseCoefs[MHW_SCALER_UV_WIN_SIZE]; |
| 950 | double startOffset, sf, pos, sumCoefs, base; |
| 951 | int32_t minCoef[MHW_SCALER_UV_WIN_SIZE]; |
| 952 | int32_t maxCoef[MHW_SCALER_UV_WIN_SIZE]; |
| 953 | int32_t i, j; |
| 954 | int32_t adjusted_phase; |
| 955 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 956 | |
| 957 | MHW_FUNCTION_ENTER; |
| 958 | |
| 959 | MHW_CHK_NULL_RETURN(piCoefs); |
| 960 | |
| 961 | phaseCount = MHW_TABLE_PHASE_COUNT; |
| 962 | centerPixel = (MHW_SCALER_UV_WIN_SIZE / 2) - 1; |
| 963 | startOffset = (double)(-centerPixel + |
| 964 | (double)iUvPhaseOffset / (double)(phaseCount)); |
| 965 | tableCoefUnit = 1 << MHW_TBL_COEF_PREC; |
| 966 | |
| 967 | MOS_ZeroMemory(minCoef, sizeof(minCoef)); |
| 968 | MOS_ZeroMemory(maxCoef, sizeof(maxCoef)); |
| 969 | MOS_ZeroMemory(piCoefs, sizeof(int32_t)* MHW_SCALER_UV_WIN_SIZE * phaseCount); |
| 970 | |
| 971 | sf = MOS_MIN(1.0, fInverseScaleFactor); // Sf isn't used for upscaling |
| 972 | if (sf < 1.0) |
| 973 | { |
| 974 | fLanczosT = 3.0; |
| 975 | } |
| 976 | |
| 977 | for (i = 0; i < phaseCount; ++i, piCoefs += MHW_SCALER_UV_WIN_SIZE) |
| 978 | { |
| 979 | // Write all |
| 980 | // Note - to shift by a half you need to a half to each phase. |
| 981 | base = startOffset - (double)(i) / (double)(phaseCount); |
| 982 | sumCoefs = 0.0; |
| 983 | |
| 984 | for (j = 0; j < MHW_SCALER_UV_WIN_SIZE; ++j) |
| 985 | { |
| 986 | pos = base + (double)j; |
| 987 | phaseCoefs[j] = MosUtilities::MosLanczos((float)(pos * sf), 6/*MHW_SCALER_UV_WIN_SIZE*/, fLanczosT); |
| 988 | sumCoefs += phaseCoefs[j]; |
| 989 | } |
| 990 | // Normalize coefs and save |
| 991 | for (j = 0; j < MHW_SCALER_UV_WIN_SIZE; ++j) |
| 992 | { |
| 993 | piCoefs[j] = (int32_t)floor((0.5 + (double)(tableCoefUnit)* (phaseCoefs[j] / sumCoefs))); |
| 994 | |
| 995 | // For debug purposes: |
| 996 | minCoef[j] = MOS_MIN(minCoef[j], piCoefs[j]); |
| 997 | maxCoef[j] = MOS_MAX(maxCoef[j], piCoefs[j]); |
| 998 | } |
| 999 | |
| 1000 | // Recalc center coef |
| 1001 | sumQuantCoefs = 0; |
| 1002 | for (j = 0; j < MHW_SCALER_UV_WIN_SIZE; ++j) |
| 1003 | { |
| 1004 | sumQuantCoefs += piCoefs[j]; |
| 1005 | } |
| 1006 | |
| 1007 | // Fix center coef so that filter is balanced |
| 1008 | adjusted_phase = i - iUvPhaseOffset; |
| 1009 | if (adjusted_phase <= phaseCount / 2) |
| 1010 | { |
| 1011 | piCoefs[centerPixel] -= sumQuantCoefs - tableCoefUnit; |
| 1012 | } |
| 1013 | else // if(adjusted_phase < phaseCount) |
| 1014 | { |
| 1015 | piCoefs[centerPixel + 1] -= sumQuantCoefs - tableCoefUnit; |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | return eStatus; |
| 1020 | } |
| 1021 | |
| 1022 | //! |
| 1023 | //! \brief Allocate BB |
| 1024 | //! \details Allocated Batch Buffer |
| 1025 | //! \param PMOS_INTERFACE pOsInterface |
| 1026 | //! [in] Pointer to OS Interface |
| 1027 | //! \param PMHW_BATCH_BUFFER pBatchBuffer |
| 1028 | //! [in/out] Pointer to Batch Buffer |
| 1029 | //! \param PMHW_BATCH_BUFFER pBatchBufferList |
| 1030 | //! [in/out] If valid, represents the batch buffer list maintained by the client |
| 1031 | //! \param uint32_t dwSize |
| 1032 | //! [in] Sixe of the batch vuffer to be allocated |
| 1033 | //! \param bool notLockable |
| 1034 | //! [in] Indicate if the batch buffer not lockable, by default is false |
| 1035 | //! \param bool inSystemMem |
| 1036 | //! [in] Indicate if the batch buffer in system memory, by default is false |
| 1037 | //! \return MOS_STATUS |
| 1038 | //! true if the Batch Buffer was successfully allocated |
| 1039 | //! false if failed |
| 1040 | //! |
| 1041 | MOS_STATUS Mhw_AllocateBb( |
| 1042 | PMOS_INTERFACE pOsInterface, |
| 1043 | PMHW_BATCH_BUFFER pBatchBuffer, |
| 1044 | PMHW_BATCH_BUFFER pBatchBufferList, |
| 1045 | uint32_t dwSize, |
| 1046 | uint32_t batchCount, |
| 1047 | bool notLockable, |
| 1048 | bool inSystemMem) |
| 1049 | { |
| 1050 | MHW_FUNCTION_ENTER; |
| 1051 | |
| 1052 | MOS_RESOURCE OsResource; |
| 1053 | MOS_ALLOC_GFXRES_PARAMS AllocParams; |
| 1054 | uint32_t allocSize; |
| 1055 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1056 | |
| 1057 | MHW_CHK_NULL_RETURN(pOsInterface); |
| 1058 | MHW_CHK_NULL_RETURN(pBatchBuffer); |
| 1059 | MHW_ASSERT(!(notLockable && inSystemMem)); // Notlockable system memory doesn't make sense |
| 1060 | |
| 1061 | dwSize += 8 * MHW_CACHELINE_SIZE; |
| 1062 | dwSize = MOS_ALIGN_CEIL(dwSize, MOS_PAGE_SIZE); |
| 1063 | allocSize = dwSize * batchCount; |
| 1064 | |
| 1065 | MOS_ZeroMemory(&OsResource, sizeof(OsResource)); |
| 1066 | MOS_ZeroMemory(&AllocParams, sizeof(AllocParams)); |
| 1067 | AllocParams.Type = MOS_GFXRES_BUFFER; |
| 1068 | AllocParams.TileType = MOS_TILE_LINEAR; |
| 1069 | AllocParams.Format = Format_Buffer; |
| 1070 | AllocParams.dwBytes = allocSize; |
| 1071 | AllocParams.pBufName = "BatchBuffer"; |
| 1072 | AllocParams.ResUsageType = MOS_HW_RESOURCE_USAGE_MEDIA_BATCH_BUFFERS; |
| 1073 | AllocParams.Flags.bNotLockable = notLockable ? 1 : 0; |
| 1074 | if (notLockable) |
| 1075 | { |
| 1076 | AllocParams.dwMemType = MOS_MEMPOOL_DEVICEMEMORY; |
| 1077 | } |
| 1078 | else if (inSystemMem) |
| 1079 | { |
| 1080 | AllocParams.dwMemType = MOS_MEMPOOL_SYSTEMMEMORY; |
| 1081 | } |
| 1082 | else |
| 1083 | { |
| 1084 | AllocParams.dwMemType = MOS_MEMPOOL_VIDEOMEMORY; |
| 1085 | } |
| 1086 | |
| 1087 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnAllocateResource( |
| 1088 | pOsInterface, |
| 1089 | &AllocParams, |
| 1090 | &OsResource)); |
| 1091 | |
| 1092 | // Reset Allocation |
| 1093 | pOsInterface->pfnResetResourceAllocationIndex(pOsInterface, &OsResource); |
| 1094 | |
| 1095 | pBatchBuffer->OsResource = OsResource; |
| 1096 | pBatchBuffer->iSize = (int32_t)dwSize; |
| 1097 | pBatchBuffer->count = batchCount; |
| 1098 | pBatchBuffer->iRemaining = pBatchBuffer->iSize; |
| 1099 | pBatchBuffer->iCurrent = 0; |
| 1100 | pBatchBuffer->bLocked = false; |
| 1101 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 1102 | pBatchBuffer->iLastCurrent = 0; |
| 1103 | #endif |
| 1104 | |
| 1105 | // Link BB for synchronization |
| 1106 | pBatchBuffer->bBusy = false; |
| 1107 | pBatchBuffer->dwCmdBufId = 0; |
| 1108 | |
| 1109 | if (pBatchBufferList) |
| 1110 | { |
| 1111 | pBatchBuffer->pNext = pBatchBufferList; |
| 1112 | pBatchBufferList = pBatchBuffer; |
| 1113 | if (pBatchBuffer->pNext) |
| 1114 | { |
| 1115 | pBatchBuffer->pNext->pPrev = pBatchBuffer; |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | return eStatus; |
| 1120 | } |
| 1121 | |
| 1122 | //! |
| 1123 | //! \brief Free BB |
| 1124 | //! \details Frees Batch Buffer |
| 1125 | //! \param PMOS_INTERFACE pOsInterface |
| 1126 | //! [in] Pointer to OS Interface |
| 1127 | //! \param PMHW_BATCH_BUFFER pBatchBuffer |
| 1128 | //! [in] Pointer to Batch Buffer |
| 1129 | //! \param PMHW_BATCH_BUFFER pBatchBufferList |
| 1130 | //! [in/out] If valid, represents the batch buffer list maintained by the client |
| 1131 | //! \return MOS_STATUS |
| 1132 | //! |
| 1133 | MOS_STATUS Mhw_FreeBb( |
| 1134 | PMOS_INTERFACE pOsInterface, |
| 1135 | PMHW_BATCH_BUFFER pBatchBuffer, |
| 1136 | PMHW_BATCH_BUFFER pBatchBufferList) |
| 1137 | { |
| 1138 | MHW_FUNCTION_ENTER; |
| 1139 | |
| 1140 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1141 | |
| 1142 | MHW_CHK_NULL_RETURN(pOsInterface); |
| 1143 | MHW_CHK_NULL_RETURN(pBatchBuffer); |
| 1144 | |
| 1145 | if (pBatchBuffer->bLocked) |
| 1146 | { |
| 1147 | MHW_CHK_STATUS_RETURN(Mhw_UnlockBb(pOsInterface, pBatchBuffer, true)); |
| 1148 | } |
| 1149 | |
| 1150 | pOsInterface->pfnFreeResource(pOsInterface, &pBatchBuffer->OsResource); |
| 1151 | |
| 1152 | pBatchBuffer->dwCmdBufId = 0; |
| 1153 | pBatchBuffer->iSize = 0; |
| 1154 | pBatchBuffer->count = 0; |
| 1155 | pBatchBuffer->iCurrent = 0; |
| 1156 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 1157 | pBatchBuffer->iLastCurrent = 0; |
| 1158 | #endif |
| 1159 | |
| 1160 | if (pBatchBufferList) |
| 1161 | { |
| 1162 | // Unlink BB from synchronization list |
| 1163 | if (pBatchBuffer->pNext) |
| 1164 | { |
| 1165 | pBatchBuffer->pNext->pPrev = pBatchBuffer->pPrev; |
| 1166 | } |
| 1167 | |
| 1168 | if (pBatchBuffer->pPrev) |
| 1169 | { |
| 1170 | pBatchBuffer->pPrev->pNext = pBatchBuffer->pNext; |
| 1171 | } |
| 1172 | else |
| 1173 | { |
| 1174 | pBatchBufferList = pBatchBuffer->pNext; |
| 1175 | } |
| 1176 | |
| 1177 | pBatchBuffer->pPrev = pBatchBuffer->pNext = nullptr; |
| 1178 | } |
| 1179 | |
| 1180 | return eStatus; |
| 1181 | } |
| 1182 | |
| 1183 | //! |
| 1184 | //! \brief Lock BB |
| 1185 | //! \details Locks Batch Buffer |
| 1186 | //! \param PMOS_INTERFACE pOsInterface |
| 1187 | //! [in] Pointer to OS Interface |
| 1188 | //! \param PMHW_BATCH_BUFFER pBatchBuffer |
| 1189 | //! [in] Pointer to Batch Buffer |
| 1190 | //! \return MOS_STATUS |
| 1191 | //! |
| 1192 | MOS_STATUS Mhw_LockBb( |
| 1193 | PMOS_INTERFACE pOsInterface, |
| 1194 | PMHW_BATCH_BUFFER pBatchBuffer) |
| 1195 | { |
| 1196 | MHW_FUNCTION_ENTER; |
| 1197 | |
| 1198 | MOS_LOCK_PARAMS LockFlags; |
| 1199 | MOS_STATUS eStatus; |
| 1200 | |
| 1201 | MHW_CHK_NULL_RETURN(pOsInterface); |
| 1202 | MHW_CHK_NULL_RETURN(pBatchBuffer); |
| 1203 | |
| 1204 | eStatus = MOS_STATUS_UNKNOWN; |
| 1205 | |
| 1206 | if (pBatchBuffer->bLocked) |
| 1207 | { |
| 1208 | MHW_ASSERTMESSAGE("Batch Buffer is already locked."); |
| 1209 | return eStatus; |
| 1210 | } |
| 1211 | |
| 1212 | MOS_ZeroMemory(&LockFlags, sizeof(MOS_LOCK_PARAMS)); |
| 1213 | LockFlags.WriteOnly = 1; |
| 1214 | pBatchBuffer->pData = (uint8_t*)pOsInterface->pfnLockResource( |
| 1215 | pOsInterface, |
| 1216 | &pBatchBuffer->OsResource, |
| 1217 | &LockFlags); |
| 1218 | |
| 1219 | MHW_CHK_NULL_RETURN(pBatchBuffer->pData); |
| 1220 | |
| 1221 | pBatchBuffer->bLocked = true; |
| 1222 | eStatus = MOS_STATUS_SUCCESS; |
| 1223 | |
| 1224 | return eStatus; |
| 1225 | } |
| 1226 | |
| 1227 | //! |
| 1228 | //! \brief Unlock BB |
| 1229 | //! \details Unlocks Batch Buffer |
| 1230 | //! \param PMOS_INTERFACE pOsInterface |
| 1231 | //! [in] Pointer to OS Interface |
| 1232 | //! \param PMHW_BATCH_BUFFER pBatchBuffer |
| 1233 | //! [in] Pointer to Batch Buffer |
| 1234 | //! \param bool bResetBuffer |
| 1235 | //! [in] Reset BB information concerning current offset and size |
| 1236 | //! \return MOS_STATUS |
| 1237 | //! |
| 1238 | MOS_STATUS Mhw_UnlockBb( |
| 1239 | PMOS_INTERFACE pOsInterface, |
| 1240 | PMHW_BATCH_BUFFER pBatchBuffer, |
| 1241 | bool bResetBuffer) |
| 1242 | { |
| 1243 | MHW_FUNCTION_ENTER; |
| 1244 | |
| 1245 | MOS_STATUS eStatus; |
| 1246 | |
| 1247 | MHW_CHK_NULL_RETURN(pOsInterface); |
| 1248 | MHW_CHK_NULL_RETURN(pBatchBuffer); |
| 1249 | |
| 1250 | eStatus = MOS_STATUS_UNKNOWN; |
| 1251 | |
| 1252 | if (!pBatchBuffer->bLocked) |
| 1253 | { |
| 1254 | MHW_ASSERTMESSAGE("Batch buffer is locked."); |
| 1255 | return eStatus; |
| 1256 | } |
| 1257 | |
| 1258 | if (bResetBuffer) |
| 1259 | { |
| 1260 | pBatchBuffer->iRemaining = pBatchBuffer->iSize; |
| 1261 | pBatchBuffer->iCurrent = 0; |
| 1262 | } |
| 1263 | |
| 1264 | MHW_CHK_STATUS_RETURN(pOsInterface->pfnUnlockResource( |
| 1265 | pOsInterface, |
| 1266 | &pBatchBuffer->OsResource)); |
| 1267 | |
| 1268 | pBatchBuffer->bLocked = false; |
| 1269 | pBatchBuffer->pData = nullptr; |
| 1270 | |
| 1271 | eStatus = MOS_STATUS_SUCCESS; |
| 1272 | |
| 1273 | return eStatus; |
| 1274 | } |
| 1275 | |
| 1276 | //! |
| 1277 | //! \brief Convert To Nano Seconds |
| 1278 | //! \details Convert to Nano Seconds |
| 1279 | //! \param PVPHAL_HW_int32_tERFACE pHwInterface |
| 1280 | //! [in] Pointer to Hardware Interface Structure |
| 1281 | //! \param uint64_t iTicks |
| 1282 | //! [in] Ticks |
| 1283 | //! \param uint64_t* piNs |
| 1284 | //! [in] Nano Seconds |
| 1285 | //! \return MOS_STATUS |
| 1286 | //! |
| 1287 | MOS_STATUS Mhw_ConvertToNanoSeconds( |
| 1288 | uint64_t iTicks, |
| 1289 | uint64_t *piNs) |
| 1290 | { |
| 1291 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1292 | |
| 1293 | MHW_CHK_NULL_RETURN(piNs); |
| 1294 | |
| 1295 | *piNs = iTicks * MHW_NS_PER_TICK_RENDER_ENGINE; |
| 1296 | |
| 1297 | return eStatus; |
| 1298 | } |
| 1299 | |
| 1300 | //! |
| 1301 | //! \brief Convert Mos Tile Type to TR Mode |
| 1302 | //! \details Convert Mos Tile Type to TR Mode |
| 1303 | //! \param MOS_TILE_TYPE Type |
| 1304 | //! [in] MOS tile type |
| 1305 | //! \return uint32_t |
| 1306 | //! Tile Resouece Mode |
| 1307 | //! |
| 1308 | uint32_t Mhw_ConvertToTRMode(MOS_TILE_TYPE Type) |
| 1309 | { |
| 1310 | switch (Type) |
| 1311 | { |
| 1312 | case MOS_TILE_YS: |
| 1313 | return TRMODE_TILEYS; |
| 1314 | case MOS_TILE_YF: |
| 1315 | return TRMODE_TILEYF; |
| 1316 | default: |
| 1317 | return TRMODE_NONE; |
| 1318 | } |
| 1319 | } |