Debian Codegraph @

media_driver/agnostic/Xe_M/Xe_XPM_plus/shared/renderhal_memdecomp.h

raw
1 /*
2 * Copyright (c) 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 //! \file renderhal_memdecomp.h
24 //! \brief Defines data structures and interfaces for media memory decompression.
25 //! \details
26 //!
27
28 #ifndef __RENDERHAL_MEMDECOMP_H__
29 #define __RENDERHAL_MEMDECOMP_H__
30
31 #include "mhw_render_legacy.h"
32 #include "mos_os.h"
33 #include "mediamemdecomp.h"
34 #include "renderhal_legacy.h"
35
36 //------------------------------------------------------------------------------
37 // Macros specific to MOS_VP_SUBCOMP_RENDER sub-comp
38 //------------------------------------------------------------------------------
39 #define RENDERHAL_MEMORY_DECOMP_ASSERT(_expr) \
40 MOS_ASSERT(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _expr)
41
42 #define RENDERHAL_MEMORY_DECOMP_ASSERTMESSAGE(_message, ...) \
43 MOS_ASSERTMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
44
45 #define RENDERHAL_MEMORY_DECOMP_WARNINGMESSAGE(_message, ...) \
46 MOS_WARNINGMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
47
48 #define RENDERHAL_MEMORY_DECOMP_NORMALMESSAGE(_message, ...) \
49 MOS_NORMALMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
50
51 #define RENDERHAL_MEMORY_DECOMP_VERBOSEMESSAGE(_message, ...) \
52 MOS_VERBOSEMESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
53
54 #define RENDERHAL_MEMORY_DECOMP_FUNCTION_ENTER \
55 MOS_FUNCTION_ENTER(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER)
56
57 #define RENDERHAL_MEMORY_DECOMP_EXITMESSAGE(_message, ...) \
58 MOS_DEBUGMESSAGE(MOS_MESSAGE_LVL_FUNCTION_EXIT, MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _message, ##__VA_ARGS__)
59
60 #define RENDERHAL_MEMORY_DECOMP_CHK_STATUS(_stmt) \
61 MOS_CHK_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt)
62
63 #define RENDERHAL_MEMORY_DECOMP_CHK_STATUS_RETURN(_stmt) \
64 MOS_CHK_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt)
65
66 #define RENDERHAL_MEMORY_DECOMP_CHK_STATUS_MESSAGE(_stmt, _message, ...) \
67 MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _stmt, _message, ##__VA_ARGS__)
68
69 #define RENDERHAL_MEMORY_DECOMP_CHK_NULL(_ptr) \
70 MOS_CHK_NULL(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
71
72 #define RENDERHAL_MEMORY_DECOMP_CHK_NULL_RETURN(_ptr) \
73 MOS_CHK_NULL_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
74
75 #define RENDERHAL_MEMORY_DECOMP_CHK_NULL_NO_STATUS(_ptr) \
76 MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_RENDER, _ptr)
77
78 //!
79 //! \class MediaRenderDecompState
80 //! \brief Media render inplace memory decompression state. This class defines the member fields
81 //! functions etc used by memory decompression.
82 //!
83 class MediaRenderDecompState : public MediaMemDecompBaseState
84 {
85 public:
86
87 //!
88 //! \brief Constructor, initiallize
89 //!
90 MediaRenderDecompState();
91
92 //!
93 //! \brief Copy constructor
94 //!
95 MediaRenderDecompState(const MediaRenderDecompState &) = delete;
96
97 //!
98 //! \brief Copy assignment operator
99 //!
100 MediaRenderDecompState &operator=(const MediaRenderDecompState &) = delete;
101
102 //!
103 //! \brief Destructor
104 //!
105 virtual ~MediaRenderDecompState();
106
107 //!
108 //! \brief Media memory decompression
109 //! \details Entry point to decompress media memory
110 //! \param [in] targetResource
111 //! The surface will be decompressed
112 //!
113 //! \return MOS_STATUS_SUCCESS if succeeded, else error code.
114 //!
115 virtual MOS_STATUS MemoryDecompress(
116 PMOS_RESOURCE targetResource);
117
118
119 //!
120 //! \brief Media memory copy
121 //! \details Entry point to copy media memory, input can support both compressed/uncompressed
122 //! \param [in] inputSurface
123 //! The surface resource will be decompressed
124 //! \param [out] outputSurface
125 //! The target uncompressed surface resource will be copied to
126 //! \param [in] outputCompressed
127 //! The surface resource will compressed if true for compressilbe surface
128 //!
129 //! \return MOS_STATUS_SUCCESS if succeeded, else error code.
130 //!
131 virtual MOS_STATUS MediaMemoryCopy(
132 PMOS_RESOURCE inputResource,
133 PMOS_RESOURCE outputResource,
134 bool outputCompressed);
135
136 //!
137 //! \brief Media memory copy 2D
138 //! \details Entry point to decompress media memory and copy with byte in unit
139 //! \param [in] inputSurface
140 //! The source surface resource
141 //! \param [out] outputSurface
142 //! The target surface resource will be copied to
143 //! \param [in] copyWidth
144 //! The 2D surface Width
145 //! \param [in] copyHeight
146 //! The 2D surface height
147 //! \param [in] copyInputOffset
148 //! The offset of copied surface from
149 //! \param [in] copyOutputOffset
150 //! The offset of copied to
151 //! \param [in] bpp
152 //! bit per pixel for copied surfaces
153 //! \param [in] bOutputCompressed
154 //! true means apply compression on output surface, else output uncompressed surface
155 //!
156 //! \return MOS_STATUS_SUCCESS if succeeded, else error code.
157 //!
158 virtual MOS_STATUS MediaMemoryCopy2D(
159 PMOS_RESOURCE inputResource,
160 PMOS_RESOURCE outputResource,
161 uint32_t copyWidth,
162 uint32_t copyHeight,
163 uint32_t copyInputOffset,
164 uint32_t copyOutputOffset,
165 uint32_t bpp,
166 bool bOutputCompressed);
167
168 //!
169 //! \brief Initialize memory decompress state
170 //! \param [in] osInterface
171 //! Os interface
172 //! \param [in] cpInterface
173 //! CP interface
174 //! \param [in] mhwMiInterface
175 //! Hw MI interface
176 //! \param [in] MhwRenderInterface
177 //! Hw render interface
178 //! \return MOS_STATUS_SUCCESS if succeeded, else error code.
179 //!
180 MOS_STATUS Initialize(
181 PMOS_INTERFACE osInterface,
182 MhwCpInterface *cpInterface,
183 PMHW_MI_INTERFACE mhwMiInterface,
184 MhwRenderInterface *renderInterface);
185
186 virtual PMOS_INTERFACE GetDecompStateMosInterface()
187 {
188 return m_osInterface;
189 }
190 protected:
191 PMOS_INTERFACE m_osInterface = nullptr;
192 PMHW_MI_INTERFACE m_mhwMiInterface = nullptr;
193 MhwCpInterface *m_cpInterface = nullptr;
194 MhwRenderInterface *m_renderInterface = nullptr;
195 };
196
197 #endif // __RENDERHAL_MEMDECOMP_H__