1 /* 2 * Copyright (c) 2016-2021, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file vphal_render_composite.h 24 //! \brief Common interface and structure used in Composite 25 //! \details Common interface and structure used in Composite 26 //! 27 #ifndef __VPHAL_RENDER_COMPOSITE_H__ 28 #define __VPHAL_RENDER_COMPOSITE_H__ 29 30 #include "vphal.h" 31 #include "vphal_render_renderstate.h" 32 #include "vphal_render_common.h" 33 #include "mhw_render.h" 34 35 //! 36 //! \brief Compositing buffers 37 //! 38 #define VPHAL_COMP_BUFFERS_DEFAULT 4 39 #define VPHAL_COMP_BUFFERS_MAX 32 40 41 #define VPHAL_MAX_PROCAMP 2 42 43 #define VPHAL_SURFACE_INDEX_INVALID -1 44 #define VPHAL_COMP_MAX_PALETTES 2 45 #define VPHAL_COMP_MAX_LUMA_KEY 1 46 #define VPHAL_COMP_MAX_AVS 1 47 #define VPHAL_COMP_MAX_PROCAMP 1 48 #define VPHAL_COMP_SAMPLER_NEAREST 1 49 #define VPHAL_COMP_SAMPLER_BILINEAR 2 50 #define VPHAL_COMP_SAMPLER_LUMAKEY 4 51 #define VPHAL_COMP_MAX_SAMPLER (VPHAL_COMP_SAMPLER_NEAREST | VPHAL_COMP_SAMPLER_BILINEAR | VPHAL_COMP_SAMPLER_LUMAKEY) 52 53 #define VPHAL_SAMPLER_Y 1 54 #define VPHAL_SAMPLER_U 2 55 #define VPHAL_SAMPLER_V 3 56 #define VPHAL_COMP_COMPUTE_WALKER_THREAD_SPACE_WIDTH 1 57 #define VPHAL_COMP_COMPUTE_WALKER_THREAD_SPACE_HEIGHT 1 58 #define VPHAL_COMP_COMPUTE_WALKER_THREAD_SPACE_DEPTH 1 59 60 // GRF 8 for unified kernel inline data (NLAS is enabled) 61 struct MEDIA_OBJECT_NLAS_INLINE_DATA 62 { 63 // DWORD 0 - GRF R6.0 64 union 65 { 66 struct 67 { 68 float HorizontalFrameOriginLayer0; 69 }; 70 71 uint32_t Value; 72 } DW00; 73 74 // DWORD 1 - GRF R6.1 75 union 76 { 77 struct 78 { 79 float HorizontalFrameOriginLayer1; 80 }; 81 82 uint32_t Value; 83 } DW01; 84 85 // DWORD 2 - GRF R6.2 86 union 87 { 88 struct 89 { 90 float HorizontalFrameOriginLayer2; 91 }; 92 93 uint32_t Value; 94 } DW02; 95 96 // DWORD 03 - GRF R6.3 97 union 98 { 99 struct 100 { 101 float HorizontalFrameOriginLayer3; 102 }; 103 104 uint32_t Value; 105 } DW03; 106 107 // DWORD 04 - GRF R6.4 108 union 109 { 110 struct 111 { 112 float HorizontalFrameOriginLayer4; 113 }; 114 115 uint32_t Value; 116 } DW04; 117 118 // DWORD 05 - GRF R6.5 119 union 120 { 121 struct 122 { 123 float HorizontalFrameOriginLayer5; 124 }; 125 126 uint32_t Value; 127 } DW05; 128 129 // DWORD 06 - GRF R6.6 130 union 131 { 132 struct 133 { 134 float HorizontalFrameOriginLayer6; 135 }; 136 137 uint32_t Value; 138 } DW06; 139 140 // DWORD 07 - GRF R6.7 141 union 142 { 143 struct 144 { 145 float HorizontalFrameOriginLayer7; 146 }; 147 148 uint32_t Value; 149 } DW07; 150 }; 151 152 //! 153 //! \brief Structure to VPHAL Composite Media Object Inline Data 154 //! 155 struct VPHAL_COMPOSITE_MO_INLINE_DATA 156 { 157 // Do not change the two members' order because of low level memcpy 158 MEDIA_OBJECT_NLAS_INLINE_DATA NLASInline; 159 MEDIA_OBJECT_KA2_INLINE_DATA KA2Inline; 160 }; 161 162 //! 163 //! \brief Structure to VPHAL Composite Parameters 164 //! 165 typedef struct _VPHAL_COMPOSITE_PARAMS 166 { 167 // Pointer to target and source surfaces 168 uint32_t uSourceCount; //!< Number of sources 169 PVPHAL_SURFACE pSource[VPHAL_COMP_MAX_LAYERS]; 170 uint32_t uTargetCount; //!< Number of targets 171 VPHAL_SURFACE Target[VPHAL_MAX_TARGETS]; //!< Render targets 172 // Needed by CP during MHW VP integration, due to pTokenState->pResourceInfo 173 RENDERHAL_SURFACE RenderHalSurfaceSrc[VPHAL_COMP_MAX_LAYERS]; 174 RENDERHAL_SURFACE RenderHalSurfaceSrcField[VPHAL_COMP_MAX_LAYERS]; 175 RENDERHAL_SURFACE RenderHalSurfaceTarget[VPHAL_MAX_TARGETS]; 176 177 bool bSkipBlocks; //!< Skip empty blocks 178 PRECT pConstriction; //!< Constricted output 179 PVPHAL_COLORFILL_PARAMS pColorFillParams; //!< ColorFill - BG only 180 PVPHAL_ALPHA_PARAMS pCompAlpha; //!< Alpha for composited surface 181 bool bAlphaCalculateEnable; 182 bool bForceSkipColorFill; //!< Force skip colorfill even the first layer is translucent 183 184 // Resource counters 185 int32_t nLayers; 186 int32_t nPalettes; 187 int32_t nAVS; 188 int32_t nProcamp; 189 int32_t nLumaKeys; 190 int32_t nSampler; 191 VPHAL_ROTATION Rotation; //!< Layer 0 rotation info 192 } VPHAL_COMPOSITE_PARAMS, *PVPHAL_COMPOSITE_PARAMS; 193 194 //! 195 //! \brief Structure to VPHAL Composite Rendering data 196 //! 197 typedef struct _VPHAL_RENDERING_DATA_COMPOSITE 198 { 199 // Sources 200 int32_t iLayers; 201 PVPHAL_SURFACE pLayers[VPHAL_COMP_MAX_LAYERS]; 202 PVPHAL_SURFACE pTarget[VPHAL_MAX_TARGETS]; 203 PVPHAL_COLORFILL_PARAMS pColorFill; 204 PVPHAL_ALPHA_PARAMS pCompAlpha; 205 206 // Geometry 207 int32_t iBlocksX; 208 int32_t iBlocksY; 209 int32_t iBindingTable; 210 int32_t iMediaID; 211 int32_t iCurbeOffset; 212 int32_t iCurbeLength; 213 RECT rcOutput; 214 215 // Constriction parameters 216 PRECT pConstriction; 217 int32_t ConstrictionOriginX; 218 int32_t ConstrictionOriginY; 219 float fConstrictionStepX; 220 float fConstrictionStepY; 221 222 // HDC Direct Write flag 223 bool bHdcDwEnable; 224 225 // Alpha Calculate flag 226 bool bAlphaCalculateEnable; 227 228 // CM FC flag 229 bool bCmFcEnable; 230 231 // States 232 PRENDERHAL_MEDIA_STATE pMediaState; 233 MHW_SAMPLER_STATE_PARAM SamplerStateParams[MHW_RENDER_ENGINE_SAMPLERS_MAX]; 234 int32_t iCmdInlineSize; 235 int32_t iNLASInlineSize; 236 MEDIA_OBJECT_KA2_STATIC_DATA Static; 237 MEDIA_WALKER_KA2_STATIC_DATA WalkerStatic; 238 MEDIA_OBJECT_KA2_INLINE_DATA Inline; 239 PMHW_AVS_PARAMS pAvsParams; 240 MEDIA_DP_FC_STATIC_DATA DPFCStatic; 241 // Batch Buffer rendering arguments 242 VPHAL_BB_COMP_ARGS BbArgs; 243 244 // Kernel Information 245 Kdll_CacheEntry *pKernelEntry; 246 Kdll_Procamp *pProcamp; 247 248 // Extension data 249 void* pExtensionData; 250 251 } VPHAL_RENDERING_DATA_COMPOSITE, *PVPHAL_RENDERING_DATA_COMPOSITE; 252 253 //! 254 //! \brief Structure to VPHAL 16x16 Block COMPOSITE Mask 255 //! 256 typedef struct _VPHAL_16X16BLOCK_COMPOSITE_MASK 257 { 258 uint32_t HorizontalBlockCompositeMask : 16; 259 uint32_t VerticalBlockCompositeMask : 16; 260 } VPHAL_16X16BLOCK_COMPOSITE_MASK, *PVPHAL_16X16BLOCK_COMPOSITE_MASK; 261 262 //! 263 //! \brief Class to VPHAL Composite render 264 //! 265 class CompositeState : public RenderState 266 { 267 public: 268 //! 269 //! \brief Composite Constructor 270 //! \details Construct Composite render and allocate member data structure 271 //! \param [in] pOsInterface 272 //! Pointer to MOS interface structure 273 //! \param [in] pRenderHal 274 //! Pointer to RenderHal interface structure 275 //! \param [in] pPerfData 276 //! Pointer to performance data structure 277 //! \param [in] compositeCacheCntl 278 //! Composite Cache Control Data 279 //! \param [out] peStatus 280 //! Pointer to MOS status 281 //! 282 CompositeState( 283 PMOS_INTERFACE pOsInterface, 284 PRENDERHAL_INTERFACE pRenderHal, 285 PVPHAL_RNDR_PERF_DATA pPerfData, 286 const VPHAL_COMPOSITE_CACHE_CNTL &compositeCacheCntl, 287 MOS_STATUS *peStatus); 288 289 //! 290 //! \brief Composite render Destructor 291 //! \details Destroy Composite render and release all related RenderState resources 292 //! 293 virtual ~CompositeState(); 294 295 //! 296 //! \brief Initialize Composite render 297 //! \param [in] pSettings 298 //! Pointer to VPHAL Settings 299 //! \param [in] pKernelDllState 300 //! Pointer to KernelDLL State 301 //! \return MOS_STATUS 302 //! Return MOS_STATUS_SUCCESS if successful 303 //! 304 virtual MOS_STATUS Initialize( 305 const VphalSettings *pSettings, 306 Kdll_State *pKernelDllState); 307 308 //! 309 //! \brief Composite Destroy function 310 //! \details Destroy resource allocated by Composite 311 //! 312 virtual void Destroy(); 313 314 //! 315 //! \brief Composite render Rendering 316 //! \details VPHal Composite render entry 317 //! \param [in] pcRenderParams 318 //! Pointer to Render parameters 319 //! \param [in,out] pRenderPassData 320 //! Pointer to Render data 321 //! \return MOS_STATUS 322 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 323 //! 324 MOS_STATUS Render( 325 PCVPHAL_RENDER_PARAMS pcRenderParams, 326 RenderpassData *pRenderPassData); 327 328 //! 329 //! \brief Judge if Composite render is needed 330 //! \details Check Render parameter/data if Composite render needed 331 //! \param [in] pcRenderParams 332 //! Pointer to Render parameters 333 //! \param [in,out] pRenderPassData 334 //! Pointer to Render data 335 //! \return bool 336 //! true if meeded. Else false 337 //! 338 bool IsNeeded( 339 PCVPHAL_RENDER_PARAMS pcRenderParams, 340 RenderpassData *pRenderPassData); 341 342 void PrintCurbeData(MEDIA_OBJECT_KA2_STATIC_DATA *pWalkerStatic); 343 344 void PrintWalkerParas(PMHW_GPGPU_WALKER_PARAMS pWalkerParams); 345 346 void PrintSamplerParams(PMHW_SAMPLER_STATE_PARAM pSamplerParams); 347 348 //! 349 //! \brief set Report data 350 //! \details set Report data for this render 351 //! \param [in] pSource 352 //! pointer to the surface 353 //! 354 virtual void SetReporting(PVPHAL_SURFACE pSource); 355 356 //! 357 //! \brief copy Report data 358 //! \details copy Report data from this render 359 //! \param [out] pReporting 360 //! pointer to the Report data to copy data to 361 //! 362 virtual void CopyReporting(VphalFeatureReport* pReporting); 363 364 //! 365 //! \brief Judge if Composite render support multiple stream rendering 366 //! \details Judge if Composite render support multiple stream rendering 367 //! \return bool 368 //! true if supported. Else false 369 //! 370 bool IsMultipleStreamSupported(); 371 372 //! 373 //! \brief Search for the best match BB according to the Composition BB arguments 374 //! \param [in] pBatchBufferTable 375 //! Pointer to the BB table to be searched 376 //! \param [in] pInputBbParams 377 //! Pointer to the BB params required for the best match 378 //! \param [in] iBbSize 379 //! the BB size required for the best match 380 //! \param [out] ppBatchBuffer 381 //! Pointer to the addr of the best matched BB, pointer to nullptr if there's 382 //! no available matched BB 383 //! \return MOS_STATUS 384 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 385 //! 386 static MOS_STATUS GetBestMatchBB( 387 PVPHAL_BATCH_BUFFER_TABLE pBatchBufferTable, 388 PVPHAL_BATCH_BUFFER_PARAMS pInputBbParams, 389 int32_t iBbSize, 390 PMHW_BATCH_BUFFER *ppBatchBuffer); 391 392 //! 393 //! \brief Load Palette Data 394 //! \details Load Palette Data according to color space and CSC matrix. 395 //! \param [in] pInPalette 396 //! Pointer to Input Palette structure 397 //! \param [in] srcCspace 398 //! Source color space 399 //! \param [in] dstCspace 400 //! Destination color space 401 //! \param [in] piCscMatrix 402 //! Pointer to CSC matrix to use in fixed point format 403 //! \param [in] iNumEntries 404 //! Number of Palette entries to be filled 405 //! \param [in,out] pPaletteData 406 //! Pointer to Output Palette Address 407 //! \return MOS_STATUS 408 //! MOS_STATUS_SUCCESS, otherwise MOS_STATUS_UNIMPLEMENTED if Destination Colorspace not supported, 409 //! or MOS_STATUS_INVALID_PARAMETER/MOS_STATUS_NULL_POINTER 410 //! 411 MOS_STATUS LoadPaletteData( 412 PVPHAL_PALETTE pInPalette, 413 VPHAL_CSPACE srcCspace, 414 VPHAL_CSPACE dstCspace, 415 int32_t* piCscMatrix, 416 int32_t iNumEntries, 417 void* pPaletteData); 418 419 protected: 420 //! 421 //! \brief Set Sampler Avs 8x8 Table 422 //! \param [in] pRenderHal 423 //! Pointer to RenderHal Interface Structure 424 //! \param [in] pSamplerStateParams 425 //! Pointer to Sampler State Params 426 //! \param [in,out] pAvsParams 427 //! Pointer to AVS Params 428 //! \param [in] SrcFormat 429 //! Source Format 430 //! \param [in] fScaleX 431 //! Horizontal Scale Factor 432 //! \param [in] fScaleY 433 //! Vertical Scale Factor 434 //! \param [in] dwChromaSiting 435 //! Chroma Siting 436 //! \return MOS_STATUS 437 //! 438 virtual MOS_STATUS SetSamplerAvsTableParam( 439 PRENDERHAL_INTERFACE pRenderHal, 440 PMHW_SAMPLER_STATE_PARAM pSamplerStateParams, 441 PMHW_AVS_PARAMS pAvsParams, 442 MOS_FORMAT SrcFormat, 443 float fScaleX, 444 float fScaleY, 445 uint32_t dwChromaSiting); 446 447 //! 448 //! \brief Get Plane Offset override parameter for Kernel WA 449 //! \details Get Y/UV Plane Offset override parameters for Kernel WA 450 //! \param pRenderHalSurface 451 //! [in,out] Pointer to Render Hal Surface 452 //! \param pParams 453 //! [in] Pointer to Surface State Params 454 //! \param pOverride 455 //! [out] Pointer to override param that provides adjustments to 456 //! Y, UV plane offsets, used for kernel WA in a few cases. 457 //! \return RENDERHAL_OFFSET_OVERRIDE 458 //! return pointer to RENDERHAL_OFFSET_OVERRIDE if need, otherwise return nullptr. 459 //! GetPlaneOffsetOverrideParam(PRENDERHAL_SURFACE pRenderHalSurface,PRENDERHAL_SURFACE_STATE_PARAMS pParams,PRENDERHAL_OFFSET_OVERRIDE pOverride)460 virtual PRENDERHAL_OFFSET_OVERRIDE GetPlaneOffsetOverrideParam( 461 PRENDERHAL_SURFACE pRenderHalSurface, 462 PRENDERHAL_SURFACE_STATE_PARAMS pParams, 463 PRENDERHAL_OFFSET_OVERRIDE pOverride) 464 { 465 return nullptr; 466 } 467 468 //! 469 //! \brief Get Thread Count for VFE state parameter 470 //! \details Get Thread Count for VFE state parameter 471 //! \param pRenderingData 472 //! [in] Pointer to Composite state 473 //! \param pTarget 474 //! [in] Pointer to target surface 475 //! \return INT 476 //! return the thread count 477 //! 478 virtual int32_t GetThreadCountForVfeState( 479 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 480 PVPHAL_SURFACE pTarget); 481 482 //! 483 //! \brief Calculate Composite parameter and render data 484 //! \param [in,out] pCompParams 485 //! Pointer to Composite parameters. 486 //! \param [in,out] pSource 487 //! Pointer to surface. 488 //! \param [in,out] pRenderingData 489 //! Pointer to Composite RenderData. 490 //! \param [out] pbColorfill 491 //! Pointer to color fill flag. 492 //! \return void 493 //! 494 virtual void CalculateRenderData( 495 PVPHAL_COMPOSITE_PARAMS pCompParams, 496 PVPHAL_SURFACE pSurface, 497 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 498 bool* pbColorfill); 499 500 //! 501 //! \brief Set Sampler AVS parameters 502 //! \param [in] pRenderingData 503 //! pointer to render data 504 //! \param [in] pSource 505 //! pointer to source surface 506 //! \param [in] pSurfaceEntry 507 //! pointer to source state entry 508 //! \param [out] pSamplerStateParams 509 //! pointer to Sampler state params 510 //! \param [in] fScaleX 511 //! width scaling ratio 512 //! \param [in] fScaleY 513 //! height scaling ratio 514 //! \return MOS_STATUS 515 //! 516 virtual MOS_STATUS SetSamplerAvsParams( 517 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 518 PVPHAL_SURFACE pSource, 519 PRENDERHAL_SURFACE_STATE_ENTRY pSurfaceEntry, 520 PMHW_SAMPLER_STATE_PARAM pSamplerStateParams, 521 float fScaleX, 522 float fScaleY); 523 524 //! 525 //! \brief set inline data 526 //! \param [in] pBbArgs 527 //! Pointer to Composite BB argument 528 //! \param [in] pRenderingData 529 //! Pointer to Composite render data 530 //! \param [in] pStatic 531 //! Pointer to static data 532 //! \param [in,out] pInline 533 //! Pointer to inline data 534 //! \param [in,out] pInlineNLAS 535 //! Pointer to NLAS inline data 536 //! \param [in] x 537 //! horizontal origin 538 //! \param [out] fSrcX 539 //! horizontal origin of layers 540 //! \return void 541 //! ModifyInlineData(PVPHAL_BB_COMP_ARGS pBbArgs,PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData,MEDIA_OBJECT_KA2_STATIC_DATA * pStatic,MEDIA_OBJECT_KA2_INLINE_DATA * pInline,MEDIA_OBJECT_NLAS_INLINE_DATA * pInlineNLAS,int32_t x,float * fSrcX)542 virtual void ModifyInlineData( 543 PVPHAL_BB_COMP_ARGS pBbArgs, 544 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 545 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic, 546 MEDIA_OBJECT_KA2_INLINE_DATA *pInline, 547 MEDIA_OBJECT_NLAS_INLINE_DATA *pInlineNLAS, 548 int32_t x, 549 float *fSrcX) {;} 550 551 //! 552 //! \brief Calculate crop factor 553 //! \param [in] iLayer 554 //! layer index 555 //! \param [in] pRenderingData 556 //! pointer to render data 557 //! \param [out] pfCropX 558 //! crop factor 559 //! \param [out] pfCropY 560 //! crop factor 561 //! \return MOS_STATUS 562 //! 563 virtual MOS_STATUS CalculateCropParams( 564 int32_t iLayer, 565 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 566 float* pfCropX, 567 float* pfCropY); 568 569 //! 570 //! \brief Calculate and set inline data size 571 //! \param [in] pRenderingData 572 //! pointer to render data 573 //! \param [out] pStatic 574 //! pointer to static data 575 //! \return void 576 //! 577 virtual int32_t CalculateInlineDataSize( 578 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 579 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic); 580 581 //! 582 //! \brief Calculate Media Object size 583 //! \param [in] pRenderingData 584 //! Pointer to Rendering Data 585 //! \return int32_t 586 //! Return the size of Media Object 587 //! 588 virtual int32_t CalculateMediaObjectSize( 589 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 590 591 //! 592 //! \brief Modify MediaWalker Static Data 593 //! \param [in] pRenderingData 594 //! Pointer to Rendering Data 595 //! \return void 596 //! 597 virtual void ModifyMediaWalkerStaticData( 598 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 599 600 //! 601 //! \brief Initialize Composite Rendering data 602 //! \details Initialize Composite Rendering data, set output area, number of blocks, 603 //! Sources, constriction parameters, rendering states, etc. 604 //! \param [in] pCompParams 605 //! Pointer to Composite parameters 606 //! \param [out] pRenderingData 607 //! Pointer to Composite Rendering data 608 //! \return MOS_STATUS 609 //! 610 virtual MOS_STATUS RenderInit( 611 PVPHAL_COMPOSITE_PARAMS pCompParams, 612 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 613 614 //! 615 //! \brief Release Composite Rendering data 616 //! \param [in] pRenderingData 617 //! Pointer to Composite Rendering data 618 //! \return MOS_STATUS 619 //! 620 virtual void CleanRenderingData( 621 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 622 623 //! 624 //! \brief Fill in Gen specific static data 625 //! \details Fill in Gen specific static data 626 //! \param pRenderingData 627 //! [in] Pointer to REnder Data 628 //! \param pTarget 629 //! [in] Pointer to Target Surface 630 //! \param pStatic 631 //! [in,out] Pointer to Static Data 632 //! \return void 633 //! 634 virtual void SubmitStatesFillGenSpecificStaticData( 635 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 636 PVPHAL_SURFACE pTarget, 637 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic) = 0; 638 639 //! 640 //! \brief Get Output Surface Chroma sitting position for kernel 641 //! \details Get Output Surface Chroma sitting position for kernel 642 //! \param pTarget 643 //! [in] Pointer to Target Surface 644 //! \return DWORD 645 //! Return chroma sitting position 646 //! 647 uint32_t GetOutputChromaSitting( 648 PVPHAL_SURFACE pTarget); 649 650 //! 651 //! \brief Set Surface Compressed Parameters 652 //! \details Set Surface Compressed Parameters, and compression mode 653 //! \param [in,out] pSource 654 //! Pointer to Source Surface 655 //! \param [in] isRenderTarget 656 //! Render Target or not 657 //! \return void 658 //! 659 virtual void SetSurfaceCompressionParams( 660 PVPHAL_SURFACE pSource, 661 bool isRenderTarget); 662 663 //! 664 //! \brief Check NV12 luma key sampler solution is needed or not 665 //! \details This func is needed for Gen9 platforms 666 //! \param pSrc 667 //! [in] Pointer to Source Surface 668 //! \param pRenderHal 669 //! [in] Pointer to render hal 670 //! \return bool 671 //! Return TRUE if needed, otherwise FALSE 672 //! IsNV12SamplerLumakeyNeeded(PVPHAL_SURFACE pSrc,PRENDERHAL_INTERFACE pRenderHal)673 virtual bool IsNV12SamplerLumakeyNeeded(PVPHAL_SURFACE pSrc, PRENDERHAL_INTERFACE pRenderHal) 674 { 675 return false; 676 } 677 678 //! 679 //! \brief Check whether parameters for composition valid or not. 680 //! \param [in] CompositeParams 681 //! Parameters for composition 682 //! \return MOS_STATUS 683 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 684 //! 685 virtual MOS_STATUS IsCompositeParamsValid( 686 const VPHAL_COMPOSITE_PARAMS& CompositeParams); 687 688 //! 689 //! \brief Get Sampler Index associated with a surface state for composite 690 //! \param [in] pSurface 691 //! point to input Surface 692 //! \param [in] pEntry 693 //! Pointer to Surface state 694 //! \param [out] pSamplerIndex 695 //! Pointer to Sampler Index 696 //! \param [out] pSamplerType 697 //! Pointer to Sampler Type 698 //! \return MOS_STATUS 699 //! Return MOS_STATUS_SUCCESS if successful, otherwise MOS_STATUS_UNKNOWN 700 //! 701 virtual MOS_STATUS GetSamplerIndex( 702 PVPHAL_SURFACE pSurface, 703 PRENDERHAL_SURFACE_STATE_ENTRY pEntry, 704 int32_t* pSamplerIndex, 705 PMHW_SAMPLER_TYPE pSamplerType); 706 707 //! 708 //! \brief Check whether the 3Dsampler use for Y plane 709 //! \param [in] SamplerID 710 //! sampler ID 711 //! \return bool 712 //! Return true if the 3Dsampler use for Y plane, otherwise fase 713 //! 714 virtual bool IsSamplerIDForY( 715 int32_t SamplerID); 716 717 //! \brief set Sampler status 718 //! \param [in] pSurface 719 //! point to input Surface 720 //! \param [in] Layer 721 //! composition layer 722 //! \param [in] pStatic 723 //! Pointer to static data 724 //! \return MOS_STATUS 725 //! Return MOS_STATUS_SUCCESS if successful, otherwise MOS_STATUS_UNKNOWN 726 //! Set3DSamplerStatus(PVPHAL_SURFACE pSurface,uint8_t Layer,MEDIA_OBJECT_KA2_STATIC_DATA * pStatic)727 virtual MOS_STATUS Set3DSamplerStatus( 728 PVPHAL_SURFACE pSurface, 729 uint8_t Layer, 730 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic) 731 { 732 // Just need the sub class to implement if it is needed; 733 return MOS_STATUS_SUCCESS; 734 } 735 736 //! \brief Update Inline Data status 737 //! \param [in] pSurface 738 //! point to input Surface 739 //! \param [in] pStatic 740 //! Pointer to static data 741 //! \return MOS_STATUS 742 //! Return MOS_STATUS_SUCCESS if successful, otherwise MOS_STATUS_UNKNOWN 743 //! UpdateInlineDataStatus(PVPHAL_SURFACE pSurface,MEDIA_OBJECT_KA2_STATIC_DATA * pStatic)744 virtual MOS_STATUS UpdateInlineDataStatus( 745 PVPHAL_SURFACE pSurface, 746 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic) 747 { 748 // Just need the sub class to implement if it is needed; 749 return MOS_STATUS_SUCCESS; 750 } 751 752 MOS_STATUS IntermediateAllocation(PVPHAL_SURFACE &pIntermediate, 753 PMOS_INTERFACE pOsInterface, 754 uint32_t dwTempWidth, 755 uint32_t dwTempHeight, 756 PVPHAL_SURFACE pTarget); 757 758 //! 759 //! \brief Prepare phases for composite and allocate intermediate buffer for rendering 760 //! \param [in] pcRenderParams 761 //! Pointer to Render parameters 762 //! \param [in] ppSources 763 //! Pointer to the address of Source Surfaces 764 //! \param [in] iSources 765 //! Count of Source Surfaces 766 //! \return bool 767 //! Return true if multiple phases, otherwise false 768 //! 769 virtual bool PreparePhases( 770 PCVPHAL_RENDER_PARAMS pcRenderParams, 771 PVPHAL_SURFACE *ppSources, 772 int32_t iSources); 773 774 //! 775 //! \brief Reset composite rendering parameters for the current phase 776 //! \param [in,out] pComposite 777 //! Pointer to Composite parameters 778 //! \return void 779 //! 780 void ResetCompParams( 781 PVPHAL_COMPOSITE_PARAMS pComposite); 782 783 //! 784 //! \brief Adds a source layer for composite 785 //! \param [in,out] pComposite 786 //! Pointer to Composite parameters 787 //! \param [in] pSource 788 //! Pointer to Source Surface 789 //! \return bool 790 //! Return TURE if source may be processed in the same phase, otherwise false 791 //! 792 bool AddCompLayer( 793 PVPHAL_COMPOSITE_PARAMS pComposite, 794 PVPHAL_SURFACE pSource); 795 796 //! 797 //! \brief Adds render target layer for composite 798 //! \param [in,out] pComposite 799 //! Pointer to Composite parameters 800 //! \param [in] pTarget 801 //! Pointer to target surface 802 //! \return bool 803 //! Return TURE if target may be processed in the same phase, otherwise false 804 //! 805 bool AddCompTarget( 806 PVPHAL_COMPOSITE_PARAMS pComposite, 807 PVPHAL_SURFACE pTarget); 808 809 //! 810 //! \brief set sclaing Ratio 811 //! \details set sclaing Ratio for kernels which need to use different kernel to process scaling. 812 //! parameters 813 //! \param [in,out] Kdll_Scalingratio 814 //! Pointer to scaling ratio 815 //! \return void SetFilterScalingRatio(Kdll_Scalingratio * ScalingRatio)816 virtual void SetFilterScalingRatio( 817 Kdll_Scalingratio* ScalingRatio) {} 818 819 //! 820 //! \brief Render Compute Walker Buffer 821 //! \details Render Compute Walker Buffer, fill Walker static data fields and set walker 822 //! cmd params 823 //! \param [in] pBatchBuffer 824 //! Pointer to BatchBuffer 825 //! \param [in] pRenderingData 826 //! Pointer to Rendering Data 827 //! \param [in] pWalkerParams 828 //! Pointer to Walker parameters 829 //! \return bool 830 //! Return true if successful, otherwise false 831 //! 832 virtual bool RenderBufferComputeWalker( 833 PMHW_BATCH_BUFFER pBatchBuffer, 834 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 835 PMHW_GPGPU_WALKER_PARAMS pWalkerParams); 836 837 //! 838 //! \brief Submit Composite states 839 //! \details Submit Composite states, including load CSC matrix, set NLAS Inline data, 840 //! set background color, load Palettes, set output format, load kernel, load 841 //! curbe data, set sampler state, set VFE State params, and etc 842 //! \param [in] pRenderingData 843 //! Pointer to Composite state 844 //! \return bool 845 //! Return TURE if successful, otherwise false 846 //! 847 virtual bool SubmitStates( 848 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 849 850 private: 851 //! 852 //! \brief Prepare phases for composite and determine intermediate colorspace 853 //! \param [in] pcRenderParams 854 //! Pointer to Render parameters 855 //! \param [in] ppSources 856 //! Pointer to the address of Source Surfaces 857 //! \param [in] iSources 858 //! Count of Source Surfaces 859 //! \return VPHAL_CSPACE 860 //! Return intermediate colorspace 861 //! 862 VPHAL_CSPACE PrepareCSC( 863 PCVPHAL_RENDER_PARAMS pcRenderParams, 864 PVPHAL_SURFACE *ppSources, 865 int32_t iSources); 866 867 //! 868 //! \brief Composite multiple phase rendering 869 //! \details Composite render with multiple phases. In some cases we cannot process composition just in one phase 870 //! for example, if the input streams count is 9 (1 primary + 8 substreams), we need to postpone the 871 //! 9th stream to next second phase due to the input count limitation of current composition kernel. 872 //! \param [in] pcRenderParams 873 //! Pointer to VPHAL_RENDER_PARAMS 874 //! \param [in] ppSources 875 //! Pointer to PVPHAL_SURFACE, array of input surfaces 876 //! \param [in] iSources 877 //! constant int iSource indicating the size of ppSources 878 //! \param [in] pOutput 879 //! Pointer to VPHAL_SURFACE, output surface for the overall composition process 880 //! \return MOS_STATUS 881 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 882 //! 883 MOS_STATUS RenderMultiPhase( 884 PCVPHAL_RENDER_PARAMS pcRenderParams, 885 PVPHAL_SURFACE *ppSources, 886 const int32_t iSources, 887 PVPHAL_SURFACE pOutput); 888 889 //! 890 //! \brief Perform multiple layer composite operation in one phase 891 //! \details Perform multiple layer composite operation in one phase(scaling, blending, 892 //! lumakey, CSC) 893 //! \param [in,out] pCompParams 894 //! Pointer to Composite parameters 895 //! \return MOS_STATUS 896 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 897 //! 898 MOS_STATUS RenderPhase( 899 PVPHAL_COMPOSITE_PARAMS pCompParams); 900 901 //! 902 //! \brief Set Composite Scaling mode 903 //! \param [in,out] pSource 904 //! Pointer to Source Surface 905 //! \param [in] uSourceCount 906 //! Count of Source Surfaces 907 //! \return void 908 //! 909 void SetScalingMode( 910 PVPHAL_SURFACE pSource, 911 uint32_t uSourceCount); 912 913 //! 914 //! \brief Judge whether Bob Di should be enabled 915 //! \details Judge whether Bob Di should be enabled according to the parameter 916 //! of pDeinterlaceParams and the height of the input surface 917 //! \param [in] pSrc 918 //! Pointer to Source Surface 919 //! \return bool 920 //! Return true if Bob DI should be enabled, otherwise false 921 //! 922 virtual bool IsBobDiEnabled(PVPHAL_SURFACE pSrc); 923 924 //! 925 //! \brief Set Composite Layer 926 //! \details Set Composite Layer, including setup surface state and binding table, setup 927 //! lumakey parameters, setup samplers, setup alpha blending parameters, adjust 928 //! geometry for BOB DI, normalize source co-ordinates, set curbe and inline 929 //! data, and etc 930 //! \param [in] pRenderingData 931 //! Pointer to Composite Rendering data 932 //! \param [in] pSource 933 //! Pointer to Source Surface 934 //! \param [in] iLayerIdInCompParams 935 //! Layer id in pCompParams for pSource 936 //! \param [in,out] pCompParams 937 //! Pointer to Composite parameters 938 //! \return int32_t 939 //! Return 1 if set layer successful, otherwise -1 940 //! 941 int32_t SetLayer( 942 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 943 PVPHAL_SURFACE pSource, 944 int iLayerIdInCompParams, 945 PVPHAL_COMPOSITE_PARAMS pCompParams); 946 947 //! 948 //! \brief Set Composite Render Target Layer 949 //! \details Set Composite Render Target Layer, setup surface state and binding table 950 //! \param [in] pRenderingData 951 //! Pointer to Composite Rendering data 952 //! \param [in] pCompParams 953 //! Pointer to Composite parameters 954 //! \return int32_t 955 //! Return number of Surface State entries if successful, otherwise -1 956 //! 957 int32_t SetLayerRT( 958 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 959 PVPHAL_COMPOSITE_PARAMS pCompParams); 960 961 //! 962 //! \brief Build filter description for dynamic linking 963 //! \details Build filter description(render method, current layer, layer format, layer 964 //! rotation, layer colorspace, sampling mode, scaling mode, luma key, blending, 965 //! colorfill, procamp, CSC) for dynamic linking 966 //! parameters 967 //! \param [in] pCompParams 968 //! Pointer to Composite parameters 969 //! \param [out] pFilter 970 //! Pointer to first filter entry 971 //! \param [out] piFilterSize 972 //! Pointer to filter size 973 //! \return bool 974 //! Return true if successful, otherwise false 975 //! 976 bool BuildFilter( 977 PVPHAL_COMPOSITE_PARAMS pCompParams, 978 PKdll_FilterEntry pFilter, 979 int32_t* piFilterSize); 980 981 //! 982 //! \brief Render Composite BatchBuffer 983 //! \details Render Composite BatchBuffer, fill Walker static data fields and set walker 984 //! cmd params 985 //! \param [in] pBatchBuffer 986 //! Pointer to BatchBuffer 987 //! \param [in] pRenderingData 988 //! Pointer to Rendering Data 989 //! \param [in] pWalkerParams 990 //! Pointer to Walker parameters 991 //! \return bool 992 //! Return true if successful, otherwise false 993 //! 994 bool RenderBufferMediaWalker( 995 PMHW_BATCH_BUFFER pBatchBuffer, 996 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 997 PMHW_WALKER_PARAMS pWalkerParams); 998 999 //! 1000 //! \brief Judge whether media walker pattern will be vertical or not 1001 //! \details if input layer is one , and input is linear format and rotation 90 1002 //! or 270 is needed then the media walker pattern should be vertical 1003 //! \param [in] pRenderingData 1004 //! Pointer to Rendering Data 1005 //! \return bool 1006 //! Return true if vertical media pattern used, otherwise false 1007 //! 1008 bool MediaWalkerVertical( 1009 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 1010 1011 //! 1012 //! \brief Set Surface Parameters 1013 //! \details Set Surface Parameters, set flags for RT, set surface type based on scaling 1014 //! mode, set interlacing flags, etc. 1015 //! \param [in,out] pSource 1016 //! Pointer to Source Surface 1017 //! \param [out] pSurfaceParams 1018 //! Pointer to Surface Parameters 1019 //! \return void 1020 //! 1021 void SetSurfaceParams( 1022 PVPHAL_SURFACE pSource, 1023 PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams); 1024 1025 //! 1026 //! \brief Allocate Composite BatchBuffer 1027 //! \details Allocate Composite BatchBuffer, search from existing BBs for a match. If 1028 //! none, allocate new BB 1029 //! \param [in] pRenderingData 1030 //! Pointer to Rendering Data 1031 //! \param [out] ppBatchBuffer 1032 //! Pointer to the addr of the available BB. Pointer to nullptr if there's no 1033 //! \return MOS_STATUS 1034 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 1035 //! 1036 MOS_STATUS AllocateBuffer( 1037 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, 1038 PMHW_BATCH_BUFFER *ppBatchBuffer); 1039 1040 //! 1041 //! \brief Render Composite BatchBuffer 1042 //! \details Render Composite BatchBuffer, setup Media Object header and inline data 1043 //! \param [in] pBatchBuffer 1044 //! Pointer to BatchBuffer 1045 //! \param [in] pRenderingData 1046 //! Pointer to Rendering Data 1047 //! \return bool 1048 //! Return true if successful, otherwise false 1049 //! 1050 bool RenderBuffer( 1051 PMHW_BATCH_BUFFER pBatchBuffer, 1052 PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData); 1053 1054 //! 1055 //! \brief Judge whether 8-tap adaptive filter for all channels should be enabled 1056 //! \details Judge whether 8-tap adaptive filter for all channels should be enabled according to the input parameter 1057 //! \param [in] pSrc 1058 //! Pointer to Source Surface 1059 //! \param [in] fScaleX 1060 //! width scaling ratio 1061 //! \param [in] fScaleY 1062 //! height scaling ratio 1063 //! \return bool 1064 //! Return true 8-tap adaptive filter for all channels should be enabled, otherwise false 1065 //! 1066 bool Is8TapAdaptiveEnabled( 1067 PVPHAL_SURFACE pSrc, 1068 float fScaleX, 1069 float fScaleY); 1070 1071 //! 1072 //! \brief Initialize Colorfill parameters 1073 //! \details Initialize Colorfill parameters 1074 //! \return void 1075 //! 1076 void InitColorFillParams(); 1077 1078 //! 1079 //! \brief Check if sample unorm being used for source surface. 1080 //! \param [in] pCompParams 1081 //! Pointer to Composite parameters 1082 //! \param pSrc 1083 //! [in] Pointer to Source Surface 1084 //! \return bool 1085 //! Return TRUE if use sample unorm, otherwise FALSE 1086 //! 1087 bool IsUsingSampleUnorm( 1088 PVPHAL_COMPOSITE_PARAMS pCompParams, 1089 PVPHAL_SURFACE pSrc); 1090 1091 //! 1092 //! \brief Check if sampler lumakey being supported or not for source surface. 1093 //! \param pSrc 1094 //! [in] Pointer to Source Surface 1095 //! \return bool 1096 //! Return TRUE if support, otherwise FALSE 1097 //! 1098 bool IsSamplerLumakeySupported(PVPHAL_SURFACE pSrc); 1099 1100 //! 1101 //! \brief Get intermediate surface output 1102 //! \param pOutput 1103 //! [in] Pointer to Intermediate Output Surface 1104 //! \return PVPHAL_SURFACE 1105 //! Return the chose output 1106 //! 1107 virtual MOS_STATUS GetIntermediateOutput(PVPHAL_SURFACE &output); 1108 1109 // Procamp 1110 int32_t m_iMaxProcampEntries; 1111 int32_t m_iProcampVersion; 1112 Kdll_Procamp m_Procamp[VPHAL_MAX_PROCAMP]; 1113 1114 // Cache attributes 1115 VPHAL_COMPOSITE_CACHE_CNTL m_SurfMemObjCtl; 1116 1117 bool m_bNullHwRenderComp; //!< Null rendering flag for Composite function 1118 1119 bool m_b8TapAdaptiveEnable; //!< 8 tap adaptive filter enable flag, read from user feature key 1120 1121 Kdll_FilterDesc m_SearchFilter; 1122 Kdll_SearchState m_KernelSearch; 1123 int32_t m_ThreadCountPrimary; 1124 1125 // CMFC CSC Coefficient surface 1126 VPHAL_SURFACE m_CmfcCoeff; 1127 RENDERHAL_SURFACE m_RenderHalCmfcCoeff; 1128 1129 // Batch buffers 1130 int32_t m_iBatchBufferCount; 1131 MHW_BATCH_BUFFER m_BatchBuffer[VPHAL_COMP_BUFFERS_MAX]; 1132 VPHAL_BATCH_BUFFER_PARAMS m_BufferParam[VPHAL_COMP_BUFFERS_MAX]; 1133 1134 // Multiple phase support 1135 int32_t m_iCallID; 1136 1137 bool m_bLastPhase; //!< Flag for indicating the last Comp render phase 1138 1139 protected: 1140 1141 // Background Color fill parameters 1142 struct 1143 { 1144 VPHAL_COLOR_SAMPLE_8 m_csSrc; 1145 VPHAL_COLOR_SAMPLE_8 m_csDst; 1146 VPHAL_CSPACE m_CSpaceSrc; 1147 VPHAL_CSPACE m_CSpaceDst; 1148 }; 1149 1150 // Feature flags 1151 float m_fSamplerLinearBiasX; //!< Linear sampler bias X 1152 float m_fSamplerLinearBiasY; //!< Linear sampler bias Y 1153 bool m_bFtrMediaWalker; //!< Media Object Walker enabled 1154 bool m_bFtrComputeWalker; //!< Compute Walker enabled 1155 bool m_bFtrCSCCoeffPatchMode; //!< Set CSC Coeff using patch mode 1156 bool m_bSamplerSupportRotation; //!< Use sampler for Rotation 1157 bool m_bChromaUpSampling; //!< Chroma Up Sampling needed 1158 bool m_bChromaDownSampling; //!< Chroma Down Sampling needed 1159 bool m_bFallbackIefPatch; //!< Fall back IEF path from AVS to SFC 1160 bool m_bKernelSupportDualOutput; //!< Kernel support Dual Output 1161 bool m_bKernelSupportHdcDW; //!< Kernel support HDC direct write 1162 bool m_bApplyTwoLayersCompOptimize;//!< Apply 2 layers composition optimization 1163 bool m_need3DSampler; //!< If AVS Sampler not avaliable on specific platform, then we need 3D sampler instead 1164 bool m_bEnableSamplerLumakey; //!< Enable/Disable sampler lumakey feature. 1165 bool m_bYV12iAvsScaling; //!< Interlace AVS scaling support YV12 input format 1166 1167 // AVS table 1168 MHW_AVS_PARAMS m_AvsParameters; 1169 MHW_SAMPLER_AVS_TABLE_PARAM m_mhwSamplerAvsTableParam; //!< params for AVS scaling 8x8 table 1170 bool m_bAvsTableCoeffExtraEnabled; //!< Sampler AVS table param, bIsCoeffExtraEnabled 1171 bool m_bAvsTableBalancedFilter; //!< Sampler AVS table param, bBalancedFilter 1172 1173 static const int AVS_CACHE_SIZE = 4; //!< AVS coefficients cache size 1174 AvsCoeffsCache<AVS_CACHE_SIZE> m_AvsCoeffsCache; //!< AVS coefficients calculation is expensive, add cache to mitigate 1175 VPHAL_SURFACE m_Intermediate = {}; //!< Intermediate surface (multiple phase / constriction support) 1176 VPHAL_SURFACE m_Intermediate1 = {}; //!< Intermediate surface (multiple phase / constriction support) 1177 VPHAL_SURFACE m_Intermediate2 = {}; //!< Rotation output intermediate surface 1178 1179 Kdll_State *m_pKernelDllState = nullptr; //!< Compositing Kernel DLL/Search state 1180 RENDERHAL_KERNEL_PARAM m_KernelParams = {0}; 1181 1182 float m_fScaleX = 1.0f; 1183 float m_fScaleY = 1.0f; 1184 1185 bool m_FusedEuDispatch = false; 1186 }; 1187 1188 typedef CompositeState * PCComposite; 1189 1190 #endif // __VPHAL_RENDER_COMPOSITE_H__ 1191