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_os.h
24 //! \brief Common interface and structure used in MOS OS
25 //!
26
27 #ifndef __MOS_OS_H__
28 #define __MOS_OS_H__
29
30 #include "mos_defs.h"
31 #include "mos_utilities.h"
32 #include "media_skuwa_specific.h"
33 #include "mos_util_debug.h"
34 #include "mos_os_hw.h" //!< HW specific details that flow through OS pathes
35 #if (_RELEASE_INTERNAL || _DEBUG)
36 #if defined(CM_DIRECT_GUC_SUPPORT)
37 #include "work_queue_mngr.h"
38 #include <FirmwareManager/GpuFW/GucModule/commoninc/KmGucClientInterface.h>
39 #endif
40 #endif
41
42 #include "media_user_setting_specific.h"
43 #include "null_hardware.h"
44 //!
45 //! \brief OS specific includes and definitions
46 //!
47 #include "mos_os_specific.h"
48 #include "mos_os_virtualengine_specific.h"
49
50 #include "mos_oca_interface.h"
51 #include "mos_cache_manager.h"
52
53 #define MOS_NAL_UNIT_LENGTH 4
54 #define MOS_NAL_UNIT_STARTCODE_LENGTH 3
55 #define MOS_MAX_PATH_LENGTH 256
56
57 #define MOS_MAX_SEMAPHORE_COUNT 3
58 #define MOS_MAX_OBJECT_SIGNALED 32
59
60 #define MOS_INVALID_APPID 0xFFFFFFFF
61
62 #define MOS_GPU_CONTEXT_CREATE_DEFAULT 1
63 #define MOS_GPU_CONTEXT_CREATE_CM_DEFAULT 15
64
65 #define MOS_VCS_ENGINE_USED(GpuContext) ( \
66 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO) || \
67 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO2) || \
68 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO3) || \
69 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO4) || \
70 ((GpuContext) == MOS_GPU_CONTEXT_VDBOX2_VIDEO) || \
71 ((GpuContext) == MOS_GPU_CONTEXT_VDBOX2_VIDEO2) || \
72 ((GpuContext) == MOS_GPU_CONTEXT_VDBOX2_VIDEO3) || \
73 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO5) || \
74 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO6) || \
75 ((GpuContext) == MOS_GPU_CONTEXT_VIDEO7) \
76 )
77
78 #define MOS_RCS_ENGINE_USED(GpuContext) ( \
79 ((GpuContext) == MOS_GPU_CONTEXT_RENDER) || \
80 ((GpuContext) == MOS_GPU_CONTEXT_RENDER2) || \
81 ((GpuContext) == MOS_GPU_CONTEXT_RENDER3) || \
82 ((GpuContext) == MOS_GPU_CONTEXT_RENDER4) || \
83 ((GpuContext) == MOS_GPU_CONTEXT_COMPUTE) || \
84 ((GpuContext) == MOS_GPU_CONTEXT_CM_COMPUTE) || \
85 ((GpuContext) == MOS_GPU_CONTEXT_COMPUTE_RA) || \
86 ((GpuContext) == MOS_GPU_CONTEXT_RENDER_RA) \
87 )
88
89 #define MOS_BCS_ENGINE_USED(GpuContext) ( \
90 ((GpuContext) == MOS_GPU_CONTEXT_BLT))
91
92 #if MOS_MEDIASOLO_SUPPORTED
93 #define MOS_VECS_ENGINE_USED(GpuContext) ( \
94 ((GpuContext) == MOS_GPU_CONTEXT_VEBOX) || \
95 ((GpuContext) == MOS_GPU_CONTEXT_VEBOX2))
96 #else
97 #define MOS_VECS_ENGINE_USED(GpuContext) ( \
98 ((GpuContext) == MOS_GPU_CONTEXT_VEBOX))
99 #endif
100
101 #define MOS_TEECS_ENGINE_USED(GpuContext) ( \
102 ((GpuContext) == MOS_GPU_CONTEXT_TEE))
103
104 #if MOS_COMMAND_BUFFER_DUMP_SUPPORTED
105 #define MOS_COMMAND_BUFFER_OUT_FILE "Command_buffer_output"
106 #define MOS_COMMAND_BUFFER_OUT_DIR "Command_buffer_dumps"
107 #define MOS_COMMAND_BUFFER_RENDER_ENGINE "CS"
108 #define MOS_COMMAND_BUFFER_VIDEO_ENGINE "VCS"
109 #define MOS_COMMAND_BUFFER_VEBOX_ENGINE "VECS"
110 #define MOS_COMMAND_BUFFER_TEE_ENGINE "TEE"
111 #define MOS_COMMAND_BUFFER_PLATFORM_LEN 4
112 #endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED
113
114 #ifndef E_NOTIMPL
115 #define E_NOTIMPL 0x80004001L
116 #endif // E_NOTIMPL
117
118 #ifndef E_UNEXPECTED
119 #define E_UNEXPECTED 0x8000FFFFL
120 #endif // E_UNEXPECTED
121
122 //!
123 //! \brief Structure to OS sync parameters
124 //!
125 typedef struct _MOS_SYNC_PARAMS
126 {
127 MOS_GPU_CONTEXT GpuContext; //!< GPU context you would like to signal on or wait in
128 PMOS_RESOURCE presSyncResource; //!< Has 2 meanings:
129 //!< 1) a resource that requires sync, like a destination surface
130 //!< 2) a resource used by HW/OS to sync between engines, like for MI_SEMAPHORE_MBOX
131 uint32_t uiSemaphoreCount;
132 uint32_t uiSemaphoreValue; //!< Tag value in the case of resource tagging
133 uint32_t uiSemaphoreOffset; //!< Offset into the sync resource for value read/write
134 int32_t bReadOnly; //!< Marks the resource as read or write for future waits
135 int32_t bDisableDecodeSyncLock; //!< Disable the lock function for decode.
136 int32_t bDisableLockForTranscode; //!< Disable the lock function for transcode perf.
137 } MOS_SYNC_PARAMS, *PMOS_SYNC_PARAMS;
138
139 typedef enum _MOS_SCALABILITY_ENABLE_MODE
140 {
141 MOS_SCALABILITY_ENABLE_MODE_FALSE = 0,
142 MOS_SCALABILITY_ENABLE_MODE_DEFAULT = 0x0001,
143 MOS_SCALABILITY_ENABLE_MODE_USER_FORCE = 0x0010
144 } MOS_SCALABILITY_ENABLE_MODE;
145
146 typedef enum _TRINITY_PATH
147 {
148 TRINITY_DISABLED = 0,
149 TRINITY9_ENABLED = 1,
150 TRINITY11_ENABLED = 2,
151 } TRINITY_PATH;
152
153 #if (_DEBUG || _RELEASE_INTERNAL)
154 //!
155 //! \brief for forcing VDBOX
156 //!
157
158 #define MOS_FORCE_VDBOX_NONE 0
159 #define MOS_FORCE_VDBOX_1 0x0001
160 #define MOS_FORCE_VDBOX_2 0x0002
161 //below is for scalability case,
162 //format is FE vdbox is specified as lowest 4 bits; BE0 is 2nd low 4 bits; BE1 is 3rd low 4bits.
163 #define MOS_FORCE_VDBOX_1_1_2 0x0211
164 //FE-VDBOX2, BE0-VDBOX1, BE2-VDBOX2
165 #define MOS_FORCE_VDBOX_2_1_2 0x0212
166
167 //!
168 //! \brief Enum for forcing VEBOX
169 //!
170 typedef enum _MOS_FORCE_VEBOX
171 {
172 MOS_FORCE_VEBOX_NONE = 0,
173 MOS_FORCE_VEBOX_1 = 0x0001,
174 MOS_FORCE_VEBOX_2 = 0x0002,
175 MOS_FORCE_VEBOX_3 = 0x0003,
176 MOS_FORCE_VEBOX_4 = 0x0004,
177 // For scalability case
178 MOS_FORCE_VEBOX_1_2 = 0x0012,
179 MOS_FORCE_VEBOX_1_2_3 = 0x0123,
180 MOS_FORCE_VEBOX_1_2_3_4 = 0x1234
181 } MOS_FORCE_VEBOX;
182
183 #define MOS_FORCEVEBOX_VEBOXID_BITSNUM 4 //each VEBOX ID occupies 4 bits see defintion MOS_FORCE_VEBOX
184 #define MOS_FORCEVEBOX_MASK 0xf
185
186
187 #define MOS_FORCEVDBOX_VDBOXID_BITSNUM 4 //each VDBOX ID occupies 4 bits see defintion MOS_FORCE_VDBOX
188 #define MOS_FORCEVDBOX_MASK 0xF
189
190 #define MOS_FORCEENGINE_MASK 0xf
191 #define MOS_FORCEENGINE_ENGINEID_BITSNUM 4 //each VDBOX ID occupies 4 bits see defintion MOS_FORCE_VDBOX
192 #define MOS_INVALID_FORCEENGINE_VALUE 0xffffffff
193 #define MOS_INVALID_ENGINE_INSTANCE 0xff // this invalid engine instance value aligns with KMD
194 #endif
195
196 typedef struct _MOS_VIRTUALENGINE_INTERFACE *PMOS_VIRTUALENGINE_INTERFACE;
197 typedef struct _MOS_CMD_BUF_ATTRI_VE MOS_CMD_BUF_ATTRI_VE, *PMOS_CMD_BUF_ATTRI_VE;
198
199
200 typedef struct _MOS_COMMAND_BUFFER_ATTRIBUTES
201 {
202 int32_t bTurboMode;
203 int32_t bIsMdfLoad;
204 int32_t bMediaPreemptionEnabled;
205 uint32_t dwNumRequestedEUSlices;
206 uint32_t dwNumRequestedSubSlices;
207 uint32_t dwNumRequestedEUs;
208 int32_t bValidPowerGatingRequest;
209 int32_t bEnableMediaFrameTracking;
210 uint32_t dwMediaFrameTrackingTag;
211 uint32_t dwMediaFrameTrackingAddrOffset;
212 PMOS_RESOURCE resMediaFrameTrackingSurface;
213 int32_t bUmdSSEUEnable;
214 int32_t bFrequencyBoost;
215 void* pAttriVe;
216 } MOS_COMMAND_BUFFER_ATTRIBUTES, *PMOS_COMMAND_BUFFER_ATTRIBUTES;
217
218 //!
219 //! \brief VDBOX indices
220 //!
221 typedef enum _MOS_VDBOX_NODE_IND
222 {
223 MOS_VDBOX_NODE_INVALID = -1,
224 MOS_VDBOX_NODE_1 = 0x0,
225 MOS_VDBOX_NODE_2 = 0x1
226 } MOS_VDBOX_NODE_IND;
227
228 //!
229 //! \brief VEBOX indices
230 //!
231 typedef enum _MOS_VEBOX_NODE_IND
232 {
233 MOS_VEBOX_NODE_INVALID = -1,
234 MOS_VEBOX_NODE_1 = 0x0,
235 MOS_VEBOX_NODE_2 = 0x1,
236 MOS_VEBOX_NODE_3 = 0x2,
237 MOS_VEBOX_NODE_4 = 0x3
238 } MOS_VEBOX_NODE_IND;
239
240 #define SUBMISSION_TYPE_SINGLE_PIPE (1 << 0)
241 #define SUBMISSION_TYPE_SINGLE_PIPE_MASK (0xff)
242 #define SUBMISSION_TYPE_MULTI_PIPE_SHIFT 8
243 #define SUBMISSION_TYPE_MULTI_PIPE_ALONE (1 << SUBMISSION_TYPE_MULTI_PIPE_SHIFT)
244 #define SUBMISSION_TYPE_MULTI_PIPE_MASTER (1 << (SUBMISSION_TYPE_MULTI_PIPE_SHIFT+1))
245 #define SUBMISSION_TYPE_MULTI_PIPE_SLAVE (1 << (SUBMISSION_TYPE_MULTI_PIPE_SHIFT+2))
246 #define SUBMISSION_TYPE_MULTI_PIPE_MASK (0xff << SUBMISSION_TYPE_MULTI_PIPE_SHIFT)
247 #define SUBMISSION_TYPE_MULTI_PIPE_SLAVE_INDEX_SHIFT 16
248 #define SUBMISSION_TYPE_MULTI_PIPE_SLAVE_INDEX_MASK (0xff << SUBMISSION_TYPE_MULTI_PIPE_SLAVE_INDEX_SHIFT)
249 #define SUBMISSION_TYPE_MULTI_PIPE_FLAGS_SHIFT 24
250 #define SUBMISSION_TYPE_MULTI_PIPE_FLAGS_MASK (0xff << SUBMISSION_TYPE_MULTI_PIPE_FLAGS_SHIFT)
251 #define SUBMISSION_TYPE_MULTI_PIPE_FLAGS_LAST_PIPE (1 << SUBMISSION_TYPE_MULTI_PIPE_FLAGS_SHIFT)
252 typedef int32_t MOS_SUBMISSION_TYPE;
253
254 #define EXTRA_PADDING_NEEDED 4096
255 #define MEDIA_CMF_UNCOMPRESSED_WRITE 0xC
256
257 //!
258 //! \brief Structure to command buffer
259 //!
260 typedef struct _MOS_COMMAND_BUFFER
261 {
262 MOS_RESOURCE OsResource; //!< OS Resource
263
264 // Common fields
265 uint32_t *pCmdBase; //!< Base address (CPU)
266 uint32_t *pCmdPtr; //!< Current address (CPU)
267 int32_t iOffset; //!< Current offset in bytes
268 int32_t iRemaining; //!< Remaining size
269 int32_t iTokenOffsetInCmdBuf; //!< Pointer to (Un)Secure token's next field Offset
270 int32_t iCmdIndex; //!< command buffer's index
271 MOS_VDBOX_NODE_IND iVdboxNodeIndex; //!< Which VDBOX buffer is binded to
272 MOS_VEBOX_NODE_IND iVeboxNodeIndex; //!< Which VEBOX buffer is binded to
273 int32_t iSubmissionType;
274 bool is1stLvlBB; //!< indicate it's a first level BB or not
275 struct _MOS_COMMAND_BUFFER *cmdBuf1stLvl; //!< Pointer to 1st level command buffer.
276 MOS_COMMAND_BUFFER_ATTRIBUTES Attributes; //!< Attributes for the command buffer to be provided to KMD at submission
277 } MOS_COMMAND_BUFFER;
278
279 //!
280 //! \brief Structure to Lock params
281 //!
282 typedef struct _MOS_LOCK_PARAMS
283 {
284 union
285 {
286 struct
287 {
288 uint32_t ReadOnly : 1; //!< Lock only for reading.
289 uint32_t WriteOnly : 1; //!< Lock only for writing.
290 uint32_t TiledAsTiled : 1; //!< Means that you want to lock a tiled surface as tiled, not linear.
291 uint32_t NoOverWrite : 1; //!< No Over write for async locks
292 uint32_t NoDecompress : 1; //!< No decompression for memory compressed surface
293 uint32_t Uncached : 1; //!< Use uncached lock
294 uint32_t ForceCached : 1; //!< Prefer normal map to global GTT map(Uncached) if both can work
295 uint32_t DumpBeforeSubmit : 1; //!< Lock only for dump before submit
296 uint32_t DumpAfterSubmit : 1; //!< Lock only for dump after submit
297 uint32_t Reserved : 23; //!< Reserved for expansion.
298 };
299 uint32_t Value;
300 };
301 } MOS_LOCK_PARAMS, *PMOS_LOCK_PARAMS;
302
303 //!
304 //! \brief flags for GFX allocation destroy
305 //!
306 typedef struct _MOS_GFXRES_FREE_FLAGS
307 {
308 union
309 {
310 struct
311 {
312 uint32_t AssumeNotInUse : 1;
313 uint32_t SynchronousDestroy : 1;
314 uint32_t Reserved : 30;
315 };
316 uint32_t Value;
317 };
318 } MOS_GFXRES_FREE_FLAGS;
319
320 //!
321 //! \brief Structure to Resource Flags
322 //!
323 typedef struct _MOS_GFXRES_FLAGS
324 {
325 int32_t bNotLockable; //!< [in] true: Resource will not be CPU accessible. false: Resource can be CPU accessed.
326 int32_t bOverlay;
327 int32_t bFlipChain;
328 int32_t bSVM;
329 int32_t bCacheable;
330 } MOS_GFXRES_FLAGS, *PMOS_GFXRES_FLAGS;
331
332 //!
333 //! \brief Structure to Resource allocation parameters
334 //!
335 typedef struct _MOS_ALLOC_GFXRES_PARAMS
336 {
337 MOS_GFXRES_TYPE Type; //!< [in] Basic resource geometry
338 MOS_GFXRES_FLAGS Flags; //!< [in] Flags to describe attributes
339 union
340 {
341 uint32_t dwWidth; //!< [in] Type == 2D || VOLUME, width in pixels.
342 uint32_t dwBytes; //!< [in] Type == BUFFER, # of bytes
343 };
344 uint32_t dwHeight; //!< [in] Type == 2D || VOLUME, height in rows. Type == BUFFER, n/a
345 uint32_t dwDepth; //!< [in] 0: Implies 2D resource. >=1: volume resource
346 uint32_t dwArraySize; //!< [in] 0,1: 1 element. >1: N elements
347 MOS_TILE_TYPE TileType; //!< [in] Defines the layout of a physical page. Optimal choice depends on usage model.
348 MOS_TILE_MODE_GMM m_tileModeByForce; //!< [in] Indicates a tile Encoding (aligned w/ GMM defination) needs set by force
349 MOS_FORMAT Format; //!< [in] Pixel format
350 void *pSystemMemory; //!< [in] Optional parameter. If non null, TileType must be set to linear.
351 const char *pBufName; //!< [in] Optional parameter. A string indicates the buffer name and is used for debugging. nullptr is OK.
352 int32_t bIsCompressible; //!< [in] Resource is compressible or not.
353 MOS_RESOURCE_MMC_MODE CompressionMode; //!< [in] Compression mode.
354 int32_t bIsPersistent; //!< [in] Optional parameter. Used to indicate that resource can not be evicted
355 int32_t bBypassMODImpl;
356 int32_t dwMemType; //!< [in] Optional paramerter. Prefer memory type
357 MOS_HW_RESOURCE_DEF ResUsageType; //!< [in] the resource usage type to determine the cache policy
358 bool hardwareProtected; //!< [in] Flag as hint that Resource can be used as hw protected
359 } MOS_ALLOC_GFXRES_PARAMS, *PMOS_ALLOC_GFXRES_PARAMS;
360
361 //!
362 //! \brief Enum for MOS patch type
363 //!
364 typedef enum _MOS_PATCH_TYPE
365 {
366 MOS_PATCH_TYPE_BASE_ADDRESS = 0,
367 MOS_PATCH_TYPE_PITCH,
368 MOS_PATCH_TYPE_UV_Y_OFFSET,
369 MOS_PATCH_TYPE_BIND_ONLY,
370 MOS_PATCH_TYPE_UV_BASE_ADDRESS,
371 MOS_PATCH_TYPE_V_BASE_ADDRESS,
372 MOS_PATCH_TYPE_V_Y_OFFSET
373 } MOS_PATCH_TYPE;
374
375 //!
376 //! \brief Structure to OS sync parameters
377 //!
378 typedef struct _MOS_PATCH_ENTRY_PARAMS
379 {
380 PMOS_RESOURCE presResource; //!< resource to be patched
381 uint32_t uiAllocationIndex;
382 uint32_t uiResourceOffset; //!< resource offset
383 uint32_t uiPatchOffset; //!< patch offset
384 uint32_t bWrite; //!< is write operation
385 int32_t bUpperBoundPatch; //!< is upper bound patch
386 MOS_HW_COMMAND HwCommandType; //!< hw cmd type
387 uint32_t forceDwordOffset; //!< force dword offset
388 uint8_t *cmdBufBase; //!< cmd buffer base address
389 uint32_t offsetInSSH; //!< patch offset in SSH
390 uint32_t shiftAmount; //!< shift amount for patch
391 uint32_t shiftDirection; //!< shift direction for patch
392 MOS_PATCH_TYPE patchType; //!< patch type
393 MOS_COMMAND_BUFFER *cmdBuffer; //!< command buffer
394 } MOS_PATCH_ENTRY_PARAMS, *PMOS_PATCH_ENTRY_PARAMS;
395
396 typedef struct _MOS_GPUCTX_CREATOPTIONS MOS_GPUCTX_CREATOPTIONS, *PMOS_GPUCTX_CREATOPTIONS;
397 struct _MOS_GPUCTX_CREATOPTIONS
398 {
399 uint32_t CmdBufferNumScale;
400 uint32_t RAMode;
401 uint32_t ProtectMode;
402 uint32_t gpuNode;
403 //For slice shutdown
404 union
405 {
406 struct
407 {
408 uint8_t SliceCount;
409 uint8_t SubSliceCount; //Subslice count per slice
410 uint8_t MaxEUcountPerSubSlice;
411 uint8_t MinEUcountPerSubSlice;
412 } packed;
413
414 uint32_t SSEUValue;
415 };
416
417 uint8_t isRealTimePriority; // 1 if context is created from real time priority command queue (run GT at higher frequency)
418
_MOS_GPUCTX_CREATOPTIONS_MOS_GPUCTX_CREATOPTIONS419 _MOS_GPUCTX_CREATOPTIONS() : CmdBufferNumScale(MOS_GPU_CONTEXT_CREATE_DEFAULT),
420 RAMode(0),
421 ProtectMode(0),
422 gpuNode(0),
423 SSEUValue(0),
424 isRealTimePriority(0){}
425
_MOS_GPUCTX_CREATOPTIONS_MOS_GPUCTX_CREATOPTIONS426 _MOS_GPUCTX_CREATOPTIONS(_MOS_GPUCTX_CREATOPTIONS* createOption) : CmdBufferNumScale(createOption->CmdBufferNumScale),
427 RAMode(createOption->RAMode),
428 ProtectMode(createOption->ProtectMode),
429 gpuNode(createOption->gpuNode),
430 SSEUValue(createOption->SSEUValue),
431 isRealTimePriority(createOption->isRealTimePriority) {}
432
~_MOS_GPUCTX_CREATOPTIONS_MOS_GPUCTX_CREATOPTIONS433 virtual ~_MOS_GPUCTX_CREATOPTIONS(){}
434 };
435
436 class OsContext;
437
438 #if MOS_COMMAND_RESINFO_DUMP_SUPPORTED
439 //!
440 //! \brief Class to Dump GPU Command Info
441 //!
442 class GpuCmdResInfoDump
443 {
444 public:
445
446 static const GpuCmdResInfoDump *GetInstance(PMOS_CONTEXT mosCtx);
447 GpuCmdResInfoDump(PMOS_CONTEXT mosCtx);
448
449 void Dump(PMOS_INTERFACE pOsInterface) const;
450
451 void StoreCmdResPtr(PMOS_INTERFACE pOsInterface, const void *pRes) const;
452
453 void ClearCmdResPtrs(PMOS_INTERFACE pOsInterface) const;
454
455 private:
456
457 struct GpuCmdResInfo;
458
459 void Dump(const void *pRes, std::ofstream &outputFile) const;
460
461 const std::vector<const void *> &GetCmdResPtrs(PMOS_INTERFACE pOsInterface) const;
462
463 const char *GetResType(MOS_GFXRES_TYPE resType) const;
464
465 const char *GetTileType(MOS_TILE_TYPE tileType) const;
466
467 private:
468
469 static std::shared_ptr<GpuCmdResInfoDump> m_instance;
470 mutable uint32_t m_cnt = 0;
471 bool m_dumpEnabled = false;
472 std::string m_path = "";
473 };
474 #endif // MOS_COMMAND_RESINFO_DUMP_SUPPORTED
475
476 class OsContextNext;
477 typedef void * OS_PER_STREAM_PARAMETERS;
478 typedef void * EXTRA_PARAMS;
479 typedef OsContextNext OsDeviceContext;
480 typedef _MOS_GPUCTX_CREATOPTIONS GpuContextCreateOption;
481 struct _MOS_INTERFACE;
482 class MosVeInterface;
483 class CommandList;
484 class CmdBufMgrNext;
485 class MosCpInterface;
486 class MosDecompression;
487
488 //!
489 //! \brief Structure to Unified InDirectState Dump Info
490 //!
491 struct INDIRECT_STATE_INFO
492 {
493 uint32_t stateSize = 0; //size of indirectstate
494 uint32_t *indirectState = nullptr; //indirectstate address
495 uint32_t *gfxAddressBottom = nullptr; //indirect gfx address bottom
496 uint32_t *gfxAddressTop = nullptr; //indirect gfx address top
497 const char *stateName = "";
498 };
499
500 struct MosStreamState
501 {
502 OsDeviceContext *osDeviceContext = nullptr;
503 GPU_CONTEXT_HANDLE currentGpuContextHandle = MOS_GPU_CONTEXT_INVALID_HANDLE;
504 MOS_COMPONENT component = COMPONENT_UNKNOWN;
505
506 CommandList *currentCmdList = nullptr; //<! Command list used in async mode
507 CmdBufMgrNext *currentCmdBufMgr = nullptr; //<! Cmd buffer manager used in async mode
508 MosDecompression *mosDecompression = nullptr; //<! Decompression State used for decompress
509 bool enableDecomp = false; //<! Set true in StreamState init. If false then not inited
510 bool postponedExecution = false; //!< Indicate if the stream is work in postponed execution mode. This flag is only used in aync mode.
511
512 bool supportVirtualEngine = false; //!< Flag to indicate using virtual engine interface
513 MosVeInterface *virtualEngineInterface = nullptr; //!< Interface to virtual engine state
514 bool useHwSemaForResSyncInVe = false; //!< Flag to indicate if UMD need to send HW sema cmd under this OS when there is a resource sync need with Virtual Engine interface
515 bool veEnable = false; //!< Flag to indicate virtual engine enabled (Can enable VE without using virtual engine interface)
516 bool phasedSubmission = false; //!< Flag to indicate if secondary command buffers are submitted together or separately due to different OS
517 bool frameSplit = true; //!< Flag to indicate if frame split is enabled (only active when phasedSubmission is true)
518 int32_t hcpDecScalabilityMode = 0; //!< Hcp scalability mode
519 int32_t veboxScalabilityMode = 0; //!< Vebox scalability mode
520
521 bool ctxBasedScheduling = false; //!< Indicate if context based scheduling is enabled in this stream
522 bool multiNodeScaling = false; //!< Flag to indicate if multi-node scaling is enabled for virtual engine (only active when ctxBasedScheduling is true)
523
524 int32_t ctxPriority = 0;
525 bool softReset = false; //!< trigger soft reset
526
527 MosCpInterface *osCpInterface = nullptr; //!< CP interface
528
529 bool mediaReset = false; //!< Flag to indicate media reset is enabled
530
531 bool forceMediaCompressedWrite = false; //!< Flag to force media compressed write
532
533 bool simIsActive = false; //!< Flag to indicate if Simulation is enabled
534 MOS_NULL_RENDERING_FLAGS nullHwAccelerationEnable = {}; //!< To indicate which components to enable Null HW support
535
536 bool usesPatchList = false; //!< Uses patch list instead of graphic address directly
537 bool usesGfxAddress = false; //!< Uses graphic address directly instead of patch list
538 bool enableKmdMediaFrameTracking = false; //!< Enable KMD Media frame tracking
539 bool usesCmdBufHeaderInResize = false; //!< Use cmd buffer header in resize
540 bool usesCmdBufHeader = false; //!< Use cmd buffer header
541
542 // GPU Reset Statistics
543 uint32_t gpuResetCount = 0;
544 uint32_t gpuActiveBatch = 0;
545 uint32_t gpuPendingBatch = 0;
546
547 #if MOS_COMMAND_BUFFER_DUMP_SUPPORTED
548 // Command buffer dump
549 bool dumpCommandBuffer = false; //!< Flag to indicate if Dump command buffer is enabled
550 bool dumpCommandBufferToFile = false; //!< Indicates that the command buffer should be dumped to a file
551 bool dumpCommandBufferAsMessages = false; //!< Indicates that the command buffer should be dumped via MOS normal messages
552 char sDirName[MOS_MAX_HLT_FILENAME_LEN] = {0}; //!< Dump Directory name - maximum 260 bytes length
553 std::vector<INDIRECT_STATE_INFO> indirectStateInfo = {};
554 #endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED
555
556 #if _DEBUG || _RELEASE_INTERNAL
557 bool enableDbgOvrdInVirtualEngine = false; //!< enable debug override in virtual engine
558
559 int32_t eForceVdbox = 0; //!< Force select Vdbox
560 int32_t eForceVebox = 0; //!< Force select Vebox
561 #endif // _DEBUG || _RELEASE_INTERNAL
562
563 bool bParallelSubmission = false; //!< Flag to indicate if parallel submission is enabled
564 OS_PER_STREAM_PARAMETERS perStreamParameters = nullptr; //!< Parameters of OS specific per stream
565
566 static void *pvSoloContext; //!< pointer to MediaSolo context
567
568 #if MOS_MEDIASOLO_SUPPORTED
569
570 int32_t bSupportMediaSoloVirtualEngine = 0; //!< Flag to indicate if MediaSolo uses VE solution in cmdbuffer submission.
571 uint32_t dwEnableMediaSoloFrameNum = 0; //!< The frame number at which MediaSolo will be enabled, 0 is not valid.
572 int32_t bSoloInUse = 0; //!< Flag to indicate if MediaSolo is enabled
573 #endif // MOS_MEDIASOLO_SUPPORTED
574
575 };
576
577 // OS agnostic MOS objects
578 typedef OsDeviceContext *MOS_DEVICE_HANDLE;
579 typedef MosStreamState *MOS_STREAM_HANDLE;
580 //typedef uint32_t GPU_CONTEXT_HANDLE;
581 typedef MOS_COMMAND_BUFFER *COMMAND_BUFFER_HANDLE;
582 typedef MOS_RESOURCE *MOS_RESOURCE_HANDLE;
583 typedef MosVeInterface *MOS_VE_HANDLE;
584
585 // OS specific MOS objects
586 typedef void * OsSpecificRes; //!< stand for different os specific resource structure (or info)
587 typedef void * OS_HANDLE; //!< stand for different os handles
588 typedef MOS_SURFACE MosResourceInfo;
589 typedef void * DDI_DEVICE_CONTEXT; //!< stand for different os specific device context
590 typedef void * MOS_INTERFACE_HANDLE;
591
592 class GpuContextMgr;
593
594 namespace CMRT_UMD
595 {
596 class CmDevice;
597 };
598 struct _CM_HAL_STATE;
599 typedef struct _CM_HAL_STATE *PCM_HAL_STATE;
600 class MhwCpInterface;
601 class CodechalSecureDecodeInterface;
602 class CodechalSetting;
603 class CodechalHwInterface;
604 class CodechalHwInterfaceNext;
605
606 struct MOS_SURF_DUMP_SURFACE_DEF
607 {
608 uint32_t offset; //!< Offset from start of the plane
609 uint32_t height; //!< Height in rows
610 uint32_t width; //!< Width in bytes
611 uint32_t pitch; //!< Pitch in bytes
612 };
613
614 struct ResourceDumpAttri
615 {
616 MOS_RESOURCE res = {};
617 MOS_LOCK_PARAMS lockFlags = {};
618 std::string fullFileName = {};
619 uint32_t width = 0;
620 uint32_t height = 0;
621 uint32_t pitch = 0;
622 MOS_GFXRES_FREE_FLAGS resFreeFlags = {};
623 MOS_PLANE_OFFSET yPlaneOffset = {}; // Y surface plane offset
624 MOS_PLANE_OFFSET uPlaneOffset = {}; // U surface plane offset
625 MOS_PLANE_OFFSET vPlaneOffset = {}; // V surface plane offset
626 };
627
628 //!
629 //! \brief Structure to Unified HAL OS resources
630 //!
631 typedef struct _MOS_INTERFACE
632 {
633 //APO WRAPPER
634 MOS_STREAM_HANDLE osStreamState = MOS_INVALID_HANDLE;
635
636 // Saved OS context
637 PMOS_CONTEXT pOsContext;
638 MOS_GPU_CONTEXT CurrentGpuContextOrdinal = MOS_GPU_CONTEXT_MAX;
639 //!< An internal handle that indexes into the list of GPU Context object
640 uint32_t CurrentGpuContextHandle;
641 //!< A handle to the graphics context device that can be used to calls back
642 //!< into the kernel subsystem
643 HANDLE CurrentGpuContextRuntimeHandle;
644
645 //!< Only used in async and softlet mos mode for backward compatiable
646 GPU_CONTEXT_HANDLE m_GpuContextHandleMap[MOS_GPU_CONTEXT_MAX] = {0};
647 GPU_CONTEXT_HANDLE m_encContext;
648 GPU_CONTEXT_HANDLE m_pakContext;
649 // OS dependent settings, flags, limits
650 int32_t b64bit;
651 int32_t bDeallocateOnExit;
652 MOS_USER_FEATURE_INTERFACE UserFeatureInterface;
653 MosCpInterface *osCpInterface;
654
655 int32_t bUsesCmdBufHeader;
656 int32_t bUsesCmdBufHeaderInResize;
657 int32_t bEnableKmdMediaFrameTracking;
658 int32_t bNoParsingAssistanceInKmd;
659 bool bPitchAndUVPatchingNeeded = false;
660 uint32_t dwCommandBufferReservedSpace;
661 uint32_t dwNumNalUnitBytesIncluded;
662
663 // GPU Reset Statistics
664 uint32_t dwGPUResetCount;
665 uint32_t dwGPUActiveBatch;
666 uint32_t dwGPUPendingBatch;
667
668 // Resource addressing
669 int32_t bUsesPatchList;
670 int32_t bUsesGfxAddress;
671 int32_t bMapOnCreate; // For limited GPU VA resource can not be mapped during creation
672 int32_t bInlineCodecStatusUpdate; // check whether use inline codec status update or seperate BB
673 int32_t bAllowExtraPatchToSameLoc; // patch another resource to same location in cmdbuffer
674
675 // Component info
676 MOS_COMPONENT Component;
677
678 // Stream info
679 uint32_t streamIndex = 0;
680
681 // Synchronization
682 int32_t bTagEngineSync;
683 int32_t bTagResourceSync;
684 int32_t bOsEngineSync;
685 int32_t bOsResourceSync;
686
687 // Simulation (HAS) related
688 int32_t bSimIsActive; //!< Flag to indicate if HAS is enabled
689
690 MOS_NULL_RENDERING_FLAGS NullHWAccelerationEnable; //!< To indicate which components to enable Null HW support
691
692 // for MODS Wrapper
693 int32_t modulizedMosEnabled;
694 int32_t modularizedGpuCtxEnabled;
695 OsContext* osContextPtr;
696
697 // used for media reset enabling/disabling in UMD
698 // pls remove it after hw scheduling
699 int32_t bMediaReset;
700 TRINITY_PATH trinityPath;
701
702 bool umdMediaResetEnable;
703
704 bool forceMediaCompressedWrite;
705
706 #if MOS_MEDIASOLO_SUPPORTED
707 // MediaSolo related
708 int32_t bSoloInUse; //!< Flag to indicate if MediaSolo is enabled
709 static void *pvSoloContext; //!< pointer to MediaSolo context
710 static uint32_t soloRefCnt;
711 uint32_t dwEnableMediaSoloFrameNum; //!< The frame number at which MediaSolo will be enabled, 0 is not valid.
712 #endif // MOS_MEDIASOLO_SUPPORTED
713
714 #if MOS_COMMAND_BUFFER_DUMP_SUPPORTED
715 // Command buffer dump
716 int32_t bDumpCommandBuffer; //!< Flag to indicate if Dump command buffer is enabled
717 int32_t bDumpCommandBufferToFile; //!< Indicates that the command buffer should be dumped to a file
718 int32_t bDumpCommandBufferAsMessages; //!< Indicates that the command buffer should be dumped via MOS normal messages
719 char sPlatformName[MOS_COMMAND_BUFFER_PLATFORM_LEN]; //!< Platform name - maximum 4 bytes length
720 char sDirName[MOS_MAX_HLT_FILENAME_LEN]; //!< Dump Directory name - maximum 260 bytes length
721 #endif // MOS_COMMAND_BUFFER_DUMP_SUPPORTED
722
723 #if (_RELEASE_INTERNAL||_DEBUG)
724 #if defined(CM_DIRECT_GUC_SUPPORT)
725 CMRTWorkQueueMngr *m_pWorkQueueMngr;
726 CMRT_WORK_QUEUE_INFO m_WorkQueueInfo[5]; //IGFX_ABSOLUTE_MAX_ENGINES
727 #endif
728 #endif
729
730 bool bEnableVdboxBalancing; //!< Enable per BB VDBox balancing
731 #if (_DEBUG || _RELEASE_INTERNAL)
732 int eForceVdbox; //!< Force select Vdbox
733 uint32_t dwForceTileYfYs; // force to allocate Yf (=1) or Ys (=2), remove after full validation
734 int32_t bTriggerCodecHang; // trigger GPU HANG in codec
735 int32_t bTriggerVPHang; //!< trigger GPU HANG in VP
736 #endif // (_DEBUG || _RELEASE_INTERNAL)
737
738 bool apoMosEnabled; //!< apo mos or not
739 bool apoMosForLegacyRuntime = false;
740 std::vector<ResourceDumpAttri> resourceDumpAttriArray;
741
742 MEMORY_OBJECT_CONTROL_STATE (* pfnCachePolicyGetMemoryObject) (
743 MOS_HW_RESOURCE_DEF Usage,
744 GMM_CLIENT_CONTEXT *pGmmClientContext);
745
746 uint8_t (* pfnCachePolicyGetL1Config) (
747 MOS_HW_RESOURCE_DEF Usage,
748 GMM_CLIENT_CONTEXT *pGmmClientContext);
749
750 MOS_STATUS (* pfnCreateGpuContext) (
751 PMOS_INTERFACE pOsInterface,
752 MOS_GPU_CONTEXT GpuContext,
753 MOS_GPU_NODE GpuNode,
754 PMOS_GPUCTX_CREATOPTIONS createOption);
755
756 GPU_CONTEXT_HANDLE (*pfnCreateGpuComputeContext) (
757 PMOS_INTERFACE osInterface,
758 MOS_GPU_CONTEXT gpuContext,
759 MOS_GPUCTX_CREATOPTIONS *createOption);
760
761 MOS_STATUS (* pfnDestroyGpuContext) (
762 PMOS_INTERFACE pOsInterface,
763 MOS_GPU_CONTEXT GpuContext);
764
765 MOS_STATUS (* pfnDestroyGpuContextByHandle) (
766 PMOS_INTERFACE pOsInterface,
767 GPU_CONTEXT_HANDLE gpuContextHandle);
768
769 MOS_STATUS (* pfnDestroyGpuComputeContext) (
770 PMOS_INTERFACE osInterface,
771 GPU_CONTEXT_HANDLE gpuContextHandle);
772
773 MOS_STATUS (* pfnSetGpuContext) (
774 PMOS_INTERFACE pOsInterface,
775 MOS_GPU_CONTEXT GpuContext);
776
777 MOS_STATUS (*pfnSetGpuContextFromHandle)(PMOS_INTERFACE osInterface,
778 MOS_GPU_CONTEXT contextName,
779 GPU_CONTEXT_HANDLE contextHandle);
780
781 MOS_STATUS (*pfnSetGpuContextHandle) (
782 PMOS_INTERFACE pOsInterface,
783 GPU_CONTEXT_HANDLE gpuContextHandle,
784 MOS_GPU_CONTEXT GpuContext);
785
786 #if (_RELEASE_INTERNAL || _DEBUG)
787 #if defined(CM_DIRECT_GUC_SUPPORT)
788 MOS_STATUS(*pfnDestroyGuC) (
789 PMOS_INTERFACE pOsInterface);
790 MOS_STATUS(*pfnInitGuC) (
791 PMOS_INTERFACE pOsInterface,
792 MOS_GPU_NODE Engine);
793 MOS_STATUS(*pfnSubmitWorkQueue) (
794 PMOS_INTERFACE pOsInterface,
795 MOS_GPU_NODE Engine,
796 uint64_t BatchBufferAddress);
797 #endif
798 #endif
799
800 MOS_GPU_CONTEXT (* pfnGetGpuContext) (
801 PMOS_INTERFACE pOsInterface);
802
803 void* (*pfnGetGpuContextbyHandle)(
804 PMOS_INTERFACE pOsInterface,
805 const GPU_CONTEXT_HANDLE gpuContextHandle);
806
807 GMM_CLIENT_CONTEXT* (* pfnGetGmmClientContext) (
808 PMOS_INTERFACE pOsInterface);
809
810 MOS_STATUS (* pfnIsGpuContextValid) (
811 PMOS_INTERFACE pOsInterface,
812 MOS_GPU_CONTEXT GpuContext);
813
814 void (* pfnSetEncodeEncContext) (
815 PMOS_INTERFACE pOsInterface,
816 MOS_GPU_CONTEXT GpuContext);
817
818 void (* pfnSetEncodePakContext) (
819 PMOS_INTERFACE pOsInterface,
820 MOS_GPU_CONTEXT GpuContext);
821
822 void (* pfnSyncOnResource) (
823 PMOS_INTERFACE pOsInterface,
824 PMOS_RESOURCE pOsResource,
825 MOS_GPU_CONTEXT requestorGPUCtx,
826 int32_t bWriteOperation);
827
828 void (* pfnSyncOnOverlayResource) (
829 PMOS_INTERFACE pOsInterface,
830 PMOS_RESOURCE pOsResource,
831 MOS_GPU_CONTEXT requestorGPUCtx);
832
833 void (* pfnSetResourceSyncTag) (
834 PMOS_INTERFACE pOsInterface,
835 PMOS_SYNC_PARAMS pParams);
836
837 MOS_STATUS (* pfnPerformOverlaySync) (
838 PMOS_INTERFACE pOsInterface,
839 PMOS_SYNC_PARAMS pParams);
840
841 MOS_STATUS (* pfnResourceSignal) (
842 PMOS_INTERFACE pOsInterface,
843 PMOS_SYNC_PARAMS pParams);
844
845 MOS_STATUS (* pfnResourceWait) (
846 PMOS_INTERFACE pOsInterface,
847 PMOS_SYNC_PARAMS pParams);
848
849 MOS_STATUS (* pfnEngineSignal) (
850 PMOS_INTERFACE pOsInterface,
851 PMOS_SYNC_PARAMS pParams);
852
853 MOS_STATUS (* pfnEngineWait) (
854 PMOS_INTERFACE pOsInterface,
855 PMOS_SYNC_PARAMS pParams);
856
857 MOS_STATUS (* pfnWaitAllCmdCompletion) (
858 PMOS_INTERFACE pOsInterface);
859
860 MOS_STATUS (* pfnCreateSyncResource) (
861 PMOS_INTERFACE pOsInterface,
862 PMOS_RESOURCE pOsResource);
863
864 MOS_STATUS (* pfnDestroySyncResource) (
865 PMOS_INTERFACE pOsInterface,
866 PMOS_RESOURCE pOsResource);
867
868 void (* pfnSyncGpuContext) (
869 PMOS_INTERFACE pOsInterface,
870 MOS_GPU_CONTEXT busyGPUCtx,
871 MOS_GPU_CONTEXT requestorGPUCtx);
872
873 MOS_STATUS (* pfnRegisterBBCompleteNotifyEvent) (
874 PMOS_INTERFACE pOsInterface,
875 MOS_GPU_CONTEXT GpuContext);
876
877 MOS_STATUS (* pfnWaitForBBCompleteNotifyEvent) (
878 PMOS_INTERFACE pOsInterface,
879 MOS_GPU_CONTEXT GpuContext,
880 uint32_t uiTimeOut);
881
882 void (* pfnDestroy) (
883 PMOS_INTERFACE pOsInterface,
884 int32_t bDestroyVscVppDeviceTag);
885
886 void (* pfnGetPlatform) (
887 PMOS_INTERFACE pOsInterface,
888 PLATFORM *pPlatform);
889
890 MEDIA_FEATURE_TABLE *(* pfnGetSkuTable) (
891 PMOS_INTERFACE pOsInterface);
892
893 MEDIA_WA_TABLE *(* pfnGetWaTable) (
894 PMOS_INTERFACE pOsInterface);
895
896 MEDIA_SYSTEM_INFO *(* pfnGetGtSystemInfo)(
897 PMOS_INTERFACE pOsInterface);
898
899 MOS_STATUS (*pfnGetMediaEngineInfo)(
900 PMOS_INTERFACE pOsInterface, MEDIA_ENGINE_INFO &info);
901
902 void (* pfnResetOsStates) (
903 PMOS_INTERFACE pOsInterface);
904
905 MOS_STATUS(* pfnInitializeMultiThreadingSyncTags) (
906 PMOS_INTERFACE pOsInterface,
907 PMOS_RESOURCE pOsResource,
908 uint8_t ucRenderTargetIndex,
909 PMOS_SEMAPHORE *pCurFrmSem,
910 PMOS_SEMAPHORE *pRefFrmSem,
911 PMOS_MUTEX *pFrmMutex);
912
913 MOS_STATUS (* pfnMultiThreadingWaitCurrentFrame) (
914 PMOS_RESOURCE pOsResource);
915
916 MOS_STATUS (* pfnMultiThreadingPostCurrentFrame) (
917 PMOS_RESOURCE pOsResource);
918
919 MOS_STATUS (* pfnMultiThreadResourceSync) (
920 PMOS_INTERFACE pOsInterface,
921 PMOS_RESOURCE pOsResource);
922
923 MOS_STATUS(*pfnSetHybridDecoderRunningFlag) (
924 PMOS_INTERFACE pOsInterface,
925 int32_t bFlag);
926
927 MOS_STATUS(*pfnGetHybridDecoderRunningFlag) (
928 PMOS_INTERFACE pOsInterface,
929 int32_t *pFlag);
930
931 uint32_t (* pfnGetInterfaceVersion) (
932 PMOS_INTERFACE pOsInterface);
933
934 #if MOS_MESSAGES_ENABLED
935
936 #define pfnAllocateResource(pOsInterface, pParams, pOsResource) \
937 pfnAllocateResource(pOsInterface, pParams, __FUNCTION__, __FILE__, __LINE__, pOsResource)
938
939 MOS_STATUS (* pfnAllocateResource) (
940 PMOS_INTERFACE pOsInterface,
941 PMOS_ALLOC_GFXRES_PARAMS pParams,
942 const char *functionName,
943 const char *filename,
944 int32_t line,
945 PMOS_RESOURCE pOsResource);
946
947 MOS_STATUS (* pfnDumpCommandBuffer) (
948 PMOS_INTERFACE pOsInterface,
949 PMOS_COMMAND_BUFFER pCmdBuffer);
950
951 void (* pfnAddIndirectState) (
952 PMOS_INTERFACE pOsInterface,
953 uint32_t indirectStateSize,
954 uint32_t *pIndirectState,
955 uint32_t *gfxAddressBottom,
956 uint32_t *gfxAddressTop,
957 const char *stateName);
958
959 #define pfnFreeResource(pOsInterface, pResource) \
960 pfnFreeResource(pOsInterface, __FUNCTION__, __FILE__, __LINE__, pResource)
961
962 void (* pfnFreeResource) (
963 PMOS_INTERFACE pOsInterface,
964 const char *functionName,
965 const char *filename,
966 int32_t line,
967 PMOS_RESOURCE pResource);
968
969 #define pfnFreeResourceWithFlag(pOsInterface, pResource, uiFlag) \
970 pfnFreeResourceWithFlag(pOsInterface, pResource, __FUNCTION__, __FILE__, __LINE__, uiFlag)
971
972 void (* pfnFreeResourceWithFlag) (
973 PMOS_INTERFACE pOsInterface,
974 PMOS_RESOURCE pResource,
975 const char *functionName,
976 const char *filename,
977 int32_t line,
978 uint32_t uiFlag);
979
980 #else
981
982 MOS_STATUS (* pfnAllocateResource) (
983 PMOS_INTERFACE pOsInterface,
984 PMOS_ALLOC_GFXRES_PARAMS pParams,
985 PMOS_RESOURCE pOsResource);
986
987 void (* pfnFreeResource) (
988 PMOS_INTERFACE pOsInterface,
989 PMOS_RESOURCE pResource);
990
991 void (* pfnFreeResourceWithFlag) (
992 PMOS_INTERFACE pOsInterface,
993 PMOS_RESOURCE pResource,
994 uint32_t uiFlag);
995
996 #endif // MOS_MESSAGES_ENABLED
997
998 MOS_STATUS (* pfnGetResourceInfo) (
999 PMOS_INTERFACE pOsInterface,
1000 PMOS_RESOURCE pOsResource,
1001 PMOS_SURFACE pDetails);
1002
1003 MOS_STATUS (* pfnLockSyncRequest) (
1004 PMOS_INTERFACE pOsInterface,
1005 PMOS_RESOURCE pResource,
1006 PMOS_LOCK_PARAMS pFlags);
1007
1008 void *(* pfnLockResource) (
1009 PMOS_INTERFACE pOsInterface,
1010 PMOS_RESOURCE pResource,
1011 PMOS_LOCK_PARAMS pFlags);
1012
1013 MOS_STATUS (* pfnUnlockResource) (
1014 PMOS_INTERFACE pOsInterface,
1015 PMOS_RESOURCE pResource);
1016
1017 MOS_STATUS (* pfnDecompResource) (
1018 PMOS_INTERFACE pOsInterface,
1019 PMOS_RESOURCE pResource);
1020
1021 MOS_STATUS (* pfnSetDecompSyncRes) (
1022 PMOS_INTERFACE pOsInterface,
1023 PMOS_RESOURCE syncResource);
1024
1025 MOS_STATUS(*pfnDoubleBufferCopyResource) (
1026 PMOS_INTERFACE pOsInterface,
1027 PMOS_RESOURCE pInputOsResource,
1028 PMOS_RESOURCE pOutputOsResource,
1029 bool bOutputCompressed);
1030
1031 MOS_STATUS(*pfnMediaCopyResource2D) (
1032 PMOS_INTERFACE pOsInterface,
1033 PMOS_RESOURCE pInputOsResource,
1034 PMOS_RESOURCE pOutputOsResource,
1035 uint32_t copyPitch,
1036 uint32_t copyHeight,
1037 uint32_t bpp,
1038 bool bOutputCompressed);
1039
1040 MOS_STATUS (*pfnMonoSurfaceCopy) (
1041 PMOS_INTERFACE pOsInterface,
1042 PMOS_RESOURCE pInputOsResource,
1043 PMOS_RESOURCE pOutputOsResource,
1044 uint32_t copyPitch,
1045 uint32_t copyHeight,
1046 uint32_t copyInputOffset,
1047 uint32_t copyOutputOffset,
1048 bool bOutputCompressed);
1049
1050 MOS_STATUS (*pfnVerifyMosSurface) (
1051 PMOS_SURFACE mosSurface,
1052 bool &bIsValid);
1053
1054 MOS_STATUS(*pfnGetMosContext) (
1055 PMOS_INTERFACE pOsInterface,
1056 PMOS_CONTEXT* mosContext);
1057
1058 MOS_STATUS (* pfnFillResource) (
1059 PMOS_INTERFACE pOsInterface,
1060 PMOS_RESOURCE pResource,
1061 uint32_t dwSize,
1062 uint8_t iValue);
1063
1064 MOS_STATUS (*pfnUpdateResourceUsageType) (
1065 PMOS_RESOURCE pOsResource,
1066 MOS_HW_RESOURCE_DEF resUsageType);
1067
1068 MOS_STATUS (* pfnRegisterResource) (
1069 PMOS_INTERFACE pOsInterface,
1070 PMOS_RESOURCE pResource,
1071 int32_t bWrite,
1072 int32_t bWritebSetResourceSyncTag);
1073
1074 void (* pfnResetResourceAllocationIndex) (
1075 PMOS_INTERFACE pOsInterface,
1076 PMOS_RESOURCE pResource);
1077
1078 int32_t (* pfnGetResourceAllocationIndex) (
1079 PMOS_INTERFACE pOsInterface,
1080 PMOS_RESOURCE pResource);
1081
1082 uint64_t (* pfnGetResourceGfxAddress) (
1083 PMOS_INTERFACE pOsInterface,
1084 PMOS_RESOURCE pResource);
1085
1086 uint64_t (*pfnGetResourceClearAddress)(
1087 PMOS_INTERFACE pOsInterface,
1088 PMOS_RESOURCE pResource);
1089
1090 MOS_STATUS (* pfnSetPatchEntry) (
1091 PMOS_INTERFACE pOsInterface,
1092 PMOS_PATCH_ENTRY_PARAMS pParams);
1093
1094 #if MOS_MEDIASOLO_SUPPORTED
1095 MOS_STATUS (* pfnInitializeMediaSolo) (
1096 PMOS_INTERFACE pOsInterface);
1097 #endif // MOS_MEDIASOLO_SUPPORTED
1098
1099 uint32_t (* pfnGetGpuStatusTag) (
1100 PMOS_INTERFACE pOsInterface,
1101 MOS_GPU_CONTEXT GpuContext);
1102
1103 void (* pfnIncrementGpuStatusTag) (
1104 PMOS_INTERFACE pOsInterface,
1105 MOS_GPU_CONTEXT GpuContext);
1106
1107 uint32_t (* pfnGetGpuStatusTagOffset) (
1108 PMOS_INTERFACE pOsInterface,
1109 MOS_GPU_CONTEXT GpuContext);
1110
1111 uint32_t (* pfnGetGpuStatusSyncTag) (
1112 PMOS_INTERFACE pOsInterface,
1113 MOS_GPU_CONTEXT GpuContext);
1114
1115 MOS_STATUS (* pfnVerifyCommandBufferSize) (
1116 PMOS_INTERFACE pOsInterface,
1117 uint32_t dwRequestedSize,
1118 uint32_t dwFlags);
1119
1120 MOS_STATUS (* pfnResizeCommandBufferAndPatchList) (
1121 PMOS_INTERFACE pOsInterface,
1122 uint32_t dwRequestedCommandBufferSize,
1123 uint32_t dwRequestedPatchListSize,
1124 uint32_t dwFlags);
1125
1126 MOS_STATUS (* pfnGetCommandBuffer) (
1127 PMOS_INTERFACE pOsInterface,
1128 PMOS_COMMAND_BUFFER pCmdBuffer,
1129 uint32_t dwFlags);
1130
1131 MOS_STATUS (* pfnSetIndirectStateSize) (
1132 PMOS_INTERFACE pOsInterface,
1133 uint32_t uSize);
1134
1135 MOS_STATUS (* pfnGetIndirectState) (
1136 PMOS_INTERFACE pOsInterface,
1137 uint32_t *puOffset,
1138 uint32_t *puSize);
1139
1140 MOS_STATUS (* pfnGetIndirectStatePointer) (
1141 PMOS_INTERFACE pOsInterface,
1142 uint8_t **pIndirectState);
1143
1144 void (* pfnReturnCommandBuffer) (
1145 PMOS_INTERFACE pOsInterface,
1146 PMOS_COMMAND_BUFFER pCmdBuffer,
1147 uint32_t dwFlags);
1148
1149 MOS_STATUS (* pfnSubmitCommandBuffer) (
1150 PMOS_INTERFACE pOsInterface,
1151 PMOS_COMMAND_BUFFER pCmdBuffer,
1152 int32_t bNullRendering);
1153
1154 MOS_STATUS (* pfnWaitAndReleaseCmdBuffer) (
1155 PMOS_INTERFACE pOsInterface,
1156 PMOS_COMMAND_BUFFER pCmdBuffer);
1157
1158 void (* pfnSetPerfTag) (
1159 PMOS_INTERFACE pOsInterface,
1160 uint32_t PerfTag);
1161
1162 uint32_t(* pfnGetPerfTag) (
1163 PMOS_INTERFACE pOsInterface);
1164
1165 void (* pfnResetPerfBufferID) (
1166 PMOS_INTERFACE pOsInterface);
1167
1168 void (* pfnIncPerfFrameID) (
1169 PMOS_INTERFACE pOsInterface);
1170
1171 void (* pfnIncPerfBufferID) (
1172 PMOS_INTERFACE pOsInterface);
1173
1174 void (* pfnSetPerfHybridKernelID) (
1175 PMOS_INTERFACE pOsInterface,
1176 uint32_t KernelID);
1177
1178 int32_t (* pfnIsPerfTagSet) (
1179 PMOS_INTERFACE pOsInterface);
1180
1181 MOS_STATUS (* pfnGetBitsPerPixel) (
1182 PMOS_INTERFACE pOsInterface,
1183 MOS_FORMAT Format,
1184 uint32_t *piBpp);
1185
1186 MOS_STATUS (*pfnLoadLibrary) (
1187 PMOS_INTERFACE pOsInterface,
1188 const char *pFileName,
1189 PHMODULE phModule);
1190
1191 MOS_STATUS (*pfnFreeLibrary) (
1192 HINSTANCE hInstance);
1193
1194 MOS_NULL_RENDERING_FLAGS (* pfnGetNullHWRenderFlags) (
1195 PMOS_INTERFACE pOsInterface);
1196
1197 MOS_STATUS (* pfnSetCmdBufferDebugInfo) (
1198 PMOS_INTERFACE pOsInterface,
1199 int32_t bSamplerState,
1200 int32_t bSurfaceState,
1201 uint32_t dwStateIndex,
1202 uint32_t dwType);
1203
1204 uint32_t (* pfnGetCmdBufferDebugInfo) (
1205 PMOS_INTERFACE pOsInterface,
1206 int32_t bSamplerState,
1207 int32_t bSurfaceState,
1208 uint32_t dwStateIndex);
1209
1210 MOS_STATUS (*pfnGetGpuStatusBufferResource) (
1211 PMOS_INTERFACE pOsInterface,
1212 PMOS_RESOURCE &pOsResource);
1213
1214 MOS_STATUS (* pfnVerifyPatchListSize) (
1215 PMOS_INTERFACE pOsInterface,
1216 uint32_t dwRequestedSize);
1217
1218 MOS_STATUS (* pfnResetCommandBuffer) (
1219 PMOS_INTERFACE pOsInterface,
1220 PMOS_COMMAND_BUFFER pCmdBuffer);
1221
1222 MOS_STATUS (* pfnGetMemoryCompressionMode) (
1223 PMOS_INTERFACE pOsInterface,
1224 PMOS_RESOURCE pOsResource,
1225 PMOS_MEMCOMP_STATE pResMmcMode);
1226
1227 MOS_STATUS (* pfnSetMemoryCompressionMode) (
1228 PMOS_INTERFACE pOsInterface,
1229 PMOS_RESOURCE pOsResource,
1230 MOS_MEMCOMP_STATE ResMmcMode);
1231
1232 MOS_STATUS (* pfnSetMemoryCompressionHint) (
1233 PMOS_INTERFACE pOsInterface,
1234 PMOS_RESOURCE pOsResource,
1235 int32_t bHintOn);
1236
1237 MOS_STATUS (* pfnGetMemoryCompressionFormat) (
1238 PMOS_INTERFACE pOsInterface,
1239 PMOS_RESOURCE pOsResource,
1240 uint32_t *pResMmcFormat);
1241
1242 MOS_STATUS (* pfnCreateVideoNodeAssociation)(
1243 PMOS_INTERFACE pOsInterface,
1244 int32_t bSetVideoNode,
1245 MOS_GPU_NODE *pVideoNodeOrdinal);
1246
1247 MOS_VDBOX_NODE_IND (* pfnGetVdboxNodeId)(
1248 PMOS_INTERFACE pOsInterface,
1249 PMOS_COMMAND_BUFFER pCmdBuffer);
1250
1251 MOS_STATUS (* pfnDestroyVideoNodeAssociation)(
1252 PMOS_INTERFACE pOsInterface,
1253 MOS_GPU_NODE VideoNodeOrdinal);
1254
1255 MOS_STATUS(*pfnSkipResourceSync)(
1256 PMOS_RESOURCE pOsResource);
1257
1258 MOS_STATUS(*pfnSetObjectCapture)(
1259 PMOS_RESOURCE pOsResource);
1260
1261 bool(*pfnIsValidStreamID)(
1262 PMOS_RESOURCE pOsResource);
1263
1264 void(*pfnInvalidateStreamID)(
1265 PMOS_RESOURCE pOsResource);
1266
1267 MOS_STATUS(*pfnSetStreamID)(
1268 PMOS_RESOURCE pOsResource,
1269 PMOS_INTERFACE pOsInterface,
1270 uint8_t streamID);
1271
1272 uint8_t(*pfnGetStreamID)(
1273 PMOS_RESOURCE pOsResource);
1274
1275 int32_t (*pfnIsGPUHung)(
1276 PMOS_INTERFACE pOsInterface);
1277
1278 bool (*pfnIsMultipleCodecDevicesInUse)(
1279 PMOS_INTERFACE pOsInterface);
1280
1281 MOS_STATUS (*pfnSetMultiEngineEnabled)(
1282 PMOS_INTERFACE pOsInterface,
1283 MOS_COMPONENT component,
1284 bool enabled);
1285
1286 MOS_STATUS (*pfnGetMultiEngineStatus)(
1287 PMOS_INTERFACE pOsInterface,
1288 PLATFORM *platform,
1289 MOS_COMPONENT component,
1290 bool &isMultiDevices,
1291 bool &isMultiEngine);
1292
1293 MOS_GPU_NODE(*pfnGetLatestVirtualNode)(
1294 PMOS_INTERFACE pOsInterface,
1295 MOS_COMPONENT component);
1296
1297 void (*pfnSetLatestVirtualNode)(
1298 PMOS_INTERFACE pOsInterface,
1299 MOS_GPU_NODE node);
1300
1301 MOS_GPU_NODE (*pfnGetDecoderVirtualNodePerStream)(
1302 PMOS_INTERFACE pOsInterface);
1303
1304 void (*pfnSetDecoderVirtualNodePerStream)(
1305 PMOS_INTERFACE pOsInterface,
1306 MOS_GPU_NODE node);
1307
1308 HANDLE (*pfnGetUmdDmaCompleteEventHandle)(
1309 PMOS_INTERFACE osInterface,
1310 MOS_GPU_CONTEXT gpuContext);
1311
1312 //!
1313 //! \brief Get Aux Table base address
1314 //!
1315 //! \param [in] pOsInterface
1316 //! MOS_INTERFACE pointer
1317 //! \return uint64_t
1318 //! return Aux Table base address
1319 //!
1320 uint64_t(*pfnGetAuxTableBaseAddr)(
1321 PMOS_INTERFACE pOsInterface);
1322
1323 //!
1324 //! \brief Get Gpu Priority
1325 //! \param [in] pOsInterface
1326 //! pointer to the current gpu context.
1327 //! \param [out] pPriority
1328 //! pointer to the priority get from gpu context.
1329 //!
1330 void (*pfnGetGpuPriority)(
1331 PMOS_INTERFACE pOsInterface,
1332 int32_t *pPriority);
1333
1334 //!
1335 //! \brief Set Gpu Priority
1336 //!
1337 //! \param [in] pOsInterface
1338 //! pointer to the current gpu context
1339 //! \param [in] priority
1340 //! pointer to the priority set to gpu context
1341 //!
1342 void (*pfnSetGpuPriority)(
1343 PMOS_INTERFACE pOsInterface,
1344 int32_t priority);
1345
1346 //!
1347 //! \brief Set slice count to shared memory and KMD
1348 //! \param [in] pOsInterface
1349 //! pointer to the requested slice count for current context
1350 //! \param [out] pSliceCount
1351 //! pointer to the ruling slice count shared by all contexts
1352 void (*pfnSetSliceCount)(
1353 PMOS_INTERFACE pOsInterface,
1354 uint32_t *pSliceCount);
1355
1356 //!
1357 //! \brief Get resource index
1358 //! \param [in] osResource
1359 //! pointer to the resource
1360 //! \return uint32_t
1361 //! return resource index
1362 uint32_t(*pfnGetResourceIndex)(
1363 PMOS_RESOURCE osResource);
1364
1365 //!
1366 //! \brief Get SetMarker enabled flag
1367 //! \details Get SetMarker enabled flag from OsInterface
1368 //! \param PMOS_INTERFACE pOsInterface
1369 //! [in] OS Interface
1370 //! \return bool
1371 //! SetMarker enabled flag
1372 //!
1373 bool (*pfnIsSetMarkerEnabled)(
1374 PMOS_INTERFACE pOsInterface);
1375
1376 //!
1377 //! \brief Get SetMarker resource address
1378 //! \details Get SetMarker resource address from OsInterface
1379 //! \param PMOS_INTERFACE pOsInterface
1380 //! [in] OS Interface
1381 //! \return PMOS_RESOURCE
1382 //! SetMarker resource address
1383 //!
1384 PMOS_RESOURCE (*pfnGetMarkerResource)(
1385 PMOS_INTERFACE pOsInterface);
1386
1387 //!
1388 //! \brief Is Device Async or not
1389 //! \details Is Device Async or not.
1390 //! \param [in] streamState
1391 //! Handle of Os Stream State.
1392 //! \return bool
1393 //! Return true if is async, otherwise false
1394 //!
1395 bool (*pfnIsAsyncDevice)(
1396 MOS_STREAM_HANDLE streamState);
1397
1398 //!
1399 //! \brief Mos format to os format
1400 //! \details Mos format to os format
1401 //! \param [in] format
1402 //! Mos format.
1403 //! \return uint32_t
1404 //! Return OS FORMAT
1405 //!
1406 uint32_t (*pfnMosFmtToOsFmt)(
1407 MOS_FORMAT format);
1408
1409 //!
1410 //! \brief Os format to Mos format
1411 //! \details Os format to Mos format
1412 //! \param [in] format
1413 //! Os format.
1414 //! \return MOS_FORMAT
1415 //! Return MOS FORMAT
1416 //!
1417 MOS_FORMAT (*pfnOsFmtToMosFmt)(
1418 uint32_t format);
1419
1420 //!
1421 //! \brief Mos format to GMM format
1422 //! \details Mos format to GMM format
1423 //! \param [in] format
1424 //! Mos format.
1425 //! \return GMM_RESOURCE_FORMAT
1426 //! Return GMM FORMAT
1427 //!
1428 GMM_RESOURCE_FORMAT (*pfnMosFmtToGmmFmt)(
1429 MOS_FORMAT format);
1430
1431 //!
1432 //! \brief GMM format to mos format
1433 //! \details GMM format to mos format
1434 //! \param [in] format
1435 //! GMM_RESOURCE_FORMAT.
1436 //! \return MOS_FORMAT
1437 //! Return MOS FORMAT
1438 //!
1439 MOS_FORMAT (*pfnGmmFmtToMosFmt)(
1440 GMM_RESOURCE_FORMAT format);
1441
1442 //!
1443 //! \brief Wait For cmd Completion
1444 //! \details [GPU Context Interface] Waiting for the completion of cmd in provided GPU context
1445 //! \details Caller: HAL only
1446 //! \param [in] streamState
1447 //! Handle of Os Stream State
1448 //! \param [in] gpuCtx
1449 //! GpuContext handle of the gpu context to wait cmd completion
1450 //! \return MOS_STATUS
1451 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1452 //!
1453 MOS_STATUS (*pfnWaitForCmdCompletion)(
1454 MOS_STREAM_HANDLE streamState,
1455 GPU_CONTEXT_HANDLE gpuCtx);
1456
1457 //!
1458 //! \brief Get Resource array index
1459 //! \details Returns the array index
1460 //! \param PMOS_RESOURCE
1461 //! [in] Pointer to MOS_RESOURCE
1462 //! \return uint32_t - array index
1463 //!
1464 uint32_t (*pfnGetResourceArrayIndex)(
1465 PMOS_RESOURCE resource);
1466
1467 //!
1468 //! \brief Setup VE Attribute Buffer
1469 //! \details [Cmd Buffer Interface] Setup VE Attribute Buffer into cmd buffer.
1470 //! \details Caller: MHW only
1471 //! \details This interface is called to setup into cmd buffer.
1472 //! \param [in] streamState
1473 //! Handle of Os Stream State
1474 //! \param [out] cmdBuffer
1475 //! Cmd buffer to setup VE attribute.
1476 //! \return MOS_STATUS
1477 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1478 //!
1479 MOS_STATUS (*pfnSetupAttributeVeBuffer)(
1480 MOS_STREAM_HANDLE streamState,
1481 COMMAND_BUFFER_HANDLE cmdBuffer);
1482
1483 //!
1484 //! \brief Get VE Attribute Buffer
1485 //! \details [Cmd Buffer Interface] Get VE Attribute Buffer from cmd buffer.
1486 //! \details Caller: HAL only
1487 //! \details This interface is called to get VE attribute buffer from cmd buffer if it contains one.
1488 //! If there is no VE attribute buffer returned, it means the cmd buffer has no such buffer
1489 //! in current MOS module. It is not error state if it is nullptr.
1490 //! \param [out] cmdBuffer
1491 //! Cmd buffer to setup VE attribute.
1492 //! \return MOS_CMD_BUF_ATTRI_VE*
1493 //! Return pointer of VE attribute buffer, nullptr if current cmdBuffer didn't contain attribute.
1494 //!
1495 MOS_CMD_BUF_ATTRI_VE* (*pfnGetAttributeVeBuffer)(
1496 COMMAND_BUFFER_HANDLE cmdBuffer);
1497
1498 //!
1499 //! \brief Setup commandlist and command pool from os interface
1500 //! \details Set the commandlist and commandPool used in this stream from os interface.
1501 //! \param [in] osInterface
1502 //! pointer to the mos interface
1503 //! \param [out] streamState
1504 //! Handle of Os Stream State.
1505 //! \return MOS_STATUS
1506 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1507 //!
1508 MOS_STATUS (*pfnSetupCurrentCmdListAndPool)(
1509 PMOS_INTERFACE osInterface,
1510 MOS_STREAM_HANDLE streamState);
1511
1512 //!
1513 //! \brief Get MOS_HW_RESOURCE_DEF
1514 //! \details [Resource Interface] Get Mos HW Resource DEF
1515 //! Caller: HAL & MHW
1516 //! \param [in] gmmResUsage
1517 //! Gmm Resource usage as index
1518 //! \return MOS_HW_RESOURCE_DEF
1519 //! Mos HW resource definition
1520 //!
1521 MOS_HW_RESOURCE_DEF (*pfnGmmToMosResourceUsageType)(
1522 GMM_RESOURCE_USAGE_TYPE gmmResUsage);
1523
1524 //!
1525 //! \brief Get Adapter Info
1526 //! \details [System info Interface] Get Adapter Info
1527 //! \details Caller: DDI & HAL
1528 //! \details This func is called to differentiate the behavior according to Adapter Info.
1529 //! \param [in] streamState
1530 //! Handle of Os Stream State
1531 //! \return ADAPTER_INFO*
1532 //! Read-only Adapter Info got, nullptr if failed to get
1533 //!
1534 ADAPTER_INFO* (*pfnGetAdapterInfo)(
1535 MOS_STREAM_HANDLE streamState);
1536
1537 //!
1538 //! \brief Surface compression is supported
1539 //! \details Surface compression is supported
1540 //! \param [in] skuTable
1541 //! Pointer to MEDIA_FEATURE_TABLE
1542 //! \return bool
1543 //! If true, compression is enabled
1544 //!
1545 bool (*pfnIsCompressibelSurfaceSupported)(
1546 MEDIA_FEATURE_TABLE *skuTable);
1547
1548 //!
1549 //! \brief Destroy Virtual Engine State
1550 //! \details [Virtual Engine Interface] Destroy Virtual Engine State of provided streamState
1551 //! \details Caller: Hal (Scalability) only
1552 //! \details This func is called when a stream (Hal instance) need to destroy a VE state
1553 //! \details into provided stream.
1554 //! \param [in] streamState
1555 //! Handle of Os Stream State
1556 //! \return MOS_STATUS
1557 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1558 //!
1559 MOS_STATUS (*pfnDestroyVirtualEngineState)(
1560 MOS_STREAM_HANDLE streamState);
1561
1562 //!
1563 //! \brief Get resource handle
1564 //! \details Get resource handle
1565 //! \param [in] streamState
1566 //! Handle of Os Stream State
1567 //! \param [in] osResource
1568 //! Pointer to mos resource
1569 //! \return uint64_t
1570 //! Return resource handle
1571 //!
1572 uint64_t (*pfnGetResourceHandle)(
1573 MOS_STREAM_HANDLE streamState,
1574 PMOS_RESOURCE osResource);
1575
1576 //!
1577 //! \brief Get RT log resource info
1578 //! \details Get RT log resource info
1579 //! \param [in] streamState
1580 //! Handle of Os Stream State
1581 //! \param [in,out] osResource
1582 //! Reference to pointer of mos resource
1583 //! \param [in,out] size
1584 //! Reference to size
1585 //! \return void
1586 //!
1587 void (*pfnGetRtLogResourceInfo)(
1588 PMOS_INTERFACE osInterface,
1589 PMOS_RESOURCE &osResource,
1590 uint32_t &size);
1591
1592 //!
1593 //! \brief OS reset resource
1594 //! \details Resets the OS resource
1595 //! \param PMOS_RESOURCE resource
1596 //! [in] Pointer to OS Resource
1597 //! \return void
1598 //! Return NONE
1599 //!
1600 void (*pfnResetResource)(
1601 PMOS_RESOURCE resource);
1602
1603
1604 #if (_DEBUG || _RELEASE_INTERNAL)
1605 //!
1606 //! \brief Get engine count
1607 //! \details [Virtual Engine Interface] Get engine count from Virtual Engine State in provided stream
1608 //! \details Caller: Hal (Scalability) only
1609 //! \details Get engine count from virtual engine state
1610 //! \param [in] streamState
1611 //! Handle of Os Stream State
1612 //! \return uint8_t
1613 //! Engine count
1614 //!
1615 uint8_t (*pfnGetVeEngineCount)(
1616 MOS_STREAM_HANDLE streamState);
1617
1618 //!
1619 //! \brief Get Engine Logic Id
1620 //! \details [Virtual Engine Interface] Get engine Logic Id from Virtual Engine State in provided stream
1621 //! \details Caller: Hal (Scalability) only
1622 //! \details Get engine Logic Id from virtual engine state
1623 //! \param [in] streamState
1624 //! Handle of Os Stream State
1625 //! \param [in] instanceIdx
1626 //! Engine instance index
1627 //! \return uint8_t
1628 //!
1629 uint8_t (*pfnGetEngineLogicIdByIdx)(
1630 MOS_STREAM_HANDLE streamState,
1631 uint32_t instanceIdx);
1632
1633 //!
1634 //! \brief Set Gpu Virtual Address for Debug
1635 //! \details Manually make page fault
1636 //!
1637 //! \param [in] pResource
1638 //! Resource to set Gpu Address
1639 //! \param [in] address
1640 //! Address to set
1641 //! \return MOS_STATUS
1642 //!
1643 MOS_STATUS (*pfnSetGpuVirtualAddress)(
1644 PMOS_RESOURCE pResource,
1645 uint64_t address);
1646 #endif
1647
1648 #if MOS_MEDIASOLO_SUPPORTED
1649 //!
1650 //! \brief Solo set ready to execute
1651 //! \details Solo set ready to execute
1652 //! \param [in] osInterface
1653 //! Pointer to OsInterface
1654 //! \param [in] readyToExecute
1655 //! ready to execute
1656 //! \return void
1657 //!
1658 void (*pfnMosSoloSetReadyToExecute)(
1659 PMOS_INTERFACE osInterface,
1660 bool readyToExecute);
1661
1662 //!
1663 //! \brief Solo Check node limitation
1664 //! \details Solo Check node limitation
1665 //! \param [in] osInterface
1666 //! Pointer to OsInterface
1667 //! \param [out] pGpuNodeToUse
1668 //! Pointer to the GPU node to use
1669 //! \return void
1670 //!
1671 void (*pfnMosSoloCheckNodeLimitation)(
1672 PMOS_INTERFACE osInterface,
1673 uint32_t *pGpuNodeToUse);
1674
1675 //!
1676 //! \brief Set MSDK event handling
1677 //! \details Receive MSDK event to be set in mediasolo
1678 //! \param [in] osInterface
1679 //! Pointer to OsInterface
1680 //! \param [out] gpuAppTaskEvent
1681 //! Event handle
1682 //! \return MOS_STATUS
1683 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1684 //!
1685 MOS_STATUS (*pfnMosSoloSetGpuAppTaskEvent)(
1686 PMOS_INTERFACE osInterface,
1687 HANDLE gpuAppTaskEvent);
1688
1689 //!
1690 //! \brief Solo force dump
1691 //! \details After dwBufferDumpFrameNum submissions are dumped. Force enable mediasolo debug out dump.
1692 //! If no solo interface exists, creates one.
1693 //! \param [in] dwBufferDumpFrameNum
1694 //! Frame Number of the buffer to dump
1695 //! \param [in, out] osInterface
1696 //! Pointer to OsInterface
1697 //! \return void
1698 //!
1699 MOS_STATUS (*pfnMosSoloForceDumps)(
1700 uint32_t dwBufferDumpFrameNum,
1701 PMOS_INTERFACE osInterface);
1702
1703 //!
1704 //! \brief Solo Pre Process for Decode
1705 //! \details Do solo specific operations before decode.
1706 //! Include disable aubload optimization.
1707 //! And set dumped resource in Aubcapture.
1708 //! \param [in] osInterface
1709 //! Indicate if this is first execute call
1710 //! \param [in] psDestSurface
1711 //! Pointer to the surface to add to Aubcapture dump
1712 //! \return MOS_STATUS
1713 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1714 //!
1715 MOS_STATUS (*pfnMosSoloPreProcessDecode)(
1716 PMOS_INTERFACE osInterface,
1717 PMOS_SURFACE psDestSurface);
1718
1719 //!
1720 //! \brief Solo Post Process for Decode
1721 //! \details Do solo specific operations after decode.
1722 //! Include remove dumped resource in Aubcapture.
1723 //! \param [in] osInterface
1724 //! Pointer to OsInterface
1725 //! \param [in] psDestSurface
1726 //! Pointer to the surface to remove from Aubcapture dump
1727 //! \return MOS_STATUS
1728 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1729 //!
1730 MOS_STATUS (*pfnMosSoloPostProcessDecode)(
1731 PMOS_INTERFACE osInterface,
1732 PMOS_SURFACE psDestSurface);
1733
1734 //!
1735 //! \brief Solo Pre Process for Encode
1736 //! \details Do solo specific operations before encode.
1737 //! Include set dumped resource in Aubcapture.
1738 //! \param [in] osInterface
1739 //! Pointer to OsInterface
1740 //! \param [in] pBitstreamBuffer
1741 //! Pointer to the resource to add to Aubcapture dump
1742 //! \param [in] pReconSurface
1743 //! Pointer to the surface to add to Aubcapture dump
1744 //! \return MOS_STATUS
1745 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1746 //!
1747 MOS_STATUS (*pfnMosSoloPreProcessEncode)(
1748 PMOS_INTERFACE osInterface,
1749 PMOS_RESOURCE pBitstreamBuffer,
1750 PMOS_SURFACE pReconSurface);
1751
1752 //!
1753 //! \brief Solo Post Process for Encode
1754 //! \details Do solo specific operations after encode.
1755 //! Include remove dumped resource in Aubcapture.
1756 //! \param [in] osInterface
1757 //! Pointer to OsInterface
1758 //! \param [in] pBitstreamBuffer
1759 //! Pointer to the resource to remove from Aubcapture dump
1760 //! \param [in] pReconSurface
1761 //! Pointer to the surface to remove from Aubcapture dump
1762 //! \return MOS_STATUS
1763 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1764 //!
1765 MOS_STATUS (*pfnMosSoloPostProcessEncode)(
1766 PMOS_INTERFACE osInterface,
1767 PMOS_RESOURCE pBitstreamBuffer,
1768 PMOS_SURFACE pReconSurface);
1769
1770 //!
1771 //! \brief Solo Disable Aubcapture Optimizations
1772 //! \details Solo Disable Aubcapture Optimizations
1773 //! \param [in] osInterface
1774 //! Pointer to OsInterface pointer list
1775 //! \param [in] bFirstExecuteCall
1776 //! Indicate if this is first execute call
1777 //! \return MOS_STATUS
1778 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1779 //!
1780 MOS_STATUS (*pfnMosSoloDisableAubcaptureOptimizations)(
1781 PMOS_INTERFACE osInterface,
1782 int32_t bFirstExecuteCall);
1783 #endif
1784 //!
1785 //! \brief Notify shared Stream index
1786 //!
1787 //! \param PMOS_INTERFACE pOsInterface
1788 //! [in] OS Interface
1789 //! \return void
1790 //!
1791 void (*pfnNotifyStreamIndexSharing)(
1792 PMOS_INTERFACE pOsInterface);
1793
1794 //!
1795 //! \brief Check if mismatch order programming model supported in current device
1796 //!
1797 //! \return bool
1798 //!
1799 bool (*pfnIsMismatchOrderProgrammingSupported)();
1800
1801 //! \brief Unified OS add command to command buffer
1802 //! \details Offset returned is dword aligned but size requested can be byte aligned
1803 //! \param PMOS_COMMAND_BUFFER pCmdBuffer
1804 //! [in/out] Pointer to Command Buffer
1805 //! \param void *pCmd
1806 //! [in] Command Pointer
1807 //! \param uint32_t dwCmdSize
1808 //! [in] Size of command in bytes
1809 //! \return MOS_STATUS
1810 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
1811 //!
1812 MOS_STATUS (*pfnAddCommand)(
1813 PMOS_COMMAND_BUFFER pCmdBuffer,
1814 const void *pCmd,
1815 uint32_t dwCmdSize);
1816
1817 //!
1818 //! \brief Check virtual engine is supported
1819 //! \details Check virtual engine is supported
1820 //! \param PMOS_INTERFACE pOsInterface
1821 //! [in] OS Interface
1822 //! \return MOS_STATUS
1823 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
1824 //!
1825 MOS_STATUS (*pfnVirtualEngineSupported)(
1826 PMOS_INTERFACE osInterface,
1827 bool isDecode,
1828 bool veDefaultEnable);
1829
1830 //!
1831 //! \brief Retrieve the CachePolicyMemoryObject for a resource
1832 //! \details Retrieve the CachePolicyMemoryObject for a resource
1833 //! \param PMOS_INTERFACE osInterface
1834 //! [in] OS Interface
1835 //! \param PMOS_RESOURCE resource
1836 //! [in] resource
1837 //! \return MEMORY_OBJECT_CONTROL_STATE
1838 //! return a value of MEMORY_OBJECT_CONTROL_STATE
1839 //!
1840 MEMORY_OBJECT_CONTROL_STATE (*pfnGetResourceCachePolicyMemoryObject)(
1841 PMOS_INTERFACE osInterface,
1842 PMOS_RESOURCE resource);
1843
1844 //!
1845 //! \brief Get Buffer Type
1846 //! \details Returns the type of buffer, 1D, 2D or volume
1847 //! \param PMOS_RESOURCE pOsResource
1848 //! [in] Pointer to OS Resource
1849 //! \return GFX resource Type
1850 //!
1851 MOS_GFXRES_TYPE (*pfnGetResType)(
1852 PMOS_RESOURCE pOsResource);
1853
1854 //!
1855 //! \brief Get TimeStamp frequency base
1856 //! \details Get TimeStamp frequency base from OsInterface
1857 //! \param PMOS_INTERFACE pOsInterface
1858 //! [in] OS Interface
1859 //! \return uint32_t
1860 //! time stamp frequency base
1861 //!
1862 uint32_t (*pfnGetTsFrequency)(
1863 PMOS_INTERFACE pOsInterface);
1864
1865 //!
1866 //! \brief Set hint parameters
1867 //! \details
1868 //! \param PMOS_INTERFACE pOsInterface
1869 //! [in] Pointer to OS interface structure
1870 //! \param MOS_VIRTUALENGINE_SET_PARAMS veParams
1871 //! [out] VIRTUALENGINE SET PARAMS
1872 //! \return MOS_STATUS
1873 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
1874 //!
1875 MOS_STATUS (*pfnSetHintParams)(
1876 PMOS_INTERFACE pOsInterface,
1877 PMOS_VIRTUALENGINE_SET_PARAMS veParams);
1878
1879 //!
1880 //! \brief Checks whether the requested resource is releasable
1881 //! \param PMOS_INTERFACE pOsInterface
1882 //! [in] OS Interface
1883 //! \param PMOS_RESOURCE pOsResource
1884 //! [in] Pointer to OS Resource
1885 //! \return MOS_STATUS
1886 //! MOS_STATUS_SUCCESS if requested can be released, otherwise MOS_STATUS_UNKNOWN
1887 //!
1888 MOS_STATUS (*pfnIsResourceReleasable)(
1889 PMOS_INTERFACE pOsInterface,
1890 PMOS_RESOURCE pOsResource);
1891
1892 //!
1893 //! \brief Virtual Engine Init for media Scalability
1894 //! \details
1895 //! \param PMOS_INTERFACE pOsInterface
1896 //! [in] Pointer to OS interface structure
1897 //! \param PMOS_VIRTUALENGINE_HINT_PARAMS veHitParams
1898 //! [out] Pointer to Virtual Engine hint parameters
1899 //! \param PMOS_VIRTUALENGINE_INTERFACE veInterface
1900 //! [out] Pointer to Virtual Engine Interface
1901 //! \return MOS_STATUS
1902 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
1903 //!
1904 MOS_STATUS (*pfnVirtualEngineInit)(
1905 PMOS_INTERFACE pOsInterface,
1906 PMOS_VIRTUALENGINE_HINT_PARAMS* veHitParams,
1907 MOS_VIRTUALENGINE_INIT_PARAMS& veInParams);
1908 //!
1909 //! \brief initialize virtual engine interface
1910 //! \details initialize virtual engine interface
1911 //! \param [in] PMOS_INTERFACE
1912 //! pointer to mos interface
1913 //! \param [in] PMOS_VIRTUALENGINE_INIT_PARAMS pVEInitParms
1914 //! pointer to VE init parameters
1915 //! \return MOS_STATUS
1916 //! MOS_STATUS_SUCCESS if success, else fail reason
1917 //!
1918 MOS_STATUS (*pfnVirtualEngineInterfaceInitialize)(
1919 PMOS_INTERFACE pOsInterface,
1920 PMOS_VIRTUALENGINE_INIT_PARAMS pVEInitParms);
1921
1922 //!
1923 //! \brief Destroy veInterface
1924 //! \details
1925 //! \param PMOS_VIRTUALENGINE_INTERFACE *veInterface
1926 //! [in] Pointer to PMOS_VIRTUALENGINE_INTERFACE
1927 //! \return MOS_STATUS
1928 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
1929 //!
1930 MOS_STATUS (*pfnDestroyVeInterface)(
1931 PMOS_VIRTUALENGINE_INTERFACE *veInterface);
1932
1933 //!
1934 //! \brief Creates a CmDevice from a MOS context.
1935 //! \details If an existing CmDevice has already associated to the MOS context,
1936 //! the existing CmDevice will be returned. Otherwise, a new CmDevice
1937 //! instance will be created and associatied with that MOS context.
1938 //! \param mosContext
1939 //! [in] pointer to MOS conetext.
1940 //! \param device
1941 //! [in,out] reference to the pointer to the CmDevice.
1942 //! \param devCreateOption
1943 //! [in] option to customize CmDevice.
1944 //! \return int32_t
1945 //! CM_SUCCESS if the CmDevice is successfully created.
1946 //! CM_NULL_POINTER if pMosContext is null.
1947 //! CM_FAILURE otherwise.
1948 //!
1949 int32_t (*pfnCreateCmDevice)(
1950 MOS_CONTEXT *mosContext,
1951 CMRT_UMD::CmDevice *&device,
1952 uint32_t devCreateOption,
1953 uint8_t priority);
1954
1955 //!
1956 //! \brief Destroys the CmDevice.
1957 //! \details This function also destroys surfaces, kernels, programs, samplers,
1958 //! threadspaces, tasks and the queues that were created using this
1959 //! device instance but haven't explicitly been destroyed by calling
1960 //! respective destroy functions.
1961 //! \param device
1962 //! [in] reference to the pointer to the CmDevice.
1963 //! \return int32_t
1964 //! CM_SUCCESS if CmDevice is successfully destroyed.
1965 //! CM_FAILURE otherwise.
1966 //!
1967 int32_t (*pfnDestroyCmDevice)(
1968 CMRT_UMD::CmDevice *&device);
1969
1970 //!
1971 //! \brief Initialize cm hal ddi interfaces
1972 //! \details Initialize cm hal ddi interfaces
1973 //! \param cmState
1974 //! [in,out] the pointer to the cm state.
1975 //! \return MOS_STATUS
1976 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
1977 //!
1978 MOS_STATUS (*pfnInitCmInterface)(
1979 PCM_HAL_STATE cmState);
1980
1981 //!
1982 //! \brief Create MhwCpInterface Object
1983 //! Must use Delete_MhwCpInterface to delete created Object to avoid ULT Memory Leak errors
1984 //!
1985 //! \return Return CP Wrapper Object if CPLIB not loaded
1986 //!
1987 MhwCpInterface* (*pfnCreateMhwCpInterface)(PMOS_INTERFACE osInterface);
1988
1989 //!
1990 //! \brief Delete the MhwCpInterface Object
1991 //!
1992 //! \param [in] *pMhwCpInterface
1993 //! MhwCpInterface
1994 //!
1995 void (*pfnDeleteMhwCpInterface)(MhwCpInterface *mhwCpInterface);
1996
1997 //!
1998 //! \brief Create CodechalSecureDeocde Object
1999 //! Must use Delete_CodechalSecureDecodeInterface to delete created Object to avoid ULT Memory Leak errors
2000 //!
2001 //! \return Return CP Wrapper Object
2002 //!
2003 CodechalSecureDecodeInterface* (*pfnCreateSecureDecodeInterface)(
2004 CodechalSetting *codechalSettings,
2005 CodechalHwInterface *hwInterfaceInput);
2006
2007 //!
2008 //! \brief Delete the CodecHalSecureDecode Object
2009 //!
2010 //! \param [in] *codechalSecureDecodeInterface
2011 //! CodechalSecureDecodeInterface
2012 //!
2013 void (*pfnDeleteSecureDecodeInterface)(CodechalSecureDecodeInterface *codechalSecureDecodeInterface);
2014
2015 #if (_DEBUG || _RELEASE_INTERNAL)
2016 //!
2017 //! \brief gpuCtxCreateOption Init for media Scalability
2018 //! \details
2019 //! \param PMOS_INTERFACE pOsInterface
2020 //! [in] Pointer to OS interface structure
2021 //! \param uint8_t id
2022 //! [out] EngineLogicId
2023 //! \return MOS_STATUS
2024 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
2025 //!
2026 MOS_STATUS (*pfnGetEngineLogicId)(
2027 PMOS_INTERFACE pOsInterface,
2028 uint8_t& id);
2029 #endif
2030 //!
2031 //! \brief Is Device Async or not
2032 //! \details Is Device Async or not.
2033 //!
2034 //! \param PMOS_INTERFACE pOsInterface
2035 //! [in] OS Interface
2036 //!
2037 //! \return bool
2038 //! Return true if is async, otherwise false
2039 //!
2040 bool (*pfnIsAsynDevice)(
2041 PMOS_INTERFACE osInterface);
2042
2043 //!
2044 //! \brief Get User Setting instance
2045 //!
2046 //! \param PMOS_INTERFACE pOsInterface
2047 //! [in] OS Interface
2048 //! \return MediaUserSettingSharedPtr
2049 //!
2050 MediaUserSettingSharedPtr (*pfnGetUserSettingInstance)(
2051 PMOS_INTERFACE pOsInterface);
2052
2053 bool (*pfnInsertCacheSetting)(CACHE_COMPONENTS id, std::map<uint64_t, MOS_CACHE_ELEMENT> *cacheTablesPtr);
2054
2055 bool (*pfnGetCacheSetting)(MOS_COMPONENT id, uint32_t feature, bool bOut, ENGINE_TYPE engineType, MOS_CACHE_ELEMENT &element, bool isHeapSurf);
2056
2057 // Virtual Engine related
2058 int32_t bSupportVirtualEngine; //!< Enable virtual engine flag
2059 int32_t bUseHwSemaForResSyncInVE; //!< Flag to indicate if UMD need to send HW sema cmd under this OS when there is a resource sync need with Virtual Engine interface
2060 PMOS_VIRTUALENGINE_INTERFACE pVEInterf;
2061 bool ctxBasedScheduling; //!< Flag to indicate if context based scheduling enabled for virtual engine, that is VE2.0.
2062 bool multiNodeScaling; //!< Flag to indicate if multi-node scaling is enabled for virtual engine, that is VE3.0.
2063 bool veDefaultEnable = true; //!< Flag to indicate if virtual engine is enabled by default
2064 bool phasedSubmission = false; //!< Flag to indicate if secondary command buffers are submitted together (Win) or separately (Linux)
2065 bool frameSplit = true; //!< Flag to indicate if frame split is enabled
2066 bool bSetHandleInvalid = false;
2067 bool bParallelSubmission = false; //!< Flag to indicate if parallel submission is enabled
2068 MOS_CMD_BUF_ATTRI_VE bufAttriVe[MOS_GPU_CONTEXT_MAX];
2069
2070 MOS_STATUS (*pfnCheckVirtualEngineSupported)(
2071 PMOS_INTERFACE pOsInterface);
2072
2073 #if MOS_MEDIASOLO_SUPPORTED
2074 int32_t bSupportMediaSoloVirtualEngine; //!< Flag to indicate if MediaSolo uses VE solution in cmdbuffer submission.
2075 #endif // MOS_MEDIASOLO_SUPPORTED
2076 bool VEEnable;
2077 bool bCanEnableSecureRt;
2078
2079 int32_t bHcpDecScalabilityMode; //!< enable scalability decode {mode: default, user force, false}
2080 #if (_DEBUG || _RELEASE_INTERNAL)
2081 MOS_FORCE_VEBOX eForceVebox; //!< Force select Vebox
2082 int32_t bEnableDbgOvrdInVE; //!< It is for all scalable engines: used together with KMD VE for UMD to specify an engine directly
2083 int32_t bSoftReset; //!< trigger soft reset
2084 #endif // (_DEBUG || _RELEASE_INTERNAL)
2085 bool streamStateIniter = false;
2086
2087 int32_t bVeboxScalabilityMode; //!< Enable scalability vebox
2088
2089 bool bOptimizeCpuTiming; //!< Optimize Cpu Timing
2090
2091 bool bNullHwIsEnabled; //!< Null Hw is enabled or not
2092
2093 //!< os interface extension
2094 void *pOsExt;
2095 } MOS_INTERFACE;
2096
2097 #ifdef __cplusplus
2098 extern "C" {
2099 #endif
2100
2101 //! \brief Unified OS Initializes OS Interface
2102 //! \details OS Interface initilization
2103 //! \param PMOS_INTERFACE pOsInterface
2104 //! [in/out] Pointer to OS Interface
2105 //! \param MOS_CONTEXT_HANDLE pOsDriverContext
2106 //! [in] Pointer to Driver context
2107 //! \param MOS_COMPONENT component
2108 //! [in] OS component
2109 //! \return MOS_STATUS
2110 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2111 //!
2112 MOS_STATUS Mos_InitOsInterface(
2113 PMOS_INTERFACE pOsInterface,
2114 MOS_CONTEXT_HANDLE pOsDriverContext,
2115 MOS_COMPONENT component);
2116
2117 //! \brief Destroy the mos interface
2118 //! \details MOS Interface release
2119 //! \param PMOS_INTERFACE pOsInterface
2120 //! [in/out] Pointer to OS Interface
2121 //! \return MOS_STATUS
2122 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2123 //!
2124 MOS_STATUS Mos_DestroyInterface(PMOS_INTERFACE pOsInterface);
2125
2126 //! \brief Unified OS add command to command buffer
2127 //! \details Offset returned is dword aligned but size requested can be byte aligned
2128 //! \param PMOS_COMMAND_BUFFER pCmdBuffer
2129 //! [in/out] Pointer to Command Buffer
2130 //! \param void *pCmd
2131 //! [in] Command Pointer
2132 //! \param uint32_t dwCmdSize
2133 //! [in] Size of command in bytes
2134 //! \return MOS_STATUS
2135 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2136 //!
2137 MOS_STATUS Mos_AddCommand(
2138 PMOS_COMMAND_BUFFER pCmdBuffer,
2139 const void *pCmd,
2140 uint32_t dwCmdSize);
2141
2142 //! \brief Unified OS get uf path info
2143 //! \details return a pointer to the user feature key path info
2144 //! \param PMOS_CONTEXT mosContext
2145 //! [in/out] Pointer to mosContext
2146 //! \return MOS_USER_FEATURE_KEY_PATH_INFO*
2147 //! Return a poniter to user feature path info
2148 //!
2149 MOS_USER_FEATURE_KEY_PATH_INFO *Mos_GetDeviceUfPathInfo(
2150 PMOS_CONTEXT mosContext);
2151
2152
2153 #if !EMUL
2154 //!
2155 //! \brief Get memory object based on resource usage
2156 //! \details Get memory object based on resource usage
2157 //! \param MOS_HW_RESOURCE_DEF MosUsage
2158 //! [in] Current usage for resource
2159 //! [in] Gmm client context
2160 //! \return MEMORY_OBJECT_CONTROL_STATE
2161 //! Populated memory object
2162 //!
2163 MEMORY_OBJECT_CONTROL_STATE Mos_CachePolicyGetMemoryObject(
2164 MOS_HW_RESOURCE_DEF MosUsage,
2165 GMM_CLIENT_CONTEXT *pGmmClientContext);
2166
2167 #endif
2168
2169 #ifdef __cplusplus
2170 }
2171 #endif
2172
2173 typedef struct _MOS_GPUCTX_CREATOPTIONS_ENHANCED MOS_GPUCTX_CREATOPTIONS_ENHANCED, *PMOS_GPUCTX_CREATOPTIONS_ENHANCED;
2174 struct _MOS_GPUCTX_CREATOPTIONS_ENHANCED : public _MOS_GPUCTX_CREATOPTIONS
2175 {
2176 union
2177 {
2178 struct
2179 {
2180 uint32_t UsingSFC : 1;
2181 uint32_t Reserved1 : 1; // remove HWRestrictedEngine
2182 #if (_DEBUG || _RELEASE_INTERNAL)
2183 uint32_t Reserved : 29;
2184 uint32_t DebugOverride : 1; // Debug & validation usage only
2185 #else
2186 uint32_t Reserved : 30;
2187 #endif
2188 };
2189 uint32_t Flags;
2190 };
2191
2192 uint32_t LRCACount;
2193
2194 #if (_DEBUG || _RELEASE_INTERNAL)
2195 // Logical engine instances used by this context; valid only if flag DebugOverride is set.
2196 uint8_t EngineInstance[MOS_MAX_ENGINE_INSTANCE_PER_CLASS];
2197 #endif
2198
_MOS_GPUCTX_CREATOPTIONS_ENHANCED_MOS_GPUCTX_CREATOPTIONS_ENHANCED2199 _MOS_GPUCTX_CREATOPTIONS_ENHANCED()
2200 : Flags(0),
2201 LRCACount(0)
2202 {
2203 #if (_DEBUG || _RELEASE_INTERNAL)
2204 for (auto i = 0; i < MOS_MAX_ENGINE_INSTANCE_PER_CLASS; i++)
2205 {
2206 EngineInstance[i] = MOS_INVALID_ENGINE_INSTANCE;
2207 }
2208 #endif
2209 }
2210
_MOS_GPUCTX_CREATOPTIONS_ENHANCED_MOS_GPUCTX_CREATOPTIONS_ENHANCED2211 _MOS_GPUCTX_CREATOPTIONS_ENHANCED(_MOS_GPUCTX_CREATOPTIONS* createOption)
2212 : _MOS_GPUCTX_CREATOPTIONS(createOption)
2213 {
2214 if (typeid(*createOption) == typeid(_MOS_GPUCTX_CREATOPTIONS_ENHANCED))
2215 {
2216 Flags = ((MOS_GPUCTX_CREATOPTIONS_ENHANCED *)createOption)->Flags;
2217 LRCACount = ((MOS_GPUCTX_CREATOPTIONS_ENHANCED *)createOption)->LRCACount;
2218 #if (_DEBUG || _RELEASE_INTERNAL)
2219 for (auto i = 0; i < MOS_MAX_ENGINE_INSTANCE_PER_CLASS; i++)
2220 {
2221 EngineInstance[i] = ((MOS_GPUCTX_CREATOPTIONS_ENHANCED *)createOption)->EngineInstance[i];
2222 }
2223 #endif
2224 }
2225 else
2226 {
2227 Flags = 0;
2228 LRCACount = 0;
2229 #if (_DEBUG || _RELEASE_INTERNAL)
2230 for (auto i = 0; i < MOS_MAX_ENGINE_INSTANCE_PER_CLASS; i++)
2231 {
2232 EngineInstance[i] = MOS_INVALID_ENGINE_INSTANCE;
2233 }
2234 #endif
2235 }
2236 }
2237
2238 };
2239
2240 #define MOS_VE_SUPPORTED(pOsInterface) \
2241 (pOsInterface ? pOsInterface->bSupportVirtualEngine : false)
2242
2243 #define MOS_VE_CTXBASEDSCHEDULING_SUPPORTED(pOsInterface) \
2244 (pOsInterface ? pOsInterface->ctxBasedScheduling : false)
2245
2246 #define MOS_VE_MULTINODESCALING_SUPPORTED(pOsInterface) \
2247 (pOsInterface ? pOsInterface->multiNodeScaling : false)
2248
2249 #if MOS_MEDIASOLO_SUPPORTED
2250 #define MOS_MEDIASOLO_VE_SUPPORTED(pOsInterface) \
2251 (pOsInterface ? pOsInterface->bSupportMediaSoloVirtualEngine : false)
2252 #endif
2253
Mos_SetVirtualEngineSupported(PMOS_INTERFACE pOsInterface,bool bEnabled)2254 __inline void Mos_SetVirtualEngineSupported(PMOS_INTERFACE pOsInterface, bool bEnabled)
2255 {
2256 if (pOsInterface && pOsInterface->veDefaultEnable)
2257 {
2258 pOsInterface->bSupportVirtualEngine = bEnabled;
2259 }
2260 }
2261
2262 //!
2263 //! \brief Check whether the parameter of mos surface is valid for copy
2264 //!
2265 //! \param [in] mosSurface
2266 //! Pointer to MosSurface
2267 //!
2268 //! \return bool
2269 //! Whether the paramter of mosSurface is valid
2270 //!
2271 MOS_STATUS Mos_VerifyMosSurface(
2272 PMOS_SURFACE mosSurface,
2273 bool &bIsValid);
2274
2275 //!
2276 //! \brief Check virtual engine is supported
2277 //! \details Check virtual engine is supported
2278 //! \param PMOS_INTERFACE pOsInterface
2279 //! [in] OS Interface
2280 //! \return MOS_STATUS
2281 //! MOS_STATUS_SUCCESS if succeeded, otherwise error code
2282 //!
2283 MOS_STATUS Mos_CheckVirtualEngineSupported(
2284 PMOS_INTERFACE osInterface,
2285 bool isDecode,
2286 bool veDefaultEnable);
2287
2288 //!
2289 //! \brief Retrieve the CachePolicyMemoryObject for a resource
2290 //! \details Retrieve the CachePolicyMemoryObject for a resource
2291 //! \param PMOS_INTERFACE osInterface
2292 //! [in] OS Interface
2293 //! \param PMOS_RESOURCE resource
2294 //! [in] resource
2295 //! \return MEMORY_OBJECT_CONTROL_STATE
2296 //! return a value of MEMORY_OBJECT_CONTROL_STATE
2297 //!
2298 MEMORY_OBJECT_CONTROL_STATE Mos_GetResourceCachePolicyMemoryObject(
2299 PMOS_INTERFACE osInterface,
2300 PMOS_RESOURCE resource);
2301
2302 //!
2303 //! \brief Is Device Async or not
2304 //! \details Is Device Async or not.
2305 //! \param [in] streamState
2306 //! Handle of Os Stream State.
2307 //! \return bool
2308 //! Return true if is async, otherwise false
2309 //!
2310 bool Mos_IsAsyncDevice(
2311 MOS_STREAM_HANDLE streamState);
2312
2313 //!
2314 //! \brief Mos format to os format
2315 //! \details Mos format to os format
2316 //! \param [in] format
2317 //! Mos format.
2318 //! \return uint32_t
2319 //! Return OS FORMAT
2320 //!
2321 uint32_t Mos_MosFmtToOsFmt(
2322 MOS_FORMAT format);
2323
2324 //!
2325 //! \brief Os format to Mos format
2326 //! \details Os format to Mos format
2327 //! \param [in] format
2328 //! Os format.
2329 //! \return MOS_FORMAT
2330 //! Return MOS FORMAT
2331 //!
2332 MOS_FORMAT Mos_OsFmtToMosFmt(
2333 uint32_t format);
2334
2335 //!
2336 //! \brief Mos format to GMM format
2337 //! \details Mos format to GMM format
2338 //! \param [in] format
2339 //! Mos format.
2340 //! \return GMM_RESOURCE_FORMAT
2341 //! Return GMM FORMAT
2342 //!
2343 GMM_RESOURCE_FORMAT Mos_MosFmtToGmmFmt(
2344 MOS_FORMAT format);
2345
2346 //!
2347 //! \brief GMM format to mos format
2348 //! \details GMM format to mos format
2349 //! \param [in] format
2350 //! GMM_RESOURCE_FORMAT.
2351 //! \return MOS_FORMAT
2352 //! Return MOS FORMAT
2353 //!
2354 MOS_FORMAT Mos_GmmFmtToMosFmt(
2355 GMM_RESOURCE_FORMAT format);
2356
2357 //!
2358 //! \brief Wait For cmd Completion
2359 //! \details [GPU Context Interface] Waiting for the completion of cmd in provided GPU context
2360 //! \details Caller: HAL only
2361 //! \param [in] streamState
2362 //! Handle of Os Stream State
2363 //! \param [in] gpuCtx
2364 //! GpuContext handle of the gpu context to wait cmd completion
2365 //! \return MOS_STATUS
2366 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2367 //!
2368 MOS_STATUS Mos_WaitForCmdCompletion(
2369 MOS_STREAM_HANDLE streamState,
2370 GPU_CONTEXT_HANDLE gpuCtx);
2371
2372 //!
2373 //! \brief Get Resource array index
2374 //! \details Returns the array index
2375 //! \param PMOS_RESOURCE
2376 //! [in] Pointer to MOS_RESOURCE
2377 //! \return uint32_t - array index
2378 //!
2379 uint32_t Mos_GetResourceArrayIndex(
2380 PMOS_RESOURCE resource);
2381
2382 //!
2383 //! \brief Setup VE Attribute Buffer
2384 //! \details [Cmd Buffer Interface] Setup VE Attribute Buffer into cmd buffer.
2385 //! \details Caller: MHW only
2386 //! \details This interface is called to setup into cmd buffer.
2387 //! \param [in] streamState
2388 //! Handle of Os Stream State
2389 //! \param [out] cmdBuffer
2390 //! Cmd buffer to setup VE attribute.
2391 //! \return MOS_STATUS
2392 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2393 //!
2394 MOS_STATUS Mos_SetupAttributeVeBuffer(
2395 MOS_STREAM_HANDLE streamState,
2396 COMMAND_BUFFER_HANDLE cmdBuffer);
2397
2398 //!
2399 //! \brief Get VE Attribute Buffer
2400 //! \details [Cmd Buffer Interface] Get VE Attribute Buffer from cmd buffer.
2401 //! \details Caller: HAL only
2402 //! \details This interface is called to get VE attribute buffer from cmd buffer if it contains one.
2403 //! If there is no VE attribute buffer returned, it means the cmd buffer has no such buffer
2404 //! in current MOS module. It is not error state if it is nullptr.
2405 //! \param [out] cmdBuffer
2406 //! Cmd buffer to setup VE attribute.
2407 //! \return MOS_CMD_BUF_ATTRI_VE*
2408 //! Return pointer of VE attribute buffer, nullptr if current cmdBuffer didn't contain attribute.
2409 //!
2410 MOS_CMD_BUF_ATTRI_VE *Mos_GetAttributeVeBuffer(
2411 COMMAND_BUFFER_HANDLE cmdBuffer);
2412
2413 //!
2414 //! \brief Setup commandlist and command pool from os interface
2415 //! \details Set the commandlist and commandPool used in this stream from os interface.
2416 //! \param [in] osInterface
2417 //! pointer to the mos interface
2418 //! \param [out] streamState
2419 //! Handle of Os Stream State.
2420 //! \return MOS_STATUS
2421 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2422 //!
2423 MOS_STATUS Mos_SetupCurrentCmdListAndPool(
2424 PMOS_INTERFACE osInterface,
2425 MOS_STREAM_HANDLE streamState);
2426
2427 //!
2428 //! \brief Get MOS_HW_RESOURCE_DEF
2429 //! \details [Resource Interface] Get Mos HW Resource DEF
2430 //! Caller: HAL & MHW
2431 //! \param [in] gmmResUsage
2432 //! Gmm Resource usage as index
2433 //! \return MOS_HW_RESOURCE_DEF
2434 //! Mos HW resource definition
2435 //!
2436 MOS_HW_RESOURCE_DEF Mos_GmmToMosResourceUsageType(
2437 GMM_RESOURCE_USAGE_TYPE gmmResUsage);
2438
2439 //!
2440 //! \brief Get Adapter Info
2441 //! \details [System info Interface] Get Adapter Info
2442 //! \details Caller: DDI & HAL
2443 //! \details This func is called to differentiate the behavior according to Adapter Info.
2444 //! \param [in] streamState
2445 //! Handle of Os Stream State
2446 //! \return ADAPTER_INFO*
2447 //! Read-only Adapter Info got, nullptr if failed to get
2448 //!
2449 ADAPTER_INFO *Mos_GetAdapterInfo(
2450 MOS_STREAM_HANDLE streamState);
2451
2452 //!
2453 //! \brief Surface compression is supported
2454 //! \details Surface compression is supported
2455 //! \param [in] skuTable
2456 //! Pointer to MEDIA_FEATURE_TABLE
2457 //! \return bool
2458 //! If true, compression is enabled
2459 //!
2460 bool Mos_IsCompressibelSurfaceSupported(
2461 MEDIA_FEATURE_TABLE *skuTable);
2462
2463 //!
2464 //! \brief Destroy Virtual Engine State
2465 //! \details [Virtual Engine Interface] Destroy Virtual Engine State of provided streamState
2466 //! \details Caller: Hal (Scalability) only
2467 //! \details This func is called when a stream (Hal instance) need to destroy a VE state
2468 //! \details into provided stream.
2469 //! \param [in] streamState
2470 //! Handle of Os Stream State
2471 //! \return MOS_STATUS
2472 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
2473 //!
2474 MOS_STATUS Mos_DestroyVirtualEngineState(
2475 MOS_STREAM_HANDLE streamState);
2476
2477 //!
2478 //! \brief Get resource handle
2479 //! \details Get resource handle
2480 //! \param [in] streamState
2481 //! Handle of Os Stream State
2482 //! \param [in] osResource
2483 //! Pointer to mos resource
2484 //! \return uint64_t
2485 //! Return resource handle
2486 //!
2487 uint64_t Mos_GetResourceHandle(
2488 MOS_STREAM_HANDLE streamState,
2489 PMOS_RESOURCE osResource);
2490
2491 //!
2492 //! \brief Get RT log resource info
2493 //! \details Get RT log resource info
2494 //! \param [in] streamState
2495 //! Handle of Os Stream State
2496 //! \param [in,out] osResource
2497 //! Reference to pointer of mos resource
2498 //! \param [in,out] size
2499 //! Reference to size
2500 //! \return void
2501 //!
2502 void Mos_GetRtLogResourceInfo(
2503 PMOS_INTERFACE osInterface,
2504 PMOS_RESOURCE &osResource,
2505 uint32_t &size);
2506
2507 //!
2508 //! \brief OS reset resource
2509 //! \details Resets the OS resource
2510 //! \param PMOS_RESOURCE resource
2511 //! [in] Pointer to OS Resource
2512 //! \return void
2513 //! Return NONE
2514 //!
2515 void Mos_ResetMosResource(
2516 PMOS_RESOURCE resource);
2517
2518
2519 bool Mos_InsertCacheSetting(CACHE_COMPONENTS id, std::map<uint64_t, MOS_CACHE_ELEMENT> *cacheTablesPtr);
2520
2521 bool Mos_GetCacheSetting(MOS_COMPONENT id, uint32_t feature, bool bOut, ENGINE_TYPE engineType, MOS_CACHE_ELEMENT &element, bool isHeapSurf);
2522
2523 #if (_DEBUG || _RELEASE_INTERNAL)
2524 //!
2525 //! \brief Get engine count
2526 //! \details [Virtual Engine Interface] Get engine count from Virtual Engine State in provided stream
2527 //! \details Caller: Hal (Scalability) only
2528 //! \details Get engine count from virtual engine state
2529 //! \param [in] streamState
2530 //! Handle of Os Stream State
2531 //! \return uint8_t
2532 //! Engine count
2533 //!
2534 uint8_t Mos_GetVeEngineCount(
2535 MOS_STREAM_HANDLE streamState);
2536
2537 //!
2538 //! \brief Get Engine Logic Id
2539 //! \details [Virtual Engine Interface] Get engine Logic Id from Virtual Engine State in provided stream
2540 //! \details Caller: Hal (Scalability) only
2541 //! \details Get engine Logic Id from virtual engine state
2542 //! \param [in] streamState
2543 //! Handle of Os Stream State
2544 //! \param [in] instanceIdx
2545 //! Engine instance index
2546 //! \return uint8_t
2547 //!
2548 uint8_t Mos_GetEngineLogicId(
2549 MOS_STREAM_HANDLE streamState,
2550 uint32_t instanceIdx);
2551
2552 //!
2553 //! \brief Set Gpu Virtual Address for Debug
2554 //! \details Manually make page fault
2555 //!
2556 //! \param [in] pResource
2557 //! Resource to set Gpu Address
2558 //! \param [in] address
2559 //! Address to set
2560 //! \return MOS_STATUS
2561 //!
2562 MOS_STATUS MOS_SetGpuVirtualAddress(
2563 PMOS_RESOURCE pResource,
2564 uint64_t address);
2565
2566 #endif
2567
2568 struct ContextRequirement
2569 {
2570 bool IsEnc = false;
2571 bool IsPak = false;
2572 bool IsContextSwitchBack = false;
2573 };
2574
2575 #endif // __MOS_OS_H__
2576