Debian Codegraph @

media_softlet/agnostic/common/shared/mmc/media_mem_decompression_next.h

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