| 1 | /* |
| 2 | * Copyright (c) 2011-2018, 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 |
| 24 | //! \brief |
| 25 | //! |
| 26 | //! |
| 27 | //! \file vphal_render_vebox_g8_base.cpp |
| 28 | //! \brief Interface and structure specific for BDW (GEN8) Vebox |
| 29 | //! \details Interface and structure specific for BDW (GEN8) Vebox |
| 30 | //! |
| 31 | #include "vphal.h" |
| 32 | #include "vphal_render_vebox_base.h" |
| 33 | #include "vphal_render_vebox_g8_base.h" |
| 34 | #include "vphal_render_vebox_util_base.h" |
| 35 | #include "vpkrnheader.h" |
| 36 | |
| 37 | const char g_KernelDNDI_Str_g8[KERNEL_VEBOX_BASE_MAX][MAX_PATH] = |
| 38 | { |
| 39 | DBG_TEXT("Reserved"), |
| 40 | DBG_TEXT("UpdateDNState"), |
| 41 | }; |
| 42 | |
| 43 | //! |
| 44 | //! \brief Kernel Params |
| 45 | //! |
| 46 | const RENDERHAL_KERNEL_PARAM g_Vebox_KernelParam_g8[KERNEL_VEBOX_BASE_MAX] = |
| 47 | { |
| 48 | ///* GRF_Count |
| 49 | // | BT_Count |
| 50 | // | | Sampler_Count |
| 51 | // | | | Thread_Count |
| 52 | // | | | | GRF_Start_Register |
| 53 | // | | | | | CURBE_Length |
| 54 | // | | | | | | block_width |
| 55 | // | | | | | | | block_height |
| 56 | // | | | | | | | | blocks_x |
| 57 | // | | | | | | | | | blocks_y |
| 58 | // | | | | | | | | | |*/ |
| 59 | { 0, 0, 0, VPHAL_USE_MEDIA_THREADS_MAX, 0, 0, 0, 0, 0, 0 }, // Reserved |
| 60 | { 4, 34, 0, VPHAL_USE_MEDIA_THREADS_MAX, 0, 1, 64, 8, 1, 1 }, // UPDATEDNSTATE |
| 61 | }; |
| 62 | |
| 63 | const uint32_t dwDenoiseASDThreshold[NOISEFACTOR_MAX + 1] = { |
| 64 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
| 65 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
| 66 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
| 67 | 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, |
| 68 | 40 }; |
| 69 | |
| 70 | const uint32_t dwDenoiseHistoryDelta[NOISEFACTOR_MAX + 1] = { |
| 71 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 72 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 73 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 74 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 75 | 8 }; |
| 76 | |
| 77 | const uint32_t dwDenoiseMaximumHistory[NOISEFACTOR_MAX + 1] = { |
| 78 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 79 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 80 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 81 | 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, |
| 82 | 208 }; |
| 83 | |
| 84 | const uint32_t dwDenoiseSTADThreshold[NOISEFACTOR_MAX + 1] = { |
| 85 | 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
| 86 | 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
| 87 | 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
| 88 | 140, 140, 140, 140, 141, 141, 141, 141, 142, 142, 142, 142, 143, 143, 143, 143, |
| 89 | 144 }; |
| 90 | |
| 91 | const uint32_t dwDenoiseSCMThreshold[NOISEFACTOR_MAX + 1] = { |
| 92 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
| 93 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
| 94 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
| 95 | 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, |
| 96 | 40 }; |
| 97 | |
| 98 | const uint32_t dwDenoiseMPThreshold[NOISEFACTOR_MAX + 1] = { |
| 99 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 100 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 101 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 102 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 103 | 2 }; |
| 104 | |
| 105 | const uint32_t dwLTDThreshold[NOISEFACTOR_MAX + 1] = { |
| 106 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 107 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 108 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 109 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 110 | 8 }; |
| 111 | |
| 112 | const uint32_t dwTDThreshold[NOISEFACTOR_MAX + 1] = { |
| 113 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 114 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 115 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 116 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, |
| 117 | 14 }; |
| 118 | |
| 119 | const uint32_t dwGoodNeighborThreshold[NOISEFACTOR_MAX + 1] = { |
| 120 | 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, |
| 121 | 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, |
| 122 | 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, |
| 123 | 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, |
| 124 | 16 }; |
| 125 | |
| 126 | const uint32_t dwHistoryDeltaUV[NOISEFACTOR_MAX + 1] = { |
| 127 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 128 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 129 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 130 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 131 | 8 }; |
| 132 | |
| 133 | const uint32_t dwHistoryMaxUV[NOISEFACTOR_MAX + 1] = { |
| 134 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 135 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 136 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 137 | 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, |
| 138 | 208 }; |
| 139 | |
| 140 | const uint32_t dwLTDThresholdUV[NOISEFACTOR_MAX + 1] = { |
| 141 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 142 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 143 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 144 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 145 | 8 }; |
| 146 | |
| 147 | const uint32_t dwTDThresholdUV[NOISEFACTOR_MAX + 1] = { |
| 148 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 149 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 150 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 151 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, |
| 152 | 14 }; |
| 153 | |
| 154 | const uint32_t dwSTADThresholdUV[NOISEFACTOR_MAX + 1] = { |
| 155 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 156 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 157 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 158 | 140, 140, 140, 140, 141, 141, 141, 141, 142, 142, 142, 142, 143, 143, 143, 143, |
| 159 | 144 }; |
| 160 | |
| 161 | //! |
| 162 | //! \brief Setup Vebox_State Command parameter |
| 163 | //! \param [in] bDiVarianceEnable |
| 164 | //! Is DI/Variances report enabled |
| 165 | //! \param [in,out] pVeboxStateCmdParams |
| 166 | //! Pointer to VEBOX_STATE command parameters |
| 167 | //! \return MOS_STATUS |
| 168 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 169 | //! |
| 170 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::SetupVeboxState( |
| 171 | bool bDiVarianceEnable, |
| 172 | PMHW_VEBOX_STATE_CMD_PARAMS pVeboxStateCmdParams) |
| 173 | { |
| 174 | PMHW_VEBOX_MODE pVeboxMode; |
| 175 | MOS_STATUS eStatus; |
| 176 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 177 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 178 | |
| 179 | pVeboxMode = &pVeboxStateCmdParams->VeboxMode; |
| 180 | eStatus = MOS_STATUS_SUCCESS; |
| 181 | |
| 182 | MOS_ZeroMemory(pVeboxStateCmdParams, sizeof(*pVeboxStateCmdParams)); |
| 183 | |
| 184 | if (IS_VPHAL_OUTPUT_PIPE_VEBOX(pRenderData)) |
| 185 | { |
| 186 | // On Gen8, GlobalIECP must be enabled when the output pipe is Vebox |
| 187 | pVeboxMode->GlobalIECPEnable = true; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | pVeboxMode->GlobalIECPEnable = IsIECPEnabled(); |
| 192 | } |
| 193 | |
| 194 | pVeboxMode->DIEnable = bDiVarianceEnable; |
| 195 | |
| 196 | pVeboxMode->DNEnable = pRenderData->bDenoise; |
| 197 | pVeboxMode->DNDIFirstFrame = !pRenderData->bRefValid; |
| 198 | |
| 199 | pVeboxMode->DIOutputFrames = SetDIOutputFrame(pRenderData,pVeboxState,pVeboxMode); |
| 200 | |
| 201 | if (MEDIA_IS_SKU(pVeboxState->m_pRenderHal->pSkuTable, FtrSingleVeboxSlice)) |
| 202 | { |
| 203 | pVeboxMode->SingleSliceVeboxEnable = false; |
| 204 | } |
| 205 | else |
| 206 | { |
| 207 | { |
| 208 | pVeboxMode->SingleSliceVeboxEnable = (MEDIA_IS_SKU(pVeboxState->m_pRenderHal->pSkuTable, FtrGT3) && |
| 209 | MEDIA_IS_SKU(pVeboxState->m_pRenderHal->pSkuTable, FtrEDram)) ? false : true; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | return eStatus; |
| 214 | } |
| 215 | |
| 216 | #if VEBOX_AUTO_DENOISE_SUPPORTED |
| 217 | //! |
| 218 | //! \brief Load update kernel curbe data |
| 219 | //! \details Loads the static data of update kernel to curbe |
| 220 | //! \param [out] iCurbeOffsetOutDN |
| 221 | //! Pointer to DN kernel curbe offset |
| 222 | //! \return MOS_STATUS |
| 223 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 224 | //! |
| 225 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::LoadUpdateDenoiseKernelStaticData( |
| 226 | int32_t* iCurbeOffsetOutDN) |
| 227 | { |
| 228 | PRENDERHAL_INTERFACE pRenderHal; |
| 229 | VEBOX_STATE_UPDATE_STATIC_DATA_G8 DNStaticData; // DN Update kernelStatic parameters |
| 230 | PMHW_VEBOX_INTERFACE pVeboxInterface; |
| 231 | PVPHAL_DENOISE_PARAMS pDenoiseParams; // Denoise |
| 232 | int32_t iOffset0, iOffset1; |
| 233 | MOS_STATUS eStatus; |
| 234 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 235 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 236 | |
| 237 | pRenderHal = pVeboxState->m_pRenderHal; |
| 238 | pVeboxInterface = pVeboxState->m_pVeboxInterface; |
| 239 | eStatus = MOS_STATUS_SUCCESS; |
| 240 | |
| 241 | // init the static data |
| 242 | MOS_ZeroMemory(&DNStaticData , sizeof(VEBOX_STATE_UPDATE_STATIC_DATA_G8)); |
| 243 | |
| 244 | pDenoiseParams = m_currentSurface->pDenoiseParams; |
| 245 | VPHAL_RENDER_ASSERT(pDenoiseParams); |
| 246 | |
| 247 | // Get offset for slice0 and slice1 |
| 248 | VPHAL_RENDER_CHK_STATUS(VeboxGetStatisticsSurfaceOffsets( |
| 249 | &iOffset0, |
| 250 | &iOffset1)); |
| 251 | |
| 252 | // Load DN update kernel CURBE data |
| 253 | if (pRenderData->bAutoDenoise) |
| 254 | { |
| 255 | // set the curbe data for DN update kernel |
| 256 | DNStaticData.DW00.OffsetToSlice0 = iOffset0; |
| 257 | DNStaticData.DW01.OffsetToSlice1 = iOffset1; |
| 258 | DNStaticData.DW02.FirstFrameFlag = pVeboxState->bFirstFrame; |
| 259 | DNStaticData.DW02.NoiseLevel = pDenoiseParams->NoiseLevel; |
| 260 | DNStaticData.DW03.VeboxStatisticsSurface = BI_DN_STATISTICS_SURFACE; |
| 261 | DNStaticData.DW04.VeboxDndiStateSurface = BI_DN_VEBOX_STATE_SURFACE; |
| 262 | DNStaticData.DW05.VeboxTempSurface = BI_DN_TEMP_SURFACE; |
| 263 | |
| 264 | *iCurbeOffsetOutDN = pRenderHal->pfnLoadCurbeData( |
| 265 | pRenderHal, |
| 266 | pRenderData->pMediaState, |
| 267 | &DNStaticData, |
| 268 | sizeof(DNStaticData)); |
| 269 | |
| 270 | if (*iCurbeOffsetOutDN < 0) |
| 271 | { |
| 272 | eStatus = MOS_STATUS_UNKNOWN; |
| 273 | goto finish; |
| 274 | } |
| 275 | |
| 276 | pRenderData->iCurbeLength += sizeof(DNStaticData); |
| 277 | } |
| 278 | |
| 279 | finish: |
| 280 | return eStatus; |
| 281 | } |
| 282 | #endif |
| 283 | |
| 284 | //! |
| 285 | //! \brief Vebox get the back-end colorspace conversion matrix |
| 286 | //! \details When the i/o is A8R8G8B8 or X8R8G8B8, the transfer matrix |
| 287 | //! needs to be updated accordingly |
| 288 | //! \param [in] pSrcSurface |
| 289 | //! Pointer to input surface of Vebox |
| 290 | //! \param [in] pOutSurface |
| 291 | //! Pointer to output surface of Vebox |
| 292 | //! \return void |
| 293 | //! |
| 294 | void VPHAL_VEBOX_STATE_G8_BASE::VeboxGetBeCSCMatrix( |
| 295 | PVPHAL_SURFACE pSrcSurface, |
| 296 | PVPHAL_SURFACE pOutSurface) |
| 297 | { |
| 298 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 299 | float fTemp[3]; |
| 300 | uint32_t uiSize; |
| 301 | |
| 302 | // Get the matrix to use for conversion |
| 303 | VpHal_GetCscMatrix( |
| 304 | pSrcSurface->ColorSpace, |
| 305 | pOutSurface->ColorSpace, |
| 306 | pVeboxState->fCscCoeff, |
| 307 | pVeboxState->fCscInOffset, |
| 308 | pVeboxState->fCscOutOffset); |
| 309 | |
| 310 | // Vebox only supports A8B8G8R8 output, swap the 1st and 3rd rows of the |
| 311 | // transfer matrix for A8R8G8B8 and X8R8G8B8 |
| 312 | // This only happens when Vebox output is used |
| 313 | if ((pOutSurface->Format == Format_A8R8G8B8) || |
| 314 | (pOutSurface->Format == Format_X8R8G8B8)) |
| 315 | { |
| 316 | // Swap row 0 and row 2 of Coeff matrix and OutOffset matrix |
| 317 | uiSize = sizeof(float) * 3; |
| 318 | |
| 319 | // Copy row 0 to Temp |
| 320 | MOS_SecureMemcpy( |
| 321 | fTemp, |
| 322 | uiSize, |
| 323 | &pVeboxState->fCscCoeff[0], |
| 324 | uiSize); |
| 325 | |
| 326 | // Copy row 2 to row 0 |
| 327 | MOS_SecureMemcpy( |
| 328 | &pVeboxState->fCscCoeff[0], |
| 329 | uiSize, |
| 330 | &pVeboxState->fCscCoeff[6], |
| 331 | uiSize); |
| 332 | |
| 333 | // Copy Temp to row 2 |
| 334 | MOS_SecureMemcpy( |
| 335 | &pVeboxState->fCscCoeff[6], |
| 336 | uiSize, |
| 337 | fTemp, |
| 338 | uiSize); |
| 339 | |
| 340 | // Swap row 0 and row 2 of InOffset matrix |
| 341 | fTemp[0] = pVeboxState->fCscOutOffset[0]; |
| 342 | pVeboxState->fCscOutOffset[0] = pVeboxState->fCscOutOffset[2]; |
| 343 | pVeboxState->fCscOutOffset[2] = fTemp[0]; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | //! |
| 348 | //! \brief Setup kernels for Vebox auto mode features |
| 349 | //! \details Setup kernels that co-operate with Vebox auto mode features |
| 350 | //! \param [in] iKDTIndex |
| 351 | //! Index to Kernel Parameter Array (defined platform specific) |
| 352 | //! \return MOS_STATUS |
| 353 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 354 | //! |
| 355 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::SetupVeboxKernel( |
| 356 | int32_t iKDTIndex) |
| 357 | { |
| 358 | Kdll_CacheEntry *pCacheEntryTable; // Kernel Cache Entry table |
| 359 | Kdll_FilterEntry *pFilter; // Kernel Filter (points to base of filter array) |
| 360 | int32_t iKUID; // Kernel Unique ID (VEBOX uses combined kernels) |
| 361 | int32_t iInlineLength; // Inline data length |
| 362 | MOS_STATUS eStatus; // Return code |
| 363 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 364 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 365 | |
| 366 | // Initialize Variables |
| 367 | eStatus = MOS_STATUS_SUCCESS; |
| 368 | pFilter = &pVeboxState->SearchFilter[0]; |
| 369 | pCacheEntryTable = pVeboxState->m_pKernelDllState->ComponentKernelCache.pCacheEntries; |
| 370 | |
| 371 | // Initialize States |
| 372 | MOS_ZeroMemory(pFilter, sizeof(pVeboxState->SearchFilter)); |
| 373 | MOS_ZeroMemory(&pRenderData->KernelEntry[iKDTIndex], sizeof(Kdll_CacheEntry)); |
| 374 | |
| 375 | #if VEBOX_AUTO_DENOISE_SUPPORTED |
| 376 | if (iKDTIndex == KERNEL_UPDATEDNSTATE) |
| 377 | { |
| 378 | iKUID = IDR_VP_UpdateDNState; |
| 379 | iInlineLength = 0; // No inline data |
| 380 | pRenderData->PerfTag = VPHAL_VEBOX_UPDATE_DN_STATE; |
| 381 | } |
| 382 | else // Incorrect index to kernel parameters array |
| 383 | #endif |
| 384 | { |
| 385 | VPHAL_RENDER_ASSERTMESSAGE("Incorrect index to kernel parameters array."); |
| 386 | eStatus = MOS_STATUS_UNKNOWN; |
| 387 | goto finish; |
| 388 | } |
| 389 | |
| 390 | // Store pointer to Kernel Parameter |
| 391 | pRenderData->pKernelParam[iKDTIndex] = |
| 392 | &pVeboxState->pKernelParamTable[iKDTIndex]; |
| 393 | |
| 394 | // Set Parameters for Kernel Entry |
| 395 | pRenderData->KernelEntry[iKDTIndex].iKUID = iKUID; |
| 396 | pRenderData->KernelEntry[iKDTIndex].iKCID = -1; |
| 397 | pRenderData->KernelEntry[iKDTIndex].iFilterSize = 2; |
| 398 | pRenderData->KernelEntry[iKDTIndex].pFilter = pFilter; |
| 399 | pRenderData->KernelEntry[iKDTIndex].iSize = pCacheEntryTable[iKUID].iSize; |
| 400 | pRenderData->KernelEntry[iKDTIndex].pBinary = pCacheEntryTable[iKUID].pBinary; |
| 401 | |
| 402 | // set the Inline Data length |
| 403 | pRenderData->iInlineLength = iInlineLength; |
| 404 | |
| 405 | VPHAL_RENDER_VERBOSEMESSAGE("Vebox Kernels: %s.", g_KernelDNDI_Str_g8[iKDTIndex]); |
| 406 | |
| 407 | finish: |
| 408 | return eStatus; |
| 409 | } |
| 410 | |
| 411 | //! |
| 412 | //! \brief Check for DN only case |
| 413 | //! \details Check for DN only case |
| 414 | //! \return bool |
| 415 | //! Return true if DN only case, otherwise not |
| 416 | //! |
| 417 | bool VPHAL_VEBOX_STATE_G8_BASE::IsDNOnly() |
| 418 | { |
| 419 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 420 | |
| 421 | return pRenderData->bDenoise && |
| 422 | (!pRenderData->bDeinterlace) && |
| 423 | (!IsQueryVarianceEnabled()) && |
| 424 | (!IsIECPEnabled()); |
| 425 | } |
| 426 | |
| 427 | |
| 428 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::GetFFDISurfParams( |
| 429 | MOS_FORMAT &Format, |
| 430 | MOS_TILE_TYPE &TileType, |
| 431 | VPHAL_CSPACE &ColorSpace, |
| 432 | VPHAL_SAMPLE_TYPE &SampleType) |
| 433 | { |
| 434 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 435 | |
| 436 | if ((pRenderData->bDeinterlace && |
| 437 | !pRenderData->bProgressive)) |
| 438 | { |
| 439 | Format = Format_YUY2; |
| 440 | TileType = MOS_TILE_Y; |
| 441 | } |
| 442 | else |
| 443 | { |
| 444 | // Do not change the format for progressive case |
| 445 | Format = m_currentSurface->Format; |
| 446 | } |
| 447 | |
| 448 | ColorSpace = m_currentSurface->ColorSpace; |
| 449 | |
| 450 | // When IECP is enabled and Bob or interlaced scaling is selected for interlaced input, |
| 451 | // output surface's SampleType should be same to input's. Bob is being |
| 452 | // done in Composition part |
| 453 | if (pRenderData->bIECP && |
| 454 | ((m_currentSurface->pDeinterlaceParams && |
| 455 | m_currentSurface->pDeinterlaceParams->DIMode == DI_MODE_BOB) || |
| 456 | m_currentSurface->bInterlacedScaling)) |
| 457 | { |
| 458 | SampleType = m_currentSurface->SampleType; |
| 459 | } |
| 460 | else |
| 461 | { |
| 462 | SampleType = SAMPLE_PROGRESSIVE; |
| 463 | } |
| 464 | |
| 465 | return MOS_STATUS_SUCCESS; |
| 466 | } |
| 467 | |
| 468 | bool VPHAL_VEBOX_STATE_G8_BASE::IsFFDISurfNeeded() |
| 469 | { |
| 470 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 471 | |
| 472 | if (pRenderData->bDeinterlace || pRenderData->bIECP) |
| 473 | { |
| 474 | return true; |
| 475 | } |
| 476 | else |
| 477 | { |
| 478 | return false; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | bool VPHAL_VEBOX_STATE_G8_BASE::IsFFDNSurfNeeded() |
| 483 | { |
| 484 | return GetLastExecRenderData()->bDenoise ? true : false; |
| 485 | } |
| 486 | |
| 487 | bool VPHAL_VEBOX_STATE_G8_BASE::IsSTMMSurfNeeded() |
| 488 | { |
| 489 | |
| 490 | return (GetLastExecRenderData()->bDenoise || GetLastExecRenderData()->bDeinterlace); |
| 491 | } |
| 492 | |
| 493 | //! |
| 494 | //! \brief Vebox allocate resources |
| 495 | //! \details Allocate resources that will be used in Vebox |
| 496 | //! \return MOS_STATUS |
| 497 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 498 | //! |
| 499 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::AllocateResources() |
| 500 | { |
| 501 | MOS_STATUS eStatus; |
| 502 | PMOS_INTERFACE pOsInterface; |
| 503 | PRENDERHAL_INTERFACE pRenderHal; |
| 504 | uint32_t dwWidth; |
| 505 | uint32_t dwHeight; |
| 506 | uint32_t dwSize; |
| 507 | int32_t i; |
| 508 | bool bAllocated; |
| 509 | bool bDIEnable; |
| 510 | MHW_VEBOX_SURFACE_PARAMS MhwVeboxSurfaceParam; |
| 511 | PMHW_VEBOX_INTERFACE pVeboxInterface; |
| 512 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 513 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 514 | |
| 515 | bAllocated = false; |
| 516 | pOsInterface = pVeboxState->m_pOsInterface; |
| 517 | pRenderHal = pVeboxState->m_pRenderHal; |
| 518 | pVeboxInterface = pVeboxState->m_pVeboxInterface; |
| 519 | |
| 520 | // Allocate FFDI/IECP surfaces---------------------------------------------- |
| 521 | if (IsFFDISurfNeeded()) |
| 522 | { |
| 523 | MOS_FORMAT format; |
| 524 | MOS_TILE_TYPE TileType; |
| 525 | VPHAL_CSPACE ColorSpace; |
| 526 | VPHAL_SAMPLE_TYPE SampleType; |
| 527 | |
| 528 | VPHAL_RENDER_CHK_STATUS(GetFFDISurfParams(format, TileType, ColorSpace, SampleType)); |
| 529 | |
| 530 | for (i = 0; i < pVeboxState->iNumFFDISurfaces; i++) |
| 531 | { |
| 532 | VPHAL_RENDER_CHK_STATUS(VpHal_ReAllocateSurface( |
| 533 | pOsInterface, |
| 534 | pVeboxState->FFDISurfaces[i], |
| 535 | "VeboxFFDISurface_g8", |
| 536 | format, |
| 537 | MOS_GFXRES_2D, |
| 538 | TileType, |
| 539 | pVeboxState->m_currentSurface->dwWidth, |
| 540 | pVeboxState->m_currentSurface->dwHeight, |
| 541 | false, |
| 542 | MOS_MMC_DISABLED, |
| 543 | &bAllocated)); |
| 544 | |
| 545 | pVeboxState->FFDISurfaces[i]->SampleType = SampleType; |
| 546 | |
| 547 | // Copy rect sizes so that if input surface state needs to adjust, |
| 548 | // output surface can be adjustted also. |
| 549 | pVeboxState->FFDISurfaces[i]->rcSrc = pVeboxState->m_currentSurface->rcSrc; |
| 550 | pVeboxState->FFDISurfaces[i]->rcDst = pVeboxState->m_currentSurface->rcDst; |
| 551 | // Copy max src rect |
| 552 | pVeboxState->FFDISurfaces[i]->rcMaxSrc = pVeboxState->m_currentSurface->rcMaxSrc; |
| 553 | |
| 554 | // Set Colorspace of FFDI |
| 555 | pVeboxState->FFDISurfaces[i]->ColorSpace = ColorSpace; |
| 556 | // Copy ScalingMode, it's used in setting SFC state |
| 557 | pVeboxState->FFDISurfaces[i]->ScalingMode = pVeboxState->m_currentSurface->ScalingMode; |
| 558 | } |
| 559 | } |
| 560 | else |
| 561 | { |
| 562 | // Free FFDI surfaces |
| 563 | for (i = 0; i < pVeboxState->iNumFFDISurfaces; i++) |
| 564 | { |
| 565 | if (pVeboxState->FFDISurfaces[i]) |
| 566 | { |
| 567 | pOsInterface->pfnFreeResource( |
| 568 | pOsInterface, |
| 569 | &pVeboxState->FFDISurfaces[i]->OsResource); |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | // Allocate FFDN surfaces--------------------------------------------------- |
| 575 | if (IsFFDNSurfNeeded()) |
| 576 | { |
| 577 | for (i = 0; i < VPHAL_NUM_FFDN_SURFACES; i++) |
| 578 | { |
| 579 | VPHAL_RENDER_CHK_STATUS(VpHal_ReAllocateSurface( |
| 580 | pOsInterface, |
| 581 | pVeboxState->FFDNSurfaces[i], |
| 582 | "VeboxFFDNSurface_g8", |
| 583 | pVeboxState->m_currentSurface->Format, |
| 584 | MOS_GFXRES_2D, |
| 585 | pVeboxState->m_currentSurface->TileType, |
| 586 | pVeboxState->m_currentSurface->dwWidth, |
| 587 | pVeboxState->m_currentSurface->dwHeight, |
| 588 | false, |
| 589 | MOS_MMC_DISABLED, |
| 590 | &bAllocated)); |
| 591 | |
| 592 | // if allocated, pVeboxState->PreviousSurface is not valid for DN reference. |
| 593 | if (bAllocated) |
| 594 | { |
| 595 | // If DI is enabled, try to use app's reference if provided |
| 596 | if (pVeboxState->m_currentSurface->pBwdRef && pRenderData->bDeinterlace) |
| 597 | { |
| 598 | CopySurfaceValue(pVeboxState->m_previousSurface, pVeboxState->m_currentSurface->pBwdRef); |
| 599 | } |
| 600 | else |
| 601 | { |
| 602 | pRenderData->bRefValid = false; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | // DN's output format should be same to input |
| 607 | pVeboxState->FFDNSurfaces[i]->SampleType = |
| 608 | pVeboxState->m_currentSurface->SampleType; |
| 609 | |
| 610 | // Copy rect sizes so that if input surface state needs to adjust, |
| 611 | // output surface can be adjustted also. |
| 612 | pVeboxState->FFDNSurfaces[i]->rcSrc = pVeboxState->m_currentSurface->rcSrc; |
| 613 | pVeboxState->FFDNSurfaces[i]->rcDst = pVeboxState->m_currentSurface->rcDst; |
| 614 | // Copy max src rect |
| 615 | pVeboxState->FFDNSurfaces[i]->rcMaxSrc = pVeboxState->m_currentSurface->rcMaxSrc; |
| 616 | |
| 617 | // Set Colorspace of FFDN |
| 618 | pVeboxState->FFDNSurfaces[i]->ColorSpace = pVeboxState->m_currentSurface->ColorSpace; |
| 619 | |
| 620 | // Copy FrameID and parameters, as DN output will be used as next blt's current |
| 621 | pVeboxState->FFDNSurfaces[i]->FrameID = pVeboxState->m_currentSurface->FrameID; |
| 622 | pVeboxState->FFDNSurfaces[i]->pDenoiseParams = pVeboxState->m_currentSurface->pDenoiseParams; |
| 623 | // Copy ScalingMode, it's used in setting SFC state |
| 624 | pVeboxState->FFDNSurfaces[i]->ScalingMode = pVeboxState->m_currentSurface->ScalingMode; |
| 625 | } |
| 626 | } |
| 627 | else |
| 628 | { |
| 629 | // Free FFDN surfaces |
| 630 | for (i = 0; i < VPHAL_NUM_FFDN_SURFACES; i++) |
| 631 | { |
| 632 | if (pVeboxState->FFDNSurfaces[i]) |
| 633 | { |
| 634 | pOsInterface->pfnFreeResource( |
| 635 | pOsInterface, |
| 636 | &pVeboxState->FFDNSurfaces[i]->OsResource); |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | // Adjust the rcMaxSrc of pRenderTarget when Vebox output is enabled |
| 642 | if (IS_VPHAL_OUTPUT_PIPE_VEBOX(pRenderData)) |
| 643 | { |
| 644 | pRenderData->pRenderTarget->rcMaxSrc = pVeboxState->m_currentSurface->rcMaxSrc; |
| 645 | } |
| 646 | |
| 647 | if (IsSTMMSurfNeeded()) |
| 648 | { |
| 649 | // Allocate STMM (Spatial-Temporal Motion Measure) Surfaces------------------ |
| 650 | for (i = 0; i < VPHAL_NUM_STMM_SURFACES; i++) |
| 651 | { |
| 652 | VPHAL_RENDER_CHK_STATUS(VpHal_ReAllocateSurface( |
| 653 | pOsInterface, |
| 654 | &pVeboxState->STMMSurfaces[i], |
| 655 | "VeboxSTMMSurface_g8", |
| 656 | Format_STMM, |
| 657 | MOS_GFXRES_2D, |
| 658 | MOS_TILE_Y, |
| 659 | pVeboxState->m_currentSurface->dwWidth, |
| 660 | pVeboxState->m_currentSurface->dwHeight, |
| 661 | false, |
| 662 | MOS_MMC_DISABLED, |
| 663 | &bAllocated)); |
| 664 | |
| 665 | if (bAllocated) |
| 666 | { |
| 667 | VPHAL_RENDER_CHK_STATUS(VeboxInitSTMMHistory(i)); |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | else |
| 672 | { |
| 673 | // Free DI history buffers (STMM = Spatial-temporal motion measure) |
| 674 | for (i = 0; i < VPHAL_NUM_STMM_SURFACES; i++) |
| 675 | { |
| 676 | pOsInterface->pfnFreeResource( |
| 677 | pOsInterface, |
| 678 | &pVeboxState->STMMSurfaces[i].OsResource); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | // Allocate Statistics State Surface---------------------------------------- |
| 683 | // Width to be a aligned on 64 bytes and height is 1/4 the height |
| 684 | // Per frame information written twice per frame for 2 slices |
| 685 | // Surface to be a rectangle aligned with dwWidth to get proper dwSize |
| 686 | bDIEnable = pRenderData->bDeinterlace || IsQueryVarianceEnabled(); |
| 687 | |
| 688 | VPHAL_RENDER_CHK_STATUS(VpHal_InitVeboxSurfaceParams( |
| 689 | pVeboxState->m_currentSurface, &MhwVeboxSurfaceParam)); |
| 690 | VPHAL_RENDER_CHK_STATUS(pVeboxInterface->VeboxAdjustBoundary( |
| 691 | &MhwVeboxSurfaceParam, |
| 692 | &dwWidth, |
| 693 | &dwHeight, |
| 694 | bDIEnable)); |
| 695 | |
| 696 | dwWidth = MOS_ALIGN_CEIL(dwWidth, 64); |
| 697 | dwHeight = MOS_ROUNDUP_DIVIDE(dwHeight, 4) + |
| 698 | MOS_ROUNDUP_DIVIDE(VPHAL_VEBOX_STATISTICS_SIZE_G8 * sizeof(uint32_t), dwWidth); |
| 699 | dwSize = dwWidth * dwHeight; |
| 700 | |
| 701 | VPHAL_RENDER_CHK_STATUS(VpHal_ReAllocateSurface( |
| 702 | pOsInterface, |
| 703 | &pVeboxState->VeboxStatisticsSurface, |
| 704 | "VeboxStatisticsSurface_g8", |
| 705 | Format_Buffer, |
| 706 | MOS_GFXRES_BUFFER, |
| 707 | MOS_TILE_LINEAR, |
| 708 | dwSize, |
| 709 | 1, |
| 710 | false, |
| 711 | MOS_MMC_DISABLED, |
| 712 | &bAllocated)); |
| 713 | |
| 714 | if (bAllocated) |
| 715 | { |
| 716 | // initialize Statistics Surface |
| 717 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnFillResource( |
| 718 | pOsInterface, |
| 719 | &(pVeboxState->VeboxStatisticsSurface.OsResource), |
| 720 | dwSize, |
| 721 | 0)); |
| 722 | |
| 723 | pVeboxState->dwVeboxPerBlockStatisticsWidth = dwWidth; |
| 724 | pVeboxState->dwVeboxPerBlockStatisticsHeight = dwHeight - |
| 725 | MOS_ROUNDUP_DIVIDE(VPHAL_VEBOX_STATISTICS_SIZE_G8 * sizeof(uint32_t), dwWidth); |
| 726 | } |
| 727 | |
| 728 | #if VEBOX_AUTO_DENOISE_SUPPORTED |
| 729 | // Allocate Temp Surface for Vebox Update kernels---------------------------------------- |
| 730 | // the surface size is one Page |
| 731 | dwSize = MHW_PAGE_SIZE; |
| 732 | |
| 733 | VPHAL_RENDER_CHK_STATUS(VpHal_ReAllocateSurface( |
| 734 | pOsInterface, |
| 735 | &pVeboxState->VeboxTempSurface, |
| 736 | "VeboxTempSurface_g8", |
| 737 | Format_Buffer, |
| 738 | MOS_GFXRES_BUFFER, |
| 739 | MOS_TILE_LINEAR, |
| 740 | dwSize, |
| 741 | 1, |
| 742 | false, |
| 743 | MOS_MMC_DISABLED, |
| 744 | &bAllocated)); |
| 745 | |
| 746 | if (bAllocated) |
| 747 | { |
| 748 | // initialize Statistics Surface |
| 749 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnFillResource( |
| 750 | pOsInterface, |
| 751 | &(pVeboxState->VeboxTempSurface.OsResource), |
| 752 | dwSize, |
| 753 | 0)); |
| 754 | } |
| 755 | #endif |
| 756 | |
| 757 | finish: |
| 758 | if (eStatus != MOS_STATUS_SUCCESS) |
| 759 | { |
| 760 | pVeboxState->FreeResources(); |
| 761 | } |
| 762 | |
| 763 | return eStatus; |
| 764 | } |
| 765 | |
| 766 | //! |
| 767 | //! \brief Vebox free resources |
| 768 | //! \details Free resources that are used in Vebox |
| 769 | //! \return void |
| 770 | //! |
| 771 | void VPHAL_VEBOX_STATE_G8_BASE::FreeResources() |
| 772 | { |
| 773 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 774 | int32_t i; |
| 775 | PMOS_INTERFACE pOsInterface = pVeboxState->m_pOsInterface; |
| 776 | |
| 777 | // Free FFDI surfaces |
| 778 | for (i = 0; i < pVeboxState->iNumFFDISurfaces; i++) |
| 779 | { |
| 780 | if (pVeboxState->FFDISurfaces[i]) |
| 781 | { |
| 782 | pOsInterface->pfnFreeResource( |
| 783 | pOsInterface, |
| 784 | &pVeboxState->FFDISurfaces[i]->OsResource); |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | // Free FFDN surfaces |
| 789 | for (i = 0; i < VPHAL_NUM_FFDN_SURFACES; i++) |
| 790 | { |
| 791 | if (pVeboxState->FFDNSurfaces[i]) |
| 792 | { |
| 793 | pOsInterface->pfnFreeResource( |
| 794 | pOsInterface, |
| 795 | &pVeboxState->FFDNSurfaces[i]->OsResource); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | // Free DI history buffers (STMM = Spatial-temporal motion measure) |
| 800 | for (i = 0; i < VPHAL_NUM_STMM_SURFACES; i++) |
| 801 | { |
| 802 | pOsInterface->pfnFreeResource( |
| 803 | pOsInterface, |
| 804 | &pVeboxState->STMMSurfaces[i].OsResource); |
| 805 | } |
| 806 | |
| 807 | // Free Statistics data surface for VEBOX |
| 808 | pOsInterface->pfnFreeResource( |
| 809 | pOsInterface, |
| 810 | &pVeboxState->VeboxStatisticsSurface.OsResource); |
| 811 | |
| 812 | #if VEBOX_AUTO_DENOISE_SUPPORTED |
| 813 | // Free Temp Surface for VEBOX |
| 814 | pOsInterface->pfnFreeResource( |
| 815 | pOsInterface, |
| 816 | &pVeboxState->VeboxTempSurface.OsResource); |
| 817 | #endif |
| 818 | |
| 819 | } |
| 820 | |
| 821 | //! |
| 822 | //! \brief Setup Vebox_DI_IECP Command params for VEBOX final output surface on G75 |
| 823 | //! \details Setup Vebox_DI_IECP Command params for VEBOX final output surface on G75 |
| 824 | //! \param [in] bDiScdEnable |
| 825 | //! Is DI/Variances report enabled |
| 826 | //! \param [in,out] pVeboxDiIecpCmdParams |
| 827 | //! Pointer to VEBOX_DI_IECP command parameters |
| 828 | //! \return MOS_STATUS |
| 829 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 830 | //! |
| 831 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::SetupDiIecpStateForOutputSurf( |
| 832 | bool bDiScdEnable, |
| 833 | PMHW_VEBOX_DI_IECP_CMD_PARAMS pVeboxDiIecpCmdParams) |
| 834 | { |
| 835 | PMOS_INTERFACE pOsInterface; |
| 836 | PRENDERHAL_INTERFACE pRenderHal; |
| 837 | PMHW_VEBOX_INTERFACE pVeboxInterface; |
| 838 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 839 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 840 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 841 | |
| 842 | pOsInterface = pVeboxState->m_pOsInterface; |
| 843 | pRenderHal = pVeboxState->m_pRenderHal; |
| 844 | pVeboxInterface = pVeboxState->m_pVeboxInterface; |
| 845 | |
| 846 | // VEBOX final output surface |
| 847 | if (IS_VPHAL_OUTPUT_PIPE_VEBOX(pRenderData)) |
| 848 | { |
| 849 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 850 | pOsInterface, |
| 851 | &pRenderData->pRenderTarget->OsResource, |
| 852 | true, |
| 853 | true)); |
| 854 | |
| 855 | pVeboxDiIecpCmdParams->pOsResCurrOutput = |
| 856 | &pRenderData->pRenderTarget->OsResource; |
| 857 | pVeboxDiIecpCmdParams->dwCurrOutputSurfOffset = |
| 858 | pRenderData->pRenderTarget->dwOffset; |
| 859 | pVeboxDiIecpCmdParams->CurrOutputSurfCtrl.Value = |
| 860 | pVeboxState->DnDiSurfMemObjCtl.CurrentOutputSurfMemObjCtl; |
| 861 | } |
| 862 | else if (bDiScdEnable) |
| 863 | { |
| 864 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 865 | pOsInterface, |
| 866 | &pVeboxState->FFDISurfaces[pRenderData->iFrame1]->OsResource, |
| 867 | true, |
| 868 | true)); |
| 869 | |
| 870 | pVeboxDiIecpCmdParams->pOsResCurrOutput = |
| 871 | &pVeboxState->FFDISurfaces[pRenderData->iFrame1]->OsResource; |
| 872 | pVeboxDiIecpCmdParams->CurrOutputSurfCtrl.Value = |
| 873 | pVeboxState->DnDiSurfMemObjCtl.CurrentOutputSurfMemObjCtl; |
| 874 | |
| 875 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 876 | pOsInterface, |
| 877 | &pVeboxState->FFDISurfaces[pRenderData->iFrame0]->OsResource, |
| 878 | true, |
| 879 | true)); |
| 880 | |
| 881 | pVeboxDiIecpCmdParams->pOsResPrevOutput = |
| 882 | &pVeboxState->FFDISurfaces[pRenderData->iFrame0]->OsResource; |
| 883 | pVeboxDiIecpCmdParams->PrevOutputSurfCtrl.Value = |
| 884 | pVeboxState->DnDiSurfMemObjCtl.CurrentOutputSurfMemObjCtl; |
| 885 | } |
| 886 | else if (IsIECPEnabled()) // IECP output surface without DI |
| 887 | { |
| 888 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 889 | pOsInterface, |
| 890 | &pVeboxState->FFDISurfaces[pRenderData->iCurDNOut]->OsResource, |
| 891 | true, |
| 892 | true)); |
| 893 | |
| 894 | pVeboxDiIecpCmdParams->pOsResCurrOutput = |
| 895 | &pVeboxState->FFDISurfaces[pRenderData->iCurDNOut]->OsResource; |
| 896 | pVeboxDiIecpCmdParams->CurrOutputSurfCtrl.Value = |
| 897 | pVeboxState->DnDiSurfMemObjCtl.CurrentOutputSurfMemObjCtl; |
| 898 | } |
| 899 | |
| 900 | finish: |
| 901 | return eStatus; |
| 902 | } |
| 903 | |
| 904 | //! |
| 905 | //! \brief Setup Vebox_DI_IECP Command params for Gen75 |
| 906 | //! \details Setup Vebox_DI_IECP Command params for Gen75 |
| 907 | //! \param [in] bDiScdEnable |
| 908 | //! Is DI/Variances report enabled |
| 909 | //! \param [in,out] pVeboxDiIecpCmdParams |
| 910 | //! Pointer to VEBOX_DI_IECP command parameters |
| 911 | //! \return MOS_STATUS |
| 912 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 913 | //! |
| 914 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::SetupDiIecpState( |
| 915 | bool bDiScdEnable, |
| 916 | PMHW_VEBOX_DI_IECP_CMD_PARAMS pVeboxDiIecpCmdParams) |
| 917 | { |
| 918 | PMOS_INTERFACE pOsInterface; |
| 919 | PRENDERHAL_INTERFACE pRenderHal; |
| 920 | uint32_t dwWidth; |
| 921 | uint32_t dwHeight; |
| 922 | bool bDIEnable; |
| 923 | MOS_STATUS eStatus; |
| 924 | MHW_VEBOX_SURFACE_PARAMS MhwVeboxSurfaceParam; |
| 925 | PMHW_VEBOX_INTERFACE pVeboxInterface; |
| 926 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 927 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 928 | |
| 929 | pOsInterface = pVeboxState->m_pOsInterface; |
| 930 | pRenderHal = pVeboxState->m_pRenderHal; |
| 931 | pVeboxInterface = pVeboxState->m_pVeboxInterface; |
| 932 | MOS_ZeroMemory(pVeboxDiIecpCmdParams, sizeof(*pVeboxDiIecpCmdParams)); |
| 933 | |
| 934 | // Align dwEndingX with surface state |
| 935 | bDIEnable = pRenderData->bDeinterlace || IsQueryVarianceEnabled(); |
| 936 | VPHAL_RENDER_CHK_STATUS(VpHal_InitVeboxSurfaceParams( |
| 937 | pVeboxState->m_currentSurface, &MhwVeboxSurfaceParam)); |
| 938 | VPHAL_RENDER_CHK_STATUS(pVeboxInterface->VeboxAdjustBoundary( |
| 939 | &MhwVeboxSurfaceParam, |
| 940 | &dwWidth, |
| 941 | &dwHeight, |
| 942 | bDIEnable)); |
| 943 | |
| 944 | pVeboxDiIecpCmdParams->dwStartingX = 0; |
| 945 | pVeboxDiIecpCmdParams->dwEndingX = dwWidth - 1; |
| 946 | |
| 947 | // Input Surface |
| 948 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 949 | pOsInterface, |
| 950 | &pVeboxState->m_currentSurface->OsResource, |
| 951 | false, |
| 952 | true)); |
| 953 | |
| 954 | pVeboxDiIecpCmdParams->pOsResCurrInput = |
| 955 | &pVeboxState->m_currentSurface->OsResource; |
| 956 | pVeboxDiIecpCmdParams->dwCurrInputSurfOffset = |
| 957 | pVeboxState->m_currentSurface->dwOffset; |
| 958 | pVeboxDiIecpCmdParams->CurrInputSurfCtrl.Value = |
| 959 | pVeboxState->DnDiSurfMemObjCtl.CurrentInputSurfMemObjCtl; |
| 960 | |
| 961 | // Reference surface |
| 962 | if (pRenderData->bRefValid) |
| 963 | { |
| 964 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 965 | pOsInterface, |
| 966 | &pVeboxState->m_previousSurface->OsResource, |
| 967 | false, |
| 968 | true)); |
| 969 | |
| 970 | pVeboxDiIecpCmdParams->pOsResPrevInput = |
| 971 | &pVeboxState->m_previousSurface->OsResource; |
| 972 | pVeboxDiIecpCmdParams->dwPrevInputSurfOffset = |
| 973 | pVeboxState->m_previousSurface->dwOffset; |
| 974 | pVeboxDiIecpCmdParams->PrevInputSurfCtrl.Value = |
| 975 | pVeboxState->DnDiSurfMemObjCtl.PreviousInputSurfMemObjCtl; |
| 976 | } |
| 977 | |
| 978 | // VEBOX final output surface |
| 979 | VPHAL_RENDER_CHK_STATUS(SetupDiIecpStateForOutputSurf(bDiScdEnable, pVeboxDiIecpCmdParams)); |
| 980 | |
| 981 | // DN intermediate output surface |
| 982 | if (IsFFDNSurfNeeded()) |
| 983 | { |
| 984 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 985 | pOsInterface, |
| 986 | &pVeboxState->FFDNSurfaces[pRenderData->iCurDNOut]->OsResource, |
| 987 | true, |
| 988 | true)); |
| 989 | |
| 990 | pVeboxDiIecpCmdParams->pOsResDenoisedCurrOutput = |
| 991 | &pVeboxState->FFDNSurfaces[pRenderData->iCurDNOut]->OsResource; |
| 992 | pVeboxDiIecpCmdParams->DenoisedCurrOutputSurfCtrl.Value = |
| 993 | pVeboxState->DnDiSurfMemObjCtl.DnOutSurfMemObjCtl; |
| 994 | } |
| 995 | |
| 996 | // STMM surface |
| 997 | if (bDiScdEnable || IsSTMMSurfNeeded()) |
| 998 | { |
| 999 | // STMM in |
| 1000 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 1001 | pOsInterface, |
| 1002 | &pVeboxState->STMMSurfaces[pRenderData->iCurHistIn].OsResource, |
| 1003 | false, |
| 1004 | true)); |
| 1005 | |
| 1006 | pVeboxDiIecpCmdParams->pOsResStmmInput = |
| 1007 | &pVeboxState->STMMSurfaces[pRenderData->iCurHistIn].OsResource; |
| 1008 | pVeboxDiIecpCmdParams->StmmInputSurfCtrl.Value = |
| 1009 | pVeboxState->DnDiSurfMemObjCtl.STMMInputSurfMemObjCtl; |
| 1010 | |
| 1011 | // STMM out |
| 1012 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 1013 | pOsInterface, |
| 1014 | &pVeboxState->STMMSurfaces[pRenderData->iCurHistOut].OsResource, |
| 1015 | true, |
| 1016 | true)); |
| 1017 | |
| 1018 | pVeboxDiIecpCmdParams->pOsResStmmOutput = |
| 1019 | &pVeboxState->STMMSurfaces[pRenderData->iCurHistOut].OsResource; |
| 1020 | pVeboxDiIecpCmdParams->StmmOutputSurfCtrl.Value = |
| 1021 | pVeboxState->DnDiSurfMemObjCtl.STMMOutputSurfMemObjCtl; |
| 1022 | } |
| 1023 | |
| 1024 | // Statistics data: GNE, FMD, ACE... |
| 1025 | VPHAL_RENDER_CHK_STATUS(pOsInterface->pfnRegisterResource( |
| 1026 | pOsInterface, |
| 1027 | &pVeboxState->VeboxStatisticsSurface.OsResource, |
| 1028 | true, |
| 1029 | true)); |
| 1030 | |
| 1031 | pVeboxDiIecpCmdParams->pOsResStatisticsOutput = |
| 1032 | &pVeboxState->VeboxStatisticsSurface.OsResource; |
| 1033 | pVeboxDiIecpCmdParams->StatisticsOutputSurfCtrl.Value = |
| 1034 | pVeboxState->DnDiSurfMemObjCtl.StatisticsOutputSurfMemObjCtl; |
| 1035 | |
| 1036 | finish: |
| 1037 | return eStatus; |
| 1038 | } |
| 1039 | |
| 1040 | //! |
| 1041 | //! \brief Vebox query statistics surface layout |
| 1042 | //! \details Get Specific Layout Info like GNE Offset, size of per frame info inside |
| 1043 | //! Vebox Statistics Surface for BDW. |
| 1044 | //! \param [in] QueryType |
| 1045 | //! Query type |
| 1046 | //! \param [out] pQuery |
| 1047 | //! return layout type |
| 1048 | //! \return MOS_STATUS |
| 1049 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1050 | //! |
| 1051 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::VeboxQueryStatLayout( |
| 1052 | VEBOX_STAT_QUERY_TYPE QueryType, |
| 1053 | uint32_t* pQuery) |
| 1054 | { |
| 1055 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1056 | |
| 1057 | VPHAL_RENDER_ASSERT(pQuery); |
| 1058 | |
| 1059 | switch (QueryType) |
| 1060 | { |
| 1061 | case VEBOX_STAT_QUERY_GNE_OFFEST: |
| 1062 | *pQuery = VPHAL_VEBOX_STATISTICS_SURFACE_GNE_OFFSET_G8; |
| 1063 | break; |
| 1064 | |
| 1065 | case VEBOX_STAT_QUERY_PER_FRAME_SIZE: |
| 1066 | *pQuery = VPHAL_VEBOX_STATISTICS_PER_FRAME_SIZE_G8; |
| 1067 | break; |
| 1068 | |
| 1069 | case VEBOX_STAT_QUERY_FMD_OFFEST: |
| 1070 | *pQuery = VPHAL_VEBOX_STATISTICS_SURFACE_FMD_OFFSET_G8; |
| 1071 | break; |
| 1072 | |
| 1073 | case VEBOX_STAT_QUERY_STD_OFFEST: |
| 1074 | *pQuery = VPHAL_VEBOX_STATISTICS_SURFACE_STD_OFFSET_G8; |
| 1075 | break; |
| 1076 | |
| 1077 | default: |
| 1078 | VPHAL_RENDER_ASSERTMESSAGE("Vebox Statistics Layout Query, type ('%d') is not implemented.", QueryType); |
| 1079 | eStatus = MOS_STATUS_UNKNOWN; |
| 1080 | break; |
| 1081 | } |
| 1082 | |
| 1083 | return eStatus; |
| 1084 | } |
| 1085 | |
| 1086 | //! |
| 1087 | //! \brief Vebox get Luma default value |
| 1088 | //! \details Initialize luma denoise paramters w/ default values. |
| 1089 | //! \param [out] pLumaParams |
| 1090 | //! Pointer to Luma DN parameter |
| 1091 | //! \return void |
| 1092 | //! |
| 1093 | void VPHAL_VEBOX_STATE_G8_BASE::GetLumaDefaultValue( |
| 1094 | PVPHAL_SAMPLER_STATE_DNDI_PARAM pLumaParams) |
| 1095 | { |
| 1096 | VPHAL_RENDER_ASSERT(pLumaParams); |
| 1097 | |
| 1098 | pLumaParams->dwDenoiseASDThreshold = NOISE_ABSSUMTEMPORALDIFF_THRESHOLD_DEFAULT; |
| 1099 | pLumaParams->dwDenoiseHistoryDelta = NOISE_HISTORY_DELTA_DEFAULT; |
| 1100 | pLumaParams->dwDenoiseMaximumHistory = NOISE_HISTORY_MAX_DEFAULT; |
| 1101 | pLumaParams->dwDenoiseSTADThreshold = NOISE_SUMABSTEMPORALDIFF_THRESHOLD_DEFAULT; |
| 1102 | pLumaParams->dwDenoiseSCMThreshold = NOISE_SPATIALCOMPLEXITYMATRIX_THRESHOLD_DEFAULT; |
| 1103 | pLumaParams->dwDenoiseMPThreshold = NOISE_NUMMOTIONPIXELS_THRESHOLD_DEFAULT; |
| 1104 | pLumaParams->dwLTDThreshold = NOISE_LOWTEMPORALPIXELDIFF_THRESHOLD_DEFAULT; |
| 1105 | pLumaParams->dwTDThreshold = NOISE_TEMPORALPIXELDIFF_THRESHOLD_DEFAULT; |
| 1106 | } |
| 1107 | |
| 1108 | //! |
| 1109 | //! \brief Vebox set DN parameter |
| 1110 | //! \details Set denoise paramters for luma and chroma. |
| 1111 | //! \param [in] pSrcSurface |
| 1112 | //! Pointer to input surface of Vebox |
| 1113 | //! \param [in] pLumaParams |
| 1114 | //! Pointer to Luma DN parameter |
| 1115 | //! \param [in] pChromaParams |
| 1116 | //! Pointer to Chroma DN parameter |
| 1117 | //! \return MOS_STATUS |
| 1118 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1119 | //! |
| 1120 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::SetDNDIParams( |
| 1121 | PVPHAL_SURFACE pSrcSurface, |
| 1122 | PVPHAL_SAMPLER_STATE_DNDI_PARAM pLumaParams, |
| 1123 | PVPHAL_DNUV_PARAMS pChromaParams) |
| 1124 | { |
| 1125 | MOS_STATUS eStatus; |
| 1126 | PVPHAL_DENOISE_PARAMS pDNParams; |
| 1127 | uint32_t dwDenoiseFactor; |
| 1128 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 1129 | |
| 1130 | VPHAL_RENDER_ASSERT(pSrcSurface); |
| 1131 | VPHAL_RENDER_ASSERT(pLumaParams); |
| 1132 | VPHAL_RENDER_ASSERT(pChromaParams); |
| 1133 | VPHAL_RENDER_ASSERT(pRenderData); |
| 1134 | |
| 1135 | eStatus = MOS_STATUS_SUCCESS; |
| 1136 | pDNParams = pSrcSurface->pDenoiseParams; |
| 1137 | |
| 1138 | // Set Luma DN params |
| 1139 | if (pRenderData->bDenoise) |
| 1140 | { |
| 1141 | // Setup Denoise Params |
| 1142 | GetLumaDefaultValue(pLumaParams); |
| 1143 | |
| 1144 | // Denoise Slider case (no auto DN detect) |
| 1145 | if (!pDNParams->bAutoDetect) |
| 1146 | { |
| 1147 | dwDenoiseFactor = (uint32_t)pDNParams->fDenoiseFactor; |
| 1148 | |
| 1149 | if (dwDenoiseFactor > NOISEFACTOR_MAX) |
| 1150 | { |
| 1151 | dwDenoiseFactor = NOISEFACTOR_MAX; |
| 1152 | } |
| 1153 | |
| 1154 | pLumaParams->dwGoodNeighborThreshold = dwGoodNeighborThreshold[dwDenoiseFactor]; |
| 1155 | pLumaParams->dwDenoiseASDThreshold = dwDenoiseASDThreshold[dwDenoiseFactor]; |
| 1156 | pLumaParams->dwDenoiseHistoryDelta = dwDenoiseHistoryDelta[dwDenoiseFactor]; |
| 1157 | pLumaParams->dwDenoiseMaximumHistory = dwDenoiseMaximumHistory[dwDenoiseFactor]; |
| 1158 | pLumaParams->dwDenoiseSTADThreshold = dwDenoiseSTADThreshold[dwDenoiseFactor]; |
| 1159 | pLumaParams->dwDenoiseSCMThreshold = dwDenoiseSCMThreshold[dwDenoiseFactor]; |
| 1160 | pLumaParams->dwDenoiseMPThreshold = dwDenoiseMPThreshold[dwDenoiseFactor]; |
| 1161 | pLumaParams->dwLTDThreshold = dwLTDThreshold[dwDenoiseFactor]; |
| 1162 | pLumaParams->dwTDThreshold = dwTDThreshold[dwDenoiseFactor]; |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | // Set Chroma DN params |
| 1167 | if (pRenderData->bChromaDenoise) |
| 1168 | { |
| 1169 | // Setup Denoise Params |
| 1170 | pChromaParams->dwHistoryDeltaUV = NOISE_HISTORY_DELTA_DEFAULT; |
| 1171 | pChromaParams->dwHistoryMaxUV = NOISE_HISTORY_MAX_DEFAULT; |
| 1172 | |
| 1173 | // Denoise Slider case (no auto DN detect) |
| 1174 | if (!pDNParams->bAutoDetect) |
| 1175 | { |
| 1176 | dwDenoiseFactor = (uint32_t)pDNParams->fDenoiseFactor; |
| 1177 | |
| 1178 | if (dwDenoiseFactor > NOISEFACTOR_MAX) |
| 1179 | { |
| 1180 | dwDenoiseFactor = NOISEFACTOR_MAX; |
| 1181 | } |
| 1182 | |
| 1183 | pChromaParams->dwSTADThresholdU = dwSTADThresholdUV[dwDenoiseFactor]; |
| 1184 | pChromaParams->dwSTADThresholdV = dwSTADThresholdUV[dwDenoiseFactor]; |
| 1185 | pChromaParams->dwLTDThresholdU = dwLTDThresholdUV[dwDenoiseFactor]; |
| 1186 | pChromaParams->dwLTDThresholdV = dwLTDThresholdUV[dwDenoiseFactor]; |
| 1187 | pChromaParams->dwTDThresholdU = dwTDThresholdUV[dwDenoiseFactor]; |
| 1188 | pChromaParams->dwTDThresholdV = dwTDThresholdUV[dwDenoiseFactor]; |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | return eStatus; |
| 1193 | } |
| 1194 | |
| 1195 | //! |
| 1196 | //! \brief Setup surface states for Vebox |
| 1197 | //! \details Setup surface states for use in the current Vebox Operation |
| 1198 | //! \param [in] DiVarianceEnable |
| 1199 | //! Is DI/Variances report enabled |
| 1200 | //! \param [in,out] pVeboxSurfaceStateCmdParams |
| 1201 | //! Pointer to VEBOX_SURFACE_STATE command parameters |
| 1202 | //! \return void |
| 1203 | //! |
| 1204 | void VPHAL_VEBOX_STATE_G8_BASE::SetupSurfaceStates( |
| 1205 | bool bDiVarianceEnable, |
| 1206 | PVPHAL_VEBOX_SURFACE_STATE_CMD_PARAMS pVeboxSurfaceStateCmdParams) |
| 1207 | { |
| 1208 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 1209 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 1210 | |
| 1211 | MOS_ZeroMemory(pVeboxSurfaceStateCmdParams, |
| 1212 | sizeof(VPHAL_VEBOX_SURFACE_STATE_CMD_PARAMS)); |
| 1213 | |
| 1214 | pVeboxSurfaceStateCmdParams->pSurfInput = pVeboxState->m_currentSurface; |
| 1215 | |
| 1216 | if (IS_VPHAL_OUTPUT_PIPE_VEBOX(pRenderData)) // Vebox output pipe |
| 1217 | { |
| 1218 | pVeboxSurfaceStateCmdParams->pSurfOutput = |
| 1219 | pRenderData->pRenderTarget; |
| 1220 | } |
| 1221 | else if (bDiVarianceEnable) // DNDI, DI, DI + IECP |
| 1222 | { |
| 1223 | pVeboxSurfaceStateCmdParams->pSurfOutput = |
| 1224 | pVeboxState->FFDISurfaces[pRenderData->iFrame0]; |
| 1225 | } |
| 1226 | else if (IsIECPEnabled()) // DN + IECP or IECP only |
| 1227 | { |
| 1228 | pVeboxSurfaceStateCmdParams->pSurfOutput = |
| 1229 | pVeboxState->FFDISurfaces[pRenderData->iCurDNOut]; |
| 1230 | } |
| 1231 | else if (pRenderData->bDenoise) // DN only |
| 1232 | { |
| 1233 | pVeboxSurfaceStateCmdParams->pSurfOutput = |
| 1234 | pVeboxState->FFDNSurfaces[pRenderData->iCurDNOut]; |
| 1235 | pVeboxSurfaceStateCmdParams->pSurfDNOutput = |
| 1236 | pVeboxState->FFDNSurfaces[pRenderData->iCurDNOut]; |
| 1237 | } |
| 1238 | else |
| 1239 | { |
| 1240 | VPHAL_RENDER_ASSERTMESSAGE("Unable to determine Vebox Output Surface."); |
| 1241 | } |
| 1242 | |
| 1243 | pVeboxSurfaceStateCmdParams->pSurfDNOutput = |
| 1244 | pVeboxState->FFDNSurfaces[pRenderData->iCurDNOut]; |
| 1245 | pVeboxSurfaceStateCmdParams->bDIEnable = bDiVarianceEnable; |
| 1246 | } |
| 1247 | |
| 1248 | bool VPHAL_VEBOX_STATE_G8_BASE::UseKernelResource() |
| 1249 | { |
| 1250 | return false; // can always use driver resource in clear memory |
| 1251 | } |
| 1252 | |
| 1253 | //! |
| 1254 | //! \brief Get the output pipe on BDW |
| 1255 | //! \details There are 2 output pipes on BDW. Check which output pipe can be applied |
| 1256 | //! \param [in] pcRenderParams |
| 1257 | //! Pointer to VpHal render parameters |
| 1258 | //! \param [in] pSrcSurface |
| 1259 | //! Pointer to input surface of Vebox |
| 1260 | //! \param [out] pbCompNeeded |
| 1261 | //! Return whether composition is needed after Vebox |
| 1262 | //! \return VPHAL_OUTPUT_PIPE_MODE |
| 1263 | //! Return the output pipe mode |
| 1264 | //! |
| 1265 | VPHAL_OUTPUT_PIPE_MODE VPHAL_VEBOX_STATE_G8_BASE::GetOutputPipe( |
| 1266 | PCVPHAL_RENDER_PARAMS pcRenderParams, |
| 1267 | PVPHAL_SURFACE pSrcSurface, |
| 1268 | bool* pbCompNeeded) |
| 1269 | { |
| 1270 | VPHAL_OUTPUT_PIPE_MODE OutputPipe; |
| 1271 | bool bCompBypassFeasible; |
| 1272 | bool bOutputPipeVeboxFeasible; |
| 1273 | PVPHAL_SURFACE pTarget; |
| 1274 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 1275 | |
| 1276 | bCompBypassFeasible = IS_COMP_BYPASS_FEASIBLE(*pbCompNeeded, pcRenderParams, pSrcSurface); |
| 1277 | if (!bCompBypassFeasible) |
| 1278 | { |
| 1279 | OutputPipe = VPHAL_OUTPUT_PIPE_MODE_COMP; |
| 1280 | goto finish; |
| 1281 | } |
| 1282 | |
| 1283 | bOutputPipeVeboxFeasible = IS_OUTPUT_PIPE_VEBOX_FEASIBLE(pVeboxState, pcRenderParams, pSrcSurface); |
| 1284 | if (bOutputPipeVeboxFeasible) |
| 1285 | { |
| 1286 | OutputPipe = VPHAL_OUTPUT_PIPE_MODE_VEBOX; |
| 1287 | goto finish; |
| 1288 | } |
| 1289 | |
| 1290 | pTarget = pcRenderParams->pTarget[0]; |
| 1291 | // g75 doesn't support sfc, so set output as comp here. |
| 1292 | OutputPipe = VPHAL_OUTPUT_PIPE_MODE_COMP; |
| 1293 | |
| 1294 | // Explore the potential to still output by VEBOX and perform quick color fill in composition |
| 1295 | if (bCompBypassFeasible && |
| 1296 | pcRenderParams->pColorFillParams && |
| 1297 | pSrcSurface->rcDst.left == pTarget->rcDst.left && |
| 1298 | pSrcSurface->rcDst.top == pTarget->rcDst.top && |
| 1299 | pSrcSurface->rcDst.right == pTarget->rcDst.right && |
| 1300 | pSrcSurface->rcDst.bottom < pTarget->rcDst.bottom) |
| 1301 | { |
| 1302 | int32_t lTargetBottom; |
| 1303 | lTargetBottom = pTarget->rcDst.bottom; |
| 1304 | pTarget->rcDst.bottom = pSrcSurface->rcDst.bottom; |
| 1305 | |
| 1306 | // Check if Vebox can be the output pipe again |
| 1307 | bOutputPipeVeboxFeasible = IS_OUTPUT_PIPE_VEBOX_FEASIBLE(pVeboxState, pcRenderParams, pSrcSurface); |
| 1308 | if (bOutputPipeVeboxFeasible) |
| 1309 | { |
| 1310 | OutputPipe = VPHAL_OUTPUT_PIPE_MODE_VEBOX; |
| 1311 | pTarget->bFastColorFill = true; |
| 1312 | } |
| 1313 | pTarget->rcDst.bottom = lTargetBottom; |
| 1314 | } |
| 1315 | |
| 1316 | finish: |
| 1317 | *pbCompNeeded = (OutputPipe == VPHAL_OUTPUT_PIPE_MODE_COMP) ? true : false; |
| 1318 | return OutputPipe; |
| 1319 | } |
| 1320 | |
| 1321 | //! |
| 1322 | //! \brief Vebox is needed on BDW |
| 1323 | //! \details Check if Vebox Render operation can be applied |
| 1324 | //! \param [in] pcRenderParams |
| 1325 | //! Pointer to VpHal render parameters |
| 1326 | //! \param [in,out] pRenderPassData |
| 1327 | //! Pointer to Render data |
| 1328 | //! \return bool |
| 1329 | //! Return true if Vebox is needed, otherwise false |
| 1330 | //! |
| 1331 | bool VPHAL_VEBOX_STATE_G8_BASE::IsNeeded( |
| 1332 | PCVPHAL_RENDER_PARAMS pcRenderParams, |
| 1333 | RenderpassData *pRenderPassData) |
| 1334 | { |
| 1335 | PVPHAL_VEBOX_RENDER_DATA pRenderData; |
| 1336 | PRENDERHAL_INTERFACE pRenderHal; |
| 1337 | PVPHAL_SURFACE pRenderTarget; |
| 1338 | bool bVeboxNeeded; |
| 1339 | PMOS_INTERFACE pOsInterface; |
| 1340 | MOS_STATUS eStatus; |
| 1341 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 1342 | PVPHAL_SURFACE pSrcSurface; |
| 1343 | |
| 1344 | bVeboxNeeded = false; |
| 1345 | VPHAL_RENDER_CHK_NULL(pVeboxState->m_pRenderHal); |
| 1346 | VPHAL_RENDER_CHK_NULL(pVeboxState->m_pOsInterface); |
| 1347 | |
| 1348 | pRenderHal = pVeboxState->m_pRenderHal; |
| 1349 | pOsInterface = pVeboxState->m_pOsInterface; |
| 1350 | |
| 1351 | pRenderTarget = pcRenderParams->pTarget[0]; |
| 1352 | pRenderData = pVeboxState->GetLastExecRenderData(); |
| 1353 | pSrcSurface = pRenderPassData->pSrcSurface; |
| 1354 | |
| 1355 | VPHAL_RENDER_CHK_NULL(pSrcSurface); |
| 1356 | |
| 1357 | // Check whether VEBOX is available |
| 1358 | // VTd doesn't support VEBOX |
| 1359 | if (!MEDIA_IS_SKU(pVeboxState->m_pSkuTable, FtrVERing)) |
| 1360 | { |
| 1361 | pRenderPassData->bCompNeeded = true; |
| 1362 | goto finish; |
| 1363 | } |
| 1364 | |
| 1365 | // Check if the Surface size is greater than 64x16 which is the minimum Width and Height VEBOX can handle |
| 1366 | if (pSrcSurface->dwWidth < MHW_VEBOX_MIN_WIDTH || pSrcSurface->dwHeight < MHW_VEBOX_MIN_HEIGHT) |
| 1367 | { |
| 1368 | pRenderPassData->bCompNeeded = true; |
| 1369 | goto finish; |
| 1370 | } |
| 1371 | |
| 1372 | pRenderData->Init(); |
| 1373 | |
| 1374 | // Determine the output pipe before setting the rendering flags for Vebox |
| 1375 | SET_VPHAL_OUTPUT_PIPE( |
| 1376 | pRenderData, |
| 1377 | GetOutputPipe( |
| 1378 | pcRenderParams, |
| 1379 | pSrcSurface, |
| 1380 | &pRenderPassData->bCompNeeded)); |
| 1381 | |
| 1382 | // Update execution state based on current and past events such as the |
| 1383 | // # of future and past frames available. |
| 1384 | pVeboxState->UpdateVeboxExecutionState( |
| 1385 | pSrcSurface, |
| 1386 | pRenderData->OutputPipe); |
| 1387 | |
| 1388 | // Check if Vebox can be used to process the surface |
| 1389 | if (pVeboxState->IsFormatSupported(pSrcSurface)) |
| 1390 | { |
| 1391 | // Setup Rendering Flags for Vebox |
| 1392 | VeboxSetRenderingFlags( |
| 1393 | pSrcSurface, |
| 1394 | pRenderTarget); |
| 1395 | |
| 1396 | // Vebox is needed if Vebox isn't bypassed |
| 1397 | bVeboxNeeded = !pRenderData->bVeboxBypass; |
| 1398 | } |
| 1399 | |
| 1400 | // Save Alpha passed by App to be used in Vebox |
| 1401 | if (bVeboxNeeded && IS_VPHAL_OUTPUT_PIPE_VEBOX(pRenderData)) |
| 1402 | { |
| 1403 | pRenderData->pAlphaParams = pcRenderParams->pCompAlpha; |
| 1404 | } |
| 1405 | |
| 1406 | finish: |
| 1407 | return bVeboxNeeded; |
| 1408 | } |
| 1409 | |
| 1410 | #if VEBOX_AUTO_DENOISE_SUPPORTED |
| 1411 | //! |
| 1412 | //! \brief Setup surface states for Denoise |
| 1413 | //! \details Setup Surface State for Vebox States Auto DN kernel |
| 1414 | //! \return MOS_STATUS |
| 1415 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1416 | //! |
| 1417 | MOS_STATUS VPHAL_VEBOX_STATE_G8_BASE::SetupSurfaceStatesForDenoise() |
| 1418 | { |
| 1419 | PRENDERHAL_INTERFACE pRenderHal; |
| 1420 | PMOS_INTERFACE pOsInterface; |
| 1421 | RENDERHAL_SURFACE_STATE_PARAMS SurfaceParams; |
| 1422 | MOS_STATUS eStatus; |
| 1423 | bool bUseKernelResource; |
| 1424 | const MHW_VEBOX_HEAP *pVeboxHeap = nullptr; |
| 1425 | PVPHAL_VEBOX_STATE_G8_BASE pVeboxState = this; |
| 1426 | PVPHAL_VEBOX_RENDER_DATA pRenderData = GetLastExecRenderData(); |
| 1427 | |
| 1428 | eStatus = MOS_STATUS_SUCCESS; |
| 1429 | pRenderHal = pVeboxState->m_pRenderHal; |
| 1430 | pOsInterface = pVeboxState->m_pOsInterface; |
| 1431 | VPHAL_RENDER_CHK_STATUS(pVeboxState->m_pVeboxInterface->GetVeboxHeapInfo( |
| 1432 | &pVeboxHeap)); |
| 1433 | VPHAL_RENDER_CHK_NULL(pVeboxHeap); |
| 1434 | |
| 1435 | bUseKernelResource = UseKernelResource(); |
| 1436 | |
| 1437 | MOS_ZeroMemory(&SurfaceParams, sizeof(SurfaceParams)); |
| 1438 | MOS_ZeroMemory(&pVeboxState->VeboxHeapResource, sizeof(VPHAL_SURFACE)); |
| 1439 | MOS_ZeroMemory(&pVeboxState->tmpResource, sizeof(VPHAL_SURFACE)); |
| 1440 | |
| 1441 | // Treat the 1D buffer as 2D surface |
| 1442 | // VEBox State Surface |
| 1443 | pVeboxState->VeboxHeapResource.Format = Format_L8; |
| 1444 | pVeboxState->VeboxHeapResource.dwWidth = SECURE_BLOCK_COPY_KERNEL_SURF_WIDTH; // Hard code for secure Block Copy kernel |
| 1445 | pVeboxState->VeboxHeapResource.dwPitch = SECURE_BLOCK_COPY_KERNEL_SURF_WIDTH; // Hard code for secure Block Copy kernel |
| 1446 | pVeboxState->VeboxHeapResource.dwHeight = |
| 1447 | MOS_ROUNDUP_DIVIDE(pVeboxHeap->uiInstanceSize, SECURE_BLOCK_COPY_KERNEL_SURF_WIDTH); |
| 1448 | pVeboxState->VeboxHeapResource.dwOffset = |
| 1449 | pVeboxHeap->uiInstanceSize * |
| 1450 | pVeboxHeap->uiCurState; |
| 1451 | pVeboxState->VeboxHeapResource.TileType = MOS_TILE_LINEAR; |
| 1452 | pVeboxState->VeboxHeapResource.OsResource = bUseKernelResource ? |
| 1453 | pVeboxHeap->KernelResource : |
| 1454 | pVeboxHeap->DriverResource; |
| 1455 | |
| 1456 | // Temp Surface: for Noise Level History |
| 1457 | pVeboxState->tmpResource.Format = Format_L8; |
| 1458 | pVeboxState->tmpResource.dwWidth = SECURE_BLOCK_COPY_KERNEL_SURF_WIDTH; // Hard code for secure Block Copy kernel |
| 1459 | pVeboxState->tmpResource.dwPitch = SECURE_BLOCK_COPY_KERNEL_SURF_WIDTH; // Hard code for secure Block Copy kernel |
| 1460 | pVeboxState->tmpResource.dwHeight = |
| 1461 | MOS_ROUNDUP_DIVIDE(MHW_PAGE_SIZE, SECURE_BLOCK_COPY_KERNEL_SURF_WIDTH); |
| 1462 | pVeboxState->tmpResource.dwOffset = 0; |
| 1463 | pVeboxState->tmpResource.TileType = MOS_TILE_LINEAR; |
| 1464 | pVeboxState->tmpResource.OsResource = pVeboxState->VeboxTempSurface.OsResource; |
| 1465 | |
| 1466 | // Statistics Surface----------------------------------------------------------- |
| 1467 | VPHAL_RENDER_CHK_STATUS(VpHal_CommonSetBufferSurfaceForHwAccess( |
| 1468 | pRenderHal, |
| 1469 | &pVeboxState->VeboxStatisticsSurface, |
| 1470 | &pVeboxState->RenderHalVeboxStatisticsSurface, |
| 1471 | nullptr, |
| 1472 | pRenderData->iBindingTable, |
| 1473 | BI_DN_STATISTICS_SURFACE, |
| 1474 | false)); |
| 1475 | |
| 1476 | // VEBox State Surface----------------------------------------------------------- |
| 1477 | MOS_ZeroMemory(&SurfaceParams, sizeof(SurfaceParams)); |
| 1478 | |
| 1479 | SurfaceParams.Type = pRenderHal->SurfaceTypeDefault; |
| 1480 | SurfaceParams.isOutput = true; |
| 1481 | SurfaceParams.bWidthInDword_Y = true; |
| 1482 | SurfaceParams.bWidthInDword_UV = true; |
| 1483 | SurfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL; |
| 1484 | SurfaceParams.bWidth16Align = false; |
| 1485 | |
| 1486 | VPHAL_RENDER_CHK_STATUS(VpHal_CommonSetSurfaceForHwAccess( |
| 1487 | pRenderHal, |
| 1488 | &pVeboxState->VeboxHeapResource, |
| 1489 | &pVeboxState->RenderHalVeboxHeapResource, |
| 1490 | &SurfaceParams, |
| 1491 | pRenderData->iBindingTable, |
| 1492 | BI_DN_VEBOX_STATE_SURFACE, |
| 1493 | true)); |
| 1494 | |
| 1495 | // VEBox Temp Surface----------------------------------------------------------- |
| 1496 | MOS_ZeroMemory(&SurfaceParams, sizeof(SurfaceParams)); |
| 1497 | |
| 1498 | SurfaceParams.Type = pRenderHal->SurfaceTypeDefault; |
| 1499 | SurfaceParams.isOutput = true; |
| 1500 | SurfaceParams.bWidthInDword_Y = true; |
| 1501 | SurfaceParams.bWidthInDword_UV = true; |
| 1502 | SurfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL; |
| 1503 | SurfaceParams.bWidth16Align = false; |
| 1504 | |
| 1505 | VPHAL_RENDER_CHK_STATUS(VpHal_CommonSetSurfaceForHwAccess( |
| 1506 | pRenderHal, |
| 1507 | &pVeboxState->tmpResource, |
| 1508 | &pVeboxState->RenderHalTmpResource, |
| 1509 | &SurfaceParams, |
| 1510 | pRenderData->iBindingTable, |
| 1511 | BI_DN_TEMP_SURFACE, |
| 1512 | true)); |
| 1513 | |
| 1514 | finish: |
| 1515 | return eStatus; |
| 1516 | } |
| 1517 | #endif |
| 1518 | |
| 1519 | //! |
| 1520 | //! \brief Vebox format support check |
| 1521 | //! \details Checks to see if Vebox operation is supported with source surface format |
| 1522 | //! \param [in] pSrcSurface |
| 1523 | //! Pointer to input surface of Vebox |
| 1524 | //! \return bool |
| 1525 | //! return true if input surface format is supported, otherwise false |
| 1526 | //! |
| 1527 | bool VPHAL_VEBOX_STATE_G8_BASE::IsFormatSupported( |
| 1528 | PVPHAL_SURFACE pSrcSurface) |
| 1529 | { |
| 1530 | bool bRet; |
| 1531 | |
| 1532 | bRet = false; |
| 1533 | |
| 1534 | // Check if Sample Format is supported |
| 1535 | if (pSrcSurface->Format != Format_NV12 && |
| 1536 | pSrcSurface->Format != Format_AYUV && |
| 1537 | pSrcSurface->Format != Format_Y416 && |
| 1538 | !IS_PA_FORMAT(pSrcSurface->Format)) |
| 1539 | { |
| 1540 | VPHAL_RENDER_NORMALMESSAGE("Unsupported Source Format '0x%08x' for VEBOX.", pSrcSurface->Format); |
| 1541 | goto finish; |
| 1542 | } |
| 1543 | |
| 1544 | bRet = true; |
| 1545 | |
| 1546 | finish: |
| 1547 | return bRet; |
| 1548 | } |
| 1549 | |
| 1550 | //! |
| 1551 | //! \brief Vebox format support check |
| 1552 | //! \details Checks to see if RT format is supported when Vebox output pipe is selected |
| 1553 | //! \param [in] pSrcSurface |
| 1554 | //! Pointer to Render source surface of VPP BLT |
| 1555 | //! \param [in] pRTSurface |
| 1556 | //! Pointer to Render target surface of VPP BLT |
| 1557 | //! \return bool |
| 1558 | //! return true if render target surface format is supported, otherwise false |
| 1559 | //! |
| 1560 | bool VPHAL_VEBOX_STATE_G8_BASE::IsRTFormatSupported( |
| 1561 | PVPHAL_SURFACE pSrcSurface, |
| 1562 | PVPHAL_SURFACE pRTSurface) |
| 1563 | { |
| 1564 | bool bRet; |
| 1565 | |
| 1566 | bRet = false; |
| 1567 | |
| 1568 | // Check if RT Format is supported by Vebox |
| 1569 | if (IS_PA_FORMAT(pRTSurface->Format) || |
| 1570 | pRTSurface->Format == Format_NV12) |
| 1571 | { |
| 1572 | // Supported Vebox Render Target format. Vebox Pipe Output can be selected. |
| 1573 | bRet = true; |
| 1574 | } |
| 1575 | |
| 1576 | if ((pSrcSurface->ColorSpace == CSpace_BT2020) && |
| 1577 | ((pSrcSurface->Format == Format_P010) || |
| 1578 | (pSrcSurface->Format == Format_P016)) && |
| 1579 | IS_RGB32_FORMAT(pRTSurface->Format)) |
| 1580 | { |
| 1581 | bRet = true; |
| 1582 | } |
| 1583 | |
| 1584 | return bRet; |
| 1585 | } |
| 1586 | |
| 1587 | //! |
| 1588 | //! \brief Vebox format support check for DN |
| 1589 | //! \details Check if the input surface format is supported for DN |
| 1590 | //! \param [in] pSrcSurface |
| 1591 | //! Pointer to input surface of Vebox |
| 1592 | //! \return bool |
| 1593 | //! return true if input surface format is supported, otherwise false |
| 1594 | //! |
| 1595 | bool VPHAL_VEBOX_STATE_G8_BASE::IsDnFormatSupported( |
| 1596 | PVPHAL_SURFACE pSrcSurface) |
| 1597 | { |
| 1598 | bool bRet; |
| 1599 | |
| 1600 | bRet = false; |
| 1601 | VPHAL_RENDER_CHK_NULL_NO_STATUS(pSrcSurface); |
| 1602 | |
| 1603 | if ((pSrcSurface->Format != Format_YUYV) && |
| 1604 | (pSrcSurface->Format != Format_VYUY) && |
| 1605 | (pSrcSurface->Format != Format_YVYU) && |
| 1606 | (pSrcSurface->Format != Format_UYVY) && |
| 1607 | (pSrcSurface->Format != Format_YUY2) && |
| 1608 | (pSrcSurface->Format != Format_Y8) && |
| 1609 | (pSrcSurface->Format != Format_NV12)) |
| 1610 | { |
| 1611 | VPHAL_RENDER_NORMALMESSAGE("Unsupported Format '0x%08x' for VEBOX DN.", pSrcSurface->Format); |
| 1612 | goto finish; |
| 1613 | } |
| 1614 | |
| 1615 | bRet = true; |
| 1616 | |
| 1617 | finish: |
| 1618 | return bRet; |
| 1619 | } |
| 1620 | |
| 1621 | //! |
| 1622 | //! \brief Check if surface format is supported by DI |
| 1623 | //! \details Check if surface format is supported by DI |
| 1624 | //! \param [in] pSrc |
| 1625 | //! Pointer to input surface of Vebox |
| 1626 | //! \return bool |
| 1627 | //! Return true if surface format is supported, otherwise return false |
| 1628 | //! |
| 1629 | bool VPHAL_VEBOX_STATE_G8_BASE::IsDiFormatSupported( |
| 1630 | PVPHAL_SURFACE pSrc) |
| 1631 | { |
| 1632 | bool bRet = false; |
| 1633 | |
| 1634 | VPHAL_RENDER_CHK_NULL_NO_STATUS(pSrc); |
| 1635 | |
| 1636 | if (pSrc->Format != Format_AYUV && |
| 1637 | pSrc->Format != Format_Y410 && |
| 1638 | pSrc->Format != Format_Y416 && |
| 1639 | pSrc->Format != Format_P010 && |
| 1640 | pSrc->Format != Format_P016 && |
| 1641 | pSrc->Format != Format_A8B8G8R8 && |
| 1642 | pSrc->Format != Format_A8R8G8B8 && |
| 1643 | pSrc->Format != Format_B10G10R10A2 && |
| 1644 | pSrc->Format != Format_R10G10B10A2 && |
| 1645 | pSrc->Format != Format_A16B16G16R16 && |
| 1646 | pSrc->Format != Format_A16R16G16B16) |
| 1647 | { |
| 1648 | bRet = true; |
| 1649 | } |
| 1650 | else |
| 1651 | { |
| 1652 | bRet = false; |
| 1653 | } |
| 1654 | |
| 1655 | finish: |
| 1656 | return bRet; |
| 1657 | } |
| 1658 | |
| 1659 | VPHAL_VEBOX_STATE_G8_BASE::VPHAL_VEBOX_STATE_G8_BASE( |
| 1660 | PMOS_INTERFACE pOsInterface, |
| 1661 | PMHW_VEBOX_INTERFACE pVeboxInterface, |
| 1662 | PRENDERHAL_INTERFACE pRenderHal, |
| 1663 | PVPHAL_VEBOX_EXEC_STATE pVeboxExecState, |
| 1664 | PVPHAL_RNDR_PERF_DATA pPerfData, |
| 1665 | const VPHAL_DNDI_CACHE_CNTL &dndiCacheCntl, |
| 1666 | MOS_STATUS *peStatus) : |
| 1667 | VPHAL_VEBOX_STATE(pOsInterface, pVeboxInterface, nullptr, pRenderHal, pVeboxExecState, pPerfData, dndiCacheCntl, peStatus) |
| 1668 | { |
| 1669 | // States |
| 1670 | pKernelParamTable = (PRENDERHAL_KERNEL_PARAM)g_Vebox_KernelParam_g8; |
| 1671 | iNumFFDISurfaces = 2; // PE on: 4 used. PE off: 2 used |
| 1672 | } |