1 /* 2 * Copyright (c) 2014-2020, 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 mhw_state_heap.h 24 //! \brief This modules implements HW interface layer to be used on all platforms on all operating systems/DDIs, across MHW components. 25 //! 26 #ifndef __MHW_STATE_HEAP_H__ 27 #define __MHW_STATE_HEAP_H__ 28 29 #include "mos_os.h" 30 #include "mhw_utilities.h" 31 #include "heap_manager.h" 32 33 typedef struct _MHW_STATE_HEAP_MEMORY_BLOCK MHW_STATE_HEAP_MEMORY_BLOCK, *PMHW_STATE_HEAP_MEMORY_BLOCK; 34 typedef struct _MHW_STATE_HEAP_INTERFACE MHW_STATE_HEAP_INTERFACE, *PMHW_STATE_HEAP_INTERFACE; 35 typedef class XMHW_STATE_HEAP_INTERFACE *PXMHW_STATE_HEAP_INTERFACE; 36 typedef struct _MHW_STATE_HEAP MHW_STATE_HEAP, *PMHW_STATE_HEAP; 37 typedef struct MHW_BLOCK_MANAGER *PMHW_BLOCK_MANAGER; 38 39 #define MHW_INDIRECT_HEAP_SIZE MHW_PAGE_SIZE 40 #define MHW_SURFACE_PITCH_ALIGNMENT 128 41 #define MHW_MAX_SURFACE_PLANES 3 42 43 #define MHW_NUM_HW_POLYPHASE_TABLES 17 44 #define MHW_NUM_HW_POLYPHASE_EXTRA_TABLES_G9 15 45 46 //! 47 //! \brief GSH Defaults and limits 48 //! 49 #define MHW_MEDIA_STATE_ALIGN 128 50 #define MHW_SCRATCH_SPACE_ALIGN 1024 51 #define MHW_SAMPLER_STATE_ALIGN 64 52 #define MHW_SAMPLER_STATE_VA_ALIGN 32 53 #define MHW_SAMPLER_STATE_AVS_ALIGN 1024 54 #define MHW_SAMPLER_STATE_AVS_ALIGN_G9 2048 55 56 #define MHW_SAMPLER_STATE_AVS_ALIGN_MEDIA 1024 // per old HWCMD files AVS samplers were aligned to 256. Not sure if this is needed 57 #define MHW_SURFACE_STATE_ALIGN 64 // (1 << MHW_BINDING_TABLE_OFFSET_SHIFT) 58 59 #define MHW_MEDIA_OBJECT_BYTE_SIZE 24 60 61 // Each increment in sampler index represents this increment in offset 62 #define MHW_SAMPLER_STATE_VA_INC 32 63 #define MHW_SAMPLER_STATE_CONV_1D_INC 128 64 #define MHW_AVS_SAMPLER_WIDTH_ALIGN_UNIT 2 65 #define MHW_SAMPLER_STATE_AVS_INC_LEGACY 512 66 #define MHW_AVS_SAMPLER_HEIGHT_ALIGN_UNIT 2 67 #define MHW_SAMPLER_STATE_CONV_INC_LEGACY 512 68 69 #define MHW_SAMPLER_WIDTH_ALIGN_UNIT 2 70 #define MHW_SAMPLER_HEIGHT_ALIGN_UNIT 4 71 72 #define MHW_INVALID_BINDING_TABLE_IDX 0xFFFFFFFF 73 74 #define MHW_ASSERT_INVALID_BINDING_TABLE_IDX(index) \ 75 { \ 76 if ((index) == MHW_INVALID_BINDING_TABLE_IDX) \ 77 { \ 78 MHW_ASSERTMESSAGE("Invalid (nullptr) Pointer."); \ 79 eStatus = MOS_STATUS_UNKNOWN; \ 80 return eStatus; \ 81 } \ 82 } 83 84 #define MHW_INVALID_SYNC_TAG 0xFFFFFFFF 85 86 enum MW_RENDER_ENGINE_ADDRESS_SHIFT 87 { 88 MHW_STATE_HEAP_SURFACE_STATE_SHIFT = 0 89 }; 90 91 typedef enum _MHW_STATE_HEAP_PARAM_SHIFTS 92 { 93 MHW_SLM_SHIFT = 2, 94 MHW_BINDING_TABLE_OFFSET_SHIFT = 6, 95 MHW_BINDING_TABLE_ID_SHIFT = 5, 96 MHW_SAMPLER_SHIFT = 5, 97 MHW_CURBE_SHIFT = 5, 98 MHW_THRD_CON_DATA_RD_SHIFT = 5, 99 MHW_KERNEL_OFFSET_SHIFT = 6, 100 MHW_SAMPLER_INDIRECT_SHIFT = 6, 101 MHW_SCRATCH_SPACE_SHIFT = 10, 102 MHW_SSH_BASE_SHIFT = 12, 103 MHW_COMPUTE_INDIRECT_SHIFT = 6 104 } MHW_STATE_HEAP_PARAM_SHIFTS; 105 106 typedef enum _MHW_FRAME_FIELD_TYPE 107 { 108 MHW_FRAME = 0, 109 MHW_TOP_FIELD, 110 MHW_BOTTOM_FIELD, 111 MHW_NUM_FRAME_FIELD_TYPES, 112 } MHW_FRAME_FIELD_TYPE; 113 114 typedef enum _MHW_STATE_HEAP_TYPE 115 { 116 MHW_ISH_TYPE = 0, 117 MHW_DSH_TYPE, 118 MHW_SSH_TYPE //!< Note SSH is currently managed by MOS 119 } MHW_STATE_HEAP_TYPE; 120 121 typedef enum _MHW_STATE_HEAP_MODE 122 { 123 MHW_RENDER_HAL_MODE = 0, //!< 0 - RenderHal handles 124 MHW_DSH_MODE, //!< 1 - MDF dynamic heap management 125 MHW_DGSH_MODE //!< 2 - Ddynamic generic heap management 126 }MHW_STATE_HEAP_MODE; 127 128 typedef enum _MHW_PLANE 129 { 130 MHW_GENERIC_PLANE = 0, // 1D Surface: MHW_GENERIC_PLANE, 2D Surface: MHW_Y_PLANE 131 MHW_Y_PLANE = 0, 132 MHW_U_PLANE, 133 MHW_V_PLANE, 134 } MHW_PLANE; 135 136 //! 137 //! \brief MHW Rotation Mode enum 138 //! 139 typedef enum _MHW_ROTATION 140 { 141 MHW_ROTATION_IDENTITY = 0, //!< Rotation 0 degrees 142 MHW_ROTATION_90, //!< Rotation 90 degrees 143 MHW_ROTATION_180, //!< Rotation 180 degrees 144 MHW_ROTATION_270, //!< Rotation 270 degrees 145 MHW_MIRROR_HORIZONTAL, //!< Horizontal Mirror 146 MHW_MIRROR_VERTICAL, //!< Vertical Mirror 147 MHW_ROTATE_90_MIRROR_VERTICAL, //!< 90 + V Mirror 148 MHW_ROTATE_90_MIRROR_HORIZONTAL //!< 90 + H Mirror 149 } MHW_ROTATION; 150 151 //! 152 //! \brief Render chroma siting vertical value 153 //! 154 typedef enum _MHW_CHROMA_SITING_VDIRECTION 155 { 156 MHW_CHROMA_SITING_VDIRECTION_0 = 0x0, 157 MHW_CHROMA_SITING_VDIRECTION_1_4 = 0x1, 158 MHW_CHROMA_SITING_VDIRECTION_1_2 = 0x2, 159 MHW_CHROMA_SITING_VDIRECTION_3_4 = 0x3, 160 MHW_CHROMA_SITING_VDIRECTION_1 = 0x4 161 } MHW_CHROMA_SITING_VDIRECTION; 162 163 //! 164 //! \brief Chroma Siting enum 165 //! 166 typedef enum _MHW_CHROMA_SITING 167 { 168 MHW_CHROMA_SITING_NONE = 0, 169 MHW_CHROMA_SITING_HORZ_LEFT = 1 << 0, 170 MHW_CHROMA_SITING_HORZ_CENTER = 1 << 1, 171 MHW_CHROMA_SITING_HORZ_RIGHT = 1 << 2, 172 MHW_CHROMA_SITING_VERT_TOP = 1 << 4, 173 MHW_CHROMA_SITING_VERT_CENTER = 1 << 5, 174 MHW_CHROMA_SITING_VERT_BOTTOM = 1 << 6, 175 } MHW_CHROMA_SITING; 176 177 //! 178 //! \brief Scaling mode enum 179 //! 180 typedef enum _MHW_SCALING_MODE 181 { 182 MHW_SCALING_NEAREST = 0, 183 MHW_SCALING_BILINEAR, 184 MHW_SCALING_AVS 185 } MHW_SCALING_MODE; 186 187 //! 188 //! \brief AVS Params 189 //! 190 typedef struct _MHW_AVS_PARAMS 191 { 192 MOS_FORMAT Format; 193 float fScaleX; 194 float fScaleY; 195 int32_t *piYCoefsX; 196 int32_t *piYCoefsY; 197 int32_t *piUVCoefsX; 198 int32_t *piUVCoefsY; 199 bool bForcePolyPhaseCoefs; 200 bool bUse8x8Filter; 201 } MHW_AVS_PARAMS, *PMHW_AVS_PARAMS; 202 203 // Memory block state 204 typedef enum _MHW_BLOCK_STATE 205 { 206 MHW_BLOCK_STATE_POOL = 0, //!< Block belongs to the pool of memory block objects, it doesn't point to a valid memory block, most fields may be invalid. 207 MHW_BLOCK_STATE_FREE, //!< Block points to available memory in State Heap 208 MHW_BLOCK_STATE_ALLOCATED, //!< Block points to allocated area in State Heap (allocated but not in use by GPU) 209 MHW_BLOCK_STATE_SUBMITTED, //!< Block points to area in State Heap that was submitted for execution by GPU; memory cannot be overwritten or deleted before workload is finished. 210 MHW_BLOCK_STATE_DELETED, //!< Block is marked for deletion (State Heap is being deleted). 211 212 MHW_BLOCK_STATE_COUNT = 5 213 } MHW_BLOCK_STATE; 214 215 struct _MHW_STATE_HEAP_MEMORY_BLOCK 216 { 217 //! 218 //! \brief The sync tag ID for the memory block may be used to determine 219 //! whether or not the memory block is in use--if the ID is 220 //! invalid (+1 to the defined maximum number of sync tags), the 221 //! memory block is not in use and some or all of it may be used 222 //! for a new kernel state region. 223 //! 224 FrameTrackerTokenFlat trackerToken; 225 226 uint32_t dwBlockSize; 227 PMHW_STATE_HEAP pStateHeap; 228 uint32_t dwOffsetInStateHeap; 229 bool bStatic; //!< The kernel state region in this state heap is static and will not be removed during cleanup step. 230 231 _MHW_STATE_HEAP_MEMORY_BLOCK *pPrev; 232 _MHW_STATE_HEAP_MEMORY_BLOCK *pNext; 233 234 //! 235 //! \brief The following code is for the MHW dynamic state heap implementation by MDF. 236 //! Code is not yet unified across all media driver components 237 //! 238 MHW_BLOCK_STATE BlockState: 16; //!< Current block state (void, free, allocated, in use, completed, deleted) 239 uint32_t bDelete : 1; //!< Block is flagged for deletion upon completion 240 uint32_t Reserved : 15; //!< Reserved (uniq block ID used for tracking block utilization by system) 241 242 PMHW_STATE_HEAP_MEMORY_BLOCK pHeapNext; //!< Next block in same state heap (adjacent), null if last 243 PMHW_STATE_HEAP_MEMORY_BLOCK pHeapPrev; //!< Previous block in same state heap (adjacent), null if first 244 245 uint8_t *pDataPtr; //!< Pointer to aligned data 246 uint32_t dwDataOffset; //!< Offset of pDataPtr (from State Heap Base - used in state programming) 247 uint32_t dwDataSize; //!< Data size (>= requested size due to heap granularity) 248 uint32_t dwAlignment; //!< Offset alignment (offset from actual block start) 249 }; 250 251 typedef struct _MHW_KERNEL_PARAM 252 { 253 void *pExtra; //!< Kernel parameter 254 uint8_t *pBinary; //!< Pointer to kernel binary 255 int32_t iSize; //!< Kernel size 256 int32_t iGrfCount; //!< Number of registers 257 int32_t iBTCount; //!< Number of BT entries 258 int32_t iThreadCount; //!< Number of threads (max) 259 int32_t iGrfStartRegister; //!< Start register 260 int32_t iSamplerCount; //!< Sampler count 261 int32_t iSamplerLength; //!< Sampler length 262 int32_t iCurbeLength; //!< Constant URB length 263 int32_t iIdCount; //!< Num IDs used by kernel state 264 int32_t iInlineDataLength; //!< MEDIA_OBJECT inline data (aka URB length) 265 int32_t iBlockWidth; //!< Block width 266 int32_t iBlockHeight; //!< Block height 267 268 //! 269 //! \brief Dynamic kernel parameters may follow below if necessary. 270 //! 271 int32_t bLoaded; //!< Kernel Loaded flag 272 int32_t iKID; //!< Interface descriptor ID for the kernel 273 int32_t iKUID; //!< Kernel Unique ID 274 int32_t iKCID; //!< Kernel Cache ID 275 int32_t iAKBaseID; //!< Authenticated Kernel Base ID 276 277 bool bForceReload; //!< The flag to indicate if the kernel need to be reloaded forcibly 278 279 } MHW_KERNEL_PARAM, *PMHW_KERNEL_PARAM; 280 281 typedef struct MHW_KERNEL_STATE 282 { MHW_KERNEL_STATEMHW_KERNEL_STATE283 MHW_KERNEL_STATE() 284 { 285 m_dshRegion = MemoryBlock(); 286 m_ishRegion = MemoryBlock(); 287 } 288 ~MHW_KERNEL_STATEMHW_KERNEL_STATE289 virtual ~MHW_KERNEL_STATE() { MHW_FUNCTION_ENTER; } 290 //! 291 //! \brief Set when the kernel state is created 292 //! 293 MHW_KERNEL_PARAM KernelParams = {}; //!< Kernel parameters 294 295 //! 296 //! \brief Set when the kernel state region for the kernel state 297 //! is acquired. 298 //! Note: For state heaps other than the SSH it is possible to 299 //! make a kernel state region static, such that it belongs 300 //! to the kernel state and it is not necessary to acquire a 301 //! kernel state region for the DSH/ISH (whichever is 302 //! static). 303 //! 304 uint32_t dwSshOffset = 0; //!< Offset within SSH to the kernel state region 305 uint32_t dwBindingTableSize = 0; //!< The size of the binding table for this kernel state 306 uint32_t dwSshSize = 0; //!< Size of the kernel state region in the SSH 307 uint32_t dwIdOffset = 0; //!< Offset within DSH to ID(s) in kernel state region 308 uint32_t dwCurbeOffset = 0; //!< Offset within DSH to CURBE(s) in kernel state region 309 uint32_t dwSamplerOffset = 0; //!< Offset within DSH to Sampler(s) in kernel state region 310 uint32_t dwKernelBinaryOffset = 0; //!< Offset within ISH to the kernel state region 311 312 //! 313 //! \brief Descriptors of the DSH/ISH kernel state regions. Since there 314 //! may be multiple DSH/ISH buffers, it is necessary to store 315 //! which one is used. If one of the regions is static, the memory 316 //! block pointer is always expected to be valid. 317 //! 318 MemoryBlock m_dshRegion; 319 MemoryBlock m_ishRegion; 320 321 uint32_t m_currTrackerId = MemoryBlock::m_invalidTrackerId; //!< tracker ID for the current execution 322 } *PMHW_KERNEL_STATE; 323 324 typedef struct _MHW_BINDING_TABLE_PARAMS { 325 uint8_t *pBindingTableEntry; // Pointer to BT entry to setup 326 uint32_t dwSurfaceStateOffset; // Offset to Surface State (Indirect State) 327 bool bSurfaceStateAvs; // true if AVS surface 328 int32_t iBindingTableEntry; // Binding Table entry index 329 } MHW_BINDING_TABLE_PARAMS, *PMHW_BINDING_TABLE_PARAMS; 330 331 typedef struct _MHW_BINDING_TABLE_SEND_PARAMS { 332 uint8_t *pBindingTableSource; // Pointer to BT source 333 uint8_t *pBindingTableTarget; // Pointer to BT target 334 int32_t iSurfaceStateBase; // Offset to first Surface State in SSH 335 int32_t iSurfaceStateOffset; // [out] Offset to Surface State in SSH 336 int32_t iSurfaceState; // [out] Surface State index (-1 if Copy==0) 337 } MHW_BINDING_TABLE_SEND_PARAMS, *PMHW_BINDING_TABLE_SEND_PARAMS; 338 339 typedef struct _MHW_SURFACE_STATE_PARAMS { 340 uint8_t *pSurfaceState; 341 uint32_t dwCacheabilityControl; 342 uint32_t dwFormat; 343 uint32_t dwWidth; 344 uint32_t dwHeight; 345 uint32_t dwDepth; 346 uint32_t dwPitch; 347 uint32_t dwQPitch; 348 uint32_t bUseAdvState : 1; 349 uint32_t AddressControl : 1; 350 uint32_t SurfaceType3D : 3; 351 uint32_t bTiledSurface : 1; 352 uint32_t bTileWalk : 1; 353 uint32_t bVerticalLineStride : 1; 354 uint32_t bVerticalLineStrideOffset : 1; 355 uint32_t bCompressionEnabled : 1; 356 uint32_t bCompressionMode : 1; 357 uint32_t MmcState : 3; 358 uint32_t bInterleaveChroma : 1; 359 uint32_t bHalfPitchChroma : 1; 360 uint32_t bSeperateUVPlane : 1; 361 uint32_t UVPixelOffsetUDirection : 2; 362 uint32_t UVPixelOffsetVDirection : 2; 363 uint32_t RotationMode : 3; 364 uint32_t bSurfaceArraySpacing : 1; 365 uint32_t bBoardColorOGL : 1; 366 int32_t iXOffset; 367 int32_t iYOffset; 368 uint32_t dwXOffsetForU; // U or UV 369 uint32_t dwYOffsetForU; // U or UV 370 uint32_t dwXOffsetForV; 371 uint32_t dwYOffsetForV; 372 uint32_t dwCompressionFormat; // Memory Compression Format 373 uint32_t L1CacheConfig; 374 375 uint32_t *pdwCmd; // [out] Pointer for patching 376 uint32_t dwLocationInCmd; // [out] Offset in command for patching 377 MOS_TILE_MODE_GMM TileModeGMM; // Tile Type from GMM Definition 378 bool bGMMTileEnabled; //!< GMM defined tile mode flag 379 } MHW_SURFACE_STATE_PARAMS, *PMHW_SURFACE_STATE_PARAMS; 380 381 struct _MHW_STATE_HEAP 382 { 383 MOS_RESOURCE resHeap; //!< Graphics resource for state heap 384 void *pvLockedHeap; //!< System (logical) address for state heap 385 bool bKeepLocked; 386 uint32_t dwSize; //!< Size of the state heap 387 388 uint32_t dwUsed; //!< Used memory in state heap 389 uint32_t dwFree; //!< Free memory in state heap 390 bool bDeleted; //!< State heap is in process of being deleted 391 392 // State heap object points to its interface object and block manager 393 PMHW_BLOCK_MANAGER pBlockManager; 394 PXMHW_STATE_HEAP_INTERFACE pMhwStateHeapInterface; 395 396 //! 397 //! \brief The memory blocks will be managed in a linked list, each state 398 //! heap will have one linked list starting with pMemoryHead. The 399 //! memory blocks in this list will describe all available and 400 //! used space in the state heap. 401 //! 402 PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryHead; 403 404 PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryTail; //!< Last block in state heap memory (used to traverse pMemNext/pMemPrev) 405 PMHW_STATE_HEAP_MEMORY_BLOCK pDebugKernel; //!< Block associated to debug (SIP) kernel in the current ISH 406 PMHW_STATE_HEAP_MEMORY_BLOCK pScratchSpace; //!< Block associated with current active scratch space (older scratch spaces are removed) 407 uint32_t dwScratchSpace; //!< Active scratch space size 408 409 PMHW_STATE_HEAP pPrev; //!< The first state heap is considered primary (pPrev == nullptr) 410 PMHW_STATE_HEAP pNext; 411 412 uint32_t dwCurrOffset; //!< For simulated SSH to denote the current amount of space used 413 }; 414 415 typedef struct _MHW_SYNC_TAG 416 { 417 uint32_t dwCmdBufId; //!< Command buffer ID for this sync tag, 0 is available 418 uint32_t dwSshSizeUsed; 419 420 //! 421 //! \brief Memory blocks used during the clean up step. 422 //! 423 PMHW_STATE_HEAP_MEMORY_BLOCK pDshRegion; //!< Memory block for DSH 424 PMHW_STATE_HEAP_MEMORY_BLOCK pIshRegion; //!< Memory block for ISH 425 } MHW_SYNC_TAG, *PMHW_SYNC_TAG; 426 427 typedef struct _MHW_INTERFACE_DESCRIPTOR_PARAMS 428 { 429 PMHW_KERNEL_STATE pKernelState; 430 uint32_t dwKernelStartOffset; //!< Offset relative to the kernel state region binary start offset in the ISH 431 uint32_t dwIdIdx; //!< Index within the ID block of the kernel state region in the DSH of the ID to be added 432 uint32_t dwBtOffset; //!< Offset relative to SSH base of the BT start 433 uint32_t dwSamplerOffset; //!< Offset within the Sampler block of the kernel state region for the current sampler state 434 } MHW_INTERFACE_DESCRIPTOR_PARAMS, *PMHW_INTERFACE_DESCRIPTOR_PARAMS; 435 436 // Structure used to program media interface descriptor entry 437 typedef struct _MHW_ID_ENTRY_PARAMS 438 { 439 uint32_t dwMediaIdOffset; //! Offset of the first Media Interface Descriptor (in DSH) 440 uint32_t iMediaId; //! Media Interface Descriptor # 441 uint32_t dwKernelOffset; //! Kernel offset (in ISH) 442 uint32_t dwSamplerOffset; //! Sampler offset (in DSH) 443 uint32_t dwSamplerCount; //! Sample count 444 uint32_t dwBindingTableOffset; //! Binding table offset (in DSH) 445 uint32_t iCurbeOffset; //! Curbe offset (in DSH) 446 uint32_t iCurbeLength; //! Curbe lenght 447 bool bBarrierEnable; //! Enable Barrier 448 bool bGlobalBarrierEnable; //! Enable Global Barrier (SKL+) 449 uint32_t dwNumberofThreadsInGPGPUGroup; //! Number of threads per group 450 uint32_t dwSharedLocalMemorySize; //! Size of SharedLocalMemory (SLM) 451 int32_t iCrsThdConDataRdLn; //! 452 PMHW_STATE_HEAP pGeneralStateHeap; //! General state heap in use 453 MemoryBlock *memoryBlock; //! Memory block associated with the state heap 454 uint32_t preferredSlmAllocationSize; //! SLM Allocation Size for per SubSlice 455 } MHW_ID_ENTRY_PARAMS, *PMHW_ID_ENTRY_PARAMS; 456 457 typedef struct _MHW_PLANE_SETTING 458 { 459 uint8_t ui8PlaneID; // Plane identifier 460 uint8_t ui8ScaleWidth; // X Scale (divider) 461 uint8_t ui8ScaleHeight; // Y Scale (divider) 462 uint8_t ui8AlignWidth; // X Alignment 463 uint8_t ui8AlignHeight; // Y Alignment 464 uint8_t ui8PixelsPerDword; // Pixels per Dword (for dataport read/write) 465 bool bAdvanced; // Advanced Surface State 466 uint32_t dwFormat; // Hardware Surface Format 467 } MHW_PLANE_SETTING, *PMHW_PLANE_SETTING; 468 469 typedef struct _MHW_SURFACE_PLANES 470 { 471 uint32_t dwNumPlanes; // Number of planes 472 MHW_PLANE_SETTING Plane[MHW_MAX_SURFACE_PLANES]; // Description of each plane 473 } MHW_SURFACE_PLANES, *PMHW_SURFACE_PLANES; 474 475 typedef const _MHW_PLANE_SETTING *PCMHW_PLANE_SETTING; 476 typedef const _MHW_SURFACE_PLANES *PCMHW_SURFACE_PLANES; 477 478 typedef struct _MHW_RCS_SURFACE_PARAMS 479 { 480 PMOS_SURFACE psSurface; 481 482 uint32_t bUseAdvState; //!< Indicates that SURFACE_STATE_ADV should be used 483 484 uint32_t dwNumPlanes; //!< Indicates the number of valid binding table offsets included 485 uint32_t dwPlaneType[MHW_MAX_SURFACE_PLANES]; //!< Indicates the plane type 486 uint32_t dwBindingTableOffset[MHW_MAX_SURFACE_PLANES]; //!< Binding table offset for all planes included in surface 487 uint32_t dwCacheabilityControl; 488 bool bRenderTarget; 489 bool bIsWritable; 490 491 uint32_t dwWidthToUse[MHW_MAX_SURFACE_PLANES]; //!< If non-zero, overrides value in psSurface 492 uint32_t dwHeightToUse[MHW_MAX_SURFACE_PLANES]; //!< If non-zero, overrides value in psSurface 493 uint32_t dwPitchToUse[MHW_MAX_SURFACE_PLANES]; //!< If non-zero, overrides value in psSurface 494 uint32_t dwBaseAddrOffset[MHW_MAX_SURFACE_PLANES]; 495 uint32_t dwYOffset[MHW_MAX_SURFACE_PLANES]; 496 uint32_t dwXOffset[MHW_MAX_SURFACE_PLANES]; 497 uint32_t ForceSurfaceFormat[MHW_MAX_SURFACE_PLANES]; //!< Of type GFX3DSTATE_SURFACEFORMAT 498 uint32_t dwSurfaceType; //!< of type GFX3DSTATE_SURFACETYPE 499 500 uint32_t bVertLineStride; 501 uint32_t bVertLineStrideOffs; 502 uint32_t bInterleaveChroma; 503 504 uint32_t dwAddressControl; 505 MHW_CHROMA_SITING_VDIRECTION Direction; 506 MHW_ROTATION Rotation; //!< 0: 0 degree, 1: 90 degree, 2: 180 degree, 3: 270 degree 507 uint32_t MediaBoundaryPixelMode; //!< Of type GFX3DSTATE_MEDIA_BOUNDARY_PIXEL_MODE 508 uint32_t dwOffsetInSSH; 509 } MHW_RCS_SURFACE_PARAMS, *PMHW_RCS_SURFACE_PARAMS; 510 511 typedef struct _MHW_SURFACE_TOKEN_PARAMS 512 { 513 PMOS_SURFACE pOsSurface; 514 uint32_t dwSurfaceOffset; 515 uint32_t YUVPlane : 2; 516 uint32_t bRenderTarget : 1; 517 uint32_t : 1; 518 uint32_t bSurfaceTypeAvs : 1; 519 uint32_t : 26; 520 } MHW_SURFACE_TOKEN_PARAMS, *PMHW_SURFACE_TOKEN_PARAMS; 521 522 //! 523 //! \brief Sampler Type 524 //! 525 typedef enum _MHW_SAMPLER_TYPE 526 { 527 MHW_SAMPLER_TYPE_INVALID = 0, 528 MHW_SAMPLER_NONE , 529 MHW_SAMPLER_TYPE_3D , // UNORM 530 MHW_SAMPLER_TYPE_AVS , // AVS (Avanced Video Sampler = 8x8, STE, IEF) 531 MHW_SAMPLER_TYPE_VME , // VME 532 MHW_SAMPLER_TYPE_MISC , // MISC 533 MHW_SAMPLER_TYPE_MINMAX , 534 MHW_SAMPLER_TYPE_ERODE , 535 MHW_SAMPLER_TYPE_DILATE , 536 MHW_SAMPLER_TYPE_CONV // CONVOLUTION (Gen8+) 537 } MHW_SAMPLER_TYPE, *PMHW_SAMPLER_TYPE; 538 539 typedef enum _MHW_SAMPLER_ELEMENTS_TYPE : unsigned int 540 { 541 MHW_Sampler1Element = 0, 542 MHW_Sampler2Elements, 543 MHW_Sampler4Elements, 544 MHW_Sampler8Elements, 545 MHW_Sampler64Elements, 546 MHW_Sampler128Elements, 547 548 MHW_SamplerTotalElements 549 }MHW_SAMPLER_ELEMENT_TYPE, *PMHW_SAMPLER_ELEMENT_TYPE; 550 551 //! 552 //! \brief Sampler Tap Mode 553 //! 554 typedef enum _MHW_SAMPLER_TAP_MODE 555 { 556 MHW_SAMPLER_FILTER_4_TAP = 0, 557 MHW_SAMPLER_FILTER_8_4_TAP, 558 MHW_SAMPLER_FILTER_8_TAP, 559 MHW_SAMPLER_FILTER_8_TAP_ADATIVE 560 } MHW_SAMPLER_TAP_MODE, *PMHW_SAMPLER_TAP_MODE; 561 562 //! 563 //! \brief Sampler Filter Mode 564 //! 565 typedef enum _MHW_SAMPLER_FILTER_MODE 566 { 567 MHW_SAMPLER_FILTER_CUSTOM = 0, 568 MHW_SAMPLER_FILTER_NEAREST, 569 MHW_SAMPLER_FILTER_BILINEAR 570 } MHW_SAMPLER_FILTER_MODE, *PMHW_SAMPLER_FILTER_MODE; 571 572 typedef enum _MHW_SAMPLER_TEXTADDR 573 { 574 MHW_SAMPLER_TEXTADDR_WRAP, 575 MHW_SAMPLER_TEXTADDR_MIRROR, 576 MHW_SAMPLER_TEXTADDR_CLAMP, 577 MHW_SAMPLER_TEXTADDR_CUBE, 578 MHW_SAMPLER_TEXTADDR_CLAMPBORDER, 579 MHW_SAMPLER_TEXTADDR_MIRROR_ONCE 580 } MHW_SAMPLER_TEXTADDR; 581 582 typedef struct _MHW_AVS_COEFFICIENT_PARAM 583 { 584 int8_t ZeroXFilterCoefficient[8]; 585 int8_t ZeroYFilterCoefficient[8]; 586 int8_t OneXFilterCoefficient[4]; //!< [0..3] maps to filter coefficients [2..5], in actual tabel [0..1] are reserved 587 int8_t OneYFilterCoefficient[4]; //!< [0..3] maps to filter coefficients [2..5], in actual tabel [0..1] are reserved 588 } MHW_AVS_COEFFICIENT_PARAM, *PMHW_AVS_COEFFICIENT_PARAM; 589 590 typedef struct _MHW_SAMPLER_AVS_TABLE_PARAM 591 { 592 MHW_AVS_COEFFICIENT_PARAM paMhwAvsCoeffParam[MHW_NUM_HW_POLYPHASE_TABLES]; 593 594 // sampler table control 595 uint8_t byteTransitionArea8Pixels; //!< only least 3-bits used 596 uint8_t byteTransitionArea4Pixels; //!< only least 3-bits used 597 uint8_t byteMaxDerivative8Pixels; 598 uint8_t byteMaxDerivative4Pixels; 599 uint8_t byteDefaultSharpnessLevel; 600 601 bool bEnableRGBAdaptive; 602 bool bAdaptiveFilterAllChannels; 603 bool bBypassYAdaptiveFiltering; 604 bool bBypassXAdaptiveFiltering; 605 606 bool b8TapAdaptiveEnable; 607 bool b4TapGY; 608 bool b4TapRBUV; 609 610 bool bIsCoeffExtraEnabled; 611 MHW_AVS_COEFFICIENT_PARAM paMhwAvsCoeffParamExtra[MHW_NUM_HW_POLYPHASE_EXTRA_TABLES_G9]; // only for gen9+ 612 613 } MHW_SAMPLER_AVS_TABLE_PARAM, *PMHW_SAMPLER_AVS_TABLE_PARAM; 614 615 //! 616 //! \brief Sampler States for 8x8 sampler 617 //! 618 typedef struct _MHW_SAMPLER_STATE_AVS_PARAM 619 { 620 int16_t stateID; 621 622 // STE params 623 bool bEnableSTDE; // a.k.a SkinToneTunedIEF 624 bool b8TapAdaptiveEnable; 625 bool bSkinDetailFactor; 626 bool bHdcDwEnable; // Gen9+ 627 bool bWritebackStandard; // set Writeback same as Original Sample_8x8 628 629 // IEF params 630 bool bEnableIEF; 631 uint16_t wIEFFactor; // 0 will disable IEF 632 uint16_t wR3xCoefficient; 633 uint16_t wR3cCoefficient; 634 uint16_t wR5xCoefficient; 635 uint16_t wR5cxCoefficient; 636 uint16_t wR5cCoefficient; 637 638 // AVS params 639 bool bEnableAVS; 640 bool AvsType; // 0 - Polyphase; 1 - nearest 641 bool EightTapAFEnable; 642 bool BypassIEF; // ignored for BWL, moved to sampler8x8 payload. 643 uint16_t GainFactor; 644 uint8_t GlobalNoiseEstm; 645 uint8_t StrongEdgeThr; 646 uint8_t WeakEdgeThr; 647 uint8_t StrongEdgeWght; 648 uint8_t RegularWght; 649 uint8_t NonEdgeWght; 650 bool b8TapLumaForYUV444; 651 652 // Additional overrides 653 uint16_t AdditionalOverridesUsed; 654 uint16_t YSlope2; 655 uint16_t S0L; 656 uint16_t YSlope1; 657 uint16_t S2U; 658 uint16_t S1U; 659 660 PMHW_SAMPLER_AVS_TABLE_PARAM pMhwSamplerAvsTableParam; // pointer to AVS scaling 8x8 table params 661 662 int32_t iTable8x8_Index; // Table allocation index (not needed on Gen8+) 663 void *pTable8x8_Ptr; // Table data ptr in GSH 664 uint32_t dwTable8x8_Offset; // Table data offset in GSH 665 } MHW_SAMPLER_STATE_AVS_PARAM, *PMHW_SAMPLER_STATE_AVS_PARAM; 666 667 //! 668 //! \brief Structure to handle UNORM sampler states 669 //! 670 typedef enum _MHW_SAMPLER_SURFACE_PIXEL_TYPE 671 { 672 MHW_SAMPLER_SURFACE_PIXEL_UINT, 673 MHW_SAMPLER_SURFACE_PIXEL_SINT, 674 MHW_SAMPLER_SURFACE_PIXEL_OTHER 675 } MHW_SAMPLER_SURFACE_PIXEL_TYPE; 676 677 typedef enum _MHW_GFX3DSTATE_MAPFILTER 678 { 679 MHW_GFX3DSTATE_MAPFILTER_NEAREST = 0x0, 680 MHW_GFX3DSTATE_MAPFILTER_LINEAR = 0x1, 681 MHW_GFX3DSTATE_MAPFILTER_ANISOTROPIC = 0x2, 682 MHW_GFX3DSTATE_MAPFILTER_FLEXIBLE = 0x3, 683 MHW_GFX3DSTATE_MAPFILTER_MONO = 0x6 684 } MHW_GFX3DSTATE_MAPFILTER; 685 686 typedef enum _MHW_GFX3DSTATE_TEXCOORDMODE 687 { 688 MHW_GFX3DSTATE_TEXCOORDMODE_WRAP = 0, 689 MHW_GFX3DSTATE_TEXCOORDMODE_MIRROR = 1, 690 MHW_GFX3DSTATE_TEXCOORDMODE_CLAMP = 2, 691 MHW_GFX3DSTATE_TEXCOORDMODE_CUBE = 3, 692 MHW_GFX3DSTATE_TEXCOORDMODE_CLAMP_BORDER = 4, 693 MHW_GFX3DSTATE_TEXCOORDMODE_MIRROR_ONCE = 5 694 } MHW_GFX3DSTATE_TEXCOORDMODE; 695 696 typedef enum _MHW_CHROMAKEY_MODE 697 { 698 MHW_CHROMAKEY_MODE_KILL_ON_ANY_MATCH = 0, 699 MHW_CHROMAKEY_MODE_REPLACE_BLACK = 1 700 } MHW_CHROMAKEY_MODE; 701 702 typedef struct _MHW_INLINE_DATA_PARAMS 703 { 704 uint32_t dwOffset; 705 uint32_t dwSize; 706 PMOS_RESOURCE resource; 707 bool isPtrType; 708 } MHW_INLINE_DATA_PARAMS, *PMHW_INLINE_DATA_PARAMS; 709 710 typedef struct _MHW_SAMPLER_STATE_UNORM_PARAM 711 { 712 MHW_SAMPLER_FILTER_MODE SamplerFilterMode; 713 MHW_GFX3DSTATE_MAPFILTER MagFilter; 714 MHW_GFX3DSTATE_MAPFILTER MinFilter; 715 MHW_GFX3DSTATE_TEXCOORDMODE AddressU; 716 MHW_GFX3DSTATE_TEXCOORDMODE AddressV; 717 MHW_GFX3DSTATE_TEXCOORDMODE AddressW; 718 719 MHW_SAMPLER_SURFACE_PIXEL_TYPE SurfaceFormat; 720 union { 721 uint32_t BorderColorRedU; 722 int32_t BorderColorRedS; 723 float BorderColorRedF; 724 }; 725 726 union { 727 uint32_t BorderColorGreenU; 728 int32_t BorderColorGreenS; 729 float BorderColorGreenF; 730 }; 731 732 union { 733 uint32_t BorderColorBlueU; 734 int32_t BorderColorBlueS; 735 float BorderColorBlueF; 736 }; 737 738 union { 739 uint32_t BorderColorAlphaU; 740 int32_t BorderColorAlphaS; 741 float BorderColorAlphaF; 742 }; 743 744 uint32_t IndirectStateOffset; 745 void *pIndirectState; 746 bool bBorderColorIsValid; 747 748 bool bChromaKeyEnable; 749 uint32_t ChromaKeyIndex; 750 MHW_CHROMAKEY_MODE ChromaKeyMode; 751 } MHW_SAMPLER_STATE_UNORM_PARAM, *PMHW_SAMPLER_STATE_UNORM_PARAM; 752 753 //! 754 //! \brief Structure to capture sizes of HW engine commands and structures 755 //! 756 typedef struct _MHW_RENDER_STATE_SIZES 757 { 758 uint32_t dwSizeMediaObjectHeaderCmd; // Size of Media Object Header Command 759 uint32_t dwMaxSizeSurfaceState; // Max size of a surface state 760 uint32_t dwSizeSurfaceState; // Size of surface state 761 uint32_t dwSizeSurfaceStateAvs; // Size of AVS surface state 762 uint32_t dwSizeBindingTableState; // Size of binding table state entry 763 uint32_t dwSizeSamplerState; // Size of sampler state (unorm) 764 uint32_t dwSizeSamplerIndirectState; // Size of sampler indirect state (unorm) 765 uint32_t dwSizeSamplerStateAvs; // Size of sampler state (Avs) 766 uint32_t dwSizeSamplerStateVA; // Size of sampler state (va) 767 uint32_t dwSizeSamplerStateVAConvolve; // Size of sampler state (va convolve) 768 uint32_t dwSizeSamplerStateTable8x8; // Size of sampler state 8x8 table 769 uint32_t dwSizeSampler8x8Table; // Size of sampler 8x8 table 770 uint32_t dwSizeInterfaceDescriptor; // Size of interface descriptor 771 uint32_t dwSizeMediaWalkerBlock; // Size of Media Walker block 772 } MHW_RENDER_STATE_SIZES, *PMHW_RENDER_STATE_SIZES; 773 774 //! 775 //! \brief Structure to handle VME Sampler State 776 //! 777 typedef struct _MHW_SAMPLER_STATE_VME_PARAM 778 { 779 uint32_t *pdwLUTSearchPath; 780 uint32_t *pdwLUTMbMode; 781 uint32_t *pdwLUTMv; 782 } MHW_SAMPLER_STATE_VME_PARAM, *PMHW_SAMPLER_STATE_VME_PARAM; 783 784 typedef struct _MHW_SAMPLER_CONVOLVE_COEFF_TABLE 785 { 786 uint16_t wFilterCoeff[16]; 787 } MHW_SAMPLER_CONVOLVE_COEFF_TABLE; 788 789 typedef struct _MHW_SAMPLER_STATE_CONVOLVE_PARAM 790 { 791 uint8_t ui8ConvolveType; // 1d, 2d 792 uint8_t ui8Height; 793 uint8_t ui8Width; 794 uint8_t ui8ScaledDownValue; 795 uint8_t ui8SizeOfTheCoefficient; 796 uint8_t ui8MSBHeight; 797 uint8_t ui8MSBWidth; 798 bool skl_mode; 799 MHW_SAMPLER_CONVOLVE_COEFF_TABLE CoeffTable[62]; 800 } MHW_SAMPLER_STATE_CONVOLVE_PARAM, *PMHW_SAMPLER_STATE_CONVOLVE_PARAM; 801 802 typedef struct _MHW_SAMPLER_8x8_MISC_STATE { 803 uint8_t byteHeight; 804 uint8_t byteWidth; 805 uint16_t wRow[15]; 806 } MHW_SAMPLER_8x8_MISC_STATE, *PMHW_SAMPLER_8x8_MISC_STATE; 807 808 //! 809 //! \brief Structure to handle Sampler State 810 //! 811 typedef struct _MHW_SAMPLER_STATE_PARAM 812 { 813 bool bInUse; 814 PMHW_KERNEL_STATE pKernelState; 815 MHW_SAMPLER_TYPE SamplerType; 816 MHW_SAMPLER_ELEMENT_TYPE ElementType; 817 union 818 { 819 MHW_SAMPLER_STATE_UNORM_PARAM Unorm; 820 MHW_SAMPLER_STATE_AVS_PARAM Avs; 821 MHW_SAMPLER_STATE_VME_PARAM Vme; 822 MHW_SAMPLER_STATE_CONVOLVE_PARAM Convolve; 823 MHW_SAMPLER_8x8_MISC_STATE Misc; 824 }; 825 } MHW_SAMPLER_STATE_PARAM, *PMHW_SAMPLER_STATE_PARAM; 826 827 typedef struct _MHW_SURFACE_STATE_SEND_PARAMS { 828 uint8_t *pIndirectStateBase; 829 uint8_t *pSurfaceStateSource; 830 uint8_t *pSurfaceToken; 831 int32_t iIndirectStateBase; 832 int32_t iSurfaceStateOffset; 833 bool bNeedNullPatch; 834 } MHW_SURFACE_STATE_SEND_PARAMS, *PMHW_SURFACE_STATE_SEND_PARAMS; 835 836 struct MHW_STATE_HEAP_SETTINGS 837 { MHW_STATE_HEAP_SETTINGSMHW_STATE_HEAP_SETTINGS838 MHW_STATE_HEAP_SETTINGS() {} 839 ~MHW_STATE_HEAP_SETTINGSMHW_STATE_HEAP_SETTINGS840 virtual ~MHW_STATE_HEAP_SETTINGS() {} 841 842 uint32_t dwIshSize = 0; //!< Initial size of ISH 843 uint32_t dwDshSize = 0; //!< Initial size of DSH 844 uint32_t dwIshIncrement = 0; //!< ISH increment step 845 uint32_t dwDshIncrement = 0; //!< DSH increment step 846 uint32_t dwIshMaxSize = 0; //!< ISH max size 847 uint32_t dwDshMaxSize = 0; //!< DSH max size 848 849 bool m_keepIshLocked = false; //!< Keep ISH locked always 850 bool m_keepDshLocked = false; //!< Keep DSH locked always 851 852 HeapManager::Behavior m_ishBehavior = HeapManager::Behavior::wait; //!< ISH behavior 853 HeapManager::Behavior m_dshBehavior = HeapManager::Behavior::wait; //!< DSH behavior 854 855 uint32_t dwNumSyncTags = 0; //!< to be removed with old interfaces 856 MOS_HW_RESOURCE_DEF m_heapUsageType = MOS_CODEC_RESOURCE_USAGE_BEGIN_CODEC; 857 }; 858 859 typedef struct _MHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS 860 { 861 int32_t *piSizes; //<! [in] array of block sizes to allocate 862 int32_t iCount; //<! [in] number of blocks to allocate 863 uint32_t dwAlignment; //<! [in] block alignment 864 bool bHeapAffinity; //<! [in] true if all blocks must be allocated in the same heap; false otherwize 865 PMHW_STATE_HEAP pHeapAffinity; //<! [in] Select a specific heap to allocate (nullptr if don't care) 866 uint32_t dwScratchSpace; //<! [in/out] Scratch space requested, scratch space allocated in same heap as the block 867 PMHW_STATE_HEAP_MEMORY_BLOCK pScratchSpace; //<! [out] Pointer to scratch space block used - needed for command buffer setup 868 bool bZeroAssignedMem; //<! [in] Zero memory blocks after allocation 869 bool bStatic; //<! [in] Block allocations are flaged as static 870 bool bGrow; //<! [in] Allow state heap to grow in order to satisfy the request 871 } MHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS, *PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS; 872 873 typedef MOS_STATUS ( *pfnAddResourceToCmd) (PMOS_INTERFACE , PMOS_COMMAND_BUFFER ,PMHW_RESOURCE_PARAMS); 874 875 class XMHW_STATE_HEAP_INTERFACE 876 { 877 public: 878 static const uint32_t m_mhwBindingTableOffsetShift = 6; 879 static const uint32_t m_mhwBindingTableSurfaceShift = 6; 880 static const uint32_t m_mhwGenericOffsetShift = 6; 881 static const uint32_t m_mhwBindingTableOffsetAlignment = (1 << m_mhwBindingTableOffsetShift); 882 static const uint32_t m_mhwNumBindingTableEntryOffset = (m_mhwBindingTableOffsetAlignment/4); 883 884 protected: 885 HeapManager m_ishManager; 886 HeapManager m_dshManager; 887 std::vector<MemoryBlock> m_blocks; 888 std::vector<uint32_t> m_blockSizes; 889 890 private: 891 MEDIA_WA_TABLE *m_pWaTable; 892 MHW_STATE_HEAP_SETTINGS m_StateHeapSettings; 893 894 // old heap management 895 MOS_RESOURCE m_resCmdBufIdGlobal; 896 uint32_t *m_pdwCmdBufIdGlobal; 897 uint32_t m_dwCurrCmdBufId; 898 PMHW_SYNC_TAG m_pSyncTags; 899 uint32_t m_dwCurrSyncTag; 900 uint32_t m_dwInvalidSyncTagId; //!< Passed in at creation by the client 901 bool m_bRegisteredBBCompleteNotifyEvent; 902 PMHW_STATE_HEAP m_pInstructionStateHeaps; 903 uint32_t m_dwNumIsh; 904 uint32_t m_dwNumDsh; 905 PMHW_STATE_HEAP m_pDynamicStateHeaps; 906 int8_t m_bDynamicMode; //!< To be deprecated, 0 - RenderHal handles, 1 - MDF heap management, 2 - generic hep 907 PMHW_BLOCK_MANAGER m_pIshBlockManager; //!< ISH block management object 908 PMHW_BLOCK_MANAGER m_pDshBlockManager; //!< DSH block management object 909 910 public: 911 PMOS_INTERFACE m_pOsInterface; 912 uint16_t m_wIdAlignment; 913 uint16_t m_wBtIdxAlignment; 914 uint16_t m_wCurbeAlignment; 915 uint16_t m_wSizeOfCmdSamplerState; 916 uint32_t m_dwMaxSurfaceStateSize; 917 pfnAddResourceToCmd m_pfnAddResourceToCmd; 918 MHW_STATE_HEAP m_SurfaceStateHeap; //!< Simulated SSH with MHW_STATE_HEAP. 919 uint16_t m_wSizeOfCmdInterfaceDescriptorData; 920 MHW_RENDER_STATE_SIZES m_HwSizes; 921 922 public: 923 //! 924 //! \brief Internal to MHW 925 //! 926 927 //! 928 //! \brief Constructor of the MI StateHeap interface 929 //! \details Internal MHW function to initialize all function pointers and some parameters 930 //! \param [in] pCpInterface 931 //! CP interface, must be valid 932 //! \param [in] pOsInterface 933 //! OS interface, must be valid 934 //! 935 XMHW_STATE_HEAP_INTERFACE(PMOS_INTERFACE pInputOSInterface, int8_t bDynamicMode=0); 936 937 XMHW_STATE_HEAP_INTERFACE(const XMHW_STATE_HEAP_INTERFACE&) = delete; 938 939 XMHW_STATE_HEAP_INTERFACE& operator=(const XMHW_STATE_HEAP_INTERFACE&) = delete; 940 941 virtual ~XMHW_STATE_HEAP_INTERFACE(); 942 GetDSHPointer()943 virtual PMHW_STATE_HEAP GetDSHPointer(){ return m_pDynamicStateHeaps; }; 944 GetISHPointer()945 virtual PMHW_STATE_HEAP GetISHPointer() { return m_pInstructionStateHeaps; }; 946 GetNumDsh()947 uint32_t GetNumDsh(){return m_dwNumDsh;}; 948 GetNumIsh()949 uint32_t GetNumIsh(){return m_dwNumIsh;}; 950 GetResCmdBufIdGlobal()951 PMOS_RESOURCE GetResCmdBufIdGlobal(){return &m_resCmdBufIdGlobal;}; 952 GetSycnTags()953 PMHW_SYNC_TAG GetSycnTags(){return m_pSyncTags;}; 954 GetIdAlignment()955 uint16_t GetIdAlignment(){return m_wIdAlignment;}; 956 GetSizeofCmdSampleState()957 uint16_t GetSizeofCmdSampleState(){return m_wSizeOfCmdSamplerState;}; 958 GetSizeofCmdInterfaceDescriptorData()959 uint16_t GetSizeofCmdInterfaceDescriptorData(){ return m_wSizeOfCmdInterfaceDescriptorData;}; 960 GetCurbeAlignment()961 uint16_t GetCurbeAlignment(){ return m_wCurbeAlignment;}; 962 GetBtIdxAlignment()963 uint16_t GetBtIdxAlignment(){ return m_wBtIdxAlignment;}; 964 GetCurrCmdBufId()965 uint32_t GetCurrCmdBufId(){ return m_dwCurrCmdBufId;}; 966 GetCmdBufIdGlobal()967 uint32_t GetCmdBufIdGlobal(){ return *m_pdwCmdBufIdGlobal;}; 968 GetCmdBufIdGlobalPointer()969 uint32_t *GetCmdBufIdGlobalPointer(){ return m_pdwCmdBufIdGlobal; }; 970 GetHwSizesPointer()971 PMHW_RENDER_STATE_SIZES GetHwSizesPointer() { return & m_HwSizes;}; 972 GetSizeofSamplerStateAvs()973 uint32_t GetSizeofSamplerStateAvs() { return m_HwSizes.dwSizeSamplerStateAvs;}; 974 GetDynamicMode()975 int8_t GetDynamicMode() { return m_bDynamicMode; } 976 977 //! 978 //! \brief Initializes the MI StateHeap interface 979 //! \details Internal MHW function to initialize all function pointers and some parameters 980 //! Assumes that the caller has checked pointer validity and whether or not an 981 //! addressing method has been selected in the OS interface (bUsesGfxAddress or 982 //! bUsesPatchList). 983 //! \param [in] StateHeapSettings 984 //! StateHeap setting passed from caller 985 //! \return MOS_STATUS 986 //! MOS_STATUS_SUCCESS if success else fail reason 987 MOS_STATUS InitializeInterface(MHW_STATE_HEAP_SETTINGS StateHeapSettings); 988 989 //! 990 //! \brief Assigns space in a state heap to a kernel state 991 //! \details Client facing function to assign as space in a state heap a kernel state; 992 //! if no space is available, a clean up is attempted 993 //! \param MHW_STATE_HEAP_TYPE StateHeapType 994 //! [in] The state heap type requested (ISH/DSH) 995 //! \param PMHW_KERNEL_STATE pKernelState 996 //! [in] Kernel state to which a state heap space will be assigned 997 //! \param uint32_t dwSpaceRequested 998 //! [in] The amount of space requested from the state heap 999 //! \param bool bStatic 1000 //! [in] Whether or not the space requested is static 1001 //! \param bool bZeroAssignedMem 1002 //! [in] Whether or not acquired memory should be zeroed 1003 //! \return MOS_STATUS 1004 //! MOS_STATUS_SUCCESS if success, MOS_STATUS_CLIENT_AR_NO_SPACE if no space 1005 //! is available but it is possible for the client to wait, else fail reason 1006 //! 1007 MOS_STATUS AssignSpaceInStateHeap( 1008 MHW_STATE_HEAP_TYPE StateHeapType, 1009 PMHW_KERNEL_STATE pKernelState, 1010 uint32_t dwSpaceRequested, 1011 bool bStatic, 1012 bool bZeroAssignedMem); 1013 1014 //! 1015 //! \brief Submits all non-static blocks in kernel state 1016 //! \param [in] pKernelState 1017 //! Kernel state containing all memory blocks to submit 1018 //! \return MOS_STATUS 1019 //! MOS_STATUS_SUCCESS if success 1020 //! 1021 MOS_STATUS SubmitBlocks(PMHW_KERNEL_STATE pKernelState); 1022 1023 //! 1024 //! \brief Locks requested state heap 1025 //! \details Client facing function to lock a state heap 1026 //! \param PMHW_STATE_HEAP pStateHeap 1027 //! [in] The state heap to be locked 1028 //! \return MOS_STATUS 1029 //! MOS_STATUS_SUCCESS if success 1030 //! 1031 MOS_STATUS LockStateHeap( 1032 PMHW_STATE_HEAP pStateHeap); 1033 1034 //! 1035 //! \brief Unlocks requested state heap 1036 //! \details Client facing function to unlock a state heap 1037 //! \param PMHW_STATE_HEAP pStateHeap 1038 //! [in] The state heap to be locked 1039 //! \return MOS_STATUS 1040 //! MOS_STATUS_SUCCESS if success 1041 //! 1042 MOS_STATUS UnLockStateHeap( 1043 PMHW_STATE_HEAP pStateHeap); 1044 1045 //! 1046 //! \brief Allocates a state heap of the requested type 1047 //! \details Client facing function to extend a state heap of the requested time, which 1048 //! involves allocating state heap and added it to the state heap liked list. 1049 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1050 //! [in] The state heap type requested (ISH/DSH) 1051 //! \param uint32_t dwSizeRequested 1052 //! [in] The size of the state heap 1053 //! \return MOS_STATUS 1054 //! MOS_STATUS_SUCCESS if success, else fail reason 1055 //! 1056 MOS_STATUS ExtendStateHeap( 1057 MHW_STATE_HEAP_TYPE StateHeapType, 1058 uint32_t dwSizeRequested); 1059 1060 //! 1061 //! \brief Update CmdBufIdGlobal 1062 //! \details Client facing function to update CmdBufIdGlobal 1063 //! reset current offset to zero 1064 //! \return MOS_STATUS 1065 //! MOS_STATUS_SUCCESS if success, else fail reason 1066 //! 1067 MOS_STATUS UpdateGlobalCmdBufId(); 1068 1069 //! 1070 //! \brief Set command buffer status pointer 1071 //! \details Client facing function to set command buffer status pointer 1072 //! \param void *pvCmdBufStatus 1073 //! [in] command buffer status pointer 1074 //! \return MOS_STATUS 1075 //! MOS_STATUS_SUCCESS if success, else fail reason 1076 //! 1077 MOS_STATUS SetCmdBufStatusPtr(void *pvCmdBufStatus); 1078 1079 //! 1080 //! \brief Calculate the space needed in the SSH 1081 //! \details Client facing function to calculate the space needed in the SSH 1082 //! given the number of binding table entries 1083 //! \param uint32_t dwBtEntriesRequested 1084 //! [in] Binding table entries requested in the SSH 1085 //! \param uint32_t *pdwSshSize 1086 //! [out] The size needed in the SSH 1087 //! \return MOS_STATUS 1088 //! MOS_STATUS_SUCCESS if success, else fail reason 1089 //! 1090 MOS_STATUS CalculateSshAndBtSizesRequested( 1091 uint32_t dwBtEntriesRequested, 1092 uint32_t *pdwSshSize, 1093 uint32_t *pdwBtSize); 1094 1095 //! 1096 //! \brief Request SSH space for a command buffer. 1097 //! \details Client facing function to request SSH space for a command buffer, if not enough 1098 //! space is available, more will be requested. 1099 //! \param uint32_t dwBtEntriesRequested 1100 //! [in] Binding table entries requested in the SSH 1101 //! \return MOS_STATUS 1102 //! MOS_STATUS_SUCCESS if success, else fail reason 1103 //! 1104 MOS_STATUS RequestSshSpaceForCmdBuf( 1105 uint32_t dwBtEntriesRequested); 1106 1107 //! 1108 //! \brief Calculates the amount of space needed 1109 //! \details Tells if there is enough space available in heap to load an array of blocks 1110 // Returns how much is missing (needs to be freed, 0 if none) 1111 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1112 //! [in] State heap type (DSH/ISH) 1113 //! \param PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS pParams 1114 //! [in] Dynamic state heap parameters 1115 //! \return uint32_t 1116 //! Amount of space needed in bytes 1117 //! 1118 uint32_t CalculateSpaceNeededDyn( 1119 MHW_STATE_HEAP_TYPE StateHeapType, 1120 PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS pParams); 1121 1122 //Virtual Interfaces 1123 1124 //! 1125 //! \brief Adds INTERFACE_DESCRIPTOR command(s) to the DSH 1126 //! \details Client facing function to add INTERFACE_DESCRIPTOR(s) to the DSH 1127 //! \param uint32_t dwNumIdsToSet 1128 //! [in] The number of pParams 1129 //! \param PMHW_INTERFACE_DESCRIPTOR_PARAMS pParams 1130 //! [in] Parameters used to set the INTERFACE_DESCRIPTOR(s) 1131 //! \return MOS_STATUS 1132 //! MOS_STATUS_SUCCESS if success, else fail reason 1133 //! 1134 virtual MOS_STATUS SetInterfaceDescriptor( 1135 uint32_t dwNumIdsToSet, 1136 PMHW_INTERFACE_DESCRIPTOR_PARAMS pParams) = 0; 1137 1138 //! 1139 //! \brief Setup Media Interface Descriptor Entry in DSH 1140 //! \details Setup Single Media Interface Descriptor Entry 1141 //! \param PMHW_ID_ENTRY_PARAMS pParams 1142 //! [in] Interface Descriptor Parameters 1143 //! \param PMOS_COMMAND_BUFFER pCmdBuffer 1144 //! [in] Pointer to Command Buffer 1145 //! \return MOS_STATUS 1146 //! 1147 virtual MOS_STATUS SetInterfaceDescriptorEntry( 1148 PMHW_ID_ENTRY_PARAMS pParams) = 0; 1149 1150 //! 1151 //! \brief Adds media interface descriptor data to dynamic GSH 1152 //! \param PMHW_ID_ENTRY_PARAMS pParams 1153 //! [in] Interface descriptor parameters 1154 //! \return MOS_STATUS 1155 //! 1156 virtual MOS_STATUS AddInterfaceDescriptorData( 1157 PMHW_ID_ENTRY_PARAMS pParams) = 0; 1158 1159 //! 1160 //! \brief Adds a binding table to the SSH 1161 //! \details Client facing function to add binding table to SSH 1162 //! \param PMHW_KERNEL_STATE pKernelState 1163 //! [in] Kernel state to construct the binding table for 1164 //! \param void *pvHwInterface 1165 //! [in] Temporary input parameter until SSH setup occurs in MHW 1166 //! \return MOS_STATUS 1167 //! MOS_STATUS_SUCCESS if success, else fail reason 1168 //! 1169 virtual MOS_STATUS SetBindingTable( 1170 PMHW_KERNEL_STATE pKernelState)= 0; 1171 1172 //! 1173 //! \brief Sets binding table entry in SSH 1174 //! \details TO BE REMOVED! Client facing function to add binding table to SSH 1175 //! \param PMHW_BINDING_TABLE_PARAMS pParams 1176 //! [in] Surface binding parameters 1177 //! 1178 virtual MOS_STATUS SetBindingTableEntry( 1179 PMHW_BINDING_TABLE_PARAMS pParams) = 0; 1180 1181 //! 1182 //! \brief Sends binding table entry to Command Buffer (indirect state) 1183 //! \details TO BE REMOVED! Sends binding table entry to indirect state heap in Cmd buffer, 1184 //! retrieving associated surface state offset and index 1185 //! \param PMHW_BINDING_TABLE_PARAMS pParams 1186 //! [in] Surface binding parameters - returns surface state pointer and index 1187 //! 1188 virtual MOS_STATUS SendBindingTableEntry( 1189 PMHW_BINDING_TABLE_SEND_PARAMS pParams) = 0; 1190 1191 //! 1192 //! \brief set surface state entry 1193 //! \details TO BE REMOVED! set surface state entry 1194 //! \param PMHW_BINDING_TABLE_PARAMS pParams 1195 //! [in] Surface state parameters 1196 //! 1197 virtual MOS_STATUS SetSurfaceStateEntry( 1198 PMHW_SURFACE_STATE_PARAMS pParams) = 0; 1199 1200 //! 1201 //! \brief Set surface state in ssh 1202 //! \details Set sampler state in ssh 1203 //! \param PMOS_COMMAND_BUFFER pCmdBuffer 1204 //! [in] command buffer pointer 1205 //! \param uint32_t dwNumSurfaceStatesToSet 1206 //! [in] number of surface states need to set 1207 //! \param PMHW_RCS_SURFACE_PARAMS pParams 1208 //! [in] render surface state parameters 1209 //! 1210 virtual MOS_STATUS SetSurfaceState( 1211 PMHW_KERNEL_STATE pKernelState, 1212 PMOS_COMMAND_BUFFER pCmdBuffer, 1213 uint32_t dwNumSurfaceStatesToSet, 1214 PMHW_RCS_SURFACE_PARAMS pParams) = 0; 1215 1216 //! 1217 //! \brief Set sampler state 1218 //! \details Set sampler state 1219 //! \param PMHW_SAMPLER_STATE_PARAM pParams 1220 //! [in] Sampler state parameters 1221 //! 1222 virtual MOS_STATUS SetSamplerState( 1223 void *pSampler, 1224 PMHW_SAMPLER_STATE_PARAM pParam) = 0; 1225 1226 //! 1227 //! \brief Adds sampler state data to dynamic GSH 1228 //! \param uint32_t samplerOffset 1229 //! [in] sampler offset 1230 //! \param MemoryBlock memoryBlock 1231 //! [in,out] Pointer to memory block 1232 //! \param PMHW_SAMPLER_STATE_PARAM pParam 1233 //! [in] sampler state parameters 1234 //! \return MOS_STATUS 1235 //! 1236 virtual MOS_STATUS AddSamplerStateData( 1237 uint32_t samplerOffset, 1238 MemoryBlock *memoryBlock, 1239 PMHW_SAMPLER_STATE_PARAM pParam) = 0; 1240 1241 //! 1242 //! \brief Initialize sampler states 1243 //! \details Initialize sampler states 1244 //! \param void *pSamplerStates 1245 //! [in] Pointer to sampler states to reset 1246 //! \param int32_t iSamplers 1247 //! [in] Number of sampler entries to reset 1248 //! \return MOS_STATUS 1249 //! MOS_STATUS_SUCCESS if success, else fail reason 1250 //! 1251 virtual MOS_STATUS InitSamplerStates( 1252 void *pSamplerStates, 1253 int32_t iSamplers) = 0; 1254 1255 //! 1256 //! \brief Init HwSizes 1257 //! \details Init HwSizes 1258 //! \return MOS_STATUS 1259 //! MOS_STATUS_SUCCESS if success else fail reason 1260 //! 1261 virtual MOS_STATUS InitHwSizes() = 0; 1262 1263 //! 1264 //! \brief Releases the dynamic state heap 1265 //! \details Releases the dynamic state heap. If all blocks 1266 //! are completed, free the resource. If there are some blocks still in 1267 //! the submitted state, then mark blocks for deletion. This function will be 1268 //! called again to free the resource when the last block is released. 1269 //! \param PMHW_STATE_HEAP pStateHeap 1270 //! [in] Pointer to the state heap to be released 1271 //! \return MOS_STATUS 1272 //! SUCCESS if state heap was either marked for deletion or actually freed 1273 //! 1274 MOS_STATUS ReleaseStateHeapDyn(PMHW_STATE_HEAP pStateHeap); 1275 1276 //! 1277 //! \brief Allocates a dynamic block 1278 //! \details Allocates either a single dynamic block or multiple blocks in ISH/DSH 1279 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1280 //! [in] State heap type (DSH/ISH) 1281 //! \param PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS pParams 1282 //! [in] Dynamic state heap parameters 1283 //! \return PMHW_STATE_HEAP_MEMORY_BLOCK 1284 //! Pointer to the allocated memory block(s) 1285 //! 1286 PMHW_STATE_HEAP_MEMORY_BLOCK AllocateDynamicBlockDyn( 1287 MHW_STATE_HEAP_TYPE StateHeapType, 1288 PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS pParams); 1289 1290 //! 1291 //! \brief Submits a dynamic block 1292 //! \details Submits a dynamic block. Detaches the block from current list and adds to to 1293 //! submitted list. Updates block with provided sync tag. 1294 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1295 //! [in] State heap type (DSH/ISH) 1296 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pBlock 1297 //! [in] Pointer to memory block to be submitted 1298 //! \param uint32_t dwSyncTag 1299 //! [in] Sync Tag 1300 //! \return MOS_STATUS 1301 //! SUCCESS if submission was successful 1302 //! 1303 MOS_STATUS SubmitDynamicBlockDyn( 1304 MHW_STATE_HEAP_TYPE StateHeapType, 1305 PMHW_STATE_HEAP_MEMORY_BLOCK pBlock, 1306 const FrameTrackerTokenFlat *trackerToken); 1307 1308 //! 1309 //! \brief Frees a dynamic block 1310 //! \details Detaches the block from current list if block has completed (based on provided dwSyncTag) 1311 //! and adds it to deleted list. Otherwise, marks for deletion upon completion. 1312 //! submitted list. Updates block with provided sync tag. 1313 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1314 //! [in] State heap type (DSH/ISH) 1315 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pBlock 1316 //! [in] Pointer to memory block to be freed 1317 //! \return MOS_STATUS 1318 //! SUCCESS if operation was successful 1319 //! 1320 MOS_STATUS FreeDynamicBlockDyn( 1321 MHW_STATE_HEAP_TYPE StateHeapType, 1322 PMHW_STATE_HEAP_MEMORY_BLOCK pBlock); 1323 1324 //! 1325 //! \brief Refresh the dynamic heap 1326 //! \details Updates block states based on last executed tag 1327 //! submitted unlocked blocks are released; 1328 //! move to allocated 1329 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1330 //! [in] State heap type (DSH/ISH) 1331 //! \param uint32_t dwSyncTag 1332 //! [in] Sync Tag 1333 //! \return MOS_STATUS 1334 //! SUCCESS if operation was successful 1335 //! 1336 MOS_STATUS RefreshDynamicHeapDyn ( 1337 MHW_STATE_HEAP_TYPE StateHeapType); 1338 1339 private: 1340 1341 //! 1342 //! \brief Insert a node into a memory block linked list 1343 //! \details MHW private function which maintains the memory block linked list 1344 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pStartNode 1345 //! [in] The memory block from which to start the insertion 1346 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pNodeToAdd 1347 //! [in] The memory block to insert 1348 //! \return MOS_STATUS 1349 //! MOS_STATUS_SUCCESS if success else fail reason 1350 //! 1351 MOS_STATUS InsertLinkedList( 1352 PMHW_STATE_HEAP_MEMORY_BLOCK pStartNode, 1353 PMHW_STATE_HEAP_MEMORY_BLOCK pNodeToAdd); 1354 1355 //! 1356 //! \brief Allocate and initialize a memory block based on input parameters 1357 //! \details MHW private function which creates memory blocks 1358 //! \param PMHW_STATE_HEAP pStateHeap 1359 //! [in] The state heap which the memory block belongs to 1360 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK ppMemoryBlock 1361 //! [in/out] The node to insert. 1362 //! \param uint32_t dwRequestedSize 1363 //! [in] The size of the memory that the memory block references. 1364 //! \param bool bStatic 1365 //! [in] If the memory block is static 1366 //! \return MOS_STATUS 1367 //! MOS_STATUS_SUCCESS if success else fail reason 1368 //! 1369 MOS_STATUS InitMemoryBlock( 1370 PMHW_STATE_HEAP pStateHeap, 1371 PMHW_STATE_HEAP_MEMORY_BLOCK *ppMemoryBlock, 1372 uint32_t dwRequestedSize, 1373 bool bStatic); 1374 1375 //! 1376 //! \brief Inserts a new memory block into an existing available memory block 1377 //! \details MHW private function to insert new memory blocks into available memory blocks 1378 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlockFree 1379 //! [in] Available memory block 1380 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlockToAdd 1381 //! [in] New memory block to be inserted 1382 //! \return MOS_STATUS 1383 //! MOS_STATUS_SUCCESS if success else fail reason 1384 //! 1385 MOS_STATUS InsertMemoryBlock( 1386 PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlockFree, 1387 PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlockToAdd); 1388 1389 //! 1390 //! \brief Returns the space of the memory block to the state heap 1391 //! \details MHW private function to return the memory block space to the state heap 1392 //! by marking it as available and merging it with adjacent memory blocks 1393 1394 //! \param PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlock 1395 //! [in] Memory block to return to the state heap 1396 //! \return MOS_STATUS 1397 //! MOS_STATUS_SUCCESS if success else fail reason 1398 //! 1399 MOS_STATUS ReturnSpaceMemoryBlock( 1400 PMHW_STATE_HEAP_MEMORY_BLOCK pMemoryBlock); 1401 1402 //Interfaces different cross static and dynmaic mode 1403 1404 //! 1405 //! \brief Extends the dynamic state heap 1406 //! \details Allocates a dynamic state heap (ISH/DSH) with requested size 1407 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1408 //! [in] State heap type (i.e. ISH/DSH) 1409 //! \param uint32_t dwSizeRequested 1410 //! [in] Size of requested state heap 1411 //! \return MOS_STATUS 1412 //! SUCCESS if state heap was successfully allocated 1413 //! 1414 MOS_STATUS ExtendStateHeapDyn( 1415 MHW_STATE_HEAP_TYPE StateHeapType, 1416 uint32_t dwSizeRequested); 1417 1418 //! 1419 //! \brief Extends the dynamic state heap 1420 //! \details Allocates a dynamic state heap (ISH/DSH) with requested size 1421 //! \param MHW_STATE_HEAP_TYPE StateHeapType 1422 //! [in] State heap type (i.e. ISH/DSH) 1423 //! \param uint32_t dwSizeRequested 1424 //! [in] Size of requested state heap 1425 //! \return MOS_STATUS 1426 //! SUCCESS if state heap was successfully allocated 1427 //! 1428 MOS_STATUS ExtendStateHeapSta( 1429 MHW_STATE_HEAP_TYPE StateHeapType, 1430 uint32_t dwSizeRequested); 1431 1432 }; 1433 1434 struct _MHW_STATE_HEAP_INTERFACE 1435 { 1436 1437 XMHW_STATE_HEAP_INTERFACE *pStateHeapInterface; 1438 1439 //! 1440 //! \brief Internal to MHW 1441 //! 1442 1443 MOS_STATUS (*pfnCreate) ( 1444 PMHW_STATE_HEAP_INTERFACE *ppStateHeapInterface, 1445 MHW_STATE_HEAP_SETTINGS StateHeapSettings); 1446 1447 MOS_STATUS (*pfnDestroy) ( 1448 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface); 1449 1450 //! 1451 //! \brief Primarily a state heap interface private function to be 1452 //! called as a pair in any state heap interface function which 1453 //! accesses the graphics resource like AddDataToStateHeap. 1454 //! 1455 MOS_STATUS (*pfnLockStateHeap) ( 1456 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1457 PMHW_STATE_HEAP pStateHeap); 1458 1459 MOS_STATUS (*pfnUnlockStateHeap) ( 1460 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1461 PMHW_STATE_HEAP pStateHeap); 1462 1463 //! 1464 //! \brief Client facing functions 1465 //! 1466 MOS_STATUS (*pfnAssignSpaceInStateHeap) ( 1467 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1468 MHW_STATE_HEAP_TYPE StateHeapType, 1469 PMHW_KERNEL_STATE pKernelState, 1470 uint32_t dwSpaceRequested, 1471 bool bStatic, 1472 bool bZeroAssignedMem); 1473 1474 MOS_STATUS(*pfnSubmitBlocks) ( 1475 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1476 PMHW_KERNEL_STATE pKernelState); 1477 1478 MOS_STATUS (*pfnExtendStateHeap) ( 1479 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1480 MHW_STATE_HEAP_TYPE StateHeapType, 1481 uint32_t dwSizeRequested); 1482 1483 MOS_STATUS (*pfnSetInterfaceDescriptor) ( 1484 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1485 uint32_t dwNumIdsToSet, 1486 PMHW_INTERFACE_DESCRIPTOR_PARAMS pParams); 1487 1488 MOS_STATUS (*pfnSetInterfaceDescriptorEntry) ( 1489 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1490 PMHW_ID_ENTRY_PARAMS pParams); 1491 1492 MOS_STATUS(*pfnSetBindingTable) ( 1493 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1494 PMHW_KERNEL_STATE pKernelState); 1495 1496 MOS_STATUS (*pfnSetSurfaceState) ( 1497 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1498 PMHW_KERNEL_STATE pKernelState, 1499 PMOS_COMMAND_BUFFER pCmdBuffer, 1500 uint32_t dwNumSurfaceStatesToSet, 1501 PMHW_RCS_SURFACE_PARAMS pParams); 1502 1503 MOS_STATUS (*pfnSetSurfaceStateBuffer) ( 1504 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1505 PMHW_RCS_SURFACE_PARAMS pParams, 1506 void *pSurfaceState); 1507 1508 MOS_STATUS (*pfnSetBindingTableEntry) ( 1509 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1510 PMHW_BINDING_TABLE_PARAMS pParams); 1511 1512 MOS_STATUS (*pfnSendBindingTableEntry) ( 1513 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1514 PMHW_BINDING_TABLE_SEND_PARAMS pParams); 1515 1516 MOS_STATUS (* pfnSetSurfaceStateToken) ( 1517 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1518 PMHW_SURFACE_TOKEN_PARAMS pParams, 1519 void *pSurfaceStateToken); 1520 1521 MOS_STATUS (*pfnSetSurfaceStateEntry) ( 1522 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1523 PMHW_SURFACE_STATE_PARAMS pParams); 1524 1525 MOS_STATUS (*pfnSendSurfaceStateEntry) ( 1526 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1527 PMOS_COMMAND_BUFFER pCmdBuffer, 1528 PMHW_SURFACE_STATE_SEND_PARAMS pParams); 1529 1530 //! 1531 //! \brief May only operate on the primary state heap. 1532 //! 1533 MOS_STATUS (*pfnCompactStateHeap) ( 1534 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1535 MHW_STATE_HEAP_TYPE StateHeapType); 1536 1537 //! 1538 //! \brief Must be called by the client directly to provide 1539 //! pointer for command buffer status for tracking purposes. 1540 //! 1541 MOS_STATUS(*pfnSetCmdBufStatusPtr) ( 1542 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1543 void *pvCmdBufStatus); 1544 1545 //! 1546 //! \brief Must be called by the client directly after a command 1547 //! buffer containing a kernel workload is submitted. 1548 //! 1549 MOS_STATUS(*pfnUpdateGlobalCmdBufId) ( 1550 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface); 1551 1552 //! 1553 //! \brief Must be called by the client before the client gets a 1554 //! command buffer for a kernel workload from MOS. This function 1555 //! will resize the SSH the current size is < dwBtEntriesRequested, 1556 //! otherwise it does nothing. In the future when SSHes are 1557 //! managed entirely in UMD this function may be deprecated and 1558 //! the SSH may be treated like the 1559 //! other state heaps. 1560 //! 1561 MOS_STATUS (*pfnRequestSshSpaceForCmdBuf) ( 1562 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1563 uint32_t dwBtEntriesRequested); 1564 1565 MOS_STATUS (*pfnCalculateSshAndBtSizesRequested) ( 1566 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1567 uint32_t dwBtEntriesRequested, 1568 uint32_t *pdwSshSize, 1569 uint32_t *pdwBtSize); 1570 1571 MOS_STATUS(* pfnInitSamplerStates) ( 1572 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1573 void *pSampler, 1574 int32_t iSamplers); 1575 1576 MOS_STATUS (* pfnSetSamplerState) ( 1577 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface, 1578 void *pSampler, 1579 PMHW_SAMPLER_STATE_PARAM pParams); 1580 1581 //Interfaces in dynamic mode 1582 uint32_t (*pfnCalculateDynamicSpaceNeeded) ( 1583 PMHW_STATE_HEAP_INTERFACE pStateHeapInterface, 1584 MHW_STATE_HEAP_TYPE StateHeapType, 1585 PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS pParams); 1586 1587 PMHW_STATE_HEAP_MEMORY_BLOCK (*pfnAllocateDynamicBlock) ( 1588 PMHW_STATE_HEAP_INTERFACE pStateHeapInterface, 1589 MHW_STATE_HEAP_TYPE StateHeapType, 1590 PMHW_STATE_HEAP_DYNAMIC_ALLOC_PARAMS pParams); 1591 1592 MOS_STATUS (*pfnSubmitDynamicBlock) ( 1593 PMHW_STATE_HEAP_INTERFACE pStateHeapInterface, 1594 MHW_STATE_HEAP_TYPE StateHeapType, 1595 PMHW_STATE_HEAP_MEMORY_BLOCK pBlock, 1596 FrameTrackerTokenFlat *trackerToken); 1597 1598 MOS_STATUS (*pfnFreeDynamicBlock) ( 1599 PMHW_STATE_HEAP_INTERFACE pStateHeapInterface, 1600 MHW_STATE_HEAP_TYPE StateHeapType, 1601 PMHW_STATE_HEAP_MEMORY_BLOCK pBlock); 1602 1603 MOS_STATUS (*pfnRefreshDynamicHeap) ( 1604 PMHW_STATE_HEAP_INTERFACE pStateHeapInterface, 1605 MHW_STATE_HEAP_TYPE StateHeapType); 1606 1607 MOS_STATUS (*pfnReleaseStateHeap) ( 1608 PMHW_STATE_HEAP_INTERFACE pStateHeapInterface, 1609 PMHW_STATE_HEAP pStateHeap); 1610 1611 }; 1612 1613 MOS_STATUS Mhw_StateHeapInterface_AssignInterfaces( 1614 PMHW_STATE_HEAP_INTERFACE pCommonStateHeapInterface); 1615 1616 MOS_STATUS Mhw_StateHeapInterface_InitInterface( 1617 PMHW_STATE_HEAP_INTERFACE *ppCommonStateHeapInterface, 1618 PMOS_INTERFACE pOsInterface, 1619 uint8_t bDynamicMode); 1620 1621 extern const uint8_t g_cMhw_VDirection[MHW_NUM_FRAME_FIELD_TYPES]; 1622 1623 #endif // __MHW_STATE_HEAP_H__ 1624