1 /* 2 * Copyright (c) 2022, 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 //! 24 //! \file decode_scalability_multipipe_next.h 25 //! \brief Defines the common interface for decode scalability mulitpipe mode. 26 //! \details The decode scalability mulitpipe interface is further sub-divided by codecs, 27 //! this file is for the base interface which is shared by all codecs. 28 //! 29 30 #ifndef __DECODE_SCALABILITY_MULTIPIPE_NEXT_H__ 31 #define __DECODE_SCALABILITY_MULTIPIPE_NEXT_H__ 32 #include "mos_defs.h" 33 #include "mos_os.h" 34 #include "codec_hw_next.h" 35 #include "media_scalability_multipipe.h" 36 #include "decode_scalability_option.h" 37 #include "mos_os_virtualengine_next.h" 38 #include "decode_phase.h" 39 40 namespace decode 41 { 42 class DecodeScalabilityMultiPipeNext : public MediaScalabilityMultiPipe 43 { 44 public: 45 //! 46 //! \brief Decode scalability mulitipipe constructor 47 //! \param [in] hwInterface 48 //! Pointer to HwInterface 49 //! \param [in] mediaContext 50 //! Pointer to MediaContext 51 //! \param [in] componentType 52 //! Component type 53 //! 54 DecodeScalabilityMultiPipeNext(void *hwInterface, MediaContext *mediaContext, uint8_t componentType); 55 56 //! 57 //! \brief Decode scalability mulitipipe destructor 58 //! 59 ~DecodeScalabilityMultiPipeNext(); 60 61 //! 62 //! \brief Copy constructor 63 //! 64 DecodeScalabilityMultiPipeNext(const DecodeScalabilityMultiPipeNext &) = delete; 65 66 //! 67 //! \brief Copy assignment operator 68 //! 69 DecodeScalabilityMultiPipeNext &operator=(const DecodeScalabilityMultiPipeNext &) = delete; 70 71 //! 72 //! \brief Initialize the media scalability 73 //! \details It will prepare the resources needed in scalability 74 //! and initialize the state of scalability 75 //! \param [in] option 76 //! Input scalability option 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! 80 MOS_STATUS Initialize(const MediaScalabilityOption &option) override; 81 82 //! 83 //! \brief Construct parameters for GPU context create. 84 //! \param [in, out] gpuCtxCreateOption 85 //! Pointer to the GPU Context Create Option 86 //! \return MOS_STATUS 87 //! MOS_STATUS_SUCCESS if success, else fail reason 88 //! 89 MOS_STATUS GetGpuCtxCreationOption(MOS_GPUCTX_CREATOPTIONS *gpuCtxCreateOption) override; 90 91 //! 92 //! \brief Destroy the media scalability 93 //! \return MOS_STATUS 94 //! MOS_STATUS_SUCCESS if success, else fail reason 95 //! 96 virtual MOS_STATUS Destroy() override; 97 98 //! 99 //! \brief Update the media scalability state 100 //! \param [in] statePars 101 //! parameters to update the state 102 //! \return MOS_STATUS 103 //! MOS_STATUS_SUCCESS if success, else fail reason 104 //! 105 MOS_STATUS UpdateState(void *statePars) override; 106 107 //! 108 //! \brief Verify command buffer 109 //! \param [in] requestedSize 110 //! requested size for command buffer 111 //! \param [in] requestedPatchListSize 112 //! requested size for patched list 113 //! \param [out] singleTaskPhaseSupportedInPak 114 //! Inidcate if to use single task phase in pak. 115 //! \return MOS_STATUS 116 //! MOS_STATUS_SUCCESS if success, else fail reason 117 //! 118 MOS_STATUS VerifyCmdBuffer(uint32_t requestedSize, uint32_t requestedPatchListSize, bool &singleTaskPhaseSupportedInPak) override; 119 120 //! 121 //! \brief Get command buffer 122 //! \param [in, out] cmdBuffer 123 //! Pointer to command buffer 124 //! \return MOS_STATUS 125 //! MOS_STATUS_SUCCESS if success, else fail reason 126 //! 127 MOS_STATUS GetCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer, bool frameTrackingRequested = true) override; 128 129 //! 130 //! \brief Return command buffer 131 //! \param [in, out] cmdBuffer 132 //! Pointer to command buffer 133 //! \return MOS_STATUS 134 //! MOS_STATUS_SUCCESS if success, else fail reason 135 //! 136 MOS_STATUS ReturnCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer) override; 137 138 //! 139 //! \brief Submit command buffer 140 //! \param [in, out] cmdBuffer 141 //! Pointer to command buffer 142 //! \return MOS_STATUS 143 //! MOS_STATUS_SUCCESS if success, else fail reason 144 //! 145 MOS_STATUS SubmitCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer) override; 146 147 //! 148 //! \brief Add synchronization for pipes. 149 //! \param [in] syncType 150 //! type of pipe sync 151 //! \param [in] semaphoreId 152 //! Id of the semaphore used for this sync 153 //! \param [in, out] cmdBuffer 154 //! Pointer to command buffer 155 //! \return MOS_STATUS 156 //! MOS_STATUS_SUCCESS if success, else fail reason 157 //! 158 MOS_STATUS SyncPipe(uint32_t syncType, uint32_t semaphoreId, PMOS_COMMAND_BUFFER cmdBuffer) override; 159 160 //! 161 //! \brief Reset semaphore 162 //! \param [in] syncType 163 //! type of pipe sync to find the related semaphore 164 //! \param [in] semaphoreId 165 //! Id of the semaphore for reset 166 //! \param [in, out] cmdBuffer 167 //! \return MOS_STATUS 168 //! MOS_STATUS_SUCCESS if success, else fail reason 169 //! 170 MOS_STATUS ResetSemaphore(uint32_t syncType, uint32_t semaphoreId, PMOS_COMMAND_BUFFER cmdBuffer) override; 171 //! 172 //! \brief Create decode multi pipe 173 //! \param [in] hwInterface 174 //! void type hw interface 175 //! \param [in] mediaContext 176 //! required media context to create multi pipe 177 //! \param [in] componentType 178 //! Inidcate component. 179 //! \return MOS_STATUS 180 //! MOS_STATUS_SUCCESS if success, else fail reason 181 //! 182 static MOS_STATUS CreateDecodeMultiPipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType); 183 protected: 184 185 //! 186 //! \brief Resizes the cmd buffer and patch list with cmd buffer header 187 //! 188 //! \param [in] requestedCommandBufferSize 189 //! Requested resize command buffer size 190 //! \param [in] requestedPatchListSize 191 //! Requested resize patchlist size 192 //! 193 //! \return MOS_STATUS 194 //! MOS_STATUS_SUCCESS if success, else fail reason 195 //! 196 virtual MOS_STATUS ResizeCommandBufferAndPatchList( 197 uint32_t requestedCommandBufferSize, 198 uint32_t requestedPatchListSize) override; 199 200 //! 201 //! \brief Verify primary command buffer 202 //! \param [in] requestedSize 203 //! requested size for command buffer 204 //! \param [in] requestedPatchListSize 205 //! requested size for patched list 206 //! \param [out] singleTaskPhaseSupportedInPak 207 //! Inidcate if to use single task phase in pak. 208 //! \return MOS_STATUS 209 //! MOS_STATUS_SUCCESS if success, else fail reason 210 //! 211 virtual MOS_STATUS VerifySpaceAvailable(uint32_t requestedSize, uint32_t requestedPatchListSize, bool &singleTaskPhaseSupportedInPak) override; 212 213 //! 214 //! \brief Set hint parameters 215 //! \return MOS_STATUS 216 //! MOS_STATUS_SUCCESS if success, else fail reason 217 //! 218 MOS_STATUS SetHintParams(); 219 220 //! 221 //! \brief Populate hint parameters 222 //! \param [in] cmdBuffer 223 //! Pointer to command buffer 224 //! \return MOS_STATUS 225 //! MOS_STATUS_SUCCESS if success, else fail reason 226 //! 227 MOS_STATUS PopulateHintParams(PMOS_COMMAND_BUFFER cmdBuffer); 228 229 //! 230 //! \brief Sync all pipes 231 //! \param [in] cmdBuffer 232 //! Pointer to command buffer 233 //! \return MOS_STATUS 234 //! MOS_STATUS_SUCCESS if success, else fail reason 235 //! 236 MOS_STATUS SyncAllPipes(PMOS_COMMAND_BUFFER cmdBuffer); 237 238 //! 239 //! \brief Sync pipes with first pipe wait for others 240 //! \detials Only support to use this sync once per frame. 241 //! \param [in] cmdBuffer 242 //! Pointer to command buffer 243 //! \param [in] pipeIdx 244 //! The index of pipeline which wait for others 245 //! \return MOS_STATUS 246 //! MOS_STATUS_SUCCESS if success, else fail reason 247 //! 248 MOS_STATUS SyncOnePipeWaitOthers(PMOS_COMMAND_BUFFER cmdBuffer, uint32_t pipeIdx); 249 250 //! \brief Allocate resources for semaphore 251 //! \return MOS_STATUS 252 //! MOS_STATUS_SUCCESS if success, else fail reason 253 //! 254 MOS_STATUS AllocateSemaphore(); 255 256 //! 257 //! \brief Send Cmd buffer Attributes with frame tracking info 258 //! 259 //! \param [in] cmdBuffer 260 //! Reference to command buffer 261 //! \param [in] frameTrackingRequested 262 //! Indicate if frame tracking is requested 263 //! 264 //! \return MOS_STATUS 265 //! MOS_STATUS_SUCCESS if success, else fail reason 266 //! 267 virtual MOS_STATUS SendAttrWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested) override; 268 269 static const uint8_t m_initSecondaryCmdBufNum = 8; //!< The initial secondary command buffer size 270 static const uint8_t m_maxCmdBufferSetsNum = 16; //!< The max number of command buffer sets 271 272 CodechalHwInterfaceNext *m_hwInterface = nullptr; 273 MOS_COMMAND_BUFFER m_primaryCmdBuffer = {}; 274 std::vector<MOS_COMMAND_BUFFER> m_secondaryCmdBuffers; 275 276 std::vector<std::vector<MOS_RESOURCE>> m_resSemaphoreAllPipes; //!< The sync semaphore between all pipes 277 std::vector<std::vector<MOS_RESOURCE>> m_resSemaphoreOnePipeWait; //!< The sync semaphore between main pipe and other pipes 278 uint8_t m_semaphoreIndex = 0; //!< The index for semaphore using by current frame 279 280 DecodePhase *m_phase = nullptr; 281 282 MEDIA_CLASS_DEFINE_END(decode__DecodeScalabilityMultiPipeNext) 283 }; 284 } // namespace decode 285 #endif // !__DECODE_SCALABILITY_MULTIPIPE_NEXT_H__ 286