| 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.h |
| 24 |
//! \brief MOS interface definition |
| 25 |
//! |
| 26 |
//! Device level: OsDeviceContext in device/Libva context. |
| 27 |
//! The global level of entire media driver instance in user space. |
| 28 |
//! There could be multiple devices in a single process. |
| 29 |
//! Stream level: OsStreamState in Hal instances (Codec pipeline, VP pipeline, CM device, CP session, etc) |
| 30 |
//! Each Hal instance can have an OsStreamState to indicate that stream's state specific to OS. |
| 31 |
//! Each Device can have multiple streams. |
| 32 |
//! All OsStreamStates must be binded with a valid OsDeviceContext to indicate the inclusion relationship |
| 33 |
//! between device and stream in DDI |
| 34 |
//! |
| 35 |
//! MOS interface provide following OS services: (OS services are abstracted and diff OS behavior is tranparent to MOS customers) |
| 36 |
//! 1) Workload scheduling (GPU context, cmdbuffer, sync, virtual engine, etc) |
| 37 |
//! 2) Resource managment (Graphic resource, external resource) |
| 38 |
//! 3) Utilities (Abstraction of generalized system call) |
| 39 |
//! 4) Performance interface |
| 40 |
//! 5) Debug interface |
| 41 |
//! |
| 42 |
//! Caller: DDI, Media interface, HAL, MHW |
| 43 |
//! Any interface func returning MOS_STATUS_UNKNOWN mean Device level is go into unstable situation. |
| 44 |
//! Caller needs to make sure exiting properly. |
| 45 |
|
| 46 |
|
| 47 |
#ifndef __MOS_INTERFACE_H__ |
| 48 |
#define __MOS_INTERFACE_H__ |
| 49 |
|
| 50 |
#include "mos_defs.h" |
| 51 |
#include "mos_oca_rtlog_mgr_defs.h" |
| 52 |
#include "mos_os.h" |
| 53 |
#include "media_class_trace.h" |
| 54 |
|
| 55 |
class GpuContextSpecificNext; |
| 56 |
struct _MOS_VIRTUALENGINE_SET_PARAMS; |
| 57 |
struct _MOS_VIRTUALENGINE_INIT_PARAMS; |
| 58 |
struct SYNC_FENCE_INFO_TRINITY; |
| 59 |
|
| 60 |
typedef struct _MOS_VIRTUALENGINE_SET_PARAMS MOS_VIRTUALENGINE_SET_PARAMS, *PMOS_VIRTUALENGINE_SET_PARAMS; |
| 61 |
typedef struct _MOS_VIRTUALENGINE_INIT_PARAMS MOS_VIRTUALENGINE_INIT_PARAMS, *PMOS_VIRTUALENGINE_INIT_PARAMS; |
| 62 |
typedef struct _MOS_CMD_BUF_ATTRI_VE MOS_CMD_BUF_ATTRI_VE, *PMOS_CMD_BUF_ATTRI_VE; |
| 63 |
typedef struct _MHW_VDBOX_GPUNODE_LIMIT *PMHW_VDBOX_GPUNODE_LIMIT; |
| 64 |
class MosInterface |
| 65 |
{ |
| 66 |
protected: |
| 67 |
//! |
| 68 |
//! \brief Destructor |
| 69 |
//! \details There is no members in Mos Interface, it's pure interface. |
| 70 |
//! Never call the Destructor of Mos interface |
| 71 |
//! |
| 72 |
~MosInterface() = default; |
| 73 |
|
| 74 |
//! |
| 75 |
//! \brief Constructor |
| 76 |
//! \details There is no members in Mos Interface, it's pure interface. |
| 77 |
//! Never call the Constructor of Mos interface |
| 78 |
//! |
| 79 |
MosInterface() = default; |
| 80 |
|
| 81 |
public: |
| 82 |
//! |
| 83 |
//! \brief Init Os Utilities |
| 84 |
//! \details Include Utilities, user settings key, mem ninja etc |
| 85 |
//! \details Must be first called MOS interface before CreateOsDeviceContext |
| 86 |
//! \details Caller: DDI only. |
| 87 |
//! |
| 88 |
//! \param [in] ddiDeviceContext |
| 89 |
//! Pointer of device context in DDI to init Os Device Context |
| 90 |
//! |
| 91 |
//! \return MOS_STATUS |
| 92 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 93 |
//! |
| 94 |
static MOS_STATUS InitOsUtilities(DDI_DEVICE_CONTEXT ddiDeviceContext); |
| 95 |
|
| 96 |
//! |
| 97 |
//! \brief Close Os Utilities |
| 98 |
//! \details Include Utilities, user settings key, mem ninja etc |
| 99 |
//! \details Must be last called MOS interface after DestroyOsDeviceContext |
| 100 |
//! \details Caller: DDI only. |
| 101 |
//! |
| 102 |
//! \param [in] mosCtx |
| 103 |
//! Pointer of device context in DDI for reg ops |
| 104 |
//! |
| 105 |
//! \return MOS_STATUS |
| 106 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 107 |
//! |
| 108 |
static MOS_STATUS CloseOsUtilities(PMOS_CONTEXT mosCtx); |
| 109 |
|
| 110 |
//! |
| 111 |
//! \brief Init Os context interface |
| 112 |
//! \details Init Os context interface |
| 113 |
//! |
| 114 |
//! \param [in/out] ctxInterface |
| 115 |
//! Pointer of MOS_CONTEXT_INTERFACE |
| 116 |
//! |
| 117 |
//! \return MOS_STATUS |
| 118 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 119 |
//! |
| 120 |
static MOS_STATUS InitCtxInterface(MOS_CONTEXT_INTERFACE *ctxInterface); |
| 121 |
|
| 122 |
//! |
| 123 |
//! \brief Create Os Device Context |
| 124 |
//! \details Create the Os Device Context in device level. |
| 125 |
//! \details Caller: DDI only. |
| 126 |
//! \details The Os Device Context is a singleton in the device, DDI must make sure call this only once. |
| 127 |
//! If the creation failed, DDI must yield to continue the initialization of device. |
| 128 |
//! |
| 129 |
//! \param [in] ddiDeviceContext |
| 130 |
//! Pointer of device context in DDI to init Os Device Context |
| 131 |
//! \param [out] deviceContext |
| 132 |
//! Handle of Os Device Context to create. If creation failed, it is INVALID_HANLE. |
| 133 |
//! OsDeviceContext is a device level singleton which stores the states, info specific to OS. |
| 134 |
//! It contain sub modules of MOS to transfer OS specific services to OS agnositic abstractions. |
| 135 |
//! |
| 136 |
//! \return MOS_STATUS |
| 137 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 138 |
//! |
| 139 |
static MOS_STATUS CreateOsDeviceContext(DDI_DEVICE_CONTEXT ddiDeviceContext, MOS_DEVICE_HANDLE *deviceContext); |
| 140 |
|
| 141 |
//! |
| 142 |
//! \brief Destroy Os Device Context |
| 143 |
//! \details Destroy the Os Device Context in device level |
| 144 |
//! \details Caller: DDI only. |
| 145 |
//! |
| 146 |
//! \param [in] deviceContext |
| 147 |
//! Handle of Os Device Context to Destroy |
| 148 |
//! |
| 149 |
//! \return MOS_STATUS |
| 150 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 151 |
//! |
| 152 |
static MOS_STATUS DestroyOsDeviceContext(MOS_DEVICE_HANDLE deviceContext); |
| 153 |
|
| 154 |
//! |
| 155 |
//! \brief Create Os Stream State |
| 156 |
//! \details Create the Os Stream State in stream level. |
| 157 |
//! \details Caller: DDI |
| 158 |
//! \details In DDI, one stream (Hal instance) can only create one Os Stream State corresponding to it. |
| 159 |
//! Os Stream state directly created by DDI is not corresponding any streams (Hal instances) |
| 160 |
//! |
| 161 |
//! \param [out] streamState |
| 162 |
//! Handle of Os Stream State to create. If creation failed, it is INVALID_HANLE. |
| 163 |
//! OsStreamState is a stream level state which stores the flags, info specific to OS specfic to that stream. |
| 164 |
//! It is be binded with a valid OsDeviceContext to indicate the inclusion relationship between device and stream. |
| 165 |
//! \param [in] deviceContext |
| 166 |
//! Device context to init streamState |
| 167 |
//! \param [in] osInterface |
| 168 |
//! Os interface to store streamState |
| 169 |
//! \param [in] component |
| 170 |
//! Indicate which component the stream state to create belongs to |
| 171 |
//! \param [in] extraParams |
| 172 |
//! Additional parameters needed to init streamstate |
| 173 |
//! |
| 174 |
//! \return MOS_STATUS |
| 175 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 176 |
//! |
| 177 |
static MOS_STATUS CreateOsStreamState( |
| 178 |
MOS_STREAM_HANDLE *streamState, |
| 179 |
MOS_DEVICE_HANDLE deviceContext, |
| 180 |
MOS_INTERFACE_HANDLE osInterface, |
| 181 |
MOS_COMPONENT component, |
| 182 |
EXTRA_PARAMS extraParams = nullptr); |
| 183 |
|
| 184 |
//! |
| 185 |
//! \brief Destroy Os Stream State |
| 186 |
//! \details Destroy the Os Stream State in stream level |
| 187 |
//! \details Caller: DDI |
| 188 |
//! |
| 189 |
//! \param [in] streamState |
| 190 |
//! Handle of Os Stream State to Destroy |
| 191 |
//! |
| 192 |
//! \return MOS_STATUS |
| 193 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 194 |
//! |
| 195 |
static MOS_STATUS DestroyOsStreamState( |
| 196 |
MOS_STREAM_HANDLE streamState); |
| 197 |
|
| 198 |
//! |
| 199 |
//! \brief Get OS runtime interface version |
| 200 |
//! \details [System info Interface] Get OS runtime interface version |
| 201 |
//! \details Caller: DDI only |
| 202 |
//! \details Only DDI can derive diff behavior due to OS runtime interface version |
| 203 |
//! |
| 204 |
//! \param [in] deviceContext |
| 205 |
//! Handle of Os Device Context |
| 206 |
//! |
| 207 |
//! \return uint32_t |
| 208 |
//! Read-only OS runtime interface version, it's meaning diff from OS and API |
| 209 |
//! |
| 210 |
static uint32_t GetInterfaceVersion(MOS_DEVICE_HANDLE deviceContext); |
| 211 |
|
| 212 |
//! |
| 213 |
//! \brief Get Platform |
| 214 |
//! \details [System info Interface] Get Get Platform information |
| 215 |
//! \details Caller: DDI & HAL & MHW |
| 216 |
//! \details This func is called in DDI only to generate hal instance stand for specific platform. |
| 217 |
//! This func can be used in HAL & MHW to get platfrom detailed info to judge the path of different behavior. |
| 218 |
//! |
| 219 |
//! \param [in] streamState |
| 220 |
//! Handle of Os Stream State |
| 221 |
//! |
| 222 |
//! \return PLATFORM |
| 223 |
//! Gfx driver shared enum of platform got. Read-only. |
| 224 |
//! |
| 225 |
static PLATFORM *GetPlatform(MOS_STREAM_HANDLE streamState); |
| 226 |
|
| 227 |
//! |
| 228 |
//! \brief Get SkuTable |
| 229 |
//! \details [System info Interface] Get Sku Table |
| 230 |
//! \details Caller: DDI & HAL & MHW |
| 231 |
//! \details This func is called to differentiate the behavior according to SKU table. |
| 232 |
//! |
| 233 |
//! \param [in] streamState |
| 234 |
//! Handle of Os Stream State |
| 235 |
//! |
| 236 |
//! \return MEDIA_FEATURE_TABLE* |
| 237 |
//! Read-only SKU table got, nullptr if failed to get |
| 238 |
//! |
| 239 |
static MEDIA_FEATURE_TABLE *GetSkuTable(MOS_STREAM_HANDLE streamState); |
| 240 |
|
| 241 |
//! |
| 242 |
//! \brief Get WaTable |
| 243 |
//! \details [System info Interface] Get WA Table |
| 244 |
//! \details Caller: DDI & HAL & MHW |
| 245 |
//! \details This func is called to differentiate the behavior according to WA table. |
| 246 |
//! |
| 247 |
//! \param [in] streamState |
| 248 |
//! Handle of Os Stream State |
| 249 |
//! |
| 250 |
//! \return MEDIA_WA_TABLE* |
| 251 |
//! Read-only WA table got, nullptr if failed to get |
| 252 |
//! |
| 253 |
static MEDIA_WA_TABLE *GetWaTable(MOS_STREAM_HANDLE streamState); |
| 254 |
|
| 255 |
//! |
| 256 |
//! \brief Get Gt System Info |
| 257 |
//! \details [System info Interface] Get Gt System Info |
| 258 |
//! \details Caller: HAL & MHW |
| 259 |
//! \details This func is called to differentiate the behavior according to Gt System Info. |
| 260 |
//! |
| 261 |
//! \param [in] streamState |
| 262 |
//! Handle of Os Stream State |
| 263 |
//! |
| 264 |
//! \return MEDIA_SYSTEM_INFO* |
| 265 |
//! Read-only GT system info got, nullptr if failed to get |
| 266 |
//! |
| 267 |
static MEDIA_SYSTEM_INFO *GetGtSystemInfo(MOS_STREAM_HANDLE streamState); |
| 268 |
|
| 269 |
//! |
| 270 |
//! \brief Get Media Engine Info |
| 271 |
//! \details [System info Interface] Get Media Engine Info |
| 272 |
//! \details Caller: HAL & MHW |
| 273 |
//! \details This func is called to differentiate the behavior according to Media Engine Info. |
| 274 |
//! |
| 275 |
//! \param [in] streamState |
| 276 |
//! Handle of Os Stream State |
| 277 |
//! \param [in] info |
| 278 |
//! MEDIA_SYS_INFO |
| 279 |
//! |
| 280 |
//! \return MOS_STATUS |
| 281 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 282 |
//! |
| 283 |
static MOS_STATUS GetMediaEngineInfo(MOS_STREAM_HANDLE streamState, MEDIA_ENGINE_INFO &info); |
| 284 |
|
| 285 |
//! |
| 286 |
//! \brief Get Adapter Info |
| 287 |
//! \details [System info Interface] Get Adapter Info |
| 288 |
//! \details Caller: DDI & HAL |
| 289 |
//! \details This func is called to differentiate the behavior according to Adapter Info. |
| 290 |
//! |
| 291 |
//! \param [in] streamState |
| 292 |
//! Handle of Os Stream State |
| 293 |
//! |
| 294 |
//! \return ADAPTER_INFO* |
| 295 |
//! Read-only Adapter Info got, nullptr if failed to get |
| 296 |
//! |
| 297 |
static ADAPTER_INFO *GetAdapterInfo(MOS_STREAM_HANDLE streamState); |
| 298 |
|
| 299 |
//! |
| 300 |
//! \brief Get current gmmclientcontext |
| 301 |
//! \details Get current gmmclientcontext |
| 302 |
//! |
| 303 |
//! \param [in] streamState |
| 304 |
//! Handle of Os Stream State |
| 305 |
//! |
| 306 |
//! \return GMM_CLIENT_CONTEXT |
| 307 |
//! Current gmmclientcontext |
| 308 |
//! |
| 309 |
static GMM_CLIENT_CONTEXT *GetGmmClientContext( |
| 310 |
MOS_STREAM_HANDLE streamState); |
| 311 |
|
| 312 |
//! |
| 313 |
//! \brief Get PAT index from gmm |
| 314 |
//! |
| 315 |
//! \param [in] gmmClient |
| 316 |
//! GMM client context |
| 317 |
//! \param [in] gmmResourceInfo |
| 318 |
//! gmm resource info |
| 319 |
//! |
| 320 |
//! \return unsigned int |
| 321 |
//! Pat index |
| 322 |
//! |
| 323 |
static unsigned int GetPATIndexFromGmm( |
| 324 |
GMM_CLIENT_CONTEXT *gmmClient, |
| 325 |
GMM_RESOURCE_INFO *gmmResourceInfo); |
| 326 |
|
| 327 |
//! |
| 328 |
//! \brief Get current Gpu context priority |
| 329 |
//! \details Get current Gpu context priority |
| 330 |
//! |
| 331 |
//! \param [in] streamState |
| 332 |
//! Handle of Os Stream State |
| 333 |
//! |
| 334 |
//! [out] |
| 335 |
//! Current Gpu context priority |
| 336 |
//! |
| 337 |
static void GetGpuPriority(MOS_STREAM_HANDLE streamState, int32_t* priority); |
| 338 |
|
| 339 |
//! |
| 340 |
//! \brief Set current Gpu context priority |
| 341 |
//! \details Set current Gpu context priority |
| 342 |
//! |
| 343 |
//! \param [in] streamState |
| 344 |
//! Handle of Os Stream State |
| 345 |
//! [in] priority |
| 346 |
//! priority to set for gpu context |
| 347 |
//! |
| 348 |
static void SetGpuPriority(MOS_STREAM_HANDLE streamState, int32_t priority); |
| 349 |
|
| 350 |
//! |
| 351 |
//! \brief Get AuxTable base address |
| 352 |
//! |
| 353 |
//! \param [in] streamState |
| 354 |
//! Handle of Os Stream State |
| 355 |
//! \return uint64_t |
| 356 |
//! 64bit base address value of AuxTable |
| 357 |
//! |
| 358 |
static uint64_t GetAuxTableBaseAddr( |
| 359 |
MOS_STREAM_HANDLE streamState); |
| 360 |
|
| 361 |
//! |
| 362 |
//! \brief Create Gpu Context |
| 363 |
//! \details [GPU Context Interface] Create Gpu Context to submit cmdbuffers |
| 364 |
//! \details Caller: HAL (Media Context) only |
| 365 |
//! \details This func is called when a stream (Hal instance) needs a SW queue to submit cmd buffers programmed with GPU cmds. |
| 366 |
//! \details This queue contain options to indicate the properties of virtual GPU engine to execute these cmds. |
| 367 |
//! \details Caller can use Usage & option & GPU_CONTEXT_HANDLE to track and re-use the GPU contexts. |
| 368 |
//! |
| 369 |
//! \param [in] streamState |
| 370 |
//! Handle of Os Stream State |
| 371 |
//! \param [in] createOption |
| 372 |
//! Properties of Gpu context to create. They stand for the request from HAL on the Gpu context. |
| 373 |
//! The request include engine type, pipe count, restrictions, etc. |
| 374 |
//! \param [out] gpuContext |
| 375 |
//! Handle of gpu Context created. If creation failed, it is INVALID_HANLE |
| 376 |
//! GPU context stands for a SW queue in user space to submit cmd buffers FIFO. |
| 377 |
//! |
| 378 |
//! \return MOS_STATUS |
| 379 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 380 |
//! |
| 381 |
static MOS_STATUS CreateGpuContext( |
| 382 |
MOS_STREAM_HANDLE streamState, |
| 383 |
GpuContextCreateOption &createOption, |
| 384 |
GPU_CONTEXT_HANDLE &gpuContext); |
| 385 |
|
| 386 |
//! |
| 387 |
//! \brief Destroy Gpu Context |
| 388 |
//! \details [GPU Context Interface] Destroy Gpu Context to submit cmdbuffers |
| 389 |
//! \details Caller: HAL (Media Context) only |
| 390 |
//! \details This func is called when a stream (Hal instance) never needs this SW queue to submit cmd buffers |
| 391 |
//! \details This func is called only in the destruction stage of Hal instance. |
| 392 |
//! Never should be SetGpuContext called to set destroied Gpu Context. |
| 393 |
//! |
| 394 |
//! \param [in] streamState |
| 395 |
//! Handle of Os Stream State |
| 396 |
//! \param [in] gpuContext |
| 397 |
//! Handle of gpu Context to destroy. |
| 398 |
//! |
| 399 |
//! \return MOS_STATUS |
| 400 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 401 |
//! |
| 402 |
static MOS_STATUS DestroyGpuContext( |
| 403 |
MOS_STREAM_HANDLE streamState, |
| 404 |
GPU_CONTEXT_HANDLE gpuContext); |
| 405 |
|
| 406 |
//! |
| 407 |
//! \brief Set Gpu Context |
| 408 |
//! \details [GPU Context Interface] Set current Gpu Context to submit cmd buffers for the stream(Hal instance) |
| 409 |
//! \details Caller: HAL (Media Context) only |
| 410 |
//! \details This func is called when a stream (Hal instance) needs an existing GPU context to submit cmd buffers. |
| 411 |
//! \details Current GPU context is the major state of Os Stream State. |
| 412 |
//! \details Before getting a cmd buffer to program GPU cmds, a valid GPU context must be setted into the stream. |
| 413 |
//! \details Calling sequence is like: SetGpuContext -> GetCommandBuffer -> AddCommand ... |
| 414 |
//! -> ReturnCommandBuffer -> SubmitCommandBuffer -> SetGpuContext ... |
| 415 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 416 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 417 |
//! |
| 418 |
//! \param [in] streamState |
| 419 |
//! Handle of Os Stream State |
| 420 |
//! \param [in] gpuContext |
| 421 |
//! Current handle of gpu Context to set. |
| 422 |
//! |
| 423 |
//! \return MOS_STATUS |
| 424 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 425 |
//! |
| 426 |
static MOS_STATUS SetGpuContext( |
| 427 |
MOS_STREAM_HANDLE streamState, |
| 428 |
GPU_CONTEXT_HANDLE gpuContext); |
| 429 |
|
| 430 |
//! \brief Sets the object capture flags for Linux OCA dump |
| 431 |
//! \details Sets the object capture flags for Linux OCA dump |
| 432 |
//! |
| 433 |
//! \param PMOS_RESOURCE osResource |
| 434 |
//! [in] osResource |
| 435 |
//! \return MOS_STATUS |
| 436 |
//! Return MOS_STATUS_SUCCESS if success else failure reason |
| 437 |
//! |
| 438 |
static MOS_STATUS SetObjectCapture( |
| 439 |
PMOS_RESOURCE osResource); |
| 440 |
|
| 441 |
//! |
| 442 |
//! \brief Get GpuContext |
| 443 |
//! \details MOS internal toolset func to get GPU context instance |
| 444 |
//! |
| 445 |
//! \param [in] streamState |
| 446 |
//! Handle of Os Stream State |
| 447 |
//! \param [in] gpuContext |
| 448 |
//! MOS GPU Context handle |
| 449 |
//! |
| 450 |
//! \return GpuContextSpecificNext |
| 451 |
//! GPU Context instance got by GPU context handle, nullptr if get failed |
| 452 |
//! |
| 453 |
static GpuContextSpecificNext *GetGpuContext(MOS_STREAM_HANDLE streamState, GPU_CONTEXT_HANDLE handle); |
| 454 |
|
| 455 |
//! |
| 456 |
//! \brief Add Command |
| 457 |
//! \details [Cmd Buffer Interface] Add gpu commands into cmd buffer |
| 458 |
//! \details Caller: MHW only |
| 459 |
//! \details It is not device stated function and can be used in both APO MHW and NON-APO MOS. |
| 460 |
//! \details This func is called when a stream (Hal instance) adds gpu cmds into cmd buffer. |
| 461 |
//! \details Before getting a cmd buffer to program GPU cmds, a valid GPU context must be setted into the stream. |
| 462 |
//! \details Calling sequence is like: SetGpuContext -> GetCommandBuffer -> AddCommand ... |
| 463 |
//! -> ReturnCommandBuffer -> SubmitCommandBuffer -> SetGpuContext ... |
| 464 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 465 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 466 |
//! |
| 467 |
//! \param [in] cmdBuffer |
| 468 |
//! Handle of cmd buffer to add cmd. cmd buffer handle can be get by calling GetCommandBuffer. |
| 469 |
//! \param [in] cmd |
| 470 |
//! Pointer to the memory to indicate cmd, caller must make sure it's valid. |
| 471 |
//! \param [in] cmdSize |
| 472 |
//! Size of cmd to program. |
| 473 |
//! |
| 474 |
//! \return MOS_STATUS |
| 475 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 476 |
//! |
| 477 |
static MOS_STATUS AddCommand( |
| 478 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 479 |
const void *cmd, |
| 480 |
uint32_t cmdSize); |
| 481 |
|
| 482 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 483 |
//! |
| 484 |
//! \brief Dump Indirect state in Command Buffer |
| 485 |
//! |
| 486 |
static MOS_STATUS DumpIndirectStates( |
| 487 |
MOS_STREAM_HANDLE streamState, |
| 488 |
const char *filePathPrefix, |
| 489 |
std::time_t currentTime); |
| 490 |
//! |
| 491 |
//! \brief Dump Indirect state in Command Buffer |
| 492 |
//! |
| 493 |
//! \param [in] streamState |
| 494 |
//! Handle of Os Stream State |
| 495 |
//! \param [in] cmdBuffer |
| 496 |
//! Handle of cmd buffer to add cmd. cmd buffer handle can be get by calling GetCommandBuffer. |
| 497 |
//! \param [in] gpuNode |
| 498 |
//! Gpu node. |
| 499 |
//! \param [in] filePathPrefix |
| 500 |
//! The prefix for indirect state dump file. |
| 501 |
//! |
| 502 |
//! \return MOS_STATUS |
| 503 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 504 |
//! |
| 505 |
static MOS_STATUS DumpBindingTable( |
| 506 |
MOS_STREAM_HANDLE streamState, |
| 507 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 508 |
MOS_GPU_NODE gpuNode, |
| 509 |
const char *filePathPrefix); |
| 510 |
|
| 511 |
//! |
| 512 |
//! \brief Add Indirect state |
| 513 |
//! |
| 514 |
//! \param [in] streamState |
| 515 |
//! Handle of Os Stream State |
| 516 |
//! \param [in] stateSize |
| 517 |
//! Size of the state |
| 518 |
//! \param [in] pIndirectState |
| 519 |
//! ptr to the sys memory of state |
| 520 |
//! \param [in] gfxAddressBottom |
| 521 |
//! ptr which store bottom gfx address of the state |
| 522 |
//! \param [in] gfxAddressTop |
| 523 |
//! ptr which store top gfx address of the state |
| 524 |
//! \param [in] stateName |
| 525 |
//! Name of the state |
| 526 |
//! |
| 527 |
//! \return MOS_STATUS |
| 528 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 529 |
//! |
| 530 |
static MOS_STATUS AddIndirectState( |
| 531 |
MOS_STREAM_HANDLE streamState, |
| 532 |
uint32_t stateSize, |
| 533 |
uint32_t *pIndirectState, |
| 534 |
uint32_t *gfxAddressBottom, |
| 535 |
uint32_t *gfxAddressTop, |
| 536 |
const char *stateName, |
| 537 |
uint32_t gfxAddressBottomValue, |
| 538 |
uint32_t gfxAddressTopValue); |
| 539 |
|
| 540 |
//! |
| 541 |
//! \brief Dump Command Buffer |
| 542 |
//! \details [Cmd Buffer Interface] Dump an existing cmd buffer |
| 543 |
//! \details Caller: HAL only |
| 544 |
//! \details This func is called when a stream (Hal instance) needs to dump cmd buffer. |
| 545 |
//! \details Only after ReturnCommandBuffer can Command Buffer being dumped |
| 546 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 547 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 548 |
//! |
| 549 |
//! \param [in] streamState |
| 550 |
//! Handle of Os Stream State |
| 551 |
//! \param [in] cmdBuffer |
| 552 |
//! Handle of cmd buffer to add cmd. cmd buffer handle can be get by calling GetCommandBuffer. |
| 553 |
//! |
| 554 |
//! \return MOS_STATUS |
| 555 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 556 |
//! |
| 557 |
static MOS_STATUS DumpCommandBuffer( |
| 558 |
MOS_STREAM_HANDLE streamState, |
| 559 |
COMMAND_BUFFER_HANDLE cmdBuffer); |
| 560 |
|
| 561 |
static MOS_STATUS DumpSyncCommandBuffer( |
| 562 |
OsContextNext *osContext, |
| 563 |
GpuContextSpecificNext *gpuContext); |
| 564 |
#endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 565 |
|
| 566 |
//! |
| 567 |
//! \brief Get Command Buffer |
| 568 |
//! \details [Cmd Buffer Interface] Get current cmd buffer to program based on streamState |
| 569 |
//! \details Caller: HAL only |
| 570 |
//! \details This func is called when a stream (Hal instance) needs to get a cmd buffer corresponding to current GPU context in os stream state. |
| 571 |
//! \details Before getting a cmd buffer to program GPU cmds, a valid GPU context must be setted into the stream. |
| 572 |
//! \details Calling sequence is like: SetGpuContext -> GetCommandBuffer -> AddCommand ... |
| 573 |
//! -> ReturnCommandBuffer -> SubmitCommandBuffer -> SetGpuContext ... |
| 574 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 575 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 576 |
//! |
| 577 |
//! \param [in] streamState |
| 578 |
//! Handle of Os Stream State |
| 579 |
//! \param [out] cmdBuffer |
| 580 |
//! Handle of cmd buffer to get. If get failed, it is INVALID_HANLE. |
| 581 |
//! \param [in] pipeIdx |
| 582 |
//! Pipe index to indicate which pipe's cmdbuffer to get. |
| 583 |
//! In frame split, pipe index is indicated to get secondary cmd buffers. They are cmd buffers split to different engines. |
| 584 |
//! |
| 585 |
//! \return MOS_STATUS |
| 586 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 587 |
//! |
| 588 |
static MOS_STATUS GetCommandBuffer( |
| 589 |
MOS_STREAM_HANDLE streamState, |
| 590 |
COMMAND_BUFFER_HANDLE &cmdBuffer, |
| 591 |
uint32_t pipeIdx = 0); |
| 592 |
|
| 593 |
//! |
| 594 |
//! \brief Return Command Buffer |
| 595 |
//! \details [Cmd Buffer Interface] Return current cmd buffer to the MOS |
| 596 |
//! \details Caller: HAL only |
| 597 |
//! \details This func is called when a stream (Hal instance) finished add cmds into a cmd buffer. |
| 598 |
//! \details ReturnCommandBuffer must be called before submit cmd buffer. MOS will do necessary operations in this interface. |
| 599 |
//! \details Calling sequence is like: SetGpuContext -> GetCommandBuffer -> AddCommand ... |
| 600 |
//! -> ReturnCommandBuffer -> SubmitCommandBuffer -> SetGpuContext ... |
| 601 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 602 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 603 |
//! |
| 604 |
//! \param [in] streamState |
| 605 |
//! Handle of Os Stream State |
| 606 |
//! \param [in] cmdBuffer |
| 607 |
//! Handle of cmd buffer to return. |
| 608 |
//! \param [in] pipeIdx |
| 609 |
//! Pipe index to indicate which pipe's cmdbuffer to get. |
| 610 |
//! In frame split, pipe index is indicated to get secondary cmd buffers. They are cmd buffers split to different engines. |
| 611 |
//! |
| 612 |
//! \return MOS_STATUS |
| 613 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 614 |
//! |
| 615 |
static MOS_STATUS ReturnCommandBuffer( |
| 616 |
MOS_STREAM_HANDLE streamState, |
| 617 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 618 |
uint32_t pipeIdx = 0); |
| 619 |
|
| 620 |
//! |
| 621 |
//! \brief Submit Command Buffer |
| 622 |
//! \details [Cmd Buffer Interface] Submit current cmd buffer to current GPU context queue. |
| 623 |
//! \details Caller: HAL only |
| 624 |
//! \details When a stream (Hal instance) call this interface, cmd buffer is enqueued into current GPU context in streamState. |
| 625 |
//! \details OS runtime and KMD will schedule the workload. HW cmds in the cmd buffer will be executed in HW engines. |
| 626 |
//! \details Calling sequence is like: SetGpuContext -> GetCommandBuffer -> AddCommand ... |
| 627 |
//! -> ReturnCommandBuffer -> SubmitCommandBuffer -> SetGpuContext ... |
| 628 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 629 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 630 |
//! \details Cmd buffer execution in GPU context is async with Hal programming. Return of this interface does not guarantee finish executing actual cmds. |
| 631 |
//! |
| 632 |
//! \param [in] streamState |
| 633 |
//! Handle of Os Stream State |
| 634 |
//! \param [in] cmdBuffer |
| 635 |
//! Handle of cmd buffer to Submit. |
| 636 |
//! If there is frame split case (more than 1 pipe) in current GPU context queue, this is primary cmd buffer handle. |
| 637 |
//! \param [in] nullRendering |
| 638 |
//! Flag to indicate if not actually submit workload into HW. |
| 639 |
//! |
| 640 |
//! \return MOS_STATUS |
| 641 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 642 |
//! |
| 643 |
static MOS_STATUS SubmitCommandBuffer( |
| 644 |
MOS_STREAM_HANDLE streamState, |
| 645 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 646 |
bool nullRendering = false); |
| 647 |
|
| 648 |
//! |
| 649 |
//! \brief Reset Command Buffer |
| 650 |
//! \details [Cmd Buffer Interface] Reset cmd buffer to the initialized state. |
| 651 |
//! \details Caller: HAL only |
| 652 |
//! \details ResetCommandBuffer can be called after a stream (Hal instance) call GetCommandBuffer. |
| 653 |
//! \details OS runtime and KMD will schedule the workload. HW cmds in the cmd buffer will be executed in HW engines. |
| 654 |
//! \details Calling sequence is like: SetGpuContext -> GetCommandBuffer (-> ResetCommandBuffer) -> AddCommand ... |
| 655 |
//! \details If Current GPU context is never set, all command buffer / resource interfaces cannot be used. |
| 656 |
//! (They will return MOS_STATUS_INVALID_GPU_CONTEXT) |
| 657 |
//! \details Cmd buffer reset means stream starts to program a new set of cmds into a cmd buffer got. |
| 658 |
//! This interface must not be called when the cmd buffer already programed cmds and not submitted unless the stream needs to drop these cmds. |
| 659 |
//! |
| 660 |
//! \param [in] streamState |
| 661 |
//! Handle of Os Stream State |
| 662 |
//! \param [in, out] cmdBuffer |
| 663 |
//! Handle of cmd buffer to reset. |
| 664 |
//! If there is frame split case (more than 1 pipe) in current GPU context queue, this is primary cmd buffer handle. |
| 665 |
//! |
| 666 |
//! \return MOS_STATUS |
| 667 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 668 |
//! |
| 669 |
static MOS_STATUS ResetCommandBuffer( |
| 670 |
MOS_STREAM_HANDLE streamState, |
| 671 |
COMMAND_BUFFER_HANDLE cmdBuffer); |
| 672 |
|
| 673 |
//! |
| 674 |
//! \brief Verify Command Buffer Size |
| 675 |
//! \details [Cmd Buffer Interface] Check if cmd buffer size is larger than the requested size |
| 676 |
//! \details Caller: HAL only |
| 677 |
//! |
| 678 |
//! \param [in] streamState |
| 679 |
//! Handle of Os Stream State |
| 680 |
//! \param [in, out] cmdBuffer |
| 681 |
//! Handle of cmd buffer to verify size |
| 682 |
//! \param [in] requestedSize |
| 683 |
//! Requested size |
| 684 |
//! \param [in] pipeIdx |
| 685 |
//! Pipe index to indicate which pipe's cmdbuffer to verify. |
| 686 |
//! In frame split, pipe index is indicated to get secondary cmd buffers. They are cmd buffers split to different engines. |
| 687 |
//! |
| 688 |
//! \return MOS_STATUS |
| 689 |
//! Return MOS_STATUS_SUCCESS if successful, MOS_STATUS_UNKNOWN if size does not meet the requirment, otherwise failed |
| 690 |
//! |
| 691 |
static MOS_STATUS VerifyCommandBufferSize( |
| 692 |
MOS_STREAM_HANDLE streamState, |
| 693 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 694 |
uint32_t requestedSize, |
| 695 |
uint32_t pipeIdx = 0); |
| 696 |
|
| 697 |
//! |
| 698 |
//! \brief Resize Command Buffer and Patch List |
| 699 |
//! \details [Cmd Buffer Interface] Resize the cmd buffer to contain more cmds. Resize the patch list to have more resource.s |
| 700 |
//! \details Caller: HAL only |
| 701 |
//! \details ResizeCommandBuffer can be called at any time if providing valid a cmd buffer. |
| 702 |
//! When cmds number to be added is increased, this interface needs to be called. |
| 703 |
//! MOS will make sure the existing cmds copied to the resized cmd buffer. |
| 704 |
//! Patch list contain the entries to patch cmds. When cmds number to be added is increased, this interface needs to be called. |
| 705 |
//! \details Recommand to call this interface only once for a specific cmd buffer with a conservative requestedSize. |
| 706 |
//! |
| 707 |
//! \param [in] streamState |
| 708 |
//! Handle of Os Stream State |
| 709 |
//! \param [in, out] cmdBuffer |
| 710 |
//! Handle of cmd buffer to resize. |
| 711 |
//! \param [in] requestedSize |
| 712 |
//! Requested size. If the size already larger than the requirement, no operations is done to cmd buffer. |
| 713 |
//! \param [in] requestedPatchListSize |
| 714 |
//! Requested patch list size. If the size already larger than the requirement, no operations is done to cmd buffer. |
| 715 |
//! \param [in] pipeIdx |
| 716 |
//! Pipe index to indicate which pipe's cmdbuffer to resize. |
| 717 |
//! In frame split, pipe index is indicated to get secondary cmd buffers. They are cmd buffers split to different engines. |
| 718 |
//! |
| 719 |
//! \return MOS_STATUS |
| 720 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 721 |
//! |
| 722 |
static MOS_STATUS ResizeCommandBufferAndPatchList( |
| 723 |
MOS_STREAM_HANDLE streamState, |
| 724 |
COMMAND_BUFFER_HANDLE cmdBuffer, |
| 725 |
uint32_t requestedSize, |
| 726 |
uint32_t requestedPatchListSize, |
| 727 |
uint32_t pipeIdx = 0); |
| 728 |
|
| 729 |
//! |
| 730 |
//! \brief Set Patch Entry |
| 731 |
//! \details [Cmd Buffer Interface] Set a patch entry in cmd buffer. |
| 732 |
//! \details Caller: MHW only |
| 733 |
//! \details This interface is called only when adding a resource into a cmd. |
| 734 |
//! The entries in cmd buffer indicate the gfx address to be patched. |
| 735 |
//! |
| 736 |
//! \param [in] streamState |
| 737 |
//! Handle of Os Stream State |
| 738 |
//! \param [in] params |
| 739 |
//! Pointer to the patch entry parameters. |
| 740 |
//! |
| 741 |
//! \return MOS_STATUS |
| 742 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 743 |
//! |
| 744 |
static MOS_STATUS SetPatchEntry( |
| 745 |
MOS_STREAM_HANDLE streamState, |
| 746 |
PMOS_PATCH_ENTRY_PARAMS params); |
| 747 |
|
| 748 |
//! |
| 749 |
//! \brief Get Indirect State |
| 750 |
//! \details [Cmd Buffer Interface] Get the indirect state in cmd buffer. |
| 751 |
//! \details Caller: MHW only |
| 752 |
//! \details This interface is called when preparing indirect state data in cmd buffer. |
| 753 |
//! Indirect state is a reserved region in cmd buffer which contains the data needed by execute Media kernel. |
| 754 |
//! |
| 755 |
//! \param [in] streamState |
| 756 |
//! Handle of Os Stream State |
| 757 |
//! \param [out] indirectState |
| 758 |
//! Pointer to pointer to indirectState data. MHW can use this ptr to set data. |
| 759 |
//! \param [out] offset |
| 760 |
//! Offset of indirect state in the cmd buffer. |
| 761 |
//! \param [out] size |
| 762 |
//! Size of indirect state in the cmd buffer. |
| 763 |
//! |
| 764 |
//! \return MOS_STATUS |
| 765 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 766 |
//! |
| 767 |
static MOS_STATUS GetIndirectState( |
| 768 |
MOS_STREAM_HANDLE streamState, |
| 769 |
uint8_t **indirectState, |
| 770 |
uint32_t &offset, |
| 771 |
uint32_t &size); |
| 772 |
|
| 773 |
//! |
| 774 |
//! \brief Setup indirect state |
| 775 |
//! \details [Cmd Buffer Interface] Setup the indirect state region in cmd buffer. |
| 776 |
//! \details Caller: MHW only |
| 777 |
//! \details This interface is called to reserve the region of indirect state data in cmd buffer. |
| 778 |
//! \details Indirect state is a reserved region in cmd buffer which contains the data needed by execute Media kernel. |
| 779 |
//! The region is at the end of cmd buffer, size is only needed. Between each SubmitCommandBuffer, this interface should only be call once. |
| 780 |
//! |
| 781 |
//! \param [in] streamState |
| 782 |
//! Handle of Os Stream State |
| 783 |
//! \param [in] size |
| 784 |
//! Size of indirect state in the cmd buffer. |
| 785 |
//! |
| 786 |
//! \return MOS_STATUS |
| 787 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 788 |
//! |
| 789 |
static MOS_STATUS SetupIndirectState( |
| 790 |
MOS_STREAM_HANDLE streamState, |
| 791 |
uint32_t size); |
| 792 |
|
| 793 |
//! |
| 794 |
//! \brief Setup commandlist and command pool |
| 795 |
//! \details Set the commandlist and commandPool used in this stream. |
| 796 |
//! |
| 797 |
//! \param [in] streamState |
| 798 |
//! Handle of Os Stream State |
| 799 |
//! \param [in] cmdList |
| 800 |
//! pointer to the command list. |
| 801 |
//! \param [in] cmdBufMgr |
| 802 |
//! pointer to the command buffer manager. |
| 803 |
//! |
| 804 |
//! \return MOS_STATUS |
| 805 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 806 |
//! |
| 807 |
static MOS_STATUS SetupCurrentCmdListAndPool( |
| 808 |
MOS_STREAM_HANDLE streamState, |
| 809 |
CommandList *cmdList, |
| 810 |
CmdBufMgrNext *cmdBufMgr); |
| 811 |
|
| 812 |
//! |
| 813 |
//! \brief Setup commandlist and command pool from os interface |
| 814 |
//! \details Set the commandlist and commandPool used in this stream from os interface. |
| 815 |
//! |
| 816 |
//! \param [in] pMosInterface |
| 817 |
//! pointer to the mos interface |
| 818 |
//! \param [out] streamStateDst |
| 819 |
//! Handle of Os Stream State. |
| 820 |
//! |
| 821 |
//! \return MOS_STATUS |
| 822 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 823 |
//! |
| 824 |
static MOS_STATUS SetupCurrentCmdListAndPoolFromOsInterface( |
| 825 |
PMOS_INTERFACE pMosInterface, |
| 826 |
MOS_STREAM_HANDLE streamState); |
| 827 |
|
| 828 |
//! |
| 829 |
//! \brief Is Device Async or not |
| 830 |
//! \details Is Device Async or not. |
| 831 |
//! |
| 832 |
//! \param [in] streamStateDst |
| 833 |
//! Handle of Os Stream State. |
| 834 |
//! |
| 835 |
//! \return bool |
| 836 |
//! Return true if is async, otherwise false |
| 837 |
//! |
| 838 |
static bool IsAsyncDevice( |
| 839 |
MOS_STREAM_HANDLE streamState); |
| 840 |
|
| 841 |
//! |
| 842 |
//! \brief Setup VE Attribute Buffer |
| 843 |
//! \details [Cmd Buffer Interface] Setup VE Attribute Buffer into cmd buffer. |
| 844 |
//! \details Caller: MHW only |
| 845 |
//! \details This interface is called to setup into cmd buffer. |
| 846 |
//! |
| 847 |
//! \param [in] streamState |
| 848 |
//! Handle of Os Stream State |
| 849 |
//! \param [out] cmdBuffer |
| 850 |
//! Cmd buffer to setup VE attribute. |
| 851 |
//! |
| 852 |
//! \return MOS_STATUS |
| 853 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 854 |
//! |
| 855 |
static MOS_STATUS SetupAttributeVeBuffer( |
| 856 |
MOS_STREAM_HANDLE streamState, |
| 857 |
COMMAND_BUFFER_HANDLE cmdBuffer); |
| 858 |
|
| 859 |
//! |
| 860 |
//! \brief Get VE Attribute Buffer |
| 861 |
//! \details [Cmd Buffer Interface] Get VE Attribute Buffer from cmd buffer. |
| 862 |
//! \details Caller: HAL only |
| 863 |
//! \details This interface is called to get VE attribute buffer from cmd buffer if it contains one. |
| 864 |
//! If there is no VE attribute buffer returned, it means the cmd buffer has no such buffer |
| 865 |
//! in current MOS module. It is not error state if it is nullptr. |
| 866 |
//! |
| 867 |
//! \param [out] cmdBuffer |
| 868 |
//! Cmd buffer to setup VE attribute. |
| 869 |
//! |
| 870 |
//! \return MOS_CMD_BUF_ATTRI_VE* |
| 871 |
//! Return pointer of VE attribute buffer, nullptr if current cmdBuffer didn't contain attribute. |
| 872 |
//! |
| 873 |
static MOS_CMD_BUF_ATTRI_VE *GetAttributeVeBuffer( |
| 874 |
COMMAND_BUFFER_HANDLE cmdBuffer); |
| 875 |
|
| 876 |
//! |
| 877 |
//! \brief Get Cache Policy Memory Object |
| 878 |
//! \details [Resource Interface] Get Cache Policy Memory Object in GMM corresponding to the resource usage |
| 879 |
//! Caller: HAL & MHW |
| 880 |
//! |
| 881 |
//! \param [in] mosUsage |
| 882 |
//! Resource usage as index to the memory object table |
| 883 |
//! If prociding unknown usage, default state will be returned |
| 884 |
//! |
| 885 |
//! \return MEMORY_OBJECT_CONTROL_STATE |
| 886 |
//! The cache policy memory object got from MOS interface |
| 887 |
//! |
| 888 |
static GMM_RESOURCE_USAGE_TYPE GetGmmResourceUsageType( |
| 889 |
MOS_HW_RESOURCE_DEF mosUsage); |
| 890 |
|
| 891 |
//! |
| 892 |
//! \brief Get MOS_HW_RESOURCE_DEF |
| 893 |
//! \details [Resource Interface] Get Mos HW Resource DEF |
| 894 |
//! Caller: HAL & MHW |
| 895 |
//! |
| 896 |
//! \param [in] gmmResUsage |
| 897 |
//! Gmm Resource usage as index |
| 898 |
//! |
| 899 |
//! \return MOS_HW_RESOURCE_DEF |
| 900 |
//! Mos HW resource definition |
| 901 |
//! |
| 902 |
static MOS_HW_RESOURCE_DEF GmmToMosResourceUsageType( |
| 903 |
GMM_RESOURCE_USAGE_TYPE gmmResUsage); |
| 904 |
|
| 905 |
//! |
| 906 |
//! \brief Get Cache Policy Memory Object |
| 907 |
//! \details [Resource Interface] Get Cache Policy Memory Object in GMM corresponding to the resource usage |
| 908 |
//! Caller: HAL & MHW |
| 909 |
//! |
| 910 |
//! \param [in] gmmClientContext |
| 911 |
//! Handle of gmmClientContext |
| 912 |
//! \param [in] mosUsage |
| 913 |
//! Resource usage as index to the memory object table |
| 914 |
//! If prociding unknown usage, default state will be returned |
| 915 |
//! |
| 916 |
//! \return MEMORY_OBJECT_CONTROL_STATE |
| 917 |
//! The cache policy memory object got from MOS interface |
| 918 |
//! |
| 919 |
static MEMORY_OBJECT_CONTROL_STATE GetCachePolicyMemoryObject( |
| 920 |
GMM_CLIENT_CONTEXT *gmmClientContext, |
| 921 |
MOS_HW_RESOURCE_DEF mosUsage); |
| 922 |
|
| 923 |
//! |
| 924 |
//! \brief Get default Cache Policy Memory Object |
| 925 |
//! \details [Resource Interface] Get Cache Policy Memory Object in GMM corresponding to the resource usage |
| 926 |
//! Caller: HAL & MHW |
| 927 |
//! |
| 928 |
//! \param [in] gmmClientContext |
| 929 |
//! Handle of gmmClientContext |
| 930 |
//! If prociding unknown usage, default state will be returned |
| 931 |
//! |
| 932 |
//! \return MEMORY_OBJECT_CONTROL_STATE |
| 933 |
//! The cache policy memory object got from MOS interface |
| 934 |
//! |
| 935 |
static MEMORY_OBJECT_CONTROL_STATE GetDefaultCachePolicyMemoryObject( |
| 936 |
GMM_CLIENT_CONTEXT *gmmClientContext); |
| 937 |
|
| 938 |
//! |
| 939 |
//! \brief Get Cache Policy Memory Object |
| 940 |
//! \details [Resource Interface] Get Cache Policy Memory Object in GMM corresponding to the resource usage |
| 941 |
//! Caller: MOS |
| 942 |
//! |
| 943 |
//! \param [in] gmmClientContext |
| 944 |
//! Handle of gmmClientContext |
| 945 |
//! \param [in] gmmUsage |
| 946 |
//! Resource usage value defined in gmm |
| 947 |
//! If prociding unknown usage, default state will be returned |
| 948 |
//! |
| 949 |
//! \return MEMORY_OBJECT_CONTROL_STATE |
| 950 |
//! The cache policy memory object got from MOS interface |
| 951 |
//! |
| 952 |
static MEMORY_OBJECT_CONTROL_STATE GetGmmCachePolicyMemoryObject( |
| 953 |
GMM_CLIENT_CONTEXT *gmmClientContext, |
| 954 |
GMM_RESOURCE_USAGE_TYPE gmmUsage); |
| 955 |
|
| 956 |
//! |
| 957 |
//! \brief Get Cache Policy L1 Config |
| 958 |
//! \details [Resource Interface] Get L1 Cache Config in GMM corresponding to the resource usage |
| 959 |
//! Caller: HAL & MHW |
| 960 |
//! |
| 961 |
//! \param [in] streamState |
| 962 |
//! Handle of Os Stream State |
| 963 |
//! \param [in] mosUsage |
| 964 |
//! Resource usage as index to the memory object table |
| 965 |
//! If prociding unknown usage, default state will be returned |
| 966 |
//! |
| 967 |
//! \return uint8_t |
| 968 |
//! The L1_Cache_Config got from MOS interface |
| 969 |
//! |
| 970 |
static uint8_t GetCachePolicyL1Config( |
| 971 |
MOS_STREAM_HANDLE streamState, |
| 972 |
MOS_HW_RESOURCE_DEF mosUsage); |
| 973 |
|
| 974 |
//! |
| 975 |
//! \brief Get Reserved info from resource |
| 976 |
//! \details |
| 977 |
//! |
| 978 |
//! \param [in] resource |
| 979 |
//! Handle of resource |
| 980 |
//! \param [out] val |
| 981 |
//! result of info. |
| 982 |
//! |
| 983 |
//! \return MOS_STATUS |
| 984 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 985 |
//! |
| 986 |
static MOS_STATUS GetReservedFromResource(MOS_RESOURCE_HANDLE resource, uint32_t &val); |
| 987 |
|
| 988 |
//! |
| 989 |
//! \brief Get Reserved info from Stream |
| 990 |
//! \details |
| 991 |
//! |
| 992 |
//! \param [in] stream |
| 993 |
//! Handle of stream |
| 994 |
//! \param [out] val |
| 995 |
//! result of info. |
| 996 |
//! |
| 997 |
//! \return MOS_STATUS |
| 998 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 999 |
//! |
| 1000 |
static MOS_STATUS GetReservedFromStream(MOS_STREAM_HANDLE stream, uint32_t &val); |
| 1001 |
|
| 1002 |
//! |
| 1003 |
//! \brief Get Reserved info from Device |
| 1004 |
//! \details |
| 1005 |
//! |
| 1006 |
//! \param [in] osDeivceContext |
| 1007 |
//! Handle of device |
| 1008 |
//! \param [out] val |
| 1009 |
//! result of info. |
| 1010 |
//! |
| 1011 |
//! \return MOS_STATUS |
| 1012 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1013 |
//! |
| 1014 |
static MOS_STATUS GetReservedFromDevice(MOS_DEVICE_HANDLE device, uint32_t &val); |
| 1015 |
|
| 1016 |
//! |
| 1017 |
//! \brief Get preStreamParameters(mos context) info from streamState |
| 1018 |
//! \details |
| 1019 |
//! |
| 1020 |
//! \param [in] stream |
| 1021 |
//! Handle of stream |
| 1022 |
//! \param [out] perStreamParameters |
| 1023 |
//! pointer of mos conxtex. |
| 1024 |
//! |
| 1025 |
//! \return MOS_STATUS |
| 1026 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1027 |
//! |
| 1028 |
static MOS_STATUS GetperStreamParameters(MOS_STREAM_HANDLE stream, void **perStreamParameters); |
| 1029 |
|
| 1030 |
//! |
| 1031 |
//! \brief Convert Resource From Ddi |
| 1032 |
//! \details [Resource Interface] Convert Resource structure From OS/API specific to MOS reource. |
| 1033 |
//! \details Caller: DDI only |
| 1034 |
//! \details It is not device stated function and can be used in both APO DDI and NON-APO MOS. |
| 1035 |
//! \details MOS resoure is the structure inside MOS module. DDI specific resource depends on OS/API verison. |
| 1036 |
//! DDI call this to convert external resources (not created by hal) to Mos resources so that HAL & MHW can use them. |
| 1037 |
//! |
| 1038 |
//! \param [in] osResource |
| 1039 |
//! OS/API specific resource structure to convert. |
| 1040 |
//! \param [out] resource |
| 1041 |
//! Handle of Mos resource convert. |
| 1042 |
//! \param UINT firstArraySlice |
| 1043 |
//! [in] resource special info |
| 1044 |
//! \param UINT mipSlice |
| 1045 |
//! [in] resource special info |
| 1046 |
//! |
| 1047 |
//! \return MOS_STATUS |
| 1048 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1049 |
//! |
| 1050 |
static MOS_STATUS ConvertResourceFromDdi( |
| 1051 |
OsSpecificRes osResource, |
| 1052 |
MOS_RESOURCE_HANDLE &resource, |
| 1053 |
uint32_t firstArraySlice, |
| 1054 |
uint32_t mipSlice); |
| 1055 |
|
| 1056 |
//! |
| 1057 |
//! \brief Create Os Specific Resource Info |
| 1058 |
//! \details [Resource Interface] Create OS/API specific resource info structures. |
| 1059 |
//! \details Caller: DDI only |
| 1060 |
//! \details Os Specific resource info must be created before uing in DDI or converting to MOS resource. |
| 1061 |
//! This interface doesn't allocate Os Specific Resource. It only create the decorated structure of that resource. |
| 1062 |
//! |
| 1063 |
//! \param [in, out] resource |
| 1064 |
//! OS/API specific resource structure to initialize. |
| 1065 |
//! \param [in] isInternal |
| 1066 |
//! Indicate if the resource is media internal. |
| 1067 |
//! |
| 1068 |
//! \return MOS_STATUS |
| 1069 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1070 |
//! |
| 1071 |
static MOS_STATUS CreateOsSpecificResourceInfo(OsSpecificRes resource, bool isInternal = false); |
| 1072 |
|
| 1073 |
//! |
| 1074 |
//! \brief Destroy Os Specific Resource Info |
| 1075 |
//! \details [Resource Interface] Destroy OS/API specific resource structure. |
| 1076 |
//! \details Caller: DDI only |
| 1077 |
//! \details It is not device stated function and can be used in both APO DDI and NON-APO MOS. |
| 1078 |
//! \details Os Specific resource info must be destroied if the resource is not used anymore. |
| 1079 |
//! |
| 1080 |
//! \param [in, out] resource |
| 1081 |
//! OS/API specific resource structure to initialize. |
| 1082 |
//! |
| 1083 |
//! \return MOS_STATUS |
| 1084 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1085 |
//! |
| 1086 |
static MOS_STATUS DestroySpecificResourceInfo(OsSpecificRes resource); |
| 1087 |
|
| 1088 |
//! |
| 1089 |
//! \brief Allocate Resource |
| 1090 |
//! \details [Resource Interface] Allocate a graphic resource. |
| 1091 |
//! \details Caller: HAL only |
| 1092 |
//! \details Graphic resource is a buffer contain data used in the HW cmds. |
| 1093 |
//! This interface allocates the gfx resource and its internal data structure. |
| 1094 |
//! RegisterResource must be called when cmds in cmd buffer programmed are using this resource. |
| 1095 |
//! |
| 1096 |
//! \param [in] streamState |
| 1097 |
//! Handle of Os Stream State |
| 1098 |
//! \param [in] params |
| 1099 |
//! Pointer to the parameters for allocating resource |
| 1100 |
//! \param [out] resource |
| 1101 |
//! MOS Resource handle of the allocated resource. |
| 1102 |
//! |
| 1103 |
//! \return MOS_STATUS |
| 1104 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1105 |
//! |
| 1106 |
static MOS_STATUS AllocateResource( |
| 1107 |
MOS_STREAM_HANDLE streamState, |
| 1108 |
PMOS_ALLOC_GFXRES_PARAMS params, // user provided va |
| 1109 |
MOS_RESOURCE_HANDLE &resource |
| 1110 |
#if MOS_MESSAGES_ENABLED |
| 1111 |
, |
| 1112 |
const char *functionName, |
| 1113 |
const char *filename, |
| 1114 |
int32_t line |
| 1115 |
#endif |
| 1116 |
); |
| 1117 |
|
| 1118 |
//! |
| 1119 |
//! \brief Convert HAL free flags to OS free flags |
| 1120 |
//! |
| 1121 |
//! \param [in] halFreeFlag |
| 1122 |
//! bit definition in MOS_GFXRES_FREE_FLAGS |
| 1123 |
//! |
| 1124 |
//! \return uint32_t |
| 1125 |
//! OS resource deallc flags |
| 1126 |
//! |
| 1127 |
static uint32_t ConvertHalFreeFlagsToOsFreeFlags( |
| 1128 |
uint32_t halFreeFlag |
| 1129 |
); |
| 1130 |
|
| 1131 |
//! |
| 1132 |
//! \brief Free Resource |
| 1133 |
//! \details [Resource Interface] Free a graphic resource. |
| 1134 |
//! \details Caller: HAL only |
| 1135 |
//! \details Graphic resource is a buffer contain data used in the HW cmds. |
| 1136 |
//! This interface frees the gfx resource and its internal data structure. |
| 1137 |
//! This interface must be called when the resource is not used anymore. |
| 1138 |
//! |
| 1139 |
//! \param [in] streamState |
| 1140 |
//! Handle of Os Stream State |
| 1141 |
//! \param [in] resource |
| 1142 |
//! MOS Resource handle of the allocated resource. |
| 1143 |
//! \param [in] flag |
| 1144 |
//! User defined free flag of the resource. |
| 1145 |
//! |
| 1146 |
//! \return MOS_STATUS |
| 1147 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1148 |
//! |
| 1149 |
static MOS_STATUS FreeResource( |
| 1150 |
MOS_STREAM_HANDLE streamState, |
| 1151 |
MOS_RESOURCE_HANDLE resource, |
| 1152 |
uint32_t flag |
| 1153 |
#if MOS_MESSAGES_ENABLED |
| 1154 |
, |
| 1155 |
const char *functionName, |
| 1156 |
const char *filename, |
| 1157 |
int32_t line |
| 1158 |
#endif // MOS_MESSAGES_ENABLED |
| 1159 |
); |
| 1160 |
|
| 1161 |
static MOS_STATUS FreeResource( |
| 1162 |
OsDeviceContext *osDeviceContext, |
| 1163 |
MOS_RESOURCE_HANDLE resource, |
| 1164 |
uint32_t flag |
| 1165 |
#if MOS_MESSAGES_ENABLED |
| 1166 |
, |
| 1167 |
const char *functionName, |
| 1168 |
const char *filename, |
| 1169 |
int32_t line |
| 1170 |
#endif // MOS_MESSAGES_ENABLED |
| 1171 |
); |
| 1172 |
|
| 1173 |
//! |
| 1174 |
//! \brief Get Resource Info |
| 1175 |
//! \details [Resource Interface] Get the info of a graphic resource. |
| 1176 |
//! \details Caller: HAL only |
| 1177 |
//! \details This interface gets the read-only detailed info of a graphic resource. |
| 1178 |
//! Any modification of details provided by this interface will not impact the actual resource. |
| 1179 |
//! |
| 1180 |
//! \param [in] streamState |
| 1181 |
//! Handle of Os Stream State |
| 1182 |
//! \param [in] resource |
| 1183 |
//! MOS Resource handle of the allocated resource. |
| 1184 |
//! \param [out] details |
| 1185 |
//! Resource detailed info got. |
| 1186 |
//! |
| 1187 |
//! \return MOS_STATUS |
| 1188 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1189 |
//! |
| 1190 |
static MOS_STATUS GetResourceInfo( |
| 1191 |
MOS_STREAM_HANDLE streamState, |
| 1192 |
MOS_RESOURCE_HANDLE resource, |
| 1193 |
MosResourceInfo &details); |
| 1194 |
|
| 1195 |
//! |
| 1196 |
//! \brief Lock Resource |
| 1197 |
//! \details [Resource Interface] Lock the gfx resource for CPU to access |
| 1198 |
//! \details Caller: HAL only |
| 1199 |
//! \details A sys memory ptr will be provided by this interface if executed successfully. |
| 1200 |
//! \details The sys memory is mapped to the gfx memory inside MOS module. |
| 1201 |
//! \details This interface is usually for driver to read/write data into a resource directly (without program HW cmd). |
| 1202 |
//! \details This interface will call the overloading LockMosResource for MOS. |
| 1203 |
//! |
| 1204 |
//! \param [in] streamState |
| 1205 |
//! Handle of Os Stream State |
| 1206 |
//! \param [in] resource |
| 1207 |
//! MOS Resource handle of the resource to lock. |
| 1208 |
//! \param [in] flags |
| 1209 |
//! Control flags of locking resource. |
| 1210 |
//! |
| 1211 |
//! \return void * |
| 1212 |
//! Locked memory data pointer, nullptr if lock failed. |
| 1213 |
//! |
| 1214 |
static void *LockMosResource( |
| 1215 |
MOS_STREAM_HANDLE streamState, |
| 1216 |
MOS_RESOURCE_HANDLE resource, |
| 1217 |
PMOS_LOCK_PARAMS flags); |
| 1218 |
//! |
| 1219 |
//! \brief Lock Resource |
| 1220 |
//! \details [Resource Interface] Lock the gfx resource for CPU to access |
| 1221 |
//! \details Caller: MOS only |
| 1222 |
//! \details A sys memory ptr will be provided by this interface if executed successfully. |
| 1223 |
//! \details The sys memory is mapped to the gfx memory inside MOS module. |
| 1224 |
//! \details This interface is usually for driver to read/write data into a resource directly (without program HW cmd). |
| 1225 |
//! \details Caller must make sure no access out of bound of the locked out data. UnlockResource must be called when finished access the locked data. |
| 1226 |
//! A resource already been locked cannot be locked again. |
| 1227 |
//! This is a blocking call if the resource is used by the cmdbuffer which already submitted to an existing GPU context. |
| 1228 |
//! Unless SkipResourceSync is called. This interface will make sure the sync of Lock. |
| 1229 |
//! \details If the resource is compressed, gfx memory decompression will be triggered. |
| 1230 |
//! |
| 1231 |
//! \param [in] OsDeviceContext |
| 1232 |
//! Os Device Context |
| 1233 |
//! \param [in] resource |
| 1234 |
//! MOS Resource handle of the resource to lock. |
| 1235 |
//! \param [in] flags |
| 1236 |
//! Control flags of locking resource. |
| 1237 |
//! |
| 1238 |
//! \return void * |
| 1239 |
//! Locked memory data pointer, nullptr if lock failed. |
| 1240 |
//! |
| 1241 |
static void *LockMosResource( |
| 1242 |
OsDeviceContext *osDeviceContext, |
| 1243 |
MOS_RESOURCE_HANDLE resource, |
| 1244 |
PMOS_LOCK_PARAMS flags, |
| 1245 |
bool isDumpPacket=0); |
| 1246 |
|
| 1247 |
//! |
| 1248 |
//! \brief Unlock Resource |
| 1249 |
//! \details [Resource Interface] Unlock the gfx resource which is locked out. |
| 1250 |
//! \details Caller: HAL only |
| 1251 |
//! \details UnlockResource must be called when finished access the locked data of the resource. |
| 1252 |
//! A resource already been unlocked cannot be unlocked again. |
| 1253 |
//! \details Unlock resource will not trigger compressing or changing the layout of the resource. |
| 1254 |
//! \details This interface will call the overloading UnlockMosResource for MOS. |
| 1255 |
//! |
| 1256 |
//! \param [in] streamState |
| 1257 |
//! Handle of Os Stream State |
| 1258 |
//! \param [in] resource |
| 1259 |
//! MOS Resource handle of the allocated resource. |
| 1260 |
//! |
| 1261 |
//! \return MOS_STATUS |
| 1262 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1263 |
//! |
| 1264 |
static MOS_STATUS UnlockMosResource( |
| 1265 |
MOS_STREAM_HANDLE streamState, |
| 1266 |
MOS_RESOURCE_HANDLE resource); |
| 1267 |
//! |
| 1268 |
//! \brief Unlock Resource |
| 1269 |
//! \details [Resource Interface] Unlock the gfx resource which is locked out. |
| 1270 |
//! \details Caller: MOS only |
| 1271 |
//! \details UnlockResource must be called when finished access the locked data of the resource. |
| 1272 |
//! A resource already been unlocked cannot be unlocked again. |
| 1273 |
//! \details Unlock resource will not trigger compressing or changing the layout of the resource. |
| 1274 |
//! |
| 1275 |
//! \param [in] OsDeviceContext |
| 1276 |
//! Os Device Context |
| 1277 |
//! \param [in] resource |
| 1278 |
//! MOS Resource handle of the allocated resource. |
| 1279 |
//! |
| 1280 |
//! \return MOS_STATUS |
| 1281 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1282 |
//! |
| 1283 |
static MOS_STATUS UnlockMosResource( |
| 1284 |
OsDeviceContext *osDeviceContext, |
| 1285 |
MOS_RESOURCE_HANDLE resource); |
| 1286 |
//! |
| 1287 |
//! \brief Update resource usage type |
| 1288 |
//! \details update the resource usage for cache policy |
| 1289 |
//! \param PMOS_RESOURCE pOsResource |
| 1290 |
//! [in/out] Pointer to OS Resource |
| 1291 |
//! \param MOS_HW_RESOURCE_DEF resUsageType |
| 1292 |
//! [in] MOS resosuce usage type |
| 1293 |
//! \return MOS_STATUS |
| 1294 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1295 |
//! |
| 1296 |
static MOS_STATUS UpdateResourceUsageType( |
| 1297 |
PMOS_RESOURCE pOsResource, |
| 1298 |
MOS_HW_RESOURCE_DEF resUsageType); |
| 1299 |
|
| 1300 |
//! |
| 1301 |
//! \brief Register Resource |
| 1302 |
//! \details [Resource Interface] Register the resource to current streamState. |
| 1303 |
//! \details Caller: MHW only |
| 1304 |
//! \details Register resource to inform MOS that the resource is read/written by current cmd buffer being programmed |
| 1305 |
//! and this cmd buffer will be submitted into current GPU context in streamState. |
| 1306 |
//! \details RegisterResource must be called when cmds in cmd buffer programmed are using this resource. |
| 1307 |
//! \details This interface is to make the residency of the resource and handle resource sync harzad between GPU contexts. |
| 1308 |
//! \details Calling sequence is like: SetGpuContext -> RegisterResource... -> SubmitCommandBuffer -> |
| 1309 |
//! SetGpuContext(another) -> RegisterResource(another or same resource)... -> SubmitCommandBuffer |
| 1310 |
//! \details If Register same resource to different GPU context when calling SetGpuContext, sync harzad will be handled. |
| 1311 |
//! RegisterResource for the same resource can be called repeatedly. MOS will make sure no duplicated residency making and sync. |
| 1312 |
//! |
| 1313 |
//! \param [in] streamState |
| 1314 |
//! Handle of Os Stream State |
| 1315 |
//! \param [out] resource |
| 1316 |
//! MOS Resource handle of the allocated resource. |
| 1317 |
//! \param [in] write |
| 1318 |
//! Indicate if the resource is written by HW or just read. |
| 1319 |
//! |
| 1320 |
//! \return MOS_STATUS |
| 1321 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1322 |
//! |
| 1323 |
static MOS_STATUS RegisterResource( |
| 1324 |
MOS_STREAM_HANDLE streamState, |
| 1325 |
MOS_RESOURCE_HANDLE resource, |
| 1326 |
bool write); |
| 1327 |
|
| 1328 |
//! |
| 1329 |
//! \brief Get Resource Gfx Address |
| 1330 |
//! \details [Resource Interface] Get the graphic virtual address of the resource. |
| 1331 |
//! \details Caller: MHW only |
| 1332 |
//! \details Only use this interface to add resource's address directly into cmd field. |
| 1333 |
//! If MHW needs patch the address in the cmd field, GetResourceAllocationIndex should be called. |
| 1334 |
//! |
| 1335 |
//! \param [in] streamState |
| 1336 |
//! Handle of Os Stream State |
| 1337 |
//! \param [in] resource |
| 1338 |
//! MOS Resource handle of the allocated resource. |
| 1339 |
//! |
| 1340 |
//! \return uint64_t |
| 1341 |
//! 64bit virtual graphic address got. 0x00000000 if execution failed. |
| 1342 |
//! |
| 1343 |
static uint64_t GetResourceGfxAddress( |
| 1344 |
MOS_STREAM_HANDLE streamState, |
| 1345 |
MOS_RESOURCE_HANDLE resource); |
| 1346 |
|
| 1347 |
//! |
| 1348 |
//! \brief Get Resource Allocation Handle |
| 1349 |
//! \details [Resource Interface] Get the allocation handle of a graphic resource. |
| 1350 |
//! \details Caller: MHW Only |
| 1351 |
//! \details This interface gets the read-only detailed info of a graphic resource. |
| 1352 |
//! Any modification of details provided by this interface will not impact the actual resource. |
| 1353 |
//! |
| 1354 |
//! \param [in] resource |
| 1355 |
//! MOS Resource handle of the allocated resource. |
| 1356 |
//! |
| 1357 |
//! \return uint32_t |
| 1358 |
//! Allocation Handle. 0 if execution failed. |
| 1359 |
//! |
| 1360 |
static uint32_t GetResourceAllocationHandle( |
| 1361 |
MOS_RESOURCE_HANDLE resource); |
| 1362 |
|
| 1363 |
//! |
| 1364 |
//! \brief Get Resource Allocation index |
| 1365 |
//! \details [Resource Interface] Get the allocation index of the resource. |
| 1366 |
//! \details Caller: MHW only |
| 1367 |
//! \details Allocation index is used when calling SetPatchEntry to add resource into cmd. |
| 1368 |
//! If MHW needs patch the address in the cmd field, GetResourceAllocationIndex should be called. |
| 1369 |
//! |
| 1370 |
//! \param [in] streamState |
| 1371 |
//! Handle of Os Stream State |
| 1372 |
//! \param [in] resource |
| 1373 |
//! MOS Resource handle of the allocated resource. |
| 1374 |
//! |
| 1375 |
//! \return uint32_t |
| 1376 |
//! Allocation index got. 0 if execution failed. |
| 1377 |
//! |
| 1378 |
static uint32_t GetResourceAllocationIndex( |
| 1379 |
MOS_STREAM_HANDLE streamState, |
| 1380 |
MOS_RESOURCE_HANDLE resource); |
| 1381 |
|
| 1382 |
//! |
| 1383 |
//! \brief Skip Resource Sync |
| 1384 |
//! \details [Resource Interface] Skip the sync handling of the resource |
| 1385 |
//! \details Caller: HAL only |
| 1386 |
//! \details It is not device stated function and can be used in both APO HAL and NON-APO MOS. |
| 1387 |
//! \details Indicate the resource provided needn't to be synced. |
| 1388 |
//! The resource skipping sync can be accessed by different cmd buffers on different GPU contexts at the same time. |
| 1389 |
//! \details RegisterResource and LockResource will not handling the sync of the resources between different GPU cotnexts. |
| 1390 |
//! \details Usually the resource skipping sync is for the case like: |
| 1391 |
//! Different cmd buffers at the same time access the non-overlapped region of the resource |
| 1392 |
//! |
| 1393 |
//! \param [in] streamState |
| 1394 |
//! Handle of Os Stream State |
| 1395 |
//! \param [in] params |
| 1396 |
//! Pointer to the parameters for allocating resource |
| 1397 |
//! \param [out] resource |
| 1398 |
//! MOS Resource handle of the allocated resource. |
| 1399 |
//! |
| 1400 |
//! \return MOS_STATUS |
| 1401 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1402 |
//! |
| 1403 |
static MOS_STATUS SkipResourceSync( |
| 1404 |
MOS_RESOURCE_HANDLE resource); |
| 1405 |
|
| 1406 |
//! |
| 1407 |
//! \brief Sync on resource |
| 1408 |
//! \details [Resource Interface] Explicit sync on resource |
| 1409 |
//! \details Caller: HAL only |
| 1410 |
//! \details Resource is shared by different cmd buffers on different GPU contexts. |
| 1411 |
//! Adding sync object into requestor GPU context queue to resolve the hazard if necessary. |
| 1412 |
//! This func is called by hal to declare the resource to consider the sync explicitly. |
| 1413 |
//! It is a strong sync request for the resource. |
| 1414 |
//! |
| 1415 |
//! \param [in] streamState |
| 1416 |
//! Handle of Os Stream State |
| 1417 |
//! \param [in] resource |
| 1418 |
//! MOS Resource handle for the resource contain hazard of sync |
| 1419 |
//! \param [in] writeOperation |
| 1420 |
//! Indicate the current programming is to write resource or not |
| 1421 |
//! \param [in] requsetorGpuContext |
| 1422 |
//! GpuContext which programming the resource. Recommand not setting it and use current GPU context. |
| 1423 |
//! |
| 1424 |
//! \return MOS_STATUS |
| 1425 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1426 |
//! |
| 1427 |
static MOS_STATUS SyncOnResource( |
| 1428 |
MOS_STREAM_HANDLE streamState, |
| 1429 |
MOS_RESOURCE_HANDLE resource, |
| 1430 |
bool writeOperation, |
| 1431 |
GPU_CONTEXT_HANDLE requsetorGpuContext = MOS_GPU_CONTEXT_INVALID_HANDLE); |
| 1432 |
|
| 1433 |
//! |
| 1434 |
//! \brief Resource Sync call back between Media and 3D for resource Sync |
| 1435 |
//! \details [Resource Interface] Sync Call Back based on resource |
| 1436 |
//! \details Caller: DDI only |
| 1437 |
//! \details Resource is shared by different cmd buffers on different GPU contexts. |
| 1438 |
//! Adding sync object into requestor GPU context queue to resolve the hazard if necessary. |
| 1439 |
//! If there is a hazard, one cmd buffer in requestor GPU context queue will wait for the other cmd buffer in busy GPU context. |
| 1440 |
//! |
| 1441 |
//! \param [in] resource |
| 1442 |
//! OS specific resource handle for the resource contain hazard of sync |
| 1443 |
//! \param [in] deviceContext |
| 1444 |
//! Handle of Os Device Context |
| 1445 |
//! \param [in] index |
| 1446 |
//! Sub-resource index |
| 1447 |
//! \param [in] hazardType |
| 1448 |
//! Type of hazard: RAW, WAR, WAR |
| 1449 |
//! \param [in] busyCtx |
| 1450 |
//! GPU Context handle of the queue being waiting for. |
| 1451 |
//! \param [in] requestorCtx |
| 1452 |
//! GPU Context handle of current GPU which requesting to use the resoure and find the hazard to wait the busy context. |
| 1453 |
//! \param [in] osRequestorHandle |
| 1454 |
//! OS runtime handle of requestor context |
| 1455 |
//! \param [in,out] fenceInfoTrinity |
| 1456 |
//! if need to sync, it is fence handle and fence value |
| 1457 |
//! |
| 1458 |
//! \return MOS_STATUS |
| 1459 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1460 |
//! |
| 1461 |
static MOS_STATUS ResourceSyncCallback( |
| 1462 |
OsSpecificRes resource, |
| 1463 |
MOS_DEVICE_HANDLE deviceContext, |
| 1464 |
uint32_t index, |
| 1465 |
SYNC_HAZARD hazardType, |
| 1466 |
GPU_CONTEXT_HANDLE busyCtx, |
| 1467 |
GPU_CONTEXT_HANDLE requestorCtx, |
| 1468 |
OS_HANDLE osRequestorHandle, |
| 1469 |
SYNC_FENCE_INFO_TRINITY *fenceInfoTrinity); |
| 1470 |
|
| 1471 |
//! |
| 1472 |
//! \brief Lock Sync Callback between Media and 3D |
| 1473 |
//! \details [Resource Interface] Lock Sync Call Back |
| 1474 |
//! \details Caller: DDI only |
| 1475 |
//! \details Resource is used in a cmd buffer on an existing GPU context. |
| 1476 |
//! Before Locking the resource, make sure the resource finished used by all GPU contexts which are using this resource. |
| 1477 |
//! If there is a hazard, CPU side will wait for the cmd buffer in busy GPU context. |
| 1478 |
//! |
| 1479 |
//! \param [in] resource |
| 1480 |
//! OS specific resource handle for the resource contain hazard of sync |
| 1481 |
//! \param [in] deviceContext |
| 1482 |
//! Handle of Os Device Context |
| 1483 |
//! \param [in] index |
| 1484 |
//! Sub-resource index |
| 1485 |
//! \param [in] hazardType |
| 1486 |
//! Type of hazard: RAW, WAR, WAR |
| 1487 |
//! \param [in] busyCtx |
| 1488 |
//! GPU Context handle of the queue being waiting for. |
| 1489 |
//! \param [in] doNotWait |
| 1490 |
//! Indicate this is blocking call or not. When set to true, possibly return MOS_STATUS_STILL_DRAWING |
| 1491 |
//! |
| 1492 |
//! \return MOS_STATUS |
| 1493 |
//! Return MOS_STATUS_SUCCESS if successful, MOS_STATUS_STILL_DRAWING if doNotWait |
| 1494 |
//! is set to true and resoure is still being used in HW, otherwise failed |
| 1495 |
//! |
| 1496 |
static MOS_STATUS LockSyncCallback( |
| 1497 |
OsSpecificRes resource, |
| 1498 |
MOS_DEVICE_HANDLE deviceContext, |
| 1499 |
uint32_t index, |
| 1500 |
SYNC_HAZARD hazardType, |
| 1501 |
GPU_CONTEXT_HANDLE busyCtx, |
| 1502 |
bool doNotWait); |
| 1503 |
|
| 1504 |
//! |
| 1505 |
//! \brief Wait For cmd Completion |
| 1506 |
//! \details [GPU Context Interface] Waiting for the completion of cmd in provided GPU context |
| 1507 |
//! \details Caller: HAL only |
| 1508 |
//! |
| 1509 |
//! \param [in] streamState |
| 1510 |
//! Handle of Os Stream State |
| 1511 |
//! \param [in] gpuCtx |
| 1512 |
//! GpuContext handle of the gpu context to wait cmd completion |
| 1513 |
//! |
| 1514 |
//! \return MOS_STATUS |
| 1515 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1516 |
//! |
| 1517 |
static MOS_STATUS WaitForCmdCompletion( |
| 1518 |
MOS_STREAM_HANDLE streamState, |
| 1519 |
GPU_CONTEXT_HANDLE gpuCtx); |
| 1520 |
|
| 1521 |
//! |
| 1522 |
//! \brief Trim Residency |
| 1523 |
//! |
| 1524 |
//! \param [in] device |
| 1525 |
//! MOS device handle |
| 1526 |
//! \param [in] periodicTrim |
| 1527 |
//! Indicate if the trim is periodic |
| 1528 |
//! \param [in] restartPeriodicTrim |
| 1529 |
//! Indicate if restarting periodic trim |
| 1530 |
//! \param [in] numBytesToTrim |
| 1531 |
//! Number bytes to trim |
| 1532 |
//! \param [in] trimToMinimum |
| 1533 |
//! Indicate if trim to minimum |
| 1534 |
//! \param [in] trimOnlyMediaResources |
| 1535 |
//! Indicate if only trim media resources. |
| 1536 |
//! |
| 1537 |
//! \return MOS_STATUS |
| 1538 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1539 |
//! |
| 1540 |
static MOS_STATUS TrimResidency( |
| 1541 |
MOS_DEVICE_HANDLE device, |
| 1542 |
bool periodicTrim, |
| 1543 |
bool restartPeriodicTrim, |
| 1544 |
uint64_t &numBytesToTrim, |
| 1545 |
bool trimToMinimum, |
| 1546 |
bool trimOnlyMediaResources); |
| 1547 |
|
| 1548 |
//! |
| 1549 |
//! \brief Update Residency |
| 1550 |
//! |
| 1551 |
//! \param [in] device |
| 1552 |
//! MOS device handle |
| 1553 |
//! \param [in] resInfo |
| 1554 |
//! Os specific resource info |
| 1555 |
//! \param [in] index |
| 1556 |
//! Resource index |
| 1557 |
//! |
| 1558 |
//! \return MOS_STATUS |
| 1559 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1560 |
//! |
| 1561 |
static MOS_STATUS UpdateResidency( |
| 1562 |
MOS_DEVICE_HANDLE device, |
| 1563 |
OsSpecificRes resInfo, |
| 1564 |
uint32_t index, |
| 1565 |
bool bypassAuxTableUpdate = false); |
| 1566 |
|
| 1567 |
|
| 1568 |
// Memory compression interfaces |
| 1569 |
|
| 1570 |
//! |
| 1571 |
//! \brief Decompress resource |
| 1572 |
//! |
| 1573 |
//! \param [in] streamState |
| 1574 |
//! Handle of Os Stream State |
| 1575 |
//! \param [in] resource |
| 1576 |
//! MOS Resource handle of the resource to decompress. |
| 1577 |
//! \return MOS_STATUS |
| 1578 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1579 |
//! |
| 1580 |
static MOS_STATUS DecompResource( |
| 1581 |
MOS_STREAM_HANDLE streamState, |
| 1582 |
MOS_RESOURCE_HANDLE resource); |
| 1583 |
|
| 1584 |
//! |
| 1585 |
//! \brief Decompress resource |
| 1586 |
//! |
| 1587 |
//! \param [in] streamState |
| 1588 |
//! Handle of Os Stream State |
| 1589 |
//! \param [out] mosDecompression |
| 1590 |
//! MosDecompression in stramStatate or in osDeviceContext. |
| 1591 |
//! \return MOS_STATUS |
| 1592 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1593 |
//! |
| 1594 |
static MOS_STATUS GetMosDecompressionFromStreamState( |
| 1595 |
MOS_STREAM_HANDLE streamState, |
| 1596 |
MosDecompression* & mosDecompression); |
| 1597 |
|
| 1598 |
//! |
| 1599 |
//! \brief Set auxiliary resource to sync with decompression |
| 1600 |
//! |
| 1601 |
//! \param [in] streamState |
| 1602 |
//! Handle of Os Stream State |
| 1603 |
//! \param [in] resource |
| 1604 |
//! MOS Resource handle of the resource. |
| 1605 |
//! \return MOS_STATUS |
| 1606 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1607 |
//! |
| 1608 |
static MOS_STATUS SetDecompSyncRes( |
| 1609 |
MOS_STREAM_HANDLE streamState, |
| 1610 |
MOS_RESOURCE_HANDLE syncResource); |
| 1611 |
|
| 1612 |
//! |
| 1613 |
//! \brief Set Memory Compression Mode |
| 1614 |
//! |
| 1615 |
//! \param [in] streamState |
| 1616 |
//! Handle of Os Stream State |
| 1617 |
//! \param [in, out] resource |
| 1618 |
//! MOS Resource handle |
| 1619 |
//! \param [in] resMmcMode |
| 1620 |
//! MMC mode |
| 1621 |
//! |
| 1622 |
//! \return MOS_STATUS |
| 1623 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1624 |
//! |
| 1625 |
static MOS_STATUS SetMemoryCompressionMode( |
| 1626 |
MOS_STREAM_HANDLE streamState, |
| 1627 |
MOS_RESOURCE_HANDLE resource, |
| 1628 |
MOS_MEMCOMP_STATE resMmcMode); |
| 1629 |
|
| 1630 |
//! |
| 1631 |
//! \brief Get Memory Compression Mode |
| 1632 |
//! |
| 1633 |
//! \param [in] streamState |
| 1634 |
//! Handle of Os Stream State |
| 1635 |
//! \param [in] resource |
| 1636 |
//! MOS Resource handle |
| 1637 |
//! \param [out] resMmcMode |
| 1638 |
//! MMC mode |
| 1639 |
//! |
| 1640 |
//! \return MOS_STATUS |
| 1641 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1642 |
//! |
| 1643 |
static MOS_STATUS GetMemoryCompressionMode( |
| 1644 |
MOS_STREAM_HANDLE streamState, |
| 1645 |
MOS_RESOURCE_HANDLE resource, |
| 1646 |
MOS_MEMCOMP_STATE &resMmcMode); |
| 1647 |
|
| 1648 |
//! |
| 1649 |
//! \brief Set Memory Compression Hint |
| 1650 |
//! |
| 1651 |
//! \param [in] streamState |
| 1652 |
//! Handle of Os Stream State |
| 1653 |
//! \param [in, out] resource |
| 1654 |
//! MOS Resource handle |
| 1655 |
//! \param [in] hintOn |
| 1656 |
//! Flag to set hint on or off |
| 1657 |
//! |
| 1658 |
//! \return MOS_STATUS |
| 1659 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1660 |
//! |
| 1661 |
static MOS_STATUS SetMemoryCompressionHint( |
| 1662 |
MOS_STREAM_HANDLE streamState, |
| 1663 |
MOS_RESOURCE_HANDLE resource, |
| 1664 |
bool hintOn); |
| 1665 |
|
| 1666 |
//! |
| 1667 |
//! \brief Get Memory Compression Format |
| 1668 |
//! |
| 1669 |
//! \param [in] streamState |
| 1670 |
//! Handle of Os Stream State |
| 1671 |
//! \param [in, out] resource |
| 1672 |
//! MOS Resource handle |
| 1673 |
//! \param [out] resMmcFormat |
| 1674 |
//! MMC format got |
| 1675 |
//! |
| 1676 |
//! \return MOS_STATUS |
| 1677 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1678 |
//! |
| 1679 |
static MOS_STATUS GetMemoryCompressionFormat( |
| 1680 |
MOS_STREAM_HANDLE streamState, |
| 1681 |
MOS_RESOURCE_HANDLE resource, |
| 1682 |
uint32_t *resMmcFormat); |
| 1683 |
|
| 1684 |
//! |
| 1685 |
//! \brief Double buffer copy resource |
| 1686 |
//! |
| 1687 |
//! \param [in] streamState |
| 1688 |
//! Handle of Os Stream State |
| 1689 |
//! \param [in] inputResource |
| 1690 |
//! Input resource to copy. |
| 1691 |
//! \param [out] outputResource |
| 1692 |
//! Output resource. |
| 1693 |
//! \param [in] outputCompressed |
| 1694 |
//! Insdicate if output resource is compressed. |
| 1695 |
//! \return MOS_STATUS |
| 1696 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1697 |
//! |
| 1698 |
static MOS_STATUS DoubleBufferCopyResource( |
| 1699 |
MOS_STREAM_HANDLE streamState, |
| 1700 |
MOS_RESOURCE_HANDLE inputResource, |
| 1701 |
MOS_RESOURCE_HANDLE outputResource, |
| 1702 |
bool outputCompressed); |
| 1703 |
|
| 1704 |
//! |
| 1705 |
//! \brief Use media copy to copy resource |
| 1706 |
//! |
| 1707 |
//! \param [in] streamState |
| 1708 |
//! Handle of Os Stream State |
| 1709 |
//! \param [in] inputResource |
| 1710 |
//! Source resource. |
| 1711 |
//! \param [out] outputResource |
| 1712 |
//! Destination resource. |
| 1713 |
//! \param [in] preferMethod |
| 1714 |
//! Preferred copy engine. |
| 1715 |
//! \return MOS_STATUS |
| 1716 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1717 |
//! |
| 1718 |
static MOS_STATUS UnifiedMediaCopyResource( |
| 1719 |
MOS_STREAM_HANDLE streamState, |
| 1720 |
MOS_RESOURCE_HANDLE inputResource, |
| 1721 |
MOS_RESOURCE_HANDLE outputResource, |
| 1722 |
int preferMethod); |
| 1723 |
|
| 1724 |
//! |
| 1725 |
//! \brief Copy Resource to Another Buffer |
| 1726 |
//! \details Decompress and Copy Resource to Another 2D Buffer |
| 1727 |
//! |
| 1728 |
//! \param [in] streamState |
| 1729 |
//! Handle of Os Stream State |
| 1730 |
//! \param inputResource |
| 1731 |
//! [in] Input Resource object |
| 1732 |
//! \param outputResource |
| 1733 |
//! [out] output Resource object |
| 1734 |
//! \param [in] copyPitch |
| 1735 |
//! The 2D surface pitch |
| 1736 |
//! \param [in] copyHeight |
| 1737 |
//! The 2D surface height |
| 1738 |
//! \param [in] copyInputOffset |
| 1739 |
//! The offset of copied surface from |
| 1740 |
//! \param [in] copyOutputOffset |
| 1741 |
//! The offset of copied to |
| 1742 |
//! \param [in] outputCompressed |
| 1743 |
//! True means apply compression on output surface, else output uncompressed surface |
| 1744 |
//! \return MOS_STATUS |
| 1745 |
//! MOS_STATUS_SUCCESS if successful |
| 1746 |
//! |
| 1747 |
static MOS_STATUS MediaCopyResource2D( |
| 1748 |
MOS_STREAM_HANDLE streamState, |
| 1749 |
MOS_RESOURCE_HANDLE inputResource, |
| 1750 |
MOS_RESOURCE_HANDLE outputResource, |
| 1751 |
uint32_t copyPitch, |
| 1752 |
uint32_t copyHeight, |
| 1753 |
uint32_t bpp, |
| 1754 |
bool outputCompressed); |
| 1755 |
|
| 1756 |
//! |
| 1757 |
//! \brief Copy Mono Resource to Another Buffer |
| 1758 |
//! \details Decompress and Copy Mono Resource to Another 2D Buffer |
| 1759 |
//! |
| 1760 |
//! \param [in] streamState |
| 1761 |
//! Handle of Os Stream State |
| 1762 |
//! \param inputResource |
| 1763 |
//! [in] Input Resource object |
| 1764 |
//! \param outputResource |
| 1765 |
//! [out] output Resource object |
| 1766 |
//! \param [in] copyWidth |
| 1767 |
//! The 2D surface Width |
| 1768 |
//! \param [in] copyHeight |
| 1769 |
//! The 2D surface height |
| 1770 |
//! \param [in] copyInputOffset |
| 1771 |
//! The offset of copied surface from |
| 1772 |
//! \param [in] copyOutputOffset |
| 1773 |
//! The offset of copied to |
| 1774 |
//! \param [in] outputCompressed |
| 1775 |
//! True means apply compression on output surface, else output uncompressed surface |
| 1776 |
//! \return MOS_STATUS |
| 1777 |
//! MOS_STATUS_SUCCESS if successful |
| 1778 |
//! |
| 1779 |
static MOS_STATUS MonoSurfaceCopy( |
| 1780 |
MOS_STREAM_HANDLE streamState, |
| 1781 |
MOS_RESOURCE_HANDLE inputResource, |
| 1782 |
MOS_RESOURCE_HANDLE outputResource, |
| 1783 |
uint32_t copyPitch, |
| 1784 |
uint32_t copyHeight, |
| 1785 |
uint32_t copyInputOffset, |
| 1786 |
uint32_t copyOutputOffset, |
| 1787 |
bool outputCompressed); |
| 1788 |
|
| 1789 |
//! |
| 1790 |
//! \brief Check whether the parameter of mos surface is valid for copy |
| 1791 |
//! |
| 1792 |
//! \param [in] mosSurface |
| 1793 |
//! Pointer to MosSurface |
| 1794 |
//! |
| 1795 |
//! \return bool |
| 1796 |
//! Whether the paramter of mosSurface is valid |
| 1797 |
//! |
| 1798 |
static MOS_STATUS VerifyMosSurface( |
| 1799 |
PMOS_SURFACE mosSurface, |
| 1800 |
bool &bIsValid); |
| 1801 |
|
| 1802 |
// GPU Status interfaces |
| 1803 |
//! |
| 1804 |
//! \brief Get Gpu Status Tag |
| 1805 |
//! |
| 1806 |
//! \param [in] streamState |
| 1807 |
//! Handle of Os Stream State |
| 1808 |
//! \param [in] gpuContext |
| 1809 |
//! MOS GPU Context handle |
| 1810 |
//! |
| 1811 |
//! \return uint32_t |
| 1812 |
//! Tag got from GPU Context indicated, 0 if failed to get the tag |
| 1813 |
//! |
| 1814 |
static uint32_t GetGpuStatusTag( |
| 1815 |
MOS_STREAM_HANDLE streamState, |
| 1816 |
GPU_CONTEXT_HANDLE gpuContext); |
| 1817 |
|
| 1818 |
//! |
| 1819 |
//! \brief Increment Gpu Status Tag |
| 1820 |
//! |
| 1821 |
//! \param [in] streamState |
| 1822 |
//! Handle of Os Stream State |
| 1823 |
//! \param [in] gpuContext |
| 1824 |
//! MOS GPU Context handle |
| 1825 |
//! |
| 1826 |
//! \return MOS_STATUS |
| 1827 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1828 |
//! |
| 1829 |
static MOS_STATUS IncrementGpuStatusTag( |
| 1830 |
MOS_STREAM_HANDLE streamState, |
| 1831 |
GPU_CONTEXT_HANDLE gpuContext); |
| 1832 |
|
| 1833 |
//! |
| 1834 |
//! \brief Get Gpu Status Sync Tag |
| 1835 |
//! |
| 1836 |
//! \param [in] streamState |
| 1837 |
//! Handle of Os Stream State |
| 1838 |
//! \param [in] gpuContext |
| 1839 |
//! MOS GPU Context handle |
| 1840 |
//! |
| 1841 |
//! \return uint64_t |
| 1842 |
//! HW tag got from GPU context, 0 if get failed |
| 1843 |
//! |
| 1844 |
static uint64_t GetGpuStatusSyncTag( |
| 1845 |
MOS_STREAM_HANDLE streamState, |
| 1846 |
GPU_CONTEXT_HANDLE gpuContext); |
| 1847 |
|
| 1848 |
//! |
| 1849 |
//! \brief Get Gpu Status Buffer Resource |
| 1850 |
//! |
| 1851 |
//! \param [in] streamState |
| 1852 |
//! Handle of Os Stream State |
| 1853 |
//! \param [out] resource |
| 1854 |
//! MOS resource handle of GPU status buffer got from current GPU context |
| 1855 |
//! \param [in] gpuContext |
| 1856 |
//! MOS GPU Context handle |
| 1857 |
//! |
| 1858 |
//! \return MOS_STATUS |
| 1859 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1860 |
//! |
| 1861 |
|
| 1862 |
static MOS_STATUS GetGpuStatusBufferResource( |
| 1863 |
MOS_STREAM_HANDLE streamState, |
| 1864 |
MOS_RESOURCE_HANDLE &resource, |
| 1865 |
GPU_CONTEXT_HANDLE gpuContext); |
| 1866 |
|
| 1867 |
//! |
| 1868 |
//! \brief Get CP Interface |
| 1869 |
//! |
| 1870 |
//! \param [in] streamState |
| 1871 |
//! Handle of Os Stream State |
| 1872 |
//! |
| 1873 |
//! \return MosCpInterface |
| 1874 |
//! CP Interface got from stream State, nullptr if get failed |
| 1875 |
//! |
| 1876 |
static MosCpInterface *GetCpInterface(MOS_STREAM_HANDLE streamState); |
| 1877 |
|
| 1878 |
//! |
| 1879 |
//! \brief Maps the specified executable module into the address space of |
| 1880 |
//! the calling process. |
| 1881 |
//! \param PMOS_INTERFACE pOsInterface |
| 1882 |
//! [in] A handle to OS interface. This can be nullptr which allows a caller to |
| 1883 |
//! always get library from specified library path (function will never check |
| 1884 |
//! driver store) which is useful if there's a constant static path of a library |
| 1885 |
//! \param const PCCHAR lpLibFileName |
| 1886 |
//! [in] String containing resource name to load. Absolute path is given here |
| 1887 |
//! if pOsInterface is nullptr, else only lib path is given, and driver will check store for path |
| 1888 |
//! \param PHMODULE phModule |
| 1889 |
//! [out] Handle to library given back to the caller |
| 1890 |
//! \return MOS_STATUS |
| 1891 |
//! Returns one of the MOS_STATUS error codes if failed, |
| 1892 |
//! else MOS_STATUS_SUCCESS |
| 1893 |
//! |
| 1894 |
static MOS_STATUS MosLoadLibrary( |
| 1895 |
MOS_STREAM_HANDLE streamState, |
| 1896 |
PCCHAR pFileName, |
| 1897 |
PHMODULE phModule); |
| 1898 |
|
| 1899 |
//! |
| 1900 |
//! \brief Free the loaded dynamic-link library |
| 1901 |
//! \details Free the loaded dynamic-link library |
| 1902 |
//! \param [in] hLibModule |
| 1903 |
//! A handle to the loaded DLL module |
| 1904 |
//! \return int32_t |
| 1905 |
//! true if success else false |
| 1906 |
//! |
| 1907 |
static MOS_STATUS MosFreeLibrary(HMODULE hLibModule); |
| 1908 |
|
| 1909 |
//! |
| 1910 |
//! \brief Create Virtual Engine State |
| 1911 |
//! \details [Virtual Engine Interface] Create Virtual Engine State of provided streamState |
| 1912 |
//! \details Caller: Hal (Scalability) only |
| 1913 |
//! \details This func is called when a stream (Hal instance) need to create a VE state |
| 1914 |
//! \details into provided stream. |
| 1915 |
//! |
| 1916 |
//! \param [in] streamState |
| 1917 |
//! Handle of Os Stream State |
| 1918 |
//! \param [in] veInitParms |
| 1919 |
//! Pointer of parameters to init ve staet |
| 1920 |
//! \param [out] veState |
| 1921 |
//! Reference of the handle of Virtual Engine State to created |
| 1922 |
//! |
| 1923 |
//! \return MOS_STATUS |
| 1924 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1925 |
//! |
| 1926 |
static MOS_STATUS CreateVirtualEngineState( |
| 1927 |
MOS_STREAM_HANDLE streamState, |
| 1928 |
PMOS_VIRTUALENGINE_INIT_PARAMS veInitParms, |
| 1929 |
MOS_VE_HANDLE &veState); |
| 1930 |
|
| 1931 |
//! |
| 1932 |
//! \brief Destroy Virtual Engine State |
| 1933 |
//! \details [Virtual Engine Interface] Destroy Virtual Engine State of provided streamState |
| 1934 |
//! \details Caller: Hal (Scalability) only |
| 1935 |
//! \details This func is called when a stream (Hal instance) need to destroy a VE state |
| 1936 |
//! \details into provided stream. |
| 1937 |
//! |
| 1938 |
//! \param [in] streamState |
| 1939 |
//! Handle of Os Stream State |
| 1940 |
//! \param [out] veState |
| 1941 |
//! Reference of the handle of Virtual Engine State to created |
| 1942 |
//! |
| 1943 |
//! \return MOS_STATUS |
| 1944 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 1945 |
//! |
| 1946 |
static MOS_STATUS DestroyVirtualEngineState( |
| 1947 |
MOS_STREAM_HANDLE streamState); |
| 1948 |
|
| 1949 |
//! |
| 1950 |
//! \brief Set hint parameters |
| 1951 |
//! |
| 1952 |
//! \details [Virtual Engine Interface] Set hint parameters into Virtual Engine State in provided stream |
| 1953 |
//! \details Caller: Hal (Scalability) only |
| 1954 |
//! \details Set hint parameters for virtual engine state |
| 1955 |
//! |
| 1956 |
//! \param [in] streamState |
| 1957 |
//! Handle of Os Stream State |
| 1958 |
//! \param [in] veParams |
| 1959 |
//! pointer to VE parameter data structure to set |
| 1960 |
//! \return MOS_STATUS |
| 1961 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1962 |
//! |
| 1963 |
static MOS_STATUS SetVeHintParams( |
| 1964 |
MOS_STREAM_HANDLE streamState, |
| 1965 |
PMOS_VIRTUALENGINE_SET_PARAMS veParams); |
| 1966 |
|
| 1967 |
//! |
| 1968 |
//! \brief Get hint parameters |
| 1969 |
//! |
| 1970 |
//! \details [Virtual Engine Interface] Get hint parameters from Virtual Engine State in provided stream |
| 1971 |
//! \details Caller: Hal (Scalability) only |
| 1972 |
//! \details Get hint parameters from virtual engine state |
| 1973 |
//! |
| 1974 |
//! \param [in] streamState |
| 1975 |
//! Handle of Os Stream State |
| 1976 |
//! \param [in] scalableMode |
| 1977 |
//! flag to indicate if scalability mode |
| 1978 |
//! \param [out] hintParams |
| 1979 |
//! pointer to VE hint parameter address |
| 1980 |
//! \return MOS_STATUS |
| 1981 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1982 |
//! |
| 1983 |
static MOS_STATUS GetVeHintParams( |
| 1984 |
MOS_STREAM_HANDLE streamState, |
| 1985 |
bool scalableMode, |
| 1986 |
PMOS_VIRTUALENGINE_HINT_PARAMS *hintParams); |
| 1987 |
|
| 1988 |
//! |
| 1989 |
//! \brief Get Adapter BDF |
| 1990 |
//! \details [System info Interface] Get Adapter BDF |
| 1991 |
//! \details Caller: DDI & HAL |
| 1992 |
//! \details This func is called to differentiate the behavior according to Adapter BDF. |
| 1993 |
//! |
| 1994 |
//! \param [in] mosCtx |
| 1995 |
//! Pointer of Mos context |
| 1996 |
//! \param [out] adapterBDF |
| 1997 |
//! Adapter BDF info |
| 1998 |
//! |
| 1999 |
//! \return MOS_STATUS |
| 2000 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2001 |
//! |
| 2002 |
static MOS_STATUS GetAdapterBDF(PMOS_CONTEXT mosCtx, ADAPTER_BDF *adapterBDF); |
| 2003 |
|
| 2004 |
//! |
| 2005 |
//! \brief Set Hybrid Cmd To GpuContext |
| 2006 |
//! \details Set Hybrid Cmd To GpuContext |
| 2007 |
//! \param PMOS_INTERFACE pOsInterface |
| 2008 |
//! [in] ptr to pOsInterface |
| 2009 |
//! \param uint64_t gpuCtxOnHybridCmd |
| 2010 |
//! gpuCtxOnHybridCmd |
| 2011 |
//! \return MOS_STATUS |
| 2012 |
//! Return MOS_STATUS |
| 2013 |
//! |
| 2014 |
static MOS_STATUS SetHybridCmdMgrToGpuContext( |
| 2015 |
PMOS_INTERFACE pOsInterface, |
| 2016 |
uint64_t gpuCtxOnHybridCmd); |
| 2017 |
|
| 2018 |
//! |
| 2019 |
//! \brief Set Hybrid Cmd Submit Mode |
| 2020 |
//! \details Set Hybrid Cmd Submit Mode |
| 2021 |
//! \param PMOS_INTERFACE pOsInterface |
| 2022 |
//! [in] ptr to pOsInterface |
| 2023 |
//! \param uint64_t hybridMgrSubmitMode |
| 2024 |
//! hybridMgrSubmitMode |
| 2025 |
//! \return MOS_STATUS |
| 2026 |
//! Return MOS_STATUS |
| 2027 |
//! |
| 2028 |
static MOS_STATUS SetHybridCmdMgrSubmitMode( |
| 2029 |
PMOS_INTERFACE pOsInterface, |
| 2030 |
uint64_t hybridMgrSubmitMode); |
| 2031 |
|
| 2032 |
//! |
| 2033 |
//! \brief Start the Cmd Consumer |
| 2034 |
//! \details Start the Cmd Consumer |
| 2035 |
//! \param PMOS_INTERFACE pOsInterface |
| 2036 |
//! [in] ptr to pOsInterface |
| 2037 |
//! \return MOS_STATUS |
| 2038 |
//! Return MOS_STATUS |
| 2039 |
//! |
| 2040 |
static MOS_STATUS StartHybridCmdMgr( |
| 2041 |
PMOS_INTERFACE pOsInterface); |
| 2042 |
|
| 2043 |
//! |
| 2044 |
//! \brief Stop the Cmd Consumer |
| 2045 |
//! \details Stop the Cmd Consumer |
| 2046 |
//! \param PMOS_INTERFACE pOsInterface |
| 2047 |
//! [in] ptr to pOsInterface |
| 2048 |
//! \return MOS_STATUS |
| 2049 |
//! Return MOS_STATUS |
| 2050 |
//! |
| 2051 |
static MOS_STATUS StopHybridCmdMgr( |
| 2052 |
PMOS_INTERFACE pOsInterface); |
| 2053 |
|
| 2054 |
//! |
| 2055 |
//! \brief Submit Cmd Package to Cmd Consumer |
| 2056 |
//! \details Submit Cmd Package to Cmd Consumer |
| 2057 |
//! \param PMOS_INTERFACE pOsInterface |
| 2058 |
//! [in] ptr to pOsInterface |
| 2059 |
//! \param CmdPackage& cmdPackage |
| 2060 |
//! [in] reference to cmdPackage |
| 2061 |
//! \return MOS_STATUS |
| 2062 |
//! Return MOS_STATUS |
| 2063 |
//! |
| 2064 |
static MOS_STATUS SubmitPackage( |
| 2065 |
PMOS_INTERFACE pOsInterface, |
| 2066 |
CmdPackage &cmdPackage); |
| 2067 |
|
| 2068 |
#if _DEBUG || _RELEASE_INTERNAL |
| 2069 |
//! |
| 2070 |
//! \brief Get engine count |
| 2071 |
//! |
| 2072 |
//! \details [Virtual Engine Interface] Get engine count from Virtual Engine State in provided stream |
| 2073 |
//! \details Caller: Hal (Scalability) only |
| 2074 |
//! \details Get engine count from virtual engine state |
| 2075 |
//! |
| 2076 |
//! \param [in] streamState |
| 2077 |
//! Handle of Os Stream State |
| 2078 |
//! \return uint8_t |
| 2079 |
//! Engine count |
| 2080 |
//! |
| 2081 |
static uint8_t GetVeEngineCount( |
| 2082 |
MOS_STREAM_HANDLE streamState); |
| 2083 |
|
| 2084 |
//! |
| 2085 |
//! \brief Get Engine Logic Id |
| 2086 |
//! \details [Virtual Engine Interface] Get engine Logic Id from Virtual Engine State in provided stream |
| 2087 |
//! \details Caller: Hal (Scalability) only |
| 2088 |
//! \details Get engine Logic Id from virtual engine state |
| 2089 |
//! |
| 2090 |
//! \param [in] streamState |
| 2091 |
//! Handle of Os Stream State |
| 2092 |
//! \param [in] instanceIdx |
| 2093 |
//! Engine instance index |
| 2094 |
//! \return uint8_t |
| 2095 |
//! |
| 2096 |
static uint8_t GetEngineLogicId( |
| 2097 |
MOS_STREAM_HANDLE streamState, |
| 2098 |
uint32_t instanceIdx); |
| 2099 |
|
| 2100 |
//! |
| 2101 |
//! \brief Set Gpu Virtual Address for Debug |
| 2102 |
//! \details Manually make page fault |
| 2103 |
//! |
| 2104 |
//! \param [in] pResource |
| 2105 |
//! Resource to set Gpu Address |
| 2106 |
//! \param [in] address |
| 2107 |
//! Address to set |
| 2108 |
//! \return MOS_STATUS |
| 2109 |
//! |
| 2110 |
static MOS_STATUS SetGpuVirtualAddress( |
| 2111 |
PMOS_RESOURCE pResource, |
| 2112 |
uint64_t address); |
| 2113 |
|
| 2114 |
#endif // _DEBUG || _RELEASE_INTERNAL |
| 2115 |
|
| 2116 |
//! |
| 2117 |
//! \brief Sets the perf tag |
| 2118 |
//! \details Sets the perf tag |
| 2119 |
//! \param [in] streamState |
| 2120 |
//! Handle of Os Stream State |
| 2121 |
//! \param uint32_t perfTag |
| 2122 |
//! [in] Perf tag |
| 2123 |
//! \return void |
| 2124 |
//! |
| 2125 |
static void SetPerfTag( |
| 2126 |
MOS_STREAM_HANDLE streamState, |
| 2127 |
uint32_t perfTag); |
| 2128 |
|
| 2129 |
//! |
| 2130 |
//! \brief Gets the perf tag |
| 2131 |
//! \details Gets the perf tag |
| 2132 |
//! \param [in] streamState |
| 2133 |
//! Handle of Os Stream State |
| 2134 |
//! \return uint32_t |
| 2135 |
//! Return perf tag |
| 2136 |
//! |
| 2137 |
static uint32_t GetPerfTag( |
| 2138 |
MOS_STREAM_HANDLE streamState); |
| 2139 |
|
| 2140 |
//! |
| 2141 |
//! \brief Check if Perf Tag is already set |
| 2142 |
//! \details Check if Perf Tag is already set |
| 2143 |
//! \param [in] streamState |
| 2144 |
//! Handle of Os Stream State |
| 2145 |
//! \return int32_t |
| 2146 |
//! |
| 2147 |
static int32_t IsPerfTagSet( |
| 2148 |
MOS_STREAM_HANDLE streamState); |
| 2149 |
|
| 2150 |
//! |
| 2151 |
//! \brief Increase performance data frame ID |
| 2152 |
//! \details Increase performance data frame ID |
| 2153 |
//! \param [in] streamState |
| 2154 |
//! Handle of Os Stream State |
| 2155 |
//! \return void |
| 2156 |
//! |
| 2157 |
static void IncPerfFrameID( |
| 2158 |
MOS_STREAM_HANDLE streamState); |
| 2159 |
|
| 2160 |
//! |
| 2161 |
//! \brief Set Hybrid Kernel ID |
| 2162 |
//! \details Set Hybrid Kernel ID |
| 2163 |
//! \param [in] streamState |
| 2164 |
//! Handle of Os Stream State |
| 2165 |
//! \param uint32_t kernelID |
| 2166 |
//! [in] Hybrid Decoder kernel ID |
| 2167 |
//! \return void |
| 2168 |
//! |
| 2169 |
static void SetPerfHybridKernelID( |
| 2170 |
MOS_STREAM_HANDLE streamState, |
| 2171 |
uint32_t kernelID); |
| 2172 |
|
| 2173 |
//! |
| 2174 |
//! \brief Reset performance data buffer ID |
| 2175 |
//! \details Reset performance data buffer ID |
| 2176 |
//! \param [in] streamState |
| 2177 |
//! Handle of Os Stream State |
| 2178 |
//! \return void |
| 2179 |
//! |
| 2180 |
static void ResetPerfBufferID( |
| 2181 |
MOS_STREAM_HANDLE streamState); |
| 2182 |
|
| 2183 |
//! |
| 2184 |
//! \brief Increase performance data buffer ID |
| 2185 |
//! \details Increase performance data buffer ID |
| 2186 |
//! \param [in] streamState |
| 2187 |
//! Handle of Os Stream State |
| 2188 |
//! \return VOID |
| 2189 |
//! |
| 2190 |
static void IncPerfBufferID( |
| 2191 |
MOS_STREAM_HANDLE streamState); |
| 2192 |
|
| 2193 |
//! |
| 2194 |
//! \brief Determines if the GPU Hung |
| 2195 |
//! \param [in] streamState |
| 2196 |
//! Handle of Os Stream State |
| 2197 |
//! \return int32_t |
| 2198 |
//! Return if the GPU Hung |
| 2199 |
//! |
| 2200 |
static int32_t IsGPUHung( |
| 2201 |
MOS_STREAM_HANDLE streamState); |
| 2202 |
|
| 2203 |
//! |
| 2204 |
//! \brief Get SetMarker enabled flag |
| 2205 |
//! \details Get SetMarker enabled flag from streamState |
| 2206 |
//! \param [in] streamState |
| 2207 |
//! Handle of Os Stream State |
| 2208 |
//! \return bool |
| 2209 |
//! SetMarker enabled flag |
| 2210 |
//! |
| 2211 |
static bool IsSetMarkerEnabled( |
| 2212 |
MOS_STREAM_HANDLE streamState); |
| 2213 |
|
| 2214 |
//! |
| 2215 |
//! \brief Get SetMarker resource address |
| 2216 |
//! \details Get SetMarker resource address from streamState |
| 2217 |
//! \param [in] streamState |
| 2218 |
//! Handle of Os Stream State |
| 2219 |
//! \return PMOS_RESOURCE |
| 2220 |
//! SetMarker resource address |
| 2221 |
//! |
| 2222 |
static PMOS_RESOURCE GetMarkerResource( |
| 2223 |
MOS_STREAM_HANDLE streamState); |
| 2224 |
|
| 2225 |
//! |
| 2226 |
//! \brief Check if OS resource is nullptr |
| 2227 |
//! \details Check if OS resource is nullptr |
| 2228 |
//! \param PMOS_RESOURCE pOsResource |
| 2229 |
//! [in] Pointer to OS Resource |
| 2230 |
//! \return int32_t |
| 2231 |
//! Return true if nullptr, otherwise false |
| 2232 |
//! |
| 2233 |
static bool MosResourceIsNull(PMOS_RESOURCE resource); |
| 2234 |
|
| 2235 |
//! |
| 2236 |
//! \brief OS reset resource |
| 2237 |
//! \details Resets the OS resource |
| 2238 |
//! \param PMOS_RESOURCE pOsResource |
| 2239 |
//! [in] Pointer to OS Resource |
| 2240 |
//! \return void |
| 2241 |
//! Return NONE |
| 2242 |
//! |
| 2243 |
static void MosResetResource(PMOS_RESOURCE resource); |
| 2244 |
|
| 2245 |
//! |
| 2246 |
//! \brief Get Gmm Resource Info |
| 2247 |
//! \details Get Gmm Resource Info |
| 2248 |
//! \param PMOS_RESOURCE resource |
| 2249 |
//! [in/out] pointer to OS resource |
| 2250 |
//! \return MOS_STATUS |
| 2251 |
//! MOS_STATUS_SUCCESS if successful |
| 2252 |
//! |
| 2253 |
static MOS_STATUS GetGmmResourceInfo(PMOS_RESOURCE resource); |
| 2254 |
|
| 2255 |
//! |
| 2256 |
//! \brief Get plane offset inside surface |
| 2257 |
//! \details Returns the offset |
| 2258 |
//! \param MOS_PLANE_OFFSET planeOffset |
| 2259 |
//! [in] Reference to MOS_PLANE_OFFSET structure |
| 2260 |
//! \return int - offset of the plane |
| 2261 |
//! |
| 2262 |
static int GetPlaneSurfaceOffset( |
| 2263 |
const MOS_PLANE_OFFSET &planeOffset); |
| 2264 |
|
| 2265 |
//! |
| 2266 |
//! \brief Get Resource array index |
| 2267 |
//! \details Returns the array index |
| 2268 |
//! \param PMOS_RESOURCE |
| 2269 |
//! [in] Pointer to MOS_RESOURCE |
| 2270 |
//! \return uint32_t - array index |
| 2271 |
//! |
| 2272 |
static uint32_t GetResourceArrayIndex( |
| 2273 |
PMOS_RESOURCE resource); |
| 2274 |
|
| 2275 |
//! |
| 2276 |
//! \brief Translate MOS_FORMAT into GMM_RESOURCE_FORMAT |
| 2277 |
//! |
| 2278 |
static GMM_RESOURCE_FORMAT MosFmtToGmmFmt(MOS_FORMAT format); |
| 2279 |
|
| 2280 |
//! |
| 2281 |
//! \brief Translate GMM_RESOURCE_FORMAT into MOS_FORMAT |
| 2282 |
//! |
| 2283 |
static MOS_FORMAT GmmFmtToMosFmt(GMM_RESOURCE_FORMAT format); |
| 2284 |
|
| 2285 |
//! |
| 2286 |
//! \brief Translate MOS_FORMAT into MOS_OS_FORMAT |
| 2287 |
//! |
| 2288 |
static uint32_t MosFmtToOsFmt(MOS_FORMAT format); |
| 2289 |
|
| 2290 |
//! |
| 2291 |
//! \brief Translate MOS_OS_FORMT into MOS_FORMAT |
| 2292 |
//! |
| 2293 |
static MOS_FORMAT OsFmtToMosFmt(uint32_t format); |
| 2294 |
|
| 2295 |
//! \brief Get usersetting instance for each stream |
| 2296 |
//! \details the user setting instance |
| 2297 |
//! \details call the overloading MosGetUserSettingInstance for osDeviceContext |
| 2298 |
//! \param MOS_STREAM_HANDLE streamState |
| 2299 |
//! [in] streamState |
| 2300 |
//! \return MediaUserSettingSharedPtr - user setting instance |
| 2301 |
//! |
| 2302 |
static MediaUserSettingSharedPtr MosGetUserSettingInstance( |
| 2303 |
MOS_STREAM_HANDLE streamState); |
| 2304 |
|
| 2305 |
//! \brief Get usersetting instance for each stream |
| 2306 |
//! \details the user setting instance |
| 2307 |
//! \param OsDeviceContext osDeviceContext |
| 2308 |
//! [in] osDeviceContext |
| 2309 |
//! \return MediaUserSettingSharedPtr - user setting instance |
| 2310 |
//! |
| 2311 |
static MediaUserSettingSharedPtr MosGetUserSettingInstance( |
| 2312 |
OsDeviceContext *osDeviceContext); |
| 2313 |
|
| 2314 |
//! \brief Get usersetting instance for each stream |
| 2315 |
//! \details the user setting instance |
| 2316 |
//! \param PMOS_CONTEXT mosCtx |
| 2317 |
//! [in] mosCtx |
| 2318 |
//! \return MediaUserSettingSharedPtr - user setting instance |
| 2319 |
//! |
| 2320 |
static MediaUserSettingSharedPtr MosGetUserSettingInstance( |
| 2321 |
PMOS_CONTEXT mosCtx); |
| 2322 |
|
| 2323 |
//! |
| 2324 |
//! \brief Translate MOS_OS_FORMT into MOS_FORMAT |
| 2325 |
//! |
| 2326 |
static bool IsCompressibelSurfaceSupported(MEDIA_FEATURE_TABLE *skuTable); |
| 2327 |
|
| 2328 |
//! |
| 2329 |
//! \brief Check if Mismatch Order Programming model is supported |
| 2330 |
//! |
| 2331 |
static bool IsMismatchOrderProgrammingSupported(); |
| 2332 |
|
| 2333 |
//! |
| 2334 |
//! \brief Translate GMM_TILE_TYPE to MOS_TILE_TYPE |
| 2335 |
//! |
| 2336 |
static MOS_TILE_TYPE MapTileType(GMM_RESOURCE_FLAG flags, GMM_TILE_TYPE type); |
| 2337 |
|
| 2338 |
//! |
| 2339 |
//! \brief Check if Multiple Codec Devices is in use |
| 2340 |
//! |
| 2341 |
static bool IsMultipleCodecDevicesInUse(PMOS_INTERFACE osInterface); |
| 2342 |
|
| 2343 |
|
| 2344 |
static MOS_STATUS SetMultiEngineEnabled( |
| 2345 |
PMOS_INTERFACE pOsInterface, |
| 2346 |
MOS_COMPONENT component, |
| 2347 |
bool enabled); |
| 2348 |
|
| 2349 |
static MOS_STATUS GetMultiEngineStatus( |
| 2350 |
PMOS_INTERFACE pOsInterface, |
| 2351 |
PLATFORM *platform, |
| 2352 |
MOS_COMPONENT component, |
| 2353 |
bool &isMultiDevices, |
| 2354 |
bool &isMultiEngine); |
| 2355 |
|
| 2356 |
//! |
| 2357 |
//! \brief get latest virtual node for encoder and decoder |
| 2358 |
//! |
| 2359 |
static MOS_GPU_NODE GetLatestVirtualNode(MOS_STREAM_HANDLE streamState, MOS_COMPONENT component); |
| 2360 |
|
| 2361 |
//! |
| 2362 |
//! \brief set latest virtual node for encoder and decoder |
| 2363 |
//! |
| 2364 |
static void SetLatestVirtualNode(MOS_STREAM_HANDLE streamState, MOS_GPU_NODE node); |
| 2365 |
|
| 2366 |
//! |
| 2367 |
//! \brief get virtual node for each decoder stream |
| 2368 |
//! |
| 2369 |
static MOS_GPU_NODE GetDecoderVirtualNodePerStream(MOS_STREAM_HANDLE streamState); |
| 2370 |
|
| 2371 |
//! |
| 2372 |
//! \brief set virtual node for each decoder stream |
| 2373 |
//! |
| 2374 |
static void SetDecoderVirtualNodePerStream(MOS_STREAM_HANDLE streamState, MOS_GPU_NODE node); |
| 2375 |
|
| 2376 |
//! \brief Wait for the created Batch Buffer completion event |
| 2377 |
//! \details Wait for the created Batch Buffer completion event, we will be |
| 2378 |
//! woken up for every Batch Buffer completion or when TimeOut expires |
| 2379 |
//! \param MOS_STREAM_HANDLE streamState |
| 2380 |
//! [in] Pointer to streamState |
| 2381 |
//! \param GPU_CONTEXT_HANDLE gpuContextHandle |
| 2382 |
//! [in] gpuContextHandle |
| 2383 |
//! \param uint32_t uiTimeOut |
| 2384 |
//! [in] Wait until signaled or TimeOut ms |
| 2385 |
//! \return MOS_STATUS |
| 2386 |
//! Return MOS_STATUS_SUCCESS if success else failure reason |
| 2387 |
//! |
| 2388 |
static MOS_STATUS WaitForBBCompleteNotifyEvent( |
| 2389 |
MOS_STREAM_HANDLE streamState, |
| 2390 |
GPU_CONTEXT_HANDLE gpuContextHandle, |
| 2391 |
uint32_t uiTimeOut); |
| 2392 |
|
| 2393 |
//! |
| 2394 |
//! \brief Register GPU Context with KMD BB Complete Event |
| 2395 |
//! \details Register GPU Context with KMD BB Complete Event |
| 2396 |
//! \param MOS_STREAM_HANDLE streamState |
| 2397 |
//! [in] Pointer to streamState |
| 2398 |
//! \param GPU_CONTEXT_HANDLE gpuContextHandle |
| 2399 |
//! [in] GPU context handle |
| 2400 |
//! \return MOS_STATUS |
| 2401 |
//! MOS_STATUS_SUCCESS if success else fail reason |
| 2402 |
//! |
| 2403 |
static MOS_STATUS RegisterBBCompleteNotifyEvent( |
| 2404 |
MOS_STREAM_HANDLE streamState, |
| 2405 |
GPU_CONTEXT_HANDLE gpuContextHandle); |
| 2406 |
|
| 2407 |
static void GetRtLogResourceInfo( |
| 2408 |
PMOS_INTERFACE osInterface, |
| 2409 |
PMOS_RESOURCE &osResource, |
| 2410 |
uint32_t &size); |
| 2411 |
|
| 2412 |
static bool IsPooledResource(MOS_STREAM_HANDLE streamState, PMOS_RESOURCE osResource); |
| 2413 |
|
| 2414 |
static uint64_t GetResourceHandle(MOS_STREAM_HANDLE streamState, PMOS_RESOURCE osResource); |
| 2415 |
|
| 2416 |
static void SetIsTrinityEnabled(bool bTrinity); |
| 2417 |
|
| 2418 |
static bool IsGpuSyncByCmd(MOS_STREAM_HANDLE streamState, GPU_CONTEXT_HANDLE gpuContextHandle); |
| 2419 |
|
| 2420 |
private: |
| 2421 |
//! |
| 2422 |
//! \brief Init per stream parameters |
| 2423 |
//! \details Init per stream parameters |
| 2424 |
//! |
| 2425 |
//! \param [in] streamState |
| 2426 |
//! Handle of Os Stream State |
| 2427 |
//! \param [in] extraParams |
| 2428 |
//! Additional parameters needed to init streamstate |
| 2429 |
//! |
| 2430 |
//! \return MOS_STATUS |
| 2431 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 2432 |
//! |
| 2433 |
static MOS_STATUS InitStreamParameters( |
| 2434 |
MOS_STREAM_HANDLE streamState, |
| 2435 |
EXTRA_PARAMS extraParams = nullptr); |
| 2436 |
|
| 2437 |
//! |
| 2438 |
//! \brief Compose Cmd buffer header |
| 2439 |
//! \details Compose Cmd buffer header if it contains header |
| 2440 |
//! |
| 2441 |
//! \param [in] streamState |
| 2442 |
//! Handle of Os Stream State |
| 2443 |
//! \param [out] cmdBuffer |
| 2444 |
//! Cmd buffer to compose header. |
| 2445 |
//! |
| 2446 |
//! \return MOS_STATUS |
| 2447 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 2448 |
//! |
| 2449 |
static MOS_STATUS ComposeCommandBufferHeader( |
| 2450 |
MOS_STREAM_HANDLE streamState, |
| 2451 |
COMMAND_BUFFER_HANDLE cmdBuffer); |
| 2452 |
|
| 2453 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 2454 |
//! \brief Unified dump command buffer initialization |
| 2455 |
//! \details check if dump command buffer was enabled and create the output directory |
| 2456 |
//! \param [in/out] streamState |
| 2457 |
//! Os stream state to init cmd buffer dump |
| 2458 |
//! \return MOS_STATUS |
| 2459 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 2460 |
//! |
| 2461 |
static MOS_STATUS DumpCommandBufferInit( |
| 2462 |
MOS_STREAM_HANDLE streamState); |
| 2463 |
#endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 2464 |
|
| 2465 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 2466 |
|
| 2467 |
enum OS_API_FAIL_TYPE |
| 2468 |
{ |
| 2469 |
OS_API_FAIL_TYPE_NONE = 0, |
| 2470 |
OS_FAIL_ALLOC_GFX_RES = 1, |
| 2471 |
OS_FAIL_REGISTER_GFX_RES = 1 << 1, |
| 2472 |
OS_API_FAIL_TYPE_MAX = OS_FAIL_ALLOC_GFX_RES | OS_FAIL_REGISTER_GFX_RES, |
| 2473 |
}; |
| 2474 |
|
| 2475 |
enum OS_API_FAIL_SIMULATE_MODE |
| 2476 |
{ |
| 2477 |
OS_API_FAIL_SIMULATE_MODE_DEFAULT = 0, |
| 2478 |
OS_API_FAIL_SIMULATE_MODE_RANDOM = 1, |
| 2479 |
OS_API_FAIL_SIMULATE_MODE_TRAVERSE = 1 << 1, |
| 2480 |
OS_API_FAIL_SIMULATE_MODE_MAX = OS_API_FAIL_SIMULATE_MODE_RANDOM | OS_API_FAIL_SIMULATE_MODE_TRAVERSE, |
| 2481 |
}; |
| 2482 |
|
| 2483 |
#define MIN_OS_API_FAIL_FREQ (1) //max memory allcation fail rate 100% |
| 2484 |
#define MAX_OS_API_FAIL_FREQ (10000) //min memory allcation fail rate 1/10000 |
| 2485 |
|
| 2486 |
#define MosOsApiFailSimulationEnabled(OsApiType) \ |
| 2487 |
(m_mosOsApiFailSimulateType == OsApiType && \ |
| 2488 |
m_mosOsApiFailSimulateMode & OS_API_FAIL_SIMULATE_MODE_MAX) |
| 2489 |
|
| 2490 |
//! |
| 2491 |
//! \brief Init OS API fail simulate flags |
| 2492 |
//! \details Init OS API fail simulate flags according user feature value |
| 2493 |
//! \param [in] mosCtx |
| 2494 |
//! os device ctx handle |
| 2495 |
//! \return void |
| 2496 |
//! |
| 2497 |
static void MosInitOsApiFailSimulateFlag(MediaUserSettingSharedPtr userSettingPtr); |
| 2498 |
|
| 2499 |
//! |
| 2500 |
//! \brief Deinit OS API fail simulate flags |
| 2501 |
//! \details Reset OS API fail simulate flags |
| 2502 |
//! \param none |
| 2503 |
//! \return void |
| 2504 |
//! |
| 2505 |
static void MosDeinitOsApiFailSimulateFlag(); |
| 2506 |
|
| 2507 |
static bool MosSimulateOsApiFail( |
| 2508 |
OS_API_FAIL_TYPE type, |
| 2509 |
const char *functionName, |
| 2510 |
const char *filename, |
| 2511 |
int32_t line); |
| 2512 |
|
| 2513 |
static uint32_t m_mosOsApiFailSimulateType; |
| 2514 |
static uint32_t m_mosOsApiFailSimulateMode; |
| 2515 |
static uint32_t m_mosOsApiFailSimulateFreq; |
| 2516 |
static uint32_t m_mosOsApiFailSimulateHint; |
| 2517 |
static uint32_t m_mosOsApiFailSimulateCounter; |
| 2518 |
#endif |
| 2519 |
static bool m_bTrinity; |
| 2520 |
MEDIA_CLASS_DEFINE_END(MosInterface) |
| 2521 |
}; |
| 2522 |
|
| 2523 |
#define Mos_ResetResource(resource) MosInterface::MosResetResource(resource) |
| 2524 |
|
| 2525 |
#endif // __MOS_INTERFACE_H__ |