1 /* 2 * Copyright (c) 2024, 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 surface_state_heap_mgr.h 24 //! \brief Render Engine Interfaces shared across platforms 25 //! \details Platform Independent Hardware Interfaces 26 //! 27 #ifndef __SURFACE_STATE_HEAP_MGR_H__ 28 #define __SURFACE_STATE_HEAP_MGR_H__ 29 30 #include <iostream> 31 #include "mos_os.h" 32 #include "mhw_utilities.h" 33 #include "mos_os_specific.h" 34 #include "mos_interface.h" 35 #include<vector> 36 37 #define MAX_SURFACE_STATES 512 38 using SURF_STATES_LIST = std::vector<int32_t>; 39 //! 40 //! \brief Default size of area for sync, debugging, performance collecting 41 //! 42 #define SYNC_SIZE 128 // range: (128 ... 4096) 43 44 //! 45 //! \brief VEBOX Heap State Structure 46 //! 47 typedef struct _SURFACE_STATES_OBJ 48 { 49 bool bBusy; // true if the state is in use (must sync before use) 50 uint32_t dwSyncTag; // surface heap state sync tag 51 } SURFACE_STATES_OBJ, *PSURFACE_STATES_OBJ; 52 53 typedef struct _SURFACE_STATES_HEAP_OBJ 54 { 55 uint32_t uiCurState; // Current surface State 56 uint32_t uiNextState; // Next surface State 57 uint32_t uiOffsetSync; // Offset of sync data in Heap 58 uint32_t uiInstanceSize; // Size of single instance 59 uint32_t uiStateHeapSize; // Total size of Surface States heap 60 PSURFACE_STATES_OBJ pSurfStateObj; // Array of SURFACE_STATES_SYNC_OBJ 61 MOS_RESOURCE osResource; // Graphics memory 62 uint8_t *pLockedOsResourceMem; // Locked resource memory 63 64 // Synchronization 65 volatile uint32_t *pSync; // Pointer to sync area (when locked) 66 uint32_t dwNextTag; // Next sync tag value to use 67 uint32_t dwSyncTag; // Last sync tag completed 68 } SURFACE_STATES_HEAP_OBJ, *PSURFACE_STATES_HEAP_OBJ; 69 70 class SurfaceStateHeapManager 71 { 72 public: 73 SurfaceStateHeapManager(PMOS_INTERFACE pOsInterface); 74 MOS_STATUS CreateHeap(size_t surfStateSize); 75 76 void RefreshSync(); 77 78 MOS_STATUS DestroyHeap(); 79 80 MOS_STATUS AssignSurfaceState(); 81 AssignUsedSurfaceState(int32_t index)82 MOS_STATUS AssignUsedSurfaceState(int32_t index) 83 { 84 m_usedStates.push_back(index); 85 return MOS_STATUS_SUCCESS; 86 } 87 88 ~SurfaceStateHeapManager(); 89 90 public: 91 PMOS_INTERFACE m_osInterface = nullptr; 92 SURFACE_STATES_HEAP_OBJ *m_surfStateHeap = nullptr; 93 int m_surfHeapInUse = 0; 94 SURF_STATES_LIST m_usedStates = {}; 95 }; 96 97 #endif // __SURFACE_STATE_HEAP_MGR_H__