| 1 |
/* |
| 2 |
* Copyright (c) 2009-2023, 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 mos_interface.cpp |
| 24 |
//! \brief MOS interface implementation |
| 25 |
//! |
| 26 |
|
| 27 |
#include "mos_interface.h" |
| 28 |
#include "mos_os_cp_interface_specific.h" |
| 29 |
#include "mos_context_specific_next.h" |
| 30 |
#include "mos_gpucontext_specific_next.h" |
| 31 |
#include "media_libva_common.h" |
| 32 |
#include "mos_auxtable_mgr.h" |
| 33 |
#include "mos_os_virtualengine_singlepipe_specific_next.h" |
| 34 |
#include "mos_os_virtualengine_scalability_specific_next.h" |
| 35 |
#include "mos_graphicsresource_specific_next.h" |
| 36 |
#include "mos_bufmgr_priv.h" |
| 37 |
#include "drm_device.h" |
| 38 |
#include "media_fourcc.h" |
| 39 |
#include "mos_oca_rtlog_mgr.h" |
| 40 |
|
| 41 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 42 |
#include <stdlib.h> //for simulate random OS API failure |
| 43 |
#include <time.h> //for simulate random OS API failure |
| 44 |
#endif |
| 45 |
|
| 46 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 47 |
#include <fstream> |
| 48 |
#include <sstream> |
| 49 |
#include <iomanip> |
| 50 |
#endif |
| 51 |
|
| 52 |
MOS_STATUS MosInterface::InitOsUtilities(DDI_DEVICE_CONTEXT ddiDeviceContext) |
| 53 |
{ |
| 54 |
MediaUserSettingSharedPtr userSettingPtr = MosGetUserSettingInstance((PMOS_CONTEXT)ddiDeviceContext); |
| 55 |
|
| 56 |
MosUtilities::MosUtilitiesInit(userSettingPtr); |
| 57 |
|
| 58 |
// MOS_OS_FUNCTION_ENTER need mos utilities init |
| 59 |
MOS_OS_FUNCTION_ENTER; |
| 60 |
|
| 61 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 62 |
//Init MOS OS API fail simulate flags |
| 63 |
MosInitOsApiFailSimulateFlag(userSettingPtr); |
| 64 |
#endif |
| 65 |
|
| 66 |
//Read user feature key here for Per Utility Tool Enabling |
| 67 |
if (!g_perfutility->bPerfUtilityKey) |
| 68 |
{ |
| 69 |
g_perfutility->dwPerfUtilityIsEnabled = 0; |
| 70 |
ReadUserSetting( |
| 71 |
userSettingPtr, |
| 72 |
g_perfutility->dwPerfUtilityIsEnabled, |
| 73 |
__MEDIA_USER_FEATURE_VALUE_PERF_UTILITY_TOOL_ENABLE, |
| 74 |
MediaUserSetting::Group::Device); |
| 75 |
|
| 76 |
|
| 77 |
MOS_STATUS eStatus_Perf = MOS_STATUS_SUCCESS; |
| 78 |
std::string perfOutputDir = ""; |
| 79 |
|
| 80 |
eStatus_Perf = ReadUserSetting( |
| 81 |
userSettingPtr, |
| 82 |
perfOutputDir, |
| 83 |
__MEDIA_USER_FEATURE_VALUE_PERF_OUTPUT_DIRECTORY, |
| 84 |
MediaUserSetting::Group::Device); |
| 85 |
if (eStatus_Perf == MOS_STATUS_SUCCESS) |
| 86 |
{ |
| 87 |
g_perfutility->setupFilePath(perfOutputDir.c_str()); |
| 88 |
} |
| 89 |
else |
| 90 |
{ |
| 91 |
g_perfutility->setupFilePath(); |
| 92 |
} |
| 93 |
|
| 94 |
g_perfutility->bPerfUtilityKey = true; |
| 95 |
} |
| 96 |
|
| 97 |
return MOS_STATUS_SUCCESS; |
| 98 |
} |
| 99 |
|
| 100 |
MOS_STATUS MosInterface::CloseOsUtilities(PMOS_CONTEXT mosCtx) |
| 101 |
{ |
| 102 |
MOS_OS_FUNCTION_ENTER; |
| 103 |
|
| 104 |
MediaUserSettingSharedPtr userSettingPtr = MosInterface::MosGetUserSettingInstance(mosCtx); |
| 105 |
|
| 106 |
// Close MOS utlities |
| 107 |
MosUtilities::MosUtilitiesClose(userSettingPtr); |
| 108 |
|
| 109 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 110 |
//reset MOS init OS API simulate flags |
| 111 |
MosDeinitOsApiFailSimulateFlag(); |
| 112 |
#endif |
| 113 |
|
| 114 |
return MOS_STATUS_SUCCESS; |
| 115 |
} |
| 116 |
|
| 117 |
MOS_STATUS MosInterface::CreateOsDeviceContext(DDI_DEVICE_CONTEXT ddiDeviceContext, MOS_DEVICE_HANDLE *deviceContext) |
| 118 |
{ |
| 119 |
MOS_OS_FUNCTION_ENTER; |
| 120 |
|
| 121 |
MOS_OS_CHK_NULL_RETURN(deviceContext); |
| 122 |
MOS_OS_CHK_NULL_RETURN(ddiDeviceContext); |
| 123 |
|
| 124 |
*deviceContext = MOS_New(OsContextSpecificNext); |
| 125 |
|
| 126 |
MOS_OS_CHK_NULL_RETURN(*deviceContext); |
| 127 |
|
| 128 |
MOS_OS_CHK_STATUS_RETURN((*deviceContext)->Init((PMOS_CONTEXT)ddiDeviceContext)); |
| 129 |
|
| 130 |
return MOS_STATUS_SUCCESS; |
| 131 |
} |
| 132 |
|
| 133 |
MOS_STATUS MosInterface::DestroyOsDeviceContext(MOS_DEVICE_HANDLE deviceContext) |
| 134 |
{ |
| 135 |
MOS_OS_FUNCTION_ENTER; |
| 136 |
|
| 137 |
if (deviceContext) |
| 138 |
{ |
| 139 |
deviceContext->CleanUp(); |
| 140 |
MOS_Delete(deviceContext); |
| 141 |
deviceContext = nullptr; |
| 142 |
} |
| 143 |
|
| 144 |
return MOS_STATUS_SUCCESS; |
| 145 |
} |
| 146 |
|
| 147 |
MOS_STATUS MosInterface::CreateOsStreamState( |
| 148 |
MOS_STREAM_HANDLE *streamState, |
| 149 |
MOS_DEVICE_HANDLE deviceContext, |
| 150 |
MOS_INTERFACE_HANDLE osInterface, |
| 151 |
MOS_COMPONENT component, |
| 152 |
EXTRA_PARAMS extraParams) |
| 153 |
{ |
| 154 |
MOS_STATUS eStatusUserFeature = MOS_STATUS_SUCCESS; |
| 155 |
uint32_t regValue = 0; |
| 156 |
MediaUserSettingSharedPtr userSettingPtr = nullptr; |
| 157 |
|
| 158 |
MOS_OS_FUNCTION_ENTER; |
| 159 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 160 |
MOS_OS_CHK_NULL_RETURN(deviceContext); |
| 161 |
|
| 162 |
*streamState = MOS_New(MosStreamState); |
| 163 |
MOS_OS_CHK_NULL_RETURN(*streamState); |
| 164 |
|
| 165 |
(*streamState)->osDeviceContext = deviceContext; |
| 166 |
(*streamState)->component = component; |
| 167 |
(*streamState)->currentGpuContextHandle = 0; |
| 168 |
|
| 169 |
(*streamState)->simIsActive = false; |
| 170 |
(*streamState)->mediaReset = false; |
| 171 |
|
| 172 |
(*streamState)->usesPatchList = true; |
| 173 |
(*streamState)->usesGfxAddress = !(*streamState)->usesPatchList; |
| 174 |
|
| 175 |
userSettingPtr = MosInterface::MosGetUserSettingInstance((PMOS_CONTEXT)extraParams); |
| 176 |
|
| 177 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 178 |
ReadUserSettingForDebug( |
| 179 |
userSettingPtr, |
| 180 |
(*streamState)->simIsActive, |
| 181 |
__MEDIA_USER_FEATURE_VALUE_SIM_ENABLE, |
| 182 |
MediaUserSetting::Group::Device); |
| 183 |
|
| 184 |
// Null HW Driver |
| 185 |
// 0: Disabled |
| 186 |
ReadUserSettingForDebug( |
| 187 |
userSettingPtr, |
| 188 |
(*streamState)->nullHwAccelerationEnable.Value, |
| 189 |
__MEDIA_USER_FEATURE_VALUE_NULL_HW_ACCELERATION_ENABLE, |
| 190 |
MediaUserSetting::Group::Device); |
| 191 |
|
| 192 |
#endif |
| 193 |
|
| 194 |
// SupportVirtualEngine flag is set by Hals |
| 195 |
(*streamState)->supportVirtualEngine = false; |
| 196 |
(*streamState)->useHwSemaForResSyncInVe = false; |
| 197 |
(*streamState)->virtualEngineInterface = nullptr; |
| 198 |
(*streamState)->veEnable = false; |
| 199 |
(*streamState)->phasedSubmission = true; |
| 200 |
|
| 201 |
auto skuTable = GetSkuTable(*streamState); |
| 202 |
MOS_OS_CHK_NULL_RETURN(skuTable); |
| 203 |
if (MEDIA_IS_SKU(skuTable, FtrGucSubmission)) |
| 204 |
{ |
| 205 |
(*streamState)->bParallelSubmission = true; |
| 206 |
} |
| 207 |
|
| 208 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 209 |
// read the "Force VDBOX" user feature key |
| 210 |
// 0: not force |
| 211 |
ReadUserSettingForDebug( |
| 212 |
userSettingPtr, |
| 213 |
(*streamState)->eForceVdbox, |
| 214 |
__MEDIA_USER_FEATURE_VALUE_FORCE_VDBOX, |
| 215 |
MediaUserSetting::Group::Device); |
| 216 |
|
| 217 |
//Read Scalable/Legacy Decode mode on Gen11+ |
| 218 |
//1:by default for scalable decode mode |
| 219 |
//0:for legacy decode mode |
| 220 |
regValue = 0; |
| 221 |
eStatusUserFeature = ReadUserSetting( |
| 222 |
userSettingPtr, |
| 223 |
regValue, |
| 224 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_HCP_SCALABILITY_DECODE, |
| 225 |
MediaUserSetting::Group::Device); |
| 226 |
|
| 227 |
(*streamState)->hcpDecScalabilityMode = regValue ? MOS_SCALABILITY_ENABLE_MODE_DEFAULT : MOS_SCALABILITY_ENABLE_MODE_FALSE; |
| 228 |
if((*streamState)->hcpDecScalabilityMode |
| 229 |
&& (eStatusUserFeature == MOS_STATUS_SUCCESS)) |
| 230 |
{ |
| 231 |
//user's value to enable scalability |
| 232 |
(*streamState)->hcpDecScalabilityMode = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE; |
| 233 |
} |
| 234 |
|
| 235 |
(*streamState)->frameSplit = false; |
| 236 |
ReadUserSettingForDebug( |
| 237 |
userSettingPtr, |
| 238 |
(*streamState)->frameSplit, |
| 239 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_LINUX_FRAME_SPLIT, |
| 240 |
MediaUserSetting::Group::Device); |
| 241 |
|
| 242 |
regValue = 0; |
| 243 |
ReadUserSettingForDebug( |
| 244 |
userSettingPtr, |
| 245 |
regValue, |
| 246 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_GUC_SUBMISSION, |
| 247 |
MediaUserSetting::Group::Device); |
| 248 |
(*streamState)->bParallelSubmission = (*streamState)->bParallelSubmission && regValue; |
| 249 |
|
| 250 |
//KMD Virtual Engine DebugOverride |
| 251 |
// 0: not Override |
| 252 |
ReadUserSettingForDebug( |
| 253 |
userSettingPtr, |
| 254 |
(*streamState)->enableDbgOvrdInVirtualEngine, |
| 255 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_VE_DEBUG_OVERRIDE, |
| 256 |
MediaUserSetting::Group::Device); |
| 257 |
#endif |
| 258 |
|
| 259 |
if (component == COMPONENT_VPCommon || |
| 260 |
component == COMPONENT_VPreP || |
| 261 |
component == COMPONENT_LibVA) |
| 262 |
{ |
| 263 |
// UMD Vebox Virtual Engine Scalability Mode |
| 264 |
// 0: disable. can set to 1 only when KMD VE is enabled. |
| 265 |
regValue = 0; |
| 266 |
eStatusUserFeature = ReadUserSetting( |
| 267 |
userSettingPtr, |
| 268 |
regValue, |
| 269 |
__MEDIA_USER_FEATURE_VALUE_ENABLE_VEBOX_SCALABILITY_MODE, |
| 270 |
MediaUserSetting::Group::Device); |
| 271 |
(*streamState)->veboxScalabilityMode = regValue ? MOS_SCALABILITY_ENABLE_MODE_DEFAULT : MOS_SCALABILITY_ENABLE_MODE_FALSE; |
| 272 |
|
| 273 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 274 |
if((*streamState)->veboxScalabilityMode |
| 275 |
&& (eStatusUserFeature == MOS_STATUS_SUCCESS)) |
| 276 |
{ |
| 277 |
//user's value to enable scalability |
| 278 |
(*streamState)->veboxScalabilityMode = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE; |
| 279 |
(*streamState)->enableDbgOvrdInVirtualEngine = true; |
| 280 |
|
| 281 |
if ((*streamState)->eForceVebox == MOS_FORCE_VEBOX_NONE) |
| 282 |
{ |
| 283 |
(*streamState)->eForceVebox = MOS_FORCE_VEBOX_1_2; |
| 284 |
} |
| 285 |
} |
| 286 |
else if ((!(*streamState)->veboxScalabilityMode) |
| 287 |
&& (eStatusUserFeature == MOS_STATUS_SUCCESS)) |
| 288 |
{ |
| 289 |
(*streamState)->enableDbgOvrdInVirtualEngine = true; |
| 290 |
(*streamState)->eForceVebox = MOS_FORCE_VEBOX_NONE; |
| 291 |
} |
| 292 |
|
| 293 |
// read the "Force VEBOX" user feature key |
| 294 |
// 0: not force |
| 295 |
regValue = 0; |
| 296 |
ReadUserSettingForDebug( |
| 297 |
userSettingPtr, |
| 298 |
regValue, |
| 299 |
__MEDIA_USER_FEATURE_VALUE_FORCE_VEBOX, |
| 300 |
MediaUserSetting::Group::Device); |
| 301 |
(*streamState)->eForceVebox = (MOS_FORCE_VEBOX)regValue; |
| 302 |
#endif |
| 303 |
} |
| 304 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 305 |
ReportUserSettingForDebug( |
| 306 |
userSettingPtr, |
| 307 |
__MEDIA_USER_FEATURE_VALUE_SIM_IN_USE, |
| 308 |
(*streamState)->simIsActive, |
| 309 |
MediaUserSetting::Group::Device); |
| 310 |
#endif |
| 311 |
|
| 312 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::InitStreamParameters(*streamState, extraParams)); |
| 313 |
|
| 314 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 315 |
DumpCommandBufferInit(*streamState); |
| 316 |
#endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 317 |
|
| 318 |
return MOS_STATUS_SUCCESS; |
| 319 |
} |
| 320 |
|
| 321 |
MOS_STATUS MosInterface::DestroyOsStreamState( |
| 322 |
MOS_STREAM_HANDLE streamState) |
| 323 |
{ |
| 324 |
MOS_OS_FUNCTION_ENTER; |
| 325 |
|
| 326 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 327 |
|
| 328 |
if (streamState->mosDecompression) |
| 329 |
{ |
| 330 |
MOS_Delete(streamState->mosDecompression); |
| 331 |
streamState->mosDecompression = nullptr; |
| 332 |
} |
| 333 |
|
| 334 |
MOS_Delete(streamState); |
| 335 |
streamState = nullptr; |
| 336 |
|
| 337 |
return MOS_STATUS_SUCCESS; |
| 338 |
} |
| 339 |
|
| 340 |
MOS_STATUS MosInterface::InitStreamParameters( |
| 341 |
MOS_STREAM_HANDLE streamState, |
| 342 |
EXTRA_PARAMS extraParams) |
| 343 |
{ |
| 344 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 345 |
PMOS_CONTEXT context = nullptr; |
| 346 |
uint32_t resetCount = 0; |
| 347 |
int32_t ret = 0; |
| 348 |
MOS_BUFMGR *bufMgr = nullptr; |
| 349 |
int32_t fd = -1; |
| 350 |
OsContextSpecificNext *osDeviceContext = nullptr; |
| 351 |
|
| 352 |
MOS_OS_FUNCTION_ENTER; |
| 353 |
|
| 354 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 355 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 356 |
MOS_OS_CHK_NULL_RETURN(extraParams); |
| 357 |
|
| 358 |
osDeviceContext = (OsContextSpecificNext *)streamState->osDeviceContext; |
| 359 |
fd = osDeviceContext->GetFd(); |
| 360 |
if (0 > fd) |
| 361 |
{ |
| 362 |
MOS_OS_ASSERTMESSAGE("Invalid fd"); |
| 363 |
return MOS_STATUS_INVALID_HANDLE; |
| 364 |
} |
| 365 |
|
| 366 |
bufMgr = osDeviceContext->GetBufMgr(); |
| 367 |
MOS_OS_CHK_NULL_RETURN(bufMgr); |
| 368 |
|
| 369 |
context = MOS_New(MOS_OS_CONTEXT); |
| 370 |
MOS_OS_CHK_NULL_RETURN(context); |
| 371 |
|
| 372 |
context->m_apoMosEnabled = true; |
| 373 |
context->m_osDeviceContext = streamState->osDeviceContext; |
| 374 |
context->bSimIsActive = streamState->simIsActive; |
| 375 |
|
| 376 |
streamState->perStreamParameters = (OS_PER_STREAM_PARAMETERS)context; |
| 377 |
|
| 378 |
context->pGmmClientContext = streamState->osDeviceContext->GetGmmClientContext();; |
| 379 |
|
| 380 |
context->bufmgr = bufMgr; |
| 381 |
context->m_gpuContextMgr = osDeviceContext->GetGpuContextMgr(); |
| 382 |
context->m_cmdBufMgr = osDeviceContext->GetCmdBufferMgr(); |
| 383 |
context->fd = fd; |
| 384 |
context->pPerfData = ((PMOS_CONTEXT)extraParams)->pPerfData; |
| 385 |
|
| 386 |
context->m_userSettingPtr = ((PMOS_CONTEXT)extraParams)->m_userSettingPtr; |
| 387 |
context->m_auxTableMgr = osDeviceContext->GetAuxTableMgr(); |
| 388 |
|
| 389 |
mos_bufmgr_enable_reuse(bufMgr); |
| 390 |
|
| 391 |
context->m_skuTable = *osDeviceContext->GetSkuTable(); |
| 392 |
context->m_waTable = *osDeviceContext->GetWaTable(); |
| 393 |
context->m_gtSystemInfo = *osDeviceContext->GetGtSysInfo(); |
| 394 |
context->m_platform = *osDeviceContext->GetPlatformInfo(); |
| 395 |
context->m_protectedGEMContext = ((PMOS_CONTEXT)extraParams)->m_protectedGEMContext; |
| 396 |
|
| 397 |
context->bUse64BitRelocs = true; |
| 398 |
context->bUseSwSwizzling = context->bSimIsActive || MEDIA_IS_SKU(&context->m_skuTable, FtrUseSwSwizzling); |
| 399 |
context->bTileYFlag = MEDIA_IS_SKU(&context->m_skuTable, FtrTileY); |
| 400 |
|
| 401 |
if (MEDIA_IS_SKU(&context->m_skuTable, FtrContextBasedScheduling)) |
| 402 |
{ |
| 403 |
MOS_TraceEventExt(EVENT_GPU_CONTEXT_CREATE, EVENT_TYPE_START, |
| 404 |
&eStatus, sizeof(eStatus), nullptr, 0); |
| 405 |
context->intel_context = mos_context_create_ext(context->bufmgr, 0, context->m_protectedGEMContext); |
| 406 |
MOS_OS_CHK_NULL_RETURN(context->intel_context); |
| 407 |
context->intel_context->vm_id = mos_vm_create(context->bufmgr); |
| 408 |
if (context->intel_context->vm_id == INVALID_VM) |
| 409 |
{ |
| 410 |
MOS_OS_ASSERTMESSAGE("Failed to create vm.\n"); |
| 411 |
return MOS_STATUS_UNKNOWN; |
| 412 |
} |
| 413 |
MOS_TraceEventExt(EVENT_GPU_CONTEXT_CREATE, EVENT_TYPE_END, |
| 414 |
&context->intel_context, sizeof(void *), |
| 415 |
&eStatus, sizeof(eStatus)); |
| 416 |
} |
| 417 |
else //use legacy context create ioctl for pre-gen11 platforms |
| 418 |
{ |
| 419 |
MOS_OS_ASSERTMESSAGE("Do not support the legacy context creation.\n"); |
| 420 |
MOS_FreeMemAndSetNull(context->pPerfData); |
| 421 |
MOS_Delete(context); |
| 422 |
streamState->perStreamParameters = nullptr; |
| 423 |
return MOS_STATUS_UNIMPLEMENTED; |
| 424 |
} |
| 425 |
context->intel_context->pOsContext = context; |
| 426 |
ret = mos_get_reset_stats(context->intel_context, &resetCount, nullptr, nullptr); |
| 427 |
if (ret) |
| 428 |
{ |
| 429 |
MOS_OS_NORMALMESSAGE("mos_get_reset_stats return error(%d)\n", ret); |
| 430 |
resetCount = 0; |
| 431 |
} |
| 432 |
streamState->ctxPriority = 0; |
| 433 |
streamState->gpuResetCount = resetCount; |
| 434 |
streamState->gpuActiveBatch = 0; |
| 435 |
streamState->gpuPendingBatch = 0; |
| 436 |
|
| 437 |
context->bIsAtomSOC = false; |
| 438 |
context->bFreeContext = true; |
| 439 |
|
| 440 |
streamState->enableDecomp = true; |
| 441 |
|
| 442 |
#ifndef ANDROID |
| 443 |
{ |
| 444 |
context->bKMDHasVCS2 = mos_has_bsd2(context->bufmgr); |
| 445 |
} |
| 446 |
#endif |
| 447 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 448 |
// read "Linux PerformanceTag Enable" user feature key |
| 449 |
uint32_t regValue = 0; |
| 450 |
ReadUserSettingForDebug( |
| 451 |
context->m_userSettingPtr, |
| 452 |
regValue, |
| 453 |
__MEDIA_USER_FEATURE_VALUE_LINUX_PERFORMANCETAG_ENABLE, |
| 454 |
MediaUserSetting::Group::Device); |
| 455 |
|
| 456 |
context->uEnablePerfTag = regValue; |
| 457 |
#endif |
| 458 |
|
| 459 |
return MOS_STATUS_SUCCESS; |
| 460 |
} |
| 461 |
|
| 462 |
uint32_t MosInterface::GetInterfaceVersion(MOS_DEVICE_HANDLE deviceContext) |
| 463 |
{ |
| 464 |
MOS_OS_FUNCTION_ENTER; |
| 465 |
|
| 466 |
// No interface version to get in Linux |
| 467 |
|
| 468 |
return 0; |
| 469 |
} |
| 470 |
|
| 471 |
PLATFORM *MosInterface::GetPlatform(MOS_STREAM_HANDLE streamState) |
| 472 |
{ |
| 473 |
MOS_OS_FUNCTION_ENTER; |
| 474 |
|
| 475 |
if (streamState && streamState->osDeviceContext) |
| 476 |
{ |
| 477 |
return streamState->osDeviceContext->GetPlatformInfo(); |
| 478 |
} |
| 479 |
|
| 480 |
return nullptr; |
| 481 |
} |
| 482 |
|
| 483 |
MEDIA_FEATURE_TABLE *MosInterface::GetSkuTable(MOS_STREAM_HANDLE streamState) |
| 484 |
{ |
| 485 |
MOS_OS_FUNCTION_ENTER; |
| 486 |
|
| 487 |
if (streamState && streamState->osDeviceContext) |
| 488 |
{ |
| 489 |
return streamState->osDeviceContext->GetSkuTable(); |
| 490 |
} |
| 491 |
|
| 492 |
return nullptr; |
| 493 |
} |
| 494 |
|
| 495 |
MEDIA_WA_TABLE *MosInterface::GetWaTable(MOS_STREAM_HANDLE streamState) |
| 496 |
{ |
| 497 |
MOS_OS_FUNCTION_ENTER; |
| 498 |
|
| 499 |
if (streamState && streamState->osDeviceContext) |
| 500 |
{ |
| 501 |
return streamState->osDeviceContext->GetWaTable(); |
| 502 |
} |
| 503 |
|
| 504 |
return nullptr; |
| 505 |
} |
| 506 |
|
| 507 |
MEDIA_SYSTEM_INFO *MosInterface::GetGtSystemInfo(MOS_STREAM_HANDLE streamState) |
| 508 |
{ |
| 509 |
MOS_OS_FUNCTION_ENTER; |
| 510 |
|
| 511 |
if (streamState && streamState->osDeviceContext) |
| 512 |
{ |
| 513 |
return streamState->osDeviceContext->GetGtSysInfo(); |
| 514 |
} |
| 515 |
|
| 516 |
return nullptr; |
| 517 |
} |
| 518 |
|
| 519 |
MOS_STATUS MosInterface::GetMediaEngineInfo(MOS_STREAM_HANDLE streamState, MEDIA_ENGINE_INFO &info) |
| 520 |
{ |
| 521 |
MOS_OS_FUNCTION_ENTER; |
| 522 |
|
| 523 |
auto systemInfo = MosInterface::GetGtSystemInfo(streamState); |
| 524 |
MOS_OS_CHK_NULL_RETURN(systemInfo); |
| 525 |
|
| 526 |
MosUtilities::MosZeroMemory(&info, sizeof(info)); |
| 527 |
info.VDBoxInfo = systemInfo->VDBoxInfo; |
| 528 |
info.VEBoxInfo = systemInfo->VEBoxInfo; |
| 529 |
|
| 530 |
return MOS_STATUS_SUCCESS; |
| 531 |
} |
| 532 |
|
| 533 |
ADAPTER_INFO *MosInterface::GetAdapterInfo(MOS_STREAM_HANDLE streamState) |
| 534 |
{ |
| 535 |
MOS_OS_FUNCTION_ENTER; |
| 536 |
|
| 537 |
// No adapter Info in Linux |
| 538 |
|
| 539 |
return nullptr; |
| 540 |
} |
| 541 |
|
| 542 |
MOS_STATUS MosInterface::CreateGpuContext( |
| 543 |
MOS_STREAM_HANDLE streamState, |
| 544 |
GpuContextCreateOption &createOption, |
| 545 |
GPU_CONTEXT_HANDLE &gpuContextHandle) |
| 546 |
{ |
| 547 |
MOS_OS_FUNCTION_ENTER; |
| 548 |
|
| 549 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 550 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 551 |
|
| 552 |
auto osDeviceContext = streamState->osDeviceContext; |
| 553 |
|
| 554 |
auto gpuContextMgr = osDeviceContext->GetGpuContextMgr(); |
| 555 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 556 |
|
| 557 |
auto cmdBufMgr = osDeviceContext->GetCmdBufferMgr(); |
| 558 |
MOS_OS_CHK_NULL_RETURN(cmdBufMgr); |
| 559 |
|
| 560 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 561 |
MOS_OS_CHK_NULL_RETURN(osParameters); |
| 562 |
|
| 563 |
if (createOption.gpuNode == MOS_GPU_NODE_3D && createOption.SSEUValue != 0) |
| 564 |
{ |
| 565 |
struct drm_i915_gem_context_param_sseu sseu; |
| 566 |
MosUtilities::MosZeroMemory(&sseu, sizeof(sseu)); |
| 567 |
sseu.engine.engine_class = I915_ENGINE_CLASS_RENDER; |
| 568 |
sseu.engine.engine_instance = 0; |
| 569 |
|
| 570 |
if (mos_get_context_param_sseu(osParameters->intel_context, &sseu)) |
| 571 |
{ |
| 572 |
MOS_OS_ASSERTMESSAGE("Failed to get sseu configuration."); |
| 573 |
return MOS_STATUS_UNKNOWN; |
| 574 |
}; |
| 575 |
|
| 576 |
if (mos_hweight8(osParameters->intel_context, sseu.subslice_mask) > createOption.packed.SubSliceCount) |
| 577 |
{ |
| 578 |
sseu.subslice_mask = mos_switch_off_n_bits(osParameters->intel_context, sseu.subslice_mask, |
| 579 |
mos_hweight8(osParameters->intel_context, sseu.subslice_mask) - createOption.packed.SubSliceCount); |
| 580 |
} |
| 581 |
|
| 582 |
if (mos_set_context_param_sseu(osParameters->intel_context, sseu)) |
| 583 |
{ |
| 584 |
MOS_OS_ASSERTMESSAGE("Failed to set sseu configuration."); |
| 585 |
return MOS_STATUS_UNKNOWN; |
| 586 |
}; |
| 587 |
} |
| 588 |
|
| 589 |
MOS_GPU_NODE gpuNode = MOS_GPU_NODE_3D; |
| 590 |
gpuNode = static_cast<MOS_GPU_NODE>(createOption.gpuNode); |
| 591 |
|
| 592 |
auto gpuContext = gpuContextMgr->CreateGpuContext(gpuNode, cmdBufMgr); |
| 593 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 594 |
|
| 595 |
auto gpuContextSpecific = static_cast<GpuContextSpecificNext *>(gpuContext); |
| 596 |
MOS_OS_CHK_NULL_RETURN(gpuContextSpecific); |
| 597 |
|
| 598 |
MOS_OS_CHK_STATUS_RETURN(gpuContextSpecific->Init(gpuContextMgr->GetOsContext(), streamState, &createOption)); |
| 599 |
|
| 600 |
gpuContextHandle = gpuContextSpecific->GetGpuContextHandle(); |
| 601 |
|
| 602 |
return MOS_STATUS_SUCCESS; |
| 603 |
} |
| 604 |
|
| 605 |
MOS_STATUS MosInterface::GetAdapterBDF(PMOS_CONTEXT mosCtx, ADAPTER_BDF *adapterBDF) |
| 606 |
{ |
| 607 |
MOS_OS_FUNCTION_ENTER; |
| 608 |
|
| 609 |
drmDevicePtr device; |
| 610 |
|
| 611 |
MOS_OS_CHK_NULL_RETURN(mosCtx); |
| 612 |
if (drmGetDevice(mosCtx->fd, &device) == 0) |
| 613 |
{ |
| 614 |
adapterBDF->Bus = device->businfo.pci->bus; |
| 615 |
adapterBDF->Device = device->businfo.pci->dev; |
| 616 |
adapterBDF->Function = device->businfo.pci->func; |
| 617 |
drmFreeDevice(&device); |
| 618 |
} |
| 619 |
else |
| 620 |
{ |
| 621 |
adapterBDF->Data = 0; |
| 622 |
} |
| 623 |
|
| 624 |
return MOS_STATUS_SUCCESS; |
| 625 |
} |
| 626 |
|
| 627 |
MOS_STATUS MosInterface::DestroyGpuContext( |
| 628 |
MOS_STREAM_HANDLE streamState, |
| 629 |
GPU_CONTEXT_HANDLE gpuContext) |
| 630 |
{ |
| 631 |
MOS_OS_FUNCTION_ENTER; |
| 632 |
|
| 633 |
MOS_STATUS eStatus; |
| 634 |
|
| 635 |
eStatus = MOS_STATUS_SUCCESS; |
| 636 |
|
| 637 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 638 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 639 |
MOS_OS_ASSERT(gpuContext != MOS_GPU_CONTEXT_INVALID_HANDLE); |
| 640 |
|
| 641 |
auto gpuContextMgr = streamState->osDeviceContext->GetGpuContextMgr(); |
| 642 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 643 |
auto gpuContextInstance = gpuContextMgr->GetGpuContext(gpuContext); |
| 644 |
MOS_OS_CHK_NULL_RETURN(gpuContextInstance); |
| 645 |
|
| 646 |
gpuContextMgr->DestroyGpuContext(gpuContextInstance); |
| 647 |
|
| 648 |
return MOS_STATUS_SUCCESS; |
| 649 |
} |
| 650 |
|
| 651 |
MOS_STATUS MosInterface::SetGpuContext( |
| 652 |
MOS_STREAM_HANDLE streamState, |
| 653 |
GPU_CONTEXT_HANDLE gpuContext) |
| 654 |
{ |
| 655 |
MOS_OS_FUNCTION_ENTER; |
| 656 |
|
| 657 |
auto gpuContextMgr = streamState->osDeviceContext->GetGpuContextMgr(); |
| 658 |
MOS_OS_CHK_NULL_RETURN(gpuContextMgr); |
| 659 |
auto gpuContextPtr = gpuContextMgr->GetGpuContext(gpuContext); |
| 660 |
MOS_OS_CHK_NULL_RETURN(gpuContextPtr); |
| 661 |
|
| 662 |
streamState->currentGpuContextHandle = gpuContext; |
| 663 |
|
| 664 |
return MOS_STATUS_SUCCESS; |
| 665 |
} |
| 666 |
|
| 667 |
MOS_STATUS MosInterface:: SetObjectCapture( |
| 668 |
PMOS_RESOURCE osResource) |
| 669 |
{ |
| 670 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 671 |
|
| 672 |
//--------------------------------------- |
| 673 |
MOS_OS_CHK_NULL_RETURN(osResource); |
| 674 |
MOS_OS_CHK_NULL_RETURN(osResource->bo); |
| 675 |
//--------------------------------------- |
| 676 |
|
| 677 |
mos_bo_set_object_capture(osResource->bo); |
| 678 |
|
| 679 |
return eStatus; |
| 680 |
} |
| 681 |
|
| 682 |
MOS_STATUS MosInterface::AddCommand( |
| 683 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 684 |
const void *cmd, |
| 685 |
uint32_t cmdSize) |
| 686 |
{ |
| 687 |
MOS_OS_FUNCTION_ENTER; |
| 688 |
|
| 689 |
uint32_t cmdSizeDwAligned = 0; |
| 690 |
|
| 691 |
MOS_OS_CHK_NULL_RETURN(cmdBuffer); |
| 692 |
MOS_OS_CHK_NULL_RETURN(cmd); |
| 693 |
|
| 694 |
if (cmdSize == 0) |
| 695 |
{ |
| 696 |
MOS_OS_ASSERTMESSAGE("Incorrect command size to add to command buffer."); |
| 697 |
return MOS_STATUS_INVALID_PARAMETER; |
| 698 |
} |
| 699 |
|
| 700 |
cmdSizeDwAligned = MOS_ALIGN_CEIL(cmdSize, sizeof(uint32_t)); |
| 701 |
|
| 702 |
cmdBuffer->iOffset += cmdSizeDwAligned; |
| 703 |
cmdBuffer->iRemaining -= cmdSizeDwAligned; |
| 704 |
|
| 705 |
if (cmdBuffer->iRemaining < 0) |
| 706 |
{ |
| 707 |
cmdBuffer->iOffset -= cmdSizeDwAligned; |
| 708 |
cmdBuffer->iRemaining += cmdSizeDwAligned; |
| 709 |
MOS_OS_ASSERTMESSAGE("Unable to add command: remaining space = %d, command size = %d.", |
| 710 |
cmdBuffer->iRemaining, |
| 711 |
cmdSizeDwAligned); |
| 712 |
return MOS_STATUS_UNKNOWN; |
| 713 |
} |
| 714 |
|
| 715 |
MOS_OS_VERBOSEMESSAGE("The command was successfully added: remaining space = %d, buffer size = %d.", |
| 716 |
cmdBuffer->iRemaining, |
| 717 |
cmdBuffer->iOffset + cmdBuffer->iRemaining); |
| 718 |
|
| 719 |
MosUtilities::MosSecureMemcpy(cmdBuffer->pCmdPtr, cmdSize, cmd, cmdSize); |
| 720 |
cmdBuffer->pCmdPtr += (cmdSizeDwAligned / sizeof(uint32_t)); |
| 721 |
|
| 722 |
return MOS_STATUS_SUCCESS; |
| 723 |
} |
| 724 |
|
| 725 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 726 |
MOS_STATUS MosInterface::AddIndirectState( |
| 727 |
MOS_STREAM_HANDLE streamState, |
| 728 |
uint32_t stateSize, |
| 729 |
uint32_t *pIndirectState, |
| 730 |
uint32_t *gfxAddressBottom, |
| 731 |
uint32_t *gfxAddressTop, |
| 732 |
const char *stateName, |
| 733 |
uint32_t gfxAddressBottomValue, |
| 734 |
uint32_t gfxAddressTopValue) |
| 735 |
{ |
| 736 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 737 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 738 |
|
| 739 |
if (streamState->osDeviceContext->m_dumpCommandBuffer && |
| 740 |
streamState->osDeviceContext->m_dumpCommandBufferToFile) |
| 741 |
{ |
| 742 |
INDIRECT_STATE_INFO indirectStateInfo = {}; |
| 743 |
indirectStateInfo.stateSize = stateSize; |
| 744 |
indirectStateInfo.indirectState = pIndirectState; |
| 745 |
indirectStateInfo.gfxAddressBottom = gfxAddressBottom; |
| 746 |
indirectStateInfo.gfxAddressTop = gfxAddressTop; |
| 747 |
indirectStateInfo.stateName = stateName; |
| 748 |
indirectStateInfo.gfxAddressBottomValue = gfxAddressBottomValue; |
| 749 |
indirectStateInfo.gfxAddressTopValue = gfxAddressTopValue; |
| 750 |
streamState->indirectStateInfo.push_back(std::move(indirectStateInfo)); |
| 751 |
} |
| 752 |
|
| 753 |
return MOS_STATUS_SUCCESS; |
| 754 |
} |
| 755 |
|
| 756 |
MOS_STATUS MosInterface::DumpIndirectStates(MOS_STREAM_HANDLE streamState, const char *filePathPrefix, std::time_t currentTime) |
| 757 |
{ |
| 758 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 759 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 760 |
auto &inDirectStateInfoArray = streamState->indirectStateInfo; |
| 761 |
const uint32_t SIZE_OF_ONE_WORD = 9; |
| 762 |
|
| 763 |
for (auto &lastElement : inDirectStateInfoArray) |
| 764 |
{ |
| 765 |
if (lastElement.indirectState == nullptr) |
| 766 |
{ |
| 767 |
MOS_OS_NORMALMESSAGE("IndirectState pointer is nullptr"); |
| 768 |
continue; |
| 769 |
} |
| 770 |
uint32_t *data = (uint32_t *)lastElement.indirectState; |
| 771 |
uint32_t dwordCount = lastElement.stateSize / 4; |
| 772 |
uint32_t dwBytesWritten = 0; |
| 773 |
uint32_t dwSizeToAllocate = 0; |
| 774 |
char *outputBuffer = nullptr; |
| 775 |
std::stringstream fileName; |
| 776 |
|
| 777 |
dwSizeToAllocate = dwordCount * (SIZE_OF_ONE_WORD + 1); // Add 1 byte for the space following each Dword. |
| 778 |
outputBuffer = (char *)MOS_AllocAndZeroMemory(dwSizeToAllocate); // Alloc output buffer. |
| 779 |
if (outputBuffer == nullptr) |
| 780 |
{ |
| 781 |
MOS_OS_NORMALMESSAGE("Alloc outputBuffer failed"); |
| 782 |
inDirectStateInfoArray.clear(); |
| 783 |
return MOS_STATUS_SUCCESS; |
| 784 |
} |
| 785 |
for (uint32_t i = 0; i < dwordCount; ++i) |
| 786 |
{ |
| 787 |
dwBytesWritten += MosUtilities::MosSecureStringPrint( |
| 788 |
outputBuffer + dwBytesWritten, |
| 789 |
SIZE_OF_ONE_WORD + 1, |
| 790 |
SIZE_OF_ONE_WORD + 1, |
| 791 |
"%.8x ", |
| 792 |
data[i]); |
| 793 |
} |
| 794 |
fileName << filePathPrefix << "_" << std::hex << (lastElement.gfxAddressBottom ? *lastElement.gfxAddressBottom : 0) |
| 795 |
<< "_" |
| 796 |
<< (lastElement.gfxAddressTop ? *lastElement.gfxAddressTop : 0) |
| 797 |
<< "_" << lastElement.stateName << ".txt"; |
| 798 |
eStatus = MosUtilities::MosAppendFileFromPtr((const char *)fileName.str().c_str(), outputBuffer, dwBytesWritten); |
| 799 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 800 |
{ |
| 801 |
MOS_OS_NORMALMESSAGE("DumpIndirectStates %s failed", fileName.str().c_str()); |
| 802 |
} |
| 803 |
MOS_FreeMemory(outputBuffer); |
| 804 |
} |
| 805 |
inDirectStateInfoArray.clear(); |
| 806 |
return eStatus; |
| 807 |
} |
| 808 |
|
| 809 |
MOS_STATUS MosInterface::DumpBindingTable( |
| 810 |
MOS_STREAM_HANDLE streamState, |
| 811 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 812 |
MOS_GPU_NODE gpuNode, |
| 813 |
const char *filePathPrefix) |
| 814 |
{ |
| 815 |
MOS_OS_CHK_NULL_RETURN(filePathPrefix); |
| 816 |
|
| 817 |
if (MOS_GPU_NODE_COMPUTE == gpuNode || MOS_GPU_NODE_3D == gpuNode) |
| 818 |
{ |
| 819 |
uint8_t *indirectState = nullptr; |
| 820 |
uint32_t offset = 0; |
| 821 |
uint32_t size = 0; |
| 822 |
MosInterface::GetIndirectState(streamState, &indirectState, offset, size); |
| 823 |
|
| 824 |
if (indirectState) |
| 825 |
{ |
| 826 |
std::stringstream ss; |
| 827 |
uint32_t dwordCount = size / 4; |
| 828 |
uint32_t *data = (uint32_t *)indirectState; |
| 829 |
|
| 830 |
for (uint32_t i = 0; i < dwordCount; ++i) |
| 831 |
{ |
| 832 |
if (0 == i % 4) |
| 833 |
{ |
| 834 |
if (0 != i) |
| 835 |
{ |
| 836 |
ss << std::endl; |
| 837 |
} |
| 838 |
ss << "#0 #0"; |
| 839 |
} |
| 840 |
ss << " " << std::hex << std::setw(8) << std::setfill('0') << data[i]; |
| 841 |
} |
| 842 |
|
| 843 |
std::stringstream fileName; |
| 844 |
fileName << filePathPrefix << "_binding_table.txt"; |
| 845 |
std::fstream fs; |
| 846 |
fs.open(fileName.str(), std::ios_base::out | std::ios_base::app); |
| 847 |
fs << ss.str(); |
| 848 |
fs.close(); |
| 849 |
} |
| 850 |
else |
| 851 |
{ |
| 852 |
MOS_OS_NORMALMESSAGE("nullptr == indirectState"); |
| 853 |
} |
| 854 |
} |
| 855 |
|
| 856 |
return MOS_STATUS_SUCCESS; |
| 857 |
} |
| 858 |
|
| 859 |
MOS_STATUS MosInterface::DumpCommandBuffer( |
| 860 |
MOS_STREAM_HANDLE streamState, |
| 861 |
COMMAND_BUFFER_HANDLE cmdBuffer) |
| 862 |
{ |
| 863 |
MOS_OS_FUNCTION_ENTER; |
| 864 |
|
| 865 |
static uint32_t dwCommandBufferNumber = 0; |
| 866 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 867 |
char * pOutputBuffer = nullptr; |
| 868 |
// Each hex value should have 9 chars. |
| 869 |
uint32_t SIZE_OF_ONE_WORD = 9; |
| 870 |
uint32_t dwBytesWritten = 0; |
| 871 |
uint32_t dwNumberOfDwords = 0; |
| 872 |
uint32_t dwSizeToAllocate = 0; |
| 873 |
char sFileName[MOS_MAX_HLT_FILENAME_LEN] = {0}; |
| 874 |
// Maximum length of engine name is 6 |
| 875 |
char sEngName[6]; |
| 876 |
size_t nSizeFileNamePrefix = 0; |
| 877 |
std::time_t currentTime = std::time(nullptr); |
| 878 |
|
| 879 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 880 |
MOS_OS_CHK_NULL_RETURN(cmdBuffer); |
| 881 |
|
| 882 |
// Set the name of the engine that is going to be used. |
| 883 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 884 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 885 |
MOS_GPU_NODE gpuNode = gpuContext->GetContextNode(); |
| 886 |
switch (gpuNode) |
| 887 |
{ |
| 888 |
case MOS_GPU_NODE_VIDEO: |
| 889 |
case MOS_GPU_NODE_VIDEO2: |
| 890 |
MosUtilities::MosSecureStrcpy(sEngName, sizeof(sEngName), MOS_COMMAND_BUFFER_VIDEO_ENGINE); |
| 891 |
break; |
| 892 |
case MOS_GPU_NODE_COMPUTE: |
| 893 |
case MOS_GPU_NODE_BLT: |
| 894 |
MosUtilities::MosSecureStrcpy(sEngName, sizeof(sEngName), MOS_COMMAND_BUFFER_RENDER_ENGINE); |
| 895 |
break; |
| 896 |
case MOS_GPU_NODE_VE: |
| 897 |
MosUtilities::MosSecureStrcpy(sEngName, sizeof(sEngName), MOS_COMMAND_BUFFER_VEBOX_ENGINE); |
| 898 |
break; |
| 899 |
case MOS_GPU_NODE_3D: |
| 900 |
MosUtilities::MosSecureStrcpy(sEngName, sizeof(sEngName), MOS_COMMAND_BUFFER_RENDER_ENGINE); |
| 901 |
break; |
| 902 |
default: |
| 903 |
MOS_OS_ASSERTMESSAGE("Unsupported GPU context."); |
| 904 |
return eStatus; |
| 905 |
} |
| 906 |
|
| 907 |
dwNumberOfDwords = cmdBuffer->iOffset / sizeof(uint32_t); |
| 908 |
|
| 909 |
dwSizeToAllocate = |
| 910 |
dwNumberOfDwords * (SIZE_OF_ONE_WORD + 1) // Add 1 byte for the space following each Dword. |
| 911 |
+ 3 * SIZE_OF_ONE_WORD; // For engine and platform names. |
| 912 |
|
| 913 |
// Alloc output buffer. |
| 914 |
pOutputBuffer = (char *)MOS_AllocAndZeroMemory(dwSizeToAllocate); |
| 915 |
MOS_OS_CHK_NULL_RETURN(pOutputBuffer); |
| 916 |
|
| 917 |
dwBytesWritten = MosUtilities::MosSecureStringPrint( |
| 918 |
pOutputBuffer, |
| 919 |
SIZE_OF_ONE_WORD * 3, |
| 920 |
SIZE_OF_ONE_WORD * 3, |
| 921 |
"Eng=%s ", |
| 922 |
sEngName); |
| 923 |
|
| 924 |
if (streamState->dumpCommandBufferToFile) |
| 925 |
{ |
| 926 |
MosUtilities::MosSecureMemcpy(sFileName, MOS_MAX_HLT_FILENAME_LEN, streamState->sDirName, MOS_MAX_HLT_FILENAME_LEN); |
| 927 |
|
| 928 |
nSizeFileNamePrefix = strnlen(sFileName, sizeof(sFileName)); |
| 929 |
MosUtilities::MosSecureStringPrint( |
| 930 |
sFileName + nSizeFileNamePrefix, |
| 931 |
sizeof(sFileName) - nSizeFileNamePrefix, |
| 932 |
sizeof(sFileName) - nSizeFileNamePrefix, |
| 933 |
"%c%s%c%s_%d_%d.txt", |
| 934 |
MOS_DIR_SEPERATOR, |
| 935 |
MOS_COMMAND_BUFFER_OUT_DIR, |
| 936 |
MOS_DIR_SEPERATOR, |
| 937 |
MOS_COMMAND_BUFFER_OUT_FILE, |
| 938 |
dwCommandBufferNumber, |
| 939 |
currentTime); |
| 940 |
|
| 941 |
// Write the output buffer to file. |
| 942 |
if((eStatus = MosUtilities::MosWriteFileFromPtr((const char *)sFileName, pOutputBuffer, dwBytesWritten)) != MOS_STATUS_SUCCESS) |
| 943 |
{ |
| 944 |
MOS_FreeMemory(pOutputBuffer); |
| 945 |
MOS_OS_CHK_STATUS_RETURN(eStatus); |
| 946 |
} |
| 947 |
} |
| 948 |
|
| 949 |
if (streamState->dumpCommandBufferAsMessages) |
| 950 |
{ |
| 951 |
MOS_OS_NORMALMESSAGE(pOutputBuffer); |
| 952 |
} |
| 953 |
|
| 954 |
MosUtilities::MosZeroMemory(pOutputBuffer, dwBytesWritten); |
| 955 |
dwBytesWritten = 0; |
| 956 |
|
| 957 |
// Fill in the output buffer with the command buffer dwords. |
| 958 |
for (uint32_t dwIndex = 0; dwIndex < dwNumberOfDwords; dwIndex++) |
| 959 |
{ |
| 960 |
dwBytesWritten += MosUtilities::MosSecureStringPrint( |
| 961 |
pOutputBuffer + dwBytesWritten, |
| 962 |
SIZE_OF_ONE_WORD + 1, |
| 963 |
SIZE_OF_ONE_WORD + 1, |
| 964 |
"%.8x ", |
| 965 |
cmdBuffer->pCmdBase[dwIndex]); |
| 966 |
|
| 967 |
if (dwBytesWritten % (SIZE_OF_ONE_WORD + 1) == 0) |
| 968 |
{ |
| 969 |
if (streamState->dumpCommandBufferToFile) |
| 970 |
{ |
| 971 |
if((eStatus = MosUtilities::MosAppendFileFromPtr((const char *)sFileName, pOutputBuffer, dwBytesWritten)) != MOS_STATUS_SUCCESS) |
| 972 |
{ |
| 973 |
MOS_FreeMemory(pOutputBuffer); |
| 974 |
MOS_OS_CHK_STATUS_RETURN(eStatus); |
| 975 |
} |
| 976 |
} |
| 977 |
if (streamState->dumpCommandBufferAsMessages) |
| 978 |
{ |
| 979 |
MOS_OS_NORMALMESSAGE(pOutputBuffer); |
| 980 |
} |
| 981 |
|
| 982 |
MosUtilities::MosZeroMemory(pOutputBuffer, dwBytesWritten); |
| 983 |
dwBytesWritten = 0; |
| 984 |
} |
| 985 |
} |
| 986 |
|
| 987 |
if (streamState->dumpCommandBufferToFile) |
| 988 |
{ |
| 989 |
if((eStatus = MosUtilities::MosAppendFileFromPtr((const char *)sFileName, pOutputBuffer, dwBytesWritten)) != MOS_STATUS_SUCCESS) |
| 990 |
{ |
| 991 |
MOS_FreeMemory(pOutputBuffer); |
| 992 |
MOS_OS_CHK_STATUS_RETURN(eStatus); |
| 993 |
} |
| 994 |
if ((eStatus = DumpBindingTable(streamState, cmdBuffer, gpuNode, sFileName)) != MOS_STATUS_SUCCESS) |
| 995 |
{ |
| 996 |
MOS_FreeMemory(pOutputBuffer); |
| 997 |
return eStatus; |
| 998 |
} |
| 999 |
if ((eStatus = DumpIndirectStates(streamState, sFileName, currentTime)) != MOS_STATUS_SUCCESS) |
| 1000 |
{ |
| 1001 |
MOS_FreeMemory(pOutputBuffer); |
| 1002 |
return eStatus; |
| 1003 |
} |
| 1004 |
} |
| 1005 |
|
| 1006 |
if (streamState->dumpCommandBufferAsMessages) |
| 1007 |
{ |
| 1008 |
MOS_OS_NORMALMESSAGE(pOutputBuffer); |
| 1009 |
} |
| 1010 |
|
| 1011 |
dwCommandBufferNumber++; |
| 1012 |
MOS_FreeMemory(pOutputBuffer); |
| 1013 |
eStatus = MOS_STATUS_SUCCESS; |
| 1014 |
|
| 1015 |
return eStatus; |
| 1016 |
|
| 1017 |
} |
| 1018 |
#endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 1019 |
|
| 1020 |
MOS_STATUS MosInterface::GetCommandBuffer( |
| 1021 |
MOS_STREAM_HANDLE streamState, |
| 1022 |
COMMAND_BUFFER_HANDLE &cmdBuffer, |
| 1023 |
uint32_t pipeIdx) |
| 1024 |
{ |
| 1025 |
MOS_OS_FUNCTION_ENTER; |
| 1026 |
|
| 1027 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1028 |
|
| 1029 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1030 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1031 |
|
| 1032 |
return (gpuContext->GetCommandBuffer(cmdBuffer, pipeIdx)); |
| 1033 |
} |
| 1034 |
|
| 1035 |
MOS_STATUS MosInterface::ReturnCommandBuffer( |
| 1036 |
MOS_STREAM_HANDLE streamState, |
| 1037 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 1038 |
uint32_t pipeIdx) |
| 1039 |
{ |
| 1040 |
MOS_OS_FUNCTION_ENTER; |
| 1041 |
|
| 1042 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1043 |
|
| 1044 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1045 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1046 |
|
| 1047 |
(gpuContext->ReturnCommandBuffer(cmdBuffer, pipeIdx)); |
| 1048 |
|
| 1049 |
return MOS_STATUS_SUCCESS; |
| 1050 |
} |
| 1051 |
|
| 1052 |
MOS_STATUS MosInterface::SubmitCommandBuffer( |
| 1053 |
MOS_STREAM_HANDLE streamState, |
| 1054 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 1055 |
bool nullRendering) |
| 1056 |
{ |
| 1057 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1058 |
|
| 1059 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1060 |
|
| 1061 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1062 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1063 |
|
| 1064 |
gpuContext->UpdatePriority(streamState->ctxPriority); |
| 1065 |
|
| 1066 |
return (gpuContext->SubmitCommandBuffer(streamState, cmdBuffer, nullRendering)); |
| 1067 |
} |
| 1068 |
|
| 1069 |
MOS_STATUS MosInterface::ResetCommandBuffer( |
| 1070 |
MOS_STREAM_HANDLE streamState, |
| 1071 |
COMMAND_BUFFER_HANDLE cmdBuffer) |
| 1072 |
{ |
| 1073 |
MOS_OS_FUNCTION_ENTER; |
| 1074 |
|
| 1075 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1076 |
|
| 1077 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1078 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1079 |
|
| 1080 |
// Reset the explicitly provided cmd buffer, or reset GPU context states |
| 1081 |
if (cmdBuffer) |
| 1082 |
{ |
| 1083 |
MOS_OS_CHK_STATUS_RETURN(gpuContext->ResetCommandBuffer()); |
| 1084 |
} |
| 1085 |
else |
| 1086 |
{ |
| 1087 |
gpuContext->ResetGpuContextStatus(); |
| 1088 |
} |
| 1089 |
|
| 1090 |
return MOS_STATUS_SUCCESS; |
| 1091 |
} |
| 1092 |
|
| 1093 |
MOS_STATUS MosInterface::VerifyCommandBufferSize( |
| 1094 |
MOS_STREAM_HANDLE streamState, |
| 1095 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 1096 |
uint32_t requestedSize, |
| 1097 |
uint32_t pipeIdx) |
| 1098 |
{ |
| 1099 |
MOS_OS_FUNCTION_ENTER; |
| 1100 |
|
| 1101 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1102 |
|
| 1103 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1104 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1105 |
|
| 1106 |
return (gpuContext->VerifyCommandBufferSize(requestedSize)); |
| 1107 |
} |
| 1108 |
|
| 1109 |
MOS_STATUS MosInterface::ResizeCommandBufferAndPatchList( |
| 1110 |
MOS_STREAM_HANDLE streamState, |
| 1111 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 1112 |
uint32_t requestedSize, |
| 1113 |
uint32_t requestedPatchListSize, |
| 1114 |
uint32_t pipeIdx) |
| 1115 |
{ |
| 1116 |
MOS_OS_FUNCTION_ENTER; |
| 1117 |
|
| 1118 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1119 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1120 |
|
| 1121 |
return (gpuContext->ResizeCommandBufferAndPatchList(requestedSize, requestedPatchListSize, pipeIdx)); |
| 1122 |
} |
| 1123 |
|
| 1124 |
MOS_STATUS MosInterface::SetPatchEntry( |
| 1125 |
MOS_STREAM_HANDLE streamState, |
| 1126 |
PMOS_PATCH_ENTRY_PARAMS params) |
| 1127 |
{ |
| 1128 |
MOS_OS_FUNCTION_ENTER; |
| 1129 |
|
| 1130 |
MOS_OS_CHK_NULL_RETURN(params); |
| 1131 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1132 |
|
| 1133 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1134 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1135 |
|
| 1136 |
MOS_OS_CHK_STATUS_RETURN(gpuContext->SetPatchEntry(streamState, params)); |
| 1137 |
|
| 1138 |
return MOS_STATUS_SUCCESS; |
| 1139 |
} |
| 1140 |
|
| 1141 |
MOS_STATUS MosInterface::GetIndirectState( |
| 1142 |
MOS_STREAM_HANDLE streamState, |
| 1143 |
uint8_t **indirectState, |
| 1144 |
uint32_t &offset, |
| 1145 |
uint32_t &size) |
| 1146 |
{ |
| 1147 |
MOS_OS_FUNCTION_ENTER; |
| 1148 |
|
| 1149 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1150 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1151 |
|
| 1152 |
MOS_OS_CHK_STATUS_RETURN(gpuContext->GetIndirectState(offset, size)); |
| 1153 |
if (indirectState) |
| 1154 |
{ |
| 1155 |
MOS_OS_CHK_STATUS_RETURN(gpuContext->GetIndirectStatePointer(indirectState)); |
| 1156 |
} |
| 1157 |
|
| 1158 |
return MOS_STATUS_SUCCESS; |
| 1159 |
} |
| 1160 |
|
| 1161 |
MOS_STATUS MosInterface::SetupIndirectState( |
| 1162 |
MOS_STREAM_HANDLE streamState, |
| 1163 |
uint32_t size) |
| 1164 |
{ |
| 1165 |
MOS_OS_FUNCTION_ENTER; |
| 1166 |
|
| 1167 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 1168 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 1169 |
|
| 1170 |
MOS_OS_CHK_STATUS_RETURN(gpuContext->SetIndirectStateSize(size)); |
| 1171 |
|
| 1172 |
return MOS_STATUS_SUCCESS; |
| 1173 |
} |
| 1174 |
|
| 1175 |
MOS_STATUS MosInterface::SetupAttributeVeBuffer( |
| 1176 |
MOS_STREAM_HANDLE streamState, |
| 1177 |
COMMAND_BUFFER_HANDLE cmdBuffer) |
| 1178 |
{ |
| 1179 |
MOS_OS_FUNCTION_ENTER; |
| 1180 |
|
| 1181 |
// no VE attribute buffer to setup |
| 1182 |
|
| 1183 |
return MOS_STATUS_SUCCESS; |
| 1184 |
} |
| 1185 |
|
| 1186 |
MOS_CMD_BUF_ATTRI_VE *MosInterface::GetAttributeVeBuffer( |
| 1187 |
COMMAND_BUFFER_HANDLE cmdBuffer) |
| 1188 |
{ |
| 1189 |
MOS_OS_FUNCTION_ENTER; |
| 1190 |
|
| 1191 |
// no VE attribute buffer to get |
| 1192 |
return nullptr; |
| 1193 |
} |
| 1194 |
|
| 1195 |
static constexpr GMM_RESOURCE_USAGE_TYPE GmmResourceUsage[MOS_HW_RESOURCE_DEF_MAX] = |
| 1196 |
{ |
| 1197 |
// |
| 1198 |
// CODEC USAGES |
| 1199 |
// |
| 1200 |
GMM_RESOURCE_USAGE_BEGIN_CODEC, |
| 1201 |
GMM_RESOURCE_USAGE_PRE_DEBLOCKING_CODEC, |
| 1202 |
GMM_RESOURCE_USAGE_PRE_DEBLOCKING_CODEC_PARTIALENCSURFACE, |
| 1203 |
GMM_RESOURCE_USAGE_POST_DEBLOCKING_CODEC, |
| 1204 |
GMM_RESOURCE_USAGE_ORIGINAL_UNCOMPRESSED_PICTURE_ENCODE, |
| 1205 |
GMM_RESOURCE_USAGE_ORIGINAL_UNCOMPRESSED_PICTURE_DECODE, |
| 1206 |
GMM_RESOURCE_USAGE_STREAMOUT_DATA_CODEC, |
| 1207 |
GMM_RESOURCE_USAGE_INTRA_ROWSTORE_SCRATCH_BUFFER_CODEC, |
| 1208 |
GMM_RESOURCE_USAGE_DEBLOCKINGFILTER_ROWSTORE_SCRATCH_BUFFER_CODEC, |
| 1209 |
GMM_RESOURCE_USAGE_REFERENCE_PICTURE_CODEC, |
| 1210 |
GMM_RESOURCE_USAGE_MACROBLOCK_STATUS_BUFFER_CODEC, |
| 1211 |
GMM_RESOURCE_USAGE_MFX_INDIRECT_BITSTREAM_OBJECT_DECODE, |
| 1212 |
GMM_RESOURCE_USAGE_MFX_INDIRECT_MV_OBJECT_CODEC, |
| 1213 |
GMM_RESOURCE_USAGE_MFD_INDIRECT_IT_COEF_OBJECT_DECODE, |
| 1214 |
GMM_RESOURCE_USAGE_MFC_INDIRECT_PAKBASE_OBJECT_CODEC, |
| 1215 |
GMM_RESOURCE_USAGE_BSDMPC_ROWSTORE_SCRATCH_BUFFER_CODEC, |
| 1216 |
GMM_RESOURCE_USAGE_MPR_ROWSTORE_SCRATCH_BUFFER_CODEC, |
| 1217 |
GMM_RESOURCE_USAGE_BITPLANE_READ_CODEC, |
| 1218 |
GMM_RESOURCE_USAGE_DIRECTMV_BUFFER_CODEC, |
| 1219 |
GMM_RESOURCE_USAGE_SURFACE_CURR_ENCODE, |
| 1220 |
GMM_RESOURCE_USAGE_SURFACE_REF_ENCODE, |
| 1221 |
GMM_RESOURCE_USAGE_SURFACE_MV_DATA_ENCODE, |
| 1222 |
GMM_RESOURCE_USAGE_SURFACE_HME_DOWNSAMPLED_ENCODE, |
| 1223 |
GMM_RESOURCE_USAGE_SURFACE_HME_DOWNSAMPLED_ENCODE_FF, |
| 1224 |
GMM_RESOURCE_USAGE_SURFACE_HME_DOWNSAMPLED_ENCODE_DST, |
| 1225 |
GMM_RESOURCE_USAGE_SURFACE_ME_DISTORTION_ENCODE, |
| 1226 |
GMM_RESOURCE_USAGE_SURFACE_BRC_ME_DISTORTION_ENCODE, |
| 1227 |
GMM_RESOURCE_USAGE_PAK_OBJECT_ENCODE, |
| 1228 |
GMM_RESOURCE_USAGE_SURFACE_FLATNESS_CHECK_ENCODE, |
| 1229 |
GMM_RESOURCE_USAGE_SURFACE_MBENC_CURBE_ENCODE, |
| 1230 |
GMM_RESOURCE_USAGE_SURFACE_MAD_ENCODE, |
| 1231 |
GMM_RESOURCE_USAGE_VP8_BLOCK_MODE_COST_ENCODE, |
| 1232 |
GMM_RESOURCE_USAGE_VP8_MB_MODE_COST_ENCODE, |
| 1233 |
GMM_RESOURCE_USAGE_VP8_MBENC_OUTPUT_ENCODE, |
| 1234 |
GMM_RESOURCE_USAGE_VP8_HISTOGRAM_ENCODE, |
| 1235 |
GMM_RESOURCE_USAGE_VP8_L3_LLC_ENCODE, |
| 1236 |
GMM_RESOURCE_USAGE_MFX_STANDALONE_DEBLOCKING_CODEC, |
| 1237 |
GMM_RESOURCE_USAGE_HCP_MD_CODEC, |
| 1238 |
GMM_RESOURCE_USAGE_HCP_SAO_CODEC, |
| 1239 |
GMM_RESOURCE_USAGE_HCP_MV_CODEC, |
| 1240 |
GMM_RESOURCE_USAGE_HCP_STATUS_ERROR_CODEC, |
| 1241 |
GMM_RESOURCE_USAGE_HCP_LCU_ILDB_STREAMOUT_CODEC, |
| 1242 |
GMM_RESOURCE_USAGE_VP9_PROBABILITY_BUFFER_CODEC, |
| 1243 |
GMM_RESOURCE_USAGE_VP9_SEGMENT_ID_BUFFER_CODEC, |
| 1244 |
GMM_RESOURCE_USAGE_VP9_HVD_ROWSTORE_BUFFER_CODEC, |
| 1245 |
GMM_RESOURCE_USAGE_MBDISABLE_SKIPMAP_CODEC, |
| 1246 |
GMM_RESOURCE_USAGE_VDENC_ROW_STORE_BUFFER_CODEC, |
| 1247 |
GMM_RESOURCE_USAGE_VDENC_STREAMIN_CODEC, |
| 1248 |
GMM_RESOURCE_USAGE_SURFACE_MB_QP_CODEC, |
| 1249 |
GMM_RESOURCE_USAGE_MACROBLOCK_ILDB_STREAM_OUT_BUFFER_CODEC, |
| 1250 |
GMM_RESOURCE_USAGE_SSE_SRC_PIXEL_ROW_STORE_BUFFER_CODEC, |
| 1251 |
GMM_RESOURCE_USAGE_SLICE_STATE_STREAM_OUT_BUFFER_CODEC, |
| 1252 |
GMM_RESOURCE_USAGE_CABAC_SYNTAX_STREAM_OUT_BUFFER_CODEC, |
| 1253 |
GMM_RESOURCE_USAGE_PRED_COL_STORE_BUFFER_CODEC, |
| 1254 |
GMM_RESOURCE_USAGE_SURFACE_PAK_IMAGESTATE_ENCODE, |
| 1255 |
GMM_RESOURCE_USAGE_SURFACE_MBENC_BRC_ENCODE, |
| 1256 |
GMM_RESOURCE_USAGE_SURFACE_MB_BRC_CONST_ENCODE, |
| 1257 |
GMM_RESOURCE_USAGE_SURFACE_BRC_MB_QP_ENCODE, |
| 1258 |
GMM_RESOURCE_USAGE_SURFACE_BRC_ROI_ENCODE, |
| 1259 |
GMM_RESOURCE_USAGE_SURFACE_SLICE_MAP_ENCODE, |
| 1260 |
GMM_RESOURCE_USAGE_SURFACE_WP_DOWNSAMPLED_ENCODE, |
| 1261 |
GMM_RESOURCE_USAGE_SURFACE_VDENC_IMAGESTATE_ENCODE, |
| 1262 |
GMM_RESOURCE_USAGE_SURFACE_UNCACHED, |
| 1263 |
GMM_RESOURCE_USAGE_SURFACE_ELLC_ONLY, |
| 1264 |
GMM_RESOURCE_USAGE_SURFACE_ELLC_LLC_ONLY, |
| 1265 |
GMM_RESOURCE_USAGE_SURFACE_ELLC_LLC_L3, |
| 1266 |
GMM_RESOURCE_USAGE_SURFACE_BRC_HISTORY_ENCODE, |
| 1267 |
GMM_RESOURCE_USAGE_SURFACE_SOFTWARE_SCOREBOARD_ENCODE, |
| 1268 |
GMM_RESOURCE_USAGE_SURFACE_ME_MV_DATA_ENCODE, |
| 1269 |
GMM_RESOURCE_USAGE_SURFACE_MV_DISTORTION_ENCODE, |
| 1270 |
GMM_RESOURCE_USAGE_SURFACE_4XME_DISTORTION_ENCODE, |
| 1271 |
GMM_RESOURCE_USAGE_SURFACE_INTRA_DISTORTION_ENCODE, |
| 1272 |
GMM_RESOURCE_USAGE_MB_STATS_ENCODE, |
| 1273 |
GMM_RESOURCE_USAGE_SURFACE_PAK_STATS_ENCODE, |
| 1274 |
GMM_RESOURCE_USAGE_SURFACE_PIC_STATE_READ_ENCODE, |
| 1275 |
GMM_RESOURCE_USAGE_SURFACE_PIC_STATE_WRITE_ENCODE, |
| 1276 |
GMM_RESOURCE_USAGE_SURFACE_COMBINED_ENC_ENCODE, |
| 1277 |
GMM_RESOURCE_USAGE_SURFACE_BRC_CONSTANT_DATA_ENCODE, |
| 1278 |
GMM_RESOURCE_USAGE_SURFACE_INTERMEDIATE_CU_RECORD_SURFACE_ENCODE, |
| 1279 |
GMM_RESOURCE_USAGE_SURFACE_SCRATCH_ENCODE, |
| 1280 |
GMM_RESOURCE_USAGE_SURFACE_LCU_LEVEL_DATA_ENCODE, |
| 1281 |
GMM_RESOURCE_USAGE_SURFACE_ENC_HISTORY_INPUT_ENCODE, |
| 1282 |
GMM_RESOURCE_USAGE_SURFACE_ENC_HISTORY_OUTPUT_ENCODE, |
| 1283 |
GMM_RESOURCE_USAGE_SURFACE_DEBUG_ENCODE, |
| 1284 |
GMM_RESOURCE_USAGE_SURFACE_ENC_CONSTANT_TABLE_ENCODE, |
| 1285 |
GMM_RESOURCE_USAGE_SURFACE_ENC_CU_RECORD_ENCODE, |
| 1286 |
GMM_RESOURCE_USAGE_SURFACE_ENC_MV_TEMPORAL_BUFFER_ENCODE, |
| 1287 |
GMM_RESOURCE_USAGE_SURFACE_ENC_CU_PACKET_FOR_PAK_ENCODE, |
| 1288 |
GMM_RESOURCE_USAGE_SURFACE_ENC_BCOMBINED1_ENCODE, |
| 1289 |
GMM_RESOURCE_USAGE_SURFACE_ENC_BCOMBINED2_ENCODE, |
| 1290 |
GMM_RESOURCE_USAGE_FRAME_STATS_STREAMOUT_DATA_CODEC, |
| 1291 |
GMM_RESOURCE_USAGE_DEBLOCKINGFILTER_ROWSTORE_TILE_LINE_BUFFER_CODEC, |
| 1292 |
GMM_RESOURCE_USAGE_DEBLOCKINGFILTER_ROWSTORE_TILE_COLUMN_BUFFER_CODEC, |
| 1293 |
GMM_RESOURCE_USAGE_HCP_MD_TILE_LINE_CODEC, |
| 1294 |
GMM_RESOURCE_USAGE_HCP_MD_TILE_COLUMN_CODEC, |
| 1295 |
GMM_RESOURCE_USAGE_HCP_SAO_TILE_LINE_CODEC, |
| 1296 |
GMM_RESOURCE_USAGE_HCP_SAO_TILE_COLUMN_CODEC, |
| 1297 |
GMM_RESOURCE_USAGE_VP9_PROBABILITY_COUNTER_BUFFER_CODEC, |
| 1298 |
GMM_RESOURCE_USAGE_HUC_VIRTUAL_ADDR_REGION_BUFFER_CODEC, |
| 1299 |
GMM_RESOURCE_USAGE_SIZE_STREAMOUT_CODEC, |
| 1300 |
GMM_RESOURCE_USAGE_COMPRESSED_HEADER_BUFFER_CODEC, |
| 1301 |
GMM_RESOURCE_USAGE_PROBABILITY_DELTA_BUFFER_CODEC, |
| 1302 |
GMM_RESOURCE_USAGE_TILE_RECORD_BUFFER_CODEC, |
| 1303 |
GMM_RESOURCE_USAGE_TILE_SIZE_STAS_BUFFER_CODEC, |
| 1304 |
GMM_RESOURCE_USAGE_END_CODEC, |
| 1305 |
|
| 1306 |
// |
| 1307 |
// CM USAGES |
| 1308 |
// |
| 1309 |
CM_RESOURCE_USAGE_SurfaceState, |
| 1310 |
CM_RESOURCE_USAGE_StateHeap, |
| 1311 |
CM_RESOURCE_USAGE_NO_L3_SurfaceState, |
| 1312 |
CM_RESOURCE_USAGE_NO_LLC_ELLC_SurfaceState, |
| 1313 |
CM_RESOURCE_USAGE_NO_LLC_SurfaceState, |
| 1314 |
CM_RESOURCE_USAGE_NO_ELLC_SurfaceState, |
| 1315 |
CM_RESOURCE_USAGE_NO_LLC_L3_SurfaceState, |
| 1316 |
CM_RESOURCE_USAGE_NO_ELLC_L3_SurfaceState, |
| 1317 |
CM_RESOURCE_USAGE_NO_CACHE_SurfaceState, |
| 1318 |
CM_RESOURCE_USAGE_L1_Enabled_SurfaceState, |
| 1319 |
|
| 1320 |
// |
| 1321 |
// MP USAGES |
| 1322 |
// |
| 1323 |
MP_RESOURCE_USAGE_BEGIN, |
| 1324 |
MP_RESOURCE_USAGE_DEFAULT, |
| 1325 |
MP_RESOURCE_USAGE_DEFAULT_FF, |
| 1326 |
MP_RESOURCE_USAGE_DEFAULT_RCS, |
| 1327 |
MP_RESOURCE_USAGE_SurfaceState, |
| 1328 |
MP_RESOURCE_USAGE_SurfaceState_FF, |
| 1329 |
MP_RESOURCE_USAGE_SurfaceState_RCS, |
| 1330 |
MP_RESOURCE_USAGE_AGE3_SurfaceState, |
| 1331 |
MP_RESOURCE_USAGE_EDRAM_SurfaceState, |
| 1332 |
MP_RESOURCE_USAGE_EDRAM_AGE3_SurfaceState, |
| 1333 |
MP_RESOURCE_USAGE_No_L3_SurfaceState, |
| 1334 |
MP_RESOURCE_USAGE_No_LLC_L3_SurfaceState, |
| 1335 |
MP_RESOURCE_USAGE_No_LLC_L3_AGE_SurfaceState, |
| 1336 |
MP_RESOURCE_USAGE_No_LLC_eLLC_L3_AGE_SurfaceState, |
| 1337 |
MP_RESOURCE_USAGE_PartialEnc_No_LLC_L3_AGE_SurfaceState, |
| 1338 |
MP_RESOURCE_USAGE_END, |
| 1339 |
|
| 1340 |
// MHW - SFC |
| 1341 |
MHW_RESOURCE_USAGE_Sfc_CurrentOutputSurface, //!< SFC output surface |
| 1342 |
MHW_RESOURCE_USAGE_Sfc_CurrentOutputSurface_PartialEncSurface, //!< SFC output surface for partial secure surfaces |
| 1343 |
MHW_RESOURCE_USAGE_Sfc_AvsLineBufferSurface, //!< SFC AVS Line buffer Surface |
| 1344 |
MHW_RESOURCE_USAGE_Sfc_IefLineBufferSurface, //!< SFC IEF Line buffer Surface |
| 1345 |
|
| 1346 |
// Camera caputure. |
| 1347 |
GMM_RESOURCE_USAGE_CAMERA_CAPTURE, |
| 1348 |
// Media GMM Resource USAGES |
| 1349 |
GMM_RESOURCE_USAGE_CCS_MEDIA_WRITABLE, |
| 1350 |
|
| 1351 |
// Media BLT copy USAGES |
| 1352 |
GMM_RESOURCE_USAGE_BLT_SOURCE, |
| 1353 |
GMM_RESOURCE_USAGE_BLT_DESTINATION, |
| 1354 |
|
| 1355 |
// PAT Media Usages |
| 1356 |
GMM_RESOURCE_USAGE_MEDIA_BATCH_BUFFERS, |
| 1357 |
// DECODE |
| 1358 |
GMM_RESOURCE_USAGE_DECODE_INPUT_BITSTREAM, |
| 1359 |
GMM_RESOURCE_USAGE_DECODE_INPUT_REFERENCE, |
| 1360 |
GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ, |
| 1361 |
GMM_RESOURCE_USAGE_DECODE_INTERNAL_WRITE, |
| 1362 |
GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_CACHE, |
| 1363 |
GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE, |
| 1364 |
GMM_RESOURCE_USAGE_DECODE_OUTPUT_PICTURE, |
| 1365 |
GMM_RESOURCE_USAGE_DECODE_OUTPUT_STATISTICS_WRITE, |
| 1366 |
GMM_RESOURCE_USAGE_DECODE_OUTPUT_STATISTICS_READ_WRITE, |
| 1367 |
// ENCODE |
| 1368 |
GMM_RESOURCE_USAGE_ENCODE_INPUT_RAW, |
| 1369 |
GMM_RESOURCE_USAGE_ENCODE_INPUT_RECON, |
| 1370 |
GMM_RESOURCE_USAGE_ENCODE_INTERNAL_READ, |
| 1371 |
GMM_RESOURCE_USAGE_ENCODE_INTERNAL_WRITE, |
| 1372 |
GMM_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_CACHE, |
| 1373 |
GMM_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_NOCACHE, |
| 1374 |
GMM_RESOURCE_USAGE_ENCODE_EXTERNAL_READ, |
| 1375 |
GMM_RESOURCE_USAGE_ENCODE_OUTPUT_PICTURE, |
| 1376 |
GMM_RESOURCE_USAGE_ENCODE_OUTPUT_BITSTREAM, |
| 1377 |
GMM_RESOURCE_USAGE_ENCODE_OUTPUT_STATISTICS_WRITE, |
| 1378 |
GMM_RESOURCE_USAGE_ENCODE_OUTPUT_STATISTICS_READ_WRITE, |
| 1379 |
// VP |
| 1380 |
GMM_RESOURCE_USAGE_VP_INPUT_PICTURE_FF, |
| 1381 |
GMM_RESOURCE_USAGE_VP_INPUT_REFERENCE_FF, |
| 1382 |
GMM_RESOURCE_USAGE_VP_INTERNAL_READ_FF, |
| 1383 |
GMM_RESOURCE_USAGE_VP_INTERNAL_WRITE_FF, |
| 1384 |
GMM_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_FF, |
| 1385 |
GMM_RESOURCE_USAGE_VP_OUTPUT_PICTURE_FF, |
| 1386 |
GMM_RESOURCE_USAGE_VP_INPUT_PICTURE_RENDER, |
| 1387 |
GMM_RESOURCE_USAGE_VP_INPUT_REFERENCE_RENDER, |
| 1388 |
GMM_RESOURCE_USAGE_VP_INTERNAL_READ_RENDER, |
| 1389 |
GMM_RESOURCE_USAGE_VP_INTERNAL_WRITE_RENDER, |
| 1390 |
GMM_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_RENDER, |
| 1391 |
GMM_RESOURCE_USAGE_VP_OUTPUT_PICTURE_RENDER, |
| 1392 |
// CP |
| 1393 |
GMM_RESOURCE_USAGE_CP_EXTERNAL_READ, |
| 1394 |
GMM_RESOURCE_USAGE_CP_INTERNAL_WRITE, |
| 1395 |
}; |
| 1396 |
|
| 1397 |
GMM_RESOURCE_USAGE_TYPE MosInterface::GetGmmResourceUsageType( |
| 1398 |
MOS_HW_RESOURCE_DEF resUsage) |
| 1399 |
{ |
| 1400 |
if (resUsage >= (sizeof(GmmResourceUsage) / sizeof(GmmResourceUsage[0]))) |
| 1401 |
return GMM_RESOURCE_USAGE_UNKNOWN; |
| 1402 |
|
| 1403 |
return GmmResourceUsage[resUsage]; |
| 1404 |
} |
| 1405 |
|
| 1406 |
MOS_HW_RESOURCE_DEF MosInterface::GmmToMosResourceUsageType( |
| 1407 |
GMM_RESOURCE_USAGE_TYPE gmmResUsage) |
| 1408 |
{ |
| 1409 |
MOS_HW_RESOURCE_DEF mosResUsage = MOS_HW_RESOURCE_DEF_MAX; |
| 1410 |
switch (gmmResUsage) |
| 1411 |
{ |
| 1412 |
case GMM_RESOURCE_USAGE_DECODE_INPUT_BITSTREAM: |
| 1413 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_INPUT_BITSTREAM; |
| 1414 |
break; |
| 1415 |
case GMM_RESOURCE_USAGE_DECODE_INPUT_REFERENCE: |
| 1416 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_INPUT_REFERENCE; |
| 1417 |
break; |
| 1418 |
case GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ: |
| 1419 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_INTERNAL_READ; |
| 1420 |
break; |
| 1421 |
case GMM_RESOURCE_USAGE_DECODE_INTERNAL_WRITE: |
| 1422 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_INTERNAL_WRITE; |
| 1423 |
break; |
| 1424 |
case GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_CACHE: |
| 1425 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_CACHE; |
| 1426 |
break; |
| 1427 |
case GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE: |
| 1428 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE; |
| 1429 |
break; |
| 1430 |
case GMM_RESOURCE_USAGE_DECODE_OUTPUT_PICTURE: |
| 1431 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_OUTPUT_PICTURE; |
| 1432 |
break; |
| 1433 |
case GMM_RESOURCE_USAGE_DECODE_OUTPUT_STATISTICS_WRITE: |
| 1434 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_OUTPUT_STATISTICS_WRITE; |
| 1435 |
break; |
| 1436 |
case GMM_RESOURCE_USAGE_DECODE_OUTPUT_STATISTICS_READ_WRITE: |
| 1437 |
mosResUsage = MOS_HW_RESOURCE_USAGE_DECODE_OUTPUT_STATISTICS_READ_WRITE; |
| 1438 |
break; |
| 1439 |
default: |
| 1440 |
mosResUsage = MOS_HW_RESOURCE_DEF_MAX; |
| 1441 |
} |
| 1442 |
return mosResUsage; |
| 1443 |
} |
| 1444 |
|
| 1445 |
MEMORY_OBJECT_CONTROL_STATE MosInterface::GetGmmCachePolicyMemoryObject( |
| 1446 |
GMM_CLIENT_CONTEXT *gmmClientContext, |
| 1447 |
GMM_RESOURCE_USAGE_TYPE gmmUsage) |
| 1448 |
{ |
| 1449 |
MOS_OS_FUNCTION_ENTER; |
| 1450 |
if (!gmmClientContext) |
| 1451 |
{ |
| 1452 |
return {0}; |
| 1453 |
} |
| 1454 |
|
| 1455 |
if (gmmClientContext->GetCachePolicyElement(gmmUsage).Initialized) |
| 1456 |
{ |
| 1457 |
return gmmClientContext->CachePolicyGetMemoryObject(nullptr, gmmUsage); |
| 1458 |
} |
| 1459 |
else |
| 1460 |
{ |
| 1461 |
return GetDefaultCachePolicyMemoryObject(gmmClientContext); |
| 1462 |
} |
| 1463 |
} |
| 1464 |
|
| 1465 |
MEMORY_OBJECT_CONTROL_STATE MosInterface::GetDefaultCachePolicyMemoryObject( |
| 1466 |
GMM_CLIENT_CONTEXT *gmmClientContext) |
| 1467 |
{ |
| 1468 |
MOS_OS_FUNCTION_ENTER; |
| 1469 |
if (!gmmClientContext) |
| 1470 |
{ |
| 1471 |
return {0}; |
| 1472 |
} |
| 1473 |
if (gmmClientContext->GetCachePolicyElement(GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE).Initialized) //For arch usage, use GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE as the default setting. |
| 1474 |
{ |
| 1475 |
MOS_OS_NORMALMESSAGE("use GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE"); |
| 1476 |
return gmmClientContext->CachePolicyGetMemoryObject(nullptr, GMM_RESOURCE_USAGE_DECODE_INTERNAL_READ_WRITE_NOCACHE); |
| 1477 |
} |
| 1478 |
else if (gmmClientContext->GetCachePolicyElement(MP_RESOURCE_USAGE_DEFAULT).Initialized) |
| 1479 |
{ |
| 1480 |
MOS_OS_NORMALMESSAGE("use MP_RESOURCE_USAGE_DEFAULT"); |
| 1481 |
return gmmClientContext->CachePolicyGetMemoryObject(nullptr, MP_RESOURCE_USAGE_DEFAULT); |
| 1482 |
} |
| 1483 |
else |
| 1484 |
{ |
| 1485 |
MOS_OS_NORMALMESSAGE("use GMM_RESOURCE_USAGE_UNKNOWN"); |
| 1486 |
return gmmClientContext->CachePolicyGetMemoryObject(nullptr, GMM_RESOURCE_USAGE_UNKNOWN); |
| 1487 |
} |
| 1488 |
} |
| 1489 |
|
| 1490 |
MEMORY_OBJECT_CONTROL_STATE MosInterface::GetCachePolicyMemoryObject( |
| 1491 |
GMM_CLIENT_CONTEXT *gmmClientContext, |
| 1492 |
MOS_HW_RESOURCE_DEF mosUsage) |
| 1493 |
{ |
| 1494 |
MOS_OS_FUNCTION_ENTER; |
| 1495 |
|
| 1496 |
GMM_RESOURCE_USAGE_TYPE usage = GmmResourceUsage[mosUsage]; |
| 1497 |
return MosInterface::GetGmmCachePolicyMemoryObject(gmmClientContext, usage); |
| 1498 |
} |
| 1499 |
|
| 1500 |
uint8_t MosInterface::GetCachePolicyL1Config( |
| 1501 |
MOS_STREAM_HANDLE streamState, |
| 1502 |
MOS_HW_RESOURCE_DEF mosUsage) |
| 1503 |
{ |
| 1504 |
MOS_OS_FUNCTION_ENTER; |
| 1505 |
return 0; |
| 1506 |
} |
| 1507 |
|
| 1508 |
MOS_STATUS MosInterface::GetReservedFromResource(MOS_RESOURCE_HANDLE resource, uint32_t &val) |
| 1509 |
{ |
| 1510 |
return MOS_STATUS_UNIMPLEMENTED; |
| 1511 |
} |
| 1512 |
|
| 1513 |
MOS_STATUS MosInterface::GetReservedFromStream(MOS_STREAM_HANDLE stream, uint32_t &val) |
| 1514 |
{ |
| 1515 |
return MOS_STATUS_UNIMPLEMENTED; |
| 1516 |
} |
| 1517 |
|
| 1518 |
MOS_STATUS MosInterface::GetReservedFromDevice(MOS_DEVICE_HANDLE device, uint32_t &val) |
| 1519 |
{ |
| 1520 |
MOS_OS_CHK_NULL_RETURN(device); |
| 1521 |
OsContextSpecificNext *osDevice = dynamic_cast<OsContextSpecificNext*>(device); |
| 1522 |
MOS_OS_CHK_NULL_RETURN(osDevice); |
| 1523 |
if (osDevice->GetBufMgr()->get_reserved) |
| 1524 |
{ |
| 1525 |
val = *(osDevice->GetBufMgr()->get_reserved); |
| 1526 |
return MOS_STATUS_SUCCESS; |
| 1527 |
} |
| 1528 |
else |
| 1529 |
{ |
| 1530 |
return MOS_STATUS_UNIMPLEMENTED; |
| 1531 |
} |
| 1532 |
} |
| 1533 |
|
| 1534 |
MOS_STATUS MosInterface::GetperStreamParameters(MOS_STREAM_HANDLE stream, void **perStreamParameters) |
| 1535 |
{ |
| 1536 |
MOS_OS_CHK_NULL_RETURN(stream); |
| 1537 |
*perStreamParameters = (void*)stream->perStreamParameters; |
| 1538 |
return MOS_STATUS_SUCCESS; |
| 1539 |
} |
| 1540 |
|
| 1541 |
MOS_STATUS MosInterface::ConvertResourceFromDdi( |
| 1542 |
OsSpecificRes osResource, |
| 1543 |
MOS_RESOURCE_HANDLE &resource, |
| 1544 |
uint32_t firstArraySlice, |
| 1545 |
uint32_t mipSlice) |
| 1546 |
{ |
| 1547 |
MOS_OS_FUNCTION_ENTER; |
| 1548 |
|
| 1549 |
if (firstArraySlice == OS_SPECIFIC_RESOURCE_INVALID || firstArraySlice >= OS_SPECIFIC_RESOURCE_MAX) |
| 1550 |
{ |
| 1551 |
MOS_OS_ASSERTMESSAGE("Cannot Convert Resource From Ddi, invalid ddi resource type!"); |
| 1552 |
return MOS_STATUS_INVALID_PARAMETER; |
| 1553 |
} |
| 1554 |
|
| 1555 |
MOS_OS_CHK_NULL_RETURN(osResource); |
| 1556 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 1557 |
|
| 1558 |
if (firstArraySlice == OS_SPECIFIC_RESOURCE_SURFACE) |
| 1559 |
{ |
| 1560 |
DDI_MEDIA_SURFACE *mediaSurface = (DDI_MEDIA_SURFACE *)osResource; |
| 1561 |
|
| 1562 |
switch (mediaSurface->format) |
| 1563 |
{ |
| 1564 |
case Media_Format_NV12: |
| 1565 |
resource->Format = Format_NV12; |
| 1566 |
break; |
| 1567 |
case Media_Format_NV21: |
| 1568 |
resource->Format = Format_NV21; |
| 1569 |
break; |
| 1570 |
case Media_Format_YUY2: |
| 1571 |
resource->Format = Format_YUY2; |
| 1572 |
break; |
| 1573 |
case Media_Format_X8R8G8B8: |
| 1574 |
resource->Format = Format_X8R8G8B8; |
| 1575 |
break; |
| 1576 |
case Media_Format_X8B8G8R8: |
| 1577 |
resource->Format = Format_X8B8G8R8; |
| 1578 |
break; |
| 1579 |
case Media_Format_A8B8G8R8: |
| 1580 |
case Media_Format_R8G8B8A8: |
| 1581 |
resource->Format = Format_A8B8G8R8; |
| 1582 |
break; |
| 1583 |
case Media_Format_A8R8G8B8: |
| 1584 |
resource->Format = Format_A8R8G8B8; |
| 1585 |
break; |
| 1586 |
case Media_Format_R5G6B5: |
| 1587 |
resource->Format = Format_R5G6B5; |
| 1588 |
break; |
| 1589 |
case Media_Format_R8G8B8: |
| 1590 |
resource->Format = Format_R8G8B8; |
| 1591 |
break; |
| 1592 |
case Media_Format_RGBP: |
| 1593 |
resource->Format = Format_RGBP; |
| 1594 |
break; |
| 1595 |
case Media_Format_BGRP: |
| 1596 |
resource->Format = Format_BGRP; |
| 1597 |
break; |
| 1598 |
case Media_Format_444P: |
| 1599 |
resource->Format = Format_444P; |
| 1600 |
break; |
| 1601 |
case Media_Format_411P: |
| 1602 |
resource->Format = Format_411P; |
| 1603 |
break; |
| 1604 |
case Media_Format_IMC3: |
| 1605 |
resource->Format = Format_IMC3; |
| 1606 |
break; |
| 1607 |
case Media_Format_400P: |
| 1608 |
resource->Format = Format_400P; |
| 1609 |
break; |
| 1610 |
case Media_Format_422H: |
| 1611 |
resource->Format = Format_422H; |
| 1612 |
break; |
| 1613 |
case Media_Format_422V: |
| 1614 |
resource->Format = Format_422V; |
| 1615 |
break; |
| 1616 |
case Media_Format_Buffer: |
| 1617 |
resource->Format = Format_Any; |
| 1618 |
break; |
| 1619 |
case Media_Format_P010: |
| 1620 |
resource->Format = Format_P010; |
| 1621 |
break; |
| 1622 |
case Media_Format_P012: |
| 1623 |
case Media_Format_P016: |
| 1624 |
resource->Format = Format_P016; |
| 1625 |
break; |
| 1626 |
case Media_Format_Y210: |
| 1627 |
resource->Format = Format_Y210; |
| 1628 |
break; |
| 1629 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 1630 |
case Media_Format_Y212: |
| 1631 |
#endif |
| 1632 |
case Media_Format_Y216: |
| 1633 |
resource->Format = Format_Y216; |
| 1634 |
break; |
| 1635 |
case Media_Format_AYUV: |
| 1636 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 1637 |
case Media_Format_XYUV: |
| 1638 |
#endif |
| 1639 |
resource->Format = Format_AYUV; |
| 1640 |
break; |
| 1641 |
case Media_Format_Y410: |
| 1642 |
resource->Format = Format_Y410; |
| 1643 |
break; |
| 1644 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 1645 |
case Media_Format_Y412: |
| 1646 |
#endif |
| 1647 |
case Media_Format_Y416: |
| 1648 |
resource->Format = Format_Y416; |
| 1649 |
break; |
| 1650 |
case Media_Format_Y8: |
| 1651 |
resource->Format = Format_Y8; |
| 1652 |
break; |
| 1653 |
case Media_Format_Y16S: |
| 1654 |
resource->Format = Format_Y16S; |
| 1655 |
break; |
| 1656 |
case Media_Format_Y16U: |
| 1657 |
resource->Format = Format_Y16U; |
| 1658 |
break; |
| 1659 |
case Media_Format_R10G10B10A2: |
| 1660 |
case Media_Format_R10G10B10X2: |
| 1661 |
resource->Format = Format_R10G10B10A2; |
| 1662 |
break; |
| 1663 |
case Media_Format_B10G10R10A2: |
| 1664 |
case Media_Format_B10G10R10X2: |
| 1665 |
resource->Format = Format_B10G10R10A2; |
| 1666 |
break; |
| 1667 |
case Media_Format_UYVY: |
| 1668 |
resource->Format = Format_UYVY; |
| 1669 |
break; |
| 1670 |
case Media_Format_VYUY: |
| 1671 |
resource->Format = Format_VYUY; |
| 1672 |
break; |
| 1673 |
case Media_Format_YVYU: |
| 1674 |
resource->Format = Format_YVYU; |
| 1675 |
break; |
| 1676 |
case Media_Format_A16R16G16B16: |
| 1677 |
resource->Format = Format_A16R16G16B16; |
| 1678 |
break; |
| 1679 |
case Media_Format_A16B16G16R16: |
| 1680 |
resource->Format = Format_A16B16G16R16; |
| 1681 |
break; |
| 1682 |
case Media_Format_I420: |
| 1683 |
resource->Format = Format_I420; |
| 1684 |
break; |
| 1685 |
case Media_Format_YV12: |
| 1686 |
resource->Format = Format_YV12; |
| 1687 |
break; |
| 1688 |
default: |
| 1689 |
MOS_OS_ASSERTMESSAGE("MOS: unsupported media format for surface."); |
| 1690 |
break; |
| 1691 |
} |
| 1692 |
resource->iWidth = mediaSurface->iWidth; |
| 1693 |
resource->iHeight = mediaSurface->iHeight; |
| 1694 |
resource->iPitch = mediaSurface->iPitch; |
| 1695 |
// Use surface bo size as resource size since we need real bounds checking when fill padding for the surface. |
| 1696 |
resource->iSize = mediaSurface->bo->size; |
| 1697 |
resource->iCount = mediaSurface->iRefCount; |
| 1698 |
resource->isTiled = mediaSurface->isTiled; |
| 1699 |
resource->TileType = LinuxToMosTileType(mediaSurface->TileType); |
| 1700 |
resource->bo = mediaSurface->bo; |
| 1701 |
resource->name = mediaSurface->name; |
| 1702 |
|
| 1703 |
resource->ppCurrentFrameSemaphore = &mediaSurface->pCurrentFrameSemaphore; |
| 1704 |
resource->ppReferenceFrameSemaphore = &mediaSurface->pReferenceFrameSemaphore; |
| 1705 |
resource->bSemInitialized = false; |
| 1706 |
resource->bMapped = false; |
| 1707 |
|
| 1708 |
if (mediaSurface->bMapped == true) |
| 1709 |
{ |
| 1710 |
resource->pData = mediaSurface->pData; |
| 1711 |
} |
| 1712 |
else |
| 1713 |
{ |
| 1714 |
resource->pData = nullptr; |
| 1715 |
} |
| 1716 |
resource->pGmmResInfo = mediaSurface->pGmmResourceInfo; |
| 1717 |
resource->dwGfxAddress = 0; |
| 1718 |
} |
| 1719 |
else if (firstArraySlice == OS_SPECIFIC_RESOURCE_BUFFER) |
| 1720 |
{ |
| 1721 |
DDI_MEDIA_BUFFER *mediaBuffer = (DDI_MEDIA_BUFFER *)osResource; |
| 1722 |
switch (mediaBuffer->format) |
| 1723 |
{ |
| 1724 |
case Media_Format_Buffer: |
| 1725 |
resource->Format = Format_Buffer; |
| 1726 |
resource->iWidth = mediaBuffer->iSize; |
| 1727 |
resource->iHeight = 1; |
| 1728 |
resource->iPitch = mediaBuffer->iSize; |
| 1729 |
break; |
| 1730 |
case Media_Format_Perf_Buffer: |
| 1731 |
resource->Format = Format_Buffer; |
| 1732 |
resource->iWidth = mediaBuffer->iSize; |
| 1733 |
resource->iHeight = 1; |
| 1734 |
resource->iPitch = mediaBuffer->iSize; |
| 1735 |
break; |
| 1736 |
case Media_Format_2DBuffer: |
| 1737 |
resource->Format = Format_Buffer_2D; |
| 1738 |
resource->iWidth = mediaBuffer->uiWidth; |
| 1739 |
resource->iHeight = mediaBuffer->uiHeight; |
| 1740 |
resource->iPitch = mediaBuffer->uiPitch; |
| 1741 |
break; |
| 1742 |
case Media_Format_CPU: |
| 1743 |
return MOS_STATUS_SUCCESS; |
| 1744 |
default: |
| 1745 |
resource->iWidth = mediaBuffer->iSize; |
| 1746 |
resource->iHeight = 1; |
| 1747 |
resource->iPitch = mediaBuffer->iSize; |
| 1748 |
MOS_OS_ASSERTMESSAGE("MOS: unsupported media format for surface."); |
| 1749 |
break; |
| 1750 |
} |
| 1751 |
resource->iSize = mediaBuffer->bo->size; |
| 1752 |
resource->iCount = mediaBuffer->iRefCount; |
| 1753 |
resource->isTiled = 0; |
| 1754 |
resource->TileType = LinuxToMosTileType(mediaBuffer->TileType); |
| 1755 |
resource->bo = mediaBuffer->bo; |
| 1756 |
resource->name = mediaBuffer->name; |
| 1757 |
resource->bMapped = false; |
| 1758 |
|
| 1759 |
if (mediaBuffer->bMapped == true) |
| 1760 |
{ |
| 1761 |
resource->pData = mediaBuffer->pData; |
| 1762 |
} |
| 1763 |
else |
| 1764 |
{ |
| 1765 |
resource->pData = nullptr; |
| 1766 |
} |
| 1767 |
resource->dwGfxAddress = 0; |
| 1768 |
resource->pGmmResInfo = mediaBuffer->pGmmResourceInfo; |
| 1769 |
} |
| 1770 |
|
| 1771 |
resource->bConvertedFromDDIResource = true; |
| 1772 |
resource->memObjCtrlState.DwordValue = 0; |
| 1773 |
resource->mocsMosResUsageType = MOS_CODEC_RESOURCE_USAGE_BEGIN_CODEC; |
| 1774 |
|
| 1775 |
return MOS_STATUS_SUCCESS; |
| 1776 |
} |
| 1777 |
|
| 1778 |
MOS_STATUS MosInterface::CreateOsSpecificResourceInfo(OsSpecificRes resource, bool isInternal) |
| 1779 |
{ |
| 1780 |
MOS_OS_FUNCTION_ENTER; |
| 1781 |
|
| 1782 |
// No OsSpecificResourceInfo in Linux |
| 1783 |
|
| 1784 |
return MOS_STATUS_SUCCESS; |
| 1785 |
} |
| 1786 |
|
| 1787 |
MOS_STATUS MosInterface::DestroySpecificResourceInfo(OsSpecificRes resource) |
| 1788 |
{ |
| 1789 |
MOS_OS_FUNCTION_ENTER; |
| 1790 |
|
| 1791 |
// No OsSpecificResourceInfo in Linux |
| 1792 |
|
| 1793 |
return MOS_STATUS_SUCCESS; |
| 1794 |
} |
| 1795 |
|
| 1796 |
MOS_STATUS MosInterface::AllocateResource( |
| 1797 |
MOS_STREAM_HANDLE streamState, |
| 1798 |
PMOS_ALLOC_GFXRES_PARAMS params, |
| 1799 |
MOS_RESOURCE_HANDLE &resource |
| 1800 |
#if MOS_MESSAGES_ENABLED |
| 1801 |
, |
| 1802 |
const char *functionName, |
| 1803 |
const char *filename, |
| 1804 |
int32_t line |
| 1805 |
#endif |
| 1806 |
) |
| 1807 |
{ |
| 1808 |
MOS_STATUS estatus = MOS_STATUS_SUCCESS; |
| 1809 |
MOS_OS_FUNCTION_ENTER; |
| 1810 |
|
| 1811 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 1812 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1813 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 1814 |
|
| 1815 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 1816 |
if (MosSimulateOsApiFail(OS_FAIL_ALLOC_GFX_RES, __FUNCTION__, __FILE__, __LINE__)) |
| 1817 |
{ |
| 1818 |
return MOS_STATUS_NO_SPACE; |
| 1819 |
} |
| 1820 |
#endif |
| 1821 |
|
| 1822 |
resource->bConvertedFromDDIResource = false; |
| 1823 |
if (!params->bBypassMODImpl) |
| 1824 |
{ |
| 1825 |
resource->pGfxResourceNext = GraphicsResourceNext::CreateGraphicResource(GraphicsResourceNext::osSpecificResource); |
| 1826 |
MOS_OS_CHK_NULL_RETURN(resource->pGfxResourceNext); |
| 1827 |
|
| 1828 |
GraphicsResourceNext::CreateParams createParams(params); |
| 1829 |
auto eStatus = resource->pGfxResourceNext->Allocate(streamState->osDeviceContext, createParams); |
| 1830 |
MOS_OS_CHK_STATUS_MESSAGE_RETURN(eStatus, "Allocate graphic resource failed"); |
| 1831 |
|
| 1832 |
eStatus = resource->pGfxResourceNext->ConvertToMosResource(resource); |
| 1833 |
MOS_OS_CHK_STATUS_MESSAGE_RETURN(eStatus, "Convert graphic resource failed"); |
| 1834 |
} |
| 1835 |
else |
| 1836 |
{ |
| 1837 |
estatus = GraphicsResourceSpecificNext::AllocateExternalResource(streamState, params, resource); |
| 1838 |
MOS_OS_CHK_STATUS_MESSAGE_RETURN(estatus, "Allocate external graphic resource failed"); |
| 1839 |
} |
| 1840 |
|
| 1841 |
MOS_OS_CHK_NULL_RETURN(resource->pGmmResInfo); |
| 1842 |
MosUtilities::MosAtomicIncrement(MosUtilities::m_mosMemAllocCounterGfx); |
| 1843 |
|
| 1844 |
MOS_MEMNINJA_GFX_ALLOC_MESSAGE( |
| 1845 |
resource->pGmmResInfo, |
| 1846 |
params->pBufName, |
| 1847 |
streamState->component, |
| 1848 |
(uint32_t)resource->pGmmResInfo->GetSizeSurface(), |
| 1849 |
params->dwArraySize, |
| 1850 |
functionName, |
| 1851 |
filename, |
| 1852 |
line); |
| 1853 |
|
| 1854 |
return MOS_STATUS_SUCCESS; |
| 1855 |
} |
| 1856 |
|
| 1857 |
//The input bit definition in MOS_GFXRES_FREE_FLAGS |
| 1858 |
uint32_t MosInterface::ConvertHalFreeFlagsToOsFreeFlags( |
| 1859 |
uint32_t halFreeFlag) |
| 1860 |
{ |
| 1861 |
return halFreeFlag; |
| 1862 |
} |
| 1863 |
|
| 1864 |
MOS_STATUS MosInterface::FreeResource( |
| 1865 |
MOS_STREAM_HANDLE streamState, |
| 1866 |
MOS_RESOURCE_HANDLE resource, |
| 1867 |
uint32_t flag |
| 1868 |
#if MOS_MESSAGES_ENABLED |
| 1869 |
, |
| 1870 |
const char *functionName, |
| 1871 |
const char *filename, |
| 1872 |
int32_t line |
| 1873 |
#endif // MOS_MESSAGES_ENABLED |
| 1874 |
) |
| 1875 |
{ |
| 1876 |
MOS_OS_FUNCTION_ENTER; |
| 1877 |
|
| 1878 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 1879 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 1880 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 1881 |
|
| 1882 |
bool osContextValid = streamState->osDeviceContext->GetOsContextValid(); |
| 1883 |
|
| 1884 |
bool byPassMod = !((!resource->bConvertedFromDDIResource) && (osContextValid == true) && (resource->pGfxResourceNext)); |
| 1885 |
|
| 1886 |
if (!byPassMod) |
| 1887 |
{ |
| 1888 |
if (resource && resource->pGfxResourceNext) |
| 1889 |
{ |
| 1890 |
resource->pGfxResourceNext->Free(streamState->osDeviceContext); |
| 1891 |
} |
| 1892 |
else |
| 1893 |
{ |
| 1894 |
MOS_OS_VERBOSEMESSAGE("Received an empty Graphics Resource, skip free"); |
| 1895 |
} |
| 1896 |
MOS_Delete(resource->pGfxResourceNext); |
| 1897 |
resource->pGfxResourceNext = nullptr; |
| 1898 |
|
| 1899 |
MosUtilities::MosAtomicDecrement(MosUtilities::m_mosMemAllocCounterGfx); |
| 1900 |
MOS_MEMNINJA_GFX_FREE_MESSAGE(resource->pGmmResInfo, functionName, filename, line); |
| 1901 |
MosUtilities::MosZeroMemory(resource, sizeof(*resource)); |
| 1902 |
|
| 1903 |
return MOS_STATUS_SUCCESS; |
| 1904 |
} |
| 1905 |
|
| 1906 |
MOS_STATUS status = GraphicsResourceSpecificNext::FreeExternalResource(streamState, resource, flag); |
| 1907 |
|
| 1908 |
if (resource->pGmmResInfo != nullptr && |
| 1909 |
streamState->perStreamParameters != nullptr) |
| 1910 |
{ |
| 1911 |
PMOS_CONTEXT perStreamParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 1912 |
if (perStreamParameters && perStreamParameters->pGmmClientContext) |
| 1913 |
{ |
| 1914 |
MosUtilities::MosAtomicDecrement(MosUtilities::m_mosMemAllocCounterGfx); |
| 1915 |
MOS_MEMNINJA_GFX_FREE_MESSAGE(resource->pGmmResInfo, functionName, filename, line); |
| 1916 |
|
| 1917 |
perStreamParameters->pGmmClientContext->DestroyResInfoObject(resource->pGmmResInfo); |
| 1918 |
|
| 1919 |
resource->pGmmResInfo = nullptr; |
| 1920 |
} |
| 1921 |
} |
| 1922 |
|
| 1923 |
return status; |
| 1924 |
} |
| 1925 |
|
| 1926 |
MOS_STATUS MosInterface::FreeResource( |
| 1927 |
OsDeviceContext *osDeviceContext, |
| 1928 |
MOS_RESOURCE_HANDLE resource, |
| 1929 |
uint32_t flag |
| 1930 |
#if MOS_MESSAGES_ENABLED |
| 1931 |
, |
| 1932 |
const char *functionName, |
| 1933 |
const char *filename, |
| 1934 |
int32_t line |
| 1935 |
#endif // MOS_MESSAGES_ENABLED |
| 1936 |
) |
| 1937 |
{ |
| 1938 |
MOS_OS_FUNCTION_ENTER; |
| 1939 |
return MOS_STATUS_UNIMPLEMENTED; |
| 1940 |
} |
| 1941 |
|
| 1942 |
MOS_STATUS MosInterface::GetResourceInfo( |
| 1943 |
MOS_STREAM_HANDLE streamState, |
| 1944 |
MOS_RESOURCE_HANDLE resource, |
| 1945 |
MosResourceInfo &details) //MOS_SURFACE |
| 1946 |
{ |
| 1947 |
MOS_OS_FUNCTION_ENTER; |
| 1948 |
|
| 1949 |
GMM_RESOURCE_INFO * gmmResourceInfo = nullptr; |
| 1950 |
GMM_DISPLAY_FRAME gmmChannel = GMM_DISPLAY_FRAME_MAX; |
| 1951 |
GMM_REQ_OFFSET_INFO reqInfo[3] = {}; |
| 1952 |
GMM_RESOURCE_FLAG gmmFlags = {}; |
| 1953 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1954 |
|
| 1955 |
MOS_UNUSED(streamState); |
| 1956 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 1957 |
|
| 1958 |
// Get Gmm resource info |
| 1959 |
gmmResourceInfo = (GMM_RESOURCE_INFO*)resource->pGmmResInfo; |
| 1960 |
MOS_OS_CHK_NULL_RETURN(gmmResourceInfo); |
| 1961 |
|
| 1962 |
gmmFlags = gmmResourceInfo->GetResFlags(); |
| 1963 |
|
| 1964 |
// Get resource information |
| 1965 |
details.dwWidth = GFX_ULONG_CAST(gmmResourceInfo->GetBaseWidth()); |
| 1966 |
details.dwHeight = gmmResourceInfo->GetBaseHeight(); |
| 1967 |
details.dwPitch = GFX_ULONG_CAST(gmmResourceInfo->GetRenderPitch()); |
| 1968 |
details.dwSize = GFX_ULONG_CAST(gmmResourceInfo->GetSizeSurface()); |
| 1969 |
details.dwDepth = MOS_MAX(1, gmmResourceInfo->GetBaseDepth()); |
| 1970 |
details.dwLockPitch = GFX_ULONG_CAST(gmmResourceInfo->GetRenderPitch()); |
| 1971 |
|
| 1972 |
details.dwQPitch = gmmResourceInfo->GetQPitch(); |
| 1973 |
|
| 1974 |
details.bCompressible = gmmFlags.Gpu.MMC ? |
| 1975 |
(gmmResourceInfo->GetMmcHint(0) == GMM_MMC_HINT_ON) : false; |
| 1976 |
details.bIsCompressed = gmmResourceInfo->IsMediaMemoryCompressed(0); |
| 1977 |
details.CompressionMode = (MOS_RESOURCE_MMC_MODE)gmmResourceInfo->GetMmcMode(0); |
| 1978 |
|
| 1979 |
auto skuTable = MosInterface::GetSkuTable(streamState); |
| 1980 |
if(skuTable && MEDIA_IS_SKU(skuTable, FtrXe2Compression)) |
| 1981 |
{ |
| 1982 |
if (gmmResourceInfo->GetResFlags().Info.MediaCompressed == 1) |
| 1983 |
{ |
| 1984 |
details.CompressionMode = MOS_MMC_MC; |
| 1985 |
details.bIsCompressed = 1; |
| 1986 |
details.bCompressible = (details.CompressionMode != MOS_MMC_DISABLED) ? true : false; |
| 1987 |
} |
| 1988 |
} |
| 1989 |
|
| 1990 |
if (0 == details.dwPitch) |
| 1991 |
{ |
| 1992 |
MOS_OS_ASSERTMESSAGE("Pitch from GmmResource is 0, unexpected."); |
| 1993 |
return MOS_STATUS_INVALID_PARAMETER; |
| 1994 |
} |
| 1995 |
// check resource's tile type |
| 1996 |
details.TileModeGMM = (MOS_TILE_MODE_GMM)gmmResourceInfo->GetTileModeSurfaceState(); |
| 1997 |
details.bGMMTileEnabled = true; |
| 1998 |
switch (gmmResourceInfo->GetTileType()) |
| 1999 |
{ |
| 2000 |
case GMM_TILED_Y: |
| 2001 |
if (gmmFlags.Info.TiledYf) |
| 2002 |
{ |
| 2003 |
details.TileType = MOS_TILE_YF; |
| 2004 |
} |
| 2005 |
else if (gmmFlags.Info.TiledYs) |
| 2006 |
{ |
| 2007 |
details.TileType = MOS_TILE_YS; |
| 2008 |
} |
| 2009 |
else |
| 2010 |
{ |
| 2011 |
details.TileType = MOS_TILE_Y; |
| 2012 |
} |
| 2013 |
break; |
| 2014 |
case GMM_TILED_X: |
| 2015 |
details.TileType = MOS_TILE_X; |
| 2016 |
break; |
| 2017 |
case GMM_NOT_TILED: |
| 2018 |
details.TileType = MOS_TILE_LINEAR; |
| 2019 |
break; |
| 2020 |
default: |
| 2021 |
details.TileType = MOS_TILE_Y; |
| 2022 |
break; |
| 2023 |
} |
| 2024 |
details.Format = resource->Format; |
| 2025 |
|
| 2026 |
details.MipTailStartLOD = gmmResourceInfo->GetMipTailStartLodSurfaceState(); |
| 2027 |
|
| 2028 |
// Get planes |
| 2029 |
MosUtilities::MosZeroMemory(reqInfo, sizeof(reqInfo)); |
| 2030 |
gmmChannel = GMM_DISPLAY_BASE; |
| 2031 |
// Get the base offset of the surface (plane Y) |
| 2032 |
reqInfo[2].ReqRender = true; |
| 2033 |
reqInfo[2].Plane = GMM_PLANE_Y; |
| 2034 |
reqInfo[2].Frame = gmmChannel; |
| 2035 |
reqInfo[2].CubeFace = __GMM_NO_CUBE_MAP; |
| 2036 |
reqInfo[2].ArrayIndex = 0; |
| 2037 |
gmmResourceInfo->GetOffset(reqInfo[2]); |
| 2038 |
details.RenderOffset.YUV.Y.BaseOffset = reqInfo[2].Render.Offset; |
| 2039 |
details.RenderOffset.YUV.Y.XOffset = reqInfo[2].Render.XOffset; |
| 2040 |
details.RenderOffset.YUV.Y.YOffset = reqInfo[2].Render.YOffset; |
| 2041 |
details.LockOffset.YUV.Y = reqInfo[2].Lock.Offset; |
| 2042 |
|
| 2043 |
// Get U/UV plane information (plane offset, X/Y offset) |
| 2044 |
reqInfo[0].ReqRender = true; |
| 2045 |
reqInfo[0].Plane = GMM_PLANE_U; |
| 2046 |
reqInfo[0].Frame = gmmChannel; |
| 2047 |
reqInfo[0].CubeFace = __GMM_NO_CUBE_MAP; |
| 2048 |
reqInfo[0].ArrayIndex = 0; |
| 2049 |
gmmResourceInfo->GetOffset(reqInfo[0]); |
| 2050 |
|
| 2051 |
details.RenderOffset.YUV.U.BaseOffset = reqInfo[0].Render.Offset; |
| 2052 |
details.RenderOffset.YUV.U.XOffset = reqInfo[0].Render.XOffset; |
| 2053 |
details.RenderOffset.YUV.U.YOffset = reqInfo[0].Render.YOffset; |
| 2054 |
details.LockOffset.YUV.U = reqInfo[0].Lock.Offset; |
| 2055 |
|
| 2056 |
// Get V plane information (plane offset, X/Y offset) |
| 2057 |
reqInfo[1].ReqRender = true; |
| 2058 |
reqInfo[1].Plane = GMM_PLANE_V; |
| 2059 |
reqInfo[1].Frame = gmmChannel; |
| 2060 |
reqInfo[1].CubeFace = __GMM_NO_CUBE_MAP; |
| 2061 |
reqInfo[1].ArrayIndex = 0; |
| 2062 |
gmmResourceInfo->GetOffset(reqInfo[1]); |
| 2063 |
|
| 2064 |
details.RenderOffset.YUV.V.BaseOffset = reqInfo[1].Render.Offset; |
| 2065 |
details.RenderOffset.YUV.V.XOffset = reqInfo[1].Render.XOffset; |
| 2066 |
details.RenderOffset.YUV.V.YOffset = reqInfo[1].Render.YOffset; |
| 2067 |
details.LockOffset.YUV.V = reqInfo[1].Lock.Offset; |
| 2068 |
|
| 2069 |
// Get Y plane information (plane offset, X / Y offset) |
| 2070 |
details.dwOffset = details.RenderOffset.YUV.Y.BaseOffset; |
| 2071 |
details.YPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.Y.BaseOffset; |
| 2072 |
details.YPlaneOffset.iXOffset = details.RenderOffset.YUV.Y.XOffset; |
| 2073 |
details.YPlaneOffset.iYOffset = details.RenderOffset.YUV.Y.YOffset; |
| 2074 |
details.YPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.Y; |
| 2075 |
|
| 2076 |
// Get U/UV plane information (plane offset, X/Y offset) |
| 2077 |
details.UPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.U.BaseOffset; |
| 2078 |
details.UPlaneOffset.iXOffset = details.RenderOffset.YUV.U.XOffset; |
| 2079 |
details.UPlaneOffset.iYOffset = details.RenderOffset.YUV.U.YOffset; |
| 2080 |
details.UPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.U; |
| 2081 |
|
| 2082 |
// Get V plane information (plane offset, X/Y offset) |
| 2083 |
details.VPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.V.BaseOffset; |
| 2084 |
details.VPlaneOffset.iXOffset = details.RenderOffset.YUV.V.XOffset; |
| 2085 |
details.VPlaneOffset.iYOffset = details.RenderOffset.YUV.V.YOffset; |
| 2086 |
details.VPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.V; |
| 2087 |
|
| 2088 |
details.YoffsetForUplane = (details.UPlaneOffset.iSurfaceOffset - details.dwOffset) / details.dwPitch + |
| 2089 |
details.UPlaneOffset.iYOffset; |
| 2090 |
details.YoffsetForVplane = (details.VPlaneOffset.iSurfaceOffset - details.dwOffset) / details.dwPitch + |
| 2091 |
details.VPlaneOffset.iYOffset; |
| 2092 |
|
| 2093 |
// Update Uncompressed write request from resources |
| 2094 |
if (gmmResourceInfo->GetMmcHint(0) == GMM_MMC_HINT_OFF) |
| 2095 |
{ |
| 2096 |
resource->bUncompressedWriteNeeded = true; |
| 2097 |
} |
| 2098 |
|
| 2099 |
return eStatus; |
| 2100 |
} |
| 2101 |
|
| 2102 |
void *MosInterface::LockMosResource( |
| 2103 |
MOS_STREAM_HANDLE streamState, |
| 2104 |
MOS_RESOURCE_HANDLE resource, |
| 2105 |
PMOS_LOCK_PARAMS flags) |
| 2106 |
{ |
| 2107 |
MOS_OS_FUNCTION_ENTER; |
| 2108 |
|
| 2109 |
void *pData = nullptr; |
| 2110 |
|
| 2111 |
if (nullptr == streamState) |
| 2112 |
{ |
| 2113 |
MOS_OS_ASSERTMESSAGE("input parameter streamState is NULL."); |
| 2114 |
return nullptr; |
| 2115 |
} |
| 2116 |
|
| 2117 |
if (nullptr == resource) |
| 2118 |
{ |
| 2119 |
MOS_OS_ASSERTMESSAGE("input parameter resource is NULL."); |
| 2120 |
return nullptr; |
| 2121 |
} |
| 2122 |
|
| 2123 |
if ((!resource->bConvertedFromDDIResource) && (resource->pGfxResourceNext)) |
| 2124 |
{ |
| 2125 |
if (nullptr == streamState->osDeviceContext) |
| 2126 |
{ |
| 2127 |
MOS_OS_ASSERTMESSAGE("invalid osDeviceContext, skip lock"); |
| 2128 |
return nullptr; |
| 2129 |
} |
| 2130 |
|
| 2131 |
if (resource->pGfxResourceNext) |
| 2132 |
{ |
| 2133 |
GraphicsResourceNext::LockParams params(flags); |
| 2134 |
pData = resource->pGfxResourceNext->Lock(streamState->osDeviceContext, params); |
| 2135 |
} |
| 2136 |
else |
| 2137 |
{ |
| 2138 |
MOS_OS_ASSERTMESSAGE("Received an empty Graphics Resource, skip lock"); |
| 2139 |
return nullptr; |
| 2140 |
} |
| 2141 |
return pData; |
| 2142 |
} |
| 2143 |
|
| 2144 |
pData = GraphicsResourceSpecificNext::LockExternalResource(streamState, resource, flags); |
| 2145 |
return pData; |
| 2146 |
} |
| 2147 |
|
| 2148 |
void *MosInterface::LockMosResource( |
| 2149 |
OsDeviceContext *osDeviceContext, |
| 2150 |
MOS_RESOURCE_HANDLE resource, |
| 2151 |
PMOS_LOCK_PARAMS flags, |
| 2152 |
bool isDumpPacket) |
| 2153 |
{ |
| 2154 |
MOS_OS_FUNCTION_ENTER; |
| 2155 |
return nullptr; |
| 2156 |
} |
| 2157 |
|
| 2158 |
MOS_STATUS MosInterface::UnlockMosResource( |
| 2159 |
MOS_STREAM_HANDLE streamState, |
| 2160 |
MOS_RESOURCE_HANDLE resource) |
| 2161 |
{ |
| 2162 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2163 |
|
| 2164 |
MOS_OS_FUNCTION_ENTER; |
| 2165 |
|
| 2166 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2167 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2168 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 2169 |
|
| 2170 |
if ((!resource->bConvertedFromDDIResource) && (resource->pGfxResourceNext)) |
| 2171 |
{ |
| 2172 |
if (resource->pGfxResourceNext) |
| 2173 |
{ |
| 2174 |
eStatus = resource->pGfxResourceNext->Unlock(streamState->osDeviceContext); |
| 2175 |
} |
| 2176 |
else |
| 2177 |
{ |
| 2178 |
MOS_OS_VERBOSEMESSAGE("Received an empty Graphics Resource, skip unlock"); |
| 2179 |
} |
| 2180 |
return eStatus; |
| 2181 |
} |
| 2182 |
|
| 2183 |
eStatus = GraphicsResourceSpecificNext::UnlockExternalResource(streamState, resource); |
| 2184 |
|
| 2185 |
return eStatus; |
| 2186 |
} |
| 2187 |
|
| 2188 |
MOS_STATUS MosInterface::UnlockMosResource( |
| 2189 |
OsDeviceContext *osDeviceContext, |
| 2190 |
MOS_RESOURCE_HANDLE resource) |
| 2191 |
{ |
| 2192 |
MOS_OS_FUNCTION_ENTER; |
| 2193 |
return MOS_STATUS_UNIMPLEMENTED; |
| 2194 |
} |
| 2195 |
|
| 2196 |
MOS_STATUS MosInterface::UpdateResourceUsageType( |
| 2197 |
PMOS_RESOURCE pOsResource, |
| 2198 |
MOS_HW_RESOURCE_DEF resUsageType) |
| 2199 |
{ |
| 2200 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2201 |
|
| 2202 |
//--------------------------------- |
| 2203 |
MOS_OS_CHK_NULL_RETURN(pOsResource); |
| 2204 |
MOS_OS_CHK_NULL_RETURN(pOsResource->pGmmResInfo); |
| 2205 |
//--------------------------------- |
| 2206 |
|
| 2207 |
pOsResource->mocsMosResUsageType = resUsageType; |
| 2208 |
pOsResource->pGmmResInfo->OverrideCachePolicyUsage(GetGmmResourceUsageType(resUsageType)); |
| 2209 |
|
| 2210 |
return eStatus; |
| 2211 |
} |
| 2212 |
|
| 2213 |
MOS_STATUS MosInterface::RegisterResource( |
| 2214 |
MOS_STREAM_HANDLE streamState, |
| 2215 |
MOS_RESOURCE_HANDLE resource, |
| 2216 |
bool write) |
| 2217 |
{ |
| 2218 |
MOS_OS_FUNCTION_ENTER; |
| 2219 |
|
| 2220 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2221 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2222 |
MOS_OS_CHK_NULL_RETURN(streamState->osDeviceContext); |
| 2223 |
|
| 2224 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 2225 |
if (MosSimulateOsApiFail(OS_FAIL_REGISTER_GFX_RES, __FUNCTION__, __FILE__, __LINE__)) |
| 2226 |
{ |
| 2227 |
return MOS_STATUS_NO_SPACE; |
| 2228 |
} |
| 2229 |
#endif |
| 2230 |
|
| 2231 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 2232 |
MOS_OS_CHK_NULL_RETURN(gpuContext); |
| 2233 |
|
| 2234 |
return (gpuContext->RegisterResource(resource, write)); |
| 2235 |
} |
| 2236 |
|
| 2237 |
uint64_t MosInterface::GetResourceGfxAddress( |
| 2238 |
MOS_STREAM_HANDLE streamState, |
| 2239 |
MOS_RESOURCE_HANDLE resource) |
| 2240 |
{ |
| 2241 |
MOS_OS_FUNCTION_ENTER; |
| 2242 |
|
| 2243 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2244 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2245 |
|
| 2246 |
if (!mos_bo_is_softpin(resource->bo)) |
| 2247 |
{ |
| 2248 |
mos_bo_set_softpin(resource->bo); |
| 2249 |
} |
| 2250 |
return resource->bo->offset64; |
| 2251 |
} |
| 2252 |
|
| 2253 |
uint32_t MosInterface::GetResourceAllocationHandle( |
| 2254 |
MOS_RESOURCE_HANDLE resource) |
| 2255 |
{ |
| 2256 |
MOS_OS_FUNCTION_ENTER; |
| 2257 |
|
| 2258 |
if (resource && resource->bo) |
| 2259 |
{ |
| 2260 |
return resource->bo->handle; |
| 2261 |
} |
| 2262 |
else |
| 2263 |
{ |
| 2264 |
return 0; |
| 2265 |
} |
| 2266 |
} |
| 2267 |
|
| 2268 |
uint32_t MosInterface::GetResourceAllocationIndex( |
| 2269 |
MOS_STREAM_HANDLE streamState, |
| 2270 |
MOS_RESOURCE_HANDLE resource) |
| 2271 |
{ |
| 2272 |
MOS_OS_FUNCTION_ENTER; |
| 2273 |
|
| 2274 |
return 0; |
| 2275 |
} |
| 2276 |
|
| 2277 |
MOS_STATUS MosInterface::SkipResourceSync( |
| 2278 |
MOS_RESOURCE_HANDLE resource) |
| 2279 |
{ |
| 2280 |
MOS_OS_FUNCTION_ENTER; |
| 2281 |
|
| 2282 |
// No resource sync to skip |
| 2283 |
|
| 2284 |
return MOS_STATUS_SUCCESS; |
| 2285 |
} |
| 2286 |
|
| 2287 |
MOS_STATUS SyncOnResource( |
| 2288 |
MOS_STREAM_HANDLE streamState, |
| 2289 |
MOS_RESOURCE_HANDLE resource, |
| 2290 |
bool writeOperation, |
| 2291 |
GPU_CONTEXT_HANDLE requsetorGpuContext) |
| 2292 |
{ |
| 2293 |
MOS_OS_FUNCTION_ENTER; |
| 2294 |
|
| 2295 |
// No need to do sync on resource |
| 2296 |
|
| 2297 |
return MOS_STATUS_SUCCESS; |
| 2298 |
} |
| 2299 |
|
| 2300 |
MOS_STATUS MosInterface::ResourceSyncCallback( |
| 2301 |
OsSpecificRes resource, |
| 2302 |
MOS_DEVICE_HANDLE deviceContext, |
| 2303 |
uint32_t index, |
| 2304 |
SYNC_HAZARD hazardType, |
| 2305 |
GPU_CONTEXT_HANDLE busyCtx, |
| 2306 |
GPU_CONTEXT_HANDLE requestorCtx, |
| 2307 |
OS_HANDLE osHandle, |
| 2308 |
SYNC_FENCE_INFO_TRINITY *fenceInfoTrinity) |
| 2309 |
{ |
| 2310 |
MOS_OS_FUNCTION_ENTER; |
| 2311 |
|
| 2312 |
// No need to do resource sync |
| 2313 |
|
| 2314 |
return MOS_STATUS_SUCCESS; |
| 2315 |
} |
| 2316 |
|
| 2317 |
MOS_STATUS MosInterface::LockSyncCallback( |
| 2318 |
OsSpecificRes resource, |
| 2319 |
MOS_DEVICE_HANDLE deviceContext, |
| 2320 |
uint32_t index, |
| 2321 |
SYNC_HAZARD hazardType, |
| 2322 |
GPU_CONTEXT_HANDLE busyCtx, |
| 2323 |
bool doNotWait) |
| 2324 |
{ |
| 2325 |
MOS_OS_FUNCTION_ENTER; |
| 2326 |
|
| 2327 |
// No need to do Lock sync |
| 2328 |
|
| 2329 |
return MOS_STATUS_SUCCESS; |
| 2330 |
} |
| 2331 |
|
| 2332 |
MOS_STATUS MosInterface::WaitForCmdCompletion( |
| 2333 |
MOS_STREAM_HANDLE streamState, |
| 2334 |
GPU_CONTEXT_HANDLE gpuCtx) |
| 2335 |
{ |
| 2336 |
MOS_OS_FUNCTION_ENTER; |
| 2337 |
|
| 2338 |
// No need to do WaitForCmdCompletion |
| 2339 |
|
| 2340 |
return MOS_STATUS_SUCCESS; |
| 2341 |
} |
| 2342 |
|
| 2343 |
MOS_STATUS MosInterface::TrimResidency( |
| 2344 |
MOS_DEVICE_HANDLE device, |
| 2345 |
bool periodicTrim, |
| 2346 |
bool restartPeriodicTrim, |
| 2347 |
uint64_t &numBytesToTrim, |
| 2348 |
bool trimToMinimum, |
| 2349 |
bool trimOnlyMediaResources) |
| 2350 |
{ |
| 2351 |
MOS_OS_FUNCTION_ENTER; |
| 2352 |
|
| 2353 |
// No residency to trim |
| 2354 |
|
| 2355 |
return MOS_STATUS_SUCCESS; |
| 2356 |
} |
| 2357 |
|
| 2358 |
MOS_STATUS UpdateResidency( |
| 2359 |
MOS_DEVICE_HANDLE device, |
| 2360 |
OsSpecificRes resInfo, |
| 2361 |
uint32_t index) |
| 2362 |
{ |
| 2363 |
MOS_OS_FUNCTION_ENTER; |
| 2364 |
|
| 2365 |
// No residency to update |
| 2366 |
|
| 2367 |
return MOS_STATUS_SUCCESS; |
| 2368 |
} |
| 2369 |
|
| 2370 |
MOS_STATUS MosInterface::SetMemoryCompressionMode( |
| 2371 |
MOS_STREAM_HANDLE streamState, |
| 2372 |
MOS_RESOURCE_HANDLE resource, |
| 2373 |
MOS_MEMCOMP_STATE resMmcMode) |
| 2374 |
{ |
| 2375 |
MOS_OS_FUNCTION_ENTER; |
| 2376 |
|
| 2377 |
PGMM_RESOURCE_INFO pGmmResourceInfo = nullptr; |
| 2378 |
GMM_RESOURCE_MMC_INFO GmmResMmcMode = GMM_MMC_DISABLED; |
| 2379 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 2380 |
|
| 2381 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2382 |
|
| 2383 |
// Get Gmm resource info |
| 2384 |
pGmmResourceInfo = (GMM_RESOURCE_INFO *)resource->pGmmResInfo; |
| 2385 |
MOS_OS_CHK_NULL_RETURN(pGmmResourceInfo); |
| 2386 |
|
| 2387 |
switch (resMmcMode) |
| 2388 |
{ |
| 2389 |
case MOS_MEMCOMP_HORIZONTAL: |
| 2390 |
GmmResMmcMode = GMM_MMC_HORIZONTAL; |
| 2391 |
break; |
| 2392 |
case MOS_MEMCOMP_VERTICAL: |
| 2393 |
GmmResMmcMode = GMM_MMC_VERTICAL; |
| 2394 |
break; |
| 2395 |
case MOS_MEMCOMP_DISABLED: |
| 2396 |
default: |
| 2397 |
GmmResMmcMode = GMM_MMC_DISABLED; |
| 2398 |
break; |
| 2399 |
} |
| 2400 |
|
| 2401 |
pGmmResourceInfo->SetMmcMode(GmmResMmcMode, 0); |
| 2402 |
|
| 2403 |
eStatus = MOS_STATUS_SUCCESS; |
| 2404 |
|
| 2405 |
return eStatus; |
| 2406 |
} |
| 2407 |
|
| 2408 |
MOS_STATUS MosInterface::GetMemoryCompressionMode( |
| 2409 |
MOS_STREAM_HANDLE streamState, |
| 2410 |
MOS_RESOURCE_HANDLE resource, |
| 2411 |
MOS_MEMCOMP_STATE &resMmcMode) |
| 2412 |
{ |
| 2413 |
MOS_OS_FUNCTION_ENTER; |
| 2414 |
|
| 2415 |
PGMM_RESOURCE_INFO gmmResourceInfo = nullptr; |
| 2416 |
GMM_RESOURCE_FLAG flags; |
| 2417 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 2418 |
|
| 2419 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2420 |
MosUtilities::MosZeroMemory(&flags, sizeof(GMM_RESOURCE_FLAG)); |
| 2421 |
|
| 2422 |
// Get Gmm resource info |
| 2423 |
gmmResourceInfo = (GMM_RESOURCE_INFO *)resource->pGmmResInfo; |
| 2424 |
MOS_OS_CHK_NULL_RETURN(gmmResourceInfo); |
| 2425 |
auto skuTable = GetSkuTable(streamState); |
| 2426 |
MOS_OS_CHK_NULL_RETURN(MosInterface::GetGmmClientContext(streamState)); |
| 2427 |
MOS_OS_CHK_NULL_RETURN(skuTable); |
| 2428 |
|
| 2429 |
if (MEDIA_IS_SKU(skuTable, FtrXe2Compression)) |
| 2430 |
{ |
| 2431 |
// reusing MC to mark all media engins to turn on compression w/ NotCompressed Flag |
| 2432 |
if (!resource->pGmmResInfo->GetResFlags().Info.NotCompressed) |
| 2433 |
{ |
| 2434 |
resMmcMode = MOS_MEMCOMP_MC; |
| 2435 |
} |
| 2436 |
else |
| 2437 |
{ |
| 2438 |
resMmcMode = MOS_MEMCOMP_DISABLED; |
| 2439 |
} |
| 2440 |
return MOS_STATUS_SUCCESS; |
| 2441 |
} |
| 2442 |
|
| 2443 |
flags = resource->pGmmResInfo->GetResFlags(); |
| 2444 |
|
| 2445 |
if (!flags.Gpu.MMC || !flags.Gpu.CCS) |
| 2446 |
{ |
| 2447 |
resMmcMode = MOS_MEMCOMP_DISABLED; |
| 2448 |
return MOS_STATUS_SUCCESS; |
| 2449 |
} |
| 2450 |
|
| 2451 |
if (flags.Info.MediaCompressed || flags.Info.RenderCompressed) |
| 2452 |
{ |
| 2453 |
resMmcMode = flags.Info.RenderCompressed ? MOS_MEMCOMP_RC : MOS_MEMCOMP_MC; |
| 2454 |
} |
| 2455 |
else |
| 2456 |
{ |
| 2457 |
switch (gmmResourceInfo->GetMmcMode(0)) |
| 2458 |
{ |
| 2459 |
case GMM_MMC_HORIZONTAL: |
| 2460 |
resMmcMode = MOS_MEMCOMP_HORIZONTAL; |
| 2461 |
break; |
| 2462 |
case GMM_MMC_VERTICAL: |
| 2463 |
resMmcMode = MOS_MEMCOMP_VERTICAL; |
| 2464 |
break; |
| 2465 |
case GMM_MMC_DISABLED: |
| 2466 |
default: |
| 2467 |
resMmcMode = MOS_MEMCOMP_DISABLED; |
| 2468 |
break; |
| 2469 |
} |
| 2470 |
} |
| 2471 |
|
| 2472 |
uint32_t MmcFormat = 0; |
| 2473 |
GMM_RESOURCE_FORMAT gmmResFmt; |
| 2474 |
gmmResFmt = gmmResourceInfo->GetResourceFormat(); |
| 2475 |
|
| 2476 |
if (resMmcMode == MOS_MEMCOMP_MC) |
| 2477 |
{ |
| 2478 |
MmcFormat = static_cast<uint32_t>(MosInterface::GetGmmClientContext(streamState)->GetMediaSurfaceStateCompressionFormat(gmmResFmt)); |
| 2479 |
resMmcMode = (MmcFormat > 0 && MmcFormat < 0x1f) ? resMmcMode : MOS_MEMCOMP_DISABLED; |
| 2480 |
} |
| 2481 |
|
| 2482 |
eStatus = MOS_STATUS_SUCCESS; |
| 2483 |
|
| 2484 |
return eStatus; |
| 2485 |
} |
| 2486 |
|
| 2487 |
MOS_STATUS MosInterface::SetMemoryCompressionHint( |
| 2488 |
MOS_STREAM_HANDLE streamState, |
| 2489 |
MOS_RESOURCE_HANDLE resource, |
| 2490 |
bool hintOn) |
| 2491 |
{ |
| 2492 |
MOS_OS_FUNCTION_ENTER; |
| 2493 |
|
| 2494 |
PGMM_RESOURCE_INFO pGmmResourceInfo = nullptr; |
| 2495 |
uint32_t uiArrayIndex = 0; |
| 2496 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 2497 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2498 |
|
| 2499 |
// Get Gmm resource info |
| 2500 |
pGmmResourceInfo = (GMM_RESOURCE_INFO *)resource->pGmmResInfo; |
| 2501 |
MOS_OS_CHK_NULL_RETURN(pGmmResourceInfo); |
| 2502 |
|
| 2503 |
pGmmResourceInfo->SetMmcHint(hintOn ? GMM_MMC_HINT_ON : GMM_MMC_HINT_OFF, uiArrayIndex); |
| 2504 |
|
| 2505 |
eStatus = MOS_STATUS_SUCCESS; |
| 2506 |
|
| 2507 |
return eStatus; |
| 2508 |
} |
| 2509 |
|
| 2510 |
MOS_STATUS MosInterface::GetMemoryCompressionFormat( |
| 2511 |
MOS_STREAM_HANDLE streamState, |
| 2512 |
MOS_RESOURCE_HANDLE resource, |
| 2513 |
uint32_t * resMmcFormat) |
| 2514 |
{ |
| 2515 |
MOS_OS_FUNCTION_ENTER; |
| 2516 |
|
| 2517 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 2518 |
PGMM_RESOURCE_INFO pGmmResourceInfo; |
| 2519 |
|
| 2520 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2521 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2522 |
MOS_OS_CHK_NULL_RETURN(resMmcFormat); |
| 2523 |
|
| 2524 |
pGmmResourceInfo = (GMM_RESOURCE_INFO *)resource->pGmmResInfo; |
| 2525 |
MOS_OS_CHK_NULL_RETURN(pGmmResourceInfo); |
| 2526 |
MOS_OS_CHK_NULL_RETURN(MosInterface::GetGmmClientContext(streamState)); |
| 2527 |
// Get compression format from GMM RESOURCE FORMAT |
| 2528 |
GMM_RESOURCE_FORMAT gmmResFmt; |
| 2529 |
gmmResFmt = pGmmResourceInfo->GetResourceFormat(); |
| 2530 |
MOS_MEMCOMP_STATE MmcMode = MOS_MEMCOMP_DISABLED; |
| 2531 |
uint32_t MmcFormat = 0; |
| 2532 |
MosInterface::GetMemoryCompressionMode(streamState, resource, MmcMode); |
| 2533 |
switch (MmcMode) |
| 2534 |
{ |
| 2535 |
case MOS_MEMCOMP_MC: |
| 2536 |
MmcFormat = static_cast<uint32_t>(MosInterface::GetGmmClientContext(streamState)->GetMediaSurfaceStateCompressionFormat(gmmResFmt)); |
| 2537 |
break; |
| 2538 |
case MOS_MEMCOMP_RC: |
| 2539 |
MmcFormat = static_cast<uint32_t>(MosInterface::GetGmmClientContext(streamState)->GetSurfaceStateCompressionFormat(gmmResFmt)); |
| 2540 |
break; |
| 2541 |
default: |
| 2542 |
MmcFormat = 0; |
| 2543 |
} |
| 2544 |
|
| 2545 |
if (MmcFormat > 0x1F) |
| 2546 |
{ |
| 2547 |
MOS_OS_ASSERTMESSAGE("Get a incorrect Compression format(%d) from GMM", MmcFormat); |
| 2548 |
} |
| 2549 |
else |
| 2550 |
{ |
| 2551 |
*resMmcFormat = MmcFormat; |
| 2552 |
MOS_OS_VERBOSEMESSAGE("GMM compression mode %d, compression format %d", MmcMode, MmcFormat); |
| 2553 |
} |
| 2554 |
|
| 2555 |
eStatus = MOS_STATUS_SUCCESS; |
| 2556 |
|
| 2557 |
return eStatus; |
| 2558 |
} |
| 2559 |
|
| 2560 |
MOS_STATUS MosInterface::UnifiedMediaCopyResource( |
| 2561 |
MOS_STREAM_HANDLE streamState, |
| 2562 |
MOS_RESOURCE_HANDLE inputResource, |
| 2563 |
MOS_RESOURCE_HANDLE outputResource, |
| 2564 |
int preferMethod) |
| 2565 |
{ |
| 2566 |
auto pOsDeviceContext = streamState->osDeviceContext; |
| 2567 |
MOS_OS_CHK_NULL_RETURN(pOsDeviceContext); |
| 2568 |
auto pMosMediaCopy = pOsDeviceContext->GetMosMediaCopy(); |
| 2569 |
MOS_OS_CHK_NULL_RETURN(pMosMediaCopy); |
| 2570 |
|
| 2571 |
return pMosMediaCopy->MediaCopy(inputResource, outputResource, (MCPY_METHOD)preferMethod); |
| 2572 |
} |
| 2573 |
|
| 2574 |
MOS_STATUS MosInterface::DoubleBufferCopyResource( |
| 2575 |
MOS_STREAM_HANDLE streamState, |
| 2576 |
MOS_RESOURCE_HANDLE inputResource, |
| 2577 |
MOS_RESOURCE_HANDLE outputResource, |
| 2578 |
bool outputCompressed) |
| 2579 |
{ |
| 2580 |
MOS_OS_FUNCTION_ENTER; |
| 2581 |
|
| 2582 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 2583 |
MOS_OS_CHK_NULL_RETURN(inputResource); |
| 2584 |
MOS_OS_CHK_NULL_RETURN(outputResource); |
| 2585 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2586 |
|
| 2587 |
MosDecompression *mosDecompression = nullptr; |
| 2588 |
auto lbdMemDecomp = [&]() |
| 2589 |
{ |
| 2590 |
if (inputResource->bo && inputResource->pGmmResInfo && |
| 2591 |
outputResource->bo && outputResource->pGmmResInfo) |
| 2592 |
{ |
| 2593 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetMosDecompressionFromStreamState(streamState, mosDecompression)); |
| 2594 |
MOS_OS_CHK_NULL_RETURN(mosDecompression); |
| 2595 |
|
| 2596 |
// Double Buffer Copy can support any tile status surface with/without compression |
| 2597 |
return mosDecompression->MediaMemoryCopy(inputResource, outputResource, outputCompressed); |
| 2598 |
} |
| 2599 |
else |
| 2600 |
{ |
| 2601 |
return MOS_STATUS_NULL_POINTER; |
| 2602 |
} |
| 2603 |
}; |
| 2604 |
|
| 2605 |
void *mmd = nullptr; |
| 2606 |
if (mosDecompression && mosDecompression->GetMediaMemDecompState()) |
| 2607 |
{ |
| 2608 |
mmd = *mosDecompression->GetMediaMemDecompState(); |
| 2609 |
} |
| 2610 |
// If mmd device not registered, use media vebopx copy. |
| 2611 |
if (lbdMemDecomp() != MOS_STATUS_SUCCESS && mosDecompression && !mmd) |
| 2612 |
{ |
| 2613 |
MOS_OS_CRITICALMESSAGE("MMD device not registered. Use media copy instead."); |
| 2614 |
status = MosInterface::UnifiedMediaCopyResource(streamState, inputResource, outputResource, MCPY_METHOD_BALANCE); |
| 2615 |
} |
| 2616 |
|
| 2617 |
return status; |
| 2618 |
} |
| 2619 |
|
| 2620 |
MOS_STATUS MosInterface::VerifyMosSurface( |
| 2621 |
PMOS_SURFACE mosSurface, |
| 2622 |
bool &bIsValid) |
| 2623 |
{ |
| 2624 |
MOS_OS_FUNCTION_ENTER; |
| 2625 |
|
| 2626 |
MOS_OS_CHK_NULL_RETURN(mosSurface); |
| 2627 |
MOS_OS_CHK_NULL_RETURN(mosSurface->OsResource.pGmmResInfo); |
| 2628 |
|
| 2629 |
if ((mosSurface->dwPitch * mosSurface->dwHeight > mosSurface->OsResource.pGmmResInfo->GetSizeMainSurface() && (mosSurface->Type != MOS_GFXRES_BUFFER)) || |
| 2630 |
(mosSurface->dwPitch > mosSurface->OsResource.pGmmResInfo->GetSizeMainSurface() && (mosSurface->Type == MOS_GFXRES_BUFFER)) || |
| 2631 |
mosSurface->dwHeight == 0 || |
| 2632 |
mosSurface->dwPitch == 0) |
| 2633 |
{ |
| 2634 |
bIsValid = false; |
| 2635 |
MOS_OS_ASSERTMESSAGE("Invalid arguments for mos surface copy: dwPitch %lu, dwHeight %lu, gmmMainSurfaceSize %llu, GFXRES Type %d", |
| 2636 |
mosSurface->dwPitch, |
| 2637 |
mosSurface->dwHeight, |
| 2638 |
mosSurface->OsResource.pGmmResInfo->GetSizeMainSurface(), |
| 2639 |
mosSurface->Type); |
| 2640 |
} |
| 2641 |
else |
| 2642 |
{ |
| 2643 |
bIsValid = true; |
| 2644 |
} |
| 2645 |
|
| 2646 |
return MOS_STATUS_SUCCESS; |
| 2647 |
} |
| 2648 |
|
| 2649 |
MOS_STATUS MosInterface::MediaCopyResource2D( |
| 2650 |
MOS_STREAM_HANDLE streamState, |
| 2651 |
MOS_RESOURCE_HANDLE inputResource, |
| 2652 |
MOS_RESOURCE_HANDLE outputResource, |
| 2653 |
uint32_t copyWidth, |
| 2654 |
uint32_t copyHeight, |
| 2655 |
uint32_t bpp, |
| 2656 |
bool outputCompressed) |
| 2657 |
{ |
| 2658 |
MOS_OS_FUNCTION_ENTER; |
| 2659 |
|
| 2660 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 2661 |
MOS_OS_CHK_NULL_RETURN(inputResource); |
| 2662 |
MOS_OS_CHK_NULL_RETURN(outputResource); |
| 2663 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2664 |
|
| 2665 |
MosDecompression *mosDecompression = nullptr; |
| 2666 |
auto lbdMemDecomp = [&]() |
| 2667 |
{ |
| 2668 |
if (inputResource->bo && inputResource->pGmmResInfo && |
| 2669 |
outputResource->bo && outputResource->pGmmResInfo) |
| 2670 |
{ |
| 2671 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetMosDecompressionFromStreamState(streamState, mosDecompression)); |
| 2672 |
MOS_OS_CHK_NULL_RETURN(mosDecompression); |
| 2673 |
|
| 2674 |
// Double Buffer Copy can support any tile status surface with/without compression |
| 2675 |
return mosDecompression->MediaMemoryCopy2D(inputResource, outputResource, |
| 2676 |
copyWidth, copyHeight, 0, 0, bpp, outputCompressed); |
| 2677 |
} |
| 2678 |
else |
| 2679 |
{ |
| 2680 |
return MOS_STATUS_NULL_POINTER; |
| 2681 |
} |
| 2682 |
}; |
| 2683 |
|
| 2684 |
// If mmd device not registered, use media vebopx copy. |
| 2685 |
if (lbdMemDecomp() != MOS_STATUS_SUCCESS && mosDecompression && !mosDecompression->GetMediaMemDecompState()) |
| 2686 |
{ |
| 2687 |
MOS_OS_CRITICALMESSAGE("MMD device not registered. Use media copy instead."); |
| 2688 |
status = MosInterface::UnifiedMediaCopyResource(streamState, inputResource, outputResource, MCPY_METHOD_BALANCE); |
| 2689 |
} |
| 2690 |
|
| 2691 |
return status; |
| 2692 |
} |
| 2693 |
|
| 2694 |
MOS_STATUS MosInterface::MonoSurfaceCopy( |
| 2695 |
MOS_STREAM_HANDLE streamState, |
| 2696 |
MOS_RESOURCE_HANDLE inputResource, |
| 2697 |
MOS_RESOURCE_HANDLE outputResource, |
| 2698 |
uint32_t copyWidth, |
| 2699 |
uint32_t copyHeight, |
| 2700 |
uint32_t copyInputOffset, |
| 2701 |
uint32_t copyOutputOffset, |
| 2702 |
bool outputCompressed) |
| 2703 |
{ |
| 2704 |
MOS_OS_FUNCTION_ENTER; |
| 2705 |
|
| 2706 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 2707 |
MOS_OS_CHK_NULL_RETURN(inputResource); |
| 2708 |
MOS_OS_CHK_NULL_RETURN(outputResource); |
| 2709 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2710 |
|
| 2711 |
MosDecompression *mosDecompression = nullptr; |
| 2712 |
auto lbdMemDecomp = [&]() |
| 2713 |
{ |
| 2714 |
if (inputResource->bo && inputResource->pGmmResInfo && |
| 2715 |
outputResource->bo && outputResource->pGmmResInfo) |
| 2716 |
{ |
| 2717 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetMosDecompressionFromStreamState(streamState, mosDecompression)); |
| 2718 |
MOS_OS_CHK_NULL_RETURN(mosDecompression); |
| 2719 |
|
| 2720 |
// Double Buffer Copy can support any tile status surface with/without compression |
| 2721 |
return mosDecompression->MediaMemoryCopy2D(inputResource, outputResource, |
| 2722 |
copyWidth, copyHeight, copyInputOffset, copyOutputOffset, 16, outputCompressed); |
| 2723 |
} |
| 2724 |
else |
| 2725 |
{ |
| 2726 |
return MOS_STATUS_NULL_POINTER; |
| 2727 |
} |
| 2728 |
}; |
| 2729 |
|
| 2730 |
// If mmd device not registered, use media vebopx copy. |
| 2731 |
if (lbdMemDecomp() != MOS_STATUS_SUCCESS && mosDecompression && !mosDecompression->GetMediaMemDecompState()) |
| 2732 |
{ |
| 2733 |
MOS_OS_CRITICALMESSAGE("MMD device not registered. Use media copy instead."); |
| 2734 |
MOS_SURFACE inputResInfo, outputResInfo; |
| 2735 |
MOS_ZeroMemory(&inputResInfo, sizeof(MOS_SURFACE)); |
| 2736 |
MOS_ZeroMemory(&outputResInfo, sizeof(MOS_SURFACE)); |
| 2737 |
|
| 2738 |
struct BackupResInfo |
| 2739 |
{ |
| 2740 |
MOS_FORMAT format; |
| 2741 |
uint32_t height; |
| 2742 |
uint32_t width; |
| 2743 |
uint32_t pitch; |
| 2744 |
uint32_t offset; |
| 2745 |
}; |
| 2746 |
|
| 2747 |
inputResInfo.Format = Format_Invalid; |
| 2748 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetResourceInfo(streamState, inputResource, inputResInfo)); |
| 2749 |
BackupResInfo bkIn = {inputResInfo.Format, inputResInfo.dwHeight, inputResInfo.dwWidth, inputResInfo.dwPitch}; |
| 2750 |
|
| 2751 |
outputResInfo.Format = Format_Invalid; |
| 2752 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetResourceInfo(streamState, outputResource, outputResInfo)); |
| 2753 |
BackupResInfo bkOut = {outputResInfo.Format, outputResInfo.dwHeight, outputResInfo.dwWidth, outputResInfo.dwPitch}; |
| 2754 |
|
| 2755 |
uint32_t pixelInByte = 2; |
| 2756 |
MOS_FORMAT overrideFormat = Format_Y16U; |
| 2757 |
|
| 2758 |
inputResource->pGmmResInfo->OverrideSurfaceFormat(MosInterface::MosFmtToGmmFmt(overrideFormat)); |
| 2759 |
inputResource->pGmmResInfo->OverrideBaseWidth(copyWidth / pixelInByte); |
| 2760 |
inputResource->pGmmResInfo->OverridePitch(copyWidth); |
| 2761 |
inputResource->pGmmResInfo->OverrideBaseHeight(copyHeight); |
| 2762 |
outputResource->pGmmResInfo->OverrideSurfaceFormat(MosInterface::MosFmtToGmmFmt(overrideFormat)); |
| 2763 |
outputResource->pGmmResInfo->OverrideBaseWidth(copyWidth / pixelInByte); |
| 2764 |
outputResource->pGmmResInfo->OverridePitch(copyWidth); |
| 2765 |
outputResource->pGmmResInfo->OverrideBaseHeight(copyHeight); |
| 2766 |
|
| 2767 |
uint32_t inOffset = inputResource->dwOffsetForMono; |
| 2768 |
uint32_t outOffset = outputResource->dwOffsetForMono; |
| 2769 |
inputResource->dwOffsetForMono = copyInputOffset; |
| 2770 |
outputResource->dwOffsetForMono = copyOutputOffset; |
| 2771 |
|
| 2772 |
status = MosInterface::UnifiedMediaCopyResource(streamState, inputResource, outputResource, MCPY_METHOD_BALANCE); |
| 2773 |
|
| 2774 |
inputResource->pGmmResInfo->OverrideSurfaceFormat(MosInterface::MosFmtToGmmFmt(bkIn.format)); |
| 2775 |
inputResource->pGmmResInfo->OverrideBaseWidth(bkIn.width); |
| 2776 |
inputResource->pGmmResInfo->OverrideBaseWidth(bkIn.pitch); |
| 2777 |
inputResource->pGmmResInfo->OverrideBaseHeight(bkIn.height); |
| 2778 |
outputResource->pGmmResInfo->OverrideSurfaceFormat(MosInterface::MosFmtToGmmFmt(bkOut.format)); |
| 2779 |
outputResource->pGmmResInfo->OverrideBaseWidth(bkOut.width); |
| 2780 |
outputResource->pGmmResInfo->OverrideBaseWidth(bkOut.pitch); |
| 2781 |
outputResource->pGmmResInfo->OverrideBaseHeight(bkOut.height); |
| 2782 |
|
| 2783 |
inputResource->dwOffsetForMono = inOffset; |
| 2784 |
outputResource->dwOffsetForMono = outOffset; |
| 2785 |
} |
| 2786 |
|
| 2787 |
return status; |
| 2788 |
} |
| 2789 |
|
| 2790 |
MOS_STATUS MosInterface::DecompResource( |
| 2791 |
MOS_STREAM_HANDLE streamState, |
| 2792 |
MOS_RESOURCE_HANDLE resource) |
| 2793 |
{ |
| 2794 |
MOS_OS_FUNCTION_ENTER; |
| 2795 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 2796 |
|
| 2797 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2798 |
MOS_OS_CHK_NULL_RETURN(resource); |
| 2799 |
MOS_OS_CHK_NULL_RETURN(resource->bo); |
| 2800 |
MOS_OS_CHK_NULL_RETURN(resource->pGmmResInfo); |
| 2801 |
|
| 2802 |
MOS_LINUX_BO *bo = resource->bo; |
| 2803 |
GMM_RESOURCE_FLAG gmmFlags; |
| 2804 |
gmmFlags = resource->pGmmResInfo->GetResFlags(); |
| 2805 |
if (((gmmFlags.Gpu.MMC || |
| 2806 |
gmmFlags.Gpu.CCS) && |
| 2807 |
gmmFlags.Gpu.UnifiedAuxSurface) || |
| 2808 |
resource->pGmmResInfo->IsMediaMemoryCompressed(0)) |
| 2809 |
{ |
| 2810 |
MosDecompression *mosDecompression = nullptr; |
| 2811 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::GetMosDecompressionFromStreamState(streamState, mosDecompression)); |
| 2812 |
|
| 2813 |
MOS_OS_CHK_NULL_RETURN(mosDecompression); |
| 2814 |
mosDecompression->MemoryDecompress(resource); |
| 2815 |
|
| 2816 |
MOS_OS_CHK_STATUS_RETURN(MosInterface::SetMemoryCompressionHint(streamState, resource, false)); |
| 2817 |
} |
| 2818 |
|
| 2819 |
return MOS_STATUS_SUCCESS; |
| 2820 |
} |
| 2821 |
|
| 2822 |
MOS_STATUS MosInterface::GetMosDecompressionFromStreamState( |
| 2823 |
MOS_STREAM_HANDLE streamState, |
| 2824 |
MosDecompression* & mosDecompression) |
| 2825 |
{ |
| 2826 |
MOS_OS_FUNCTION_ENTER; |
| 2827 |
MOS_STATUS status = MOS_STATUS_SUCCESS; |
| 2828 |
|
| 2829 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2830 |
mosDecompression = streamState->mosDecompression; |
| 2831 |
if (!mosDecompression) |
| 2832 |
{ |
| 2833 |
if (streamState->enableDecomp) |
| 2834 |
{ |
| 2835 |
PMOS_CONTEXT mosContext = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 2836 |
MOS_OS_CHK_NULL_RETURN(mosContext); |
| 2837 |
mosDecompression = streamState->mosDecompression = MOS_New(MosDecompression, mosContext); |
| 2838 |
} |
| 2839 |
else |
| 2840 |
{ |
| 2841 |
OsContextNext *osCtx = streamState->osDeviceContext; |
| 2842 |
MOS_OS_CHK_NULL_RETURN(osCtx); |
| 2843 |
mosDecompression = osCtx->GetMosDecompression(); |
| 2844 |
} |
| 2845 |
} |
| 2846 |
MOS_OS_CHK_NULL_RETURN(mosDecompression); |
| 2847 |
|
| 2848 |
return status; |
| 2849 |
} |
| 2850 |
|
| 2851 |
MOS_STATUS MosInterface::SetDecompSyncRes( |
| 2852 |
MOS_STREAM_HANDLE streamState, |
| 2853 |
MOS_RESOURCE_HANDLE syncResource) |
| 2854 |
{ |
| 2855 |
return MOS_STATUS_SUCCESS; |
| 2856 |
} |
| 2857 |
|
| 2858 |
uint32_t MosInterface::GetGpuStatusTag( |
| 2859 |
MOS_STREAM_HANDLE streamState, |
| 2860 |
GPU_CONTEXT_HANDLE gpuContext) |
| 2861 |
{ |
| 2862 |
MOS_OS_FUNCTION_ENTER; |
| 2863 |
|
| 2864 |
if (streamState) |
| 2865 |
{ |
| 2866 |
auto gpuContextIns = MosInterface::GetGpuContext(streamState, gpuContext); |
| 2867 |
if (gpuContextIns == nullptr) |
| 2868 |
{ |
| 2869 |
MOS_OS_ASSERTMESSAGE("Get GPU Status Tag failed."); |
| 2870 |
return 0; |
| 2871 |
} |
| 2872 |
|
| 2873 |
return gpuContextIns->GetGpuStatusTag(); |
| 2874 |
} |
| 2875 |
MOS_OS_ASSERTMESSAGE("Get GPU Status Tag failed."); |
| 2876 |
|
| 2877 |
return 0; |
| 2878 |
} |
| 2879 |
|
| 2880 |
MOS_STATUS MosInterface::IncrementGpuStatusTag( |
| 2881 |
MOS_STREAM_HANDLE streamState, |
| 2882 |
GPU_CONTEXT_HANDLE gpuContext) |
| 2883 |
{ |
| 2884 |
MOS_OS_FUNCTION_ENTER; |
| 2885 |
|
| 2886 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2887 |
auto gpuContextIns = MosInterface::GetGpuContext(streamState, gpuContext); |
| 2888 |
MOS_OS_CHK_NULL_RETURN(gpuContextIns); |
| 2889 |
|
| 2890 |
gpuContextIns->IncrementGpuStatusTag(); |
| 2891 |
|
| 2892 |
return MOS_STATUS_SUCCESS; |
| 2893 |
} |
| 2894 |
|
| 2895 |
uint64_t MosInterface::GetGpuStatusSyncTag( |
| 2896 |
MOS_STREAM_HANDLE streamState, |
| 2897 |
GPU_CONTEXT_HANDLE gpuContext) |
| 2898 |
{ |
| 2899 |
MOS_OS_FUNCTION_ENTER; |
| 2900 |
|
| 2901 |
// No Gpu Status Sync Tag in Linux |
| 2902 |
|
| 2903 |
return 0; |
| 2904 |
} |
| 2905 |
|
| 2906 |
MOS_STATUS MosInterface::GetGpuStatusBufferResource( |
| 2907 |
MOS_STREAM_HANDLE streamState, |
| 2908 |
MOS_RESOURCE_HANDLE &resource, |
| 2909 |
GPU_CONTEXT_HANDLE gpuContext) |
| 2910 |
{ |
| 2911 |
MOS_OS_FUNCTION_ENTER; |
| 2912 |
|
| 2913 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 2914 |
|
| 2915 |
auto gpuContextIns = MosInterface::GetGpuContext(streamState, gpuContext); |
| 2916 |
MOS_OS_CHK_NULL_RETURN(gpuContextIns); |
| 2917 |
|
| 2918 |
resource = gpuContextIns->GetStatusBufferResource(); |
| 2919 |
|
| 2920 |
return MOS_STATUS_SUCCESS; |
| 2921 |
} |
| 2922 |
|
| 2923 |
GMM_CLIENT_CONTEXT *MosInterface::GetGmmClientContext( |
| 2924 |
MOS_STREAM_HANDLE streamState) |
| 2925 |
{ |
| 2926 |
MOS_OS_FUNCTION_ENTER; |
| 2927 |
|
| 2928 |
if (streamState && streamState->osDeviceContext) |
| 2929 |
{ |
| 2930 |
return streamState->osDeviceContext->GetGmmClientContext(); |
| 2931 |
} |
| 2932 |
|
| 2933 |
return nullptr; |
| 2934 |
} |
| 2935 |
|
| 2936 |
unsigned int MosInterface::GetPATIndexFromGmm( |
| 2937 |
GMM_CLIENT_CONTEXT *gmmClient, |
| 2938 |
GMM_RESOURCE_INFO *gmmResourceInfo) |
| 2939 |
{ |
| 2940 |
if (gmmClient && gmmResourceInfo) |
| 2941 |
{ |
| 2942 |
auto IsFormatSupportCompression = [=]()->bool |
| 2943 |
{ |
| 2944 |
// formats support compression match to copy supported formats except RGBP&BGRP |
| 2945 |
switch(GmmFmtToMosFmt(gmmResourceInfo->GetResourceFormat())) |
| 2946 |
{ |
| 2947 |
case Format_NV12: |
| 2948 |
case Format_YV12: |
| 2949 |
case Format_I420: |
| 2950 |
case Format_P010: |
| 2951 |
case Format_Y410: |
| 2952 |
case Format_Y416: |
| 2953 |
case Format_Y210: |
| 2954 |
case Format_Y216: |
| 2955 |
case Format_YUY2: |
| 2956 |
case Format_R5G6B5: |
| 2957 |
case Format_R8G8B8: |
| 2958 |
case Format_A8R8G8B8: |
| 2959 |
case Format_A8B8G8R8: |
| 2960 |
case Format_X8R8G8B8: |
| 2961 |
case Format_X8B8G8R8: |
| 2962 |
case Format_AYUV: |
| 2963 |
case Format_R10G10B10A2: |
| 2964 |
case Format_B10G10R10A2: |
| 2965 |
case Format_P8: |
| 2966 |
case Format_L8: |
| 2967 |
case Format_A8: |
| 2968 |
case Format_Y16U: |
| 2969 |
return true; |
| 2970 |
case Format_P016: |
| 2971 |
// For P016 format we use SW swizzle because of history with reason (some hard code plane offset calculation in vaGetImage/vaPutImage). |
| 2972 |
return false; |
| 2973 |
default: |
| 2974 |
return false; |
| 2975 |
} |
| 2976 |
}; |
| 2977 |
|
| 2978 |
// GetDriverProtectionBits funtion could hide gmm details info, |
| 2979 |
// and we should use GetDriverProtectionBits to replace CachePolicyGetPATIndex in future. |
| 2980 |
// isCompressionEnable could be false temparaily. |
| 2981 |
bool isCompressionEnable = false; |
| 2982 |
if (gmmResourceInfo->GetResFlags().Info.NotCompressed == 0 && |
| 2983 |
IsFormatSupportCompression() && |
| 2984 |
gmmResourceInfo->GetResFlags().Info.Tile4 == 1 && |
| 2985 |
gmmResourceInfo->GetBaseWidth() > 64 && |
| 2986 |
gmmResourceInfo->GetBaseHeight() > 64) |
| 2987 |
{ |
| 2988 |
isCompressionEnable = true; |
| 2989 |
} |
| 2990 |
return gmmClient->CachePolicyGetPATIndex( |
| 2991 |
gmmResourceInfo, |
| 2992 |
gmmResourceInfo->GetCachePolicyUsage(), |
| 2993 |
&isCompressionEnable, |
| 2994 |
gmmResourceInfo->GetResFlags().Info.Cacheable); |
| 2995 |
} |
| 2996 |
return PAT_INDEX_INVALID; |
| 2997 |
} |
| 2998 |
|
| 2999 |
void MosInterface::GetGpuPriority(MOS_STREAM_HANDLE streamState, int32_t* pPriority) |
| 3000 |
{ |
| 3001 |
MOS_OS_FUNCTION_ENTER; |
| 3002 |
|
| 3003 |
if (streamState == nullptr) |
| 3004 |
{ |
| 3005 |
MOS_OS_ASSERTMESSAGE("Failed to set the gpu priority"); |
| 3006 |
return; |
| 3007 |
} |
| 3008 |
|
| 3009 |
PMOS_OS_CONTEXT pOsContext = (PMOS_OS_CONTEXT)streamState->perStreamParameters; |
| 3010 |
if (pOsContext == nullptr) |
| 3011 |
{ |
| 3012 |
MOS_OS_ASSERTMESSAGE("Failed to set the gpu priority"); |
| 3013 |
return; |
| 3014 |
} |
| 3015 |
|
| 3016 |
uint64_t priority = 0; |
| 3017 |
mos_get_context_param(pOsContext->intel_context, 0, DRM_CONTEXT_PARAM_PRIORITY, &priority); |
| 3018 |
*pPriority = (int32_t)priority; |
| 3019 |
} |
| 3020 |
|
| 3021 |
void MosInterface::SetGpuPriority(MOS_STREAM_HANDLE streamState, int32_t priority) |
| 3022 |
{ |
| 3023 |
MOS_OS_FUNCTION_ENTER; |
| 3024 |
|
| 3025 |
if (streamState == nullptr) |
| 3026 |
{ |
| 3027 |
MOS_OS_ASSERTMESSAGE("Failed to set the gpu priority"); |
| 3028 |
return; |
| 3029 |
} |
| 3030 |
|
| 3031 |
if (streamState->ctxPriority == priority) |
| 3032 |
return; |
| 3033 |
|
| 3034 |
PMOS_OS_CONTEXT pOsContext = (PMOS_OS_CONTEXT)streamState->perStreamParameters; |
| 3035 |
if (pOsContext == nullptr) |
| 3036 |
{ |
| 3037 |
MOS_OS_ASSERTMESSAGE("Failed to set the gpu priority"); |
| 3038 |
return; |
| 3039 |
} |
| 3040 |
|
| 3041 |
int32_t ret = mos_set_context_param(pOsContext->intel_context, 0, DRM_CONTEXT_PARAM_PRIORITY,(uint64_t)priority); |
| 3042 |
if (ret != 0) |
| 3043 |
{ |
| 3044 |
MOS_OS_ASSERTMESSAGE("failed to set the gpu priority, error is %d", ret); |
| 3045 |
} |
| 3046 |
|
| 3047 |
streamState->ctxPriority = priority; |
| 3048 |
} |
| 3049 |
|
| 3050 |
uint64_t MosInterface::GetAuxTableBaseAddr( |
| 3051 |
MOS_STREAM_HANDLE streamState) |
| 3052 |
{ |
| 3053 |
MOS_OS_FUNCTION_ENTER; |
| 3054 |
|
| 3055 |
if (!streamState || !streamState->osDeviceContext) |
| 3056 |
{ |
| 3057 |
return 0; |
| 3058 |
} |
| 3059 |
auto osDeviceContextSpecific = static_cast<OsContextSpecificNext *>(streamState->osDeviceContext); |
| 3060 |
auto auxTableMgr = osDeviceContextSpecific->GetAuxTableMgr(); |
| 3061 |
if(!auxTableMgr) |
| 3062 |
{ |
| 3063 |
return 0; |
| 3064 |
} |
| 3065 |
return auxTableMgr->GetAuxTableBase(); |
| 3066 |
} |
| 3067 |
|
| 3068 |
MosCpInterface *MosInterface::GetCpInterface(MOS_STREAM_HANDLE streamState) |
| 3069 |
{ |
| 3070 |
MOS_OS_FUNCTION_ENTER; |
| 3071 |
|
| 3072 |
return streamState ? streamState->osCpInterface : nullptr; |
| 3073 |
} |
| 3074 |
|
| 3075 |
MOS_STATUS MosInterface::CreateVirtualEngineState( |
| 3076 |
MOS_STREAM_HANDLE streamState, |
| 3077 |
PMOS_VIRTUALENGINE_INIT_PARAMS veInitParms, |
| 3078 |
MOS_VE_HANDLE& veState) |
| 3079 |
{ |
| 3080 |
MOS_OS_FUNCTION_ENTER; |
| 3081 |
|
| 3082 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 3083 |
|
| 3084 |
if (veInitParms->bScalabilitySupported) |
| 3085 |
{ |
| 3086 |
streamState->virtualEngineInterface = MOS_New(MosOsVeScalabilitySpecific); |
| 3087 |
} |
| 3088 |
else |
| 3089 |
{ |
| 3090 |
streamState->virtualEngineInterface = MOS_New(MosOsVeSinglePipeSpecific); |
| 3091 |
} |
| 3092 |
MOS_OS_CHK_NULL_RETURN(streamState->virtualEngineInterface); |
| 3093 |
|
| 3094 |
MOS_OS_CHK_STATUS_RETURN(streamState->virtualEngineInterface->Initialize(streamState, veInitParms)); |
| 3095 |
|
| 3096 |
veState = streamState->virtualEngineInterface; |
| 3097 |
|
| 3098 |
return MOS_STATUS_SUCCESS; |
| 3099 |
} |
| 3100 |
|
| 3101 |
MOS_STATUS MosInterface::DestroyVirtualEngineState( |
| 3102 |
MOS_STREAM_HANDLE streamState) |
| 3103 |
{ |
| 3104 |
MOS_OS_FUNCTION_ENTER; |
| 3105 |
|
| 3106 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 3107 |
if (streamState->virtualEngineInterface) |
| 3108 |
{ |
| 3109 |
streamState->virtualEngineInterface->Destroy(); |
| 3110 |
MOS_Delete(streamState->virtualEngineInterface); |
| 3111 |
} |
| 3112 |
|
| 3113 |
return MOS_STATUS_SUCCESS; |
| 3114 |
} |
| 3115 |
|
| 3116 |
MOS_STATUS MosInterface::SetVeHintParams( |
| 3117 |
MOS_STREAM_HANDLE streamState, |
| 3118 |
PMOS_VIRTUALENGINE_SET_PARAMS veParams) |
| 3119 |
{ |
| 3120 |
MOS_OS_FUNCTION_ENTER; |
| 3121 |
|
| 3122 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 3123 |
MOS_OS_CHK_NULL_RETURN(streamState->virtualEngineInterface); |
| 3124 |
|
| 3125 |
return streamState->virtualEngineInterface->SetHintParams(veParams); |
| 3126 |
} |
| 3127 |
|
| 3128 |
MOS_STATUS MosInterface::GetVeHintParams( |
| 3129 |
MOS_STREAM_HANDLE streamState, |
| 3130 |
bool scalableMode, |
| 3131 |
PMOS_VIRTUALENGINE_HINT_PARAMS* hintParams) |
| 3132 |
{ |
| 3133 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 3134 |
MOS_OS_CHK_NULL_RETURN(streamState->virtualEngineInterface); |
| 3135 |
MOS_OS_CHK_NULL_RETURN(hintParams); |
| 3136 |
|
| 3137 |
return streamState->virtualEngineInterface->GetHintParams(scalableMode, hintParams); |
| 3138 |
} |
| 3139 |
|
| 3140 |
MOS_STATUS MosInterface::SetHybridCmdMgrToGpuContext( |
| 3141 |
PMOS_INTERFACE pOsInterface, |
| 3142 |
uint64_t gpuCtxOnHybridCmd) |
| 3143 |
{ |
| 3144 |
return MOS_STATUS_SUCCESS; |
| 3145 |
} |
| 3146 |
|
| 3147 |
MOS_STATUS MosInterface::SetHybridCmdMgrSubmitMode( |
| 3148 |
PMOS_INTERFACE pOsInterface, |
| 3149 |
uint64_t hybridMgrSubmitMode) |
| 3150 |
{ |
| 3151 |
return MOS_STATUS_SUCCESS; |
| 3152 |
} |
| 3153 |
|
| 3154 |
MOS_STATUS MosInterface::StartHybridCmdMgr( |
| 3155 |
PMOS_INTERFACE pOsInterface) |
| 3156 |
{ |
| 3157 |
return MOS_STATUS_SUCCESS; |
| 3158 |
} |
| 3159 |
|
| 3160 |
MOS_STATUS MosInterface::StopHybridCmdMgr( |
| 3161 |
PMOS_INTERFACE pOsInterface) |
| 3162 |
{ |
| 3163 |
return MOS_STATUS_SUCCESS; |
| 3164 |
} |
| 3165 |
|
| 3166 |
MOS_STATUS MosInterface::SubmitPackage( |
| 3167 |
PMOS_INTERFACE pOsInterface, |
| 3168 |
CmdPackage &cmdPackage) |
| 3169 |
{ |
| 3170 |
return MOS_STATUS_SUCCESS; |
| 3171 |
} |
| 3172 |
|
| 3173 |
#if _DEBUG || _RELEASE_INTERNAL |
| 3174 |
|
| 3175 |
uint8_t |
| 3176 |
MosInterface::GetVeEngineCount( |
| 3177 |
MOS_STREAM_HANDLE streamState) |
| 3178 |
{ |
| 3179 |
return streamState && streamState->virtualEngineInterface ? |
| 3180 |
streamState->virtualEngineInterface->GetEngineCount() : 0; |
| 3181 |
} |
| 3182 |
|
| 3183 |
uint8_t MosInterface::GetEngineLogicId( |
| 3184 |
MOS_STREAM_HANDLE streamState, |
| 3185 |
uint32_t instanceIdx) |
| 3186 |
{ |
| 3187 |
return streamState && streamState->virtualEngineInterface ? |
| 3188 |
streamState->virtualEngineInterface->GetEngineLogicId(instanceIdx) : 0; |
| 3189 |
} |
| 3190 |
|
| 3191 |
MOS_STATUS MosInterface::SetGpuVirtualAddress( |
| 3192 |
PMOS_RESOURCE pResource, |
| 3193 |
uint64_t address) |
| 3194 |
{ |
| 3195 |
return MOS_STATUS_SUCCESS; |
| 3196 |
} |
| 3197 |
|
| 3198 |
#endif // _DEBUG || _RELEASE_INTERNAL |
| 3199 |
MOS_STATUS MosInterface::ComposeCommandBufferHeader( |
| 3200 |
MOS_STREAM_HANDLE streamState, |
| 3201 |
COMMAND_BUFFER_HANDLE cmdBuffer) |
| 3202 |
{ |
| 3203 |
MOS_OS_FUNCTION_ENTER; |
| 3204 |
|
| 3205 |
// No Command buffer header to compose |
| 3206 |
|
| 3207 |
return MOS_STATUS_SUCCESS; |
| 3208 |
} |
| 3209 |
|
| 3210 |
MOS_STATUS MosInterface::MosLoadLibrary( |
| 3211 |
MOS_STREAM_HANDLE streamState, |
| 3212 |
PCCHAR pFileName, |
| 3213 |
PHMODULE ppvModule) |
| 3214 |
{ |
| 3215 |
MOS_OS_FUNCTION_ENTER; |
| 3216 |
|
| 3217 |
MOS_UNUSED(streamState); |
| 3218 |
MOS_OS_ASSERT(pFileName); |
| 3219 |
return MosUtilities::MosLoadLibrary(pFileName, ppvModule); |
| 3220 |
} |
| 3221 |
|
| 3222 |
MOS_STATUS MosInterface::MosFreeLibrary(HMODULE hLibModule) |
| 3223 |
{ |
| 3224 |
MOS_OS_ASSERT(hLibModule); |
| 3225 |
|
| 3226 |
uint32_t ret = MosUtilities::MosFreeLibrary(hLibModule); |
| 3227 |
|
| 3228 |
return (ret == true) ? MOS_STATUS_SUCCESS : MOS_STATUS_UNKNOWN; |
| 3229 |
} |
| 3230 |
|
| 3231 |
GpuContextSpecificNext *MosInterface::GetGpuContext(MOS_STREAM_HANDLE streamState, GPU_CONTEXT_HANDLE handle) |
| 3232 |
{ |
| 3233 |
MOS_OS_FUNCTION_ENTER; |
| 3234 |
|
| 3235 |
if (streamState && streamState->osDeviceContext) |
| 3236 |
{ |
| 3237 |
auto osDeviceContext = streamState->osDeviceContext; |
| 3238 |
|
| 3239 |
auto gpuContextMgr = osDeviceContext->GetGpuContextMgr(); |
| 3240 |
if (gpuContextMgr) |
| 3241 |
{ |
| 3242 |
GpuContextNext *gpuCtx = gpuContextMgr->GetGpuContext(handle); |
| 3243 |
|
| 3244 |
return static_cast<GpuContextSpecificNext *>(gpuCtx); |
| 3245 |
} |
| 3246 |
} |
| 3247 |
|
| 3248 |
MOS_OS_ASSERTMESSAGE("GetGpuContext failed!"); |
| 3249 |
return nullptr; |
| 3250 |
} |
| 3251 |
|
| 3252 |
void MosInterface::SetPerfTag(MOS_STREAM_HANDLE streamState, uint32_t perfTag) |
| 3253 |
{ |
| 3254 |
MOS_OS_FUNCTION_ENTER; |
| 3255 |
|
| 3256 |
uint32_t componentTag; |
| 3257 |
|
| 3258 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState); |
| 3259 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState->perStreamParameters); |
| 3260 |
|
| 3261 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3262 |
PERF_DATA *perfData = osParameters->pPerfData; |
| 3263 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(perfData); |
| 3264 |
|
| 3265 |
switch (streamState->component) |
| 3266 |
{ |
| 3267 |
case COMPONENT_VPreP: |
| 3268 |
case COMPONENT_VPCommon: |
| 3269 |
componentTag = PERFTAG_VPREP; |
| 3270 |
break; |
| 3271 |
|
| 3272 |
case COMPONENT_LibVA: |
| 3273 |
componentTag = PERFTAG_LIBVA; |
| 3274 |
break; |
| 3275 |
|
| 3276 |
case COMPONENT_CM: |
| 3277 |
componentTag = PERFTAG_CM; |
| 3278 |
break; |
| 3279 |
|
| 3280 |
case COMPONENT_Decode: |
| 3281 |
componentTag = PERFTAG_DECODE; |
| 3282 |
break; |
| 3283 |
|
| 3284 |
case COMPONENT_Encode: |
| 3285 |
componentTag = PERFTAG_ENCODE; |
| 3286 |
break; |
| 3287 |
|
| 3288 |
case COMPONENT_MCPY: |
| 3289 |
componentTag = PERFTAG_VPREP; |
| 3290 |
break; |
| 3291 |
|
| 3292 |
default: |
| 3293 |
componentTag = 0xF000 & perfData->dmaBufID; |
| 3294 |
break; |
| 3295 |
} |
| 3296 |
|
| 3297 |
perfData->dmaBufID = componentTag | (perfTag & 0x0fff); |
| 3298 |
|
| 3299 |
return; |
| 3300 |
} |
| 3301 |
|
| 3302 |
int32_t MosInterface::IsPerfTagSet(MOS_STREAM_HANDLE streamState) |
| 3303 |
{ |
| 3304 |
uint32_t componentTag = 0; |
| 3305 |
int32_t ret = false; |
| 3306 |
|
| 3307 |
MOS_OS_FUNCTION_ENTER; |
| 3308 |
|
| 3309 |
if (streamState == nullptr || |
| 3310 |
streamState->perStreamParameters == nullptr) |
| 3311 |
{ |
| 3312 |
MOS_OS_ASSERTMESSAGE("streamState or perStreamParameters invalid nullptr"); |
| 3313 |
return false; |
| 3314 |
} |
| 3315 |
|
| 3316 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3317 |
|
| 3318 |
PERF_DATA *perfData = osParameters->pPerfData; |
| 3319 |
if (perfData == nullptr) |
| 3320 |
{ |
| 3321 |
MOS_OS_ASSERTMESSAGE("perfData invalid nullptr"); |
| 3322 |
return false; |
| 3323 |
} |
| 3324 |
|
| 3325 |
componentTag = 0xF000 & perfData->dmaBufID; |
| 3326 |
|
| 3327 |
switch (componentTag) |
| 3328 |
{ |
| 3329 |
case PERFTAG_ENCODE: |
| 3330 |
case PERFTAG_DECODE: |
| 3331 |
ret = true; |
| 3332 |
break; |
| 3333 |
|
| 3334 |
default: |
| 3335 |
ret = false; |
| 3336 |
break; |
| 3337 |
} |
| 3338 |
|
| 3339 |
return ret; |
| 3340 |
} |
| 3341 |
|
| 3342 |
void MosInterface::IncPerfFrameID(MOS_STREAM_HANDLE streamState) |
| 3343 |
{ |
| 3344 |
MOS_OS_FUNCTION_ENTER; |
| 3345 |
|
| 3346 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState); |
| 3347 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState->perStreamParameters); |
| 3348 |
|
| 3349 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3350 |
|
| 3351 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(osParameters->pPerfData); |
| 3352 |
|
| 3353 |
osParameters->pPerfData->frameID++; |
| 3354 |
|
| 3355 |
return; |
| 3356 |
} |
| 3357 |
|
| 3358 |
uint32_t MosInterface::GetPerfTag(MOS_STREAM_HANDLE streamState) |
| 3359 |
{ |
| 3360 |
uint32_t perfTag; |
| 3361 |
|
| 3362 |
MOS_OS_FUNCTION_ENTER; |
| 3363 |
|
| 3364 |
if (streamState == nullptr || |
| 3365 |
streamState->perStreamParameters == nullptr) |
| 3366 |
{ |
| 3367 |
MOS_OS_ASSERTMESSAGE("streamState or perStreamParameters invalid nullptr"); |
| 3368 |
return 0; |
| 3369 |
} |
| 3370 |
|
| 3371 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3372 |
|
| 3373 |
perfTag = *(uint32_t *)(osParameters->pPerfData); |
| 3374 |
return perfTag; |
| 3375 |
} |
| 3376 |
|
| 3377 |
void MosInterface::SetPerfHybridKernelID( |
| 3378 |
MOS_STREAM_HANDLE streamState, |
| 3379 |
uint32_t kernelID) |
| 3380 |
{ |
| 3381 |
MOS_OS_FUNCTION_ENTER; |
| 3382 |
|
| 3383 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState); |
| 3384 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState->perStreamParameters); |
| 3385 |
|
| 3386 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3387 |
PERF_DATA *perfData = osParameters->pPerfData; |
| 3388 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(perfData); |
| 3389 |
|
| 3390 |
perfData->dmaBufID = (perfData->dmaBufID & 0xF0FF) | ((kernelID << 8) & 0x0F00); |
| 3391 |
|
| 3392 |
return; |
| 3393 |
} |
| 3394 |
|
| 3395 |
void MosInterface::ResetPerfBufferID( |
| 3396 |
MOS_STREAM_HANDLE streamState) |
| 3397 |
{ |
| 3398 |
MOS_OS_FUNCTION_ENTER; |
| 3399 |
|
| 3400 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState); |
| 3401 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState->perStreamParameters); |
| 3402 |
|
| 3403 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3404 |
|
| 3405 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(osParameters->pPerfData); |
| 3406 |
|
| 3407 |
osParameters->pPerfData->bufferID = 0; |
| 3408 |
|
| 3409 |
return; |
| 3410 |
} |
| 3411 |
|
| 3412 |
void MosInterface::IncPerfBufferID( |
| 3413 |
MOS_STREAM_HANDLE streamState) |
| 3414 |
{ |
| 3415 |
MOS_OS_FUNCTION_ENTER; |
| 3416 |
|
| 3417 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState); |
| 3418 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(streamState->perStreamParameters); |
| 3419 |
|
| 3420 |
auto osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3421 |
|
| 3422 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(osParameters->pPerfData); |
| 3423 |
|
| 3424 |
osParameters->pPerfData->bufferID++; |
| 3425 |
|
| 3426 |
return; |
| 3427 |
} |
| 3428 |
|
| 3429 |
int32_t MosInterface::IsGPUHung( |
| 3430 |
MOS_STREAM_HANDLE streamState) |
| 3431 |
{ |
| 3432 |
uint32_t resetCount = 0; |
| 3433 |
uint32_t activeBatch = 0; |
| 3434 |
uint32_t pendingBatch = 0; |
| 3435 |
int32_t result = false; |
| 3436 |
int32_t ret = 0; |
| 3437 |
PMOS_CONTEXT osParameters = nullptr; |
| 3438 |
|
| 3439 |
MOS_OS_FUNCTION_ENTER; |
| 3440 |
|
| 3441 |
if (!streamState || !streamState->perStreamParameters) |
| 3442 |
{ |
| 3443 |
MOS_OS_ASSERTMESSAGE("invalid streamstate"); |
| 3444 |
return false; |
| 3445 |
} |
| 3446 |
|
| 3447 |
osParameters = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3448 |
|
| 3449 |
MOS_LINUX_CONTEXT *intel_i915_ctx = osParameters->intel_context; |
| 3450 |
auto gpuContext = MosInterface::GetGpuContext(streamState, streamState->currentGpuContextHandle); |
| 3451 |
if(gpuContext != nullptr && gpuContext->GetI915Context(0) != nullptr) |
| 3452 |
{ |
| 3453 |
intel_i915_ctx = gpuContext->GetI915Context(0); |
| 3454 |
} |
| 3455 |
|
| 3456 |
ret = mos_get_reset_stats(intel_i915_ctx, &resetCount, &activeBatch, &pendingBatch); |
| 3457 |
if (ret) |
| 3458 |
{ |
| 3459 |
MOS_OS_NORMALMESSAGE("mos_get_reset_stats return error(%d)\n", ret); |
| 3460 |
return false; |
| 3461 |
} |
| 3462 |
|
| 3463 |
//Chip reset will count this value, but maybe caused by ctx in other process. |
| 3464 |
//In this case, reset has no impact on current process |
| 3465 |
if (resetCount != streamState->gpuResetCount) |
| 3466 |
{ |
| 3467 |
streamState->gpuResetCount = resetCount; |
| 3468 |
} |
| 3469 |
|
| 3470 |
//Thses two values are ctx specific, it must reset in current process if either changes |
| 3471 |
if (activeBatch != streamState->gpuActiveBatch || |
| 3472 |
pendingBatch != streamState->gpuPendingBatch) |
| 3473 |
{ |
| 3474 |
streamState->gpuActiveBatch = activeBatch; |
| 3475 |
streamState->gpuPendingBatch = pendingBatch; |
| 3476 |
result = true; |
| 3477 |
} |
| 3478 |
else |
| 3479 |
{ |
| 3480 |
result = false; |
| 3481 |
} |
| 3482 |
return result; |
| 3483 |
} |
| 3484 |
|
| 3485 |
bool MosInterface::IsSetMarkerEnabled( |
| 3486 |
MOS_STREAM_HANDLE streamState) |
| 3487 |
{ |
| 3488 |
return false; |
| 3489 |
} |
| 3490 |
|
| 3491 |
PMOS_RESOURCE MosInterface::GetMarkerResource( |
| 3492 |
MOS_STREAM_HANDLE streamState) |
| 3493 |
{ |
| 3494 |
return nullptr; |
| 3495 |
} |
| 3496 |
|
| 3497 |
void MosInterface::MosResetResource(PMOS_RESOURCE resource) |
| 3498 |
{ |
| 3499 |
int32_t i = 0; |
| 3500 |
|
| 3501 |
MOS_OS_FUNCTION_ENTER; |
| 3502 |
|
| 3503 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(resource); |
| 3504 |
|
| 3505 |
MOS_ZeroMemory(resource, sizeof(MOS_RESOURCE)); |
| 3506 |
resource->Format = Format_None; |
| 3507 |
for (i = 0; i < MOS_GPU_CONTEXT_MAX; i++) |
| 3508 |
{ |
| 3509 |
resource->iAllocationIndex[i] = MOS_INVALID_ALLOC_INDEX; |
| 3510 |
} |
| 3511 |
return; |
| 3512 |
} |
| 3513 |
|
| 3514 |
bool MosInterface::MosResourceIsNull(PMOS_RESOURCE resource) |
| 3515 |
{ |
| 3516 |
if( nullptr == resource ) |
| 3517 |
{ |
| 3518 |
MOS_OS_NORMALMESSAGE("found pOsResource nullptr\n"); |
| 3519 |
return true; |
| 3520 |
} |
| 3521 |
|
| 3522 |
return ((resource->bo == nullptr) |
| 3523 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 3524 |
&& ((resource->pData == nullptr) ) |
| 3525 |
#endif // (_DEBUG || _RELEASE_INTERNAL) |
| 3526 |
); |
| 3527 |
} |
| 3528 |
|
| 3529 |
MOS_STATUS MosInterface::GetGmmResourceInfo(PMOS_RESOURCE resource) |
| 3530 |
{ |
| 3531 |
return MOS_STATUS_SUCCESS; |
| 3532 |
} |
| 3533 |
|
| 3534 |
int MosInterface::GetPlaneSurfaceOffset(const MOS_PLANE_OFFSET &planeOffset) |
| 3535 |
{ |
| 3536 |
return planeOffset.iSurfaceOffset; |
| 3537 |
} |
| 3538 |
|
| 3539 |
uint32_t MosInterface::GetResourceArrayIndex( |
| 3540 |
PMOS_RESOURCE resource) |
| 3541 |
{ |
| 3542 |
return 0; |
| 3543 |
} |
| 3544 |
|
| 3545 |
MOS_STATUS MosInterface::SetupCurrentCmdListAndPoolFromOsInterface( |
| 3546 |
PMOS_INTERFACE pMosInterface, |
| 3547 |
MOS_STREAM_HANDLE streamState) |
| 3548 |
{ |
| 3549 |
return MOS_STATUS_SUCCESS; |
| 3550 |
} |
| 3551 |
|
| 3552 |
uint64_t MosInterface::GetResourceHandle(MOS_STREAM_HANDLE streamState, PMOS_RESOURCE osResource) |
| 3553 |
{ |
| 3554 |
if (osResource && osResource->bo) |
| 3555 |
{ |
| 3556 |
return osResource->bo->handle; |
| 3557 |
} |
| 3558 |
else |
| 3559 |
{ |
| 3560 |
return 0; |
| 3561 |
} |
| 3562 |
} |
| 3563 |
|
| 3564 |
MediaUserSettingSharedPtr MosInterface::MosGetUserSettingInstance( |
| 3565 |
PMOS_CONTEXT osContext) |
| 3566 |
{ |
| 3567 |
if (osContext == nullptr) |
| 3568 |
{ |
| 3569 |
MOS_OS_NORMALMESSAGE("Null usersetting PTR"); |
| 3570 |
return nullptr; |
| 3571 |
} |
| 3572 |
|
| 3573 |
return osContext->m_userSettingPtr; |
| 3574 |
} |
| 3575 |
|
| 3576 |
MediaUserSettingSharedPtr MosInterface::MosGetUserSettingInstance( |
| 3577 |
MOS_STREAM_HANDLE streamState) |
| 3578 |
{ |
| 3579 |
PMOS_CONTEXT mosContext = nullptr; |
| 3580 |
if (streamState == nullptr) |
| 3581 |
{ |
| 3582 |
MOS_OS_NORMALMESSAGE("Null usersetting PTR"); |
| 3583 |
return nullptr; |
| 3584 |
} |
| 3585 |
mosContext = (PMOS_CONTEXT)streamState->perStreamParameters; |
| 3586 |
return MosGetUserSettingInstance(mosContext); |
| 3587 |
} |
| 3588 |
|
| 3589 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 3590 |
MOS_STATUS MosInterface::DumpCommandBufferInit( |
| 3591 |
MOS_STREAM_HANDLE streamState) |
| 3592 |
{ |
| 3593 |
char sFileName[MOS_MAX_HLT_FILENAME_LEN] = {0}; |
| 3594 |
MOS_STATUS eStatus = MOS_STATUS_UNKNOWN; |
| 3595 |
uint32_t value = 0; |
| 3596 |
size_t nSizeFileNamePrefix = 0; |
| 3597 |
MediaUserSettingSharedPtr userSettingPtr = MosInterface::MosGetUserSettingInstance(streamState); |
| 3598 |
|
| 3599 |
MOS_OS_CHK_NULL_RETURN(streamState); |
| 3600 |
|
| 3601 |
// Check if command buffer dump was enabled in user feature. |
| 3602 |
ReadUserSetting( |
| 3603 |
userSettingPtr, |
| 3604 |
value, |
| 3605 |
__MEDIA_USER_FEATURE_VALUE_DUMP_COMMAND_BUFFER_ENABLE, |
| 3606 |
MediaUserSetting::Group::Device); |
| 3607 |
|
| 3608 |
streamState->dumpCommandBuffer = (value != 0); |
| 3609 |
streamState->dumpCommandBufferToFile = ((value & 1) != 0); |
| 3610 |
streamState->dumpCommandBufferAsMessages = ((value & 2) != 0); |
| 3611 |
|
| 3612 |
if (streamState->dumpCommandBufferToFile) |
| 3613 |
{ |
| 3614 |
// Create output directory. |
| 3615 |
eStatus = MosUtilDebug::MosLogFileNamePrefix(streamState->sDirName, userSettingPtr); |
| 3616 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 3617 |
{ |
| 3618 |
MOS_OS_NORMALMESSAGE("Failed to create log file prefix. Status = %d", eStatus); |
| 3619 |
return eStatus; |
| 3620 |
} |
| 3621 |
|
| 3622 |
memcpy(sFileName, streamState->sDirName, MOS_MAX_HLT_FILENAME_LEN); |
| 3623 |
nSizeFileNamePrefix = strnlen(sFileName, sizeof(sFileName)); |
| 3624 |
MOS_SecureStringPrint( |
| 3625 |
sFileName + nSizeFileNamePrefix, |
| 3626 |
sizeof(sFileName) - nSizeFileNamePrefix, |
| 3627 |
sizeof(sFileName) - nSizeFileNamePrefix, |
| 3628 |
"%c%s", |
| 3629 |
MOS_DIR_SEPERATOR, |
| 3630 |
MOS_COMMAND_BUFFER_OUT_DIR); |
| 3631 |
|
| 3632 |
eStatus = MosUtilities::MosCreateDirectory(sFileName); |
| 3633 |
if (eStatus != MOS_STATUS_SUCCESS) |
| 3634 |
{ |
| 3635 |
MOS_OS_NORMALMESSAGE("Failed to create output directory. Status = %d", eStatus); |
| 3636 |
return eStatus; |
| 3637 |
} |
| 3638 |
} |
| 3639 |
|
| 3640 |
return MOS_STATUS_SUCCESS; |
| 3641 |
} |
| 3642 |
#endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 3643 |
|
| 3644 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 3645 |
|
| 3646 |
uint32_t MosInterface::m_mosOsApiFailSimulateType = 0; |
| 3647 |
uint32_t MosInterface::m_mosOsApiFailSimulateMode = 0; |
| 3648 |
uint32_t MosInterface::m_mosOsApiFailSimulateFreq = 0; |
| 3649 |
uint32_t MosInterface::m_mosOsApiFailSimulateHint = 0; |
| 3650 |
uint32_t MosInterface::m_mosOsApiFailSimulateCounter = 0; |
| 3651 |
|
| 3652 |
void MosInterface::MosInitOsApiFailSimulateFlag(MediaUserSettingSharedPtr userSettingPtr) |
| 3653 |
{ |
| 3654 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3655 |
uint32_t value = 0; |
| 3656 |
|
| 3657 |
//default off for simulate random fail |
| 3658 |
m_mosOsApiFailSimulateType = OS_API_FAIL_TYPE_NONE; |
| 3659 |
m_mosOsApiFailSimulateMode = OS_API_FAIL_SIMULATE_MODE_DEFAULT; |
| 3660 |
m_mosOsApiFailSimulateFreq = 0; |
| 3661 |
m_mosOsApiFailSimulateHint = 0; |
| 3662 |
m_mosOsApiFailSimulateCounter = 0; |
| 3663 |
|
| 3664 |
// Read Config : memory allocation failure simulate mode |
| 3665 |
ReadUserSetting( |
| 3666 |
userSettingPtr, |
| 3667 |
value, |
| 3668 |
__MEDIA_USER_FEATURE_VALUE_OS_API_FAIL_SIMULATE_TYPE, |
| 3669 |
MediaUserSetting::Group::Device); |
| 3670 |
|
| 3671 |
if (value & OS_API_FAIL_TYPE_MAX) |
| 3672 |
{ |
| 3673 |
m_mosOsApiFailSimulateType = value; |
| 3674 |
MOS_OS_NORMALMESSAGE("Init MosSimulateOsApiFailSimulateType as %d \n ", m_mosOsApiFailSimulateType); |
| 3675 |
} |
| 3676 |
else |
| 3677 |
{ |
| 3678 |
m_mosOsApiFailSimulateType = OS_API_FAIL_TYPE_NONE; |
| 3679 |
MOS_OS_NORMALMESSAGE("Invalid OS API Fail Simulate Type from config: %d \n ", value); |
| 3680 |
} |
| 3681 |
|
| 3682 |
// Read Config : memory allocation failure simulate mode |
| 3683 |
value = 0; |
| 3684 |
ReadUserSetting( |
| 3685 |
userSettingPtr, |
| 3686 |
value, |
| 3687 |
__MEDIA_USER_FEATURE_VALUE_OS_API_FAIL_SIMULATE_MODE, |
| 3688 |
MediaUserSetting::Group::Device); |
| 3689 |
if ((value == OS_API_FAIL_SIMULATE_MODE_DEFAULT) || |
| 3690 |
(value == OS_API_FAIL_SIMULATE_MODE_RANDOM) || |
| 3691 |
(value == OS_API_FAIL_SIMULATE_MODE_TRAVERSE)) |
| 3692 |
{ |
| 3693 |
m_mosOsApiFailSimulateMode = value; |
| 3694 |
MOS_OS_NORMALMESSAGE("Init MosSimulateOsApiFailSimulateMode as %d \n ", m_mosOsApiFailSimulateMode); |
| 3695 |
} |
| 3696 |
else |
| 3697 |
{ |
| 3698 |
m_mosOsApiFailSimulateMode = OS_API_FAIL_SIMULATE_MODE_DEFAULT; |
| 3699 |
MOS_OS_NORMALMESSAGE("Invalid OS API Fail Simulate Mode from config: %d \n ", value); |
| 3700 |
} |
| 3701 |
|
| 3702 |
// Read Config : memory allocation failure simulate frequence |
| 3703 |
value = 0; |
| 3704 |
ReadUserSetting( |
| 3705 |
userSettingPtr, |
| 3706 |
value, |
| 3707 |
__MEDIA_USER_FEATURE_VALUE_OS_API_FAIL_SIMULATE_FREQ, |
| 3708 |
MediaUserSetting::Group::Device); |
| 3709 |
if ((value >= MIN_OS_API_FAIL_FREQ) && |
| 3710 |
(value <= MAX_OS_API_FAIL_FREQ)) |
| 3711 |
{ |
| 3712 |
m_mosOsApiFailSimulateFreq = value; |
| 3713 |
MOS_OS_NORMALMESSAGE("Init m_MosSimulateRandomOsApiFailFreq as %d \n ", m_mosOsApiFailSimulateFreq); |
| 3714 |
|
| 3715 |
if (m_mosOsApiFailSimulateMode == OS_API_FAIL_SIMULATE_MODE_RANDOM) |
| 3716 |
{ |
| 3717 |
srand((unsigned int)time(nullptr)); |
| 3718 |
} |
| 3719 |
} |
| 3720 |
else |
| 3721 |
{ |
| 3722 |
m_mosOsApiFailSimulateFreq = 0; |
| 3723 |
MOS_OS_NORMALMESSAGE("Invalid OS API Fail Simulate Freq from config: %d \n ", value); |
| 3724 |
} |
| 3725 |
|
| 3726 |
// Read Config : memory allocation failure simulate counter |
| 3727 |
value = 0; |
| 3728 |
ReadUserSetting( |
| 3729 |
userSettingPtr, |
| 3730 |
value, |
| 3731 |
__MEDIA_USER_FEATURE_VALUE_OS_API_FAIL_SIMULATE_HINT, |
| 3732 |
MediaUserSetting::Group::Device); |
| 3733 |
if (value <= m_mosOsApiFailSimulateFreq) |
| 3734 |
{ |
| 3735 |
m_mosOsApiFailSimulateHint = value; |
| 3736 |
MOS_OS_NORMALMESSAGE("Init m_MosOsApiFailSimulateHint as %d \n ", m_mosOsApiFailSimulateHint); |
| 3737 |
} |
| 3738 |
else |
| 3739 |
{ |
| 3740 |
m_mosOsApiFailSimulateHint = m_mosOsApiFailSimulateFreq; |
| 3741 |
MOS_OS_NORMALMESSAGE("Set m_mosOsApiFailSimulateHint as %d since INVALID CONFIG %d \n ", m_mosOsApiFailSimulateHint, value); |
| 3742 |
} |
| 3743 |
} |
| 3744 |
|
| 3745 |
void MosInterface::MosDeinitOsApiFailSimulateFlag() |
| 3746 |
{ |
| 3747 |
//default off for simulate fail |
| 3748 |
m_mosOsApiFailSimulateType = OS_API_FAIL_TYPE_NONE; |
| 3749 |
m_mosOsApiFailSimulateMode = OS_API_FAIL_SIMULATE_MODE_DEFAULT; |
| 3750 |
m_mosOsApiFailSimulateFreq = 0; |
| 3751 |
m_mosOsApiFailSimulateHint = 0; |
| 3752 |
m_mosOsApiFailSimulateCounter = 0; |
| 3753 |
} |
| 3754 |
|
| 3755 |
bool MosInterface::MosSimulateOsApiFail( |
| 3756 |
OS_API_FAIL_TYPE type, |
| 3757 |
const char *functionName, |
| 3758 |
const char *filename, |
| 3759 |
int32_t line) |
| 3760 |
{ |
| 3761 |
bool bSimulateOsApiFail = false; |
| 3762 |
|
| 3763 |
if (!MosOsApiFailSimulationEnabled(type)) |
| 3764 |
{ |
| 3765 |
return false; |
| 3766 |
} |
| 3767 |
|
| 3768 |
if (m_mosOsApiFailSimulateMode == OS_API_FAIL_SIMULATE_MODE_RANDOM) |
| 3769 |
{ |
| 3770 |
int32_t Rn = rand(); |
| 3771 |
m_mosOsApiFailSimulateCounter++; |
| 3772 |
if (Rn % m_mosOsApiFailSimulateFreq == 1) |
| 3773 |
{ |
| 3774 |
bSimulateOsApiFail = true; |
| 3775 |
MOS_DEBUGMESSAGE(MOS_MESSAGE_LVL_CRITICAL, MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, |
| 3776 |
"Simulated OS API(Type %d) Fail (Rn=%d, SimulateAllocCounter=%d) for: functionName: %s, filename: %s, line: %d\n", |
| 3777 |
m_mosOsApiFailSimulateType, Rn, m_mosOsApiFailSimulateCounter, functionName, filename, line); |
| 3778 |
} |
| 3779 |
else |
| 3780 |
{ |
| 3781 |
bSimulateOsApiFail = false; |
| 3782 |
} |
| 3783 |
} |
| 3784 |
else if (m_mosOsApiFailSimulateMode == OS_API_FAIL_SIMULATE_MODE_TRAVERSE) |
| 3785 |
{ |
| 3786 |
if (m_mosOsApiFailSimulateCounter++ == m_mosOsApiFailSimulateHint) |
| 3787 |
{ |
| 3788 |
MOS_DEBUGMESSAGE(MOS_MESSAGE_LVL_CRITICAL, MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, |
| 3789 |
"Simulated OS API(Type %d) Fail (hint=%d) for: functionName: %s, filename: %s, line: %d\n", |
| 3790 |
m_mosOsApiFailSimulateType, m_mosOsApiFailSimulateHint, functionName, filename, line); |
| 3791 |
bSimulateOsApiFail = true; |
| 3792 |
} |
| 3793 |
else |
| 3794 |
{ |
| 3795 |
bSimulateOsApiFail = false; |
| 3796 |
} |
| 3797 |
} |
| 3798 |
else |
| 3799 |
{ |
| 3800 |
//MOS_OS_NORMALMESSAGE("Invalid m_mosOsApiFailSimulateMode: %d \n ", m_mosOsApiFailSimulateMode); |
| 3801 |
bSimulateOsApiFail = false; |
| 3802 |
} |
| 3803 |
|
| 3804 |
return bSimulateOsApiFail; |
| 3805 |
} |
| 3806 |
#endif // #if (_DEBUG || _RELEASE_INTERNAL) |
| 3807 |
|
| 3808 |
bool MosInterface::IsAsyncDevice(MOS_STREAM_HANDLE streamState) |
| 3809 |
{ |
| 3810 |
return false; |
| 3811 |
} |
| 3812 |
|
| 3813 |
MOS_FORMAT MosInterface::GmmFmtToMosFmt( |
| 3814 |
GMM_RESOURCE_FORMAT format) |
| 3815 |
{ |
| 3816 |
static const std::map<GMM_RESOURCE_FORMAT, MOS_FORMAT> gmm2MosFmtMap = { |
| 3817 |
{GMM_FORMAT_B8G8R8X8_UNORM_TYPE, Format_X8R8G8B8}, |
| 3818 |
{GMM_FORMAT_R8G8B8A8_UNORM_TYPE, Format_A8B8G8R8}, |
| 3819 |
{GMM_FORMAT_B8G8R8A8_UNORM_TYPE, Format_A8R8G8B8}, |
| 3820 |
{GMM_FORMAT_B5G6R5_UNORM_TYPE, Format_R5G6B5}, |
| 3821 |
{GMM_FORMAT_R8G8B8_UNORM, Format_R8G8B8}, |
| 3822 |
{GMM_FORMAT_R8G8B8_UINT_TYPE, Format_R8G8B8}, |
| 3823 |
{GMM_FORMAT_R32_UINT_TYPE, Format_R32U}, |
| 3824 |
{GMM_FORMAT_R32_FLOAT_TYPE, Format_R32F}, |
| 3825 |
{GMM_FORMAT_MEDIA_Y8_UNORM, Format_Y8}, |
| 3826 |
{GMM_FORMAT_MEDIA_Y1_UNORM, Format_Y8}, |
| 3827 |
{GMM_FORMAT_MEDIA_Y16_UNORM, Format_Y16U}, |
| 3828 |
{GMM_FORMAT_MEDIA_Y16_SNORM, Format_Y16S}, |
| 3829 |
{GMM_FORMAT_YUY2_2x1, Format_YUY2}, |
| 3830 |
{GMM_FORMAT_YUY2, Format_YUY2}, |
| 3831 |
{GMM_FORMAT_P8, Format_P8}, |
| 3832 |
{GMM_FORMAT_R16_UNORM_TYPE, Format_R16UN}, |
| 3833 |
{GMM_FORMAT_A8_UNORM_TYPE, Format_A8}, |
| 3834 |
{GMM_FORMAT_GENERIC_8BIT, Format_L8}, |
| 3835 |
{GMM_FORMAT_L16_UNORM_TYPE, Format_L16}, |
| 3836 |
{GMM_FORMAT_GENERIC_16BIT_TYPE, Format_D16}, |
| 3837 |
{GMM_FORMAT_YVYU, Format_YVYU}, |
| 3838 |
{GMM_FORMAT_UYVY, Format_UYVY}, |
| 3839 |
{GMM_FORMAT_VYUY_2x1, Format_VYUY}, |
| 3840 |
{GMM_FORMAT_VYUY, Format_VYUY}, |
| 3841 |
{GMM_FORMAT_P016_TYPE, Format_P016}, |
| 3842 |
{GMM_FORMAT_P010_TYPE, Format_P010}, |
| 3843 |
{GMM_FORMAT_NV12_TYPE, Format_NV12}, |
| 3844 |
{GMM_FORMAT_NV11_TYPE, Format_NV11}, |
| 3845 |
{GMM_FORMAT_P208_TYPE, Format_P208}, |
| 3846 |
{GMM_FORMAT_IMC1_TYPE, Format_IMC1}, |
| 3847 |
{GMM_FORMAT_IMC2_TYPE, Format_IMC2}, |
| 3848 |
{GMM_FORMAT_IMC3_TYPE, Format_IMC3}, |
| 3849 |
{GMM_FORMAT_IMC4_TYPE, Format_IMC4}, |
| 3850 |
{GMM_FORMAT_I420_TYPE, Format_I420}, |
| 3851 |
{GMM_FORMAT_IYUV_TYPE, Format_IYUV}, |
| 3852 |
{GMM_FORMAT_YV12_TYPE, Format_YV12}, |
| 3853 |
{GMM_FORMAT_YVU9_TYPE, Format_YVU9}, |
| 3854 |
{GMM_FORMAT_R8_UNORM_TYPE, Format_R8UN}, |
| 3855 |
{GMM_FORMAT_R16_UINT_TYPE, Format_R16U}, |
| 3856 |
{GMM_FORMAT_R8G8_SNORM, Format_V8U8}, |
| 3857 |
{GMM_FORMAT_R8_UINT_TYPE, Format_R8U}, |
| 3858 |
{GMM_FORMAT_R32_SINT, Format_R32S}, |
| 3859 |
{GMM_FORMAT_R8G8_UNORM_TYPE, Format_R8G8UN}, |
| 3860 |
{GMM_FORMAT_R16_SINT_TYPE, Format_R16S}, |
| 3861 |
{GMM_FORMAT_R16G16B16A16_UNORM_TYPE, Format_A16B16G16R16}, |
| 3862 |
{GMM_FORMAT_R16G16B16A16_FLOAT_TYPE, Format_A16B16G16R16F}, |
| 3863 |
{GMM_FORMAT_R10G10B10A2_UNORM_TYPE, Format_R10G10B10A2}, |
| 3864 |
{GMM_FORMAT_B10G10R10A2_UNORM_TYPE, Format_B10G10R10A2}, |
| 3865 |
{GMM_FORMAT_MFX_JPEG_YUV422H_TYPE, Format_422H}, |
| 3866 |
{GMM_FORMAT_MFX_JPEG_YUV411_TYPE, Format_411P}, |
| 3867 |
{GMM_FORMAT_MFX_JPEG_YUV422V_TYPE, Format_422V}, |
| 3868 |
{GMM_FORMAT_MFX_JPEG_YUV444_TYPE, Format_444P}, |
| 3869 |
{GMM_FORMAT_BAYER_BGGR16, Format_IRW0}, |
| 3870 |
{GMM_FORMAT_BAYER_RGGB16, Format_IRW1}, |
| 3871 |
{GMM_FORMAT_BAYER_GRBG16, Format_IRW2}, |
| 3872 |
{GMM_FORMAT_BAYER_GBRG16, Format_IRW3}, |
| 3873 |
{GMM_FORMAT_R8G8B8A8_UINT_TYPE, Format_AYUV}, |
| 3874 |
{GMM_FORMAT_AYUV, Format_AYUV}, |
| 3875 |
{GMM_FORMAT_R16G16_UNORM_TYPE, Format_R16G16UN}, |
| 3876 |
{GMM_FORMAT_R16_FLOAT, Format_R16F}, |
| 3877 |
{GMM_FORMAT_Y416_TYPE, Format_Y416}, |
| 3878 |
{GMM_FORMAT_Y410_TYPE, Format_Y410}, |
| 3879 |
{GMM_FORMAT_Y210_TYPE, Format_Y210}, |
| 3880 |
{GMM_FORMAT_Y216_TYPE, Format_Y216}, |
| 3881 |
{GMM_FORMAT_MFX_JPEG_YUV411R_TYPE, Format_411R}, |
| 3882 |
{GMM_FORMAT_RGBP_TYPE, Format_RGBP}, |
| 3883 |
{GMM_FORMAT_BGRP_TYPE, Format_RGBP}, |
| 3884 |
{GMM_FORMAT_R24_UNORM_X8_TYPELESS, Format_D24S8UN}, |
| 3885 |
{GMM_FORMAT_R32_FLOAT_X8X24_TYPELESS, Format_D32S8X24_FLOAT}, |
| 3886 |
{GMM_FORMAT_R16G16_SINT_TYPE, Format_R16G16S}, |
| 3887 |
{GMM_FORMAT_R32G32B32A32_FLOAT, Format_R32G32B32A32F}, |
| 3888 |
{GMM_FORMAT_R8G8_UNORM_TYPE, Format_R8G8UN}}; |
| 3889 |
|
| 3890 |
auto iter = gmm2MosFmtMap.find(format); |
| 3891 |
if (iter != gmm2MosFmtMap.end()) |
| 3892 |
{ |
| 3893 |
return iter->second; |
| 3894 |
} |
| 3895 |
return Format_Invalid; |
| 3896 |
} |
| 3897 |
|
| 3898 |
GMM_RESOURCE_FORMAT MosInterface::MosFmtToGmmFmt(MOS_FORMAT format) |
| 3899 |
{ |
| 3900 |
static const std::map<MOS_FORMAT, GMM_RESOURCE_FORMAT> mos2GmmFmtMap = { |
| 3901 |
{Format_Buffer, GMM_FORMAT_GENERIC_8BIT}, |
| 3902 |
{Format_Buffer_2D, GMM_FORMAT_GENERIC_8BIT}, |
| 3903 |
{Format_L8, GMM_FORMAT_GENERIC_8BIT}, |
| 3904 |
{Format_L16, GMM_FORMAT_L16_UNORM_TYPE}, |
| 3905 |
{Format_STMM, GMM_FORMAT_MEDIA_Y8_UNORM}, |
| 3906 |
{Format_AI44, GMM_FORMAT_GENERIC_8BIT}, |
| 3907 |
{Format_IA44, GMM_FORMAT_GENERIC_8BIT}, |
| 3908 |
{Format_R5G6B5, GMM_FORMAT_B5G6R5_UNORM_TYPE}, |
| 3909 |
{Format_R8G8B8, GMM_FORMAT_R8G8B8_UNORM}, |
| 3910 |
{Format_X8R8G8B8, GMM_FORMAT_B8G8R8X8_UNORM_TYPE}, |
| 3911 |
{Format_A8R8G8B8, GMM_FORMAT_B8G8R8A8_UNORM_TYPE}, |
| 3912 |
{Format_X8B8G8R8, GMM_FORMAT_R8G8B8X8_UNORM_TYPE}, |
| 3913 |
{Format_A8B8G8R8, GMM_FORMAT_R8G8B8A8_UNORM_TYPE}, |
| 3914 |
{Format_R32F, GMM_FORMAT_R32_FLOAT_TYPE}, |
| 3915 |
{Format_V8U8, GMM_FORMAT_GENERIC_16BIT}, // matching size as format |
| 3916 |
{Format_YUY2, GMM_FORMAT_YUY2}, |
| 3917 |
{Format_UYVY, GMM_FORMAT_UYVY}, |
| 3918 |
{Format_P8, GMM_FORMAT_RENDER_8BIT_TYPE}, // matching size as format |
| 3919 |
{Format_A8, GMM_FORMAT_A8_UNORM_TYPE}, |
| 3920 |
{Format_AYUV, GMM_FORMAT_AYUV_TYPE}, |
| 3921 |
{Format_NV12, GMM_FORMAT_NV12_TYPE}, |
| 3922 |
{Format_NV21, GMM_FORMAT_NV21_TYPE}, |
| 3923 |
{Format_YV12, GMM_FORMAT_YV12_TYPE}, |
| 3924 |
{Format_R32U, GMM_FORMAT_R32_UINT_TYPE}, |
| 3925 |
{Format_R32S, GMM_FORMAT_R32_SINT_TYPE}, |
| 3926 |
{Format_RAW, GMM_FORMAT_GENERIC_8BIT}, |
| 3927 |
{Format_444P, GMM_FORMAT_MFX_JPEG_YUV444_TYPE}, |
| 3928 |
{Format_422H, GMM_FORMAT_MFX_JPEG_YUV422H_TYPE}, |
| 3929 |
{Format_422V, GMM_FORMAT_MFX_JPEG_YUV422V_TYPE}, |
| 3930 |
{Format_IMC3, GMM_FORMAT_IMC3_TYPE}, |
| 3931 |
{Format_411P, GMM_FORMAT_MFX_JPEG_YUV411_TYPE}, |
| 3932 |
{Format_411R, GMM_FORMAT_MFX_JPEG_YUV411R_TYPE}, |
| 3933 |
{Format_RGBP, GMM_FORMAT_RGBP_TYPE}, |
| 3934 |
{Format_BGRP, GMM_FORMAT_BGRP_TYPE}, |
| 3935 |
{Format_R8U, GMM_FORMAT_R8_UINT_TYPE}, |
| 3936 |
{Format_R8UN, GMM_FORMAT_R8_UNORM}, |
| 3937 |
{Format_R16U, GMM_FORMAT_R16_UINT_TYPE}, |
| 3938 |
{Format_R16F, GMM_FORMAT_R16_FLOAT_TYPE}, |
| 3939 |
{Format_P010, GMM_FORMAT_P010_TYPE}, |
| 3940 |
{Format_P016, GMM_FORMAT_P016_TYPE}, |
| 3941 |
{Format_Y216, GMM_FORMAT_Y216_TYPE}, |
| 3942 |
{Format_Y416, GMM_FORMAT_Y416_TYPE}, |
| 3943 |
{Format_P208, GMM_FORMAT_P208_TYPE}, |
| 3944 |
{Format_A16B16G16R16, GMM_FORMAT_R16G16B16A16_UNORM_TYPE}, |
| 3945 |
{Format_Y210, GMM_FORMAT_Y210_TYPE}, |
| 3946 |
{Format_Y410, GMM_FORMAT_Y410_TYPE}, |
| 3947 |
{Format_R10G10B10A2, GMM_FORMAT_R10G10B10A2_UNORM_TYPE}, |
| 3948 |
{Format_B10G10R10A2, GMM_FORMAT_B10G10R10A2_UNORM_TYPE}, |
| 3949 |
{Format_A16B16G16R16F, GMM_FORMAT_R16G16B16A16_FLOAT}, |
| 3950 |
{Format_R32G32B32A32F, GMM_FORMAT_R32G32B32A32_FLOAT}, |
| 3951 |
{Format_R8G8UN, GMM_FORMAT_R8G8_UNORM_TYPE} |
| 3952 |
}; |
| 3953 |
|
| 3954 |
auto iter = mos2GmmFmtMap.find(format); |
| 3955 |
if (iter != mos2GmmFmtMap.end()) |
| 3956 |
{ |
| 3957 |
return iter->second; |
| 3958 |
} |
| 3959 |
return GMM_FORMAT_INVALID; |
| 3960 |
|
| 3961 |
} |
| 3962 |
|
| 3963 |
uint32_t MosInterface::MosFmtToOsFmt(MOS_FORMAT format) |
| 3964 |
{ |
| 3965 |
static const std::map<MOS_FORMAT, MOS_OS_FORMAT> mos2OsFmtMap = { |
| 3966 |
{Format_A8R8G8B8, (MOS_OS_FORMAT)DDI_FORMAT_A8R8G8B8}, |
| 3967 |
{Format_X8R8G8B8, (MOS_OS_FORMAT)DDI_FORMAT_X8R8G8B8}, |
| 3968 |
{Format_A8B8G8R8, (MOS_OS_FORMAT)DDI_FORMAT_A8B8G8R8}, |
| 3969 |
{Format_R32U, (MOS_OS_FORMAT)DDI_FORMAT_R32F}, |
| 3970 |
{Format_R32F, (MOS_OS_FORMAT)DDI_FORMAT_R32F}, |
| 3971 |
{Format_R5G6B5, (MOS_OS_FORMAT)DDI_FORMAT_R5G6B5}, |
| 3972 |
{Format_YUY2, (MOS_OS_FORMAT)DDI_FORMAT_YUY2}, |
| 3973 |
{Format_P8, (MOS_OS_FORMAT)DDI_FORMAT_P8}, |
| 3974 |
{Format_A8P8, (MOS_OS_FORMAT)DDI_FORMAT_A8P8}, |
| 3975 |
{Format_A8, (MOS_OS_FORMAT)DDI_FORMAT_A8}, |
| 3976 |
{Format_L8, (MOS_OS_FORMAT)DDI_FORMAT_L8}, |
| 3977 |
{Format_L16, (MOS_OS_FORMAT)DDI_FORMAT_L16}, |
| 3978 |
{Format_A4L4, (MOS_OS_FORMAT)DDI_FORMAT_A4L4}, |
| 3979 |
{Format_A8L8, (MOS_OS_FORMAT)DDI_FORMAT_A8L8}, |
| 3980 |
{Format_V8U8, (MOS_OS_FORMAT)DDI_FORMAT_V8U8}, |
| 3981 |
{Format_YVYU, (MOS_OS_FORMAT)FOURCC_YVYU}, |
| 3982 |
{Format_UYVY, (MOS_OS_FORMAT)FOURCC_UYVY}, |
| 3983 |
{Format_VYUY, (MOS_OS_FORMAT)FOURCC_VYUY}, |
| 3984 |
{Format_AYUV, (MOS_OS_FORMAT)FOURCC_AYUV}, |
| 3985 |
{Format_NV12, (MOS_OS_FORMAT)FOURCC_NV12}, |
| 3986 |
{Format_NV21, (MOS_OS_FORMAT)FOURCC_NV21}, |
| 3987 |
{Format_NV11, (MOS_OS_FORMAT)FOURCC_NV11}, |
| 3988 |
{Format_P208, (MOS_OS_FORMAT)FOURCC_P208}, |
| 3989 |
{Format_IMC1, (MOS_OS_FORMAT)FOURCC_IMC1}, |
| 3990 |
{Format_IMC2, (MOS_OS_FORMAT)FOURCC_IMC2}, |
| 3991 |
{Format_IMC3, (MOS_OS_FORMAT)FOURCC_IMC3}, |
| 3992 |
{Format_IMC4, (MOS_OS_FORMAT)FOURCC_IMC4}, |
| 3993 |
{Format_I420, (MOS_OS_FORMAT)FOURCC_I420}, |
| 3994 |
{Format_IYUV, (MOS_OS_FORMAT)FOURCC_IYUV}, |
| 3995 |
{Format_YV12, (MOS_OS_FORMAT)FOURCC_YV12}, |
| 3996 |
{Format_YVU9, (MOS_OS_FORMAT)FOURCC_YVU9}, |
| 3997 |
{Format_AI44, (MOS_OS_FORMAT)FOURCC_AI44}, |
| 3998 |
{Format_IA44, (MOS_OS_FORMAT)FOURCC_IA44}, |
| 3999 |
{Format_400P, (MOS_OS_FORMAT)FOURCC_400P}, |
| 4000 |
{Format_411P, (MOS_OS_FORMAT)FOURCC_411P}, |
| 4001 |
{Format_411R, (MOS_OS_FORMAT)FOURCC_411R}, |
| 4002 |
{Format_422H, (MOS_OS_FORMAT)FOURCC_422H}, |
| 4003 |
{Format_422V, (MOS_OS_FORMAT)FOURCC_422V}, |
| 4004 |
{Format_444P, (MOS_OS_FORMAT)FOURCC_444P}, |
| 4005 |
{Format_RGBP, (MOS_OS_FORMAT)FOURCC_RGBP}, |
| 4006 |
{Format_BGRP, (MOS_OS_FORMAT)FOURCC_BGRP}, |
| 4007 |
{Format_STMM, (MOS_OS_FORMAT)DDI_FORMAT_P8}, |
| 4008 |
{Format_P010, (MOS_OS_FORMAT)FOURCC_P010}, |
| 4009 |
{Format_P016, (MOS_OS_FORMAT)FOURCC_P016}, |
| 4010 |
{Format_Y216, (MOS_OS_FORMAT)FOURCC_Y216}, |
| 4011 |
{Format_Y416, (MOS_OS_FORMAT)FOURCC_Y416}, |
| 4012 |
{Format_A16B16G16R16, (MOS_OS_FORMAT)DDI_FORMAT_A16B16G16R16}, |
| 4013 |
{Format_Y210, (MOS_OS_FORMAT)FOURCC_Y210}, |
| 4014 |
{Format_Y410, (MOS_OS_FORMAT)FOURCC_Y410}, |
| 4015 |
{Format_R32G32B32A32F, (MOS_OS_FORMAT)DDI_FORMAT_R32G32B32A32F}}; |
| 4016 |
|
| 4017 |
auto iter = mos2OsFmtMap.find(format); |
| 4018 |
if (iter != mos2OsFmtMap.end()) |
| 4019 |
{ |
| 4020 |
return iter->second; |
| 4021 |
} |
| 4022 |
return (MOS_OS_FORMAT)DDI_FORMAT_UNKNOWN; |
| 4023 |
} |
| 4024 |
|
| 4025 |
MOS_FORMAT MosInterface::OsFmtToMosFmt(uint32_t format) |
| 4026 |
{ |
| 4027 |
static const std::map<MOS_OS_FORMAT, MOS_FORMAT> os2MosFmtMap = { |
| 4028 |
{DDI_FORMAT_A8B8G8R8, Format_A8R8G8B8}, |
| 4029 |
{DDI_FORMAT_X8B8G8R8, Format_X8R8G8B8}, |
| 4030 |
{DDI_FORMAT_R32F, Format_R32F}, |
| 4031 |
{DDI_FORMAT_A8R8G8B8, Format_A8R8G8B8}, |
| 4032 |
{DDI_FORMAT_X8R8G8B8, Format_X8R8G8B8}, |
| 4033 |
{DDI_FORMAT_R5G6B5, Format_R5G6B5}, |
| 4034 |
{DDI_FORMAT_YUY2, Format_YUY2}, |
| 4035 |
{DDI_FORMAT_P8, Format_P8}, |
| 4036 |
{DDI_FORMAT_A8P8, Format_A8P8}, |
| 4037 |
{DDI_FORMAT_A8, Format_A8}, |
| 4038 |
{DDI_FORMAT_L8, Format_L8}, |
| 4039 |
{DDI_FORMAT_L16, Format_L16}, |
| 4040 |
{DDI_FORMAT_A4L4, Format_A4L4}, |
| 4041 |
{DDI_FORMAT_A8L8, Format_A8L8}, |
| 4042 |
{DDI_FORMAT_V8U8, Format_V8U8}, |
| 4043 |
{DDI_FORMAT_A16B16G16R16, Format_A16B16G16R16}, |
| 4044 |
{DDI_FORMAT_R32G32B32A32F, Format_R32G32B32A32F}, |
| 4045 |
{FOURCC_YVYU, Format_YVYU}, |
| 4046 |
{FOURCC_UYVY, Format_UYVY}, |
| 4047 |
{FOURCC_VYUY, Format_VYUY}, |
| 4048 |
{FOURCC_AYUV, Format_AYUV}, |
| 4049 |
{FOURCC_NV12, Format_NV12}, |
| 4050 |
{FOURCC_NV21, Format_NV21}, |
| 4051 |
{FOURCC_NV11, Format_NV11}, |
| 4052 |
{FOURCC_P208, Format_P208}, |
| 4053 |
{FOURCC_IMC1, Format_IMC1}, |
| 4054 |
{FOURCC_IMC2, Format_IMC2}, |
| 4055 |
{FOURCC_IMC3, Format_IMC3}, |
| 4056 |
{FOURCC_IMC4, Format_IMC4}, |
| 4057 |
{FOURCC_I420, Format_I420}, |
| 4058 |
{FOURCC_IYUV, Format_IYUV}, |
| 4059 |
{FOURCC_YV12, Format_YV12}, |
| 4060 |
{FOURCC_YVU9, Format_YVU9}, |
| 4061 |
{FOURCC_AI44, Format_AI44}, |
| 4062 |
{FOURCC_IA44, Format_IA44}, |
| 4063 |
{FOURCC_400P, Format_400P}, |
| 4064 |
{FOURCC_411P, Format_411P}, |
| 4065 |
{FOURCC_411R, Format_411R}, |
| 4066 |
{FOURCC_422H, Format_422H}, |
| 4067 |
{FOURCC_422V, Format_422V}, |
| 4068 |
{FOURCC_444P, Format_444P}, |
| 4069 |
{FOURCC_RGBP, Format_RGBP}, |
| 4070 |
{FOURCC_BGRP, Format_BGRP}, |
| 4071 |
{FOURCC_P010, Format_P010}, |
| 4072 |
{FOURCC_P016, Format_P016}, |
| 4073 |
{FOURCC_Y216, Format_Y216}, |
| 4074 |
{FOURCC_Y416, Format_Y416}, |
| 4075 |
{FOURCC_Y210, Format_Y210}, |
| 4076 |
{FOURCC_Y410, Format_Y410} |
| 4077 |
}; |
| 4078 |
|
| 4079 |
auto iter = os2MosFmtMap.find(format); |
| 4080 |
if (iter != os2MosFmtMap.end()) |
| 4081 |
{ |
| 4082 |
return iter->second; |
| 4083 |
} |
| 4084 |
return Format_Invalid; |
| 4085 |
} |
| 4086 |
|
| 4087 |
bool MosInterface::IsCompressibelSurfaceSupported(MEDIA_FEATURE_TABLE *skuTable) |
| 4088 |
{ |
| 4089 |
if(skuTable) |
| 4090 |
{ |
| 4091 |
return MEDIA_IS_SKU(skuTable, FtrCompressibleSurfaceDefault); |
| 4092 |
} |
| 4093 |
return true; |
| 4094 |
} |
| 4095 |
|
| 4096 |
bool MosInterface::IsMismatchOrderProgrammingSupported() |
| 4097 |
{ |
| 4098 |
return false; |
| 4099 |
} |
| 4100 |
|
| 4101 |
MOS_STATUS MosInterface::WaitForBBCompleteNotifyEvent( |
| 4102 |
MOS_STREAM_HANDLE streamState, |
| 4103 |
GPU_CONTEXT_HANDLE gpuContextHandle, |
| 4104 |
uint32_t uiTimeOut) |
| 4105 |
{ |
| 4106 |
return MOS_STATUS_SUCCESS; |
| 4107 |
} |
| 4108 |
|
| 4109 |
MOS_STATUS MosInterface::RegisterBBCompleteNotifyEvent( |
| 4110 |
MOS_STREAM_HANDLE streamState, |
| 4111 |
GPU_CONTEXT_HANDLE gpuContextHandle) |
| 4112 |
{ |
| 4113 |
return MOS_STATUS_SUCCESS; |
| 4114 |
} |
| 4115 |
|
| 4116 |
void MosInterface::GetRtLogResourceInfo( |
| 4117 |
PMOS_INTERFACE osInterface, |
| 4118 |
PMOS_RESOURCE &osResource, |
| 4119 |
uint32_t &size) |
| 4120 |
{ |
| 4121 |
osResource = nullptr; |
| 4122 |
size = 0; |
| 4123 |
if (osInterface->osStreamState && osInterface->osStreamState->osDeviceContext) |
| 4124 |
{ |
| 4125 |
MosOcaRTLogMgr *ocaRTLogMgr = MosOcaRTLogMgr::GetInstance(); |
| 4126 |
MOS_OS_CHK_NULL_NO_STATUS_RETURN(ocaRTLogMgr); |
| 4127 |
GpuContextSpecificNext *gpuContext = dynamic_cast<GpuContextSpecificNext*>(osInterface->osStreamState->osDeviceContext->GetGpuContextMgr()->GetGpuContext(osInterface->osStreamState->currentGpuContextHandle)); |
| 4128 |
if (gpuContext != nullptr) |
| 4129 |
{ |
| 4130 |
osResource = gpuContext->GetOcaRTLogResource(osInterface->osStreamState->osDeviceContext->GetOcaRTLogResource()); |
| 4131 |
size = ocaRTLogMgr->GetRtlogHeapSize(); |
| 4132 |
} |
| 4133 |
} |
| 4134 |
} |
| 4135 |
|
| 4136 |
bool MosInterface::IsPooledResource(MOS_STREAM_HANDLE streamState, PMOS_RESOURCE osResource) |
| 4137 |
{ |
| 4138 |
return false; |
| 4139 |
} |
| 4140 |
|
| 4141 |
MOS_TILE_TYPE MosInterface::MapTileType(GMM_RESOURCE_FLAG flags, GMM_TILE_TYPE type) |
| 4142 |
{ |
| 4143 |
return MOS_TILE_INVALID; |
| 4144 |
} |
| 4145 |
|
| 4146 |
MOS_STATUS MosInterface::SetMultiEngineEnabled( |
| 4147 |
PMOS_INTERFACE pOsInterface, |
| 4148 |
MOS_COMPONENT component, |
| 4149 |
bool enabled) |
| 4150 |
{ |
| 4151 |
return MOS_STATUS_SUCCESS; |
| 4152 |
} |
| 4153 |
|
| 4154 |
MOS_STATUS MosInterface::GetMultiEngineStatus( |
| 4155 |
PMOS_INTERFACE pOsInterface, |
| 4156 |
PLATFORM *platform, |
| 4157 |
MOS_COMPONENT component, |
| 4158 |
bool &isMultiDevices, |
| 4159 |
bool &isMultiEngine) |
| 4160 |
{ |
| 4161 |
return MOS_STATUS_SUCCESS; |
| 4162 |
} |
| 4163 |
|
| 4164 |
bool MosInterface::m_bTrinity = false; |
| 4165 |
void MosInterface::SetIsTrinityEnabled(bool bTrinity) |
| 4166 |
{ |
| 4167 |
return; |
| 4168 |
} |
| 4169 |
bool MosInterface::IsGpuSyncByCmd(MOS_STREAM_HANDLE streamState, GPU_CONTEXT_HANDLE gpuContextHandle) |
| 4170 |
{ |
| 4171 |
return false; |
| 4172 |
} |