xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/vp/hal/utils/vp_dumper.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
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_dumper.h
24 //! \brief    Defines structures and functions of vp dumpers for debugging
25 //!           This file contains the definition of structures and functions for
26 //!           surface dumper and parameter dumper
27 //!
28 
29 #ifndef __VP_DUMPER_H__
30 #define __VP_DUMPER_H__
31 
32 #if (_DEBUG || _RELEASE_INTERNAL)
33 
34 #include "renderhal.h"
35 #include "mhw_vebox.h"
36 #include "vp_common.h"       // Common interfaces and structures
37 #include "vp_pipeline_common.h"
38 
39 #if !defined(LINUX) && !defined(ANDROID)
40 #include "UmdStateSeparation.h"
41 #endif
42 
43 #define MAX_NAME_LEN            100
44 
45 #define VPHAL_DUMP_OUTPUT_FOLDER                "\\vphaldump\\"
46 
47 #define VPHAL_SURF_DUMP_MANUAL_TRIGGER_DEFAULT_NOT_SET (-1)
48 #define VPHAL_SURF_DUMP_MANUAL_TRIGGER_STARTED (1)
49 #define VPHAL_SURF_DUMP_MANUAL_TRIGGER_STOPPED (0)
50 
51 //------------------------------------------------------------------------------
52 // Dump macro for dumper.  Dump vphal parameters.
53 //------------------------------------------------------------------------------
54 #define VP_PARAMETERS_DUMPPER_DUMP_XML(              \
55     debuginterface, pRenderParams, frameCounter)     \
56     if (debuginterface)                                              \
57         debuginterface->DumpToXML(pRenderParams, frameCounter);      \
58 
59 //------------------------------------------------------------------------------
60 // Dump macro.  Simply calls the dump function.  defined as null in production
61 //------------------------------------------------------------------------------
62 #define VP_SURFACE_DUMP(                                       \
63     debuginterface, surf, frameCntr, layerCntr, loc, ddi)           \
64     if (debuginterface)                                        \
65         debuginterface->DumpVpSurface(                         \
66            surf, frameCntr, layerCntr, loc, ddi);
67 
68 //------------------------------------------------------------------------------
69 // Dump array of surfaces
70 //------------------------------------------------------------------------------
71 #define VP_SURFACE_PTRS_DUMP(                                    \
72     debuginterface, surfs, maxCntr, numCntr, frameCntr, loc, ddi)     \
73     if (debuginterface)                                          \
74         VP_DEBUG_CHK_STATUS(debuginterface->DumpVpSurfaceArray(  \
75             surfs, maxCntr, numCntr, frameCntr, loc, ddi));
76 //------------------------------------------------------------------------------
77 // Create macro for dumper.  Allocates and initializes.
78 //    Potential leak if renderer not destroyed properly. However, cannot add a
79 //    free here since renderer is not initialized to null (0)
80 //------------------------------------------------------------------------------
81 #define VP_SURF_DUMP_CREATE(surfaceDumper)                   \
82     surfaceDumper = MOS_New(VpSurfaceDumper, m_osInterface); \
83     if (surfaceDumper)                                       \
84         surfaceDumper->GetSurfaceDumpSpec();
85 
86 //------------------------------------------------------------------------------
87 // Destroy macro for dumper.  Frees and sets to null.
88 //------------------------------------------------------------------------------
89 #define VP_SURF_DUMP_DESTORY(surfaceDumper)    \
90     MOS_Delete(surfaceDumper);                 \
91     surfaceDumper = nullptr;
92 
93 //------------------------------------------------------------------------------
94 // Create macro for vphal parameters dumper.  Allocates and initializes.
95 //------------------------------------------------------------------------------
96 #define VP_PARAMETERS_DUMPPER_CREATE(parameterDumper)            \
97     parameterDumper = MOS_New(VpParameterDumper, m_osInterface); \
98     if (parameterDumper)                                         \
99         parameterDumper->GetParametersDumpSpec();
100 
101 //------------------------------------------------------------------------------
102 // Destroy macro for dumper.  Frees and sets to null.
103 //------------------------------------------------------------------------------
104 #define VP_PARAMETERS_DUMPPER_DESTORY(parameterDumper)    \
105     MOS_Delete(parameterDumper);                          \
106     parameterDumper = nullptr;
107 
108 //------------------------------------------------------------------------------
109 // Create macro for vp debug interface.  Allocates and initializes.
110 //------------------------------------------------------------------------------
111 #define VP_DEBUG_INTERFACE_CREATE(debuginterface)       \
112     debuginterface = MOS_New(VpDebugInterface);         \
113     if (debuginterface)                                 \
114         VP_PUBLIC_CHK_STATUS_RETURN(                    \
115             debuginterface->Initialize(m_osInterface)); \
116 
117 //------------------------------------------------------------------------------
118 // Destroy macro for vp debug interface.  Frees and sets to null.
119 //------------------------------------------------------------------------------
120 #define VP_DEBUG_INTERFACE_DESTROY(debuginterface)      \
121     MOS_Delete(debuginterface);                         \
122     debuginterface = nullptr;
123 
124 //------------------------------------------------------------------------------
125 // Dump macro for dumper.  Dump Sku and workaround information.
126 //------------------------------------------------------------------------------
127 #define SkuWaTable_DUMP_XML(skuTable, waTable)         \
128    if (m_debugInterface)                               \
129        m_debugInterface->SkuWa_DumpToXML(              \
130             skuTable,                                  \
131             waTable);
132 
133 //------------------------------------------------------------------------------
134 // Dump surface for dumper.  Dump surface format information.
135 //------------------------------------------------------------------------------
136 #define VP_GET_FORMAT_STRING(format)                   \
137         VpDumperTool::GetFormatStr(format)             \
138 
139 //!
140 //! Structure VPHAL_DBG_SURF_DUMP_SURFACE_DEF
141 //! \brief    Plane definition
142 //! \details  Plane information including offset, height, width, pitch
143 //!
144 struct VPHAL_SURF_DUMP_SURFACE_DEF
145 {
146     uint32_t   dwOffset;                                                           //!< Offset from start of the plane
147     uint32_t   dwHeight;                                                           //!< Height in rows
148     uint32_t   dwWidth;                                                            //!< Width in bytes
149     uint32_t   dwPitch;                                                            //!< Pitch in bytes
150 };
151 
152 //!
153 //! \brief Dump locations as enum
154 //!
155 enum VPHAL_SURF_DUMP_LOCATION
156 {
157     VPHAL_DUMP_TYPE_PRE_ALL,
158     VPHAL_DUMP_TYPE_PRE_DNDI,
159     VPHAL_DUMP_TYPE_POST_DNDI,
160     VPHAL_DUMP_TYPE_PRE_COMP,
161     VPHAL_DUMP_TYPE_POST_COMP,
162     VPHAL_DUMP_TYPE_PRE_MEMDECOMP,
163     VPHAL_DUMP_TYPE_POST_MEMDECOMP,
164     VPHAL_DUMP_TYPE_VEBOX_DRIVERHEAP,
165     VPHAL_DUMP_TYPE_VEBOX_KERNELHEAP,
166     VPHAL_DUMP_TYPE_POST_ALL,
167     VPHAL_DUMP_TYPE_INTERNAL
168 };
169 
170 //!
171 //! \brief Dump DDI as enum
172 //!
173 enum VPHAL_SURF_DUMP_DDI
174 {
175     VPHAL_SURF_DUMP_DDI_UNKNOWN,
176     VPHAL_SURF_DUMP_DDI_VP_BLT,
177     VPHAL_SURF_DUMP_DDI_CLEAR_VIEW
178 };
179 
180 //!
181 //! Structure VPHAL_SURF_DUMP_LOC
182 //! \brief    Specification for a single pipeline location dump
183 //! \details  Specification for a single pipeline location dump
184 //!
185 struct VPHAL_SURF_DUMP_LOC
186 {
187     uint32_t                        DumpLocation;                               //!< Dump location
188     VPHAL_SURFACE_TYPE              SurfType;                                   //!< Type of this surface
189 };
190 
191 //!
192 //! Structure VPHAL_SURF_DUMP_SPEC
193 //! \brief    All information about a surface dump specification
194 //! \details  All information about a surface dump specification
195 //!
196 struct VPHAL_SURF_DUMP_SPEC
197 {
198     char                          pcOutputPath[MAX_PATH];                       //!< Path where dumps are written
199     VPHAL_SURF_DUMP_LOC          *pDumpLocations;                              //!< Locations in post-processing pipeline to dump at
200     uint32_t                      uiStartFrame;                                 //!< Frame to start dumping at
201     uint32_t                      uiEndFrame;                                   //!< Frame to stop dumping at
202     int32_t                       iNumDumpLocs;                                 //!< Number of pipe stage dump locations
203     bool                          enableAuxDump;                                //!< Enable aux data dump for compressed surface
204     bool                          enablePlaneDump;                              //!< Enable surface dump by plane
205 };
206 
207 //!
208 //! Structure PVPHAL_DBG_PFIELD_LAYOUT
209 //! \brief    Debug Field Structure
210 //! \details  Debug Field Structure
211 //!
212 struct VPHAL_FIELD_LAYOUT
213 {
214     char                     pcName[MAX_NAME_LEN];
215     uint32_t                 dwOffset;
216     uint32_t                 dwSize;
217     uint32_t                 uiNumber;
218     char                     pcStructName[MAX_NAME_LEN];
219     VPHAL_FIELD_LAYOUT      *pChildLayout;
220     uint32_t                 uiNumChildren;
221 
222 };
223 
224 
225 //-------------------------------------------------------------------------------
226 // All information about parameters output dump
227 //-------------------------------------------------------------------------------
228 struct VPHAL_PARAMS_DUMP_SPEC
229 {
230     char                       outFileLocation[MAX_PATH];                         // Location where dump files need to be stored
231     uint32_t                   uiStartFrame;                                      // Start frame for dumping
232     uint32_t                   uiEndFrame;                                        // End Frame for dumping
233     uint32_t                   enableSkuWaDump;                                   // Enable sku and wa info dump
234 };
235 
236 //==<FUNCTIONS>=================================================================
237 //!
238 //! Class VpSurfaceDumper
239 //! \brief VP Surface Dumper definition
240 //!
241 class VpSurfaceDumper
242 {
243 public:
244     //!
245     //! \brief    Dump a surface into a file
246     //! \details  Dump a surface into a file, called by VpHalDbg_SurfaceDumperDump
247     //!           File name will be generated based on surface format, width,
248     //!           height, pitch, iCounter and psPathPrefix. For example, if the
249     //!           psPathPrefix is /dump/primary, then file will be created under
250     //!           /dump/ and file name will start as primary_
251     //! \param    [in] pOsInterface
252     //!           The pointer to OS interface
253     //! \param    [in] pSurface
254     //!           The pointer to the surface to be dumped
255     //! \param    [in] psPathPrefix
256     //!           The prefix of the file path which the surface will dump to
257     //! \param    [in] iCounter
258     //!           The counter that tells which render this surface belongs to
259     //! \param    [in] bLockSurface
260     //!           True if need to lock the surface
261     //! \param    [in] bNoDecompWhenLock
262     //!           True if force not to do decompress when Lock
263     //! \param    [in] pData
264     //!           non-null if caller already locked the surface byitself
265     //! \return   MOS_STATUS
266     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
267     //!
268     virtual MOS_STATUS DumpSurfaceToFile(
269         PMOS_INTERFACE              pOsInterface,
270         PVPHAL_SURFACE              pSurface,
271         const char                  *psPathPrefix,
272         uint64_t                    iCounter,
273         bool                        bLockSurface,
274         bool                        bNoDecompWhenLock,
275         uint8_t*                    pData);
276 
277     virtual MOS_STATUS DumpSurfaceToFile(
278         PMOS_INTERFACE              pOsInterface,
279         PVP_SURFACE                 pSurface,
280         const char                  *psPathPrefix,
281         uint64_t                    iCounter,
282         bool                        bLockSurface,
283         bool                        bNoDecompWhenLock,
284         uint8_t*                    pData);
285 
286     virtual MOS_STATUS CopyThenLockResources(
287         PMOS_INTERFACE               pOsInterface,
288         PVPHAL_SURFACE               pSurface,
289         PVPHAL_SURFACE              &temp2DSurfForCopy,
290         bool                         hasAuxSurf,
291         bool                         enableAuxDump,
292         PMOS_LOCK_PARAMS             pLockFlags,
293         PMOS_RESOURCE               &pLockedResource,
294         VPHAL_SURF_DUMP_SURFACE_DEF *pPlanes,
295         uint32_t                    *pdwNumPlanes,
296         uint32_t                    *pdwSize,
297         uint8_t                     *&pData,
298         const char                  *psPathPrefix = nullptr,
299         uint64_t                     iCounter = 0);
300 
301     virtual void UnlockAndDestroyResource(
302         PMOS_INTERFACE              osInterface,
303         PVPHAL_SURFACE              tempSurf,
304         PMOS_RESOURCE               lockedResource,
305         bool                        bLockSurface);
306 
307     VPHAL_SURF_DUMP_SPEC    m_dumpSpec;
308 
309     //!
310     //! \brief    VpSurfaceDumper constuctor
311     //!
312     VpSurfaceDumper(PMOS_INTERFACE pOsInterface);
313 
314     //!
315     //! \brief    VpSurfaceDumper destuctor
316     //!
317     virtual ~VpSurfaceDumper();
318 
319     //!
320     //! \brief    Dump a surface
321     //! \details  Dump a surface according to the surface dumper spec
322     //! \param    [in] pSurf
323     //!           The pointer to the surface to be dumped
324     //! \param    [in] uiFrameNumber
325     //!           The counter that tells which render this surface belongs to
326     //! \param    [in] uiCounter
327     //!           The counter that tells which layer this surface belongs to
328     //! \param    [in] Location
329     //!           The render stage, e.g. preall, predndi, postdndi ...
330     //! \return   MOS_STATUS
331     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
332     //!
333     virtual MOS_STATUS DumpSurface(
334         PVPHAL_SURFACE pSurf,
335         uint32_t       uiFrameNumber,
336         uint32_t       uiCounter,
337         uint32_t       Location,
338         uint32_t       uiDDI = VPHAL_SURF_DUMP_DDI_UNKNOWN);
339 
340 
341      virtual MOS_STATUS DumpSurface(
342         PVP_SURFACE pSurf,
343         uint32_t    uiFrameNumber,
344         uint32_t    uiCounter,
345         uint32_t    Location,
346         uint32_t    uiDDI = VPHAL_SURF_DUMP_DDI_UNKNOWN);
347 
348     // VpHalDbg_SurfaceDumperDumpPtrs
349     //!
350     //! \brief    Dump all surfaces in surface array
351     //! \details  Dump all surfaces in surface array according to the surface
352     //!           dumper spec
353     //! \param    [in] ppSurfaces
354     //!           The pointer to surface array to be dumped
355     //! \param    [in] uiMaxSurfaces
356     //!           The max number of surfaces supported in VPHAL
357     //! \param    [in] uiNumSurfaces
358     //!           The number of surfaces to be dumped
359     //! \param    [in] uint32_t uiFrameNumber
360     //!           The counter that tells which render this surface belongs to
361     //! \param    [in] Location
362     //!           The render stage, e.g. preall, predndi, postdndi ...
363     //! \return   MOS_STATUS
364     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
365     //!
366      MOS_STATUS DumpSurfaceArray(
367          PVPHAL_SURFACE *ppSurfaces,
368          uint32_t        uiMaxSurfaces,
369          uint32_t        uiNumSurfaces,
370          uint32_t        uiFrameNumber,
371          uint32_t        Location,
372          uint32_t        uiDDI = VPHAL_SURF_DUMP_DDI_UNKNOWN);
373 
374     //!
375     //! \brief    Query the register to get surface dump specification.
376     //! \return   void
377     //!
378     void GetSurfaceDumpSpec();
379 
380     void GetSurfaceDumpSpecForVPSolo(VPHAL_SURF_DUMP_SPEC * pDumpSpec, MediaUserSetting::Value outValue);
381 
382 protected:
383     //!
384     //! \brief    Convert a string to loc enum type
385     //! \param    [in] pcLocString
386     //!           Pointer to the string to be converted
387     //! \param    [out] pLocation
388     //!           Enum type
389     //! \return   MOS_STATUS
390     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
391     //!
392     virtual MOS_STATUS LocStringToEnum(
393         char*                           pcLocString,
394         uint32_t                        *pLocation);
395 
396     //!
397     //! \brief    Converts an enum for loc type to a string
398     //! \param    [in] Location
399     //!           Enum type to be converted
400     //! \param    [out] pcLocString
401     //!           Location as a string -- must be allocated before sent in
402     //! \return   MOS_STATUS
403     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
404     //!
405     virtual MOS_STATUS EnumToLocString(
406         uint32_t                        Location,
407         char*                           pcLocString);
408 
409     //!
410     //! \brief    Convert a DDI to string
411     //! \param    [in] DDI
412     //!           Enum of a DDI
413     //! \param    [out] DDI string
414     //!           Enum type
415     //! \return   MOS_STATUS
416     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
417     //!
418     virtual MOS_STATUS EnumToDdiString(
419         uint32_t                        uiDDI,
420         char*                           pcDdiString);
421 
422     //!
423     //! \brief    Check if an osResource have aux surf
424     //! \param    [in] osResource
425     //!           Pointer to MOS Resource
426     //! \return   bool
427     //!           Return true if has aux surf, otherwise false
428     //!
429     bool HasAuxSurf(
430         PMOS_RESOURCE                   osResource);
431 
432     PMOS_INTERFACE              m_osInterface;
433     char                        m_dumpPrefix[MAX_PATH];     // Called frequently, so avoid repeated stack resizing with member data
434     char                        m_dumpLoc[MAX_PATH];        // to avoid recursive call from diff owner but sharing the same buffer
435     char                        m_dumpDDI[MAX_PATH];        // to avoid recursive call from diff owner but sharing the same buffer
436     MediaUserSettingSharedPtr   m_userSettingPtr = nullptr; // userSettingInstance
437 
438 private:
439 
440     //!
441     //! \brief    Get plane information of a surface
442     //! \details  Get plane information of a surface, e.g. offset of each plane,
443     //!           number of planes, total size of the surface
444     //! \param    [in] pSurface
445     //!           The pointer to the surface
446     //! \param    [out] pPlanes
447     //!           The pointer to the plane information of the surface
448     //! \param    [out] pdwNumPlanes
449     //!           Number of planes of the surface
450     //! \param    [out] pdwSize
451     //!           The total size of the surface
452     //! \param    [in] auxEnable
453     //!           Whether aux dump is enabled
454     //! \param    [in] isDeswizzled
455     //!           Whether deswizzleing is considered. If yes, uv offset should remove paddings
456     //! \return   MOS_STATUS
457     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
458     //!
459     MOS_STATUS GetPlaneDefs(
460         PVPHAL_SURFACE                      pSurface,
461         VPHAL_SURF_DUMP_SURFACE_DEF        *pPlanes,
462         uint32_t*                           pdwNumPlanes,
463         uint32_t*                           pdwSize,
464         bool                                auxEnable,
465         bool                                isDeswizzled);
466 
467     MOS_STATUS GetPlaneDefs(
468         PVP_SURFACE                         pSurface,
469         VPHAL_SURF_DUMP_SURFACE_DEF*        pPlanes,
470         uint32_t*                           pdwNumPlanes,
471         uint32_t*                           pdwSize,
472         bool                                auxEnable,
473         bool                                isDeswizzled);
474 
475     //!
476     //! \brief    Parse dump location
477     //! \details  Take dump location strings and break down into individual post-
478     //!           processing pipeline locations and surface types.
479     //! \param    [in] pcDumpLocData
480     //!           String containing all dump locations
481     //! \return   MOS_STATUS
482     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
483     //!
484     MOS_STATUS ProcessDumpLocations(
485         char*                      pcDumpLocData);
486 
487     //!
488     //! \brief    Convert a string to surf enum type
489     //! \param    [in] pcSurfType
490     //!           The pointer to string to be converted
491     //! \param    [out] pSurfType
492     //!           Enum version of string
493     //! \return   MOS_STATUS
494     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
495     //!
496     MOS_STATUS SurfTypeStringToEnum(
497         char*                       pcSurfType,
498         VPHAL_SURFACE_TYPE          *pSurfType);
499 
500     //!
501     //! \brief    Removes white space from a C-string
502     //! \param    [in] ptr
503     //!           String to be trimmed
504     //! \return   char*
505     //!           String after trim
506     //!
507     char* WhitespaceTrim(
508         char*                       ptr);
509 
510 MEDIA_CLASS_DEFINE_END(VpSurfaceDumper)
511 };
512 
513 
514 //!
515 //! Class VpPArameerDumper
516 //! \brief RenderParameter Dumper definition
517 //!
518 class VpParameterDumper
519 {
520 public:
521     VPHAL_PARAMS_DUMP_SPEC  m_dumpSpec;
522 
523     //!
524     //! \brief    VphalParameterDumper constuctor
525     //!
526     VpParameterDumper(PMOS_INTERFACE pOsInterface);
527 
528     //!
529     //! \brief    Get VPHAL Parameters Dump Spec
530     //! \param    [in] pDumpSpec
531     //!           parameter dump spec
532     //! \param    [in] pOsInterface
533     //!           OS interface
534     //! \return   void
535     //!
536     void GetParametersDumpSpec();
537 
538     //!
539     //! \brief    VphalParameterDumper destuctor
540     //!
541     virtual ~VpParameterDumper();
542 
543     //!
544     //! \brief    Dumps the Render Parameters to XML File
545     //! \param    [in] uiFrameCounter
546     //!           frame counter
547     //! \param    [in] pcOutputPath
548     //!           Surface dump output path
549     //! \param    [in] pRenderParams
550     //!           Render parameter to be dumped
551     //! \return   MOS_STATUS
552     //!
553     virtual MOS_STATUS DumpToXML(
554         uint32_t                    uiFrameCounter,
555         char                        *pcOutputPath,
556         PVPHAL_RENDER_PARAMS        pRenderParams);
557 
558     //!
559     //! \brief    Dumps Sku and Workaround information to XML File
560     //!
561     virtual MOS_STATUS SkuWa_DumpToXML(
562         MEDIA_FEATURE_TABLE        *skuTable,
563         MEDIA_WA_TABLE             *waTable);
564 
565 protected:
566     //!
567     //! \brief    Dumps the source Surface Parameters
568     //! \param    [in] uiFrameCounter
569     //!           frame counter
570     //! \param    [in] pcOutputPath
571     //!           Surface dump output path
572     //! \param    [in] pSrc
573     //!           source Surface to be dumped
574     //! \param    [in] index
575     //!           index of source Surface
576     //! \param    [in/out] pcOutContents
577     //!           output string buffer
578     //! \return   MOS_STATUS
579     //!
580     virtual MOS_STATUS DumpSourceSurface(
581         uint32_t                        uiFrameCounter,
582         char                            *pcOutputPath,
583         PVPHAL_SURFACE                  pSrc,
584         uint32_t                        index,
585         char*                           &pcOutContents);
586 
587     //!
588     //! \brief    Dumps the target Surface Parameters
589     //! \param    [in] uiFrameCounter
590     //!           frame counter
591     //! \param    [in] pcOutputPath
592     //!           Surface dump output path
593     //! \param    [in] pSrc
594     //!           target Surface to be dumped
595     //! \param    [in] index
596     //!           index of target Surface
597     //! \param    [in/out] pcOutContents
598     //!           output string buffer
599     //! \return   MOS_STATUS
600     //!
601     virtual MOS_STATUS DumpTargetSurface(
602         uint32_t                        uiFrameCounter,
603         char                            *pcOutputPath,
604         PVPHAL_SURFACE                  pTarget,
605         uint32_t                        index,
606         char*                           &pcOutContents);
607 
608     //!
609     //! \brief    Dumps the target Surface Parameters
610     //! \param    [in] uiFrameCounter
611     //!           frame counter
612     //! \param    [in] pcOutputPath
613     //!           Surface dump output path
614     //! \param    [in] pRenderParams
615     //!           Render parameter to be dumped
616     //! \param    [in/out] pcOutContents
617     //!           output string buffer
618     //! \return   MOS_STATUS
619     //!
620     virtual MOS_STATUS DumpRenderParameter(
621         uint32_t                        uiFrameCounter,
622         char                            *pcOutputPath,
623         PVPHAL_RENDER_PARAMS            pRenderParams,
624         char*                           &pcOutContents);
625 
626     //!
627     //! \brief    Gets Debug Component String
628     //! \param    [in] component
629     //!           Mos component
630     //! \return   const char *
631     //!           String of the Component
632     //!
633     virtual const char * GetComponentStr(
634         MOS_COMPONENT             component);
635 
636 private:
637     PMOS_INTERFACE  m_osInterface;
638     MediaUserSettingSharedPtr m_userSettingPtr = nullptr;  // userSettingInstance
639     //!
640     //! \brief    Gets Debug Whole Format String
641     //! \param    [in] format
642     //!           Mos format
643     //! \return   const char *
644     //!           String of the whole format sucha as Format_NV12
645     //!
646     const char * GetWholeFormatStr(MOS_FORMAT format);
647 
648     //!
649     //! \brief    Gets Debug Tile Type String
650     //! \param    [in] format
651     //!           Mos tile type
652     //! \return   const char *
653     //!           String of the tile type
654     //!
655     const char * GetTileTypeStr(MOS_TILE_TYPE tile_type);
656 
657     //!
658     //! \brief    Gets Debug Tile Mode String
659     //! \param    [in] tilemode
660     //!           Mos tile mode
661     //! \return   const char *
662     //!           String of the tile type
663     //!
664     const char *GetTileModeGMMStr(MOS_TILE_MODE_GMM tile_mode);
665 
666     //!
667     //! \brief    Gets Debug Surface Type String
668     //! \param    [in] component
669     //!           Mos component
670     //! \return   const char *
671     //!           String of the component
672     //!
673     const char * GetSurfaceTypeStr(VPHAL_SURFACE_TYPE surface_type);
674 
675     const char *GetGammaValueTypeStr(VPHAL_GAMMA_VALUE gamma_value);
676     //!
677     //! \brief    Gets Debug Sample Type String
678     //! \param    [in] sample type
679     //!           vphal sample type
680     //! \return   const char *
681     //!           String of the vphal sample type
682     //!
683     const char * GetSampleTypeStr(VPHAL_SAMPLE_TYPE sample_type);
684 
685     //!
686     //! \brief    Gets Debug Color Type String
687     //! \param    [in] Color type
688     //!           vphal color type
689     //! \return   const char *
690     //!           String of the vphal color type
691     //!
692     const char * GetColorSpaceStr(VPHAL_CSPACE color_space);
693 
694     //!
695     //! \brief    Gets Debug Blend Type String
696     //! \param    [in] Blend type
697     //!           vphal blend type
698     //! \return   const char *
699     //!           String of the vphal color type
700     //!
701     const char * GetBlendTypeStr(VPHAL_BLEND_TYPE blend_type);
702 
703     //!
704     //! \brief    Gets Debug Palette Type String
705     //! \param    [in] palette type
706     //!           vphal palette type
707     //! \return   const char *
708     //!           String of vphal palette type
709     //!
710     const char * GetPaletteTypeStr(VPHAL_PALETTE_TYPE palette_type);
711 
712     //!
713     //! \brief    Gets Debug Scaling Mode String
714     //! \param    [in] scaling mode
715     //!           vphal scaling mode
716     //! \return   const char *
717     //!           String of vphal scaling mode
718     //!
719     const char * GetScalingModeStr(VPHAL_SCALING_MODE scaling_mode);
720 
721     //!
722     //! \brief    Gets Debug Rotation Mode String
723     //! \param    [in] rotation mode
724     //!           vphal rotation mode
725     //! \return   const char *
726     //!           String of vphal rotation mode
727     //!
728     const char * GetRotationModeStr(VPHAL_ROTATION rotation_mode);
729 
730     //!
731     //! \brief    Gets Debug Deinterlace Mode String
732     //! \param    [in] deinterlace mode
733     //!           vphal deinterlace mode
734     //! \return   const char *
735     //!           String of vphal deinterlace mode
736     //!
737     const char * GetDIModeStr(VPHAL_DI_MODE di_mode);
738 
739     //!
740     //! \brief    Gets Debug Denoise Mode String
741     //! \param    [in] denoise level
742     //!           vphal denoise level
743     //! \return   const char *
744     //!           String of vphal denoise level
745     //!
746     const char * GetDenoiseModeStr(VPHAL_NOISELEVEL noise_level);
747 
748     //!
749     //! \brief    Gets Debug HVS Denoise Mode String
750     //! \param    [in] hvs denoise mode
751     //!           vphal hvsdn mode
752     //! \return   const char *
753     //!           String of vphal hvs denoise mode
754     //!
755     const char *GetHVSDenoiseModeStr(VPHAL_HVSDN_MODE hvs_dn_mode);
756 
757 MEDIA_CLASS_DEFINE_END(VpParameterDumper)
758 };
759 
760 //!
761 //! Class VpDumperTool
762 //! \brief Dumper Tool class definition
763 //!
764 class VpDumperTool
765 {
766 public:
767     //!
768     //! \brief    Get a file path in current OS
769     //! \details  Covert a file path to a path that can be recognized in current OS.
770     //!           File path may be different in different OS.
771     //! \param    [in] pcFilePath
772     //            Input string of the file path to be converted
773     //! \param    [out] pOsFilePath
774     //!           Converted file path
775     //! \return   void
776     //!
777     static void GetOsFilePath(
778         const char* pcFilePath,
779         char*       pOsFilePath);
780 
781     //!
782     //! \brief    Convert a string to an all lower case version
783     //! \param    [in/out] pcString
784     //!           The pointer to string to be converted
785     //! \return   void
786     //!
787     static void StringToLower(
788         char*                       pcString);
789 
790     //!
791     //! \brief    Append to the string
792     //! \details  Adds second arg to end of first arg.  Works like sprintf, but
793     //!           optimized for this special use.
794     //! \param    [in] bFirst
795     //!           True if this is the first call to this function for next param.
796     //!           Note that multiple strings cannot be appended at the same time.
797     //!           They should be appended one by one, e.g. pcBigString2 can be appended
798     //!           after you finish appending pcBigString1.
799     //! \param    [in/out] ppcBigString
800     //!           Pointer to string for that is appended to
801     //! \param    [in] pcToAppendFmt
802     //!           String format for appended part
803     //! \param    [in] ...
804     //!           Fields to fill in for appended part
805     //! \return   MOS_STATUS
806     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
807     //!
808     static MOS_STATUS AppendString(
809         bool   bFirst,
810         char   **ppcBigString,
811         PCCHAR pcToAppendFmt,
812         ...);
813 
814     //!
815     //! \brief    Write Frame
816     //! \details  Debug function to write intermediate output to C:\dump
817     //! \param    [in] pOsInterface
818     //!           Pointer to OS interface
819     //! \param    [in] pSurface
820     //!           Pointer to surface that will be read from
821     //! \param    [in] fileName
822     //!           File to be written to
823     //! \param    [in] iCounter
824     //!           Frame ID and cycle counter
825     //! \return   void
826     //!
827     static void WriteFrame(
828         PMOS_INTERFACE  pOsInterface,
829         PVPHAL_SURFACE  pSurface,
830         PCCHAR          fileName,
831         uint64_t        iCounter);
832 
833     //!
834     //! \brief    Returns the Size of the surface in bytes
835     //! \param    [in] pSurface
836     //!           The pointer to the surface
837     //! \param    [int] iBpp
838     //!           Number of bits per pixel
839     //! \param    [out] piWidthInBytes
840     //!           Width of the surface
841     //! \param    [out] piHeightInRows
842     //!           Height of the surface
843     //! \return   MOS_STATUS
844     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
845     //!
846     static MOS_STATUS GetSurfaceSize(
847         PVPHAL_SURFACE              pSurface,
848         uint32_t                    iBpp,
849         uint32_t*                   piWidthInBytes,
850         uint32_t*                   piHeightInRows);
851 
852     //!
853     //! \brief    Gets Debug Format String
854     //! \param    [in] format
855     //!           Mos format
856     //! \return   const char *
857     //!           String of the format
858     //!
859     static const char * GetFormatStr(
860         MOS_FORMAT                format);
861 
862 MEDIA_CLASS_DEFINE_END(VpDumperTool)
863 };
864 #endif // (_DEBUG || _RELEASE_INTERNAL)
865 
866 #if (!(_DEBUG || _RELEASE_INTERNAL))
867 
868 #define VP_PARAMETERS_DUMPPER_DUMP_XML(debuginterface, pRenderParams, frameCounter)
869 #define VP_SURFACE_DUMP(debuginterface, surf, frameCntr, layerCntr, loc)
870 #define VP_SURFACE_PTRS_DUMP(                                            \
871     debuginterface, surfs, maxCntr, numCntr, frameCntr, loc)
872 #define VP_SURF_DUMP_CREATE(surfaceDumper)
873 #define VP_SURF_DUMP_DESTORY(surfaceDumper)
874 #define VP_PARAMETERS_DUMPPER_CREATE(pParametersDumpSpec)
875 #define VP_PARAMETERS_DUMPPER_DESTORY(pParametersDumpSpec)
876 #define VP_DEBUG_INTERFACE_CREATE(debuginterface)
877 #define VP_DEBUG_INTERFACE_DESTROY(debuginterface)
878 #define SkuWaTable_DUMP_XML(skuTable, waTable)
879 #define VP_GET_FORMAT_STRING(format) ""
880 #endif // (!(_DEBUG || _RELEASE_INTERNAL) || EMUL)
881 
882 
883 
884 
885 #endif // __VP_DUMPER_H__