Debian Codegraph @

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

raw
1 /*
2 * Copyright (c) 2018-2024, 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_pipeline_common.h
24 //! \brief Defines the common interface for vp pipeline
25 //! this file is for the base interface which is shared by all features/vp Pipelines.
26 //!
27 #ifndef __VP_PIPELINE_COMMON_H__
28 #define __VP_PIPELINE_COMMON_H__
29
30 #include "mos_utilities.h"
31 #include "vp_common.h"
32 #include "renderhal.h"
33 #include "vp_base.h"
34
35 namespace vp
36 {
37 class VpPlatformInterface;
38 class VpUserFeatureControl;
39 }
40
41 using VP_PIPELINE_PARAMS = VPHAL_RENDER_PARAMS;
42 using PVP_PIPELINE_PARAMS = VPHAL_RENDER_PARAMS*;
43 using PCVP_PIPELINE_PARAMS = const VPHAL_RENDER_PARAMS*;
44
45 //!
46 //! \brief Flags for update/copy/FMD kernels
47 //!
48 #define VP_VEBOX_FLAG_ENABLE_KERNEL_COPY 0x00000001
49 #define VP_VEBOX_FLAG_ENABLE_KERNEL_COPY_DEBUG 0x00000002
50 #define VP_VEBOX_FLAG_ENABLE_KERNEL_DN_UPDATE 0x00000004
51 #define VP_VEBOX_FLAG_ENABLE_KERNEL_DN_UPDATE_DEBUG 0x00000008
52 #define VP_VEBOX_FLAG_ENABLE_KERNEL_FMD_SUMMATION 0x00000010
53
54 #define RESOURCE_ASSIGNMENT_HINT_BITS_DI \
55 uint32_t bDi : 1; \
56 uint32_t b60fpsDi : 1;
57
58 #define RESOURCE_ASSIGNMENT_HINT_BITS_SCALING \
59 uint32_t isIScalingTypeNone : 1; \
60 uint32_t isFieldWeaving : 1;
61
62 #define RESOURCE_ASSIGNMENT_HINT_BITS_HDR \
63 uint32_t is3DLut2DNeeded : 1;
64
65 #define RESOURCE_ASSIGNMENT_HINT_BITS_DENOISE \
66 uint32_t isHVSTableNeeded : 1;
67
68 #define RESOURCE_ASSIGNMENT_HINT_BITS_STD_ALONE \
69 uint32_t isSkinScoreDumpNeededForSTDonly : 1; \
70 uint32_t isSkinScoreOutputNeededForSTDOnly : 1;
71
72 #define RESOURCE_ASSIGNMENT_HINT_BITS \
73 RESOURCE_ASSIGNMENT_HINT_BITS_DI \
74 RESOURCE_ASSIGNMENT_HINT_BITS_SCALING \
75 RESOURCE_ASSIGNMENT_HINT_BITS_HDR \
76 RESOURCE_ASSIGNMENT_HINT_BITS_DENOISE \
77 RESOURCE_ASSIGNMENT_HINT_BITS_STD_ALONE
78
79 #define RESOURCE_ASSIGNMENT_HINT_SIZE 4
80
81 //!
82 //! \brief Enumeration for the user feature key "Bypass Composition" values
83 //!
84 typedef enum _VPHAL_COMP_BYPASS_MODE
85 {
86 VPHAL_COMP_BYPASS_NOT_SET = 0xffffffff,
87 VPHAL_COMP_BYPASS_DISABLED = 0x0,
88 VPHAL_COMP_BYPASS_ENABLED = 0x1,
89 VPHAL_COMP_BYPASS_DEFAULT = 0x2
90 } VPHAL_COMP_BYPASS_MODE, *PVPHAL_COMP_BYPASS_MODE;
91
92 //!
93 //! \brief VP CTRL enum
94 //!
95 typedef enum _VP_CTRL
96 {
97 VP_CTRL_DISABLE = 0,
98 VP_CTRL_ENABLE,
99 VP_CTRL_DEFAULT
100 } VP_CTRL;
101
102 struct VP_SURFACE
103 {
104 MOS_SURFACE *osSurface = nullptr; //!< mos surface
105 bool isResourceOwner = false; //!< true if the resource is owned by current instance.
106 VPHAL_CSPACE ColorSpace = CSpace_None; //!< Color Space
107 uint32_t ChromaSiting = 0; //!< ChromaSiting
108
109 bool bQueryVariance = false; //!< enable variance query. Not in use for internal surface
110 int32_t FrameID = 0; //!< Not in use for internal surface
111 bool ExtendedGamut = false; //!< Extended Gamut Flag. Not in use for internal surface
112 VPHAL_PALETTE Palette = {}; //!< Palette data. Not in use for internal surface
113 VPHAL_SURFACE_TYPE SurfType = SURF_NONE; //!< Surface type (context). Not in use for internal surface
114 uint32_t uFwdRefCount = 0; //!< Not in use for internal surface
115 uint32_t uBwdRefCount = 0; //!< Not in use for internal surface
116 VPHAL_SURFACE *pFwdRef = nullptr; //!< Use VP_SURFACE instead of VPHAL_SURFACE later. Not in use for internal surface.
117 VPHAL_SURFACE *pBwdRef = nullptr; //!< Use VP_SURFACE instead of VPHAL_SURFACE later. Not in use for internal surface.
118 VPHAL_SAMPLE_TYPE SampleType = SAMPLE_PROGRESSIVE; //!< Interlaced/Progressive sample type.
119 // Use index of m_InputSurfaces for layerID. No need iLayerID here anymore.
120 RECT rcSrc = {0, 0, 0, 0}; //!< Source rectangle
121 RECT rcDst = {0, 0, 0, 0}; //!< Destination rectangle
122 RECT rcMaxSrc = {0, 0, 0, 0}; //!< Max source rectangle
123 bool bVEBOXCroppingUsed = false; //!<Vebox crop case need use rcSrc as vebox input.
124 uint32_t bufferWidth = 0; //!< 1D buffer Width, n/a if 2D surface
125 uint32_t bufferHeight = 0; //!< 1D buffer Height, n/a if 2D surface
126
127 //NPU L0 Info
128 void *zeNpuHostMem = nullptr;
129
130 // Return true if no resource assigned to current vp surface.
131 bool IsEmpty();
132 // Clean the vp surface to empty state. Only valid for false == isResourceOwner case.
133 MOS_STATUS Clean();
134
135 // Get Allocation Handle of resource
136 uint64_t GetAllocationHandle(MOS_INTERFACE *osIntf);
137 };
138
139 struct _VP_SETTINGS
140 {
141 // For validation purpose settings
142 uint32_t disableDnDi = 0; //!< Disable DNDI(Vebox)
143 uint32_t kernelUpdate = 0; //!< For VEBox Copy and Update kernels
144 uint32_t disableHdr = 0; //!< Disable Hdr
145 uint32_t veboxParallelExecution = 0; //!< Control VEBox parallel execution with render engine
146 bool clearVideoViewMode = 0; //!< Perf Optimize for ClearVideoView DDI
147 };
148
149 using VP_SETTINGS = _VP_SETTINGS;
150
151 // To define the features enabling on different engines
152 struct _VP_EXECUTE_CAPS
153 {
154 union {
155 struct {
156 uint64_t bVebox : 1; // Vebox needed
157 uint64_t bSFC : 1; // SFC needed
158 uint64_t bRender : 1; // Render Only needed
159 uint64_t bNpu : 1; // Npu Only Needed
160 uint64_t bSecureVebox : 1; // Vebox in Secure Mode
161 uint64_t bRenderHdr : 1; // Render HDR in use
162
163 uint64_t bOutputPipeFeatureInuse : 1; // Output surface of pipeline is in use.
164 uint64_t bForceCscToRender : 1; // If true, force to use render for csc.
165 uint64_t bForceProcampToRender : 1; // If true, force to use render for procamp.
166 uint64_t lastSubmission : 1; // If true, it's the last submission of current DDI.
167 uint64_t bTemperalInputInuse : 1; // If true, will use temperal input instead of input
168
169 // Vebox Features
170 uint64_t bDN : 1; // Vebox DN needed
171 uint64_t bDI : 1; // Vebox DI enabled
172 uint64_t bDiProcess2ndField : 1; // Vebox DI enabled
173 uint64_t bDIFmdKernel : 1; // Vebox FMD Kernel enabled
174 uint64_t bIECP : 1; // Vebox IECP needed
175 uint64_t bSTE : 1; // Vebox STE or Vebox STD_alone needed
176 uint64_t bACE : 1; // Vebox ACE needed
177 uint64_t bTCC : 1; // Vebox TCC needed
178 uint64_t bCGC : 1; // Vebox CGC needed
179 uint64_t bBt2020ToRGB : 1; // Vebox Bt2020 gamut compression to RGB format
180 uint64_t bProcamp : 1; // Vebox Procamp needed
181 uint64_t bBeCSC : 1; // Vebox back end CSC needed
182 uint64_t bFeCSC : 1; // Vebox front end CSC needed
183 uint64_t bLACE : 1; // Vebox LACE Needed
184 uint64_t bQueryVariance : 1;
185 uint64_t bRefValid : 1; // Vebox Ref is Valid
186 uint64_t bSTD : 1; // Vebox LACE STD Needed
187 uint64_t bDnKernelUpdate: 1;
188 uint64_t bVeboxSecureCopy : 1;
189 uint64_t bHDR3DLUT : 1; // Vebox 3DLUT needed
190 uint64_t bH2S : 1; // Vebox 3DLUT H2S Mode
191 uint64_t b1K1DLutInited : 1;
192 uint64_t bDV : 1;
193 uint64_t b3DlutOutput : 1;
194 uint64_t bHdr33lutsize : 1;
195 uint64_t bLutCompound : 1; // Vebox LUT Compound (CSC + 1DLUT + 3DLUT) needed
196 uint64_t bCappipe : 1;
197 uint64_t bLgca : 1;
198 uint64_t bFDFB : 1;
199 uint64_t bColorBalance : 1;
200 uint64_t b1K1DLutInUse : 1;
201 uint64_t bCcmCsc : 1;
202 uint64_t bDemosaicInUse : 1;
203 uint64_t enableSFCLinearOutputByTileConvert : 1; //true if do tileconvert from tileF to linear for SFC linear output
204
205 // SFC features
206 uint64_t bSfcCsc : 1; // Sfc Csc enabled
207 uint64_t bSfcRotMir : 1; // Sfc Rotation/Mirror needed
208 uint64_t bSfcScaling : 1; // Sfc Scaling Needed
209 uint64_t bSfcIef : 1; // Sfc Details Needed
210 uint64_t b1stPassOfSfc2PassScaling : 1; // 1st pass of sfc 2pass scaling
211
212 // Render Features
213 uint64_t bComposite : 1;
214 uint64_t bSR : 1;
215 uint64_t b3DLutCalc : 1;
216 uint64_t bHVSCalc : 1;
217 uint64_t bSegmentation : 1;
218 uint64_t bHdr : 1;
219 uint64_t bFallbackLegacyFC : 1; // only valid when vpUserFeatureControl->EnableOclFC() is true
220 uint64_t forceBypassWorkload : 1; // If true, force to bypass workload.
221
222 //Render or NPU
223 uint64_t bAiPath : 1; // if ture, it will walk into ai common filter to execute a series of ai sub kernels
224 };
225 uint64_t value;
226 };
227 };
228
229 C_ASSERT(sizeof(_VP_EXECUTE_CAPS) == sizeof(uint64_t));
230
231 typedef struct _VP_EngineEntry
232 {
233 union
234 {
235 struct
236 {
237 // set by GetXxxExecuteCaps
238 uint64_t bEnabled : 1;
239 uint64_t SfcNeeded : 1;
240 uint64_t VeboxNeeded : 1;
241 uint64_t RenderNeeded : 1;
242 uint64_t npuNeeded : 1;
243 uint64_t hdrKernelNeeded : 1;
244 uint64_t fcSupported : 1; // Supported by fast composition
245 uint64_t hdrKernelSupported : 1; // Supported by Hdr Kenrel
246 uint64_t isolated : 1; // Only support single feature.
247 uint64_t bt2020ToRGB : 1; // true if bt2020 to rgb
248 uint64_t is1K1DLutSurfaceInUse : 1; // 1K1DLut surface in use
249 uint64_t isHdr33LutSizeEnabled : 1;
250 uint64_t isH2S : 1; //Vebox 3DLut H2S
251 uint64_t isBayerInputInUse : 1;
252 uint64_t frontEndCscNeeded : 1; // true if use vebox front end csc to do output csc feature instead of using backendcsc + sfc. Only using it when no scaling needed
253 uint64_t forceLegacyFC : 1; // true if OCL FC not support the format, fall back to legacy FC
254
255 // set by GetXxxPipeEnginCaps
256 uint64_t bypassIfVeboxSfcInUse : 1; // Bypass the feature if vebox or sfc in use. In such case, VeboxNeeded and
257 // SfcNeeded are 0 but it should not block vebox or sfc being selected.
258 uint64_t forceEnableForSfc : 1; // Force enabled when sfc being selected.
259 uint64_t forceEnableForFc : 1; // Force enabled when fc being selected.
260 uint64_t forceEnableForHdrKernel : 1;
261 uint64_t nonFcFeatureExists : 1; // The feature exists, which do not support fc
262 uint64_t nonVeboxFeatureExists : 1; // The feature exists, which do not support vebox
263 uint64_t fcOnlyFeatureExists : 1; // The feature exists, which only support render fc, and not support vebox/sfc.
264 uint64_t multiPassNeeded : 1; // If true, multi-pass for frame processing is needed.
265 uint64_t VeboxARGBOut : 1;
266 uint64_t VeboxARGB10bitOutput : 1;
267 uint64_t VeboxIECPNeeded : 1;
268 uint64_t bypassVeboxFeatures : 1;
269 uint64_t diProcess2ndField : 1;
270 uint64_t sfc2PassScalingNeededX : 1;
271 uint64_t sfc2PassScalingNeededY : 1;
272 uint64_t usedForNextPass : 1; // true if current feature should be bypassed for current pass and be processed during next pass.
273 uint64_t sfcNotSupported : 1; // true if sfc cannot be selected.
274 uint64_t veboxNotSupported : 1; // true if vebox cannot be selected.
275 uint64_t isOutputPipeNeeded : 1; // true if the feature is used for parameter calculation.
276 uint64_t sfcOnlyFeatureExists : 1; // The feature exists, which only support sfc.
277 uint64_t bTemperalInputInuse : 1; // true if replace input
278 uint64_t outputWithLumaKey : 1;
279 uint64_t enableSFCLinearOutputByTileConvert : 1; //true if do tileconvert from tileF to linear for SFC linear output
280 uint64_t forceBypassWorkload : 1; // If true, force to bypass workload.
281 };
282 uint64_t value;
283 };
284 }VP_EngineEntry;
285
286 C_ASSERT(sizeof(_VP_EngineEntry) == sizeof(uint64_t));
287
288 enum _VP_PACKET_ENGINE
289 {
290 VP_PACKET_COMP = 0,
291 VP_PACKET_VEBOX,
292 };
293
294 enum VP_RGB_OUTPUT_OVERRIDE_ID
295 {
296 VP_RGB_OUTPUT_OVERRIDE_ID_INVALID = 0,
297 VP_RGB_OUTPUT_OVERRIDE_ID_RGBP_LINEAR,
298 VP_RGB_OUTPUT_OVERRIDE_ID_RGBP_TILE,
299 VP_RGB_OUTPUT_OVERRIDE_ID_RGB24LINEAR,
300 VP_RGB_OUTPUT_OVERRIDE_ID_BGRP_LINEAR,
301 VP_RGB_OUTPUT_OVERRIDE_ID_BGRP_TILE,
302 VP_RGB_OUTPUT_OVERRIDE_ID_MAX,
303 };
304
305 typedef enum _VP_COMP_BYPASS_MODE
306 {
307 VP_COMP_BYPASS_NOT_SET = 0xffffffff,
308 VP_COMP_BYPASS_DISABLED = 0x0,
309 VP_COMP_BYPASS_ENABLED = 0x1
310 } VP_COMP_BYPASS_MODE, * PVP_COMP_BYPASS_MODE;
311
312 // RESOURCE_ASSIGNMENT_HINT are feature parameters which will affect resource assignment.
313 // For caps existing in VP_EXECUTE_CAPS, they should not be added to RESOURCE_ASSIGNMENT_HINT.
314 union RESOURCE_ASSIGNMENT_HINT
315 {
316 struct
317 {
318 RESOURCE_ASSIGNMENT_HINT_BITS;
319 };
320 uint32_t value[RESOURCE_ASSIGNMENT_HINT_SIZE];
321 };
322
323 using VP_EXECUTE_CAPS = _VP_EXECUTE_CAPS;
324 using VP_PACKET_ENGINE = _VP_PACKET_ENGINE;
325 using PVP_SURFACE = VP_SURFACE*;
326
327 inline bool IsVeboxFeatureInuse(VP_EXECUTE_CAPS &caps)
328 {
329 return (caps.bVebox && (!caps.bSFC || caps.bDN || caps.bDI || caps.bIECP || caps.bSTE ||
330 caps.bACE || caps.bTCC || caps.bBeCSC || caps.bQueryVariance || caps.bLACE || caps.bSTD ||
331 caps.bHDR3DLUT || caps.bDV));
332 }
333
334 #endif