1 /* 2 * Copyright (c) 2017, 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 cm_thread_space_rt.h 24 //! \brief Contains CmThreadSpaceRT declarations. 25 //! 26 27 #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTHREADSPACERT_H_ 28 #define MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTHREADSPACERT_H_ 29 30 #include "cm_thread_space.h" 31 #include "cm_hal.h" 32 #include "cm_log.h" 33 34 struct CM_THREAD_SPACE_UNIT 35 { 36 void *kernel; 37 uint32_t threadId; 38 int32_t numEdges; //For Emulation mode 39 CM_COORDINATE scoreboardCoordinates; 40 uint8_t dependencyMask; 41 uint8_t reset; 42 uint8_t scoreboardColor; 43 uint8_t sliceDestinationSelect; 44 uint8_t subSliceDestinationSelect; 45 }; 46 47 enum CM_THREAD_SPACE_DIRTY_STATUS 48 { 49 CM_THREAD_SPACE_CLEAN = 0, 50 CM_THREAD_SPACE_DEPENDENCY_MASK_DIRTY = 1, 51 CM_THREAD_SPACE_DATA_DIRTY = 2 52 }; 53 54 namespace CMRT_UMD 55 { 56 class CmDeviceRT; 57 class CmKernel; 58 class CmKernelRT; 59 class CmTaskRT; 60 class CmSurface2D; 61 class CmThreadSpaceRT; 62 class CmThreadSpaceEx; 63 class CmThreadGroupSpace; 64 65 class CmThreadSpaceRT: public CmThreadSpace 66 { 67 public: 68 static int32_t Create(CmDeviceRT *device, 69 uint32_t indexTsArray, 70 uint32_t width, 71 uint32_t height, 72 CmThreadSpaceRT* &threadSpace); 73 74 static int32_t Destroy(CmThreadSpaceRT* &threadSpace); 75 76 CM_RT_API int32_t AssociateThread(uint32_t x, 77 uint32_t y, 78 CmKernel *kernel, 79 uint32_t threadId); 80 81 CM_RT_API int32_t AssociateThreadWithMask(uint32_t x, 82 uint32_t y, 83 CmKernel *kernel, 84 uint32_t threadId, 85 uint8_t dependencyMask); 86 87 CM_RT_API int32_t SetThreadDependencyPattern(uint32_t count, 88 int32_t *deltaX, 89 int32_t *deltaY); 90 91 CM_RT_API int32_t 92 SelectThreadDependencyPattern(CM_DEPENDENCY_PATTERN pattern); 93 94 CM_RT_API int32_t SetThreadSpaceColorCount(uint32_t colorCount); 95 96 CM_RT_API int32_t SelectMediaWalkingPattern(CM_WALKING_PATTERN pattern); 97 98 CM_RT_API int32_t Set26ZIDispatchPattern(CM_26ZI_DISPATCH_PATTERN pattern); 99 100 CM_RT_API int32_t Set26ZIMacroBlockSize(uint32_t width, uint32_t height); 101 102 CM_RT_API int32_t SetMediaWalkerGroupSelect(CM_MW_GROUP_SELECT groupSelect); 103 104 CM_RT_API int32_t 105 SelectMediaWalkingParameters(CM_WALKING_PARAMETERS parameters); 106 107 CM_RT_API int32_t 108 SelectThreadDependencyVectors(CM_DEPENDENCY dependencyVectors); 109 110 CM_RT_API int32_t 111 SetThreadSpaceOrder(uint32_t threadCount, 112 const CM_THREAD_PARAM *threadSpaceOrder); 113 114 int32_t GetThreadSpaceSize(uint32_t &width, uint32_t &height); 115 116 int32_t GetThreadSpaceUnit(CM_THREAD_SPACE_UNIT *&threadSpaceUnit); 117 118 int32_t GetDependency(CM_HAL_DEPENDENCY *&dependency); 119 120 int32_t 121 GetDependencyPatternType(CM_DEPENDENCY_PATTERN &dependencyPatternType); 122 123 int32_t GetWalkingPattern(CM_WALKING_PATTERN &walkingPattern); 124 125 int32_t Get26ZIDispatchPattern(CM_26ZI_DISPATCH_PATTERN &pattern); 126 127 int32_t GetWalkingParameters(CM_WALKING_PARAMETERS &walkingParameters); 128 129 int32_t GetDependencyVectors(CM_HAL_DEPENDENCY &dependencyVectors); 130 131 bool CheckWalkingParametersSet(); 132 133 bool CheckDependencyVectorsSet(); 134 135 bool CheckThreadSpaceOrderSet(); 136 137 int32_t GetColorCountMinusOne(uint32_t &colorCount); 138 139 int32_t GetWavefront26ZDispatchInfo( 140 CM_HAL_WAVEFRONT26Z_DISPATCH_INFO &dispatchInfo); 141 142 bool IntegrityCheck(CmTaskRT *task); 143 144 int32_t GetBoardOrder(uint32_t *&boardOrder); 145 146 int32_t Wavefront45Sequence(); 147 148 int32_t Wavefront26Sequence(); 149 150 int32_t Wavefront26ZSequence(); 151 152 int32_t Wavefront26ZISeqVVHV26(); 153 154 int32_t Wavefront26ZISeqVVHH26(); 155 156 int32_t Wavefront26ZISeqVV26HH26(); 157 158 int32_t Wavefront26ZISeqVV1x26HH1x26(); 159 160 int32_t HorizentalSequence(); 161 162 int32_t VerticalSequence(); 163 164 int32_t WavefrontDependencyVectors(); 165 166 bool IsThreadAssociated() const; 167 168 bool IsDependencySet(); 169 170 virtual uint32_t GetIndexInTsArray(); 171 172 CM_THREAD_SPACE_DIRTY_STATUS GetDirtyStatus() const; 173 174 uint32_t SetDirtyStatus(CM_THREAD_SPACE_DIRTY_STATUS dirtyStatus) const; 175 176 bool GetNeedSetKernelPointer() const; 177 178 int32_t SetKernelPointer(CmKernelRT *kernel) const; 179 180 bool KernelPointerIsNULL() const; 181 182 CmKernelRT *GetKernelPointer() const; 183 184 int32_t GetMediaWalkerGroupSelect(CM_MW_GROUP_SELECT &groupSelect); 185 186 int32_t UpdateDependency(); 187 int32_t SetDependencyArgToKernel(CmKernelRT *pKernel) const; 188 189 #if CM_LOG_ON 190 std::string Log(); 191 192 CM_HAL_STATE* GetHalState(); 193 #endif 194 195 CmThreadGroupSpace *GetThreadGroupSpace() const; 196 197 protected: 198 CmThreadSpaceRT(CmDeviceRT *device, 199 uint32_t indexTsArray, 200 uint32_t width, 201 uint32_t height); 202 203 ~CmThreadSpaceRT(); 204 205 int32_t Initialize(); 206 207 int32_t InitSwScoreBoard(); 208 209 #ifdef _DEBUG 210 int32_t PrintBoardOrder(); 211 #endif 212 213 CmDeviceRT *m_device; 214 215 uint32_t m_width; 216 uint32_t m_height; 217 uint32_t m_colorCountMinusOne; 218 219 uint32_t m_26ZIBlockWidth; 220 uint32_t m_26ZIBlockHeight; 221 222 CM_THREAD_SPACE_UNIT *m_threadSpaceUnit; 223 bool m_threadAssociated; 224 225 bool m_needSetKernelPointer; 226 CmKernelRT **m_kernel; 227 228 CM_DEPENDENCY_PATTERN m_dependencyPatternType; 229 CM_DEPENDENCY_PATTERN m_currentDependencyPattern; 230 CM_HAL_DEPENDENCY m_dependency; 231 CM_26ZI_DISPATCH_PATTERN m_26ZIDispatchPattern; 232 CM_26ZI_DISPATCH_PATTERN m_current26ZIDispatchPattern; 233 234 uint32_t *m_boardFlag; 235 uint32_t *m_boardOrderList; 236 uint32_t m_indexInList; 237 uint32_t m_indexInThreadSpaceArray; // index in device's ThreadSpaceArray 238 239 CM_WALKING_PATTERN m_walkingPattern; 240 uint32_t m_walkingParameters[CM_NUM_DWORD_FOR_MW_PARAM]; 241 bool m_mediaWalkerParamsSet; 242 CM_HAL_DEPENDENCY m_dependencyVectors; 243 bool m_dependencyVectorsSet; 244 bool m_threadSpaceOrderSet; 245 246 CmSurface2D *m_swBoardSurf; // SWSB 2D atomic 247 uint32_t *m_swBoard; // SWSB system memory store 248 bool m_swScoreBoardEnabled; 249 250 // used to emulate thread space when media walker is not available 251 CmThreadGroupSpace *m_threadGroupSpace; 252 253 private: 254 CmThreadSpaceRT(const CmThreadSpaceRT &other); 255 256 CmThreadSpaceRT &operator=(const CmThreadSpaceRT &other); 257 258 CM_THREAD_SPACE_DIRTY_STATUS *m_dirtyStatus; 259 260 CM_HAL_WAVEFRONT26Z_DISPATCH_INFO m_wavefront26ZDispatchInfo; 261 262 //Group select in media pipe, by default no group setting 263 CM_MW_GROUP_SELECT m_groupSelect; 264 }; 265 }; //namespace 266 267 #endif // #ifndef MEDIADRIVER_AGNOSTIC_COMMON_CM_CMTHREADSPACERT_H_ 268