| 1 |
/* |
| 2 |
* Copyright (c) 2020, 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_render_copy_next.cpp |
| 24 |
//! \brief render copy implement file |
| 25 |
//! \details render copy implement file |
| 26 |
//! |
| 27 |
|
| 28 |
#include "vpkrnheader.h" |
| 29 |
#include "vp_common_defs.h" |
| 30 |
#include "media_render_copy_next.h" |
| 31 |
#include "media_interfaces_mhw_next.h" |
| 32 |
#include "media_render_common.h" |
| 33 |
|
| 34 |
//! |
| 35 |
//! \brief Initialize MHW Kernel Param struct for loading Kernel |
| 36 |
//! |
| 37 |
#define INIT_MHW_KERNEL_PARAM(MhwKernelParam, _pKernelEntry) \ |
| 38 |
do \ |
| 39 |
{ \ |
| 40 |
MOS_ZeroMemory(&(MhwKernelParam), sizeof(MhwKernelParam)); \ |
| 41 |
(MhwKernelParam).pBinary = (_pKernelEntry)->pBinary; \ |
| 42 |
(MhwKernelParam).iSize = (_pKernelEntry)->iSize; \ |
| 43 |
(MhwKernelParam).iKUID = (_pKernelEntry)->iKUID; \ |
| 44 |
(MhwKernelParam).iKCID = (_pKernelEntry)->iKCID; \ |
| 45 |
(MhwKernelParam).iPaddingSize = (_pKernelEntry)->iPaddingSize; \ |
| 46 |
} while(0) |
| 47 |
|
| 48 |
|
| 49 |
RenderCopyStateNext::RenderCopyStateNext(PMOS_INTERFACE osInterface, MhwInterfacesNext *mhwInterfaces) : |
| 50 |
m_osInterface(osInterface), |
| 51 |
m_mhwInterfaces(mhwInterfaces) |
| 52 |
{ |
| 53 |
if (nullptr == osInterface) |
| 54 |
{ |
| 55 |
MCPY_ASSERTMESSAGE("osInterface is nullptr"); |
| 56 |
return; |
| 57 |
} |
| 58 |
m_RenderData.pKernelParam = (PRENDERHAL_KERNEL_PARAM)g_rendercopy_KernelParam; |
| 59 |
Mos_SetVirtualEngineSupported(osInterface, true); |
| 60 |
osInterface->pfnVirtualEngineSupported(osInterface, true, false); |
| 61 |
|
| 62 |
MOS_NULL_RENDERING_FLAGS NullRenderingFlags; |
| 63 |
NullRenderingFlags = osInterface->pfnGetNullHWRenderFlags(osInterface); |
| 64 |
|
| 65 |
m_bNullHwRenderCopy = |
| 66 |
NullRenderingFlags.VPComp || |
| 67 |
NullRenderingFlags.VPGobal; |
| 68 |
} |
| 69 |
|
| 70 |
RenderCopyStateNext:: ~RenderCopyStateNext() |
| 71 |
{ |
| 72 |
if (m_renderHal != nullptr) |
| 73 |
{ |
| 74 |
if (m_renderHal->pfnDestroy) |
| 75 |
{ |
| 76 |
MOS_STATUS eStatus = m_renderHal->pfnDestroy(m_renderHal); |
| 77 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 78 |
{ |
| 79 |
MCPY_ASSERTMESSAGE("Failed to destroy RenderHal, eStatus:%d.\n", eStatus); |
| 80 |
} |
| 81 |
} |
| 82 |
MOS_FreeMemAndSetNull(m_renderHal); |
| 83 |
} |
| 84 |
|
| 85 |
if (m_cpInterface != nullptr) |
| 86 |
{ |
| 87 |
if (m_osInterface) |
| 88 |
{ |
| 89 |
m_osInterface->pfnDeleteMhwCpInterface(m_cpInterface); |
| 90 |
m_cpInterface = nullptr; |
| 91 |
} |
| 92 |
else |
| 93 |
{ |
| 94 |
MCPY_ASSERTMESSAGE("Failed to destroy cpInterface."); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
// Destroy Kernel DLL objects (cache, hash table, states) |
| 99 |
if (m_pKernelDllState) |
| 100 |
{ |
| 101 |
KernelDll_ReleaseStates(m_pKernelDllState); |
| 102 |
m_pKernelBin = nullptr; |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
MOS_STATUS RenderCopyStateNext::Initialize() |
| 107 |
{ |
| 108 |
RENDERHAL_SETTINGS RenderHalSettings; |
| 109 |
|
| 110 |
MCPY_CHK_NULL_RETURN(m_osInterface); |
| 111 |
|
| 112 |
m_renderHal = (PRENDERHAL_INTERFACE)MOS_AllocAndZeroMemory(sizeof(*m_renderHal)); |
| 113 |
MCPY_CHK_NULL_RETURN(m_renderHal); |
| 114 |
MCPY_CHK_STATUS_RETURN(RenderHal_InitInterface( |
| 115 |
m_renderHal, |
| 116 |
&m_cpInterface, |
| 117 |
m_osInterface)); |
| 118 |
|
| 119 |
// Allocate and initialize HW states |
| 120 |
RenderHalSettings.iMediaStates = 32; |
| 121 |
MCPY_CHK_STATUS_RETURN(m_renderHal->pfnInitialize(m_renderHal, &RenderHalSettings)); |
| 122 |
|
| 123 |
m_renderHal->sseuTable = defaultSSEUTable; |
| 124 |
m_renderHal->forceDisablePreemption = true; |
| 125 |
|
| 126 |
return MOS_STATUS_SUCCESS; |
| 127 |
} |
| 128 |
|
| 129 |
int32_t RenderCopyStateNext::GetBytesPerPixelPerPlane( |
| 130 |
MOS_FORMAT Format) |
| 131 |
{ |
| 132 |
int32_t iBytePerPixelPerPlane = 0; |
| 133 |
|
| 134 |
switch(Format) |
| 135 |
{ |
| 136 |
case Format_NV12: |
| 137 |
case Format_RGBP: |
| 138 |
iBytePerPixelPerPlane = 1; |
| 139 |
break; |
| 140 |
case Format_YUY2: |
| 141 |
case Format_P010: |
| 142 |
case Format_P016: |
| 143 |
iBytePerPixelPerPlane = 2; |
| 144 |
break; |
| 145 |
case Format_Y210: |
| 146 |
case Format_Y216: |
| 147 |
case Format_Y410: |
| 148 |
case Format_AYUV: |
| 149 |
case Format_A8R8G8B8: |
| 150 |
iBytePerPixelPerPlane = 4; |
| 151 |
break; |
| 152 |
case Format_Y416: |
| 153 |
iBytePerPixelPerPlane = 8; |
| 154 |
break; |
| 155 |
default: |
| 156 |
MCPY_ASSERTMESSAGE("can't support formats %d for render copy", Format); |
| 157 |
break; |
| 158 |
} |
| 159 |
|
| 160 |
return iBytePerPixelPerPlane; |
| 161 |
} |
| 162 |
|
| 163 |
MOS_STATUS RenderCopyStateNext::SetupKernel( |
| 164 |
int32_t iKDTIndex) |
| 165 |
{ |
| 166 |
Kdll_CacheEntry* pCacheEntryTable; // Kernel Cache Entry table |
| 167 |
int32_t iKUID = 0; // Kernel Unique ID |
| 168 |
int32_t iInlineLength; // Inline data length |
| 169 |
int32_t iTotalRows; // Total number of row in statistics surface |
| 170 |
int32_t iTotalColumns; // Total number of columns in statistics surface |
| 171 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; // Return code |
| 172 |
uint32_t dwKernelBinSize; |
| 173 |
PMEDIACOPY_RENDER_DATA pRenderData = &m_RenderData; |
| 174 |
const void* pcKernelBin = nullptr; |
| 175 |
|
| 176 |
MCPY_CHK_NULL_RETURN(pRenderData); |
| 177 |
if (iKDTIndex == KERNEL_CopyKernel_1D_to_2D_NV12) |
| 178 |
{ |
| 179 |
iKUID = IDR_VP_CopyKernel_1D_to_2D_NV12_genx; |
| 180 |
} |
| 181 |
else if (iKDTIndex == KERNEL_CopyKernel_2D_to_2D_NV12) |
| 182 |
{ |
| 183 |
iKUID = IDR_VP_CopyKernel_2D_to_2D_NV12_genx; |
| 184 |
} |
| 185 |
else if (iKDTIndex == KERNEL_CopyKernel_2D_to_1D_NV12) |
| 186 |
{ |
| 187 |
iKUID = IDR_VP_CopyKernel_2D_to_1D_NV12_genx; |
| 188 |
} |
| 189 |
else if (iKDTIndex == KERNEL_CopyKernel_1D_to_2D_Planar) |
| 190 |
{ |
| 191 |
iKUID = IDR_VP_CopyKernel_1D_to_2D_RGBP_genx; |
| 192 |
} |
| 193 |
else if (iKDTIndex == KERNEL_CopyKernel_2D_to_2D_Planar) |
| 194 |
{ |
| 195 |
iKUID = IDR_VP_CopyKernel_2D_to_2D_RGBP_genx; |
| 196 |
} |
| 197 |
else if (iKDTIndex == KERNEL_CopyKernel_2D_to_1D_Planar) |
| 198 |
{ |
| 199 |
iKUID = IDR_VP_CopyKernel_2D_to_1D_RGBP_genx; |
| 200 |
} |
| 201 |
else if (iKDTIndex == KERNEL_CopyKernel_1D_to_2D_Packed) |
| 202 |
{ |
| 203 |
iKUID = IDR_VP_CopyKernel_1D_to_2D_genx; |
| 204 |
} |
| 205 |
else if (iKDTIndex == KERNEL_CopyKernel_2D_to_2D_Packed) |
| 206 |
{ |
| 207 |
iKUID = IDR_VP_CopyKernel_2D_to_2D_genx; |
| 208 |
} |
| 209 |
else if (iKDTIndex == KERNEL_CopyKernel_2D_to_1D_Packed) |
| 210 |
{ |
| 211 |
iKUID = IDR_VP_CopyKernel_2D_to_1D_genx; |
| 212 |
} |
| 213 |
else |
| 214 |
{ |
| 215 |
MCPY_ASSERTMESSAGE("Can't find the right kernel."); |
| 216 |
return MOS_STATUS_UNKNOWN; |
| 217 |
} |
| 218 |
|
| 219 |
pcKernelBin = m_KernelBin; |
| 220 |
dwKernelBinSize = m_KernelBinSize; |
| 221 |
|
| 222 |
if (nullptr == m_pKernelBin) |
| 223 |
{ |
| 224 |
m_pKernelBin = MOS_AllocMemory(dwKernelBinSize); |
| 225 |
} |
| 226 |
|
| 227 |
MCPY_CHK_NULL_RETURN(m_pKernelBin); |
| 228 |
MOS_SecureMemcpy(m_pKernelBin, |
| 229 |
dwKernelBinSize, |
| 230 |
pcKernelBin, |
| 231 |
dwKernelBinSize); |
| 232 |
|
| 233 |
// Allocate KDLL state (Kernel Dynamic Linking) |
| 234 |
if (nullptr == m_pKernelDllState) |
| 235 |
{ |
| 236 |
m_pKernelDllState = KernelDll_AllocateStates( |
| 237 |
m_pKernelBin, |
| 238 |
dwKernelBinSize, |
| 239 |
nullptr, |
| 240 |
0, |
| 241 |
nullptr, |
| 242 |
nullptr); |
| 243 |
} |
| 244 |
if (nullptr == m_pKernelDllState) |
| 245 |
{ |
| 246 |
MCPY_ASSERTMESSAGE("Failed to allocate KDLL state."); |
| 247 |
if (m_pKernelBin) |
| 248 |
{ |
| 249 |
MOS_SafeFreeMemory(m_pKernelBin); |
| 250 |
m_pKernelBin = nullptr; |
| 251 |
} |
| 252 |
return MOS_STATUS_NULL_POINTER; |
| 253 |
} |
| 254 |
pCacheEntryTable = |
| 255 |
m_pKernelDllState->ComponentKernelCache.pCacheEntries; |
| 256 |
|
| 257 |
// Set the Kernel Parameters |
| 258 |
pRenderData->pKernelParam = (PRENDERHAL_KERNEL_PARAM)&g_rendercopy_KernelParam[iKDTIndex]; |
| 259 |
pRenderData->PerfTag = VPHAL_NONE; |
| 260 |
|
| 261 |
// Set Kernel entry |
| 262 |
pRenderData->KernelEntry.iKUID = iKUID; |
| 263 |
pRenderData->KernelEntry.iKCID = -1; |
| 264 |
pRenderData->KernelEntry.iSize = pCacheEntryTable[iKUID].iSize; |
| 265 |
pRenderData->KernelEntry.pBinary = pCacheEntryTable[iKUID].pBinary; |
| 266 |
|
| 267 |
return eStatus; |
| 268 |
} |
| 269 |
|
| 270 |
MOS_STATUS RenderCopyStateNext::SubmitCMD() |
| 271 |
{ |
| 272 |
PRENDERHAL_INTERFACE pRenderHal; |
| 273 |
PMOS_INTERFACE pOsInterface; |
| 274 |
MHW_KERNEL_PARAM MhwKernelParam; |
| 275 |
int32_t iKrnAllocation; |
| 276 |
int32_t iCurbeOffset; |
| 277 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 278 |
|
| 279 |
PMEDIACOPY_RENDER_DATA pRenderData = &m_RenderData; |
| 280 |
MHW_WALKER_PARAMS WalkerParams = {0}; |
| 281 |
PMHW_WALKER_PARAMS pWalkerParams = nullptr; |
| 282 |
MHW_GPGPU_WALKER_PARAMS ComputeWalkerParams = {0}; |
| 283 |
PMHW_GPGPU_WALKER_PARAMS pComputeWalkerParams = nullptr; |
| 284 |
MOS_GPUCTX_CREATOPTIONS_ENHANCED createOption = {}; |
| 285 |
|
| 286 |
pRenderHal = m_renderHal; |
| 287 |
pOsInterface = m_osInterface; |
| 288 |
// no gpucontext will be created if the gpu context has been created before. |
| 289 |
MCPY_CHK_STATUS_RETURN(pOsInterface->pfnCreateGpuContext( |
| 290 |
m_osInterface, |
| 291 |
MOS_GPU_CONTEXT_COMPUTE, |
| 292 |
MOS_GPU_NODE_COMPUTE, |
| 293 |
&createOption)); |
| 294 |
|
| 295 |
// Register context with the Batch Buffer completion event |
| 296 |
MCPY_CHK_STATUS_RETURN(m_osInterface->pfnRegisterBBCompleteNotifyEvent( |
| 297 |
m_osInterface, |
| 298 |
MOS_GPU_CONTEXT_COMPUTE)); |
| 299 |
|
| 300 |
// Set GPU Context to Render Engine |
| 301 |
MCPY_CHK_STATUS_RETURN(pOsInterface->pfnSetGpuContext(pOsInterface, MOS_GPU_CONTEXT_COMPUTE)); |
| 302 |
|
| 303 |
pOsInterface->pfnDisableNativeFenceSyncByCmd(pOsInterface, pOsInterface->CurrentGpuContextHandle); |
| 304 |
|
| 305 |
// Reset allocation list and house keeping |
| 306 |
m_osInterface->pfnResetOsStates(pOsInterface); |
| 307 |
|
| 308 |
// Register the resource of GSH |
| 309 |
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnReset(pRenderHal)); |
| 310 |
|
| 311 |
// Set copy kernel |
| 312 |
SetupKernel(m_currKernelId); |
| 313 |
|
| 314 |
//---------------------------------- |
| 315 |
// Allocate and reset media state |
| 316 |
//---------------------------------- |
| 317 |
pRenderData->pMediaState = pRenderHal->pfnAssignMediaState(pRenderHal, RENDERHAL_COMPONENT_RENDER_COPY); |
| 318 |
MCPY_CHK_NULL_RETURN(pRenderData->pMediaState); |
| 319 |
|
| 320 |
// Allocate and reset SSH instance |
| 321 |
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnAssignSshInstance(pRenderHal)); |
| 322 |
|
| 323 |
// Assign and Reset Binding Table |
| 324 |
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnAssignBindingTable( |
| 325 |
pRenderHal, |
| 326 |
&pRenderData->iBindingTable)); |
| 327 |
|
| 328 |
// Setup surface states |
| 329 |
MCPY_CHK_STATUS_RETURN(SetupSurfaceStates()) |
| 330 |
|
| 331 |
// load static data |
| 332 |
MCPY_CHK_STATUS_RETURN(LoadStaticData( |
| 333 |
&iCurbeOffset)); |
| 334 |
|
| 335 |
//---------------------------------- |
| 336 |
// Setup VFE State params. Each Renderer MUST call pfnSetVfeStateParams(). |
| 337 |
//---------------------------------- |
| 338 |
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnSetVfeStateParams( |
| 339 |
pRenderHal, |
| 340 |
MEDIASTATE_DEBUG_COUNTER_FREE_RUNNING, |
| 341 |
pRenderData->pKernelParam->Thread_Count, |
| 342 |
pRenderData->iCurbeLength, |
| 343 |
pRenderData->iInlineLength, |
| 344 |
nullptr)); |
| 345 |
|
| 346 |
//---------------------------------- |
| 347 |
// Load kernel to GSH |
| 348 |
//---------------------------------- |
| 349 |
INIT_MHW_KERNEL_PARAM(MhwKernelParam, &pRenderData->KernelEntry); |
| 350 |
iKrnAllocation = pRenderHal->pfnLoadKernel( |
| 351 |
pRenderHal, |
| 352 |
pRenderData->pKernelParam, |
| 353 |
&MhwKernelParam, |
| 354 |
nullptr); |
| 355 |
if (iKrnAllocation < 0) |
| 356 |
{ |
| 357 |
eStatus = MOS_STATUS_UNKNOWN; |
| 358 |
return eStatus; |
| 359 |
} |
| 360 |
|
| 361 |
//---------------------------------- |
| 362 |
// Allocate Media ID, link to kernel |
| 363 |
//---------------------------------- |
| 364 |
pRenderData->iMediaID = pRenderHal->pfnAllocateMediaID( |
| 365 |
pRenderHal, |
| 366 |
iKrnAllocation, |
| 367 |
pRenderData->iBindingTable, |
| 368 |
iCurbeOffset, |
| 369 |
pRenderData->pKernelParam->CURBE_Length << 5, |
| 370 |
0, |
| 371 |
nullptr); |
| 372 |
if (pRenderData->iMediaID < 0) |
| 373 |
{ |
| 374 |
eStatus = MOS_STATUS_UNKNOWN; |
| 375 |
return eStatus; |
| 376 |
} |
| 377 |
|
| 378 |
// Set Perf Tag |
| 379 |
pOsInterface->pfnResetPerfBufferID(pOsInterface); |
| 380 |
m_osInterface->pfnSetPerfTag(m_osInterface, RENDER_COPY); |
| 381 |
|
| 382 |
// Setup Compute Walker |
| 383 |
pWalkerParams = nullptr; |
| 384 |
pComputeWalkerParams = &ComputeWalkerParams; |
| 385 |
|
| 386 |
RenderCopyComputerWalker( |
| 387 |
&ComputeWalkerParams); |
| 388 |
|
| 389 |
// Submit all states to render the kernel |
| 390 |
//VpHal_RndrCommonSubmitCommands( |
| 391 |
MediaRenderCommon::EukernelSubmitCommands( |
| 392 |
pRenderHal, |
| 393 |
nullptr, |
| 394 |
m_bNullHwRenderCopy, |
| 395 |
pWalkerParams, |
| 396 |
pComputeWalkerParams, |
| 397 |
(VpKernelID)kernelRenderCopy, |
| 398 |
true); |
| 399 |
|
| 400 |
return eStatus; |
| 401 |
} |
| 402 |
|
| 403 |
MOS_STATUS RenderCopyStateNext::GetCurentKernelID( ) |
| 404 |
{ |
| 405 |
int32_t iBytePerPixelPerPlane = GetBytesPerPixelPerPlane(m_Source.Format); |
| 406 |
|
| 407 |
if ((iBytePerPixelPerPlane < 1) || (iBytePerPixelPerPlane > 8)) |
| 408 |
{ |
| 409 |
MCPY_ASSERTMESSAGE("GetCurentKernelID wrong pixel size."); |
| 410 |
return MOS_STATUS_INVALID_PARAMETER; |
| 411 |
} |
| 412 |
|
| 413 |
// This scheme is temporary |
| 414 |
// for a !MOS_TILE_LINEAR plane surface, it is 2D surface. |
| 415 |
// for a MOS_TILE_LINEAR plane surface, if (dwWidth * bytes_per_pixel < dwPitch) it is 2D surface |
| 416 |
// if (dwWidth * bytes_per_pixel == dwPitch) it is a 1D surface. |
| 417 |
|
| 418 |
if ((m_Source.Format == Format_NV12) || (m_Source.Format == Format_P010) || (m_Source.Format == Format_P016)) |
| 419 |
{ |
| 420 |
if (m_Source.TileType == MOS_TILE_LINEAR && m_Target.TileType != MOS_TILE_LINEAR) |
| 421 |
{ |
| 422 |
m_currKernelId = KERNEL_CopyKernel_1D_to_2D_NV12; |
| 423 |
} |
| 424 |
else if (m_Source.TileType != MOS_TILE_LINEAR && m_Target.TileType == MOS_TILE_LINEAR) |
| 425 |
{ |
| 426 |
m_currKernelId = KERNEL_CopyKernel_2D_to_1D_NV12; |
| 427 |
} |
| 428 |
else if (m_Source.TileType != MOS_TILE_LINEAR && m_Target.TileType != MOS_TILE_LINEAR) |
| 429 |
{ |
| 430 |
m_currKernelId = KERNEL_CopyKernel_2D_to_2D_NV12; |
| 431 |
} |
| 432 |
else |
| 433 |
{ |
| 434 |
m_currKernelId = KERNEL_CopyKernel_MAX; |
| 435 |
MCPY_ASSERTMESSAGE("Can't find right kernel to support, pls help to check input parameters."); |
| 436 |
return MOS_STATUS_INVALID_PARAMETER; |
| 437 |
} |
| 438 |
} |
| 439 |
else if (m_Source.Format == Format_RGBP) |
| 440 |
{ |
| 441 |
if (m_Source.TileType == MOS_TILE_LINEAR && m_Target.TileType != MOS_TILE_LINEAR) |
| 442 |
{ |
| 443 |
m_currKernelId = KERNEL_CopyKernel_1D_to_2D_Planar; |
| 444 |
} |
| 445 |
else if (m_Source.TileType != MOS_TILE_LINEAR && m_Target.TileType == MOS_TILE_LINEAR) |
| 446 |
{ |
| 447 |
m_currKernelId = KERNEL_CopyKernel_2D_to_1D_Planar; |
| 448 |
} |
| 449 |
else if (m_Source.TileType != MOS_TILE_LINEAR && m_Target.TileType != MOS_TILE_LINEAR) |
| 450 |
{ |
| 451 |
m_currKernelId = KERNEL_CopyKernel_2D_to_2D_Planar; |
| 452 |
} |
| 453 |
else |
| 454 |
{ |
| 455 |
m_currKernelId = KERNEL_CopyKernel_MAX; |
| 456 |
MCPY_ASSERTMESSAGE("kernel can't support it."); |
| 457 |
return MOS_STATUS_INVALID_PARAMETER; |
| 458 |
} |
| 459 |
} |
| 460 |
else if ((m_Source.Format == Format_YUY2) || (m_Source.Format == Format_Y210) || (m_Source.Format == Format_Y216) |
| 461 |
|| (m_Source.Format == Format_AYUV) || (m_Source.Format == Format_Y410) || (m_Source.Format == Format_Y416) |
| 462 |
|| (m_Source.Format == Format_A8R8G8B8)) |
| 463 |
{ |
| 464 |
if (m_Source.TileType == MOS_TILE_LINEAR && m_Target.TileType != MOS_TILE_LINEAR) |
| 465 |
{ |
| 466 |
m_currKernelId = KERNEL_CopyKernel_1D_to_2D_Packed; |
| 467 |
} |
| 468 |
else if (m_Source.TileType != MOS_TILE_LINEAR && m_Target.TileType == MOS_TILE_LINEAR) |
| 469 |
{ |
| 470 |
m_currKernelId = KERNEL_CopyKernel_2D_to_1D_Packed; |
| 471 |
} |
| 472 |
else if (m_Source.TileType != MOS_TILE_LINEAR && m_Target.TileType != MOS_TILE_LINEAR) |
| 473 |
{ |
| 474 |
m_currKernelId = KERNEL_CopyKernel_2D_to_2D_Packed; |
| 475 |
} |
| 476 |
else |
| 477 |
{ |
| 478 |
m_currKernelId = KERNEL_CopyKernel_MAX; |
| 479 |
MCPY_ASSERTMESSAGE("kernel can't support it."); |
| 480 |
return MOS_STATUS_INVALID_PARAMETER; |
| 481 |
} |
| 482 |
|
| 483 |
} |
| 484 |
MCPY_NORMALMESSAGE("Used Render copy and currentKernel id = %d.", m_currKernelId); |
| 485 |
return MOS_STATUS_SUCCESS; |
| 486 |
} |
| 487 |
|
| 488 |
//! |
| 489 |
//! \brief setup surface states |
| 490 |
//! \details Setup surface states for fast 1toN |
| 491 |
//! \return MOS_STATUS |
| 492 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 493 |
//! |
| 494 |
MOS_STATUS RenderCopyStateNext::SetupSurfaceStates() |
| 495 |
{ |
| 496 |
RENDERHAL_SURFACE_STATE_PARAMS SurfaceParams; |
| 497 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 498 |
uint32_t index; |
| 499 |
uint32_t width = 0; |
| 500 |
MOS_FORMAT format = Format_NV12; |
| 501 |
int32_t iBTEntry; |
| 502 |
PRENDERHAL_INTERFACE pRenderHal = m_renderHal; |
| 503 |
PMEDIACOPY_RENDER_DATA pRenderData = &m_RenderData; |
| 504 |
RENDERHAL_SURFACE RenderHalSource = {}; // source for mhw |
| 505 |
RENDERHAL_SURFACE RenderHalTarget = {}; |
| 506 |
MCPY_CHK_NULL_RETURN(pRenderHal); |
| 507 |
MCPY_CHK_NULL_RETURN(pRenderData); |
| 508 |
// Source surface |
| 509 |
MOS_ZeroMemory(&SurfaceParams, sizeof(SurfaceParams)); |
| 510 |
|
| 511 |
pRenderData->SurfMemObjCtl.SourceSurfMemObjCtl = |
| 512 |
pRenderHal->pOsInterface->pfnCachePolicyGetMemoryObject( |
| 513 |
MOS_HW_RESOURCE_USAGE_VP_INPUT_PICTURE_RENDER, |
| 514 |
pRenderHal->pOsInterface->pfnGetGmmClientContext(pRenderHal->pOsInterface)).DwordValue; |
| 515 |
|
| 516 |
pRenderData->SurfMemObjCtl.TargetSurfMemObjCtl = pRenderData->SurfMemObjCtl.SourceSurfMemObjCtl; |
| 517 |
|
| 518 |
SurfaceParams.bAVS = false; |
| 519 |
SurfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_SRCRECT; |
| 520 |
SurfaceParams.isOutput = false; |
| 521 |
SurfaceParams.MemObjCtl = pRenderData->SurfMemObjCtl.SourceSurfMemObjCtl; |
| 522 |
|
| 523 |
SurfaceParams.Type = RENDERHAL_SURFACE_TYPE_G10; |
| 524 |
SurfaceParams.bWidthInDword_Y = false; |
| 525 |
SurfaceParams.bWidthInDword_UV = false; |
| 526 |
SurfaceParams.bWidth16Align = false; |
| 527 |
|
| 528 |
if (Format_NV12 == m_Target.Format) |
| 529 |
{ |
| 530 |
// set NV12 as 2 plane because render copy only uses DP reading&writing. |
| 531 |
RenderHalSource.SurfType = RENDERHAL_SURF_OUT_RENDERTARGET; |
| 532 |
RenderHalTarget.SurfType = RENDERHAL_SURF_OUT_RENDERTARGET; |
| 533 |
} |
| 534 |
|
| 535 |
if (m_currKernelId == KERNEL_CopyKernel_1D_to_2D_NV12 |
| 536 |
|| m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Planar |
| 537 |
|| m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Packed) |
| 538 |
{ |
| 539 |
format = m_Source.Format; |
| 540 |
width = m_Source.dwWidth; |
| 541 |
m_Source.Format = Format_RAW; |
| 542 |
|
| 543 |
if ((format == Format_NV12) || (format == Format_P010) || (format == Format_P016)) |
| 544 |
{ |
| 545 |
m_Source.dwWidth = (m_Source.dwHeight * m_Source.dwPitch) * 3 / 2; |
| 546 |
} |
| 547 |
else if (format == Format_RGBP) |
| 548 |
{ |
| 549 |
m_Source.dwWidth = (m_Source.dwHeight * m_Source.dwPitch) * 3; |
| 550 |
} |
| 551 |
else if ((format == Format_YUY2) || (format == Format_Y210) || (format == Format_Y216) |
| 552 |
|| (format == Format_AYUV) || (format == Format_Y410) || (format == Format_Y416) |
| 553 |
|| (format == Format_A8R8G8B8)) |
| 554 |
{ |
| 555 |
m_Source.dwWidth = m_Source.dwHeight * m_Source.dwPitch; |
| 556 |
} |
| 557 |
|
| 558 |
m_Source.dwWidth = MOS_ALIGN_CEIL(m_Source.dwWidth, 128); |
| 559 |
//1D surfaces |
| 560 |
MCPY_CHK_STATUS_RETURN(MediaRenderCommon::Set1DSurfaceForHwAccess( |
| 561 |
pRenderHal, |
| 562 |
&m_Source, |
| 563 |
&RenderHalSource, |
| 564 |
&SurfaceParams, |
| 565 |
pRenderData->iBindingTable, |
| 566 |
RENDERCOPY_SRC_INDEX, |
| 567 |
false)); |
| 568 |
m_Source.Format = format; |
| 569 |
m_Source.dwWidth = width; |
| 570 |
} |
| 571 |
else { |
| 572 |
//2D surfaces |
| 573 |
MCPY_CHK_STATUS_RETURN(MediaRenderCommon::Set2DSurfaceForHwAccess( |
| 574 |
pRenderHal, |
| 575 |
&m_Source, |
| 576 |
&RenderHalSource, |
| 577 |
&SurfaceParams, |
| 578 |
pRenderData->iBindingTable, |
| 579 |
RENDERCOPY_SRC_INDEX, |
| 580 |
false)); |
| 581 |
} |
| 582 |
|
| 583 |
// Target surface |
| 584 |
SurfaceParams.MemObjCtl = pRenderData->SurfMemObjCtl.TargetSurfMemObjCtl; |
| 585 |
SurfaceParams.Type = pRenderHal->SurfaceTypeDefault; |
| 586 |
SurfaceParams.isOutput = true; |
| 587 |
SurfaceParams.bAVS = false; |
| 588 |
SurfaceParams.Boundary = RENDERHAL_SS_BOUNDARY_DSTRECT; |
| 589 |
|
| 590 |
if (m_currKernelId == KERNEL_CopyKernel_2D_to_1D_NV12 |
| 591 |
|| m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Planar |
| 592 |
|| m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Packed) |
| 593 |
{ |
| 594 |
format = m_Target.Format; |
| 595 |
width = m_Target.dwWidth; |
| 596 |
m_Target.Format = Format_RAW; |
| 597 |
|
| 598 |
if ((format == Format_NV12) || (format == Format_P010) || (format == Format_P016)) |
| 599 |
{ |
| 600 |
m_Target.dwWidth = (m_Target.dwHeight * m_Target.dwPitch) * 3 / 2; |
| 601 |
} |
| 602 |
else if (format == Format_RGBP) |
| 603 |
{ |
| 604 |
m_Target.dwWidth = (m_Target.dwHeight * m_Target.dwPitch) * 3; |
| 605 |
} |
| 606 |
else if ((format == Format_YUY2) || (format == Format_Y210) || (format == Format_Y216) |
| 607 |
|| (format == Format_AYUV) || (format == Format_Y410) || (format == Format_Y416) |
| 608 |
|| (format == Format_A8R8G8B8)) |
| 609 |
{ |
| 610 |
m_Target.dwWidth = m_Target.dwHeight * m_Target.dwPitch; |
| 611 |
} |
| 612 |
|
| 613 |
m_Target.dwWidth = MOS_ALIGN_CEIL(m_Target.dwWidth, 128); |
| 614 |
|
| 615 |
//1D surface. |
| 616 |
MCPY_CHK_STATUS_RETURN(MediaRenderCommon::Set1DSurfaceForHwAccess( |
| 617 |
pRenderHal, |
| 618 |
&m_Target, |
| 619 |
&RenderHalTarget, |
| 620 |
&SurfaceParams, |
| 621 |
pRenderData->iBindingTable, |
| 622 |
RENDERCOPY_DST_INDEX, |
| 623 |
true)); |
| 624 |
m_Target.Format = format; |
| 625 |
m_Target.dwWidth = width; |
| 626 |
} |
| 627 |
else |
| 628 |
{ |
| 629 |
//2D surface. |
| 630 |
MCPY_CHK_STATUS_RETURN(MediaRenderCommon::Set2DSurfaceForHwAccess( |
| 631 |
pRenderHal, |
| 632 |
&m_Target, |
| 633 |
&RenderHalTarget, |
| 634 |
&SurfaceParams, |
| 635 |
pRenderData->iBindingTable, |
| 636 |
RENDERCOPY_DST_INDEX, |
| 637 |
true)); |
| 638 |
|
| 639 |
} |
| 640 |
|
| 641 |
return eStatus; |
| 642 |
} |
| 643 |
|
| 644 |
|
| 645 |
MOS_STATUS RenderCopyStateNext::LoadStaticData( |
| 646 |
int32_t* piCurbeOffset) |
| 647 |
{ |
| 648 |
DP_RENDERCOPY_NV12_STATIC_DATA WalkerNV12Static; |
| 649 |
DP_RENDERCOPY_RGBP_STATIC_DATA WalkerPlanarStatic; |
| 650 |
DP_RENDERCOPY_PACKED_STATIC_DATA WalkerSinglePlaneStatic; |
| 651 |
|
| 652 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 653 |
int32_t iCurbeLength = 0; |
| 654 |
int32_t iBytePerPixelPerPlane = GetBytesPerPixelPerPlane(m_Target.Format); |
| 655 |
PRENDERHAL_INTERFACE pRenderHal = m_renderHal; |
| 656 |
PMEDIACOPY_RENDER_DATA pRenderData = &m_RenderData; |
| 657 |
|
| 658 |
MCPY_CHK_NULL_RETURN(pRenderHal); |
| 659 |
MCPY_CHK_NULL_RETURN(pRenderData); |
| 660 |
if ((iBytePerPixelPerPlane < 1) || (iBytePerPixelPerPlane > 8)) |
| 661 |
{ |
| 662 |
MCPY_ASSERTMESSAGE("LoadStaticData wrong pixel size."); |
| 663 |
return MOS_STATUS_INVALID_PARAMETER; |
| 664 |
} |
| 665 |
|
| 666 |
int32_t srcResourceOffset = (int32_t)(m_Source.OsResource.pGmmResInfo->GetPlanarXOffset(GMM_NO_PLANE)); |
| 667 |
int32_t dstResourceOffset = (int32_t)(m_Target.OsResource.pGmmResInfo->GetPlanarXOffset(GMM_NO_PLANE)); |
| 668 |
|
| 669 |
if (srcResourceOffset) |
| 670 |
{ |
| 671 |
m_Source.dwOffset -= srcResourceOffset; |
| 672 |
} |
| 673 |
|
| 674 |
if (dstResourceOffset) |
| 675 |
{ |
| 676 |
m_Target.dwOffset -= dstResourceOffset; |
| 677 |
} |
| 678 |
|
| 679 |
if ((m_Target.Format == Format_NV12) || ((m_Target.Format == Format_P010) || (m_Target.Format == Format_P016))) |
| 680 |
{ |
| 681 |
// Set relevant static data |
| 682 |
MOS_ZeroMemory(&WalkerNV12Static, sizeof(DP_RENDERCOPY_NV12_STATIC_DATA)); |
| 683 |
|
| 684 |
WalkerNV12Static.DW0.Inputsurfaceindex = RENDERCOPY_SRC_INDEX; |
| 685 |
WalkerNV12Static.DW1.Outputsurfaceindex = RENDERCOPY_DST_INDEX; |
| 686 |
|
| 687 |
if (m_currKernelId == KERNEL_CopyKernel_1D_to_2D_NV12) |
| 688 |
{ |
| 689 |
WalkerNV12Static.DW2.Widthdword = (m_Source.dwWidth * iBytePerPixelPerPlane + 3) / 4; |
| 690 |
WalkerNV12Static.DW3.Height = m_Source.dwHeight; |
| 691 |
WalkerNV12Static.DW4.ShiftLeftOffsetInBytes = m_Source.dwOffset; |
| 692 |
WalkerNV12Static.DW5.Widthstride = m_Source.dwPitch; |
| 693 |
WalkerNV12Static.DW6.Heightstride = m_Source.dwHeight; |
| 694 |
} |
| 695 |
else |
| 696 |
{ |
| 697 |
WalkerNV12Static.DW2.Widthdword = (m_Source.dwWidth < m_Target.dwWidth) ? m_Source.dwWidth : m_Target.dwWidth; |
| 698 |
WalkerNV12Static.DW2.Widthdword = (WalkerNV12Static.DW2.Widthdword * iBytePerPixelPerPlane + 3) / 4; |
| 699 |
WalkerNV12Static.DW3.Height = (m_Source.dwHeight < m_Target.dwHeight) ? m_Source.dwHeight:m_Target.dwHeight; |
| 700 |
WalkerNV12Static.DW4.ShiftLeftOffsetInBytes = m_Target.dwOffset; |
| 701 |
WalkerNV12Static.DW5.Widthstride = m_Target.dwPitch; |
| 702 |
WalkerNV12Static.DW6.Heightstride = m_Target.dwHeight; |
| 703 |
} |
| 704 |
|
| 705 |
iCurbeLength = sizeof(DP_RENDERCOPY_NV12_STATIC_DATA); |
| 706 |
MCPY_NORMALMESSAGE("Load Curbe data: DW0.Inputsurfaceindex = %d, DW1.Outputsurfaceindex = %d, DW2.WidthDWord= %d, DW3.Height= %d," |
| 707 |
"DW4.ShiftLeftOffsetInBytes= %d,DW5.Widthstride = %d, DW6.Heightstride = % d.", |
| 708 |
WalkerNV12Static.DW0.Inputsurfaceindex, |
| 709 |
WalkerNV12Static.DW1.Outputsurfaceindex, |
| 710 |
WalkerNV12Static.DW2.Widthdword, |
| 711 |
WalkerNV12Static.DW3.Height, |
| 712 |
WalkerNV12Static.DW4.ShiftLeftOffsetInBytes, |
| 713 |
WalkerNV12Static.DW5.Widthstride, |
| 714 |
WalkerNV12Static.DW6.Heightstride); |
| 715 |
*piCurbeOffset = pRenderHal->pfnLoadCurbeData( |
| 716 |
pRenderHal, |
| 717 |
pRenderData->pMediaState, |
| 718 |
&WalkerNV12Static, |
| 719 |
iCurbeLength); |
| 720 |
} |
| 721 |
else if (m_Target.Format == Format_RGBP) |
| 722 |
{ |
| 723 |
// Set relevant static data |
| 724 |
MOS_ZeroMemory(&WalkerPlanarStatic, sizeof(DP_RENDERCOPY_RGBP_STATIC_DATA)); |
| 725 |
|
| 726 |
if (m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Planar) |
| 727 |
{ |
| 728 |
WalkerPlanarStatic.DW0.InputsurfaceRindex = RENDERCOPY_SRC_INDEX + 2; |
| 729 |
WalkerPlanarStatic.DW1.InputsurfaceGindex = RENDERCOPY_SRC_INDEX; |
| 730 |
WalkerPlanarStatic.DW2.InputsurfaceBindex = RENDERCOPY_SRC_INDEX + 1; |
| 731 |
} |
| 732 |
else |
| 733 |
{ |
| 734 |
WalkerPlanarStatic.DW0.InputsurfaceRindex = RENDERCOPY_SRC_INDEX; |
| 735 |
WalkerPlanarStatic.DW1.InputsurfaceGindex = RENDERCOPY_SRC_INDEX + 1; |
| 736 |
WalkerPlanarStatic.DW2.InputsurfaceBindex = RENDERCOPY_SRC_INDEX + 2; |
| 737 |
} |
| 738 |
|
| 739 |
if (m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Planar) |
| 740 |
{ |
| 741 |
WalkerPlanarStatic.DW3.OutputsurfaceRindex = RENDERCOPY_DST_INDEX + 2; |
| 742 |
WalkerPlanarStatic.DW4.OutputsurfaceGindex = RENDERCOPY_DST_INDEX; |
| 743 |
WalkerPlanarStatic.DW5.OutputsurfaceBindex = RENDERCOPY_DST_INDEX + 1; |
| 744 |
} |
| 745 |
else |
| 746 |
{ |
| 747 |
WalkerPlanarStatic.DW3.OutputsurfaceRindex = RENDERCOPY_DST_INDEX; |
| 748 |
WalkerPlanarStatic.DW4.OutputsurfaceGindex = RENDERCOPY_DST_INDEX + 1; |
| 749 |
WalkerPlanarStatic.DW5.OutputsurfaceBindex = RENDERCOPY_DST_INDEX + 2; |
| 750 |
} |
| 751 |
|
| 752 |
if (m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Planar) |
| 753 |
{ |
| 754 |
WalkerPlanarStatic.DW6.Widthdword = m_Source.dwPitch / 4; |
| 755 |
WalkerPlanarStatic.DW7.Height = m_Source.dwHeight; |
| 756 |
WalkerPlanarStatic.DW8.ShiftLeftOffsetInBytes = m_Source.dwOffset; |
| 757 |
} |
| 758 |
else |
| 759 |
{ |
| 760 |
WalkerPlanarStatic.DW6.Widthdword = m_Target.dwPitch / 4; |
| 761 |
WalkerPlanarStatic.DW7.Height = m_Target.dwHeight; |
| 762 |
WalkerPlanarStatic.DW8.ShiftLeftOffsetInBytes = m_Target.dwOffset; |
| 763 |
} |
| 764 |
|
| 765 |
WalkerPlanarStatic.DW9.WidthdwordNoPadding = (m_Source.dwWidth < m_Target.dwWidth) ? m_Source.dwWidth : m_Target.dwWidth; |
| 766 |
WalkerPlanarStatic.DW9.WidthdwordNoPadding = (WalkerPlanarStatic.DW9.WidthdwordNoPadding * iBytePerPixelPerPlane + 3) / 4; |
| 767 |
WalkerPlanarStatic.DW10.Dst2DStartX = 0; |
| 768 |
WalkerPlanarStatic.DW11.Dst2DStartY = 0; |
| 769 |
|
| 770 |
iCurbeLength = sizeof(DP_RENDERCOPY_RGBP_STATIC_DATA); |
| 771 |
MCPY_NORMALMESSAGE("Load Curbe data: DW0.InputsurfaceRindex = %d, DW1.InputsurfaceGindex = %d, DW2.InputsurfaceBindex= %d, DW3.Height= %d," |
| 772 |
"DW4.OutputsurfaceGindex = %d, DW5.OutputsurfaceBindex = %d, DW6.Widthdword = %d, DW7.Height = %d, DW8.ShiftLeftOffsetInByte= %d," |
| 773 |
"DW9.WidthdwordNoPadding = %d, WalkerPlanarStatic.DW10.Dst2DStartX = %d, WalkerPlanarStatic.DW11.Dst2DStartY = %d.", |
| 774 |
WalkerPlanarStatic.DW0.InputsurfaceRindex, |
| 775 |
WalkerPlanarStatic.DW1.InputsurfaceGindex, |
| 776 |
WalkerPlanarStatic.DW2.InputsurfaceBindex, |
| 777 |
WalkerPlanarStatic.DW3.OutputsurfaceRindex, |
| 778 |
WalkerPlanarStatic.DW4.OutputsurfaceGindex, |
| 779 |
WalkerPlanarStatic.DW5.OutputsurfaceBindex, |
| 780 |
WalkerPlanarStatic.DW6.Widthdword, |
| 781 |
WalkerPlanarStatic.DW7.Height, |
| 782 |
WalkerPlanarStatic.DW8.ShiftLeftOffsetInBytes, |
| 783 |
WalkerPlanarStatic.DW9.WidthdwordNoPadding, |
| 784 |
WalkerPlanarStatic.DW10.Dst2DStartX, |
| 785 |
WalkerPlanarStatic.DW11.Dst2DStartY); |
| 786 |
|
| 787 |
*piCurbeOffset = pRenderHal->pfnLoadCurbeData( |
| 788 |
pRenderHal, |
| 789 |
pRenderData->pMediaState, |
| 790 |
&WalkerPlanarStatic, |
| 791 |
iCurbeLength); |
| 792 |
} |
| 793 |
else if ((m_Target.Format == Format_YUY2) || (m_Target.Format == Format_Y210) || (m_Target.Format == Format_Y216) |
| 794 |
|| (m_Target.Format == Format_AYUV) || (m_Target.Format == Format_Y410) || (m_Target.Format == Format_Y416) |
| 795 |
|| (m_Target.Format == Format_A8R8G8B8)) |
| 796 |
{ |
| 797 |
// Set relevant static data |
| 798 |
MOS_ZeroMemory(&WalkerSinglePlaneStatic, sizeof(WalkerSinglePlaneStatic)); |
| 799 |
|
| 800 |
WalkerSinglePlaneStatic.DW0.InputSurfaceIndex = RENDERCOPY_SRC_INDEX; |
| 801 |
WalkerSinglePlaneStatic.DW1.OutputSurfaceIndex = RENDERCOPY_DST_INDEX; |
| 802 |
if (m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Packed) |
| 803 |
{ |
| 804 |
WalkerSinglePlaneStatic.DW2.WidthDWord = m_Source.dwPitch / 4; |
| 805 |
WalkerSinglePlaneStatic.DW3.Height = m_Source.dwHeight; |
| 806 |
WalkerSinglePlaneStatic.DW4.ShiftLeftOffsetInBytes = m_Source.dwOffset; |
| 807 |
} |
| 808 |
else |
| 809 |
{ |
| 810 |
WalkerSinglePlaneStatic.DW2.WidthDWord = m_Target.dwPitch / 4; |
| 811 |
WalkerSinglePlaneStatic.DW3.Height = m_Target.dwHeight; |
| 812 |
WalkerSinglePlaneStatic.DW4.ShiftLeftOffsetInBytes = m_Target.dwOffset; |
| 813 |
} |
| 814 |
|
| 815 |
if ((m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Packed) || (m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Packed)) |
| 816 |
{ |
| 817 |
WalkerSinglePlaneStatic.DW5.ThreadHeight = (m_Source.dwHeight < m_Target.dwHeight) ? m_Source.dwHeight : m_Target.dwHeight; |
| 818 |
WalkerSinglePlaneStatic.DW5.ThreadHeight = (WalkerSinglePlaneStatic.DW5.ThreadHeight + 32 - 1) / 32; |
| 819 |
} |
| 820 |
else if (m_currKernelId == KERNEL_CopyKernel_2D_to_2D_Packed) |
| 821 |
{ |
| 822 |
WalkerSinglePlaneStatic.DW5.ThreadHeight = (m_Source.dwHeight + 8 - 1) / 8; |
| 823 |
} |
| 824 |
else |
| 825 |
{ |
| 826 |
MCPY_ASSERTMESSAGE("LoadStaticData wrong kernel file."); |
| 827 |
return MOS_STATUS_INVALID_PARAMETER; |
| 828 |
} |
| 829 |
|
| 830 |
WalkerSinglePlaneStatic.DW6.WidthdwordNoPadding = (m_Source.dwWidth < m_Target.dwWidth) ? m_Source.dwWidth : m_Target.dwWidth; |
| 831 |
WalkerSinglePlaneStatic.DW6.WidthdwordNoPadding = (WalkerSinglePlaneStatic.DW6.WidthdwordNoPadding * iBytePerPixelPerPlane + 3) / 4; |
| 832 |
WalkerSinglePlaneStatic.DW7.Dst2DStartX = 0; |
| 833 |
WalkerSinglePlaneStatic.DW8.Dst2DStartY = 0; |
| 834 |
|
| 835 |
iCurbeLength = sizeof(DP_RENDERCOPY_PACKED_STATIC_DATA); |
| 836 |
MCPY_NORMALMESSAGE("Load Curbe data: DW0.InputSurfaceIndex = %d, DW1.OutputSurfaceIndex = %d, DW2.WidthDWord= %d, DW3.Height= %d," |
| 837 |
"DW4.ShiftLeftOffsetInBytes= %d,DW5.ThreadHeight = %d, DW6.WidthdwordNoPadding = %d, DW7.Dst2DStartX = %d, DW8.Dst2DStartY = %d.", |
| 838 |
WalkerSinglePlaneStatic.DW0.InputSurfaceIndex, |
| 839 |
WalkerSinglePlaneStatic.DW1.OutputSurfaceIndex, |
| 840 |
WalkerSinglePlaneStatic.DW2.WidthDWord, |
| 841 |
WalkerSinglePlaneStatic.DW3.Height, |
| 842 |
WalkerSinglePlaneStatic.DW4.ShiftLeftOffsetInBytes, |
| 843 |
WalkerSinglePlaneStatic.DW5.ThreadHeight, |
| 844 |
WalkerSinglePlaneStatic.DW6.WidthdwordNoPadding, |
| 845 |
WalkerSinglePlaneStatic.DW7.Dst2DStartX, |
| 846 |
WalkerSinglePlaneStatic.DW8.Dst2DStartY); |
| 847 |
|
| 848 |
*piCurbeOffset = pRenderHal->pfnLoadCurbeData( |
| 849 |
pRenderHal, |
| 850 |
pRenderData->pMediaState, |
| 851 |
&WalkerSinglePlaneStatic, |
| 852 |
iCurbeLength); |
| 853 |
} |
| 854 |
else |
| 855 |
{ |
| 856 |
MCPY_ASSERTMESSAGE("can't support Target format %d", m_Target.Format); |
| 857 |
} |
| 858 |
|
| 859 |
if (*piCurbeOffset < 0) |
| 860 |
{ |
| 861 |
return MOS_STATUS_UNKNOWN; |
| 862 |
} |
| 863 |
|
| 864 |
pRenderData->iCurbeLength = iCurbeLength; |
| 865 |
|
| 866 |
return eStatus; |
| 867 |
} |
| 868 |
|
| 869 |
//! |
| 870 |
//! \brief Render copy omputer walker setup |
| 871 |
//! \details Computer walker setup for render copy |
| 872 |
//! \param PMHW_WALKER_PARAMS pWalkerParams |
| 873 |
//! [in/out] Pointer to Walker params |
| 874 |
//! \return MOS_STATUS |
| 875 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 876 |
//! |
| 877 |
MOS_STATUS RenderCopyStateNext::RenderCopyComputerWalker( |
| 878 |
PMHW_GPGPU_WALKER_PARAMS pWalkerParams) |
| 879 |
{ |
| 880 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 881 |
PMEDIACOPY_RENDER_DATA pRenderData = &m_RenderData; |
| 882 |
RECT AlignedRect; |
| 883 |
int32_t iBytePerPixelPerPlane = GetBytesPerPixelPerPlane(m_Target.Format); |
| 884 |
|
| 885 |
MCPY_CHK_NULL_RETURN(pRenderData); |
| 886 |
|
| 887 |
if ((iBytePerPixelPerPlane < 1) || (iBytePerPixelPerPlane > 8)) |
| 888 |
{ |
| 889 |
MCPY_ASSERTMESSAGE("RenderCopyComputerWalker wrong pixel size."); |
| 890 |
return MOS_STATUS_INVALID_PARAMETER; |
| 891 |
} |
| 892 |
|
| 893 |
if ((m_Target.Format == Format_YUY2) || (m_Target.Format == Format_Y210) || (m_Target.Format == Format_Y216) |
| 894 |
|| (m_Target.Format == Format_AYUV) || (m_Target.Format == Format_Y410) || (m_Target.Format == Format_Y416) |
| 895 |
|| (m_Target.Format == Format_A8R8G8B8)) |
| 896 |
{ |
| 897 |
if ((m_currKernelId == KERNEL_CopyKernel_1D_to_2D_Packed) || (m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Packed)) |
| 898 |
{ |
| 899 |
m_WalkerHeightBlockSize = 32; |
| 900 |
} |
| 901 |
else if (m_currKernelId == KERNEL_CopyKernel_2D_to_2D_Packed) |
| 902 |
{ |
| 903 |
m_WalkerHeightBlockSize = 8; |
| 904 |
} |
| 905 |
else |
| 906 |
{ |
| 907 |
MCPY_ASSERTMESSAGE("RenderCopyComputerWalker wrong kernel file."); |
| 908 |
return MOS_STATUS_INVALID_PARAMETER; |
| 909 |
} |
| 910 |
} |
| 911 |
else |
| 912 |
{ |
| 913 |
m_WalkerHeightBlockSize = 8; |
| 914 |
} |
| 915 |
|
| 916 |
if ((m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Packed) || |
| 917 |
(m_currKernelId == KERNEL_CopyKernel_2D_to_1D_NV12) || |
| 918 |
(m_currKernelId == KERNEL_CopyKernel_2D_to_1D_Planar)) |
| 919 |
{ |
| 920 |
m_WalkerWidthBlockSize = 16; |
| 921 |
} |
| 922 |
else |
| 923 |
{ |
| 924 |
m_WalkerWidthBlockSize = 128; |
| 925 |
} |
| 926 |
|
| 927 |
// Set walker cmd params - Rasterscan |
| 928 |
MOS_ZeroMemory(pWalkerParams, sizeof(*pWalkerParams)); |
| 929 |
|
| 930 |
|
| 931 |
AlignedRect.left = 0; |
| 932 |
AlignedRect.top = 0; |
| 933 |
AlignedRect.right = (m_Source.dwPitch < m_Target.dwPitch) ? m_Source.dwPitch : m_Target.dwPitch; |
| 934 |
AlignedRect.bottom = (m_Source.dwHeight < m_Target.dwHeight) ? m_Source.dwHeight : m_Target.dwHeight; |
| 935 |
// Calculate aligned output area in order to determine the total # blocks |
| 936 |
// to process in case of non-16x16 aligned target. |
| 937 |
AlignedRect.right += m_WalkerWidthBlockSize - 1; |
| 938 |
AlignedRect.bottom += m_WalkerHeightBlockSize - 1; |
| 939 |
AlignedRect.left -= AlignedRect.left % m_WalkerWidthBlockSize; |
| 940 |
AlignedRect.top -= AlignedRect.top % m_WalkerHeightBlockSize; |
| 941 |
AlignedRect.right -= AlignedRect.right % m_WalkerWidthBlockSize; |
| 942 |
AlignedRect.bottom -= AlignedRect.bottom % m_WalkerHeightBlockSize; |
| 943 |
|
| 944 |
pWalkerParams->InterfaceDescriptorOffset = pRenderData->iMediaID; |
| 945 |
|
| 946 |
pWalkerParams->GroupStartingX = (AlignedRect.left / m_WalkerWidthBlockSize); |
| 947 |
pWalkerParams->GroupStartingY = (AlignedRect.top / m_WalkerHeightBlockSize); |
| 948 |
|
| 949 |
// Set number of blocks |
| 950 |
pRenderData->iBlocksX = |
| 951 |
((AlignedRect.right - AlignedRect.left) + m_WalkerWidthBlockSize - 1) / m_WalkerWidthBlockSize; |
| 952 |
pRenderData->iBlocksY = |
| 953 |
((AlignedRect.bottom - AlignedRect.top) + m_WalkerHeightBlockSize -1)/ m_WalkerHeightBlockSize; |
| 954 |
|
| 955 |
// Set number of blocks, block size is m_WalkerWidthBlockSize x m_WalkerHeightBlockSize. |
| 956 |
pWalkerParams->GroupWidth = pRenderData->iBlocksX; |
| 957 |
pWalkerParams->GroupHeight = pRenderData->iBlocksY; // hight/m_WalkerWidthBlockSize |
| 958 |
|
| 959 |
pWalkerParams->ThreadWidth = 1; |
| 960 |
pWalkerParams->ThreadHeight = 1; |
| 961 |
pWalkerParams->ThreadDepth = 1; |
| 962 |
pWalkerParams->IndirectDataStartAddress = pRenderData->iCurbeOffset; |
| 963 |
// Indirect Data Length is a multiple of 64 bytes (size of L3 cacheline). Bits [5:0] are zero. |
| 964 |
pWalkerParams->IndirectDataLength = MOS_ALIGN_CEIL(pRenderData->iCurbeLength, 1 << MHW_COMPUTE_INDIRECT_SHIFT); |
| 965 |
pWalkerParams->BindingTableID = pRenderData->iBindingTable; |
| 966 |
MCPY_NORMALMESSAGE("WidthBlockSize %d, HeightBlockSize %d, Widththreads %d, Heightthreads%d", |
| 967 |
m_WalkerWidthBlockSize, m_WalkerHeightBlockSize, pWalkerParams->GroupWidth, pWalkerParams->GroupHeight); |
| 968 |
|
| 969 |
return eStatus; |
| 970 |
} |
| 971 |
|
| 972 |
MOS_STATUS RenderCopyStateNext::CopySurface( |
| 973 |
PMOS_RESOURCE src, |
| 974 |
PMOS_RESOURCE dst) |
| 975 |
{ |
| 976 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 977 |
m_Source.OsResource = *src; |
| 978 |
m_Source.Format = Format_Invalid; |
| 979 |
m_osInterface->pfnGetResourceInfo(m_osInterface, src, &m_Source); |
| 980 |
|
| 981 |
m_Target.OsResource = *dst; |
| 982 |
m_Target.Format = Format_Invalid; |
| 983 |
m_osInterface->pfnGetResourceInfo(m_osInterface, dst, &m_Target); |
| 984 |
|
| 985 |
if ((m_Target.Format != Format_RGBP) && (m_Target.Format != Format_NV12) && (m_Target.Format != Format_RGB) |
| 986 |
&& (m_Target.Format != Format_P010) && (m_Target.Format != Format_P016) && (m_Target.Format != Format_YUY2) |
| 987 |
&& (m_Target.Format != Format_Y210) && (m_Target.Format != Format_Y216) && (m_Target.Format != Format_AYUV) |
| 988 |
&& (m_Target.Format != Format_Y410) && (m_Target.Format != Format_Y416) && (m_Target.Format != Format_A8R8G8B8)) |
| 989 |
{ |
| 990 |
MCPY_ASSERTMESSAGE("Can't suppport format %d ", m_Target.Format); |
| 991 |
return MOS_STATUS_INVALID_PARAMETER; |
| 992 |
} |
| 993 |
|
| 994 |
MCPY_CHK_STATUS_RETURN(GetCurentKernelID()); |
| 995 |
return SubmitCMD(); |
| 996 |
} |