| 1 | /* |
| 2 | * Copyright (c) 2019-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 | //! |
| 24 | //! \file vp_feature_manager.cpp |
| 25 | //! \brief Defines the common interface for vp features manager |
| 26 | //! \details The vp manager is further sub-divided by vp type |
| 27 | //! this file is for the base interface which is shared by all components. |
| 28 | //! |
| 29 | #include "vp_feature_manager.h" |
| 30 | #include "sw_filter_handle.h" |
| 31 | using namespace vp; |
| 32 | |
| 33 | /****************************************************************************************************/ |
| 34 | /* VpFeatureManagerNext */ |
| 35 | /****************************************************************************************************/ |
| 36 | |
| 37 | VpFeatureManagerNext::VpFeatureManagerNext(VpInterface &vpInterface) : |
| 38 | m_vpInterface(vpInterface) |
| 39 | { |
| 40 | m_vpInterface.SetSwFilterHandlers(m_featureHandler); |
| 41 | } |
| 42 | |
| 43 | VpFeatureManagerNext::~VpFeatureManagerNext() |
| 44 | { |
| 45 | UnregisterFeatures(); |
| 46 | MOS_Delete(m_policy); |
| 47 | } |
| 48 | |
| 49 | MOS_STATUS VpFeatureManagerNext::Init(void* settings) |
| 50 | { |
| 51 | VP_FUNC_CALL(); |
| 52 | |
| 53 | if (!m_policy) |
| 54 | { |
| 55 | m_policy = MOS_New(Policy, m_vpInterface); |
| 56 | } |
| 57 | VP_PUBLIC_CHK_NULL_RETURN(m_policy); |
| 58 | vp::VpPlatformInterface *vpPlatformInterface = m_vpInterface.GetHwInterface()->m_vpPlatformInterface; |
| 59 | VP_PUBLIC_CHK_NULL_RETURN(vpPlatformInterface); |
| 60 | VP_PUBLIC_CHK_STATUS_RETURN(vpPlatformInterface->InitVpFeatureSupportBits()); |
| 61 | VP_PUBLIC_CHK_STATUS_RETURN(RegisterFeatures()); |
| 62 | return m_policy->Initialize(); |
| 63 | } |
| 64 | |
| 65 | bool VpFeatureManagerNext::IsVeboxSfcFormatSupported(MOS_FORMAT formatInput, MOS_FORMAT formatOutput) |
| 66 | { |
| 67 | VP_FUNC_CALL(); |
| 68 | |
| 69 | if (m_policy) |
| 70 | { |
| 71 | return m_policy->IsVeboxSfcFormatSupported(formatInput, formatOutput); |
| 72 | } |
| 73 | |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | MOS_STATUS VpFeatureManagerNext::CreateHwFilterPipe(SwFilterPipe &swFilterPipe, HwFilterPipe *&pHwFilterPipe) |
| 78 | { |
| 79 | VP_FUNC_CALL(); |
| 80 | |
| 81 | MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 82 | pHwFilterPipe = nullptr; |
| 83 | |
| 84 | status = m_vpInterface.GetHwFilterPipeFactory().Create(swFilterPipe, *m_policy, pHwFilterPipe); |
| 85 | |
| 86 | VP_PUBLIC_CHK_STATUS_RETURN(status); |
| 87 | VP_PUBLIC_CHK_NULL_RETURN(pHwFilterPipe); |
| 88 | |
| 89 | return MOS_STATUS_SUCCESS; |
| 90 | } |
| 91 | |
| 92 | MOS_STATUS VpFeatureManagerNext::InitPacketPipe(SwFilterPipe &swFilterPipe, |
| 93 | PacketPipe &packetPipe) |
| 94 | { |
| 95 | VP_FUNC_CALL(); |
| 96 | |
| 97 | HwFilterPipe *pHwFilterPipe = nullptr; |
| 98 | |
| 99 | MOS_STATUS status = CreateHwFilterPipe(swFilterPipe, pHwFilterPipe); |
| 100 | |
| 101 | VP_PUBLIC_CHK_STATUS_RETURN(status); |
| 102 | VP_PUBLIC_CHK_NULL_RETURN(pHwFilterPipe); |
| 103 | |
| 104 | status = UpdateResources(*pHwFilterPipe); |
| 105 | |
| 106 | if (MOS_FAILED(status)) |
| 107 | { |
| 108 | m_vpInterface.GetHwFilterPipeFactory().Destory(pHwFilterPipe); |
| 109 | return status; |
| 110 | } |
| 111 | |
| 112 | status = pHwFilterPipe->InitPacketPipe(packetPipe); |
| 113 | |
| 114 | m_vpInterface.GetHwFilterPipeFactory().Destory(pHwFilterPipe); |
| 115 | |
| 116 | return status; |
| 117 | } |
| 118 | |
| 119 | MOS_STATUS VpFeatureManagerNext::UpdateResources(HwFilterPipe &hwFilterPipe) |
| 120 | { |
| 121 | VP_FUNC_CALL(); |
| 122 | |
| 123 | return hwFilterPipe.UpdateResources(); |
| 124 | } |
| 125 | |
| 126 | MOS_STATUS VpFeatureManagerNext::RegisterFeatures() |
| 127 | { |
| 128 | VP_FUNC_CALL(); |
| 129 | |
| 130 | if (m_isFeatureRegistered) |
| 131 | { |
| 132 | return MOS_STATUS_SUCCESS; |
| 133 | } |
| 134 | |
| 135 | // Clear m_featureHandler to avoid any garbage data. |
| 136 | UnregisterFeatures(); |
| 137 | |
| 138 | // Vebox/Sfc features. |
| 139 | SwFilterFeatureHandler *p = MOS_New(SwFilterCscHandler, m_vpInterface); |
| 140 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 141 | m_featureHandler.emplace(FeatureTypeCsc, p); |
| 142 | |
| 143 | p = MOS_New(SwFilterRotMirHandler, m_vpInterface); |
| 144 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 145 | m_featureHandler.emplace(FeatureTypeRotMir, p); |
| 146 | |
| 147 | p = MOS_New(SwFilterScalingHandler, m_vpInterface); |
| 148 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 149 | m_featureHandler.emplace(FeatureTypeScaling, p); |
| 150 | |
| 151 | p = MOS_New(SwFilterDnHandler, m_vpInterface); |
| 152 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 153 | m_featureHandler.emplace(FeatureTypeDn, p); |
| 154 | |
| 155 | p = MOS_New(SwFilterSteHandler, m_vpInterface); |
| 156 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 157 | m_featureHandler.emplace(FeatureTypeSte, p); |
| 158 | |
| 159 | p = MOS_New(SwFilterTccHandler, m_vpInterface); |
| 160 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 161 | m_featureHandler.emplace(FeatureTypeTcc, p); |
| 162 | |
| 163 | p = MOS_New(SwFilterProcampHandler, m_vpInterface); |
| 164 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 165 | m_featureHandler.emplace(FeatureTypeProcamp, p); |
| 166 | |
| 167 | p = MOS_New(SwFilterHdrHandler, m_vpInterface); |
| 168 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 169 | m_featureHandler.emplace(FeatureTypeHdr, p); |
| 170 | |
| 171 | p = MOS_New(SwFilterDiHandler, m_vpInterface); |
| 172 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 173 | m_featureHandler.emplace(FeatureTypeDi, p); |
| 174 | |
| 175 | p = MOS_New(SwFilterLumakeyHandler, m_vpInterface, FeatureTypeLumakey); |
| 176 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 177 | m_featureHandler.emplace(FeatureTypeLumakey, p); |
| 178 | |
| 179 | p = MOS_New(SwFilterBlendingHandler, m_vpInterface, FeatureTypeBlending); |
| 180 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 181 | m_featureHandler.emplace(FeatureTypeBlending, p); |
| 182 | |
| 183 | p = MOS_New(SwFilterColorFillHandler, m_vpInterface, FeatureTypeColorFill); |
| 184 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 185 | m_featureHandler.emplace(FeatureTypeColorFill, p); |
| 186 | |
| 187 | p = MOS_New(SwFilterAlphaHandler, m_vpInterface, FeatureTypeAlpha); |
| 188 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 189 | m_featureHandler.emplace(FeatureTypeAlpha, p); |
| 190 | |
| 191 | p = MOS_New(SwFilterCgcHandler, m_vpInterface); |
| 192 | VP_PUBLIC_CHK_NULL_RETURN(p); |
| 193 | m_featureHandler.emplace(FeatureTypeCgc, p); |
| 194 | |
| 195 | m_isFeatureRegistered = true; |
| 196 | return MOS_STATUS_SUCCESS; |
| 197 | } |
| 198 | |
| 199 | MOS_STATUS VpFeatureManagerNext::UnregisterFeatures() |
| 200 | { |
| 201 | VP_FUNC_CALL(); |
| 202 | |
| 203 | while (!m_featureHandler.empty()) |
| 204 | { |
| 205 | auto it = m_featureHandler.begin(); |
| 206 | SwFilterFeatureHandler* p = it->second; |
| 207 | MOS_Delete(p); |
| 208 | m_featureHandler.erase(it); |
| 209 | } |
| 210 | m_isFeatureRegistered = false; |
| 211 | return MOS_STATUS_SUCCESS; |
| 212 | } |
| 213 | |
| 214 | /****************************************************************************************************/ |
| 215 | /* VPFeatureManager */ |
| 216 | /****************************************************************************************************/ |
| 217 | |
| 218 | VPFeatureManager::VPFeatureManager( |
| 219 | PVP_MHWINTERFACE hwInterface) : |
| 220 | MediaFeatureManager(), |
| 221 | m_hwInterface(hwInterface) |
| 222 | { |
| 223 | if (m_hwInterface && m_hwInterface->m_osInterface) |
| 224 | { |
| 225 | m_userSettingPtr = m_hwInterface->m_osInterface->pfnGetUserSettingInstance(m_hwInterface->m_osInterface); |
| 226 | } |
| 227 | if (m_hwInterface) |
| 228 | { |
| 229 | m_vpUserFeatureControl = m_hwInterface->m_userFeatureControl; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | MOS_STATUS VPFeatureManager::CheckFeatures(void * params, bool &bApgFuncSupported) |
| 234 | { |
| 235 | VP_FUNC_CALL(); |
| 236 | |
| 237 | VP_PUBLIC_CHK_NULL_RETURN(params); |
| 238 | VP_PUBLIC_CHK_NULL_RETURN(m_hwInterface); |
| 239 | VP_PUBLIC_CHK_NULL_RETURN(m_hwInterface->m_osInterface); |
| 240 | |
| 241 | PVP_PIPELINE_PARAMS pvpParams = (PVP_PIPELINE_PARAMS)params; |
| 242 | bApgFuncSupported = false; |
| 243 | |
| 244 | // Color fill does not need to check src params. |
| 245 | if (0 == pvpParams->uSrcCount) |
| 246 | { |
| 247 | bApgFuncSupported = true; |
| 248 | return MOS_STATUS_SUCCESS; |
| 249 | } |
| 250 | |
| 251 | VP_PUBLIC_CHK_NULL_RETURN(pvpParams->pSrc[0]); |
| 252 | VP_PUBLIC_CHK_NULL_RETURN(pvpParams->pTarget[0]); |
| 253 | |
| 254 | // align rectangle of surface |
| 255 | VP_PUBLIC_CHK_STATUS_RETURN(RectSurfaceAlignment(pvpParams->pSrc[0], pvpParams->pTarget[0]->Format)); |
| 256 | VP_PUBLIC_CHK_STATUS_RETURN(RectSurfaceAlignment(pvpParams->pTarget[0], pvpParams->pTarget[0]->Format)); |
| 257 | |
| 258 | //Force 8K to render. Handle this case in APG path after render path being enabled. |
| 259 | if (pvpParams->bDisableVeboxFor8K && |
| 260 | ((pvpParams->pSrc[0]->dwWidth >= VPHAL_RNDR_8K_WIDTH || pvpParams->pSrc[0]->dwHeight >= VPHAL_RNDR_8K_HEIGHT) || |
| 261 | (pvpParams->pTarget[0]->dwWidth >= VPHAL_RNDR_8K_WIDTH || pvpParams->pTarget[0]->dwHeight >= VPHAL_RNDR_8K_HEIGHT))) |
| 262 | { |
| 263 | VP_PUBLIC_NORMALMESSAGE("Disable VEBOX/SFC for 8k resolution"); |
| 264 | return MOS_STATUS_SUCCESS; |
| 265 | } |
| 266 | |
| 267 | if (pvpParams->pConstriction) |
| 268 | { |
| 269 | return MOS_STATUS_SUCCESS; |
| 270 | } |
| 271 | |
| 272 | bApgFuncSupported = true; |
| 273 | |
| 274 | return MOS_STATUS_SUCCESS; |
| 275 | } |
| 276 | |
| 277 | MOS_STATUS VPFeatureManager::CheckFeatures(void * params) |
| 278 | { |
| 279 | VP_FUNC_CALL(); |
| 280 | |
| 281 | bool bApgFuncSupported = false; |
| 282 | return CheckFeatures(params, bApgFuncSupported); |
| 283 | } |
| 284 | |
| 285 | bool VPFeatureManager::IsCroppingNeeded( |
| 286 | PVPHAL_SURFACE pSrc) |
| 287 | { |
| 288 | VP_FUNC_CALL(); |
| 289 | |
| 290 | if (!pSrc) |
| 291 | { |
| 292 | return false; |
| 293 | } |
| 294 | bool bCropping = false; |
| 295 | // use comp for cropping |
| 296 | if (pSrc->rcSrc.left != 0 || pSrc->rcDst.left != 0 || |
| 297 | pSrc->rcSrc.top != 0 || pSrc->rcDst.top != 0) |
| 298 | { |
| 299 | bCropping = true; |
| 300 | } |
| 301 | return bCropping; |
| 302 | } |
| 303 | |
| 304 | bool VPFeatureManager::IsHdrNeeded( |
| 305 | PVPHAL_SURFACE pSrc, |
| 306 | PVPHAL_SURFACE pRenderTarget) |
| 307 | { |
| 308 | VP_FUNC_CALL(); |
| 309 | |
| 310 | if (!pSrc || !pRenderTarget) |
| 311 | { |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | if (!MEDIA_IS_SKU(m_hwInterface->m_skuTable, FtrHDR)) |
| 316 | { |
| 317 | return false; |
| 318 | } |
| 319 | |
| 320 | bool bBt2020Output = false; |
| 321 | bool bToneMapping = false; |
| 322 | bool bMultiLayerBt2020 = false; |
| 323 | bool bBDUHD = false; |
| 324 | bool bFP16 = false; |
| 325 | bool bRouteSdrUsageToHdr = false; |
| 326 | // Need to use HDR to process BT601/BT709->BT2020 |
| 327 | if (IS_COLOR_SPACE_BT2020(pRenderTarget->ColorSpace) && |
| 328 | !IS_COLOR_SPACE_BT2020(pSrc->ColorSpace)) |
| 329 | { |
| 330 | bBt2020Output = true; |
| 331 | } |
| 332 | |
| 333 | if ((pSrc->pHDRParams && (pSrc->pHDRParams->EOTF != VPHAL_HDR_EOTF_TRADITIONAL_GAMMA_SDR)) || |
| 334 | (pRenderTarget->pHDRParams && (pRenderTarget->pHDRParams->EOTF != VPHAL_HDR_EOTF_TRADITIONAL_GAMMA_SDR))) |
| 335 | { |
| 336 | bToneMapping = true; |
| 337 | } |
| 338 | |
| 339 | //if (IS_COLOR_SPACE_BT2020(pSrc->ColorSpace) && pRenderParams->uSrcCount > 1) |
| 340 | //{ |
| 341 | // bMultiLayerBt2020 = true; |
| 342 | //} |
| 343 | if (pSrc->pHDRParams) |
| 344 | { |
| 345 | |
| 346 | if (pSrc->pHDRParams->bPathKernel || (pRenderTarget->pHDRParams && pRenderTarget->pHDRParams->bPathKernel)) |
| 347 | { |
| 348 | bBDUHD = true; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | if ((pSrc->Format == Format_A16B16G16R16F) || (pSrc->Format == Format_A16R16G16B16F)) |
| 353 | { |
| 354 | bFP16 = true; |
| 355 | } |
| 356 | |
| 357 | bFP16 = bFP16 || (pRenderTarget->Format == Format_A16B16G16R16F) || (pRenderTarget->Format == Format_A16R16G16B16F); |
| 358 | |
| 359 | // Temorary solution for menu/FBI not show up : route all S2S uage to HDR kernel path |
| 360 | if (m_hwInterface->m_osInterface && |
| 361 | m_hwInterface->m_osInterface->osCpInterface->RenderBlockedFromCp()) |
| 362 | { |
| 363 | bRouteSdrUsageToHdr = true; |
| 364 | } |
| 365 | return (bBt2020Output || bToneMapping || bMultiLayerBt2020 || bRouteSdrUsageToHdr); |
| 366 | |
| 367 | } |
| 368 | |
| 369 | bool VPFeatureManager::Is2PassesCSCNeeded(PVPHAL_SURFACE pSrc, PVPHAL_SURFACE pRenderTarget) |
| 370 | { |
| 371 | VP_FUNC_CALL(); |
| 372 | |
| 373 | bool bRet = false; |
| 374 | bool b2PassesCSCNeeded = false; |
| 375 | |
| 376 | VP_PUBLIC_CHK_NULL_NO_STATUS(pSrc); |
| 377 | VP_PUBLIC_CHK_NULL_NO_STATUS(pRenderTarget); |
| 378 | |
| 379 | // 2 Passes CSC is used in BT2020YUV->BT601/709YUV |
| 380 | // Isolate decoder require SFC output, but SFC can not support RGB input, |
| 381 | // so sRGB need two pass, that same as original logic. |
| 382 | if (IS_COLOR_SPACE_BT2020_YUV(pSrc->ColorSpace)) |
| 383 | { |
| 384 | if ((pRenderTarget->ColorSpace == CSpace_BT601) || |
| 385 | (pRenderTarget->ColorSpace == CSpace_BT709) || |
| 386 | (pRenderTarget->ColorSpace == CSpace_BT601_FullRange) || |
| 387 | (pRenderTarget->ColorSpace == CSpace_BT709_FullRange) || |
| 388 | (pRenderTarget->ColorSpace == CSpace_stRGB) || |
| 389 | (pRenderTarget->ColorSpace == CSpace_sRGB)) |
| 390 | { |
| 391 | b2PassesCSCNeeded = true; |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | bRet = b2PassesCSCNeeded; |
| 396 | |
| 397 | finish: |
| 398 | return bRet; |
| 399 | } |
| 400 | bool VPFeatureManager::IsVeboxOutFeasible( |
| 401 | PVP_PIPELINE_PARAMS params) |
| 402 | { |
| 403 | VP_FUNC_CALL(); |
| 404 | |
| 405 | bool bRet = false; |
| 406 | bool disableVeboxOutput = false; |
| 407 | |
| 408 | VP_PUBLIC_CHK_NULL_NO_STATUS(params); |
| 409 | VP_PUBLIC_CHK_NULL_NO_STATUS(params->pSrc[0]); |
| 410 | VP_PUBLIC_CHK_NULL_NO_STATUS(params->pTarget[0]); |
| 411 | |
| 412 | // Read user feature key to get the Composition Bypass mode |
| 413 | // Vebox Comp Bypass is on by default |
| 414 | VP_PUBLIC_CHK_NULL_NO_STATUS(m_vpUserFeatureControl); |
| 415 | disableVeboxOutput = m_vpUserFeatureControl->IsVeboxOutputDisabled(); |
| 416 | |
| 417 | if (!disableVeboxOutput && |
| 418 | params->uDstCount ==1 && |
| 419 | SAME_SIZE_RECT(params->pSrc[0]->rcSrc, params->pSrc[0]->rcDst) && |
| 420 | RECT1_CONTAINS_RECT2(params->pSrc[0]->rcMaxSrc, params->pSrc[0]->rcSrc) && |
| 421 | params->pSrc[0]->rcSrc.top == 0 && |
| 422 | params->pSrc[0]->rcSrc.left == 0 && |
| 423 | SAME_SIZE_RECT(params->pSrc[0]->rcDst, params->pTarget[0]->rcDst) && |
| 424 | params->pSrc[0]->pIEFParams == nullptr && |
| 425 | params->pSrc[0]->SampleType == SAMPLE_PROGRESSIVE && |
| 426 | params->pSrc[0]->Rotation == VPHAL_ROTATION_IDENTITY && |
| 427 | params->pSrc[0]->bQueryVariance == false && |
| 428 | IsVeboxInputFormatSupport(params->pSrc[0]) && |
| 429 | IsVeboxRTFormatSupport(params->pSrc[0], params->pTarget[0]) && |
| 430 | (params->pCompAlpha == nullptr || |
| 431 | params->pCompAlpha->AlphaMode != VPHAL_ALPHA_FILL_MODE_BACKGROUND) && |
| 432 | params->pSrc[0]->rcDst.top == 0 && |
| 433 | params->pSrc[0]->rcDst.left == 0) |
| 434 | { |
| 435 | bRet = true; |
| 436 | } |
| 437 | |
| 438 | finish: |
| 439 | return bRet; |
| 440 | } |
| 441 | bool VPFeatureManager::IsVeboxInputFormatSupport(PVPHAL_SURFACE pSrcSurface) |
| 442 | { |
| 443 | VP_FUNC_CALL(); |
| 444 | |
| 445 | if (nullptr == pSrcSurface) |
| 446 | { |
| 447 | VP_PUBLIC_ASSERTMESSAGE("nullptr == pSrcSurface"); |
| 448 | return false; |
| 449 | } |
| 450 | |
| 451 | // Check if Sample Format is supported |
| 452 | // Vebox only support P016 format, P010 format can be supported by faking it as P016 |
| 453 | if (pSrcSurface->Format != Format_NV12 && |
| 454 | pSrcSurface->Format != Format_AYUV && |
| 455 | pSrcSurface->Format != Format_P010 && |
| 456 | pSrcSurface->Format != Format_P016 && |
| 457 | pSrcSurface->Format != Format_P210 && |
| 458 | pSrcSurface->Format != Format_P216 && |
| 459 | pSrcSurface->Format != Format_Y8 && |
| 460 | pSrcSurface->Format != Format_Y16U && |
| 461 | pSrcSurface->Format != Format_Y16S && |
| 462 | !IS_PA_FORMAT(pSrcSurface->Format) && |
| 463 | (pSrcSurface->Format != Format_A8B8G8R8) && |
| 464 | (pSrcSurface->Format != Format_X8B8G8R8) && |
| 465 | (pSrcSurface->Format != Format_A8R8G8B8) && |
| 466 | (pSrcSurface->Format != Format_X8R8G8B8)/* && |
| 467 | !IS_RGB64_FLOAT_FORMAT(pSrcSurface->Format)*/) |
| 468 | { |
| 469 | VP_PUBLIC_NORMALMESSAGE("Unsupported Source Format '0x%08x' for VEBOX.", pSrcSurface->Format); |
| 470 | return false; |
| 471 | } |
| 472 | |
| 473 | return true; |
| 474 | } |
| 475 | bool VPFeatureManager::IsVeboxRTFormatSupport( |
| 476 | PVPHAL_SURFACE pSrcSurface, |
| 477 | PVPHAL_SURFACE pRTSurface) |
| 478 | { |
| 479 | VP_FUNC_CALL(); |
| 480 | |
| 481 | bool bRet = false; |
| 482 | |
| 483 | if ((nullptr == pSrcSurface) || (nullptr == pRTSurface)) |
| 484 | { |
| 485 | VP_RENDER_ASSERTMESSAGE(" invalid surface"); |
| 486 | return false; |
| 487 | } |
| 488 | |
| 489 | // Check if RT Format is supported by Vebox |
| 490 | if (IS_PA_FORMAT(pRTSurface->Format) || |
| 491 | pRTSurface->Format == Format_NV12 || |
| 492 | pRTSurface->Format == Format_AYUV || |
| 493 | pRTSurface->Format == Format_P010 || |
| 494 | pRTSurface->Format == Format_P016 || |
| 495 | pRTSurface->Format == Format_P210 || |
| 496 | pRTSurface->Format == Format_P216 || |
| 497 | pRTSurface->Format == Format_Y8 || |
| 498 | pRTSurface->Format == Format_Y16U || |
| 499 | pRTSurface->Format == Format_Y16S) |
| 500 | { |
| 501 | // Supported Vebox Render Target format. Vebox Pipe Output can be selected. |
| 502 | bRet = true; |
| 503 | } |
| 504 | |
| 505 | if ((pSrcSurface->ColorSpace == CSpace_BT2020) && |
| 506 | ((pSrcSurface->Format == Format_P010) || |
| 507 | (pSrcSurface->Format == Format_P016)) && |
| 508 | // YuvChannelSwap is no longer supported from GEN10+, so we only accept 32-bits no swapped format. |
| 509 | (IS_RGB32_FORMAT(pRTSurface->Format) && IS_RGB_NO_SWAP(pRTSurface->Format))) |
| 510 | { |
| 511 | bRet = true; |
| 512 | } |
| 513 | |
| 514 | return bRet; |
| 515 | } |
| 516 | |
| 517 | bool VPFeatureManager::IsVeboxSupported(PVP_PIPELINE_PARAMS params) |
| 518 | { |
| 519 | VP_FUNC_CALL(); |
| 520 | |
| 521 | VP_RENDER_CHK_NULL_NO_STATUS(params); |
| 522 | VP_RENDER_CHK_NULL_NO_STATUS(params->pSrc[0]); |
| 523 | |
| 524 | if ((nullptr != params->pSrc[0]->pDenoiseParams && true == params->pSrc[0]->pDenoiseParams->bEnableLuma) || |
| 525 | (nullptr != params->pSrc[0]->pProcampParams && true == params->pSrc[0]->pProcampParams->bEnabled) || |
| 526 | (nullptr != params->pSrc[0]->pColorPipeParams && |
| 527 | (true == params->pSrc[0]->pColorPipeParams->bEnableACE || |
| 528 | true == params->pSrc[0]->pColorPipeParams->bEnableSTE || |
| 529 | true == params->pSrc[0]->pColorPipeParams->bEnableTCC))) |
| 530 | { |
| 531 | return true; |
| 532 | } |
| 533 | |
| 534 | finish: |
| 535 | return false; |
| 536 | } |
| 537 | |
| 538 | bool VPFeatureManager::IsSfcOutputFeasible(PVP_PIPELINE_PARAMS params) |
| 539 | { |
| 540 | VP_FUNC_CALL(); |
| 541 | |
| 542 | uint32_t dwSfcMaxWidth = 0; |
| 543 | uint32_t dwSfcMaxHeight = 0; |
| 544 | uint32_t dwSfcMinWidth = 0; |
| 545 | uint32_t dwSfcMinHeight = 0; |
| 546 | uint16_t wWidthAlignUnit = 0; |
| 547 | uint16_t wHeightAlignUnit = 0; |
| 548 | uint32_t dwSourceRegionWidth = 0; |
| 549 | uint32_t dwSourceRegionHeight = 0; |
| 550 | uint32_t dwOutputRegionWidth = 0; |
| 551 | uint32_t dwOutputRegionHeight = 0; |
| 552 | uint32_t dwTargetMinWidth = 0; |
| 553 | uint32_t dwTargetMinHeight = 0; |
| 554 | uint32_t dwOutputMinWidth = 0; |
| 555 | uint32_t dwOutputMinHeight = 0; |
| 556 | bool isInterlaced = false; |
| 557 | bool bRet = false; |
| 558 | float fScaleX = 0.0f, fScaleY = 0.0f; |
| 559 | float minRatio = 0.125f, maxRatio = 8.0f; |
| 560 | bool disableSFC = false; |
| 561 | VP_POLICY_RULES rules = {}; |
| 562 | |
| 563 | VP_RENDER_CHK_NULL_NO_STATUS(params); |
| 564 | VP_RENDER_CHK_NULL_NO_STATUS(params->pTarget[0]); |
| 565 | |
| 566 | if (MEDIA_IS_SKU(m_hwInterface->m_skuTable, FtrSFCPipe)) |
| 567 | { |
| 568 | // Read user feature key to Disable SFC |
| 569 | VP_PUBLIC_CHK_NULL_NO_STATUS(m_vpUserFeatureControl); |
| 570 | disableSFC = m_vpUserFeatureControl->IsSfcDisabled(); |
| 571 | if (disableSFC) |
| 572 | { |
| 573 | VP_RENDER_NORMALMESSAGE("SFC is disabled."); |
| 574 | bRet = false; |
| 575 | return bRet; |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | // params->pSrc[0] == nullptr is valid for color fill case on SFC. |
| 580 | if (params->pSrc[0] && !IsVeboxInputFormatSupport(params->pSrc[0])) |
| 581 | { |
| 582 | VP_RENDER_NORMALMESSAGE("The input format %d is not supported by vebox.", params->pSrc[0]->Format); |
| 583 | bRet = false; |
| 584 | return bRet; |
| 585 | } |
| 586 | |
| 587 | if (params->pTarget[0] && !IsOutputFormatSupported(params->pTarget[0])) |
| 588 | { |
| 589 | VP_RENDER_NORMALMESSAGE("The output format %d is not supported by vebox.", params->pSrc[0]->Format); |
| 590 | bRet = false; |
| 591 | return bRet; |
| 592 | } |
| 593 | |
| 594 | dwSfcMaxWidth = 16 * 1024; |
| 595 | dwSfcMaxHeight = 16 * 1024; |
| 596 | dwSfcMinWidth = MHW_SFC_MIN_WIDTH; |
| 597 | dwSfcMinHeight = MHW_SFC_MIN_HEIGHT; |
| 598 | wWidthAlignUnit = 1; |
| 599 | wHeightAlignUnit = 1; |
| 600 | |
| 601 | // Apply alignment restriction to the source and scaled regions. |
| 602 | switch (params->pTarget[0]->Format) |
| 603 | { |
| 604 | case Format_NV12: |
| 605 | wWidthAlignUnit = 2; |
| 606 | wHeightAlignUnit = 2; |
| 607 | break; |
| 608 | case Format_YUY2: |
| 609 | case Format_UYVY: |
| 610 | wWidthAlignUnit = 2; |
| 611 | break; |
| 612 | default: |
| 613 | break; |
| 614 | } |
| 615 | |
| 616 | // Region of the input frame which needs to be processed by SFC |
| 617 | dwSourceRegionHeight = MOS_ALIGN_FLOOR( |
| 618 | (uint32_t)(params->pSrc[0]->rcSrc.bottom - params->pSrc[0]->rcSrc.top), |
| 619 | wHeightAlignUnit); |
| 620 | dwSourceRegionWidth = MOS_ALIGN_FLOOR( |
| 621 | (uint32_t)(params->pSrc[0]->rcSrc.right - params->pSrc[0]->rcSrc.left), |
| 622 | wWidthAlignUnit); |
| 623 | |
| 624 | // Size of the Output Region over the Render Target |
| 625 | dwOutputRegionHeight = MOS_ALIGN_CEIL( |
| 626 | (uint32_t)(params->pSrc[0]->rcDst.bottom - params->pSrc[0]->rcDst.top), |
| 627 | wHeightAlignUnit); |
| 628 | dwOutputRegionWidth = MOS_ALIGN_CEIL( |
| 629 | (uint32_t)(params->pSrc[0]->rcDst.right - params->pSrc[0]->rcDst.left), |
| 630 | wWidthAlignUnit); |
| 631 | |
| 632 | dwTargetMinWidth = dwSfcMinWidth; |
| 633 | dwTargetMinHeight = dwSfcMinHeight; |
| 634 | dwOutputMinWidth = dwSfcMinWidth; |
| 635 | dwOutputMinHeight = dwSfcMinHeight; |
| 636 | switch (params->pSrc[0]->InterlacedScalingType) |
| 637 | { |
| 638 | case ISCALING_INTERLEAVED_TO_INTERLEAVED: |
| 639 | isInterlaced = true; |
| 640 | break; |
| 641 | case ISCALING_FIELD_TO_INTERLEAVED: |
| 642 | dwTargetMinWidth = dwSfcMinWidth * 2; |
| 643 | dwTargetMinHeight = dwSfcMinHeight * 2; |
| 644 | isInterlaced = true; |
| 645 | break; |
| 646 | case ISCALING_INTERLEAVED_TO_FIELD: |
| 647 | dwOutputMinWidth = dwSfcMinWidth / 2; |
| 648 | dwOutputMinHeight = dwSfcMinHeight / 2; |
| 649 | dwTargetMinWidth = dwSfcMinWidth / 2; |
| 650 | dwTargetMinHeight = dwSfcMinHeight / 2; |
| 651 | isInterlaced = true; |
| 652 | break; |
| 653 | default: |
| 654 | isInterlaced = false; |
| 655 | break; |
| 656 | } |
| 657 | |
| 658 | if (OUT_OF_BOUNDS(params->pSrc[0]->dwWidth, dwSfcMinWidth, dwSfcMaxWidth) || |
| 659 | OUT_OF_BOUNDS(params->pSrc[0]->dwHeight, dwSfcMinHeight, dwSfcMaxHeight) || |
| 660 | OUT_OF_BOUNDS(dwSourceRegionWidth, dwSfcMinWidth, dwSfcMaxWidth) || |
| 661 | OUT_OF_BOUNDS(dwSourceRegionHeight, dwSfcMinHeight, dwSfcMaxHeight) || |
| 662 | OUT_OF_BOUNDS(dwOutputRegionWidth, dwOutputMinWidth, dwSfcMaxWidth) || |
| 663 | OUT_OF_BOUNDS(dwOutputRegionHeight, dwOutputMinHeight, dwSfcMaxHeight) || |
| 664 | OUT_OF_BOUNDS(params->pTarget[0]->dwWidth, dwTargetMinWidth, dwSfcMaxWidth) || |
| 665 | OUT_OF_BOUNDS(params->pTarget[0]->dwHeight, dwTargetMinHeight, dwSfcMaxHeight)) |
| 666 | { |
| 667 | VP_RENDER_NORMALMESSAGE("Surface dimensions not supported by SFC Pipe"); |
| 668 | bRet = false; |
| 669 | return bRet; |
| 670 | } |
| 671 | if (isInterlaced) |
| 672 | { |
| 673 | if (params->pSrc[0]->Rotation != VPHAL_ROTATION_IDENTITY) |
| 674 | { |
| 675 | VP_RENDER_NORMALMESSAGE("Interlaced scaling cannot support rotate or mirror by SFC pipe."); |
| 676 | bRet = false; |
| 677 | return bRet; |
| 678 | } |
| 679 | |
| 680 | if (params->pSrc[0]->rcSrc.left != 0 || |
| 681 | params->pSrc[0]->rcSrc.top != 0 || |
| 682 | params->pSrc[0]->rcDst.left != 0 || |
| 683 | params->pSrc[0]->rcDst.top != 0) |
| 684 | { |
| 685 | VP_RENDER_NORMALMESSAGE("Interlaced scaling cannot support offset by SFC pipe."); |
| 686 | bRet = false; |
| 687 | return bRet; |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | // Size of the Output Region over the Render Target |
| 692 | dwOutputRegionHeight = MOS_MIN(dwOutputRegionHeight, params->pTarget[0]->dwHeight); |
| 693 | dwOutputRegionWidth = MOS_MIN(dwOutputRegionWidth, params->pTarget[0]->dwWidth); |
| 694 | |
| 695 | if ((params->pSrc[0]->Rotation > VPHAL_ROTATION_IDENTITY && params->pSrc[0]->Rotation != VPHAL_MIRROR_HORIZONTAL) && |
| 696 | params->pTarget[0]->TileType != MOS_TILE_Y) |
| 697 | { |
| 698 | VP_RENDER_NORMALMESSAGE("non TileY output mirror and rotation not supported by SFC Pipe."); |
| 699 | bRet = false; |
| 700 | return bRet; |
| 701 | } |
| 702 | |
| 703 | // Calculate the scaling ratio |
| 704 | // Both source region and scaled region are pre-rotated |
| 705 | if (params->pSrc[0]->Rotation == VPHAL_ROTATION_IDENTITY || |
| 706 | params->pSrc[0]->Rotation == VPHAL_ROTATION_180 || |
| 707 | params->pSrc[0]->Rotation == VPHAL_MIRROR_HORIZONTAL || |
| 708 | params->pSrc[0]->Rotation == VPHAL_MIRROR_VERTICAL) |
| 709 | { |
| 710 | if (params->pSrc[0]->InterlacedScalingType == ISCALING_INTERLEAVED_TO_FIELD) |
| 711 | { |
| 712 | fScaleX = (float)dwOutputRegionWidth / (float)dwSourceRegionWidth; |
| 713 | fScaleY = (float)dwOutputRegionHeight * 2.0F / (float)dwSourceRegionHeight; |
| 714 | } |
| 715 | else |
| 716 | { |
| 717 | fScaleX = (float)dwOutputRegionWidth / (float)dwSourceRegionWidth; |
| 718 | fScaleY = (float)dwOutputRegionHeight / (float)dwSourceRegionHeight; |
| 719 | } |
| 720 | } |
| 721 | else |
| 722 | { |
| 723 | // VPHAL_ROTATION_90 || VPHAL_ROTATION_270 || VPHAL_ROTATE_90_MIRROR_VERTICAL || VPHAL_ROTATE_90_MIRROR_HORIZONTAL |
| 724 | fScaleX = (float)dwOutputRegionHeight / (float)dwSourceRegionWidth; |
| 725 | fScaleY = (float)dwOutputRegionWidth / (float)dwSourceRegionHeight; |
| 726 | } |
| 727 | |
| 728 | m_hwInterface->m_vpPlatformInterface->InitPolicyRules(rules); |
| 729 | |
| 730 | if (rules.sfcMultiPassSupport.scaling.enable) |
| 731 | { |
| 732 | minRatio *= rules.sfcMultiPassSupport.scaling.downScaling.minRatioEnlarged; |
| 733 | maxRatio *= rules.sfcMultiPassSupport.scaling.upScaling.maxRatioEnlarged; |
| 734 | } |
| 735 | |
| 736 | // SFC scaling range is [0.125, 8] for both X and Y direction. |
| 737 | if ((fScaleX < minRatio) || (fScaleX > maxRatio) || |
| 738 | (fScaleY < minRatio) || (fScaleY > maxRatio)) |
| 739 | { |
| 740 | VP_RENDER_NORMALMESSAGE("Scaling factor not supported by SFC Pipe."); |
| 741 | bRet = false; |
| 742 | return bRet; |
| 743 | } |
| 744 | |
| 745 | // Check if the input/output combination is supported, given certain alpha fill mode. |
| 746 | // So far SFC only supports filling constant alpha. |
| 747 | if (params->pCompAlpha && |
| 748 | (params->pCompAlpha->AlphaMode == VPHAL_ALPHA_FILL_MODE_NONE || |
| 749 | params->pCompAlpha->AlphaMode == VPHAL_ALPHA_FILL_MODE_SOURCE_STREAM)) |
| 750 | { |
| 751 | //No Alpha DDI for LIBVA, Always allow SFC to do detail feature on GEN12+ on linux |
| 752 | //No matter what the current alpha mode is. |
| 753 | if (params->pSrc[0]->bIEF == true) |
| 754 | { |
| 755 | params->pCompAlpha->AlphaMode = VPHAL_ALPHA_FILL_MODE_NONE; |
| 756 | params->pCompAlpha->fAlpha = 1.0; |
| 757 | bRet = true; |
| 758 | return bRet; |
| 759 | } |
| 760 | else if ((params->pTarget[0]->Format == Format_A8R8G8B8 || |
| 761 | params->pTarget[0]->Format == Format_A8B8G8R8 || |
| 762 | params->pTarget[0]->Format == Format_R10G10B10A2 || |
| 763 | params->pTarget[0]->Format == Format_B10G10R10A2 || |
| 764 | params->pTarget[0]->Format == Format_Y410 || |
| 765 | params->pTarget[0]->Format == Format_Y416 || |
| 766 | params->pTarget[0]->Format == Format_AYUV) && |
| 767 | (params->pSrc[0]->Format == Format_A8B8G8R8 || |
| 768 | params->pSrc[0]->Format == Format_A8R8G8B8 || |
| 769 | params->pSrc[0]->Format == Format_Y410 || |
| 770 | params->pSrc[0]->Format == Format_Y416 || |
| 771 | params->pSrc[0]->Format == Format_AYUV)) |
| 772 | { |
| 773 | bRet = false; |
| 774 | return bRet; |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | bRet = true; |
| 779 | |
| 780 | finish: |
| 781 | return bRet; |
| 782 | } |
| 783 | |
| 784 | bool VPFeatureManager::IsRGBOutputFormatSupported(PVPHAL_SURFACE outSurface) |
| 785 | { |
| 786 | if (nullptr == outSurface) |
| 787 | { |
| 788 | VP_RENDER_ASSERTMESSAGE(" invalid outputsurface"); |
| 789 | return false; |
| 790 | } |
| 791 | |
| 792 | if (IS_RGB32_FORMAT(outSurface->Format)) // Remove RGB565 support due to quality issue. IS_RGB16_FORMAT(outSurface->Format) |
| 793 | { |
| 794 | return true; |
| 795 | } |
| 796 | else |
| 797 | { |
| 798 | return false; |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | bool VPFeatureManager::IsNV12P010OutputFormatSupported(PVPHAL_SURFACE outSurface) |
| 803 | { |
| 804 | if (nullptr == outSurface) |
| 805 | { |
| 806 | VP_RENDER_ASSERTMESSAGE(" invalid outputsurface"); |
| 807 | return false; |
| 808 | } |
| 809 | |
| 810 | if (outSurface->TileType == MOS_TILE_Y && |
| 811 | (outSurface->Format == Format_P010 || |
| 812 | outSurface->Format == Format_P016 || |
| 813 | outSurface->Format == Format_NV12)) |
| 814 | { |
| 815 | return true; |
| 816 | } |
| 817 | else |
| 818 | { |
| 819 | return false; |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | bool VPFeatureManager::IsOutputFormatSupported(PVPHAL_SURFACE outSurface) |
| 824 | { |
| 825 | VP_FUNC_CALL(); |
| 826 | if (nullptr == outSurface) |
| 827 | { |
| 828 | VP_RENDER_ASSERTMESSAGE(" invalid outputsurface"); |
| 829 | return false; |
| 830 | } |
| 831 | |
| 832 | bool ret = true; |
| 833 | |
| 834 | if (IsRGBOutputFormatSupported(outSurface) || |
| 835 | outSurface->Format == Format_YUY2 || |
| 836 | outSurface->Format == Format_UYVY || |
| 837 | outSurface->Format == Format_AYUV || |
| 838 | outSurface->Format == Format_Y210 || |
| 839 | outSurface->Format == Format_Y410 || |
| 840 | outSurface->Format == Format_Y216 || |
| 841 | outSurface->Format == Format_Y416) |
| 842 | { |
| 843 | ret = true; |
| 844 | } |
| 845 | else if (IsNV12P010OutputFormatSupported(outSurface)) |
| 846 | { |
| 847 | ret = true; |
| 848 | } |
| 849 | else |
| 850 | { |
| 851 | VP_RENDER_NORMALMESSAGE("Unsupported Render Target Format '0x%08x' for SFC Pipe.", outSurface->Format); |
| 852 | ret = false; |
| 853 | } |
| 854 | |
| 855 | return ret; |
| 856 | } |
| 857 | |
| 858 | //! |
| 859 | //! \brief Get the aligned the surface height and width unit |
| 860 | //! \details According to the format of the surface, get the aligned unit for the surface |
| 861 | //! width and height |
| 862 | //! \param [in,out] pwWidthAlignUnit |
| 863 | //! Pointer to the surface width alignment unit |
| 864 | //! \param [in,out] pwHeightAlignUnit |
| 865 | //! Pointer to the surface height alignment unit |
| 866 | //! \param [in] format |
| 867 | //! The format of the surface |
| 868 | //! \return void |
| 869 | //! |
| 870 | void VPFeatureManager::GetAlignUnit( |
| 871 | uint16_t &wWidthAlignUnit, |
| 872 | uint16_t &wHeightAlignUnit, |
| 873 | MOS_FORMAT format) |
| 874 | { |
| 875 | VP_FUNC_CALL(); |
| 876 | |
| 877 | switch (format) |
| 878 | { |
| 879 | case Format_YV12: |
| 880 | case Format_I420: |
| 881 | case Format_IYUV: |
| 882 | case Format_IMC1: |
| 883 | case Format_IMC2: |
| 884 | case Format_IMC3: |
| 885 | case Format_IMC4: |
| 886 | case Format_NV12: |
| 887 | case Format_P010: |
| 888 | case Format_P016: |
| 889 | wWidthAlignUnit = 2; |
| 890 | wHeightAlignUnit = 2; |
| 891 | break; |
| 892 | |
| 893 | case Format_YVU9: |
| 894 | wWidthAlignUnit = 4; |
| 895 | wHeightAlignUnit = 4; |
| 896 | break; |
| 897 | |
| 898 | case Format_YUY2: |
| 899 | case Format_UYVY: |
| 900 | case Format_YUYV: |
| 901 | case Format_YVYU: |
| 902 | case Format_VYUY: |
| 903 | case Format_P208: |
| 904 | case Format_Y210: |
| 905 | case Format_Y216: |
| 906 | wWidthAlignUnit = 2; |
| 907 | wHeightAlignUnit = 1; |
| 908 | break; |
| 909 | |
| 910 | case Format_NV11: |
| 911 | wWidthAlignUnit = 4; |
| 912 | wHeightAlignUnit = 1; |
| 913 | break; |
| 914 | |
| 915 | default: |
| 916 | wWidthAlignUnit = 1; |
| 917 | wHeightAlignUnit = 1; |
| 918 | break; |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | //! |
| 923 | //! \brief Align the src/dst surface rectangle and surface width/height |
| 924 | //! \details The surface rects and width/height need to be aligned according to the surface format |
| 925 | //! \param [in,out] pSurface |
| 926 | //! Pointer to the surface |
| 927 | //! \param [in] formatForDstRect |
| 928 | //! Format for Dst Rect |
| 929 | //! \return MOS_STATUS |
| 930 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 931 | //! |
| 932 | MOS_STATUS VPFeatureManager::RectSurfaceAlignment( |
| 933 | PVPHAL_SURFACE pSurface, |
| 934 | MOS_FORMAT formatForDstRect) |
| 935 | { |
| 936 | VP_FUNC_CALL(); |
| 937 | |
| 938 | uint16_t wWidthAlignUnit = 0; |
| 939 | uint16_t wHeightAlignUnit = 0; |
| 940 | uint16_t wWidthAlignUnitForDstRect = 0; |
| 941 | uint16_t wHeightAlignUnitForDstRect = 0; |
| 942 | MOS_STATUS eStatus; |
| 943 | |
| 944 | eStatus = MOS_STATUS_SUCCESS; |
| 945 | |
| 946 | GetAlignUnit(wWidthAlignUnit, wHeightAlignUnit, pSurface->Format); |
| 947 | GetAlignUnit(wWidthAlignUnitForDstRect, wHeightAlignUnitForDstRect, formatForDstRect); |
| 948 | |
| 949 | // The source rectangle is floored to the aligned unit to |
| 950 | // get rid of invalid data(ex: an odd numbered src rectangle with NV12 format |
| 951 | // will have invalid UV data for the last line of Y data). |
| 952 | pSurface->rcSrc.bottom = MOS_ALIGN_FLOOR((uint32_t)pSurface->rcSrc.bottom, wHeightAlignUnit); |
| 953 | pSurface->rcSrc.right = MOS_ALIGN_FLOOR((uint32_t)pSurface->rcSrc.right, wWidthAlignUnit); |
| 954 | |
| 955 | pSurface->rcSrc.top = MOS_ALIGN_CEIL((uint32_t)pSurface->rcSrc.top, wHeightAlignUnit); |
| 956 | pSurface->rcSrc.left = MOS_ALIGN_CEIL((uint32_t)pSurface->rcSrc.left, wWidthAlignUnit); |
| 957 | |
| 958 | // The Destination rectangle is rounded to the upper alignment unit to prevent the loss of |
| 959 | // data which was present in the source rectangle |
| 960 | pSurface->rcDst.bottom = MOS_ALIGN_CEIL((uint32_t)pSurface->rcDst.bottom, wHeightAlignUnitForDstRect); |
| 961 | pSurface->rcDst.right = MOS_ALIGN_CEIL((uint32_t)pSurface->rcDst.right, wWidthAlignUnitForDstRect); |
| 962 | |
| 963 | pSurface->rcDst.top = MOS_ALIGN_FLOOR((uint32_t)pSurface->rcDst.top, wHeightAlignUnitForDstRect); |
| 964 | pSurface->rcDst.left = MOS_ALIGN_FLOOR((uint32_t)pSurface->rcDst.left, wWidthAlignUnitForDstRect); |
| 965 | |
| 966 | if (pSurface->SurfType == SURF_OUT_RENDERTARGET) |
| 967 | { |
| 968 | pSurface->dwHeight = MOS_ALIGN_CEIL(pSurface->dwHeight, wHeightAlignUnit); |
| 969 | pSurface->dwWidth = MOS_ALIGN_CEIL(pSurface->dwWidth, wWidthAlignUnit); |
| 970 | } |
| 971 | else |
| 972 | { |
| 973 | pSurface->dwHeight = MOS_ALIGN_FLOOR(pSurface->dwHeight, wHeightAlignUnit); |
| 974 | pSurface->dwWidth = MOS_ALIGN_FLOOR(pSurface->dwWidth, wWidthAlignUnit); |
| 975 | } |
| 976 | |
| 977 | if ((pSurface->rcSrc.top == pSurface->rcSrc.bottom) || |
| 978 | (pSurface->rcSrc.left == pSurface->rcSrc.right) || |
| 979 | (pSurface->rcDst.top == pSurface->rcDst.bottom) || |
| 980 | (pSurface->rcDst.left == pSurface->rcDst.right) || |
| 981 | (pSurface->dwWidth == 0) || |
| 982 | (pSurface->dwHeight == 0)) |
| 983 | { |
| 984 | VP_RENDER_ASSERTMESSAGE("Surface Parameter is invalid."); |
| 985 | eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 986 | } |
| 987 | |
| 988 | return eStatus; |
| 989 | } |
| 990 | |
| 991 | bool VPFeatureManager::IsDiFormatSupported(MOS_FORMAT format) |
| 992 | { |
| 993 | VP_FUNC_CALL(); |
| 994 | |
| 995 | if (format != Format_AYUV && |
| 996 | format != Format_Y416 && |
| 997 | format != Format_Y410 && |
| 998 | format != Format_A8B8G8R8 && |
| 999 | format != Format_A8R8G8B8 && |
| 1000 | format != Format_B10G10R10A2 && |
| 1001 | format != Format_R10G10B10A2 && |
| 1002 | format != Format_A16B16G16R16 && |
| 1003 | format != Format_A16R16G16B16) |
| 1004 | { |
| 1005 | return true; |
| 1006 | } |
| 1007 | else |
| 1008 | { |
| 1009 | return false; |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | bool VPFeatureManager::IsVeboxSurfaceHeightAligned(VPHAL_SURFACE &surf) |
| 1014 | { |
| 1015 | VP_FUNC_CALL(); |
| 1016 | |
| 1017 | return MOS_IS_ALIGNED(MOS_MIN((uint32_t)surf.dwHeight, (uint32_t)surf.rcSrc.bottom), 4); |
| 1018 | } |