Debian Codegraph @

media_driver/agnostic/common/vp/hal/vphal_render_vebox_memdecomp.h

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