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 struct VP_SURFACE
93 {
94 MOS_SURFACE *osSurface = nullptr; //!< mos surface
95 bool isResourceOwner = false; //!< true if the resource is owned by current instance.
96 VPHAL_CSPACE ColorSpace = CSpace_None; //!< Color Space
97 uint32_t ChromaSiting = 0; //!< ChromaSiting
98
99 bool bQueryVariance = false; //!< enable variance query. Not in use for internal surface
100 int32_t FrameID = 0; //!< Not in use for internal surface
101 bool ExtendedGamut = false; //!< Extended Gamut Flag. Not in use for internal surface
102 VPHAL_PALETTE Palette = {}; //!< Palette data. Not in use for internal surface
103 VPHAL_SURFACE_TYPE SurfType = SURF_NONE; //!< Surface type (context). Not in use for internal surface
104 uint32_t uFwdRefCount = 0; //!< Not in use for internal surface
105 uint32_t uBwdRefCount = 0; //!< Not in use for internal surface
106 VPHAL_SURFACE *pFwdRef = nullptr; //!< Use VP_SURFACE instead of VPHAL_SURFACE later. Not in use for internal surface.
107 VPHAL_SURFACE *pBwdRef = nullptr; //!< Use VP_SURFACE instead of VPHAL_SURFACE later. Not in use for internal surface.
108 VPHAL_SAMPLE_TYPE SampleType = SAMPLE_PROGRESSIVE; //!< Interlaced/Progressive sample type.
109 // Use index of m_InputSurfaces for layerID. No need iLayerID here anymore.
110 RECT rcSrc = {0, 0, 0, 0}; //!< Source rectangle
111 RECT rcDst = {0, 0, 0, 0}; //!< Destination rectangle
112 RECT rcMaxSrc = {0, 0, 0, 0}; //!< Max source rectangle
113 bool bVEBOXCroppingUsed = false; //!<Vebox crop case need use rcSrc as vebox input.
114 uint32_t bufferWidth = 0; //!< 1D buffer Width, n/a if 2D surface
115 uint32_t bufferHeight = 0; //!< 1D buffer Height, n/a if 2D surface
116
117 // Return true if no resource assigned to current vp surface.
118 bool IsEmpty();
119 // Clean the vp surface to empty state. Only valid for false == isResourceOwner case.
120 MOS_STATUS Clean();
121
122 // Get Allocation Handle of resource
123 uint64_t GetAllocationHandle(MOS_INTERFACE *osIntf);
124 };
125
126 struct _VP_SETTINGS
127 {
128 // For validation purpose settings
129 uint32_t disableDnDi = 0; //!< Disable DNDI(Vebox)
130 uint32_t kernelUpdate = 0; //!< For VEBox Copy and Update kernels
131 uint32_t disableHdr = 0; //!< Disable Hdr
132 uint32_t veboxParallelExecution = 0; //!< Control VEBox parallel execution with render engine
133 bool clearVideoViewMode = 0; //!< Perf Optimize for ClearVideoView DDI
134 };
135
136 using VP_SETTINGS = _VP_SETTINGS;
137
138 // To define the features enabling on different engines
139 struct _VP_EXECUTE_CAPS
140 {
141 union {
142 struct {
143 uint64_t bVebox : 1; // Vebox needed
144 uint64_t bSFC : 1; // SFC needed
145 uint64_t bRender : 1; // Render Only needed
146 uint64_t bSecureVebox : 1; // Vebox in Secure Mode
147 uint64_t bRenderHdr : 1; // Render HDR in use
148
149 uint64_t bOutputPipeFeatureInuse : 1; // Output surface of pipeline is in use.
150 uint64_t bForceCscToRender : 1; // If true, force to use render for csc.
151 uint64_t bForceProcampToRender : 1; // If true, force to use render for procamp.
152 uint64_t lastSubmission : 1; // If true, it's the last submission of current DDI.
153 uint64_t bTemperalInputInuse : 1; // If true, will use temperal input instead of input
154
155 // Vebox Features
156 uint64_t bDN : 1; // Vebox DN needed
157 uint64_t bDI : 1; // Vebox DI enabled
158 uint64_t bDiProcess2ndField : 1; // Vebox DI enabled
159 uint64_t bDIFmdKernel : 1; // Vebox FMD Kernel enabled
160 uint64_t bIECP : 1; // Vebox IECP needed
161 uint64_t bSTE : 1; // Vebox STE or Vebox STD_alone needed
162 uint64_t bACE : 1; // Vebox ACE needed
163 uint64_t bTCC : 1; // Vebox TCC needed
164 uint64_t bCGC : 1; // Vebox CGC needed
165 uint64_t bBt2020ToRGB : 1; // Vebox Bt2020 gamut compression to RGB format
166 uint64_t bProcamp : 1; // Vebox Procamp needed
167 uint64_t bBeCSC : 1; // Vebox back end CSC needed
168 uint64_t bLACE : 1; // Vebox LACE Needed
169 uint64_t bQueryVariance : 1;
170 uint64_t bRefValid : 1; // Vebox Ref is Valid
171 uint64_t bSTD : 1; // Vebox LACE STD Needed
172 uint64_t bDnKernelUpdate: 1;
173 uint64_t bVeboxSecureCopy : 1;
174 uint64_t bHDR3DLUT : 1; // Vebox 3DLUT needed
175 uint64_t b1K1DLutInited : 1;
176 uint64_t bDV : 1;
177 uint64_t b3DlutOutput : 1;
178 uint64_t bHdr33lutsize : 1;
179 uint64_t bCappipe : 1;
180 uint64_t bLgca : 1;
181 uint64_t bFDFB : 1;
182 uint64_t bColorBalance : 1;
183 uint64_t b1K1DLutInUse : 1;
184 uint64_t bCcmCsc : 1;
185 uint64_t bDemosaicInUse : 1;
186 uint64_t enableSFCLinearOutputByTileConvert : 1; //true if do tileconvert from tileF to linear for SFC linear output
187
188 // SFC features
189 uint64_t bSfcCsc : 1; // Sfc Csc enabled
190 uint64_t bSfcRotMir : 1; // Sfc Rotation/Mirror needed
191 uint64_t bSfcScaling : 1; // Sfc Scaling Needed
192 uint64_t bSfcIef : 1; // Sfc Details Needed
193 uint64_t b1stPassOfSfc2PassScaling : 1; // 1st pass of sfc 2pass scaling
194
195 // Render Features
196 uint64_t bComposite : 1;
197 uint64_t bSR : 1;
198 uint64_t b3DLutCalc : 1;
199 uint64_t bHVSCalc : 1;
200 uint64_t bSegmentation : 1;
201 uint64_t bHdr : 1;
202 uint64_t bFallbackLegacyFC : 1; // only valid when vpUserFeatureControl->EnableL0FC() is true
203 uint64_t forceBypassWorkload : 1; // If true, force to bypass workload.
204 };
205 uint64_t value;
206 };
207 };
208
209 C_ASSERT(sizeof(_VP_EXECUTE_CAPS) == sizeof(uint64_t));
210
211 typedef struct _VP_EngineEntry
212 {
213 union
214 {
215 struct
216 {
217 // set by GetXxxExecuteCaps
218 uint64_t bEnabled : 1;
219 uint64_t SfcNeeded : 1;
220 uint64_t VeboxNeeded : 1;
221 uint64_t RenderNeeded : 1;
222 uint64_t hdrKernelNeeded : 1;
223 uint64_t fcSupported : 1; // Supported by fast composition
224 uint64_t hdrKernelSupported : 1; // Supported by Hdr Kenrel
225 uint64_t isolated : 1; // Only support single feature.
226 uint64_t bt2020ToRGB : 1; // true if bt2020 to rgb
227 uint64_t is1K1DLutSurfaceInUse : 1; // 1K1DLut surface in use
228 uint64_t isHdr33LutSizeEnabled : 1;
229 uint64_t isBayerInputInUse : 1;
230 uint64_t forceLegacyFC : 1; // true if L0 FC not support the format, fall back to legacy FC
231
232 // set by GetXxxPipeEnginCaps
233 uint64_t bypassIfVeboxSfcInUse : 1; // Bypass the feature if vebox or sfc in use. In such case, VeboxNeeded and
234 // SfcNeeded are 0 but it should not block vebox or sfc being selected.
235 uint64_t forceEnableForSfc : 1; // Force enabled when sfc being selected.
236 uint64_t forceEnableForFc : 1; // Force enabled when fc being selected.
237 uint64_t forceEnableForHdrKernel : 1;
238 uint64_t nonFcFeatureExists : 1; // The feature exists, which do not support fc
239 uint64_t nonVeboxFeatureExists : 1; // The feature exists, which do not support vebox
240 uint64_t fcOnlyFeatureExists : 1; // The feature exists, which only support render fc, and not support vebox/sfc.
241 uint64_t multiPassNeeded : 1; // If true, multi-pass for frame processing is needed.
242 uint64_t VeboxARGBOut : 1;
243 uint64_t VeboxARGB10bitOutput : 1;
244 uint64_t VeboxIECPNeeded : 1;
245 uint64_t bypassVeboxFeatures : 1;
246 uint64_t diProcess2ndField : 1;
247 uint64_t sfc2PassScalingNeededX : 1;
248 uint64_t sfc2PassScalingNeededY : 1;
249 uint64_t usedForNextPass : 1; // true if current feature should be bypassed for current pass and be processed during next pass.
250 uint64_t sfcNotSupported : 1; // true if sfc cannot be selected.
251 uint64_t veboxNotSupported : 1; // true if vebox cannot be selected.
252 uint64_t isOutputPipeNeeded : 1; // true if the feature is used for parameter calculation.
253 uint64_t sfcOnlyFeatureExists : 1; // The feature exists, which only support sfc.
254 uint64_t bTemperalInputInuse : 1; // true if replace input
255 uint64_t outputWithLumaKey : 1;
256 uint64_t enableSFCLinearOutputByTileConvert : 1; //true if do tileconvert from tileF to linear for SFC linear output
257 uint64_t forceBypassWorkload : 1; // If true, force to bypass workload.
258 };
259 uint64_t value;
260 };
261 }VP_EngineEntry;
262
263 C_ASSERT(sizeof(_VP_EngineEntry) == sizeof(uint64_t));
264
265 enum _VP_PACKET_ENGINE
266 {
267 VP_PACKET_COMP = 0,
268 VP_PACKET_VEBOX,
269 };
270
271 enum VP_RGB_OUTPUT_OVERRIDE_ID
272 {
273 VP_RGB_OUTPUT_OVERRIDE_ID_INVALID = 0,
274 VP_RGB_OUTPUT_OVERRIDE_ID_RGBP_LINEAR,
275 VP_RGB_OUTPUT_OVERRIDE_ID_RGBP_TILE,
276 VP_RGB_OUTPUT_OVERRIDE_ID_RGB24LINEAR,
277 VP_RGB_OUTPUT_OVERRIDE_ID_BGRP_LINEAR,
278 VP_RGB_OUTPUT_OVERRIDE_ID_BGRP_TILE,
279 VP_RGB_OUTPUT_OVERRIDE_ID_MAX,
280 };
281
282 typedef enum _VP_COMP_BYPASS_MODE
283 {
284 VP_COMP_BYPASS_NOT_SET = 0xffffffff,
285 VP_COMP_BYPASS_DISABLED = 0x0,
286 VP_COMP_BYPASS_ENABLED = 0x1
287 } VP_COMP_BYPASS_MODE, * PVP_COMP_BYPASS_MODE;
288
289 // RESOURCE_ASSIGNMENT_HINT are feature parameters which will affect resource assignment.
290 // For caps existing in VP_EXECUTE_CAPS, they should not be added to RESOURCE_ASSIGNMENT_HINT.
291 union RESOURCE_ASSIGNMENT_HINT
292 {
293 struct
294 {
295 RESOURCE_ASSIGNMENT_HINT_BITS;
296 };
297 uint32_t value[RESOURCE_ASSIGNMENT_HINT_SIZE];
298 };
299
300 using VP_EXECUTE_CAPS = _VP_EXECUTE_CAPS;
301 using VP_PACKET_ENGINE = _VP_PACKET_ENGINE;
302 using PVP_SURFACE = VP_SURFACE*;
303
IsVeboxFeatureInuse(VP_EXECUTE_CAPS & caps)304 inline bool IsVeboxFeatureInuse(VP_EXECUTE_CAPS &caps)
305 {
306 return (caps.bVebox && (!caps.bSFC || caps.bDN || caps.bDI || caps.bIECP || caps.bSTE ||
307 caps.bACE || caps.bTCC || caps.bBeCSC || caps.bQueryVariance || caps.bLACE || caps.bSTD ||
308 caps.bHDR3DLUT || caps.bDV));
309 }
310
311 #endif
312