| 1 |
/* |
| 2 |
* Copyright (c) 2022, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file media_blt_copy.cpp |
| 24 |
//! \brief Common interface used in Blitter Engine |
| 25 |
//! \details Common interface used in Blitter Engine which are platform independent |
| 26 |
//! |
| 27 |
|
| 28 |
#define NOMINMAX |
| 29 |
#include <algorithm> |
| 30 |
|
| 31 |
#include "media_blt_copy.h" |
| 32 |
#include "media_copy.h" |
| 33 |
#include "mhw_mi.h" |
| 34 |
#include "mos_utilities.h" |
| 35 |
#include "media_perf_profiler.h" |
| 36 |
#include "renderhal.h" |
| 37 |
#define BIT( n ) ( 1 << (n) ) |
| 38 |
|
| 39 |
#ifdef min |
| 40 |
#undef min |
| 41 |
#endif |
| 42 |
|
| 43 |
//! |
| 44 |
//! \brief BltState constructor |
| 45 |
//! \details Initialize the BltState members. |
| 46 |
//! \param osInterface |
| 47 |
//! [in] Pointer to MOS_INTERFACE. |
| 48 |
//! |
| 49 |
BltState::BltState(PMOS_INTERFACE osInterface) : |
| 50 |
m_osInterface(osInterface), |
| 51 |
m_mhwInterfaces(nullptr), |
| 52 |
m_miInterface(nullptr), |
| 53 |
m_bltInterface(nullptr), |
| 54 |
m_cpInterface(nullptr) |
| 55 |
{ |
| 56 |
MOS_ZeroMemory(¶ms, sizeof(params)); |
| 57 |
params.Flags.m_blt = 1; |
| 58 |
m_mhwInterfaces = MhwInterfaces::CreateFactory(params, osInterface); |
| 59 |
if (m_mhwInterfaces != nullptr) |
| 60 |
{ |
| 61 |
m_bltInterface = m_mhwInterfaces->m_bltInterface; |
| 62 |
m_miInterface = m_mhwInterfaces->m_miInterface; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
//! |
| 67 |
//! \brief BltState constructor |
| 68 |
//! \details Initialize the BltState members. |
| 69 |
//! \param osInterface |
| 70 |
//! [in] Pointer to MOS_INTERFACE. |
| 71 |
//! |
| 72 |
BltState::BltState(PMOS_INTERFACE osInterface, MhwInterfaces* mhwInterfaces) : |
| 73 |
m_osInterface(osInterface), |
| 74 |
m_mhwInterfaces(nullptr), |
| 75 |
m_miInterface(nullptr), |
| 76 |
m_bltInterface(nullptr), |
| 77 |
m_cpInterface(nullptr) |
| 78 |
{ |
| 79 |
m_bltInterface = mhwInterfaces->m_bltInterface; |
| 80 |
m_miInterface = mhwInterfaces->m_miInterface; |
| 81 |
m_cpInterface = mhwInterfaces->m_cpInterface; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
BltState::~BltState() |
| 86 |
{ |
| 87 |
// component interface will be relesed in media copy. |
| 88 |
if (m_mhwInterfaces) |
| 89 |
{ |
| 90 |
m_mhwInterfaces->Destroy(); |
| 91 |
MOS_Delete(m_mhwInterfaces); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
//! |
| 96 |
//! \brief BltState initialize |
| 97 |
//! \details Initialize the BltState, create BLT context. |
| 98 |
//! \return MOS_STATUS |
| 99 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 100 |
//! |
| 101 |
MOS_STATUS BltState::Initialize() |
| 102 |
{ |
| 103 |
return MOS_STATUS_SUCCESS; |
| 104 |
} |
| 105 |
|
| 106 |
//! |
| 107 |
//! \brief Copy main surface |
| 108 |
//! \details BLT engine will copy source surface to destination surface |
| 109 |
//! \param src |
| 110 |
//! [in] Pointer to source surface |
| 111 |
//! \param dst |
| 112 |
//! [in] Pointer to destination surface |
| 113 |
//! \return MOS_STATUS |
| 114 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 115 |
//! |
| 116 |
MOS_STATUS BltState::CopyMainSurface( |
| 117 |
PMOS_SURFACE src, |
| 118 |
PMOS_SURFACE dst) |
| 119 |
{ |
| 120 |
BLT_CHK_STATUS_RETURN(CopyMainSurface(&src->OsResource, &dst->OsResource)); |
| 121 |
return MOS_STATUS_SUCCESS; |
| 122 |
} |
| 123 |
|
| 124 |
//! |
| 125 |
//! \brief Copy main surface |
| 126 |
//! \details BLT engine will copy source surface to destination surface |
| 127 |
//! \param src |
| 128 |
//! [in] Pointer to source resource |
| 129 |
//! \param dst |
| 130 |
//! [in] Pointer to destination resource |
| 131 |
//! \return MOS_STATUS |
| 132 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 133 |
//! |
| 134 |
MOS_STATUS BltState::CopyMainSurface( |
| 135 |
PMOS_RESOURCE src, |
| 136 |
PMOS_RESOURCE dst) |
| 137 |
{ |
| 138 |
BLT_STATE_PARAM bltStateParam; |
| 139 |
|
| 140 |
BLT_CHK_NULL_RETURN(src); |
| 141 |
BLT_CHK_NULL_RETURN(dst); |
| 142 |
|
| 143 |
MOS_ZeroMemory(&bltStateParam, sizeof(BLT_STATE_PARAM)); |
| 144 |
bltStateParam.bCopyMainSurface = true; |
| 145 |
bltStateParam.pSrcSurface = src; |
| 146 |
bltStateParam.pDstSurface = dst; |
| 147 |
|
| 148 |
BLT_CHK_STATUS_RETURN(SubmitCMD(&bltStateParam)); |
| 149 |
|
| 150 |
return MOS_STATUS_SUCCESS; |
| 151 |
|
| 152 |
} |
| 153 |
|
| 154 |
//! |
| 155 |
//! \brief Setup fast copy parameters |
| 156 |
//! \details Setup fast copy parameters for BLT Engine |
| 157 |
//! \param mhwParams |
| 158 |
//! [in/out] Pointer to MHW_FAST_COPY_BLT_PARAM |
| 159 |
//! \param inputSurface |
| 160 |
//! [in] Pointer to input surface |
| 161 |
//! \param outputSurface |
| 162 |
//! [in] Pointer to output surface |
| 163 |
//! \param planeIndex |
| 164 |
//! [in] Pointer to YUV(RGB) plane index |
| 165 |
//! \return MOS_STATUS |
| 166 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 167 |
//! |
| 168 |
MOS_STATUS BltState::SetupBltCopyParam( |
| 169 |
PMHW_FAST_COPY_BLT_PARAM pMhwBltParams, |
| 170 |
PMOS_RESOURCE inputSurface, |
| 171 |
PMOS_RESOURCE outputSurface, |
| 172 |
int planeIndex) |
| 173 |
{ |
| 174 |
BLT_CHK_NULL_RETURN(pMhwBltParams); |
| 175 |
BLT_CHK_NULL_RETURN(inputSurface); |
| 176 |
BLT_CHK_NULL_RETURN(outputSurface); |
| 177 |
|
| 178 |
MOS_SURFACE ResDetails; |
| 179 |
MOS_ZeroMemory(&ResDetails, sizeof(MOS_SURFACE)); |
| 180 |
MOS_ZeroMemory(pMhwBltParams, sizeof(MHW_FAST_COPY_BLT_PARAM)); |
| 181 |
ResDetails.Format = Format_Invalid; |
| 182 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnGetResourceInfo(m_osInterface, inputSurface, &ResDetails)); |
| 183 |
|
| 184 |
uint32_t inputHeight = ResDetails.dwHeight; |
| 185 |
uint32_t inputWidth = ResDetails.dwWidth; |
| 186 |
uint32_t inputPitch = ResDetails.dwPitch; |
| 187 |
|
| 188 |
if (inputSurface->TileType != MOS_TILE_LINEAR) |
| 189 |
{ ///for tiled surfaces, pitch is expressed in DWORDs |
| 190 |
pMhwBltParams->dwSrcPitch = ResDetails.dwPitch / 4; |
| 191 |
} |
| 192 |
else |
| 193 |
{ |
| 194 |
pMhwBltParams->dwSrcPitch = ResDetails.dwPitch; |
| 195 |
} |
| 196 |
|
| 197 |
pMhwBltParams->dwSrcTop = ResDetails.RenderOffset.YUV.Y.YOffset; |
| 198 |
pMhwBltParams->dwSrcLeft = ResDetails.RenderOffset.YUV.Y.XOffset; |
| 199 |
|
| 200 |
MOS_ZeroMemory(&ResDetails, sizeof(MOS_SURFACE)); |
| 201 |
ResDetails.Format = Format_Invalid; |
| 202 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnGetResourceInfo(m_osInterface, outputSurface, &ResDetails)); |
| 203 |
|
| 204 |
uint32_t outputHeight = ResDetails.dwHeight; |
| 205 |
uint32_t outputWidth = ResDetails.dwWidth; |
| 206 |
uint32_t outputPitch = ResDetails.dwPitch; |
| 207 |
|
| 208 |
if (outputSurface->TileType != MOS_TILE_LINEAR) |
| 209 |
{// /for tiled surfaces, pitch is expressed in DWORDs |
| 210 |
pMhwBltParams->dwDstPitch = ResDetails.dwPitch/4; |
| 211 |
} |
| 212 |
else |
| 213 |
{ |
| 214 |
pMhwBltParams->dwDstPitch = ResDetails.dwPitch; |
| 215 |
} |
| 216 |
pMhwBltParams->dwDstTop = ResDetails.RenderOffset.YUV.Y.YOffset; |
| 217 |
pMhwBltParams->dwDstLeft = ResDetails.RenderOffset.YUV.Y.XOffset; |
| 218 |
|
| 219 |
int planeNum = GetPlaneNum(ResDetails.Format); |
| 220 |
pMhwBltParams->dwDstBottom = std::min(inputHeight, outputHeight); |
| 221 |
|
| 222 |
// some upper layer has overwrite the format, so need get orignal BitsPerBlock |
| 223 |
BLT_CHK_NULL_RETURN(inputSurface->pGmmResInfo); |
| 224 |
BLT_CHK_NULL_RETURN(outputSurface->pGmmResInfo); |
| 225 |
uint32_t inputBitsPerPixel = inputSurface->pGmmResInfo->GetBitsPerPixel(); |
| 226 |
uint32_t outputBitsPerPixel = outputSurface->pGmmResInfo->GetBitsPerPixel(); |
| 227 |
uint32_t BitsPerPixel = 8; |
| 228 |
if (inputSurface->TileType != MOS_TILE_LINEAR) |
| 229 |
{ |
| 230 |
BitsPerPixel = inputBitsPerPixel; |
| 231 |
} |
| 232 |
else if (outputSurface->TileType != MOS_TILE_LINEAR) |
| 233 |
{ |
| 234 |
BitsPerPixel = outputBitsPerPixel; |
| 235 |
} |
| 236 |
else |
| 237 |
{ |
| 238 |
// both input and output are linear surfaces. |
| 239 |
// upper layer overwrite the format from buffer to 2D surfaces. Then the BitsPerPixel may different. |
| 240 |
BitsPerPixel = inputBitsPerPixel >= outputBitsPerPixel ? inputBitsPerPixel : outputBitsPerPixel; |
| 241 |
} |
| 242 |
MCPY_NORMALMESSAGE("input BitsPerBlock %d, output BitsPerBlock %d, the vid mem BitsPerBlock %d", |
| 243 |
inputBitsPerPixel, |
| 244 |
outputBitsPerPixel, |
| 245 |
BitsPerPixel); |
| 246 |
|
| 247 |
if (true == m_blokCopyon) |
| 248 |
{ |
| 249 |
pMhwBltParams->dwColorDepth = GetBlkCopyColorDepth(outputSurface->pGmmResInfo->GetResourceFormat(), BitsPerPixel); |
| 250 |
} |
| 251 |
else |
| 252 |
{ |
| 253 |
pMhwBltParams->dwColorDepth = GetFastCopyColorDepth(outputSurface->pGmmResInfo->GetResourceFormat(), BitsPerPixel); |
| 254 |
} |
| 255 |
pMhwBltParams->dwPlaneIndex = planeIndex; |
| 256 |
pMhwBltParams->dwPlaneNum = planeNum; |
| 257 |
if (SINGLE_PLANE == planeNum) |
| 258 |
{// handle as whole memory |
| 259 |
if (false == m_blokCopyon) |
| 260 |
{// fastcopy |
| 261 |
pMhwBltParams->dwDstRight = std::min(inputPitch, outputPitch) / 4; // Regard as 32 bit per pixel format, i.e. 4 byte per pixel. |
| 262 |
pMhwBltParams->dwColorDepth = 3; //0:8bit 1:16bit 3:32bit 4:64bit |
| 263 |
} |
| 264 |
else |
| 265 |
{ |
| 266 |
pMhwBltParams->dwDstRight = std::min(inputWidth, outputWidth); |
| 267 |
} |
| 268 |
} |
| 269 |
else |
| 270 |
{ |
| 271 |
int bytePerTexelScaling = GetBytesPerTexelScaling(ResDetails.Format); |
| 272 |
pMhwBltParams->dwDstRight = std::min(inputWidth, outputWidth); |
| 273 |
|
| 274 |
if (MCPY_PLANE_U == planeIndex || MCPY_PLANE_V == planeIndex) |
| 275 |
{ |
| 276 |
pMhwBltParams->dwDstBottom = pMhwBltParams->dwDstBottom / bytePerTexelScaling; |
| 277 |
if (ResDetails.Format == Format_I420 || ResDetails.Format == Format_YV12) |
| 278 |
{ |
| 279 |
pMhwBltParams->dwDstPitch = pMhwBltParams->dwDstPitch / 2; |
| 280 |
pMhwBltParams->dwSrcPitch = pMhwBltParams->dwSrcPitch / 2; |
| 281 |
pMhwBltParams->dwDstRight = pMhwBltParams->dwDstRight / 2; |
| 282 |
pMhwBltParams->dwDstBottom = pMhwBltParams->dwDstBottom / 2; |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
pMhwBltParams->pSrcOsResource = inputSurface; |
| 287 |
pMhwBltParams->pDstOsResource = outputSurface; |
| 288 |
MCPY_NORMALMESSAGE("BLT params: m_blokCopyon = %d, format %d, planeNum %d, planeIndex %d, dwColorDepth %d, dwSrcTop %d, dwSrcLeft %d, dwSrcPitch %d," |
| 289 |
"dwDstTop %d, dwDstLeft %d, dwDstRight %d, dwDstBottom %d, dwDstPitch %d", m_blokCopyon, |
| 290 |
ResDetails.Format, planeNum, planeIndex, pMhwBltParams->dwColorDepth, pMhwBltParams->dwSrcTop, pMhwBltParams->dwSrcLeft, |
| 291 |
pMhwBltParams->dwSrcPitch, pMhwBltParams->dwDstTop, pMhwBltParams->dwDstLeft, pMhwBltParams->dwDstRight, |
| 292 |
pMhwBltParams->dwDstBottom, pMhwBltParams->dwDstPitch); |
| 293 |
|
| 294 |
return MOS_STATUS_SUCCESS; |
| 295 |
} |
| 296 |
|
| 297 |
//! |
| 298 |
//! \brief Submit command2 |
| 299 |
//! \details Submit BLT command2 |
| 300 |
//! \param pBltStateParam |
| 301 |
//! [in] Pointer to BLT_STATE_PARAM |
| 302 |
//! \return MOS_STATUS |
| 303 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 304 |
//! |
| 305 |
MOS_STATUS BltState::SubmitCMD( |
| 306 |
PBLT_STATE_PARAM pBltStateParam) |
| 307 |
{ |
| 308 |
MOS_STATUS eStatus; |
| 309 |
MOS_COMMAND_BUFFER cmdBuffer; |
| 310 |
MHW_FAST_COPY_BLT_PARAM fastCopyBltParam; |
| 311 |
MOS_GPUCTX_CREATOPTIONS_ENHANCED createOption = {}; |
| 312 |
int planeNum = 1; |
| 313 |
|
| 314 |
// no gpucontext will be created if the gpu context has been created before. |
| 315 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnCreateGpuContext( |
| 316 |
m_osInterface, |
| 317 |
MOS_GPU_CONTEXT_BLT, |
| 318 |
MOS_GPU_NODE_BLT, |
| 319 |
&createOption)); |
| 320 |
// Set GPU context |
| 321 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnSetGpuContext(m_osInterface, MOS_GPU_CONTEXT_BLT)); |
| 322 |
|
| 323 |
// Register context with the Batch Buffer completion event |
| 324 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnRegisterBBCompleteNotifyEvent( |
| 325 |
m_osInterface, |
| 326 |
MOS_GPU_CONTEXT_BLT)); |
| 327 |
|
| 328 |
// Initialize the command buffer struct |
| 329 |
MOS_ZeroMemory(&cmdBuffer, sizeof(MOS_COMMAND_BUFFER)); |
| 330 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnGetCommandBuffer(m_osInterface, &cmdBuffer, 0)); |
| 331 |
BLT_CHK_STATUS_RETURN(SetPrologParamsforCmdbuffer(&cmdBuffer)); |
| 332 |
|
| 333 |
// Add flush DW |
| 334 |
MHW_MI_FLUSH_DW_PARAMS FlushDwParams; |
| 335 |
MOS_ZeroMemory(&FlushDwParams, sizeof(FlushDwParams)); |
| 336 |
BLT_CHK_STATUS_RETURN(m_miInterface->AddMiFlushDwCmd(&cmdBuffer, &FlushDwParams)); |
| 337 |
|
| 338 |
MOS_SURFACE srcResDetails; |
| 339 |
MOS_SURFACE dstResDetails; |
| 340 |
MOS_ZeroMemory(&srcResDetails, sizeof(MOS_SURFACE)); |
| 341 |
MOS_ZeroMemory(&dstResDetails, sizeof(MOS_SURFACE)); |
| 342 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnGetResourceInfo(m_osInterface, pBltStateParam->pSrcSurface, &srcResDetails)); |
| 343 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnGetResourceInfo(m_osInterface, pBltStateParam->pDstSurface, &dstResDetails)); |
| 344 |
|
| 345 |
if (srcResDetails.Format != dstResDetails.Format) |
| 346 |
{ |
| 347 |
MCPY_ASSERTMESSAGE("BLT copy can't support CSC copy. input format = %d, output format = %d", srcResDetails.Format, dstResDetails.Format); |
| 348 |
return MOS_STATUS_INVALID_PARAMETER; |
| 349 |
} |
| 350 |
planeNum = GetPlaneNum(dstResDetails.Format); |
| 351 |
|
| 352 |
MediaPerfProfiler* perfProfiler = MediaPerfProfiler::Instance(); |
| 353 |
BLT_CHK_NULL_RETURN(perfProfiler); |
| 354 |
BLT_CHK_STATUS_RETURN(perfProfiler->AddPerfCollectStartCmd((void*)this, m_osInterface, m_miInterface, &cmdBuffer)); |
| 355 |
|
| 356 |
if (pBltStateParam->bCopyMainSurface) |
| 357 |
{ |
| 358 |
m_blokCopyon = true; |
| 359 |
BLT_CHK_STATUS_RETURN(SetupBltCopyParam( |
| 360 |
&fastCopyBltParam, |
| 361 |
pBltStateParam->pSrcSurface, |
| 362 |
pBltStateParam->pDstSurface, |
| 363 |
MCPY_PLANE_Y)); |
| 364 |
|
| 365 |
MHW_MI_LOAD_REGISTER_IMM_PARAMS RegisterDwParams; |
| 366 |
MOS_ZeroMemory(&RegisterDwParams, sizeof(RegisterDwParams)); |
| 367 |
RegisterDwParams.dwRegister = mhw_blt_state::BCS_SWCTRL_CMD::REGISTER_OFFSET; |
| 368 |
|
| 369 |
mhw_blt_state::BCS_SWCTRL_CMD swctrl; |
| 370 |
if (pBltStateParam->pSrcSurface->TileType != MOS_TILE_LINEAR) |
| 371 |
{ |
| 372 |
swctrl.DW0.TileYSource = 1; |
| 373 |
swctrl.DW0.Mask |= BIT(0); |
| 374 |
} |
| 375 |
if (pBltStateParam->pDstSurface->TileType != MOS_TILE_LINEAR) |
| 376 |
{//output tiled |
| 377 |
swctrl.DW0.TileYDestination = 1; |
| 378 |
swctrl.DW0.Mask |= BIT(1); |
| 379 |
} |
| 380 |
|
| 381 |
RegisterDwParams.dwData = swctrl.DW0.Value; |
| 382 |
BLT_CHK_STATUS_RETURN(m_miInterface->AddMiLoadRegisterImmCmd(&cmdBuffer, &RegisterDwParams)); |
| 383 |
|
| 384 |
BLT_CHK_STATUS_RETURN(m_bltInterface->AddBlockCopyBlt( |
| 385 |
&cmdBuffer, |
| 386 |
&fastCopyBltParam, |
| 387 |
srcResDetails.YPlaneOffset.iSurfaceOffset, |
| 388 |
dstResDetails.YPlaneOffset.iSurfaceOffset)); |
| 389 |
|
| 390 |
if (planeNum == TWO_PLANES || planeNum == THREE_PLANES) |
| 391 |
{ |
| 392 |
BLT_CHK_STATUS_RETURN(SetupBltCopyParam( |
| 393 |
&fastCopyBltParam, |
| 394 |
pBltStateParam->pSrcSurface, |
| 395 |
pBltStateParam->pDstSurface, |
| 396 |
MCPY_PLANE_U)); |
| 397 |
BLT_CHK_STATUS_RETURN(m_bltInterface->AddBlockCopyBlt( |
| 398 |
&cmdBuffer, |
| 399 |
&fastCopyBltParam, |
| 400 |
srcResDetails.UPlaneOffset.iSurfaceOffset, |
| 401 |
dstResDetails.UPlaneOffset.iSurfaceOffset)); |
| 402 |
|
| 403 |
if (planeNum == THREE_PLANES) |
| 404 |
{ |
| 405 |
BLT_CHK_STATUS_RETURN(SetupBltCopyParam( |
| 406 |
&fastCopyBltParam, |
| 407 |
pBltStateParam->pSrcSurface, |
| 408 |
pBltStateParam->pDstSurface, |
| 409 |
MCPY_PLANE_V)); |
| 410 |
BLT_CHK_STATUS_RETURN(m_bltInterface->AddBlockCopyBlt( |
| 411 |
&cmdBuffer, |
| 412 |
&fastCopyBltParam, |
| 413 |
srcResDetails.VPlaneOffset.iSurfaceOffset, |
| 414 |
dstResDetails.VPlaneOffset.iSurfaceOffset)); |
| 415 |
} |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
BLT_CHK_STATUS_RETURN(perfProfiler->AddPerfCollectEndCmd((void*)this, m_osInterface, m_miInterface, &cmdBuffer)); |
| 420 |
// Add flush DW |
| 421 |
BLT_CHK_STATUS_RETURN(m_miInterface->AddMiFlushDwCmd(&cmdBuffer, &FlushDwParams)); |
| 422 |
|
| 423 |
// Add Batch Buffer end |
| 424 |
BLT_CHK_STATUS_RETURN(m_miInterface->AddMiBatchBufferEnd(&cmdBuffer, nullptr)); |
| 425 |
|
| 426 |
// Flush the command buffer |
| 427 |
BLT_CHK_STATUS_RETURN(m_osInterface->pfnSubmitCommandBuffer(m_osInterface, &cmdBuffer, false)); |
| 428 |
|
| 429 |
return MOS_STATUS_SUCCESS; |
| 430 |
} |
| 431 |
|
| 432 |
uint32_t BltState::GetBlkCopyColorDepth( |
| 433 |
GMM_RESOURCE_FORMAT dstFormat, |
| 434 |
uint32_t BitsPerPixel) |
| 435 |
{ |
| 436 |
if (dstFormat == GMM_FORMAT_YUY2_2x1 || dstFormat == GMM_FORMAT_Y216_TYPE || dstFormat == GMM_FORMAT_Y210) |
| 437 |
{ // GMM_FORMAT_YUY2_2x1 32bpe 2x1 pixel blocks instead of 16bpp 1x1 block |
| 438 |
// GMM_FORMAT_Y216_TYPE/Y210 64bpe pixel blocks instead of 32bpp block. |
| 439 |
BitsPerPixel = BitsPerPixel / 2; |
| 440 |
} |
| 441 |
switch (BitsPerPixel) |
| 442 |
{ |
| 443 |
case 16: |
| 444 |
switch (dstFormat) |
| 445 |
{ |
| 446 |
case GMM_FORMAT_B5G5R5A1_UNORM: |
| 447 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_32BITCOLOR; |
| 448 |
default: |
| 449 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_16BITCOLOR; |
| 450 |
} |
| 451 |
case 32: |
| 452 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_32BITCOLOR; |
| 453 |
case 64: |
| 454 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_64BITCOLOR; |
| 455 |
case 96: |
| 456 |
MCPY_ASSERTMESSAGE("96 BitPerPixel support limimated as Linear format %d", dstFormat); |
| 457 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_96BITCOLOR_ONLYLINEARCASEISSUPPORTED; |
| 458 |
case 128: |
| 459 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_128BITCOLOR; |
| 460 |
case 8: |
| 461 |
default: |
| 462 |
return mhw_blt_state::XY_BLOCK_COPY_BLT_CMD::COLOR_DEPTH_8BITCOLOR; |
| 463 |
} |
| 464 |
} |
| 465 |
uint32_t BltState::GetFastCopyColorDepth( |
| 466 |
GMM_RESOURCE_FORMAT dstFormat, |
| 467 |
uint32_t BitsPerBlock) |
| 468 |
{ |
| 469 |
switch (BitsPerBlock) |
| 470 |
{ |
| 471 |
case 8: |
| 472 |
return mhw_blt_state::XY_FAST_COPY_BLT_CMD::COLOR_DEPTH_8BITCOLOR; |
| 473 |
break; |
| 474 |
case 16: |
| 475 |
switch (dstFormat) |
| 476 |
{ |
| 477 |
case GMM_FORMAT_B5G5R5A1_UNORM: |
| 478 |
return mhw_blt_state::XY_FAST_COPY_BLT_CMD::COLOR_DEPTH_32BITCOLOR; |
| 479 |
break; |
| 480 |
default: |
| 481 |
return mhw_blt_state::XY_FAST_COPY_BLT_CMD::COLOR_DEPTH_16BITCOLOR_565; |
| 482 |
break; |
| 483 |
} |
| 484 |
break; |
| 485 |
case 64: |
| 486 |
return mhw_blt_state::XY_FAST_COPY_BLT_CMD::COLOR_DEPTH_64BITCOLOR_FOR64KBTILING; |
| 487 |
break; |
| 488 |
case 128: |
| 489 |
return mhw_blt_state::XY_FAST_COPY_BLT_CMD::COLOR_DEPTH_128BITCOLOR_FOR64KBTILING; |
| 490 |
break; |
| 491 |
default: |
| 492 |
return mhw_blt_state::XY_FAST_COPY_BLT_CMD::COLOR_DEPTH_32BITCOLOR; |
| 493 |
break; |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
int BltState::GetBytesPerTexelScaling(MOS_FORMAT format) |
| 498 |
{ |
| 499 |
int dstBytesPerTexel = 1; |
| 500 |
|
| 501 |
switch (format) |
| 502 |
{ |
| 503 |
case Format_NV12: |
| 504 |
case Format_P010: |
| 505 |
case Format_P016: |
| 506 |
dstBytesPerTexel = 2; |
| 507 |
break; |
| 508 |
|
| 509 |
default: |
| 510 |
dstBytesPerTexel = 1; |
| 511 |
} |
| 512 |
return dstBytesPerTexel; |
| 513 |
} |
| 514 |
|
| 515 |
int BltState::GetPlaneNum(MOS_FORMAT format) |
| 516 |
{ |
| 517 |
|
| 518 |
int planeNum = SINGLE_PLANE; |
| 519 |
|
| 520 |
switch (format) |
| 521 |
{ |
| 522 |
case Format_NV12: |
| 523 |
case Format_P010: |
| 524 |
case Format_P016: |
| 525 |
planeNum = TWO_PLANES; |
| 526 |
break; |
| 527 |
case Format_YV12: |
| 528 |
case Format_I420: |
| 529 |
case Format_444P: |
| 530 |
case Format_RGBP: |
| 531 |
case Format_BGRP: |
| 532 |
case Format_IMC3: |
| 533 |
case Format_411P: |
| 534 |
case Format_422V: |
| 535 |
case Format_422H: |
| 536 |
planeNum = THREE_PLANES; |
| 537 |
break; |
| 538 |
default: |
| 539 |
planeNum = SINGLE_PLANE; |
| 540 |
break; |
| 541 |
} |
| 542 |
return planeNum; |
| 543 |
} |
| 544 |
|
| 545 |
MOS_STATUS BltState::SetPrologParamsforCmdbuffer(PMOS_COMMAND_BUFFER cmdBuffer) |
| 546 |
{ |
| 547 |
PMOS_INTERFACE pOsInterface; |
| 548 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 549 |
uint32_t iRemaining; |
| 550 |
RENDERHAL_GENERIC_PROLOG_PARAMS GenericPrologParams = {}; |
| 551 |
PMOS_RESOURCE gpuStatusBuffer = nullptr; |
| 552 |
|
| 553 |
//--------------------------------------------- |
| 554 |
BLT_CHK_NULL_RETURN(cmdBuffer); |
| 555 |
BLT_CHK_NULL_RETURN(m_osInterface); |
| 556 |
//--------------------------------------------- |
| 557 |
|
| 558 |
eStatus = MOS_STATUS_SUCCESS; |
| 559 |
pOsInterface = m_osInterface; |
| 560 |
|
| 561 |
MOS_GPU_CONTEXT gpuContext = m_osInterface->pfnGetGpuContext(m_osInterface); |
| 562 |
|
| 563 |
#ifndef EMUL |
| 564 |
if (pOsInterface->bEnableKmdMediaFrameTracking) |
| 565 |
{ |
| 566 |
// Get GPU Status buffer |
| 567 |
BLT_CHK_STATUS_RETURN(pOsInterface->pfnGetGpuStatusBufferResource(pOsInterface, gpuStatusBuffer)); |
| 568 |
BLT_CHK_NULL_RETURN(gpuStatusBuffer); |
| 569 |
// Register the buffer |
| 570 |
BLT_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource(pOsInterface, gpuStatusBuffer, true, true)); |
| 571 |
|
| 572 |
GenericPrologParams.bEnableMediaFrameTracking = true; |
| 573 |
GenericPrologParams.presMediaFrameTrackingSurface = gpuStatusBuffer; |
| 574 |
GenericPrologParams.dwMediaFrameTrackingTag = pOsInterface->pfnGetGpuStatusTag(pOsInterface, pOsInterface->CurrentGpuContextOrdinal); |
| 575 |
GenericPrologParams.dwMediaFrameTrackingAddrOffset = pOsInterface->pfnGetGpuStatusTagOffset(pOsInterface, pOsInterface->CurrentGpuContextOrdinal); |
| 576 |
|
| 577 |
// Increment GPU Status Tag |
| 578 |
pOsInterface->pfnIncrementGpuStatusTag(pOsInterface, pOsInterface->CurrentGpuContextOrdinal); |
| 579 |
} |
| 580 |
#endif |
| 581 |
|
| 582 |
if (GenericPrologParams.bEnableMediaFrameTracking) |
| 583 |
{ |
| 584 |
BLT_CHK_NULL_RETURN(GenericPrologParams.presMediaFrameTrackingSurface); |
| 585 |
cmdBuffer->Attributes.bEnableMediaFrameTracking = GenericPrologParams.bEnableMediaFrameTracking; |
| 586 |
cmdBuffer->Attributes.dwMediaFrameTrackingTag = GenericPrologParams.dwMediaFrameTrackingTag; |
| 587 |
cmdBuffer->Attributes.dwMediaFrameTrackingAddrOffset = GenericPrologParams.dwMediaFrameTrackingAddrOffset; |
| 588 |
cmdBuffer->Attributes.resMediaFrameTrackingSurface = GenericPrologParams.presMediaFrameTrackingSurface; |
| 589 |
} |
| 590 |
|
| 591 |
return eStatus; |
| 592 |
} |