Debian Codegraph @

media_softlet/agnostic/common/vp/hal/pipeline/vp_packet_reuse_manager.h

raw
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 //! \file vp_packet_reuse_manager.h
24 //! \brief Defines the classes for vp packet reuse
25 //! this file is for the base interface which is shared by all features.
26 //!
27
28 #ifndef __VP_PACKET_REUSE_MANAGER_H__
29 #define __VP_PACKET_REUSE_MANAGER_H__
30
31 #include "mos_defs.h"
32 #include "media_class_trace.h"
33 #include "sw_filter.h"
34 #include "vp_packet_pipe.h"
35
36 namespace vp
37 {
38
39 class VpCmdPacket;
40 class PacketPipeFactory;
41 class Policy;
42 class PacketPipe;
43 class SwFilterPipe;
44 class VpResourceManager;
45
46 class VpFeatureReuseBase
47 {
48 public:
49 virtual ~VpFeatureReuseBase();
50 virtual MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
51 virtual MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
52
53 MOS_STATUS HandleNullSwFilter(bool reusableOfLastPipe, bool &isPacketPipeReused, SwFilter *filter, bool &ignoreUpdateFeatureParams)
54 {
55 if (filter == nullptr)
56 {
57 if (!reusableOfLastPipe || m_paramsAvailable)
58 {
59 isPacketPipeReused = false;
60 }
61 m_paramsAvailable = false;
62 ignoreUpdateFeatureParams = true;
63 }
64 else if (reusableOfLastPipe && m_paramsAvailable)
65 {
66 m_paramsAvailable = true;
67 }
68 else
69 {
70 isPacketPipeReused = false;
71 m_paramsAvailable = true;
72 }
73
74 return MOS_STATUS_SUCCESS;
75 }
76
77 protected:
78 bool m_paramsAvailable = true;
79 MEDIA_CLASS_DEFINE_END(vp__VpFeatureReuseBase)
80 };
81
82 class VpScalingReuse : public VpFeatureReuseBase
83 {
84 public:
85 VpScalingReuse();
86 virtual ~VpScalingReuse();
87
88 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
89
90 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
91
92 protected:
93 MOS_STATUS UpdateFeatureParams(FeatureParamScaling &params);
94
95 FeatureParamScaling m_params = {};
96 VPHAL_COLORFILL_PARAMS m_colorFillParams = {}; //!< ColorFill - BG only
97 VPHAL_ALPHA_PARAMS m_compAlpha = {}; //!< Alpha for composited surfaces
98
99 MEDIA_CLASS_DEFINE_END(vp__VpScalingReuse)
100 };
101
102 class VpCscReuse : public VpFeatureReuseBase
103 {
104 public:
105 VpCscReuse();
106 virtual ~VpCscReuse() ;
107
108 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
109
110 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
111
112 protected:
113 MOS_STATUS UpdateFeatureParams(FeatureParamCsc &params);
114
115 FeatureParamCsc m_params = {};
116 VPHAL_ALPHA_PARAMS m_alphaParams = {}; //!< Alpha for composited surfaces
117 VPHAL_IEF_PARAMS m_iefParams = {};
118
119 MEDIA_CLASS_DEFINE_END(vp__VpCscReuse)
120 };
121
122 class VpRotMirReuse : public VpFeatureReuseBase
123 {
124 public:
125 VpRotMirReuse();
126 virtual ~VpRotMirReuse();
127 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
128
129 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
130
131 protected:
132 MOS_STATUS UpdateFeatureParams(FeatureParamRotMir &params);
133 FeatureParamRotMir m_params = {};
134
135 MEDIA_CLASS_DEFINE_END(vp__VpRotMirReuse)
136 };
137
138 class VpColorFillReuse : public VpFeatureReuseBase
139 {
140 public:
141 VpColorFillReuse();
142 virtual ~VpColorFillReuse();
143 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
144 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
145 protected:
146 MOS_STATUS UpdateFeatureParams(FeatureParamColorFill &params);
147
148 FeatureParamColorFill m_params = {};
149 VPHAL_COLORFILL_PARAMS m_colorFillParams = {};
150
151 MEDIA_CLASS_DEFINE_END(vp__VpColorFillReuse)
152 };
153
154 class VpAlphaReuse : public VpFeatureReuseBase
155 {
156 public:
157 VpAlphaReuse();
158 virtual ~VpAlphaReuse();
159 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
160 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
161
162 protected:
163 MOS_STATUS UpdateFeatureParams(FeatureParamAlpha &params);
164
165 FeatureParamAlpha m_params = {};
166 VPHAL_ALPHA_PARAMS m_compAlpha = {};
167
168 MEDIA_CLASS_DEFINE_END(vp__VpAlphaReuse)
169 };
170
171 class VpDenoiseReuse : public VpFeatureReuseBase
172 {
173 public:
174 VpDenoiseReuse();
175 virtual ~VpDenoiseReuse();
176 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
177 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
178
179 protected:
180 MOS_STATUS UpdateFeatureParams(FeatureParamDenoise &params);
181
182 FeatureParamDenoise m_params = {};
183
184 MEDIA_CLASS_DEFINE_END(vp__VpDenoiseReuse)
185 };
186
187 class VpTccReuse : public VpFeatureReuseBase
188 {
189 public:
190 VpTccReuse();
191 virtual ~VpTccReuse();
192 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
193 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
194
195 protected:
196 MOS_STATUS UpdateFeatureParams(FeatureParamTcc &params);
197
198 FeatureParamTcc m_params = {};
199
200 MEDIA_CLASS_DEFINE_END(vp__VpTccReuse)
201 };
202
203 class VpSteReuse : public VpFeatureReuseBase
204 {
205 public:
206 VpSteReuse();
207 virtual ~VpSteReuse();
208 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
209 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
210
211 protected:
212 MOS_STATUS UpdateFeatureParams(FeatureParamSte &params);
213
214 FeatureParamSte m_params = {};
215
216 MEDIA_CLASS_DEFINE_END(vp__VpSteReuse)
217 };
218
219 class VpProcampReuse : public VpFeatureReuseBase
220 {
221 public:
222 VpProcampReuse();
223 virtual ~VpProcampReuse();
224 MOS_STATUS UpdateFeatureParams(bool reusable, bool &reused, SwFilter *filter);
225 MOS_STATUS UpdatePacket(SwFilter *filter, VpCmdPacket *packet);
226
227 protected:
228 MOS_STATUS UpdateFeatureParams(FeatureParamProcamp &params);
229
230 FeatureParamProcamp m_params = {};
231 VPHAL_PROCAMP_PARAMS m_procampParams = {};
232
233 MEDIA_CLASS_DEFINE_END(vp__VpProcampReuse)
234 };
235
236 class VpPacketReuseManager
237 {
238 public:
239 VpPacketReuseManager(PacketPipeFactory &packetPipeFactory, VpUserFeatureControl &userFeatureControl);
240 virtual ~VpPacketReuseManager();
241 virtual MOS_STATUS RegisterFeatures();
242 virtual MOS_STATUS PreparePacketPipeReuse(SwFilterPipe *&swFilterPipes, Policy &policy, VpResourceManager &resMgr, bool &isPacketPipeReused, bool &isTeamsWL);
243 // Be called for not reused case before packet pipe execution.
244 virtual MOS_STATUS UpdatePacketPipeConfig(PacketPipe *&pipe);
245 PacketPipe *GetPacketPipeReused()
246 {
247 return m_pipeReused;
248 }
249
250 protected:
251 virtual void ReturnPacketPipeReused();
252
253 protected:
254 bool m_reusable = false; // Current parameter can be reused.
255 PacketPipe *m_pipeReused = nullptr;
256 std::map<FeatureType, VpFeatureReuseBase *> m_features;
257 PacketPipeFactory &m_packetPipeFactory;
258 bool m_disablePacketReuse = false;
259 MEDIA_CLASS_DEFINE_END(vp__VpPacketReuseManager)
260 };
261
262 } // namespace vp
263
264 #endif