| 1 |
/* |
| 2 |
* Copyright (c) 2019-2026, 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_context_next.h |
| 24 |
//! \brief Container for parameters shared across different GPU contextNexts of the same device instance |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __MOS_CONTEXT_NEXT_H__ |
| 28 |
#define __MOS_CONTEXT_NEXT_H__ |
| 29 |
|
| 30 |
#include "mos_os.h" |
| 31 |
#include "mos_gpucontextmgr_next.h" |
| 32 |
#if !EMUL |
| 33 |
#include "mos_cmdbufmgr_next.h" |
| 34 |
#include "mos_decompression.h" |
| 35 |
#endif |
| 36 |
#include "mos_mediacopy.h" |
| 37 |
|
| 38 |
class MosOcaRTLogMgr; |
| 39 |
class MosMockAdaptor; |
| 40 |
|
| 41 |
class OsContextNext |
| 42 |
{ |
| 43 |
protected: |
| 44 |
//! |
| 45 |
//! \brief Constructor for the OsContextNext |
| 46 |
//! |
| 47 |
OsContextNext(){}; |
| 48 |
|
| 49 |
//! |
| 50 |
//! \brief Interface for initializing NULL Hardware. |
| 51 |
//! \details Interface for initializing NULL Hardware. |
| 52 |
//! \param [in] osContext |
| 53 |
//! Pointer to OS context. |
| 54 |
//! \param [in] osDeviceContext |
| 55 |
//! Pointer to OS device context. |
| 56 |
//! \return MOS_STATUS |
| 57 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 58 |
//! |
| 59 |
MOS_STATUS NullHwInit(MOS_CONTEXT_HANDLE osContext); |
| 60 |
|
| 61 |
//! |
| 62 |
//! \brief Destroy NULL Hardware. |
| 63 |
//! \details Destroy NULL Hardware. |
| 64 |
//! \return MOS_STATUS |
| 65 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 66 |
//! |
| 67 |
MOS_STATUS NullHwDestroy(); |
| 68 |
|
| 69 |
public: |
| 70 |
//! |
| 71 |
//! \brief Destructor for the OsContextNext |
| 72 |
//! |
| 73 |
virtual ~OsContextNext(){}; |
| 74 |
|
| 75 |
//! |
| 76 |
//! \brief Initialzie the OS ContextNext Object |
| 77 |
//! \return MOS_STATUS_SUCCESS on success case, MOS error status on fail cases |
| 78 |
//! |
| 79 |
virtual MOS_STATUS Init(DDI_DEVICE_CONTEXT osDriverContextNext) = 0; |
| 80 |
|
| 81 |
//! |
| 82 |
//! \brief Static entrypoint, get the OS ContextNext Object |
| 83 |
//! \return the os specific object for OS contextNext |
| 84 |
//! |
| 85 |
static class OsContextNext *GetOsContextObject(); |
| 86 |
|
| 87 |
//! |
| 88 |
//! \brief Clean up the smartptr |
| 89 |
//! |
| 90 |
void CleanUp(); |
| 91 |
|
| 92 |
//! |
| 93 |
//! \brief Get the skuTable |
| 94 |
//! \return The active SKU Table |
| 95 |
//! |
| 96 |
MEDIA_FEATURE_TABLE *GetSkuTable() { return &m_skuTable; }; |
| 97 |
|
| 98 |
//! |
| 99 |
//! \brief Get the waTable |
| 100 |
//! \return The active WA table |
| 101 |
//! |
| 102 |
MEDIA_WA_TABLE *GetWaTable() { return &m_waTable; }; |
| 103 |
|
| 104 |
//! |
| 105 |
//! \brief Check if deferred GPU context destroy is supported |
| 106 |
//! \return true if supported, false otherwise |
| 107 |
//! |
| 108 |
virtual bool IsDeferredGpuContextDestroySupported() { return false; } |
| 109 |
|
| 110 |
//! |
| 111 |
//! \brief Get the platform information string |
| 112 |
//! \return value of m_platformInfo |
| 113 |
//! |
| 114 |
PLATFORM *GetPlatformInfo() { return &m_platformInfo; }; |
| 115 |
|
| 116 |
//! |
| 117 |
//! \brief Get the gtSystemInfo string |
| 118 |
//! \return value of m_gtSystemInfo |
| 119 |
//! |
| 120 |
MEDIA_SYSTEM_INFO *GetGtSysInfo() { return &m_gtSystemInfo; }; |
| 121 |
|
| 122 |
//! |
| 123 |
//! \brief Check the platform is Atom or not |
| 124 |
//! \return true on Atom platform, false on none Atom platform |
| 125 |
//! |
| 126 |
bool IsAtomSoc() { return m_isAtomSOC; }; |
| 127 |
|
| 128 |
//! |
| 129 |
//! \brief Set the OS ContextNext valid flag |
| 130 |
//! \param [in] isOsContextNextValid |
| 131 |
//! Flag to indicate if the os contextNext is valid. |
| 132 |
//! |
| 133 |
void SetOsContextValid(bool isOsContextValid) { m_osContextValid = isOsContextValid; }; |
| 134 |
|
| 135 |
//! |
| 136 |
//! \brief Return the OS ContextNext valid flag |
| 137 |
//! \return true if the OS contextNext is valid, false if not valid |
| 138 |
//! |
| 139 |
bool GetOsContextValid() { return m_osContextValid; }; |
| 140 |
|
| 141 |
//! |
| 142 |
//! \brief Set Null Hw enabled flag |
| 143 |
//! \param [in] isNullHwEnabled |
| 144 |
//! Flag to indicate if Null Hw is enabled. |
| 145 |
//! |
| 146 |
void SetNullHwIsEnabled(bool isNullHwEnabled) { m_nullHwIsEnabled = isNullHwEnabled; } |
| 147 |
|
| 148 |
//! |
| 149 |
//! \brief Return Null Hw enabled flag |
| 150 |
//! \return true if Null Hw is enabled, false if not enabled |
| 151 |
//! |
| 152 |
bool GetNullHwIsEnabled() { return m_nullHwIsEnabled; } |
| 153 |
|
| 154 |
//! |
| 155 |
//! \brief Set Vebox scalability enabled state reported flag |
| 156 |
//! \param [in] isReported |
| 157 |
//! Flag to indicate if Vebox scalability enabled state has been reported |
| 158 |
//! |
| 159 |
void SetEnableVeboxScalabilityReported(bool isReported) { m_veboxScalabilityEnableReported = isReported; } |
| 160 |
|
| 161 |
//! |
| 162 |
//! \brief Return Vebox scalability enabled state reported flag |
| 163 |
//! \return true if Vebox scalability enabled state has been reported, false otherwise |
| 164 |
//! |
| 165 |
bool GetEnableVeboxScalabilityReported() { return m_veboxScalabilityEnableReported; } |
| 166 |
|
| 167 |
//! |
| 168 |
//! \brief Set Vebox scalability disabled state reported flag |
| 169 |
//! \param [in] isReported |
| 170 |
//! Flag to indicate if Vebox scalability disabled state has been reported |
| 171 |
//! |
| 172 |
void SetDisableVeboxScalabilityReported(bool isReported) { m_veboxScalabilityDisableReported = isReported; } |
| 173 |
|
| 174 |
//! |
| 175 |
//! \brief Return Vebox scalability disabled state reported flag |
| 176 |
//! \return true if Vebox scalability disabled state has been reported, false otherwise |
| 177 |
//! |
| 178 |
bool GetDisableVeboxScalabilityReported() { return m_veboxScalabilityDisableReported; } |
| 179 |
|
| 180 |
//! |
| 181 |
//! \brief Set Vdbox scalability enabled state reported flag |
| 182 |
//! \param [in] isReported |
| 183 |
//! Flag to indicate if Vdbox scalability enabled state has been reported |
| 184 |
//! |
| 185 |
void SetEnableVdboxScalabilityReported(bool isReported) { m_vdboxScalabilityEnableReported = isReported; } |
| 186 |
|
| 187 |
//! |
| 188 |
//! \brief Return Vdbox scalability enabled state reported flag |
| 189 |
//! \return true if Vdbox scalability enabled state has been reported, false otherwise |
| 190 |
//! |
| 191 |
bool GetEnableVdboxScalabilityReported() { return m_vdboxScalabilityEnableReported; } |
| 192 |
|
| 193 |
//! |
| 194 |
//! \brief Set Vdbox scalability disabled state reported flag |
| 195 |
//! \param [in] isReported |
| 196 |
//! Flag to indicate if Vdbox scalability disabled state has been reported |
| 197 |
//! |
| 198 |
void SetDisableVdboxScalabilityReported(bool isReported) { m_vdboxScalabilityDisableReported = isReported; } |
| 199 |
|
| 200 |
//! |
| 201 |
//! \brief Return Vdbox scalability disabled state reported flag |
| 202 |
//! \return true if Vdbox scalability disabled state has been reported, false otherwise |
| 203 |
//! |
| 204 |
bool GetDisableVdboxScalabilityReported() { return m_vdboxScalabilityDisableReported; } |
| 205 |
|
| 206 |
//! |
| 207 |
//! \brief Get GPU context manager of the device |
| 208 |
//! \return GPU context manager |
| 209 |
//! |
| 210 |
GpuContextMgrNext *GetGpuContextMgr() { return m_gpuContextMgr; } |
| 211 |
|
| 212 |
//! |
| 213 |
//! \brief Get Cmd buffer manager of the device |
| 214 |
//! \return Cmd buffer manager |
| 215 |
//! |
| 216 |
CmdBufMgrNext *GetCmdBufferMgr() { return m_cmdBufMgr; } |
| 217 |
|
| 218 |
//! |
| 219 |
//! \brief Get GMM client context of the device |
| 220 |
//! \return Cmd buffer manager |
| 221 |
//! |
| 222 |
GMM_CLIENT_CONTEXT *GetGmmClientContext() { return m_gmmClientContext; } |
| 223 |
|
| 224 |
//! |
| 225 |
//! \brief Get MosDecompression |
| 226 |
//! \return ptr to MosDecompression |
| 227 |
//! |
| 228 |
#if !EMUL |
| 229 |
MosDecompression *GetMosDecompression() |
| 230 |
{ |
| 231 |
return m_mosDecompression; |
| 232 |
} |
| 233 |
#endif |
| 234 |
|
| 235 |
//! |
| 236 |
//! \brief Get MosMediaCopy |
| 237 |
//! \return ptr to MosMediaCopy |
| 238 |
//! |
| 239 |
MosMediaCopy *GetMosMediaCopy() |
| 240 |
{ |
| 241 |
return m_mosMediaCopy; |
| 242 |
} |
| 243 |
|
| 244 |
//! \brief Get the DumpFrameNum |
| 245 |
//! \return The current dumped frameNum |
| 246 |
//! |
| 247 |
uint32_t GetDumpFrameNum() { return m_dumpframeNum; } |
| 248 |
|
| 249 |
//! |
| 250 |
//! \brief Set the DumpFrameNum |
| 251 |
//! \return update the FrameNum and return success |
| 252 |
//! |
| 253 |
MOS_STATUS SetDumpFrameNum(uint32_t framNum) |
| 254 |
{ |
| 255 |
m_dumpframeNum = framNum; |
| 256 |
return MOS_STATUS_SUCCESS; |
| 257 |
} |
| 258 |
|
| 259 |
//! |
| 260 |
//! \brief Reset the DumpFrameNum |
| 261 |
//! \return init the FrameNum and return success |
| 262 |
//! |
| 263 |
MOS_STATUS ResetDumpFrameNum() |
| 264 |
{ |
| 265 |
m_dumpframeNum = 0xffffffff; |
| 266 |
return MOS_STATUS_SUCCESS; |
| 267 |
} |
| 268 |
|
| 269 |
//! |
| 270 |
//! \brief Get the dumpLoc |
| 271 |
//! \return The current dumped GetdumpLoc |
| 272 |
//! |
| 273 |
char *GetdumpLoc() { return m_dumpLoc; } |
| 274 |
|
| 275 |
//! |
| 276 |
//! \brief Reset the dumpLoc |
| 277 |
//! \return init the dumpLoc and return success |
| 278 |
//! |
| 279 |
MOS_STATUS ResetdumpLoc() |
| 280 |
{ |
| 281 |
m_dumpLoc[0] = 0; |
| 282 |
return MOS_STATUS_SUCCESS; |
| 283 |
} |
| 284 |
|
| 285 |
//! |
| 286 |
//! \brief Determine whether the device is using async mode |
| 287 |
//! \return true if the device is in async mode, false otherwise |
| 288 |
//! |
| 289 |
bool IsAynchronous() { return m_aynchronousDevice; } |
| 290 |
|
| 291 |
//! |
| 292 |
//! \brief Determine whether pooling resource is enabled |
| 293 |
//! \return true if pooling resource is enabled, false otherwise |
| 294 |
//! |
| 295 |
bool IsPoolingResourceEnabled() { return m_resourcePooling; } |
| 296 |
|
| 297 |
//! |
| 298 |
//! \brief Set oca rtlog resource |
| 299 |
//! \return Set oca rtlog resource and return success |
| 300 |
//! |
| 301 |
MOS_STATUS SetRtLogRes(PMOS_RESOURCE ocaRTLogResource) |
| 302 |
{ |
| 303 |
m_ocaRTLogResource = ocaRTLogResource; |
| 304 |
return MOS_STATUS_SUCCESS; |
| 305 |
} |
| 306 |
|
| 307 |
//! |
| 308 |
//! \brief Get OcaRTLogResource |
| 309 |
//! \return ptr to OcaRTLogResource |
| 310 |
//! |
| 311 |
PMOS_RESOURCE GetOcaRTLogResource() |
| 312 |
{ |
| 313 |
return m_ocaRTLogResource; |
| 314 |
} |
| 315 |
|
| 316 |
protected: |
| 317 |
//! |
| 318 |
//! \brief Destory the OS ContextNext Object, internal function, called by cleanup |
| 319 |
//! |
| 320 |
virtual void Destroy() = 0; |
| 321 |
|
| 322 |
public: |
| 323 |
static const uint32_t m_cmdBufAlignment = 16; //!> Cmd buffer alignment |
| 324 |
bool m_ocaLogSectionSupported = true; |
| 325 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 326 |
bool m_dumpCommandBuffer = false; |
| 327 |
bool m_dumpCommandBufferToFile = false; |
| 328 |
bool m_dumpCommandBufferAsMessages = false; |
| 329 |
char m_sFileName[MOS_MAX_HLT_FILENAME_LEN] = {0}; |
| 330 |
#endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 331 |
|
| 332 |
protected: |
| 333 |
GpuContextMgrNext *m_gpuContextMgr = nullptr; //!> GPU context manager of the device |
| 334 |
CmdBufMgrNext *m_cmdBufMgr = nullptr; //!> Cmd buffer manager of the device |
| 335 |
GMM_CLIENT_CONTEXT *m_gmmClientContext = nullptr; //!> GMM client context of the device |
| 336 |
|
| 337 |
PMOS_RESOURCE m_ocaRTLogResource = nullptr; |
| 338 |
uint32_t m_dumpframeNum = 0; // For use when dump its compressed surface, override the frame number given from MediaVeboxDecompState |
| 339 |
char m_dumpLoc[MAX_PATH] = {0}; // For use when dump its compressed surface, to distinguish each loc's pre/post decomp |
| 340 |
|
| 341 |
//! \brief Platform string including product family, chipset family, etc |
| 342 |
PLATFORM m_platformInfo = {}; |
| 343 |
|
| 344 |
//! \brief sku table |
| 345 |
MEDIA_FEATURE_TABLE m_skuTable = {}; |
| 346 |
|
| 347 |
//! \brief wa table |
| 348 |
MEDIA_WA_TABLE m_waTable = {}; |
| 349 |
|
| 350 |
//! \brief GT system information, like EU counter, thread count, etc. |
| 351 |
MEDIA_SYSTEM_INFO m_gtSystemInfo = {}; |
| 352 |
|
| 353 |
//! \brief Whether the processor is Atom |
| 354 |
bool m_isAtomSOC = false; |
| 355 |
|
| 356 |
|
| 357 |
//! \brief Flag to mark whether the os context is valid |
| 358 |
bool m_osContextValid = false; |
| 359 |
|
| 360 |
//! \brief Flag to mark whether Null Hw is enabled |
| 361 |
bool m_nullHwIsEnabled = false; |
| 362 |
|
| 363 |
//! \brief Whether or not need deallocation on exit |
| 364 |
bool m_deallocateOnExit = false; |
| 365 |
|
| 366 |
//! \brief need KMD to track the media frame or not |
| 367 |
bool m_enableKmdMediaFrameTracking = false; |
| 368 |
|
| 369 |
//! \brief For Resource addressing, whether patch list mode is active |
| 370 |
bool m_usesPatchList = false; |
| 371 |
|
| 372 |
//! \brief For Resource addressing, whether GPU address mode is active |
| 373 |
bool m_usesGfxAddress = false; |
| 374 |
|
| 375 |
//! \brief Component info |
| 376 |
MOS_COMPONENT m_component = COMPONENT_UNKNOWN; |
| 377 |
|
| 378 |
//! \brief Flag to indicate if Tile64 is supported |
| 379 |
bool m_mediaTile64 = false; |
| 380 |
|
| 381 |
//! \brief Flag to indicate if NoGfxMemory is needed |
| 382 |
bool m_noGfxMemoryNeeded = false; |
| 383 |
|
| 384 |
//! \brief Flag to indicate if Vebox BatchBuffer scalability enabled state has been reported |
| 385 |
bool m_veboxScalabilityEnableReported = false; |
| 386 |
|
| 387 |
//! \brief Flag to indicate if Vdbox BatchBuffer scalability enabled state has been reported |
| 388 |
bool m_vdboxScalabilityEnableReported = false; |
| 389 |
|
| 390 |
//! \brief Flag to indicate if Vebox BatchBuffer scalability disabled state has been reported |
| 391 |
bool m_veboxScalabilityDisableReported = false; |
| 392 |
|
| 393 |
//! \brief Flag to indicate if Vdbox BatchBuffer scalability disabled state has been reported |
| 394 |
bool m_vdboxScalabilityDisableReported = false; |
| 395 |
|
| 396 |
//! \brief the ptr to mos decompression module |
| 397 |
#if !EMUL |
| 398 |
MosDecompression *m_mosDecompression = nullptr; |
| 399 |
#endif |
| 400 |
|
| 401 |
//! \brief the ptr to mos media copy module |
| 402 |
MosMediaCopy *m_mosMediaCopy = nullptr; |
| 403 |
|
| 404 |
//! \brief the ptr to mos mock adaptor module |
| 405 |
MosMockAdaptor *m_mockAdaptor = nullptr; |
| 406 |
|
| 407 |
//!< Indicate if this device is working in aync mode or normal mode |
| 408 |
bool m_aynchronousDevice = false; |
| 409 |
|
| 410 |
//! \brief is pooled resource is supported |
| 411 |
bool m_resourcePooling = false; |
| 412 |
MEDIA_CLASS_DEFINE_END(OsContextNext) |
| 413 |
}; |
| 414 |
#endif // #ifndef __MOS_CONTEXTNext_NEXT_H__ |