Debian Codegraph @

media_softlet/agnostic/common/vp/hal/utils/vp_dumper.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_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 uint32_t enablePostCompCopy; //!< Enable PostComp surface dump copy
206 };
207
208 //!
209 //! Structure PVPHAL_DBG_PFIELD_LAYOUT
210 //! \brief Debug Field Structure
211 //! \details Debug Field Structure
212 //!
213 struct VPHAL_FIELD_LAYOUT
214 {
215 char pcName[MAX_NAME_LEN];
216 uint32_t dwOffset;
217 uint32_t dwSize;
218 uint32_t uiNumber;
219 char pcStructName[MAX_NAME_LEN];
220 VPHAL_FIELD_LAYOUT *pChildLayout;
221 uint32_t uiNumChildren;
222
223 };
224
225
226 //-------------------------------------------------------------------------------
227 // All information about parameters output dump
228 //-------------------------------------------------------------------------------
229 struct VPHAL_PARAMS_DUMP_SPEC
230 {
231 char outFileLocation[MAX_PATH]; // Location where dump files need to be stored
232 uint32_t uiStartFrame; // Start frame for dumping
233 uint32_t uiEndFrame; // End Frame for dumping
234 uint32_t enableSkuWaDump; // Enable sku and wa info dump
235 };
236
237 //==<FUNCTIONS>=================================================================
238 //!
239 //! Class VpSurfaceDumper
240 //! \brief VP Surface Dumper definition
241 //!
242 class VpSurfaceDumper
243 {
244 public:
245 //!
246 //! \brief Dump a surface into a file
247 //! \details Dump a surface into a file, called by VpHalDbg_SurfaceDumperDump
248 //! File name will be generated based on surface format, width,
249 //! height, pitch, iCounter and psPathPrefix. For example, if the
250 //! psPathPrefix is /dump/primary, then file will be created under
251 //! /dump/ and file name will start as primary_
252 //! \param [in] pOsInterface
253 //! The pointer to OS interface
254 //! \param [in] pSurface
255 //! The pointer to the surface to be dumped
256 //! \param [in] psPathPrefix
257 //! The prefix of the file path which the surface will dump to
258 //! \param [in] iCounter
259 //! The counter that tells which render this surface belongs to
260 //! \param [in] bLockSurface
261 //! True if need to lock the surface
262 //! \param [in] bNoDecompWhenLock
263 //! True if force not to do decompress when Lock
264 //! \param [in] pData
265 //! non-null if caller already locked the surface byitself
266 //! \return MOS_STATUS
267 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
268 //!
269 virtual MOS_STATUS DumpSurfaceToFile(
270 PMOS_INTERFACE pOsInterface,
271 PVPHAL_SURFACE pSurface,
272 const char *psPathPrefix,
273 uint64_t iCounter,
274 bool bLockSurface,
275 bool bNoDecompWhenLock,
276 uint8_t* pData);
277
278 virtual MOS_STATUS DumpSurfaceToFile(
279 PMOS_INTERFACE pOsInterface,
280 PVP_SURFACE pSurface,
281 const char *psPathPrefix,
282 uint64_t iCounter,
283 bool bLockSurface,
284 bool bNoDecompWhenLock,
285 uint8_t* pData);
286
287 virtual MOS_STATUS CopyThenLockResources(
288 PMOS_INTERFACE pOsInterface,
289 PVPHAL_SURFACE pSurface,
290 PVPHAL_SURFACE &temp2DSurfForCopy,
291 bool hasAuxSurf,
292 bool enableAuxDump,
293 PMOS_LOCK_PARAMS pLockFlags,
294 PMOS_RESOURCE &pLockedResource,
295 VPHAL_SURF_DUMP_SURFACE_DEF *pPlanes,
296 uint32_t *pdwNumPlanes,
297 uint32_t *pdwSize,
298 uint8_t *&pData,
299 const char *psPathPrefix = nullptr,
300 uint64_t iCounter = 0);
301
302 virtual MOS_STATUS CopyThenLockResources(
303 PMOS_INTERFACE pOsInterface,
304 PVP_SURFACE pSurface,
305 PVPHAL_SURFACE &temp2DSurfForCopy,
306 bool hasAuxSurf,
307 bool enableAuxDump,
308 PMOS_LOCK_PARAMS pLockFlags,
309 PMOS_RESOURCE &pLockedResource,
310 VPHAL_SURF_DUMP_SURFACE_DEF *pPlanes,
311 uint32_t *pdwNumPlanes,
312 uint32_t *pdwSize,
313 uint8_t *&pData,
314 const char *psPathPrefix = nullptr,
315 uint64_t iCounter = 0);
316 virtual void UnlockAndDestroyResource(
317 PMOS_INTERFACE osInterface,
318 PVPHAL_SURFACE tempSurf,
319 PMOS_RESOURCE lockedResource,
320 bool bLockSurface);
321
322 VPHAL_SURF_DUMP_SPEC m_dumpSpec;
323
324 //!
325 //! \brief VpSurfaceDumper constuctor
326 //!
327 VpSurfaceDumper(PMOS_INTERFACE pOsInterface);
328
329 //!
330 //! \brief VpSurfaceDumper destuctor
331 //!
332 virtual ~VpSurfaceDumper();
333
334 //!
335 //! \brief Dump a surface
336 //! \details Dump a surface according to the surface dumper spec
337 //! \param [in] pSurf
338 //! The pointer to the surface to be dumped
339 //! \param [in] uiFrameNumber
340 //! The counter that tells which render this surface belongs to
341 //! \param [in] uiCounter
342 //! The counter that tells which layer this surface belongs to
343 //! \param [in] Location
344 //! The render stage, e.g. preall, predndi, postdndi ...
345 //! \return MOS_STATUS
346 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
347 //!
348 virtual MOS_STATUS DumpSurface(
349 PVPHAL_SURFACE pSurf,
350 uint32_t uiFrameNumber,
351 uint32_t uiCounter,
352 uint32_t Location,
353 uint32_t uiDDI = VPHAL_SURF_DUMP_DDI_UNKNOWN);
354
355
356 virtual MOS_STATUS DumpSurface(
357 PVP_SURFACE pSurf,
358 uint32_t uiFrameNumber,
359 uint32_t uiCounter,
360 uint32_t Location,
361 uint32_t uiDDI = VPHAL_SURF_DUMP_DDI_UNKNOWN);
362
363 // VpHalDbg_SurfaceDumperDumpPtrs
364 //!
365 //! \brief Dump all surfaces in surface array
366 //! \details Dump all surfaces in surface array according to the surface
367 //! dumper spec
368 //! \param [in] ppSurfaces
369 //! The pointer to surface array to be dumped
370 //! \param [in] uiMaxSurfaces
371 //! The max number of surfaces supported in VPHAL
372 //! \param [in] uiNumSurfaces
373 //! The number of surfaces to be dumped
374 //! \param [in] uint32_t uiFrameNumber
375 //! The counter that tells which render this surface belongs to
376 //! \param [in] Location
377 //! The render stage, e.g. preall, predndi, postdndi ...
378 //! \return MOS_STATUS
379 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
380 //!
381 MOS_STATUS DumpSurfaceArray(
382 PVPHAL_SURFACE *ppSurfaces,
383 uint32_t uiMaxSurfaces,
384 uint32_t uiNumSurfaces,
385 uint32_t uiFrameNumber,
386 uint32_t Location,
387 uint32_t uiDDI = VPHAL_SURF_DUMP_DDI_UNKNOWN);
388
389 //!
390 //! \brief Query the register to get surface dump specification.
391 //! \return void
392 //!
393 void GetSurfaceDumpSpec();
394
395 void GetSurfaceDumpSpecForVPSolo(VPHAL_SURF_DUMP_SPEC * pDumpSpec, MediaUserSetting::Value outValue);
396
397 protected:
398 //!
399 //! \brief Convert a string to loc enum type
400 //! \param [in] pcLocString
401 //! Pointer to the string to be converted
402 //! \param [out] pLocation
403 //! Enum type
404 //! \return MOS_STATUS
405 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
406 //!
407 virtual MOS_STATUS LocStringToEnum(
408 char* pcLocString,
409 uint32_t *pLocation);
410
411 //!
412 //! \brief Converts an enum for loc type to a string
413 //! \param [in] Location
414 //! Enum type to be converted
415 //! \param [out] pcLocString
416 //! Location as a string -- must be allocated before sent in
417 //! \return MOS_STATUS
418 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
419 //!
420 virtual MOS_STATUS EnumToLocString(
421 uint32_t Location,
422 char* pcLocString);
423
424 //!
425 //! \brief Convert a DDI to string
426 //! \param [in] DDI
427 //! Enum of a DDI
428 //! \param [out] DDI string
429 //! Enum type
430 //! \return MOS_STATUS
431 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
432 //!
433 virtual MOS_STATUS EnumToDdiString(
434 uint32_t uiDDI,
435 char* pcDdiString);
436
437 //!
438 //! \brief Check if an osResource have aux surf
439 //! \param [in] osResource
440 //! Pointer to MOS Resource
441 //! \return bool
442 //! Return true if has aux surf, otherwise false
443 //!
444 bool HasAuxSurf(
445 PMOS_RESOURCE osResource);
446
447 PMOS_INTERFACE m_osInterface;
448 char m_dumpPrefix[MAX_PATH]; // Called frequently, so avoid repeated stack resizing with member data
449 char m_dumpLoc[MAX_PATH]; // to avoid recursive call from diff owner but sharing the same buffer
450 char m_dumpDDI[MAX_PATH]; // to avoid recursive call from diff owner but sharing the same buffer
451 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; // userSettingInstance
452
453 protected:
454
455 //!
456 //! \brief Get plane information of a surface
457 //! \details Get plane information of a surface, e.g. offset of each plane,
458 //! number of planes, total size of the surface
459 //! \param [in] pSurface
460 //! The pointer to the surface
461 //! \param [out] pPlanes
462 //! The pointer to the plane information of the surface
463 //! \param [out] pdwNumPlanes
464 //! Number of planes of the surface
465 //! \param [out] pdwSize
466 //! The total size of the surface
467 //! \param [in] auxEnable
468 //! Whether aux dump is enabled
469 //! \param [in] isDeswizzled
470 //! Whether deswizzleing is considered. If yes, uv offset should remove paddings
471 //! \return MOS_STATUS
472 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
473 //!
474 MOS_STATUS GetPlaneDefs(
475 PVPHAL_SURFACE pSurface,
476 VPHAL_SURF_DUMP_SURFACE_DEF *pPlanes,
477 uint32_t* pdwNumPlanes,
478 uint32_t* pdwSize,
479 bool auxEnable,
480 bool isDeswizzled);
481
482 MOS_STATUS GetPlaneDefs(
483 PVP_SURFACE pSurface,
484 VPHAL_SURF_DUMP_SURFACE_DEF* pPlanes,
485 uint32_t* pdwNumPlanes,
486 uint32_t* pdwSize,
487 bool auxEnable,
488 bool isDeswizzled);
489
490 //!
491 //! \brief Copy one scanline of surface data, with RGB24 hole-stripping
492 //! \details For Format_R8G8B8 on older platforms (FtrSFCRGB24OutNoPadding not set),
493 //! strips 1 padding byte every 64 bytes. Otherwise does a plain copy.
494 //! \param [in] pDst
495 //! Destination buffer
496 //! \param [in] pSrc
497 //! Source buffer
498 //! \param [in] dwWidth
499 //! Width of the scanline in bytes
500 //! \param [in] format
501 //! Surface format
502 //! \param [in] skuTable
503 //! Pointer to SKU table (may be nullptr)
504 //!
505 void CopyScanlineWithHoleStripping(
506 uint8_t *pDst,
507 const uint8_t *pSrc,
508 uint32_t dwWidth,
509 MOS_FORMAT format,
510 MEDIA_FEATURE_TABLE *skuTable);
511
512 private:
513
514 //!
515 //! \brief Parse dump location
516 //! \details Take dump location strings and break down into individual post-
517 //! processing pipeline locations and surface types.
518 //! \param [in] pcDumpLocData
519 //! String containing all dump locations
520 //! \return MOS_STATUS
521 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
522 //!
523 MOS_STATUS ProcessDumpLocations(
524 char* pcDumpLocData);
525
526 //!
527 //! \brief Convert a string to surf enum type
528 //! \param [in] pcSurfType
529 //! The pointer to string to be converted
530 //! \param [out] pSurfType
531 //! Enum version of string
532 //! \return MOS_STATUS
533 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
534 //!
535 MOS_STATUS SurfTypeStringToEnum(
536 char* pcSurfType,
537 VPHAL_SURFACE_TYPE *pSurfType);
538
539 //!
540 //! \brief Removes white space from a C-string
541 //! \param [in] ptr
542 //! String to be trimmed
543 //! \return char*
544 //! String after trim
545 //!
546 char* WhitespaceTrim(
547 char* ptr);
548
549 MEDIA_CLASS_DEFINE_END(VpSurfaceDumper)
550 };
551
552
553 //!
554 //! Class VpPArameerDumper
555 //! \brief RenderParameter Dumper definition
556 //!
557 class VpParameterDumper
558 {
559 public:
560 VPHAL_PARAMS_DUMP_SPEC m_dumpSpec;
561
562 //!
563 //! \brief VphalParameterDumper constuctor
564 //!
565 VpParameterDumper(PMOS_INTERFACE pOsInterface);
566
567 //!
568 //! \brief Get VPHAL Parameters Dump Spec
569 //! \param [in] pDumpSpec
570 //! parameter dump spec
571 //! \param [in] pOsInterface
572 //! OS interface
573 //! \return void
574 //!
575 void GetParametersDumpSpec();
576
577 //!
578 //! \brief VphalParameterDumper destuctor
579 //!
580 virtual ~VpParameterDumper();
581
582 //!
583 //! \brief Dumps the Render Parameters to XML File
584 //! \param [in] uiFrameCounter
585 //! frame counter
586 //! \param [in] pcOutputPath
587 //! Surface dump output path
588 //! \param [in] pRenderParams
589 //! Render parameter to be dumped
590 //! \return MOS_STATUS
591 //!
592 virtual MOS_STATUS DumpToXML(
593 uint32_t uiFrameCounter,
594 char *pcOutputPath,
595 PVPHAL_RENDER_PARAMS pRenderParams);
596
597 //!
598 //! \brief Dumps Sku and Workaround information to XML File
599 //!
600 virtual MOS_STATUS SkuWa_DumpToXML(
601 MEDIA_FEATURE_TABLE *skuTable,
602 MEDIA_WA_TABLE *waTable);
603
604 protected:
605 //!
606 //! \brief Dumps the source Surface Parameters
607 //! \param [in] uiFrameCounter
608 //! frame counter
609 //! \param [in] pcOutputPath
610 //! Surface dump output path
611 //! \param [in] pSrc
612 //! source Surface to be dumped
613 //! \param [in] index
614 //! index of source Surface
615 //! \param [in/out] pcOutContents
616 //! output string buffer
617 //! \return MOS_STATUS
618 //!
619 virtual MOS_STATUS DumpSourceSurface(
620 uint32_t uiFrameCounter,
621 char *pcOutputPath,
622 PVPHAL_SURFACE pSrc,
623 uint32_t index,
624 char* &pcOutContents);
625
626 //!
627 //! \brief Dumps the target Surface Parameters
628 //! \param [in] uiFrameCounter
629 //! frame counter
630 //! \param [in] pcOutputPath
631 //! Surface dump output path
632 //! \param [in] pSrc
633 //! target Surface to be dumped
634 //! \param [in] index
635 //! index of target Surface
636 //! \param [in/out] pcOutContents
637 //! output string buffer
638 //! \return MOS_STATUS
639 //!
640 virtual MOS_STATUS DumpTargetSurface(
641 uint32_t uiFrameCounter,
642 char *pcOutputPath,
643 PVPHAL_SURFACE pTarget,
644 uint32_t index,
645 char* &pcOutContents);
646
647 //!
648 //! \brief Dumps the target Surface Parameters
649 //! \param [in] uiFrameCounter
650 //! frame counter
651 //! \param [in] pcOutputPath
652 //! Surface dump output path
653 //! \param [in] pRenderParams
654 //! Render parameter to be dumped
655 //! \param [in/out] pcOutContents
656 //! output string buffer
657 //! \return MOS_STATUS
658 //!
659 virtual MOS_STATUS DumpRenderParameter(
660 uint32_t uiFrameCounter,
661 char *pcOutputPath,
662 PVPHAL_RENDER_PARAMS pRenderParams,
663 char* &pcOutContents);
664
665 //!
666 //! \brief Gets Debug Component String
667 //! \param [in] component
668 //! Mos component
669 //! \return const char *
670 //! String of the Component
671 //!
672 virtual const char * GetComponentStr(
673 MOS_COMPONENT component);
674
675 private:
676 PMOS_INTERFACE m_osInterface;
677 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; // userSettingInstance
678 //!
679 //! \brief Gets Debug Whole Format String
680 //! \param [in] format
681 //! Mos format
682 //! \return const char *
683 //! String of the whole format sucha as Format_NV12
684 //!
685 const char * GetWholeFormatStr(MOS_FORMAT format);
686
687 //!
688 //! \brief Gets Debug Tile Type String
689 //! \param [in] format
690 //! Mos tile type
691 //! \return const char *
692 //! String of the tile type
693 //!
694 const char * GetTileTypeStr(MOS_TILE_TYPE tile_type);
695
696 //!
697 //! \brief Gets Debug Tile Mode String
698 //! \param [in] tilemode
699 //! Mos tile mode
700 //! \return const char *
701 //! String of the tile type
702 //!
703 const char *GetTileModeGMMStr(MOS_TILE_MODE_GMM tile_mode);
704
705 //!
706 //! \brief Gets Debug Surface Type String
707 //! \param [in] component
708 //! Mos component
709 //! \return const char *
710 //! String of the component
711 //!
712 const char * GetSurfaceTypeStr(VPHAL_SURFACE_TYPE surface_type);
713
714 const char *GetGammaValueTypeStr(VPHAL_GAMMA_VALUE gamma_value);
715 //!
716 //! \brief Gets Debug Sample Type String
717 //! \param [in] sample type
718 //! vphal sample type
719 //! \return const char *
720 //! String of the vphal sample type
721 //!
722 const char * GetSampleTypeStr(VPHAL_SAMPLE_TYPE sample_type);
723
724 //!
725 //! \brief Gets Debug Color Type String
726 //! \param [in] Color type
727 //! vphal color type
728 //! \return const char *
729 //! String of the vphal color type
730 //!
731 const char * GetColorSpaceStr(VPHAL_CSPACE color_space);
732
733 //!
734 //! \brief Gets Debug Blend Type String
735 //! \param [in] Blend type
736 //! vphal blend type
737 //! \return const char *
738 //! String of the vphal color type
739 //!
740 const char * GetBlendTypeStr(VPHAL_BLEND_TYPE blend_type);
741
742 //!
743 //! \brief Gets Debug Palette Type String
744 //! \param [in] palette type
745 //! vphal palette type
746 //! \return const char *
747 //! String of vphal palette type
748 //!
749 const char * GetPaletteTypeStr(VPHAL_PALETTE_TYPE palette_type);
750
751 //!
752 //! \brief Gets Debug Scaling Mode String
753 //! \param [in] scaling mode
754 //! vphal scaling mode
755 //! \return const char *
756 //! String of vphal scaling mode
757 //!
758 const char * GetScalingModeStr(VPHAL_SCALING_MODE scaling_mode);
759
760 //!
761 //! \brief Gets Debug Rotation Mode String
762 //! \param [in] rotation mode
763 //! vphal rotation mode
764 //! \return const char *
765 //! String of vphal rotation mode
766 //!
767 const char * GetRotationModeStr(VPHAL_ROTATION rotation_mode);
768
769 //!
770 //! \brief Gets Debug Deinterlace Mode String
771 //! \param [in] deinterlace mode
772 //! vphal deinterlace mode
773 //! \return const char *
774 //! String of vphal deinterlace mode
775 //!
776 const char * GetDIModeStr(VPHAL_DI_MODE di_mode);
777
778 //!
779 //! \brief Gets Debug Denoise Mode String
780 //! \param [in] denoise level
781 //! vphal denoise level
782 //! \return const char *
783 //! String of vphal denoise level
784 //!
785 const char * GetDenoiseModeStr(VPHAL_NOISELEVEL noise_level);
786
787 //!
788 //! \brief Gets Debug HVS Denoise Mode String
789 //! \param [in] hvs denoise mode
790 //! vphal hvsdn mode
791 //! \return const char *
792 //! String of vphal hvs denoise mode
793 //!
794 const char *GetHVSDenoiseModeStr(VPHAL_HVSDN_MODE hvs_dn_mode);
795
796 MEDIA_CLASS_DEFINE_END(VpParameterDumper)
797 };
798
799 //!
800 //! Class VpDumperTool
801 //! \brief Dumper Tool class definition
802 //!
803 class VpDumperTool
804 {
805 public:
806 //!
807 //! \brief Get a file path in current OS
808 //! \details Covert a file path to a path that can be recognized in current OS.
809 //! File path may be different in different OS.
810 //! \param [in] pcFilePath
811 // Input string of the file path to be converted
812 //! \param [out] pOsFilePath
813 //! Converted file path
814 //! \return void
815 //!
816 static void GetOsFilePath(
817 const char* pcFilePath,
818 char* pOsFilePath);
819
820 //!
821 //! \brief Convert a string to an all lower case version
822 //! \param [in/out] pcString
823 //! The pointer to string to be converted
824 //! \return void
825 //!
826 static void StringToLower(
827 char* pcString);
828
829 //!
830 //! \brief Append to the string
831 //! \details Adds second arg to end of first arg. Works like sprintf, but
832 //! optimized for this special use.
833 //! \param [in] bFirst
834 //! True if this is the first call to this function for next param.
835 //! Note that multiple strings cannot be appended at the same time.
836 //! They should be appended one by one, e.g. pcBigString2 can be appended
837 //! after you finish appending pcBigString1.
838 //! \param [in/out] ppcBigString
839 //! Pointer to string for that is appended to
840 //! \param [in] pcToAppendFmt
841 //! String format for appended part
842 //! \param [in] ...
843 //! Fields to fill in for appended part
844 //! \return MOS_STATUS
845 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
846 //!
847 static MOS_STATUS AppendString(
848 bool bFirst,
849 char **ppcBigString,
850 PCCHAR pcToAppendFmt,
851 ...);
852
853 //!
854 //! \brief Write Frame
855 //! \details Debug function to write intermediate output to C:\dump
856 //! \param [in] pOsInterface
857 //! Pointer to OS interface
858 //! \param [in] pSurface
859 //! Pointer to surface that will be read from
860 //! \param [in] fileName
861 //! File to be written to
862 //! \param [in] iCounter
863 //! Frame ID and cycle counter
864 //! \return void
865 //!
866 static void WriteFrame(
867 PMOS_INTERFACE pOsInterface,
868 PVPHAL_SURFACE pSurface,
869 PCCHAR fileName,
870 uint64_t iCounter);
871
872 //!
873 //! \brief Returns the Size of the surface in bytes
874 //! \param [in] pSurface
875 //! The pointer to the surface
876 //! \param [int] iBpp
877 //! Number of bits per pixel
878 //! \param [out] piWidthInBytes
879 //! Width of the surface
880 //! \param [out] piHeightInRows
881 //! Height of the surface
882 //! \return MOS_STATUS
883 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
884 //!
885 static MOS_STATUS GetSurfaceSize(
886 PVPHAL_SURFACE pSurface,
887 uint32_t iBpp,
888 uint32_t* piWidthInBytes,
889 uint32_t* piHeightInRows);
890
891 //!
892 //! \brief Gets Debug Format String
893 //! \param [in] format
894 //! Mos format
895 //! \return const char *
896 //! String of the format
897 //!
898 static const char * GetFormatStr(
899 MOS_FORMAT format);
900
901 MEDIA_CLASS_DEFINE_END(VpDumperTool)
902 };
903 #endif // (_DEBUG || _RELEASE_INTERNAL)
904
905 #if (!(_DEBUG || _RELEASE_INTERNAL))
906
907 #define VP_PARAMETERS_DUMPPER_DUMP_XML(debuginterface, pRenderParams, frameCounter)
908 #define VP_SURFACE_DUMP(debuginterface, surf, frameCntr, layerCntr, loc)
909 #define VP_SURFACE_PTRS_DUMP( \
910 debuginterface, surfs, maxCntr, numCntr, frameCntr, loc)
911 #define VP_SURF_DUMP_CREATE(surfaceDumper)
912 #define VP_SURF_DUMP_DESTORY(surfaceDumper)
913 #define VP_PARAMETERS_DUMPPER_CREATE(pParametersDumpSpec)
914 #define VP_PARAMETERS_DUMPPER_DESTORY(pParametersDumpSpec)
915 #define VP_DEBUG_INTERFACE_CREATE(debuginterface)
916 #define VP_DEBUG_INTERFACE_DESTROY(debuginterface)
917 #define SkuWaTable_DUMP_XML(skuTable, waTable)
918 #define VP_GET_FORMAT_STRING(format) ""
919 #endif // (!(_DEBUG || _RELEASE_INTERNAL) || EMUL)
920
921
922
923
924 #endif // __VP_DUMPER_H__