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