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 media_mem_decompression_next.h 25 //! \brief Defines the common interface for mmc 26 //! \details 27 //! 28 #ifndef __MEDIA_MEM_DECOMPRESSION_NEXT_H__ 29 #define __MEDIA_MEM_DECOMPRESSION_NEXT_H__ 30 31 #include "mediamemdecomp.h" 32 #include "media_interfaces_mhw_next.h" 33 34 //------------------------------------------------------------------------------ 35 // Macros specific to MOS_VP_SUBCOMP_RENDER sub-comp 36 //------------------------------------------------------------------------------ 37 #define VPHAL_MEMORY_DECOMP_ASSERT(_expr) \ 38 MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _expr) 39 40 #define VPHAL_MEMORY_DECOMP_ASSERTMESSAGE(_message, ...) \ 41 MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__) 42 43 #define VPHAL_MEMORY_DECOMP_NORMALMESSAGE(_message, ...) \ 44 MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__) 45 46 #define VPHAL_MEMORY_DECOMP_VERBOSEMESSAGE(_message, ...) \ 47 MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__) 48 49 #define VPHAL_MEMORY_DECOMP_FUNCTION_ENTER \ 50 MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER) 51 52 #define VPHAL_MEMORY_DECOMP_EXITMESSAGE(_message, ...) \ 53 MOS_DEBUGMESSAGE(MOS_MESSAGE_LVL_FUNCTION_EXIT, MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__) 54 55 #define VPHAL_MEMORY_DECOMP_CHK_STATUS(_stmt) \ 56 MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt) 57 58 #define VPHAL_MEMORY_DECOMP_CHK_STATUS_RETURN(_stmt) \ 59 MOS_CHK_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt) 60 61 #define VPHAL_MEMORY_DECOMP_CHK_STATUS_MESSAGE(_stmt, _message, ...) \ 62 MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt, _message, ##__VA_ARGS__) 63 64 #define VPHAL_MEMORY_DECOMP_CHK_NULL(_ptr) \ 65 MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr) 66 67 #define VPHAL_MEMORY_DECOMP_CHK_NULL_RETURN(_ptr) \ 68 MOS_CHK_NULL_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr) 69 70 #define VPHAL_MEMORY_DECOMP_CHK_NULL_NO_STATUS(_ptr) \ 71 MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr) 72 73 class MediaMemDeCompNext : public MediaMemDecompBaseState 74 { 75 public: 76 77 //! 78 //! \brief Constructor, initiallize 79 //! 80 MediaMemDeCompNext(); 81 82 //! 83 //! \brief Copy constructor 84 //! 85 MediaMemDeCompNext(const MediaMemDeCompNext&) = delete; 86 87 //! 88 //! \brief Copy assignment operator 89 //! 90 MediaMemDeCompNext& operator=(const MediaMemDeCompNext&) = delete; 91 92 //! 93 //! \brief Destructor 94 //! 95 virtual ~MediaMemDeCompNext(); 96 97 //! 98 //! \brief Media memory decompression render 99 //! \details Entry point to decompress media memory 100 //! \param [in] surface 101 //! Input surface will be decompressed 102 //! 103 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 104 //! 105 virtual MOS_STATUS RenderDecompCMD( 106 PMOS_SURFACE surface) = 0; 107 108 //! 109 //! \brief Media memory double buffer decompression render 110 //! \details Entry point to decompress media memory 111 //! \param [in] surface 112 //! Input surface to be copied and decompressed 113 //! \param [out] surface 114 //! Output surface for clear data 115 //! 116 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 117 //! 118 virtual MOS_STATUS RenderDoubleBufferDecompCMD( 119 PMOS_SURFACE inputSurface, 120 PMOS_SURFACE outputSurface) = 0; 121 122 //! 123 //! \brief Media memory decompression 124 //! \details Entry point to decompress media memory 125 //! \param [in] targetResource 126 //! The surface will be decompressed 127 //! 128 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 129 //! 130 virtual MOS_STATUS MemoryDecompress( 131 PMOS_RESOURCE targetResource); 132 133 //! 134 //! \brief Media memory decompression Enabled or not 135 //! \details Media memory decompression Enabled or not 136 //! 137 //! \return true if MMC decompression enabled, else false. 138 //! 139 virtual MOS_STATUS IsVeboxDecompressionEnabled() = 0; 140 141 //! 142 //! \brief Media memory copy 143 //! \details Entry point to copy media memory, input can support both compressed/uncompressed 144 //! \param [in] inputSurface 145 //! The surface resource will be decompressed 146 //! \param [out] outputSurface 147 //! The target uncompressed surface resource will be copied to 148 //! \param [in] outputCompressed 149 //! The surface resource will compressed if true for compressilbe surface 150 //! 151 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 152 //! 153 virtual MOS_STATUS MediaMemoryCopy( 154 PMOS_RESOURCE inputResource, 155 PMOS_RESOURCE outputResource, 156 bool outputCompressed); 157 158 //! 159 //! \brief Media memory copy 2D 160 //! \details Entry point to decompress media memory and copy with byte in unit 161 //! \param [in] inputSurface 162 //! The source surface resource 163 //! \param [out] outputSurface 164 //! The target surface resource will be copied to 165 //! \param [in] copyPitch 166 //! The 2D surface pitch 167 //! \param [in] copyHeight 168 //! The 2D surface height 169 //! \param [in] copyInputOffset 170 //! The offset of copied surface from 171 //! \param [in] copyOutputOffset 172 //! The offset of copied to 173 //! \param [in] bpp 174 //! bit per pixel for copied surfaces 175 //! \param [in] bOutputCompressed 176 //! true means apply compression on output surface, else output uncompressed surface 177 //! 178 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 179 //! 180 virtual MOS_STATUS MediaMemoryCopy2D( 181 PMOS_RESOURCE inputResource, 182 PMOS_RESOURCE outputResource, 183 uint32_t copyPitch, 184 uint32_t copyHeight, 185 uint32_t copyInputOffset, 186 uint32_t copyOutputOffset, 187 uint32_t bpp, 188 bool outputCompressed); 189 190 //! 191 //! \brief Media memory tile convert 192 //! \details Convert media between Tile/Linear with decompression 193 //! \param [in] inputSurface 194 //! The source surface resource 195 //! \param [out] outputSurface 196 //! The target surface resource will be copied to 197 //! \param [in] copyWidth 198 //! The 2D surface Width 199 //! \param [in] copyHeight 200 //! The 2D surface height 201 //! \param [in] copyInputOffset 202 //! The offset of copied surface from 203 //! \param [in] copyOutputOffset 204 //! The offset of copied to 205 //! \param [in] isTileToLinear 206 //! Convertion direction, true: tile->linear, false: linear->tile 207 //! \param [in] outputCompressed 208 //! true means apply compression on output surface, else output uncompressed surface 209 //! 210 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 211 //! 212 virtual MOS_STATUS MediaMemoryTileConvert( 213 PMOS_RESOURCE inputResource, 214 PMOS_RESOURCE outputResource, 215 uint32_t copyWidth, 216 uint32_t copyHeight, 217 uint32_t copyInputOffset, 218 uint32_t copyOutputOffset, 219 bool isTileToLinear, 220 bool outputCompressed); 221 222 //! 223 //! \brief Initialize memory decompress state 224 //! \param [in] osInterface 225 //! Os interface 226 //! \param [in] cpInterface 227 //! CP interface 228 //! \param [in] mhwMiInterface 229 //! Hw MI interface 230 //! \param [in] veboxInterface 231 //! Vebox interface 232 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 233 //! 234 MOS_STATUS Initialize( 235 PMOS_INTERFACE osInterface, 236 MhwInterfacesNext* mhwInterfaces); 237 238 //! 239 //! \brief GetDecompState's mosinterface 240 //! \details get the mosinterface 241 //! \return mosinterface 242 //! GetDecompStateMosInterface()243 virtual PMOS_INTERFACE GetDecompStateMosInterface() 244 { 245 return m_osInterface; 246 } 247 248 protected: 249 250 //! 251 //! \brief Get resource information 252 //! \details Get resource information for the specifc surface 253 //! \param [in] pSurface 254 //! Surface pointer 255 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 256 //! 257 MOS_STATUS GetResourceInfo( 258 PMOS_SURFACE surface); 259 260 //! 261 //! \brief Setup Vebox_Surface_State Command parameter 262 //! \param [in/out] mhwVeboxSurfaceStateCmdParams 263 //! Pointer to VEBOX_SURFACE_STATE command parameters 264 //! \param [in] surface 265 //! Input surface pointer 266 //! \param [in] surface 267 //! output surface pointer 268 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 269 //! 270 MOS_STATUS SetupVeboxSurfaceState( 271 PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS mhwVeboxSurfaceStateCmdParams, 272 PMOS_SURFACE inputSurface, 273 PMOS_SURFACE outputSurface); 274 275 //! 276 //! \brief Get resource information 277 //! \details Get resource information for the specifc surface 278 //! \param [in] cmdBuffer 279 //! CmdBuffer pointer 280 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 281 //! 282 MOS_STATUS InitCommandBuffer( 283 PMOS_COMMAND_BUFFER cmdBuffer); 284 285 //! 286 //! Vebox Send Vebox_Tile_Convert command 287 //! \param [in/out] cmdBuffer 288 //! Pointer to PMOS_COMMAND_BUFFER command parameters 289 //! \param [in] surface 290 //! Pointer to Input Surface parameters 291 //! \param [in] surface 292 //! Pointer to Output Surface parameters 293 //! \param [in] streamID 294 //! Stream ID for current surface 295 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 296 //! 297 virtual MOS_STATUS VeboxSendVeboxTileConvertCMD( 298 PMOS_COMMAND_BUFFER cmdBuffer, 299 PMOS_SURFACE inputSurface, 300 PMOS_SURFACE outputSurface, 301 uint32_t streamID) = 0; 302 303 //! 304 //! Is Vebox Tile Convert/Decompression Format supported 305 //! \param [in/out] surface 306 //! Pointer to Output Surface parameters 307 //! \return true if supported, else false. 308 //! 309 bool IsFormatSupported(PMOS_SURFACE surface); 310 311 enum MEDIA_TILE_TYPE 312 { 313 MEMORY_MEDIACOMPRESSION_ENABLE = 0, 314 MEMORY_RENDERCOMPRESSION_ENABLE, 315 }; 316 317 enum MEDIA_SURFACE_TILE_RESOURCE_MODE 318 { 319 TRMODE_NONE = 0, 320 TRMODE_TILEYF, 321 TRMODE_TILEYS, 322 TRMODE_UNKNOWN, 323 }; 324 325 public: 326 // Add Public Numbers 327 // Interface 328 PMOS_INTERFACE m_osInterface; 329 330 protected: 331 332 // Interface 333 std::shared_ptr<mhw::vebox::Itf> m_veboxItf = nullptr; 334 std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr; 335 MhwCpInterface * m_cpInterface; 336 bool m_veboxMMCResolveEnabled; 337 PMOS_MUTEX m_renderMutex = nullptr; 338 339 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; //!< UserSettingInstance 340 MEDIA_CLASS_DEFINE_END(MediaMemDeCompNext) 341 }; 342 343 #endif //