| 1 |
/* |
| 2 |
* Copyright (c) 2018-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 |
//! |
| 24 |
//! \file media_scalability.h |
| 25 |
//! \brief Defines the common interface for media scalability |
| 26 |
//! \details The media scalability interface is further sub-divided by component, |
| 27 |
//! this file is for the base interface which is shared by all components. |
| 28 |
//! |
| 29 |
|
| 30 |
#ifndef __MEDIA_SCALABILITY_H__ |
| 31 |
#define __MEDIA_SCALABILITY_H__ |
| 32 |
#include <stdint.h> |
| 33 |
#include <memory> |
| 34 |
#include "mos_defs.h" |
| 35 |
#include "mos_os_specific.h" |
| 36 |
|
| 37 |
#include "mos_os_virtualengine_specific.h" |
| 38 |
|
| 39 |
#include "mos_os.h" |
| 40 |
|
| 41 |
#include "mhw_mi_itf.h" |
| 42 |
class MediaScalabilityOption; |
| 43 |
|
| 44 |
struct ComponentState; |
| 45 |
struct ScalabilityPars; |
| 46 |
#define COMMAND_BUFFER_RESERVED_SPACE 0x80 |
| 47 |
class MediaStatusReport; |
| 48 |
class MediaContext; |
| 49 |
class MediaScalability : public mhw::mi::Itf::ParSetting |
| 50 |
{ |
| 51 |
friend class MediaContext; |
| 52 |
|
| 53 |
public: |
| 54 |
//! |
| 55 |
//! \brief Media scalability constructor |
| 56 |
//! |
| 57 |
MediaScalability(MediaContext *mediaContext); |
| 58 |
|
| 59 |
MediaScalability(){}; |
| 60 |
//! |
| 61 |
//! \brief Media scalability destructor |
| 62 |
//! |
| 63 |
virtual ~MediaScalability() {} |
| 64 |
|
| 65 |
//! |
| 66 |
//! \brief Copy constructor |
| 67 |
//! |
| 68 |
MediaScalability(const MediaScalability &) = delete; |
| 69 |
|
| 70 |
//! |
| 71 |
//! \brief Copy assignment operator |
| 72 |
//! |
| 73 |
MediaScalability &operator=(const MediaScalability &) = delete; |
| 74 |
|
| 75 |
//! |
| 76 |
//! \brief Check if the scalability mode decided by parameters matched with current |
| 77 |
//! \param [in] params |
| 78 |
//! Pointer to the input parameters |
| 79 |
//! \return bool |
| 80 |
//! true if mode decided by input parameters matched with current mode, |
| 81 |
//! false if not matched. |
| 82 |
//! |
| 83 |
bool IsScalabilityModeMatched(ScalabilityPars *params); |
| 84 |
|
| 85 |
//! |
| 86 |
//! \brief Check if the scalability mode matched with current |
| 87 |
//! \param [in] scalabOption |
| 88 |
//! Scalability option to match with current |
| 89 |
//! \return bool |
| 90 |
//! true if mode matched with current mode, |
| 91 |
//! false if not matched. |
| 92 |
//! |
| 93 |
bool IsScalabilityModeMatched(MediaScalabilityOption &scalabOption); |
| 94 |
|
| 95 |
//! |
| 96 |
//! \brief Check if the Gpu ctx create option matched |
| 97 |
//! \param [in] gpuCtxCreateOption1 |
| 98 |
//! Pointer to the input gpu ctx create option for compare |
| 99 |
//! \param [in] gpuCtxCreateOption2 |
| 100 |
//! Pointer to the input gpu ctx create option for compare |
| 101 |
//! \return bool |
| 102 |
//! true if the two option are matched and can share one gpu ctx, |
| 103 |
//! false if not matched. |
| 104 |
//! |
| 105 |
bool IsGpuCtxCreateOptionMatched(PMOS_GPUCTX_CREATOPTIONS_ENHANCED gpuCtxCreateOption1, PMOS_GPUCTX_CREATOPTIONS_ENHANCED gpuCtxCreateOption2); |
| 106 |
|
| 107 |
//! |
| 108 |
//! \brief Initialize the media scalability |
| 109 |
//! \details It will prepare the resources needed in scalability |
| 110 |
//! and initialize the state of scalability |
| 111 |
//! \param [in] option |
| 112 |
//! Input scalability option |
| 113 |
//! \return MOS_STATUS |
| 114 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 115 |
//! |
| 116 |
virtual MOS_STATUS Initialize(const MediaScalabilityOption &option) = 0; |
| 117 |
|
| 118 |
//! |
| 119 |
//! \brief Construct parameters for GPU context create. |
| 120 |
//! \param [in, out] gpuCtxCreateOption |
| 121 |
//! Pointer to the GPU Context Create Option |
| 122 |
//! \return MOS_STATUS |
| 123 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 124 |
//! |
| 125 |
virtual MOS_STATUS GetGpuCtxCreationOption(MOS_GPUCTX_CREATOPTIONS *gpuCtxCreateOption) = 0; |
| 126 |
|
| 127 |
//! |
| 128 |
//! \brief Destroy the media scalability |
| 129 |
//! \return MOS_STATUS |
| 130 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 131 |
//! |
| 132 |
virtual MOS_STATUS Destroy(); |
| 133 |
|
| 134 |
//! |
| 135 |
//! \brief Update the media scalability state |
| 136 |
//! \param [in] statePars |
| 137 |
//! parameters to update the state |
| 138 |
//! \return MOS_STATUS |
| 139 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 140 |
//! |
| 141 |
virtual MOS_STATUS UpdateState(void *statePars) = 0; |
| 142 |
|
| 143 |
//! |
| 144 |
//! \brief Verify command buffer |
| 145 |
//! \param [in] requestedSize |
| 146 |
//! requested size for command buffer |
| 147 |
//! \param [in] requestedPatchListSize |
| 148 |
//! requested size for patched list |
| 149 |
//! \param [out] singleTaskPhaseSupportedInPak |
| 150 |
//! Inidcate if to use single task phase in pak. |
| 151 |
//! \return MOS_STATUS |
| 152 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 153 |
//! |
| 154 |
virtual MOS_STATUS VerifyCmdBuffer(uint32_t requestedSize, uint32_t requestedPatchListSize, bool &singleTaskPhaseSupportedInPak) = 0; |
| 155 |
|
| 156 |
//! |
| 157 |
//! \brief Get command buffer |
| 158 |
//! \param [in, out] cmdBuffer |
| 159 |
//! Pointer to command buffer |
| 160 |
//! \return MOS_STATUS |
| 161 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 162 |
//! |
| 163 |
virtual MOS_STATUS GetCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer, bool frameTrackingRequested = true) = 0; |
| 164 |
|
| 165 |
//! |
| 166 |
|
| 167 |
//! \brief Return command buffer |
| 168 |
//! \param [in, out] cmdBuffer |
| 169 |
//! Pointer to command buffer |
| 170 |
//! \return MOS_STATUS |
| 171 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 172 |
//! |
| 173 |
virtual MOS_STATUS ReturnCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 174 |
|
| 175 |
//! |
| 176 |
//! \brief Submit command buffer |
| 177 |
//! \param [in, out] cmdBuffer |
| 178 |
//! Pointer to command buffer |
| 179 |
//! \return MOS_STATUS |
| 180 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 181 |
//! |
| 182 |
virtual MOS_STATUS SubmitCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 183 |
|
| 184 |
//! |
| 185 |
//! \brief Add synchronization for pipes. |
| 186 |
//! \param [in] syncType |
| 187 |
//! type of pipe sync |
| 188 |
//! \param [in] semaphoreId |
| 189 |
//! Id of the semaphore used for this sync |
| 190 |
//! \param [in, out] cmdBuffer |
| 191 |
//! Pointer to command buffer |
| 192 |
//! \return MOS_STATUS |
| 193 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 194 |
//! |
| 195 |
virtual MOS_STATUS SyncPipe(uint32_t syncType, uint32_t semaphoreId, PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 196 |
|
| 197 |
//! |
| 198 |
//! \brief Reset semaphore |
| 199 |
//! \param [in] syncType |
| 200 |
//! type of pipe sync |
| 201 |
//! \param [in] semaphoreId |
| 202 |
//! Id of the semaphore used for this sync |
| 203 |
//! \param [in, out] cmdBuffer |
| 204 |
//! Pointer to command buffer |
| 205 |
//! \return MOS_STATUS |
| 206 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 207 |
//! |
| 208 |
virtual MOS_STATUS ResetSemaphore(uint32_t syncType, uint32_t semaphoreId, PMOS_COMMAND_BUFFER cmdBuffer) = 0; |
| 209 |
|
| 210 |
//! |
| 211 |
//! \brief Oca 1st Level BB Start |
| 212 |
//! \param [in, out] cmdBuffer |
| 213 |
//! Reference to command buffer |
| 214 |
//! \return MOS_STATUS |
| 215 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 216 |
//! |
| 217 |
virtual MOS_STATUS Oca1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer) { return MOS_STATUS_SUCCESS; }; |
| 218 |
|
| 219 |
//! |
| 220 |
//! \brief Oca 1st Level BB End |
| 221 |
//! \param [in, out] cmdBuffer |
| 222 |
//! Reference to command buffer |
| 223 |
//! \return MOS_STATUS |
| 224 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 225 |
//! |
| 226 |
virtual MOS_STATUS Oca1stLevelBBEnd(MOS_COMMAND_BUFFER &cmdBuffer) { return MOS_STATUS_SUCCESS; }; |
| 227 |
|
| 228 |
//! |
| 229 |
//! \brief Get pipe number |
| 230 |
//! \return Pipe number |
| 231 |
//! |
| 232 |
uint8_t GetPipeNumber() { return m_pipeNum; }; |
| 233 |
|
| 234 |
//! |
| 235 |
//! \brief Get current pipe |
| 236 |
//! \return Current pipe index |
| 237 |
//! |
| 238 |
uint8_t GetCurrentPipe() { return m_currentPipe; }; |
| 239 |
|
| 240 |
//! |
| 241 |
//! \brief Get pass number |
| 242 |
//! \return Pass number |
| 243 |
//! |
| 244 |
uint16_t GetPassNumber() { return m_passNum; }; |
| 245 |
|
| 246 |
//! |
| 247 |
//! \brief Get current pass |
| 248 |
//! \return Current pass index |
| 249 |
//! |
| 250 |
uint16_t GetCurrentPass() { return m_currentPass; }; |
| 251 |
|
| 252 |
//! |
| 253 |
//! \brief Set pass number |
| 254 |
//! \return void |
| 255 |
//! |
| 256 |
void SetPassNumber(uint16_t num) { m_passNum = num; }; |
| 257 |
|
| 258 |
//! |
| 259 |
//! \brief Set pass index |
| 260 |
//! \return void |
| 261 |
//! |
| 262 |
void SetCurrentPassIndex(uint8_t num) { m_currentPass = num; }; |
| 263 |
|
| 264 |
//! |
| 265 |
//! \brief Set pipe number |
| 266 |
//! \return void |
| 267 |
//! |
| 268 |
void SetPipeNumber(uint8_t num) { m_pipeNum = num; }; |
| 269 |
|
| 270 |
//! |
| 271 |
//! \brief Set pipe index |
| 272 |
//! \return void |
| 273 |
//! |
| 274 |
void SetCurrentPipeIndex(uint8_t num) { m_currentPipe = num; }; |
| 275 |
|
| 276 |
uint8_t GetCurrentRow() { return m_currentRow; }; |
| 277 |
|
| 278 |
uint8_t GetCurrentSubPass() { return m_currentSubPass; }; |
| 279 |
|
| 280 |
//! |
| 281 |
//! \brief Get component state |
| 282 |
//! \return point to component state |
| 283 |
//! |
| 284 |
ComponentState *GetComponentState() { return m_componentState; }; |
| 285 |
|
| 286 |
//! |
| 287 |
//! \brief Send Cmd buffer Attributes with frame tracking info |
| 288 |
//! |
| 289 |
//! \param [in] cmdBuffer |
| 290 |
//! Reference to command buffer |
| 291 |
//! \param [in] frameTrackingRequested |
| 292 |
//! Indicate if frame tracking is requested |
| 293 |
//! |
| 294 |
//! \return MOS_STATUS |
| 295 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 296 |
//! |
| 297 |
virtual MOS_STATUS SendAttrWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested) = 0; |
| 298 |
|
| 299 |
//! |
| 300 |
//! \brief Get if frame tracking is enabled from scalability |
| 301 |
//! \return bool |
| 302 |
//! true if enabled, else false |
| 303 |
//! |
| 304 |
bool IsFrameTrackingEnabled() { return m_frameTrackingEnabled; }; |
| 305 |
|
| 306 |
protected: |
| 307 |
//! |
| 308 |
//! \brief Resizes the cmd buffer and patch list with cmd buffer header |
| 309 |
//! |
| 310 |
//! \param [in] requestedCommandBufferSize |
| 311 |
//! Requested resize command buffer size |
| 312 |
//! \param [in] requestedPatchListSize |
| 313 |
//! Requested resize patchlist size |
| 314 |
//! |
| 315 |
//! \return MOS_STATUS |
| 316 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 317 |
//! |
| 318 |
virtual MOS_STATUS ResizeCommandBufferAndPatchList( |
| 319 |
uint32_t requestedCommandBufferSize, |
| 320 |
uint32_t requestedPatchListSize) |
| 321 |
{ |
| 322 |
return MOS_STATUS_SUCCESS; |
| 323 |
} |
| 324 |
|
| 325 |
//! |
| 326 |
//! \brief Verify command buffer |
| 327 |
//! \param [in] requestedSize |
| 328 |
//! requested size for command buffer |
| 329 |
//! \param [in] requestedPatchListSize |
| 330 |
//! requested size for patched list |
| 331 |
//! \param [out] singleTaskPhaseSupportedInPak |
| 332 |
//! Inidcate if to use single task phase in pak. |
| 333 |
//! \return MOS_STATUS |
| 334 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 335 |
//! |
| 336 |
virtual MOS_STATUS VerifySpaceAvailable(uint32_t requestedSize, uint32_t requestedPatchListSize, bool &singleTaskPhaseSupportedInPak); |
| 337 |
|
| 338 |
uint8_t m_currentPipe = 0; //!< Current pipe index |
| 339 |
uint16_t m_currentPass = 0; //!< Current pass index |
| 340 |
|
| 341 |
uint8_t m_pipeNum = 1; //!< Pipe number |
| 342 |
uint16_t m_passNum = 1; //!< Pass number |
| 343 |
bool m_singleTaskPhaseSupported = true; //!< Indicate if single task phase is supported |
| 344 |
uint8_t m_pipeIndexForSubmit = 0; //!< Pipe index to submit cmdbuffer |
| 345 |
|
| 346 |
uint8_t m_currentRow = 0; //!< Current row index when tile replay is enabled |
| 347 |
uint8_t m_currentSubPass = 0; //!< Current tile row pass index when tile replay is enabled |
| 348 |
|
| 349 |
ComponentState *m_componentState = nullptr; //!< Component state |
| 350 |
|
| 351 |
uint8_t m_componentType = 0; |
| 352 |
PMOS_INTERFACE m_osInterface = nullptr; //!< OS interface |
| 353 |
MediaScalabilityOption * m_scalabilityOption = nullptr; |
| 354 |
PMOS_GPUCTX_CREATOPTIONS m_gpuCtxCreateOption = nullptr; //!<For MultiPipe cases, it should be converted to PMOS_GPUCTX_CREATOPTIONS_ENHANCED; |
| 355 |
MediaStatusReport * m_statusReport = nullptr; //!< Media status report ptr |
| 356 |
MediaContext * m_mediaContext = nullptr; //!< Media context ptr |
| 357 |
bool m_attrReady = false; //!< Indicate if cmd buf attribute is ready |
| 358 |
bool m_frameTrackingEnabled = true; //!< Indicate if frame tracking is enabled |
| 359 |
|
| 360 |
PMOS_VIRTUALENGINE_HINT_PARAMS m_veHitParams = nullptr; //!< Virtual Engine hint parameters |
| 361 |
|
| 362 |
MOS_VE_HANDLE m_veState = nullptr; //!< Virtual Engine State |
| 363 |
std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr; |
| 364 |
PMOS_VIRTUALENGINE_INTERFACE m_veInterface = nullptr; //!< Virtual Engine Interface |
| 365 |
|
| 366 |
MEDIA_CLASS_DEFINE_END(MediaScalability) |
| 367 |
}; |
| 368 |
#endif // !__MEDIA_SCALABILITY_H__ |