| 1 |
/* |
| 2 |
* Copyright (c) 2018-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 |
//! |
| 24 |
//! \file media_context.cpp |
| 25 |
//! \brief Defines the common interface for media context |
| 26 |
//! \details The media context interface is further sub-divided by component, |
| 27 |
//! this file is for the base interface which is shared by all components. |
| 28 |
//! |
| 29 |
|
| 30 |
#include "media_context.h" |
| 31 |
#include "mos_interface.h" |
| 32 |
#include "mos_os_virtualengine_next.h" |
| 33 |
#if !EMUL |
| 34 |
#include "codec_hw_next.h" |
| 35 |
#include "decode_scalability_defs.h" |
| 36 |
#endif |
| 37 |
#include "mos_os_cp_interface_specific.h" |
| 38 |
MediaContext::MediaContext(uint8_t componentType, void *hwInterface, PMOS_INTERFACE osInterface) |
| 39 |
{ |
| 40 |
if (!hwInterface) |
| 41 |
{ |
| 42 |
MOS_OS_ASSERTMESSAGE("null HW interface, failed to create Media Context"); |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
if (!osInterface) |
| 47 |
{ |
| 48 |
MOS_OS_ASSERTMESSAGE("null OS interface, failed to create Media Context"); |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
if (componentType >= scalabilityTotal) |
| 53 |
{ |
| 54 |
MOS_OS_ASSERTMESSAGE("Invalid component type, failed to create Media Context"); |
| 55 |
return; |
| 56 |
} |
| 57 |
|
| 58 |
m_hwInterface = hwInterface; |
| 59 |
m_osInterface = osInterface; |
| 60 |
m_userSettingPtr = osInterface->pfnGetUserSettingInstance(osInterface); |
| 61 |
m_componentType = componentType; |
| 62 |
|
| 63 |
m_streamId = m_osInterface->streamIndex; |
| 64 |
m_gpuContextAttributeTable.clear(); |
| 65 |
|
| 66 |
MEDIA_SYSTEM_INFO *gtSystemInfo = nullptr; |
| 67 |
MEDIA_ENGINE_INFO mediaEngineInfo = {}; |
| 68 |
|
| 69 |
auto skuTable = m_osInterface->pfnGetSkuTable(m_osInterface); |
| 70 |
if (!skuTable) |
| 71 |
{ |
| 72 |
MOS_OS_ASSERTMESSAGE("Failed to get skuTable"); |
| 73 |
return; |
| 74 |
} |
| 75 |
if (MEDIA_IS_SKU(skuTable,FtrMediaIPSeparation)) |
| 76 |
{ |
| 77 |
if (m_osInterface->pfnGetMediaEngineInfo(m_osInterface, mediaEngineInfo) == MOS_STATUS_SUCCESS) |
| 78 |
{ |
| 79 |
m_numVdbox = (uint8_t)mediaEngineInfo.VDBoxInfo.NumberOfVDBoxEnabled; |
| 80 |
} |
| 81 |
} |
| 82 |
else |
| 83 |
{ |
| 84 |
gtSystemInfo = m_osInterface->pfnGetGtSystemInfo(m_osInterface); |
| 85 |
if(gtSystemInfo) |
| 86 |
{ |
| 87 |
m_numVdbox = (uint8_t)(gtSystemInfo->VDBoxInfo.NumberOfVDBoxEnabled); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
if (m_numVdbox > 1 |
| 92 |
&& m_osInterface != nullptr |
| 93 |
&& m_osInterface->bHcpDecScalabilityMode) |
| 94 |
{ |
| 95 |
m_scalabilitySupported = true; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
MediaContext::~MediaContext() |
| 100 |
{ |
| 101 |
if (m_osInterface && m_osInterface->pfnWaitAllCmdCompletion) |
| 102 |
{ |
| 103 |
m_osInterface->pfnWaitAllCmdCompletion(m_osInterface); |
| 104 |
} |
| 105 |
|
| 106 |
if ((MOS_VE_MULTINODESCALING_SUPPORTED(m_osInterface)) && |
| 107 |
(m_curNodeOrdinal == MOS_GPU_NODE_VIDEO || m_curNodeOrdinal == MOS_GPU_NODE_VIDEO2)) |
| 108 |
{ |
| 109 |
m_osInterface->pfnDestroyVideoNodeAssociation(m_osInterface, m_curNodeOrdinal); |
| 110 |
if (m_osInterface->osStreamState && m_osInterface->osStreamState->component == COMPONENT_Encode) |
| 111 |
{ |
| 112 |
m_osInterface->pfnSetLatestVirtualNode(m_osInterface, MOS_GPU_NODE_MAX); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
for (auto& curAttribute : m_gpuContextAttributeTable) |
| 117 |
{ |
| 118 |
if (curAttribute.scalabilityState) |
| 119 |
{ |
| 120 |
MOS_STATUS status = curAttribute.scalabilityState->Destroy(); |
| 121 |
if (MOS_FAILED(status)) |
| 122 |
{ |
| 123 |
MOS_OS_ASSERTMESSAGE("scalabilityState destroy fail."); |
| 124 |
} |
| 125 |
MOS_Delete(curAttribute.scalabilityState); |
| 126 |
// set legacy MOS ve interface to null to be compatible to legacy MOS |
| 127 |
if (m_osInterface) |
| 128 |
{ |
| 129 |
m_osInterface->pVEInterf = nullptr; |
| 130 |
} |
| 131 |
} |
| 132 |
else |
| 133 |
{ |
| 134 |
MOS_OS_ASSERTMESSAGE("scalabilityState is nullptr, something must be wrong"); |
| 135 |
return; |
| 136 |
} |
| 137 |
|
| 138 |
if (!m_osInterface || !m_osInterface->pOsContext) |
| 139 |
{ |
| 140 |
MOS_OS_ASSERTMESSAGE("m_osInterface and OsContext cannot be nullptr"); |
| 141 |
return; |
| 142 |
} |
| 143 |
|
| 144 |
if (curAttribute.gpuContext != MOS_GPU_CONTEXT_INVALID_HANDLE) |
| 145 |
{ |
| 146 |
if (m_osInterface->apoMosEnabled || m_osInterface->modularizedGpuCtxEnabled) |
| 147 |
{ |
| 148 |
auto status = m_osInterface->pfnDestroyGpuContextByHandle(m_osInterface, curAttribute.gpuContext); |
| 149 |
|
| 150 |
if (status != MOS_STATUS_SUCCESS) |
| 151 |
{ |
| 152 |
MOS_OS_NORMALMESSAGE("Gpu Context destory failed, something must be wrong"); |
| 153 |
return; |
| 154 |
} |
| 155 |
} |
| 156 |
else |
| 157 |
{ |
| 158 |
auto status = m_osInterface->pfnDestroyGpuContext( |
| 159 |
m_osInterface, |
| 160 |
curAttribute.ctxForLegacyMos); |
| 161 |
if (status != MOS_STATUS_SUCCESS) |
| 162 |
{ |
| 163 |
MOS_OS_NORMALMESSAGE("Gpu Context destory failed, something must be wrong"); |
| 164 |
return; |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
else |
| 169 |
{ |
| 170 |
MOS_OS_ASSERTMESSAGE("Invalid gpu Context handle in entry, something must be wrong"); |
| 171 |
return; |
| 172 |
} |
| 173 |
#if !EMUL |
| 174 |
// Be compatible to legacy MOS |
| 175 |
m_osInterface->pfnSetGpuContextHandle(m_osInterface, MOS_GPU_CONTEXT_INVALID_HANDLE, curAttribute.ctxForLegacyMos); |
| 176 |
#endif |
| 177 |
} |
| 178 |
|
| 179 |
m_gpuContextAttributeTable.clear(); |
| 180 |
} |
| 181 |
|
| 182 |
MOS_STATUS MediaContext::SwitchContext(MediaFunction func, ContextRequirement *requirement, MediaScalability **scalabilityState, uint64_t gpuCtxOnHybridCmd) |
| 183 |
{ |
| 184 |
MOS_OS_FUNCTION_ENTER; |
| 185 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 186 |
|
| 187 |
MOS_OS_CHK_NULL_RETURN(m_osInterface); |
| 188 |
MOS_OS_CHK_NULL_RETURN(m_osInterface->pOsContext); |
| 189 |
MOS_OS_CHK_NULL_RETURN(scalabilityState); |
| 190 |
MOS_OS_CHK_NULL_RETURN(requirement); |
| 191 |
|
| 192 |
if (func >= INVALID_MEDIA_FUNCTION) |
| 193 |
{ |
| 194 |
MOS_OS_ASSERTMESSAGE("Func required is invalid"); |
| 195 |
return MOS_STATUS_INVALID_PARAMETER; |
| 196 |
} |
| 197 |
|
| 198 |
MediaScalability * veStateProvided = nullptr; |
| 199 |
|
| 200 |
if (IS_RENDER_ENGINE_FUNCTION(func)) |
| 201 |
{ |
| 202 |
auto scalPars = (ScalabilityPars *)requirement; |
| 203 |
MOS_OS_CHK_NULL_RETURN(scalPars); |
| 204 |
MOS_OS_CHK_NULL_RETURN(m_osInterface->osCpInterface); |
| 205 |
scalPars->raMode = m_osInterface->osCpInterface->IsHMEnabled() ? MEDIA_IS_SKU(m_osInterface->pfnGetSkuTable(m_osInterface), FtrRAMode) : 0; |
| 206 |
scalPars->protectMode = m_osInterface->osCpInterface->IsHMEnabled() ? MEDIA_IS_SKU(m_osInterface->pfnGetSkuTable(m_osInterface), FtrProtectedEnableBitRequired) : 0; |
| 207 |
if (scalPars->raMode) |
| 208 |
{ |
| 209 |
MOS_OS_NORMALMESSAGE("request RA mode context for protected render workload"); |
| 210 |
ReportUserSetting(m_userSettingPtr, |
| 211 |
__MEDIA_USER_FEATURE_VALUE_RA_MODE_ENABLE, |
| 212 |
uint32_t(1), |
| 213 |
MediaUserSetting::Group::Device); |
| 214 |
} |
| 215 |
if (scalPars->protectMode) |
| 216 |
{ |
| 217 |
MOS_OS_NORMALMESSAGE("request protect mode context for protected render workload"); |
| 218 |
ReportUserSetting(m_userSettingPtr, |
| 219 |
__MEDIA_USER_FEATURE_VALUE_PROTECT_MODE_ENABLE, |
| 220 |
uint32_t(1), |
| 221 |
MediaUserSetting::Group::Device); |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
uint32_t index = m_invalidContextAttribute; |
| 226 |
#if !EMUL |
| 227 |
MOS_OS_CHK_STATUS_RETURN(SearchContext<ScalabilityPars*>(func, (ScalabilityPars*)requirement, index)); |
| 228 |
#endif |
| 229 |
if (index == m_invalidContextAttribute) |
| 230 |
{ |
| 231 |
MOS_OS_CHK_STATUS_RETURN(CreateContext<ScalabilityPars*>(func, (ScalabilityPars*)requirement, index)); |
| 232 |
} |
| 233 |
if (index == m_invalidContextAttribute || index >= m_gpuContextAttributeTable.size()) |
| 234 |
{ |
| 235 |
MOS_OS_ASSERTMESSAGE("Incorrect index get from Context attribute table"); |
| 236 |
return MOS_STATUS_UNKNOWN; |
| 237 |
} |
| 238 |
|
| 239 |
// Be compatible to legacy MOS |
| 240 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnSetGpuContext(m_osInterface, m_gpuContextAttributeTable[index].ctxForLegacyMos)); |
| 241 |
veStateProvided = m_gpuContextAttributeTable[index].scalabilityState; |
| 242 |
MOS_OS_NORMALMESSAGE("Switched to GpuContext %d, index %d", m_gpuContextAttributeTable[index].ctxForLegacyMos, index); |
| 243 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnSetHybridCmdMgrToGpuContext(m_osInterface, gpuCtxOnHybridCmd)); |
| 244 |
|
| 245 |
if (requirement->IsEnc) |
| 246 |
{ |
| 247 |
m_osInterface->pfnSetEncodeEncContext(m_osInterface, m_gpuContextAttributeTable[index].ctxForLegacyMos); |
| 248 |
} |
| 249 |
if (requirement->IsPak) |
| 250 |
{ |
| 251 |
m_osInterface->pfnSetEncodePakContext(m_osInterface, m_gpuContextAttributeTable[index].ctxForLegacyMos); |
| 252 |
} |
| 253 |
|
| 254 |
if (!requirement->IsContextSwitchBack) |
| 255 |
{ |
| 256 |
m_osInterface->pfnResetOsStates(m_osInterface); |
| 257 |
} |
| 258 |
|
| 259 |
*scalabilityState = veStateProvided; |
| 260 |
|
| 261 |
return status; |
| 262 |
} |
| 263 |
|
| 264 |
template<typename T> |
| 265 |
MOS_STATUS MediaContext::SearchContext(MediaFunction func, T params, uint32_t& indexFound) |
| 266 |
{ |
| 267 |
MOS_OS_FUNCTION_ENTER; |
| 268 |
|
| 269 |
MOS_OS_CHK_NULL_RETURN(m_osInterface); |
| 270 |
|
| 271 |
indexFound = m_invalidContextAttribute; |
| 272 |
uint32_t index = 0; |
| 273 |
|
| 274 |
for (auto& curAttribute : m_gpuContextAttributeTable) |
| 275 |
{ |
| 276 |
if (curAttribute.func == func) |
| 277 |
{ |
| 278 |
MOS_OS_CHK_NULL_RETURN(curAttribute.scalabilityState); |
| 279 |
|
| 280 |
if (curAttribute.scalabilityState->IsScalabilityModeMatched(params)) |
| 281 |
{ |
| 282 |
// Found the matching GPU context and scalability state |
| 283 |
indexFound = index; |
| 284 |
|
| 285 |
// Be compatible to legacy MOS |
| 286 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnSetGpuContextHandle(m_osInterface, curAttribute.gpuContext, curAttribute.ctxForLegacyMos)); |
| 287 |
// set legacy MOS ve interface to current reused scalability state's ve interface |
| 288 |
m_osInterface->pVEInterf = curAttribute.scalabilityState->m_veInterface; |
| 289 |
if (m_osInterface->apoMosEnabled) |
| 290 |
{ |
| 291 |
if (curAttribute.scalabilityState->m_veState) |
| 292 |
{ |
| 293 |
MOS_OS_CHK_NULL_RETURN(m_osInterface->osStreamState); |
| 294 |
m_osInterface->osStreamState->virtualEngineInterface = curAttribute.scalabilityState->m_veState; |
| 295 |
} |
| 296 |
} |
| 297 |
break; |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 301 |
index++; |
| 302 |
} |
| 303 |
|
| 304 |
return MOS_STATUS_SUCCESS; |
| 305 |
} |
| 306 |
|
| 307 |
template<typename T> |
| 308 |
MOS_STATUS MediaContext::CreateContext(MediaFunction func, T params, uint32_t& indexReturn) |
| 309 |
{ |
| 310 |
MOS_OS_FUNCTION_ENTER; |
| 311 |
|
| 312 |
MOS_OS_CHK_NULL_RETURN(m_osInterface); |
| 313 |
|
| 314 |
// Reach the max number of Gpu Context attr entries in current Media Context |
| 315 |
if (m_gpuContextAttributeTable.size() == m_maxContextAttribute) |
| 316 |
{ |
| 317 |
MOS_OS_ASSERTMESSAGE("Reached max num of entries of gpuContextAttributeTable: 4096. Cannot create more Gpu Contexts"); |
| 318 |
return MOS_STATUS_NOT_ENOUGH_BUFFER; |
| 319 |
} |
| 320 |
|
| 321 |
GpuContextAttribute newAttr; |
| 322 |
|
| 323 |
// Setup func |
| 324 |
newAttr.func = func; |
| 325 |
if (newAttr.func >= INVALID_MEDIA_FUNCTION) |
| 326 |
{ |
| 327 |
MOS_OS_ASSERTMESSAGE("Func required is invalid"); |
| 328 |
return MOS_STATUS_INVALID_PARAMETER; |
| 329 |
} |
| 330 |
|
| 331 |
// Create scalabilityState |
| 332 |
MOS_GPUCTX_CREATOPTIONS_ENHANCED option; |
| 333 |
MediaScalabilityFactory<T> scalabilityFactory; |
| 334 |
newAttr.scalabilityState = scalabilityFactory.CreateScalability( |
| 335 |
m_componentType, params, m_hwInterface, this, &option); |
| 336 |
if (newAttr.scalabilityState == nullptr) |
| 337 |
{ |
| 338 |
MOS_OS_ASSERTMESSAGE("Failed to create scalability state"); |
| 339 |
return MOS_STATUS_NO_SPACE; |
| 340 |
} |
| 341 |
|
| 342 |
// request to create or reuse gpuContext |
| 343 |
MOS_GPU_NODE node = MOS_GPU_NODE_MAX; |
| 344 |
MOS_OS_CHK_STATUS_RETURN(FunctionToNode(func, option, node)); |
| 345 |
|
| 346 |
// WA for legacy MOS |
| 347 |
MOS_OS_CHK_STATUS_RETURN(FunctionToGpuContext(func, option, node, newAttr.ctxForLegacyMos)); |
| 348 |
|
| 349 |
if(m_osInterface->bSetHandleInvalid) |
| 350 |
{ |
| 351 |
MOS_OS_NORMALMESSAGE("Force set INVALID_HANDLE for GpuContext %d", newAttr.ctxForLegacyMos); |
| 352 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnSetGpuContextHandle(m_osInterface, MOS_GPU_CONTEXT_INVALID_HANDLE, newAttr.ctxForLegacyMos)); |
| 353 |
} |
| 354 |
|
| 355 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnCreateGpuContext(m_osInterface, newAttr.ctxForLegacyMos, node, &option)); |
| 356 |
m_osInterface->pfnSetGpuContext(m_osInterface, newAttr.ctxForLegacyMos); |
| 357 |
newAttr.gpuContext = m_osInterface->CurrentGpuContextHandle; |
| 358 |
MOS_OS_NORMALMESSAGE("Create GpuContext %d, node %d, handle 0x%x, protectMode %d, raMode %d", |
| 359 |
newAttr.ctxForLegacyMos, node, newAttr.gpuContext, option.ProtectMode, option.RAMode); |
| 360 |
|
| 361 |
// Add entry to the table |
| 362 |
indexReturn = m_gpuContextAttributeTable.size(); |
| 363 |
m_gpuContextAttributeTable.push_back(newAttr); |
| 364 |
|
| 365 |
if (func == VeboxVppFunc || func == ComputeVppFunc) |
| 366 |
{ |
| 367 |
m_osInterface->pfnRegisterBBCompleteNotifyEvent( |
| 368 |
m_osInterface, |
| 369 |
newAttr.ctxForLegacyMos); |
| 370 |
} |
| 371 |
|
| 372 |
return MOS_STATUS_SUCCESS; |
| 373 |
} |
| 374 |
|
| 375 |
MOS_STATUS MediaContext::SwitchContext( |
| 376 |
MediaFunction func, |
| 377 |
MediaScalabilityOption &scalabilityOption, |
| 378 |
MediaScalability **scalabilityState, |
| 379 |
bool isEnc, |
| 380 |
bool isPak) |
| 381 |
{ |
| 382 |
MOS_OS_FUNCTION_ENTER; |
| 383 |
|
| 384 |
MOS_OS_CHK_NULL_RETURN(m_osInterface); |
| 385 |
MOS_OS_CHK_NULL_RETURN(m_osInterface->pOsContext); |
| 386 |
MOS_OS_CHK_NULL_RETURN(scalabilityState); |
| 387 |
|
| 388 |
if (func >= INVALID_MEDIA_FUNCTION) |
| 389 |
{ |
| 390 |
MOS_OS_ASSERTMESSAGE("Func required is invalid"); |
| 391 |
return MOS_STATUS_INVALID_PARAMETER; |
| 392 |
} |
| 393 |
|
| 394 |
MediaScalability * veStateProvided = nullptr; |
| 395 |
|
| 396 |
uint32_t index = m_invalidContextAttribute; |
| 397 |
#if !EMUL |
| 398 |
MOS_OS_CHK_STATUS_RETURN(SearchContext<MediaScalabilityOption&>(func, scalabilityOption, index)); |
| 399 |
#endif |
| 400 |
if (index == m_invalidContextAttribute) |
| 401 |
{ |
| 402 |
MOS_OS_CHK_STATUS_RETURN(CreateContext<MediaScalabilityOption *>(func, &scalabilityOption, index)); |
| 403 |
} |
| 404 |
if (index == m_invalidContextAttribute || index >= m_gpuContextAttributeTable.size()) |
| 405 |
{ |
| 406 |
MOS_OS_ASSERTMESSAGE("Incorrect index get from Context attribute table"); |
| 407 |
return MOS_STATUS_UNKNOWN; |
| 408 |
} |
| 409 |
|
| 410 |
// Be compatible to legacy MOS |
| 411 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnSetGpuContext(m_osInterface, m_gpuContextAttributeTable[index].ctxForLegacyMos)); |
| 412 |
veStateProvided = m_gpuContextAttributeTable[index].scalabilityState; |
| 413 |
|
| 414 |
if (isEnc) |
| 415 |
{ |
| 416 |
m_osInterface->pfnSetEncodeEncContext(m_osInterface, m_gpuContextAttributeTable[index].ctxForLegacyMos); |
| 417 |
} |
| 418 |
if (isPak) |
| 419 |
{ |
| 420 |
m_osInterface->pfnSetEncodePakContext(m_osInterface, m_gpuContextAttributeTable[index].ctxForLegacyMos); |
| 421 |
} |
| 422 |
|
| 423 |
m_osInterface->pfnResetOsStates(m_osInterface); |
| 424 |
|
| 425 |
*scalabilityState = veStateProvided; |
| 426 |
|
| 427 |
return MOS_STATUS_SUCCESS; |
| 428 |
} |
| 429 |
|
| 430 |
MOS_STATUS MediaContext::FunctionToNode(MediaFunction func, const MOS_GPUCTX_CREATOPTIONS_ENHANCED &option, MOS_GPU_NODE& node) |
| 431 |
{ |
| 432 |
MOS_OS_FUNCTION_ENTER; |
| 433 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 434 |
|
| 435 |
if (func >= INVALID_MEDIA_FUNCTION) |
| 436 |
{ |
| 437 |
MOS_OS_ASSERTMESSAGE("Func required is invalid"); |
| 438 |
return MOS_STATUS_INVALID_PARAMETER; |
| 439 |
} |
| 440 |
|
| 441 |
switch (func) |
| 442 |
{ |
| 443 |
case RenderGenericFunc: |
| 444 |
node = MOS_GPU_NODE_3D; |
| 445 |
break; |
| 446 |
case VdboxEncodeFunc: |
| 447 |
case VdboxDecodeFunc: |
| 448 |
case VdboxDecodeVirtualNode0Func: |
| 449 |
case VdboxDecodeVirtualNode1Func: |
| 450 |
if (option.LRCACount >= 2) |
| 451 |
{ |
| 452 |
node = MOS_GPU_NODE_VIDEO; // multiple pipe decode or encode always using VIDEO node |
| 453 |
if (MOS_VE_MULTINODESCALING_SUPPORTED(m_osInterface)) |
| 454 |
{ |
| 455 |
if (m_curNodeOrdinal == MOS_GPU_NODE_VIDEO || m_curNodeOrdinal == MOS_GPU_NODE_VIDEO2) |
| 456 |
{ |
| 457 |
m_osInterface->pfnDestroyVideoNodeAssociation(m_osInterface, m_curNodeOrdinal); |
| 458 |
if (func == VdboxEncodeFunc) |
| 459 |
{ |
| 460 |
m_osInterface->pfnSetLatestVirtualNode(m_osInterface, MOS_GPU_NODE_MAX); |
| 461 |
} |
| 462 |
} |
| 463 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnCreateVideoNodeAssociation( |
| 464 |
m_osInterface, |
| 465 |
true, |
| 466 |
&node)); |
| 467 |
if (func == VdboxDecodeFunc || func == VdboxDecodeVirtualNode0Func || func == VdboxDecodeVirtualNode1Func) |
| 468 |
{ |
| 469 |
m_osInterface->pfnSetDecoderVirtualNodePerStream(m_osInterface, node); |
| 470 |
} |
| 471 |
else if (func == VdboxEncodeFunc) |
| 472 |
{ |
| 473 |
m_osInterface->pfnSetLatestVirtualNode(m_osInterface, node); |
| 474 |
} |
| 475 |
} |
| 476 |
m_curNodeOrdinal = node; |
| 477 |
} |
| 478 |
#if !EMUL |
| 479 |
else |
| 480 |
{ |
| 481 |
MOS_OS_CHK_STATUS_RETURN(FunctionToNodeCodec(func, node)); |
| 482 |
} |
| 483 |
#endif |
| 484 |
break; |
| 485 |
case VdboxDecodeWaFunc: |
| 486 |
case VdboxDecrpytFunc: |
| 487 |
case VdboxCpFunc: |
| 488 |
node = MOS_GPU_NODE_VIDEO; |
| 489 |
break; |
| 490 |
case VeboxVppFunc: |
| 491 |
node = MOS_GPU_NODE_VE; |
| 492 |
break; |
| 493 |
case ComputeMdfFunc: |
| 494 |
case ComputeVppFunc: |
| 495 |
node = MOS_GPU_NODE_COMPUTE; |
| 496 |
break; |
| 497 |
default: |
| 498 |
MOS_OS_ASSERTMESSAGE("Cannot find the GPU node by the func"); |
| 499 |
status = MOS_STATUS_INVALID_PARAMETER; |
| 500 |
node = MOS_GPU_NODE_MAX; |
| 501 |
break; |
| 502 |
} |
| 503 |
|
| 504 |
return status; |
| 505 |
} |
| 506 |
#if !EMUL |
| 507 |
MOS_STATUS MediaContext::FunctionToNodeCodec(MediaFunction func, MOS_GPU_NODE& node) |
| 508 |
{ |
| 509 |
MHW_VDBOX_GPUNODE_LIMIT gpuNodeLimit = {0}; |
| 510 |
|
| 511 |
MOS_OS_CHK_STATUS_RETURN(FindGpuNodeToUse(func , &gpuNodeLimit)); |
| 512 |
|
| 513 |
node = (MOS_GPU_NODE)(gpuNodeLimit.dwGpuNodeToUse); |
| 514 |
|
| 515 |
return MOS_STATUS_SUCCESS; |
| 516 |
} |
| 517 |
|
| 518 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 519 |
MOS_STATUS MediaContext::CheckScalabilityOverrideValidity() |
| 520 |
{ |
| 521 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 522 |
|
| 523 |
MEDIA_SYSTEM_INFO *gtSystemInfo = nullptr; |
| 524 |
MEDIA_ENGINE_INFO mediaEngineInfo = {}; |
| 525 |
uint32_t forceVdbox = 0; |
| 526 |
bool scalableDecMode = false; |
| 527 |
bool useVD1 = false; |
| 528 |
bool useVD2 = false; |
| 529 |
bool useVD3 = false; |
| 530 |
|
| 531 |
MHW_MI_CHK_NULL(m_osInterface); |
| 532 |
scalableDecMode = m_osInterface->bHcpDecScalabilityMode ? true : false; |
| 533 |
forceVdbox = m_osInterface->eForceVdbox; |
| 534 |
auto skuTable = m_osInterface->pfnGetSkuTable(m_osInterface); |
| 535 |
MHW_MI_CHK_NULL(skuTable); |
| 536 |
if (MEDIA_IS_SKU(skuTable,FtrMediaIPSeparation)) |
| 537 |
{ |
| 538 |
MOS_OS_CHK_STATUS_RETURN(m_osInterface->pfnGetMediaEngineInfo(m_osInterface, mediaEngineInfo)); |
| 539 |
} |
| 540 |
else |
| 541 |
{ |
| 542 |
gtSystemInfo = m_osInterface->pfnGetGtSystemInfo(m_osInterface); |
| 543 |
MHW_MI_CHK_NULL(gtSystemInfo); |
| 544 |
} |
| 545 |
|
| 546 |
if (forceVdbox != MOS_FORCE_VDBOX_NONE && |
| 547 |
forceVdbox != MOS_FORCE_VDBOX_1 && |
| 548 |
forceVdbox != MOS_FORCE_VDBOX_2 && |
| 549 |
forceVdbox != MOS_FORCE_VDBOX_3 && |
| 550 |
// 2 pipes, VDBOX1-BE1, VDBOX2-BE2 |
| 551 |
forceVdbox != MOS_FORCE_VDBOX_1_1_2 && |
| 552 |
forceVdbox != MOS_FORCE_VDBOX_2_1_2) |
| 553 |
{ |
| 554 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 555 |
MHW_ASSERTMESSAGE("user feature forceVdbox value is invalid."); |
| 556 |
return eStatus; |
| 557 |
} |
| 558 |
if (!scalableDecMode && |
| 559 |
(forceVdbox == MOS_FORCE_VDBOX_1_1_2 || |
| 560 |
forceVdbox == MOS_FORCE_VDBOX_2_1_2)) |
| 561 |
{ |
| 562 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 563 |
MHW_ASSERTMESSAGE("user feature forceVdbox valude does not consistent with regkey scalability mode."); |
| 564 |
return eStatus; |
| 565 |
} |
| 566 |
|
| 567 |
if (scalableDecMode && !m_scalabilitySupported) |
| 568 |
{ |
| 569 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 570 |
MHW_ASSERTMESSAGE("user feature scalability mode is not allowed on current platform!"); |
| 571 |
return eStatus; |
| 572 |
} |
| 573 |
|
| 574 |
if (forceVdbox == 0) |
| 575 |
{ |
| 576 |
useVD1 = true; |
| 577 |
} |
| 578 |
else |
| 579 |
{ |
| 580 |
MHW_VDBOX_IS_VDBOX_SPECIFIED(forceVdbox, MOS_FORCE_VDBOX_1, MOS_FORCEVDBOX_VDBOXID_BITSNUM, MOS_FORCEVDBOX_MASK, useVD1); |
| 581 |
MHW_VDBOX_IS_VDBOX_SPECIFIED(forceVdbox, MOS_FORCE_VDBOX_2, MOS_FORCEVDBOX_VDBOXID_BITSNUM, MOS_FORCEVDBOX_MASK, useVD2); |
| 582 |
MHW_VDBOX_IS_VDBOX_SPECIFIED(forceVdbox, MOS_FORCE_VDBOX_3, MOS_FORCEVDBOX_VDBOXID_BITSNUM, MOS_FORCEVDBOX_MASK, useVD3); |
| 583 |
} |
| 584 |
if (MEDIA_IS_SKU(skuTable,FtrMediaIPSeparation)) |
| 585 |
{ |
| 586 |
if (!mediaEngineInfo.VDBoxInfo.IsValid || |
| 587 |
(useVD1 && !mediaEngineInfo.VDBoxInfo.Instances.Bits.VDBox0Enabled) || |
| 588 |
(useVD2 && !mediaEngineInfo.VDBoxInfo.Instances.Bits.VDBox2Enabled) || |
| 589 |
(useVD3 && !mediaEngineInfo.VDBoxInfo.Instances.Bits.VDBox1Enabled)) |
| 590 |
{ |
| 591 |
//1:VD0 2:VD2 3:VD1 |
| 592 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 593 |
MHW_ASSERTMESSAGE("the forced VDBOX is not enabled in current platform."); |
| 594 |
return eStatus; |
| 595 |
} |
| 596 |
} |
| 597 |
else |
| 598 |
{ |
| 599 |
if (!gtSystemInfo->VDBoxInfo.IsValid || |
| 600 |
(useVD1 && !gtSystemInfo->VDBoxInfo.Instances.Bits.VDBox0Enabled) || |
| 601 |
(useVD2 && !gtSystemInfo->VDBoxInfo.Instances.Bits.VDBox2Enabled) || |
| 602 |
(useVD3 && !gtSystemInfo->VDBoxInfo.Instances.Bits.VDBox1Enabled)) |
| 603 |
{ |
| 604 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 605 |
MHW_ASSERTMESSAGE("the forced VDBOX is not enabled in current platform."); |
| 606 |
return eStatus; |
| 607 |
} |
| 608 |
|
| 609 |
} |
| 610 |
|
| 611 |
return eStatus; |
| 612 |
} |
| 613 |
#endif |
| 614 |
|
| 615 |
MOS_STATUS MediaContext::FindGpuNodeToUse(MediaFunction func, PMHW_VDBOX_GPUNODE_LIMIT gpuNodeLimit) |
| 616 |
{ |
| 617 |
bool setVideoNode = false; |
| 618 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 619 |
|
| 620 |
MOS_GPU_NODE videoGpuNode = MOS_GPU_NODE_VIDEO; |
| 621 |
|
| 622 |
if (MOS_VE_MULTINODESCALING_SUPPORTED(m_osInterface)) |
| 623 |
{ |
| 624 |
if (GetNumVdbox() == 1) |
| 625 |
{ |
| 626 |
videoGpuNode = MOS_GPU_NODE_VIDEO; |
| 627 |
} |
| 628 |
else |
| 629 |
{ |
| 630 |
if (m_curNodeOrdinal == MOS_GPU_NODE_VIDEO || m_curNodeOrdinal == MOS_GPU_NODE_VIDEO2) |
| 631 |
{ |
| 632 |
m_osInterface->pfnDestroyVideoNodeAssociation(m_osInterface, m_curNodeOrdinal); |
| 633 |
if (func == VdboxEncodeFunc) |
| 634 |
{ |
| 635 |
m_osInterface->pfnSetLatestVirtualNode(m_osInterface, MOS_GPU_NODE_MAX); |
| 636 |
} |
| 637 |
} |
| 638 |
if (func == VdboxDecodeVirtualNode0Func) |
| 639 |
{ |
| 640 |
setVideoNode = true; |
| 641 |
videoGpuNode = MOS_GPU_NODE_VIDEO; |
| 642 |
} |
| 643 |
else if (func == VdboxDecodeVirtualNode1Func) |
| 644 |
{ |
| 645 |
setVideoNode = true; |
| 646 |
videoGpuNode = MOS_GPU_NODE_VIDEO2; |
| 647 |
} |
| 648 |
else if (func == VdboxEncodeFunc) |
| 649 |
{ |
| 650 |
MOS_GPU_NODE node = m_osInterface->pfnGetLatestVirtualNode(m_osInterface, COMPONENT_Decode); |
| 651 |
if (node != MOS_GPU_NODE_MAX) |
| 652 |
{ |
| 653 |
setVideoNode = true; |
| 654 |
videoGpuNode = (node == MOS_GPU_NODE_VIDEO) ? MOS_GPU_NODE_VIDEO2 : MOS_GPU_NODE_VIDEO; |
| 655 |
} |
| 656 |
} |
| 657 |
MHW_MI_CHK_STATUS(m_osInterface->pfnCreateVideoNodeAssociation( |
| 658 |
m_osInterface, |
| 659 |
setVideoNode, |
| 660 |
&videoGpuNode)); |
| 661 |
m_curNodeOrdinal = videoGpuNode; |
| 662 |
if (func == VdboxDecodeFunc || func == VdboxDecodeVirtualNode0Func || func == VdboxDecodeVirtualNode1Func) |
| 663 |
{ |
| 664 |
m_osInterface->pfnSetDecoderVirtualNodePerStream(m_osInterface, m_curNodeOrdinal); |
| 665 |
} |
| 666 |
else if (func == VdboxEncodeFunc) |
| 667 |
{ |
| 668 |
m_osInterface->pfnSetLatestVirtualNode(m_osInterface, m_curNodeOrdinal); |
| 669 |
} |
| 670 |
} |
| 671 |
} |
| 672 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 673 |
if (m_osInterface != nullptr && m_osInterface->bEnableDbgOvrdInVE && |
| 674 |
(!m_osInterface->bSupportVirtualEngine)) |
| 675 |
{ |
| 676 |
eStatus = MOS_STATUS_INVALID_PARAMETER; |
| 677 |
MHW_ASSERTMESSAGE("not support DebugOverrid on current OS or Platform."); |
| 678 |
return eStatus; |
| 679 |
} |
| 680 |
|
| 681 |
if (m_osInterface != nullptr && m_osInterface->bEnableDbgOvrdInVE) |
| 682 |
{ |
| 683 |
MHW_MI_CHK_STATUS(CheckScalabilityOverrideValidity()); |
| 684 |
} |
| 685 |
#endif |
| 686 |
gpuNodeLimit->dwGpuNodeToUse = videoGpuNode; |
| 687 |
|
| 688 |
return eStatus; |
| 689 |
} |
| 690 |
#endif |
| 691 |
|
| 692 |
MOS_STATUS MediaContext::FunctionToGpuContext(MediaFunction func, const MOS_GPUCTX_CREATOPTIONS_ENHANCED &option, const MOS_GPU_NODE &node, MOS_GPU_CONTEXT &ctx) |
| 693 |
{ |
| 694 |
MOS_OS_FUNCTION_ENTER; |
| 695 |
|
| 696 |
if (func >= INVALID_MEDIA_FUNCTION) |
| 697 |
{ |
| 698 |
MOS_OS_ASSERTMESSAGE("Func is invalid"); |
| 699 |
return MOS_STATUS_INVALID_PARAMETER; |
| 700 |
} |
| 701 |
|
| 702 |
switch (func) |
| 703 |
{ |
| 704 |
case VdboxEncodeFunc: |
| 705 |
MOS_OS_CHK_STATUS_RETURN(FunctionToGpuContextEncode(option, ctx)); |
| 706 |
break; |
| 707 |
case VdboxDecodeFunc: |
| 708 |
case VdboxDecodeVirtualNode0Func: |
| 709 |
case VdboxDecodeVirtualNode1Func: |
| 710 |
MOS_OS_CHK_STATUS_RETURN(FunctionToGpuContextDecode(option, node, ctx)); |
| 711 |
break; |
| 712 |
case VdboxDecodeWaFunc: |
| 713 |
ctx = MOS_GPU_CONTEXT_VIDEO2; |
| 714 |
break; |
| 715 |
case VdboxDecrpytFunc: |
| 716 |
ctx = MOS_GPU_CONTEXT_VDBOX2_VIDEO2; |
| 717 |
break; |
| 718 |
case VeboxVppFunc: |
| 719 |
ctx = MOS_GPU_CONTEXT_VEBOX; |
| 720 |
break; |
| 721 |
case RenderGenericFunc: |
| 722 |
ctx = option.RAMode ? MOS_GPU_CONTEXT_RENDER_RA : MOS_GPU_CONTEXT_RENDER; |
| 723 |
break; |
| 724 |
case ComputeVppFunc: |
| 725 |
ctx = option.RAMode ? MOS_GPU_CONTEXT_COMPUTE_RA : MOS_GPU_CONTEXT_COMPUTE; |
| 726 |
break; |
| 727 |
case ComputeMdfFunc: |
| 728 |
ctx = MOS_GPU_CONTEXT_CM_COMPUTE; |
| 729 |
break; |
| 730 |
case VdboxCpFunc: |
| 731 |
ctx = MOS_GPU_CONTEXT_VIDEO; |
| 732 |
break; |
| 733 |
default: |
| 734 |
ctx = MOS_GPU_CONTEXT_MAX; |
| 735 |
MOS_OS_ASSERTMESSAGE("Func is invalid"); |
| 736 |
return MOS_STATUS_INVALID_PARAMETER; |
| 737 |
} |
| 738 |
|
| 739 |
return MOS_STATUS_SUCCESS; |
| 740 |
} |
| 741 |
|
| 742 |
MOS_STATUS MediaContext::FunctionToGpuContextDecode(const MOS_GPUCTX_CREATOPTIONS_ENHANCED &option, const MOS_GPU_NODE &node, MOS_GPU_CONTEXT &ctx) |
| 743 |
{ |
| 744 |
if (option.UsingSFC) |
| 745 |
{ |
| 746 |
ctx = MOS_GPU_CONTEXT_VIDEO4; |
| 747 |
} |
| 748 |
else |
| 749 |
{ |
| 750 |
switch (option.LRCACount) |
| 751 |
{ |
| 752 |
case 0: |
| 753 |
case 1: |
| 754 |
ctx = (node == MOS_GPU_NODE_VIDEO) ? MOS_GPU_CONTEXT_VIDEO : MOS_GPU_CONTEXT_VDBOX2_VIDEO; |
| 755 |
break; |
| 756 |
case 2: |
| 757 |
ctx = MOS_GPU_CONTEXT_VIDEO5; |
| 758 |
break; |
| 759 |
case 3: |
| 760 |
ctx = MOS_GPU_CONTEXT_VIDEO7; |
| 761 |
break; |
| 762 |
default: |
| 763 |
ctx = MOS_GPU_CONTEXT_VIDEO; |
| 764 |
break; |
| 765 |
} |
| 766 |
} |
| 767 |
|
| 768 |
return MOS_STATUS_SUCCESS; |
| 769 |
} |
| 770 |
|
| 771 |
MOS_STATUS MediaContext::FunctionToGpuContextEncode(const MOS_GPUCTX_CREATOPTIONS_ENHANCED &option, MOS_GPU_CONTEXT &ctx) |
| 772 |
{ |
| 773 |
switch (option.LRCACount) |
| 774 |
{ |
| 775 |
case 0: |
| 776 |
case 1: |
| 777 |
ctx = MOS_GPU_CONTEXT_VIDEO3; |
| 778 |
break; |
| 779 |
case 2: |
| 780 |
ctx = MOS_GPU_CONTEXT_VIDEO6; |
| 781 |
break; |
| 782 |
case 4: |
| 783 |
ctx = MOS_GPU_CONTEXT_VIDEO6; //Change to proper slot when MOS_GPU_CONTEXT num extended |
| 784 |
break; |
| 785 |
default: |
| 786 |
ctx = MOS_GPU_CONTEXT_VIDEO3; |
| 787 |
break; |
| 788 |
} |
| 789 |
|
| 790 |
return MOS_STATUS_SUCCESS; |
| 791 |
} |
| 792 |
|
| 793 |
void MediaContext::SetLatestDecoderVirtualNode() |
| 794 |
{ |
| 795 |
if (m_curNodeOrdinal == MOS_GPU_NODE_VIDEO || m_curNodeOrdinal == MOS_GPU_NODE_VIDEO2) |
| 796 |
{ |
| 797 |
m_osInterface->pfnSetLatestVirtualNode(m_osInterface, m_curNodeOrdinal); |
| 798 |
} |
| 799 |
} |
| 800 |
|
| 801 |
MOS_STATUS MediaContext::ReassignContextForDecoder(uint32_t frameNum, ContextRequirement *requirement, MediaScalability **scalabilityState) |
| 802 |
{ |
| 803 |
if (frameNum == 0) |
| 804 |
{ |
| 805 |
// if encoder is working, always reassign decoder to different virtual node |
| 806 |
MOS_GPU_NODE encoderNode = m_osInterface->pfnGetLatestVirtualNode(m_osInterface, COMPONENT_Encode); |
| 807 |
if (encoderNode == MOS_GPU_NODE_VIDEO) |
| 808 |
{ |
| 809 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode1Func, requirement, scalabilityState)); |
| 810 |
} |
| 811 |
else if (encoderNode == MOS_GPU_NODE_VIDEO2) |
| 812 |
{ |
| 813 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode0Func, requirement, scalabilityState)); |
| 814 |
} |
| 815 |
else |
| 816 |
{ |
| 817 |
// if only decoders are working, reassign decoder to different virtual node compared to latest used virtual node |
| 818 |
MOS_GPU_NODE decoderNode = m_osInterface->pfnGetLatestVirtualNode(m_osInterface, COMPONENT_Decode); |
| 819 |
if (decoderNode == MOS_GPU_NODE_VIDEO) |
| 820 |
{ |
| 821 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode1Func, requirement, scalabilityState)); |
| 822 |
} |
| 823 |
else if (decoderNode == MOS_GPU_NODE_VIDEO2) |
| 824 |
{ |
| 825 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode0Func, requirement, scalabilityState)); |
| 826 |
} |
| 827 |
else |
| 828 |
{ |
| 829 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeFunc, requirement, scalabilityState)); |
| 830 |
} |
| 831 |
} |
| 832 |
} |
| 833 |
else |
| 834 |
{ |
| 835 |
// for remaining frames, don't change virtual node assignment |
| 836 |
MOS_GPU_NODE decoderNode = m_osInterface->pfnGetDecoderVirtualNodePerStream(m_osInterface); |
| 837 |
if (decoderNode == MOS_GPU_NODE_VIDEO) |
| 838 |
{ |
| 839 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode0Func, requirement, scalabilityState)); |
| 840 |
} |
| 841 |
else if (decoderNode == MOS_GPU_NODE_VIDEO2) |
| 842 |
{ |
| 843 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode1Func, requirement, scalabilityState)); |
| 844 |
} |
| 845 |
else |
| 846 |
{ |
| 847 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeFunc, requirement, scalabilityState)); |
| 848 |
} |
| 849 |
} |
| 850 |
|
| 851 |
return MOS_STATUS_SUCCESS; |
| 852 |
} |
| 853 |
|
| 854 |
MOS_STATUS MediaContext::ReassignContextForDecoder(uint32_t frameNum, MediaScalabilityOption &scalabilityOption, MediaScalability **scalabilityState) |
| 855 |
{ |
| 856 |
if (frameNum == 0) |
| 857 |
{ |
| 858 |
// if encoder is working, always reassign decoder to different virtual node |
| 859 |
MOS_GPU_NODE encoderNode = m_osInterface->pfnGetLatestVirtualNode(m_osInterface, COMPONENT_Encode); |
| 860 |
if (encoderNode == MOS_GPU_NODE_VIDEO) |
| 861 |
{ |
| 862 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode1Func, scalabilityOption, scalabilityState)); |
| 863 |
} |
| 864 |
else if (encoderNode == MOS_GPU_NODE_VIDEO2) |
| 865 |
{ |
| 866 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode0Func, scalabilityOption, scalabilityState)); |
| 867 |
} |
| 868 |
else |
| 869 |
{ |
| 870 |
// if only decoders are working, reassign decoder to different virtual node compared to latest used virtual node |
| 871 |
MOS_GPU_NODE decoderNode = m_osInterface->pfnGetLatestVirtualNode(m_osInterface, COMPONENT_Decode); |
| 872 |
if (decoderNode == MOS_GPU_NODE_VIDEO) |
| 873 |
{ |
| 874 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode1Func, scalabilityOption, scalabilityState)); |
| 875 |
} |
| 876 |
else if (decoderNode == MOS_GPU_NODE_VIDEO2) |
| 877 |
{ |
| 878 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode0Func, scalabilityOption, scalabilityState)); |
| 879 |
} |
| 880 |
else |
| 881 |
{ |
| 882 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeFunc, scalabilityOption, scalabilityState)); |
| 883 |
} |
| 884 |
} |
| 885 |
} |
| 886 |
else |
| 887 |
{ |
| 888 |
// for remaining frames, don't change virtual node assignment |
| 889 |
MOS_GPU_NODE decoderNode = m_osInterface->pfnGetDecoderVirtualNodePerStream(m_osInterface); |
| 890 |
if (decoderNode == MOS_GPU_NODE_VIDEO) |
| 891 |
{ |
| 892 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode0Func, scalabilityOption, scalabilityState)); |
| 893 |
} |
| 894 |
else if (decoderNode == MOS_GPU_NODE_VIDEO2) |
| 895 |
{ |
| 896 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeVirtualNode1Func, scalabilityOption, scalabilityState)); |
| 897 |
} |
| 898 |
else |
| 899 |
{ |
| 900 |
MOS_OS_CHK_STATUS_RETURN(SwitchContext(VdboxDecodeFunc, scalabilityOption, scalabilityState)); |
| 901 |
} |
| 902 |
} |
| 903 |
|
| 904 |
return MOS_STATUS_SUCCESS; |
| 905 |
} |