| 1 |
/* |
| 2 |
* Copyright (c) 2018, 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 codechal_encode_scalability.h |
| 24 |
//! \brief Defines the encode interface extension for scalability. |
| 25 |
//! \details Defines all types, macros, and functions required by CodecHal for virtual engine encode supporting both single pipe and scalable mode. Definitions are not externally facing. |
| 26 |
//! |
| 27 |
|
| 28 |
#ifndef __CODECHAL_ENCODER_SCALABILITY_H__ |
| 29 |
#define __CODECHAL_ENCODER_SCALABILITY_H__ |
| 30 |
|
| 31 |
#include "codechal_encoder_base.h" |
| 32 |
#include "mos_os_virtualengine_scalability.h" |
| 33 |
|
| 34 |
typedef struct _CODECHAL_ENCODE_SCALABILITY_SETHINT_PARMS |
| 35 |
{ |
| 36 |
bool bSameEngineAsLastSubmission; |
| 37 |
bool bNeedSyncWithPrevious; |
| 38 |
MOS_RESOURCE veBatchBuffer[MOS_MAX_ENGINE_INSTANCE_PER_CLASS]; // Remove once Encode moves to using secondary command buffers in MOS VE interface |
| 39 |
}CODECHAL_ENCODE_SCALABILITY_SETHINT_PARMS, *PCODECHAL_ENCODE_SCALABILITY_SETHINT_PARMS; |
| 40 |
|
| 41 |
typedef struct _CODECHAL_ENCODE_SCALABILITY_STATE |
| 42 |
{ |
| 43 |
CodechalHwInterface *pHwInterface; |
| 44 |
uint8_t ucScalablePipeNum; |
| 45 |
MOS_GPU_CONTEXT VideoContextScalable; // Remove once legacy/ new GPU context class support context re-use |
| 46 |
MOS_GPU_CONTEXT VideoContextSinglePipe; // Remove once legacy/ new GPU context class support context re-use |
| 47 |
|
| 48 |
//Virtual Engine related |
| 49 |
PMOS_VIRTUALENGINE_INTERFACE pVEInterface; |
| 50 |
PMOS_VIRTUALENGINE_HINT_PARAMS pScalHintParms; |
| 51 |
PMOS_VIRTUALENGINE_HINT_PARAMS pSingleHintParms; |
| 52 |
|
| 53 |
}CODECHAL_ENCODE_SCALABILITY_STATE, *PCODECHAL_ENCODE_SCALABILITY_STATE; |
| 54 |
|
| 55 |
//! |
| 56 |
//! \brief switch gpu context in scalability encode mode |
| 57 |
//! \param [in] pScalabilityState |
| 58 |
//! Scalability encode state |
| 59 |
//! \return MOS_STATUS |
| 60 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 61 |
//! |
| 62 |
MOS_STATUS CodecHalEncodeScalability_SwitchGpuContext( |
| 63 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalabilityState); |
| 64 |
|
| 65 |
//! |
| 66 |
//! \brief State initialization for virtual engine encode supporting scalable and single pipe mode |
| 67 |
//! \param [in] pScalabilityState |
| 68 |
//! Scalability encode state |
| 69 |
//! \return MOS_STATUS |
| 70 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 71 |
//! |
| 72 |
MOS_STATUS CodecHalEncodeScalability_InitializeState( |
| 73 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalabilityState, |
| 74 |
CodechalHwInterface *hwInterface); |
| 75 |
|
| 76 |
//! |
| 77 |
//! \brief Initiliaze Encode Parameters for virtual engine encode |
| 78 |
//! \details Initiliaze encode parameters for virtual engine encode. this is for encoder supporting scalability but not necessarily always running in scalable mode |
| 79 |
//! \param [in] pScalabilityState |
| 80 |
//! Scalability encode state |
| 81 |
//! \param [in] pucDecPassNum |
| 82 |
//! pointer to encode pass number |
| 83 |
//! \return MOS_STATUS |
| 84 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 85 |
//! |
| 86 |
MOS_STATUS CodecHalEncodeScalability_InitScalableParams( |
| 87 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalabilityState, |
| 88 |
uint8_t *pucDecPassNum); |
| 89 |
|
| 90 |
//! |
| 91 |
//! \brief Set virtual engine hint parameters for scalable encode |
| 92 |
//! \param [in] pScalabilityState |
| 93 |
//! Scalability encode state |
| 94 |
//! \param [in] pSetHintParms |
| 95 |
//! pointer to set hint parameter |
| 96 |
//! \return MOS_STATUS |
| 97 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 98 |
//! |
| 99 |
MOS_STATUS CodecHalEncodeScalability_SetHintParams( |
| 100 |
CodechalEncoderState *pEncoder, |
| 101 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalabilityState, |
| 102 |
PCODECHAL_ENCODE_SCALABILITY_SETHINT_PARMS pSetHintParms); |
| 103 |
|
| 104 |
//! |
| 105 |
//! \brief Populate virtual engine hint parameters |
| 106 |
//! \details Populate virtual engine hint parameters. Support both scalable and single pipe encode mode. |
| 107 |
//! \param [in] pScalabilityState |
| 108 |
//! Scalability encode state |
| 109 |
//! \param [in] pPrimCmdBuf |
| 110 |
//! pointer to primary cmd buffer |
| 111 |
//! \return MOS_STATUS |
| 112 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 113 |
//! |
| 114 |
MOS_STATUS CodecHalEncodeScalability_PopulateHintParams( |
| 115 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalabilityState, |
| 116 |
PMOS_COMMAND_BUFFER pPrimCmdBuf); |
| 117 |
|
| 118 |
//! \brief construct gpu context creation options when scalability supported |
| 119 |
//! \param [in] scalabilityState |
| 120 |
//! Scalability encode state |
| 121 |
//! \param [in] gpuCtxCreatOptions |
| 122 |
//! pointer to gpu context creation options |
| 123 |
//! \return MOS_STATUS |
| 124 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 125 |
//! |
| 126 |
MOS_STATUS CodechalEncodeScalability_ConstructParmsForGpuCtxCreation( |
| 127 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalState, |
| 128 |
PMOS_GPUCTX_CREATOPTIONS_ENHANCED gpuCtxCreatOpts); |
| 129 |
|
| 130 |
//! \brief Check if need to recreate gpu context and if yes, do it. |
| 131 |
//! \param [in] scalabilityState |
| 132 |
//! Scalability encode state |
| 133 |
//! \param [in] gpuCtxCreatOptions |
| 134 |
//! pointer to gpu context creation options |
| 135 |
//! \return MOS_STATUS |
| 136 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 137 |
//! |
| 138 |
MOS_STATUS CodechalEncodeScalability_ChkGpuCtxReCreation( |
| 139 |
CodechalEncoderState *pEncoder, |
| 140 |
PCODECHAL_ENCODE_SCALABILITY_STATE pScalabilityState, |
| 141 |
PMOS_GPUCTX_CREATOPTIONS_ENHANCED CurgpuCtxCreatOpts); |
| 142 |
|
| 143 |
//! |
| 144 |
//! \brief Convert Encode Phase to Batch Buffer Submission Type |
| 145 |
//! \param [in] isFirstPipe |
| 146 |
//! Is it the fist pipe? |
| 147 |
//! \param [in] pCmdBuffer |
| 148 |
//! Pointer to command buffer |
| 149 |
//! \return void |
| 150 |
//! void |
| 151 |
//! |
| 152 |
void CodecHalEncodeScalability_EncodePhaseToSubmissionType( |
| 153 |
bool isFirstPipe, |
| 154 |
PMOS_COMMAND_BUFFER pCmdBuffer); |
| 155 |
#endif //__CODECHAL_ENCODER_SCALABILITY_H__ |