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.cpp
24 //! \brief Implementation of functions for debugging
25 //! \details This file contains the Implementation of functions for
26 //! surface dumper and parameter dumper
27 //!
28
29 #if (_DEBUG || _RELEASE_INTERNAL)
30 #include <stdio.h>
31
32 #include "mos_os.h"
33 #include "vp_dumper.h"
34 #include "mos_context_next.h"
35 #include "vp_utils.h"
36
37 #define ALLOC_GRANULARITY 5000000
38
39 //==<Dump Surface>==============================================================
40 #define VPHAL_SURF_DUMP_OUTFILE_KEY_NAME "outfileLocation"
41 #define VPHAL_SURF_DUMP_LOCATION_KEY_NAME "dumpLocations"
42 #define VPHAL_SURF_DUMP_START_FRAME_KEY_NAME "startFrame"
43 #define VPHAL_SURF_DUMP_END_FRAME_KEY_NAME "endFrame"
44 #define VPHAL_SURF_DUMP_MAX_DATA_LEN 200
45 #define VPHAL_SURF_DUMP_TYPE_BACKGROUND "background"
46 #define VPHAL_SURF_DUMP_TYPE_PRIMARY "primary"
47 #define VPHAL_SURF_DUMP_TYPE_SUBSTREAM "substream"
48 #define VPHAL_SURF_DUMP_TYPE_REFERENCE "reference"
49 #define VPHAL_SURF_DUMP_TYPE_RENDERTARGET "rendertarget"
50 #define VPHAL_SURF_DUMP_LOC_PREALL "preall"
51 #define VPHAL_SURF_DUMP_LOC_PREDNDI "predndi"
52 #define VPHAL_SURF_DUMP_LOC_POSTDNDI "postdndi"
53 #define VPHAL_SURF_DUMP_LOC_PRECOMP "precomp"
54 #define VPHAL_SURF_DUMP_LOC_POSTCOMP "postcomp"
55 #define VPHAL_SURF_DUMP_LOC_PREMEMDECOMP "prememdecomp"
56 #define VPHAL_SURF_DUMP_LOC_POSTMEMDECOMP "postmemdecomp"
57 #define VPHAL_SURF_DUMP_LOC_VEBOX_DRIVERHEAP "veboxdriverheap"
58 #define VPHAL_SURF_DUMP_LOC_VEBOX_KERNELHEAP "veboxkernelheap"
59 #define VPHAL_SURF_DUMP_LOC_POSTALL "postall"
60
61 //==<Dump Parameters>====================================================
62 #define VPHAL_PARAMS_DUMP_OUTFILE_KEY_NAME "outxmlLocation"
63 #define VPHAL_PARAMS_DUMP_START_FRAME_KEY_NAME "startxmlFrame"
64 #define VPHAL_PARAMS_DUMP_END_FRAME_KEY_NAME "endxmlFrame"
65
66 //==<Dump DDI>====================================================
67 #define VPHAL_PARAMS_DUMP_DDI_UNKNOWN "unknown"
68 #define VPHAL_PARAMS_DUMP_DDI_VP_BLT "vpblt"
69 #define VPHAL_PARAMS_DUMP_DDI_CLEAR_VIEW "clearview"
70
GetOsFilePath(const char * pcFilePath,char * pOsFilePath)71 void VpDumperTool::GetOsFilePath(
72 const char* pcFilePath,
73 char* pOsFilePath)
74 {
75 VP_FUNC_CALL();
76
77 MOS_SecureMemcpy(pOsFilePath, MAX_PATH, (void*)pcFilePath, strlen(pcFilePath));
78 }
79
GetPlaneDefs(PVPHAL_SURFACE pSurface,VPHAL_SURF_DUMP_SURFACE_DEF * pPlanes,uint32_t * pdwNumPlanes,uint32_t * pdwSize,bool auxEnable,bool isDeswizzled)80 MOS_STATUS VpSurfaceDumper::GetPlaneDefs(
81 PVPHAL_SURFACE pSurface,
82 VPHAL_SURF_DUMP_SURFACE_DEF *pPlanes,
83 uint32_t *pdwNumPlanes,
84 uint32_t *pdwSize,
85 bool auxEnable,
86 bool isDeswizzled)
87 {
88 VP_FUNC_CALL();
89
90 MOS_STATUS eStatus;
91 uint32_t i;
92 bool PaddingEnable = false;
93
94 eStatus = MOS_STATUS_SUCCESS;
95
96 // Caller should supply this much!
97 MOS_ZeroMemory(pPlanes, sizeof(VPHAL_SURF_DUMP_SURFACE_DEF) * 3);
98
99 switch (pSurface->Format)
100 {
101 case Format_AI44:
102 case Format_IA44:
103 case Format_A4L4:
104 case Format_P8:
105 case Format_L8:
106 case Format_A8:
107 case Format_Buffer:
108 case Format_STMM:
109 case Format_IRW4:
110 case Format_IRW5:
111 case Format_IRW6:
112 case Format_IRW7:
113 case Format_RAW:
114 case Format_Y8:
115 *pdwNumPlanes = 1;
116
117 pPlanes[0].dwWidth = pSurface->dwWidth;
118 pPlanes[0].dwHeight = pSurface->dwHeight;
119 pPlanes[0].dwPitch = pSurface->dwPitch;
120 break;
121
122 case Format_R5G6B5:
123 case Format_A8P8:
124 case Format_A8L8:
125 case Format_YUY2:
126 case Format_YUYV:
127 case Format_YVYU:
128 case Format_UYVY:
129 case Format_VYUY:
130 case Format_IRW0:
131 case Format_IRW1:
132 case Format_IRW2:
133 case Format_IRW3:
134 case Format_V8U8:
135 case Format_R16F:
136 case Format_Y16S:
137 case Format_Y16U:
138 case Format_R16UN:
139 *pdwNumPlanes = 1;
140
141 pPlanes[0].dwWidth = pSurface->dwWidth * 2;
142 pPlanes[0].dwHeight = pSurface->dwHeight;
143 pPlanes[0].dwPitch = pSurface->dwPitch;
144 break;
145
146 case Format_R32U:
147 case Format_R32F:
148 case Format_A8R8G8B8:
149 case Format_X8R8G8B8:
150 case Format_A8B8G8R8:
151 case Format_X8B8G8R8:
152 case Format_AYUV:
153 case Format_AUYV:
154 case Format_R10G10B10A2:
155 case Format_B10G10R10A2:
156 case Format_Y410:
157 *pdwNumPlanes = 1;
158
159 pPlanes[0].dwWidth = pSurface->dwWidth * 4;
160 pPlanes[0].dwHeight = pSurface->dwHeight;
161 pPlanes[0].dwPitch = pSurface->dwPitch;
162 break;
163 case Format_R8G8B8:
164 *pdwNumPlanes = 1;
165 pPlanes[0].dwWidth = pSurface->dwWidth * 3;
166 pPlanes[0].dwHeight = pSurface->dwHeight;
167 pPlanes[0].dwPitch = pSurface->dwPitch;
168 break;
169
170 case Format_Y416:
171 case Format_A16B16G16R16:
172 case Format_A16R16G16B16:
173 case Format_A16B16G16R16F:
174 case Format_A16R16G16B16F:
175 *pdwNumPlanes = 1;
176
177 pPlanes[0].dwWidth = pSurface->dwWidth * 8;
178 pPlanes[0].dwHeight = pSurface->dwHeight;
179 pPlanes[0].dwPitch = pSurface->dwPitch;
180 break;
181
182 case Format_NV12:
183 *pdwNumPlanes = 2;
184
185 pPlanes[0].dwWidth = pSurface->dwWidth;
186 pPlanes[0].dwHeight = pSurface->dwHeight;
187 pPlanes[0].dwPitch = pSurface->dwPitch;
188
189 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
190 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
191 pPlanes[1].dwPitch = pSurface->dwPitch;
192 break;
193
194 case Format_P010:
195 case Format_P016:
196 *pdwNumPlanes = 2;
197
198 pPlanes[0].dwWidth = pSurface->dwWidth * 2;
199 pPlanes[0].dwHeight = pSurface->dwHeight;
200 pPlanes[0].dwPitch = pSurface->dwPitch;
201
202 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
203 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
204 pPlanes[1].dwPitch = pSurface->dwPitch;
205 break;
206
207 case Format_IMC2:
208 case Format_IMC4:
209 *pdwNumPlanes = 2;
210
211 pPlanes[0].dwWidth = pSurface->dwWidth;
212 pPlanes[0].dwHeight = pSurface->dwHeight;
213 pPlanes[0].dwPitch = pSurface->dwPitch;
214
215 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
216 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
217 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
218 break;
219
220 case Format_YVU9:
221 *pdwNumPlanes = 3;
222
223 pPlanes[0].dwWidth = pSurface->dwWidth;
224 pPlanes[0].dwHeight = pSurface->dwHeight;
225 pPlanes[0].dwPitch = pSurface->dwPitch;
226
227 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 4;
228 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 4;
229 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
230
231 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 4;
232 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 4;
233 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
234 break;
235
236 case Format_IMC1:
237 case Format_IMC3:
238 *pdwNumPlanes = 3;
239
240 pPlanes[0].dwWidth = pSurface->dwWidth;
241 pPlanes[0].dwHeight = pSurface->dwHeight;
242 pPlanes[0].dwPitch = pSurface->dwPitch;
243
244 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 2;
245 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
246 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
247
248 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 2;
249 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 2;
250 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
251 break;
252
253 case Format_I420:
254 case Format_IYUV:
255 case Format_YV12:
256 *pdwNumPlanes = 3;
257
258 pPlanes[0].dwWidth = pSurface->dwWidth;
259 pPlanes[0].dwHeight = pSurface->dwHeight;
260 pPlanes[0].dwPitch = pSurface->dwPitch;
261
262 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 2;
263 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
264 pPlanes[1].dwPitch = pPlanes[0].dwPitch / 2;
265
266 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 2;
267 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 2;
268 pPlanes[2].dwPitch = pPlanes[0].dwPitch / 2;
269 break;
270 case Format_400P:
271 *pdwNumPlanes = 1;
272
273 pPlanes[0].dwWidth = pSurface->dwWidth;
274 pPlanes[0].dwHeight = pSurface->dwHeight;
275 pPlanes[0].dwPitch = pSurface->dwPitch;
276 break;
277
278 case Format_411P:
279 *pdwNumPlanes = 3;
280
281 pPlanes[0].dwWidth = pSurface->dwWidth;
282 pPlanes[0].dwHeight = pSurface->dwHeight;
283 pPlanes[0].dwPitch = pSurface->dwPitch;
284
285 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 4;
286 pPlanes[1].dwHeight = pPlanes[0].dwHeight;
287 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
288
289 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 4;
290 pPlanes[2].dwHeight = pPlanes[0].dwHeight;
291 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
292 break;
293
294 case Format_411R:
295 *pdwNumPlanes = 3;
296
297 pPlanes[0].dwWidth = pSurface->dwWidth;
298 pPlanes[0].dwHeight = pSurface->dwHeight;
299 pPlanes[0].dwPitch = pSurface->dwPitch;
300
301 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
302 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 4;
303 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
304
305 pPlanes[2].dwWidth = pPlanes[0].dwWidth;
306 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 4;
307 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
308 break;
309
310 case Format_422H:
311 *pdwNumPlanes = 3;
312
313 pPlanes[0].dwWidth = pSurface->dwWidth;
314 pPlanes[0].dwHeight = pSurface->dwHeight;
315 pPlanes[0].dwPitch = pSurface->dwPitch;
316
317 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 2;
318 pPlanes[1].dwHeight = pPlanes[0].dwHeight;
319 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
320
321 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 2;
322 pPlanes[2].dwHeight = pPlanes[0].dwHeight;
323 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
324 break;
325
326 case Format_422V:
327 *pdwNumPlanes = 3;
328
329 pPlanes[0].dwWidth = pSurface->dwWidth;
330 pPlanes[0].dwHeight = pSurface->dwHeight;
331 pPlanes[0].dwPitch = pSurface->dwPitch;
332
333 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
334 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
335 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
336
337 pPlanes[2].dwWidth = pPlanes[0].dwWidth;
338 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 2;
339 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
340 break;
341
342 case Format_444P:
343 case Format_RGBP:
344 case Format_BGRP:
345 *pdwNumPlanes = 3;
346
347 pPlanes[0].dwWidth = pSurface->dwWidth;
348 pPlanes[0].dwHeight = pSurface->dwHeight;
349 pPlanes[0].dwPitch = pSurface->dwPitch;
350
351 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
352 pPlanes[1].dwHeight = pPlanes[0].dwHeight;
353 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
354
355 pPlanes[2].dwWidth = pPlanes[0].dwWidth;
356 pPlanes[2].dwHeight = pPlanes[0].dwHeight;
357 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
358 break;
359
360 case Format_Y210:
361 case Format_Y216:
362 *pdwNumPlanes = 1;
363
364 pPlanes[0].dwWidth = pSurface->dwWidth * 4;
365 pPlanes[0].dwHeight = pSurface->dwHeight;
366 pPlanes[0].dwPitch = pSurface->dwPitch;
367 break;
368
369 case Format_P210:
370 case Format_P216:
371 *pdwNumPlanes = 2;
372
373 pPlanes[0].dwWidth = pSurface->dwWidth * 2;
374 pPlanes[0].dwHeight = pSurface->dwHeight;
375 pPlanes[0].dwPitch = pSurface->dwPitch;
376
377 pPlanes[1].dwWidth = pSurface->dwWidth * 2;
378 pPlanes[1].dwHeight = pSurface->dwHeight;
379 pPlanes[1].dwPitch = pSurface->dwPitch;
380 break;
381
382 default:
383 VP_DEBUG_NORMALMESSAGE("Format '%d' not supported in current driver, using default 1 plane for dump", pSurface->Format);
384 *pdwNumPlanes = 1;
385 pPlanes[0].dwWidth = pSurface->dwWidth;
386 pPlanes[0].dwHeight = pSurface->dwHeight;
387 pPlanes[0].dwPitch = pSurface->dwPitch;
388 break;
389 }
390
391 if (MOS_TILE_LINEAR != pSurface->TileType && (Format_RGBP == pSurface->Format || Format_BGRP == pSurface->Format))
392 {
393 for (i = 0; i < *pdwNumPlanes; i++)
394 {
395 pPlanes[i].dwHeight = MOS_ALIGN_CEIL(pPlanes[i].dwHeight, 16);
396 }
397 }
398 // For Deswizzled surfaces, Mos_Specific_LockResource() already do the de-padding between Y and UV surf.
399 // so, don't use the info of U/V PlaneOffset, as the padding is already removed.
400 for (i = 0; i < *pdwNumPlanes; i++)
401 {
402 switch (i)
403 {
404 case 0:
405 pPlanes[i].dwOffset = pSurface->YPlaneOffset.iSurfaceOffset +
406 (pSurface->YPlaneOffset.iYOffset * pSurface->dwPitch) +
407 pSurface->YPlaneOffset.iXOffset;
408 break;
409 case 1:
410 if (pSurface->Format == Format_YV12)
411 {
412 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[0].dwPitch * pPlanes[0].dwHeight + pPlanes[0].dwOffset : pSurface->VPlaneOffset.iSurfaceOffset) +
413 (pSurface->VPlaneOffset.iYOffset * pSurface->dwPitch) +
414 pSurface->VPlaneOffset.iXOffset;
415 }
416 else
417 {
418 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[0].dwPitch * pPlanes[0].dwHeight + pPlanes[0].dwOffset : pSurface->UPlaneOffset.iSurfaceOffset) +
419 (pSurface->UPlaneOffset.iYOffset * pSurface->dwPitch) +
420 pSurface->UPlaneOffset.iXOffset;
421 }
422 break;
423 case 2:
424 if (pSurface->Format == Format_YV12)
425 {
426 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[1].dwOffset + pPlanes[1].dwPitch * pPlanes[1].dwHeight : pSurface->UPlaneOffset.iSurfaceOffset) +
427 (pSurface->UPlaneOffset.iYOffset * pSurface->dwPitch) +
428 pSurface->UPlaneOffset.iXOffset;
429 }
430 else
431 {
432 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[1].dwOffset + pPlanes[1].dwPitch * pPlanes[1].dwHeight : pSurface->VPlaneOffset.iSurfaceOffset) +
433 (pSurface->VPlaneOffset.iYOffset * pSurface->dwPitch) +
434 pSurface->VPlaneOffset.iXOffset;
435 }
436 break;
437 default:
438 VP_DEBUG_ASSERTMESSAGE("More than 3 planes not supported.");
439 }
440 }
441
442 //compressed surface need 32 align on height
443 if (auxEnable && !isDeswizzled)
444 {
445 for (i = 0; i < *pdwNumPlanes; i++)
446 {
447 pPlanes[i].dwHeight = MOS_ALIGN_CEIL(pPlanes[i].dwHeight, 32);
448 }
449 }
450
451 // For uncompressed surface, padding data is not needed. For compressed surface, padding data is needed for offline check
452 if (auxEnable)
453 {
454 *pdwSize = (pPlanes[0].dwPitch * pPlanes[0].dwHeight) +
455 (pPlanes[1].dwPitch * pPlanes[1].dwHeight) +
456 (pPlanes[2].dwPitch * pPlanes[2].dwHeight);
457 }
458 else
459 {
460 *pdwSize = (pPlanes[0].dwWidth * pPlanes[0].dwHeight) +
461 (pPlanes[1].dwWidth * pPlanes[1].dwHeight) +
462 (pPlanes[2].dwWidth * pPlanes[2].dwHeight);
463 }
464
465 return eStatus;
466 }
467
GetPlaneDefs(PVP_SURFACE pSurface,VPHAL_SURF_DUMP_SURFACE_DEF * pPlanes,uint32_t * pdwNumPlanes,uint32_t * pdwSize,bool auxEnable,bool isDeswizzled)468 MOS_STATUS VpSurfaceDumper::GetPlaneDefs(
469 PVP_SURFACE pSurface,
470 VPHAL_SURF_DUMP_SURFACE_DEF* pPlanes,
471 uint32_t* pdwNumPlanes,
472 uint32_t* pdwSize,
473 bool auxEnable,
474 bool isDeswizzled)
475 {
476 VP_FUNC_CALL();
477
478 MOS_STATUS eStatus;
479 uint32_t i;
480 bool PaddingEnable = false;
481
482 eStatus = MOS_STATUS_SUCCESS;
483
484 // Caller should supply this much!
485 MOS_ZeroMemory(pPlanes, sizeof(VPHAL_SURF_DUMP_SURFACE_DEF) * 3);
486
487 switch (pSurface->osSurface->Format)
488 {
489 case Format_AI44:
490 case Format_IA44:
491 case Format_A4L4:
492 case Format_P8:
493 case Format_L8:
494 case Format_A8:
495 case Format_Buffer:
496 case Format_STMM:
497 case Format_IRW4:
498 case Format_IRW5:
499 case Format_IRW6:
500 case Format_IRW7:
501 case Format_RAW:
502 case Format_Y8:
503 *pdwNumPlanes = 1;
504
505 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
506 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
507 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
508 break;
509
510 case Format_R5G6B5:
511 case Format_A8P8:
512 case Format_A8L8:
513 case Format_YUY2:
514 case Format_YUYV:
515 case Format_YVYU:
516 case Format_UYVY:
517 case Format_VYUY:
518 case Format_IRW0:
519 case Format_IRW1:
520 case Format_IRW2:
521 case Format_IRW3:
522 case Format_V8U8:
523 case Format_R16F:
524 case Format_Y16S:
525 case Format_Y16U:
526 *pdwNumPlanes = 1;
527
528 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth * 2;
529 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
530 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
531 break;
532
533 case Format_R32U:
534 case Format_R32F:
535 case Format_A8R8G8B8:
536 case Format_X8R8G8B8:
537 case Format_A8B8G8R8:
538 case Format_X8B8G8R8:
539 case Format_R8G8B8:
540 case Format_AYUV:
541 case Format_AUYV:
542 case Format_R10G10B10A2:
543 case Format_B10G10R10A2:
544 case Format_Y410:
545 *pdwNumPlanes = 1;
546
547 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth * 4;
548 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
549 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
550 break;
551
552 case Format_Y416:
553 case Format_A16B16G16R16:
554 case Format_A16R16G16B16:
555 case Format_A16B16G16R16F:
556 case Format_A16R16G16B16F:
557 *pdwNumPlanes = 1;
558
559 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth * 8;
560 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
561 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
562 break;
563
564 case Format_NV12:
565 *pdwNumPlanes = 2;
566
567 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
568 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
569 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
570
571 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
572 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
573 pPlanes[1].dwPitch = pSurface->osSurface->dwPitch;
574 break;
575
576 case Format_P010:
577 case Format_P016:
578 *pdwNumPlanes = 2;
579
580 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth * 2;
581 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
582 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
583
584 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
585 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
586 pPlanes[1].dwPitch = pSurface->osSurface->dwPitch;
587 break;
588
589 case Format_IMC2:
590 case Format_IMC4:
591 *pdwNumPlanes = 2;
592
593 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
594 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
595 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
596
597 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
598 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
599 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
600 break;
601
602 case Format_YVU9:
603 *pdwNumPlanes = 3;
604
605 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
606 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
607 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
608
609 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 4;
610 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 4;
611 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
612
613 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 4;
614 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 4;
615 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
616 break;
617
618 case Format_IMC1:
619 case Format_IMC3:
620 *pdwNumPlanes = 3;
621
622 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
623 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
624 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
625
626 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 2;
627 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
628 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
629
630 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 2;
631 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 2;
632 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
633 break;
634
635 case Format_I420:
636 case Format_IYUV:
637 case Format_YV12:
638 *pdwNumPlanes = 3;
639
640 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
641 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
642 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
643
644 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 2;
645 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
646 pPlanes[1].dwPitch = pPlanes[0].dwPitch / 2;
647
648 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 2;
649 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 2;
650 pPlanes[2].dwPitch = pPlanes[0].dwPitch / 2;
651 break;
652 case Format_400P:
653 *pdwNumPlanes = 1;
654
655 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
656 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
657 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
658 break;
659
660 case Format_411P:
661 *pdwNumPlanes = 3;
662
663 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
664 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
665 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
666
667 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 4;
668 pPlanes[1].dwHeight = pPlanes[0].dwHeight;
669 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
670
671 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 4;
672 pPlanes[2].dwHeight = pPlanes[0].dwHeight;
673 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
674 break;
675
676 case Format_411R:
677 *pdwNumPlanes = 3;
678
679 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
680 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
681 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
682
683 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
684 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 4;
685 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
686
687 pPlanes[2].dwWidth = pPlanes[0].dwWidth;
688 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 4;
689 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
690 break;
691
692 case Format_422H:
693 *pdwNumPlanes = 3;
694
695 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
696 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
697 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
698
699 pPlanes[1].dwWidth = pPlanes[0].dwWidth / 2;
700 pPlanes[1].dwHeight = pPlanes[0].dwHeight;
701 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
702
703 pPlanes[2].dwWidth = pPlanes[0].dwWidth / 2;
704 pPlanes[2].dwHeight = pPlanes[0].dwHeight;
705 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
706 break;
707
708 case Format_422V:
709 *pdwNumPlanes = 3;
710
711 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
712 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
713 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
714
715 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
716 pPlanes[1].dwHeight = pPlanes[0].dwHeight / 2;
717 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
718
719 pPlanes[2].dwWidth = pPlanes[0].dwWidth;
720 pPlanes[2].dwHeight = pPlanes[0].dwHeight / 2;
721 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
722 break;
723
724 case Format_444P:
725 case Format_RGBP:
726 case Format_BGRP:
727 *pdwNumPlanes = 3;
728
729 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
730 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
731 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
732
733 pPlanes[1].dwWidth = pPlanes[0].dwWidth;
734 pPlanes[1].dwHeight = pPlanes[0].dwHeight;
735 pPlanes[1].dwPitch = pPlanes[0].dwPitch;
736
737 pPlanes[2].dwWidth = pPlanes[0].dwWidth;
738 pPlanes[2].dwHeight = pPlanes[0].dwHeight;
739 pPlanes[2].dwPitch = pPlanes[0].dwPitch;
740 break;
741
742 case Format_Y210:
743 case Format_Y216:
744 *pdwNumPlanes = 1;
745
746 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth * 4;
747 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
748 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
749 break;
750
751 case Format_P210:
752 case Format_P216:
753 *pdwNumPlanes = 2;
754
755 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth * 2;
756 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
757 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
758
759 pPlanes[1].dwWidth = pSurface->osSurface->dwWidth * 2;
760 pPlanes[1].dwHeight = pSurface->osSurface->dwHeight;
761 pPlanes[1].dwPitch = pSurface->osSurface->dwPitch;
762 break;
763
764 default:
765 VP_DEBUG_NORMALMESSAGE("Format '%d' not supported in current driver, using default 1 plane for dump", pSurface->osSurface->Format);
766 *pdwNumPlanes = 1;
767
768 pPlanes[0].dwWidth = pSurface->osSurface->dwWidth;
769 pPlanes[0].dwHeight = pSurface->osSurface->dwHeight;
770 pPlanes[0].dwPitch = pSurface->osSurface->dwPitch;
771 break;
772 }
773
774 // For Deswizzled surfaces, Mos_Specific_LockResource() already do the de-padding between Y and UV surf.
775 // so, don't use the info of U/V PlaneOffset, as the padding is already removed.
776 for (i = 0; i < *pdwNumPlanes; i++)
777 {
778 switch (i)
779 {
780 case 0:
781 pPlanes[i].dwOffset = pSurface->osSurface->YPlaneOffset.iSurfaceOffset +
782 (pSurface->osSurface->YPlaneOffset.iYOffset * pSurface->osSurface->dwPitch) +
783 pSurface->osSurface->YPlaneOffset.iXOffset;
784 break;
785 case 1:
786 if (pSurface->osSurface->Format == Format_YV12)
787 {
788 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[0].dwPitch * pPlanes[0].dwHeight + pPlanes[0].dwOffset : pSurface->osSurface->VPlaneOffset.iSurfaceOffset) +
789 (pSurface->osSurface->VPlaneOffset.iYOffset * pSurface->osSurface->dwPitch) +
790 pSurface->osSurface->VPlaneOffset.iXOffset;
791 }
792 else
793 {
794 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[0].dwPitch * pPlanes[0].dwHeight + pPlanes[0].dwOffset : pSurface->osSurface->UPlaneOffset.iSurfaceOffset) +
795 (pSurface->osSurface->UPlaneOffset.iYOffset * pSurface->osSurface->dwPitch) +
796 pSurface->osSurface->UPlaneOffset.iXOffset;
797 }
798 break;
799 case 2:
800 if (pSurface->osSurface->Format == Format_YV12)
801 {
802 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[1].dwOffset + pPlanes[1].dwPitch * pPlanes[1].dwHeight : pSurface->osSurface->UPlaneOffset.iSurfaceOffset) +
803 (pSurface->osSurface->UPlaneOffset.iYOffset * pSurface->osSurface->dwPitch) +
804 pSurface->osSurface->UPlaneOffset.iXOffset;
805 }
806 else
807 {
808 pPlanes[i].dwOffset = (isDeswizzled ? pPlanes[1].dwOffset + pPlanes[1].dwPitch * pPlanes[1].dwHeight : pSurface->osSurface->VPlaneOffset.iSurfaceOffset) +
809 (pSurface->osSurface->VPlaneOffset.iYOffset * pSurface->osSurface->dwPitch) +
810 pSurface->osSurface->VPlaneOffset.iXOffset;
811 }
812 break;
813 default:
814 VP_DEBUG_ASSERTMESSAGE("More than 3 planes not supported.");
815 }
816 }
817
818 //compressed surface need 32 align on height
819 if (auxEnable && !isDeswizzled)
820 {
821 for (i = 0; i < *pdwNumPlanes; i++)
822 {
823 pPlanes[i].dwHeight = MOS_ALIGN_CEIL(pPlanes[i].dwHeight, 32);
824 }
825 }
826
827 // For uncompressed surface, padding data is not needed. For compressed surface, padding data is needed for offline check
828 if (auxEnable)
829 {
830 *pdwSize = (pPlanes[0].dwPitch * pPlanes[0].dwHeight) +
831 (pPlanes[1].dwPitch * pPlanes[1].dwHeight) +
832 (pPlanes[2].dwPitch * pPlanes[2].dwHeight);
833 }
834 else
835 {
836 *pdwSize = (pPlanes[0].dwWidth * pPlanes[0].dwHeight) +
837 (pPlanes[1].dwWidth * pPlanes[1].dwHeight) +
838 (pPlanes[2].dwWidth * pPlanes[2].dwHeight);
839 }
840
841 return eStatus;
842 }
843
HasAuxSurf(PMOS_RESOURCE osResource)844 bool VpSurfaceDumper::HasAuxSurf(
845 PMOS_RESOURCE osResource)
846 {
847 VP_FUNC_CALL();
848
849 bool hasAuxSurf = false;
850 #if !EMUL
851 GMM_RESOURCE_FLAG gmmFlags;
852 MOS_ZeroMemory(&gmmFlags, sizeof(gmmFlags));
853 gmmFlags = osResource->pGmmResInfo->GetResFlags();
854 hasAuxSurf = (gmmFlags.Gpu.MMC && gmmFlags.Gpu.UnifiedAuxSurface) ||
855 (gmmFlags.Gpu.CCS && gmmFlags.Gpu.UnifiedAuxSurface && gmmFlags.Info.MediaCompressed);
856 #endif
857 return hasAuxSurf;
858 }
859
CopyThenLockResources(PMOS_INTERFACE pOsInterface,PVPHAL_SURFACE pSurface,PVPHAL_SURFACE & temp2DSurfForCopy,bool hasAuxSurf,bool enableAuxDump,PMOS_LOCK_PARAMS pLockFlags,PMOS_RESOURCE & pLockedResource,VPHAL_SURF_DUMP_SURFACE_DEF * pPlanes,uint32_t * pdwNumPlanes,uint32_t * pdwSize,uint8_t * & pData,const char * psPathPrefix,uint64_t iCounter)860 MOS_STATUS VpSurfaceDumper::CopyThenLockResources(
861 PMOS_INTERFACE pOsInterface,
862 PVPHAL_SURFACE pSurface,
863 PVPHAL_SURFACE &temp2DSurfForCopy,
864 bool hasAuxSurf,
865 bool enableAuxDump,
866 PMOS_LOCK_PARAMS pLockFlags,
867 PMOS_RESOURCE &pLockedResource,
868 VPHAL_SURF_DUMP_SURFACE_DEF *pPlanes,
869 uint32_t *pdwNumPlanes,
870 uint32_t *pdwSize,
871 uint8_t *&pData,
872 const char *psPathPrefix,
873 uint64_t iCounter)
874 {
875 VP_FUNC_CALL();
876
877 bool bAllocated;
878
879 Mos_MemPool memType = MOS_MEMPOOL_SYSTEMMEMORY;
880 #if !EMUL
881 if (pSurface->OsResource.pGmmResInfo->GetSetCpSurfTag(false, 0) != 0)
882 {
883 memType = MOS_MEMPOOL_VIDEOMEMORY;
884 }
885 #endif
886
887 temp2DSurfForCopy = (PVPHAL_SURFACE)MOS_AllocAndZeroMemory(sizeof(VPHAL_SURFACE));
888 VP_DEBUG_CHK_NULL_RETURN(temp2DSurfForCopy);
889 VP_DEBUG_CHK_STATUS_RETURN(VpUtils::ReAllocateSurface(
890 pOsInterface,
891 temp2DSurfForCopy,
892 "Temp2DSurfForSurfDumper",
893 pSurface->Format,
894 MOS_GFXRES_2D,
895 MOS_TILE_LINEAR,
896 pSurface->dwWidth,
897 pSurface->dwHeight,
898 false,
899 MOS_MMC_DISABLED,
900 &bAllocated,
901 MOS_HW_RESOURCE_DEF_MAX,
902 MOS_TILE_UNSET_GMM,
903 memType));
904
905 pOsInterface->pfnDoubleBufferCopyResource(
906 pOsInterface,
907 &pSurface->OsResource,
908 &temp2DSurfForCopy->OsResource,
909 false);
910
911 if (pOsInterface->pfnIsAsynDevice(pOsInterface))
912 {
913 MOS_LOCK_PARAMS LockFlags;
914 char sPath[MAX_PATH];
915 MOS_ZeroMemory(sPath, MAX_PATH);
916 MOS_SecureStringPrint(
917 sPath,
918 MAX_PATH,
919 sizeof(sPath),
920 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].%s",
921 psPathPrefix,
922 iCounter,
923 temp2DSurfForCopy->dwWidth,
924 pPlanes[0].dwHeight,
925 temp2DSurfForCopy->dwPitch,
926 VpDumperTool::GetFormatStr(temp2DSurfForCopy->Format));
927 LockFlags.DumpAfterSubmit = true;
928 ResourceDumpAttri resDumpAttri = {};
929 MOS_GFXRES_FREE_FLAGS resFreeFlags = {0};
930 if (VpUtils::IsSyncFreeNeededForMMCSurface(temp2DSurfForCopy, pOsInterface))
931 {
932 resFreeFlags.SynchronousDestroy = 1;
933 }
934 resDumpAttri.lockFlags = LockFlags;
935 resDumpAttri.res = temp2DSurfForCopy->OsResource;
936 resDumpAttri.res.Format = temp2DSurfForCopy->Format;
937 resDumpAttri.fullFileName = sPath;
938 resDumpAttri.width = temp2DSurfForCopy->dwWidth;
939 resDumpAttri.height = temp2DSurfForCopy->dwHeight;
940 resDumpAttri.pitch = temp2DSurfForCopy->dwPitch;
941 resDumpAttri.resFreeFlags = resFreeFlags;
942 pOsInterface->resourceDumpAttriArray.push_back(resDumpAttri);
943
944 return MOS_STATUS_SUCCESS;
945 }
946
947 pData = (uint8_t *)pOsInterface->pfnLockResource(
948 pOsInterface,
949 &temp2DSurfForCopy->OsResource,
950 pLockFlags);
951 pLockedResource = &temp2DSurfForCopy->OsResource;
952
953 // get plane definitions
954 VP_DEBUG_CHK_STATUS_RETURN(GetPlaneDefs(
955 temp2DSurfForCopy,
956 pPlanes,
957 pdwNumPlanes,
958 pdwSize,
959 hasAuxSurf, //(hasAuxSurf && enableAuxDump),
960 !enableAuxDump)); // !(hasAuxSurf && enableAuxDump)));
961
962 return MOS_STATUS_SUCCESS;
963 }
964
UnlockAndDestroyResource(PMOS_INTERFACE osInterface,PVPHAL_SURFACE tempSurf,PMOS_RESOURCE lockedResource,bool bLockSurface)965 void VpSurfaceDumper::UnlockAndDestroyResource(
966 PMOS_INTERFACE osInterface,
967 PVPHAL_SURFACE tempSurf,
968 PMOS_RESOURCE lockedResource,
969 bool bLockSurface)
970 {
971 VP_FUNC_CALL();
972
973 if (bLockSurface && lockedResource != nullptr)
974 {
975 osInterface->pfnUnlockResource(osInterface, lockedResource);
976 }
977
978 if (tempSurf && osInterface && !osInterface->pfnIsAsynDevice(osInterface))
979 {
980 MOS_GFXRES_FREE_FLAGS resFreeFlags = {0};
981 if (VpUtils::IsSyncFreeNeededForMMCSurface(tempSurf, osInterface))
982 {
983 resFreeFlags.SynchronousDestroy = 1;
984 }
985 osInterface->pfnFreeResourceWithFlag(osInterface, &tempSurf->OsResource, resFreeFlags.Value);
986 }
987 MOS_SafeFreeMemory(tempSurf);
988 }
989
DumpSurfaceToFile(PMOS_INTERFACE pOsInterface,PVPHAL_SURFACE pSurface,const char * psPathPrefix,uint64_t iCounter,bool bLockSurface,bool bNoDecompWhenLock,uint8_t * pData)990 MOS_STATUS VpSurfaceDumper::DumpSurfaceToFile(
991 PMOS_INTERFACE pOsInterface,
992 PVPHAL_SURFACE pSurface,
993 const char *psPathPrefix,
994 uint64_t iCounter,
995 bool bLockSurface,
996 bool bNoDecompWhenLock,
997 uint8_t* pData)
998 {
999 VP_FUNC_CALL();
1000
1001 MOS_STATUS eStatus;
1002 char sPath[MAX_PATH], sOsPath[MAX_PATH];
1003 uint8_t *pDst, *pTmpSrc, *pTmpDst;
1004 uint32_t dwNumPlanes, dwSize, j, i;
1005 VPHAL_SURF_DUMP_SURFACE_DEF planes[3];
1006 uint32_t dstPlaneOffset[3] = {0};
1007 MOS_LOCK_PARAMS LockFlags;
1008 bool hasAuxSurf;
1009 bool enableAuxDump;
1010 bool enablePlaneDump = false;
1011 PMOS_RESOURCE pLockedResource = nullptr;
1012 PVPHAL_SURFACE temp2DSurfForCopy = nullptr;
1013
1014 VP_DEBUG_ASSERT(pSurface);
1015 VP_DEBUG_ASSERT(pOsInterface);
1016 VP_DEBUG_ASSERT(psPathPrefix);
1017
1018 eStatus = MOS_STATUS_SUCCESS;
1019 hasAuxSurf = false;
1020 pDst = nullptr;
1021 enableAuxDump = m_dumpSpec.enableAuxDump;
1022 MOS_ZeroMemory(sPath, MAX_PATH);
1023 MOS_ZeroMemory(sOsPath, MAX_PATH);
1024 dwNumPlanes = 0;
1025 enablePlaneDump = m_dumpSpec.enablePlaneDump;
1026
1027 if (pSurface->dwDepth == 0)
1028 {
1029 pSurface->dwDepth = 1;
1030 }
1031
1032 hasAuxSurf = HasAuxSurf(&pSurface->OsResource);
1033
1034 // get plane definitions
1035 VP_DEBUG_CHK_STATUS(GetPlaneDefs(
1036 pSurface,
1037 planes,
1038 &dwNumPlanes,
1039 &dwSize,
1040 hasAuxSurf, //(hasAuxSurf && enableAuxDump),
1041 !enableAuxDump));// !(hasAuxSurf && enableAuxDump)));
1042
1043 if (bLockSurface)
1044 {
1045 // Caller should not give pData when it expect the function to lock surf
1046 VP_DEBUG_ASSERT(pData = nullptr);
1047
1048 LockFlags.Value = 0;
1049 LockFlags.ReadOnly = 1;
1050
1051 // If aux data exist and enable aux dump, no swizzle and no decompress
1052 if (hasAuxSurf && enableAuxDump)
1053 {
1054 LockFlags.TiledAsTiled = 1;
1055 LockFlags.NoDecompress = 1;
1056 }
1057
1058 if (bNoDecompWhenLock)
1059 {
1060 LockFlags.NoDecompress = 1;
1061 }
1062
1063 bool isPlanar = false;
1064 #if !EMUL
1065 isPlanar = (pSurface->Format == Format_NV12) || (pSurface->Format == Format_P010) || (pSurface->Format == Format_P016);
1066 #endif
1067 VP_DEBUG_CHK_NULL(pOsInterface);
1068 VP_DEBUG_CHK_NULL(pOsInterface->pfnGetSkuTable);
1069 auto *skuTable = pOsInterface->pfnGetSkuTable(pOsInterface);
1070
1071 // RGBP and BGRP support tile output but should not transfer to linear surface due to height 16 align issue.
1072 if (((skuTable && MEDIA_IS_SKU(skuTable, FtrE2ECompression) || isPlanar) &&
1073 (pSurface->TileType != MOS_TILE_LINEAR) &&
1074 !(pSurface->Format == Format_RGBP || pSurface->Format == Format_BGRP)) ||
1075 (pOsInterface->pfnIsAsynDevice(pOsInterface) && pSurface->OsResource.bConvertedFromDDIResource))
1076 {
1077 CopyThenLockResources(pOsInterface, pSurface, temp2DSurfForCopy, hasAuxSurf, enableAuxDump, &LockFlags, pLockedResource, planes, &dwNumPlanes, &dwSize, pData, psPathPrefix, iCounter);
1078 if (pOsInterface->pfnIsAsynDevice(pOsInterface))
1079 {
1080 UnlockAndDestroyResource(pOsInterface, temp2DSurfForCopy, pLockedResource, true);
1081 return eStatus;
1082 }
1083 }
1084 else
1085 {
1086 if (pOsInterface->pfnIsAsynDevice(pOsInterface))
1087 {
1088 MOS_SecureStringPrint(
1089 sPath,
1090 MAX_PATH,
1091 sizeof(sPath),
1092 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].%s",
1093 psPathPrefix,
1094 iCounter,
1095 pSurface->dwWidth,
1096 planes[0].dwHeight,
1097 pSurface->dwPitch,
1098 VpDumperTool::GetFormatStr(pSurface->Format));
1099 LockFlags.DumpAfterSubmit = true;
1100 ResourceDumpAttri resDumpAttri = {};
1101 resDumpAttri.lockFlags = LockFlags;
1102 resDumpAttri.res = pSurface->OsResource;
1103 resDumpAttri.res.Format = pSurface->Format;
1104 resDumpAttri.fullFileName = sPath;
1105 resDumpAttri.width = pSurface->dwWidth;
1106 resDumpAttri.height = pSurface->dwHeight;
1107 resDumpAttri.pitch = pSurface->dwPitch;
1108 pOsInterface->resourceDumpAttriArray.push_back(resDumpAttri);
1109
1110 return eStatus;
1111 }
1112 else
1113 {
1114 pData = (uint8_t *)pOsInterface->pfnLockResource(
1115 pOsInterface,
1116 &pSurface->OsResource,
1117 &LockFlags);
1118 pLockedResource = &pSurface->OsResource;
1119 // if lock failed, fallback to DoubleBufferCopy
1120 if (nullptr == pData)
1121 {
1122 pLockedResource = nullptr;
1123 CopyThenLockResources(pOsInterface, pSurface, temp2DSurfForCopy, hasAuxSurf, enableAuxDump, &LockFlags, pLockedResource, planes, &dwNumPlanes, &dwSize, pData);
1124 }
1125 }
1126 }
1127 VP_DEBUG_CHK_NULL(pData);
1128
1129 // Write error to user feauture key
1130 eStatus = ReportUserSettingForDebug(
1131 m_userSettingPtr,
1132 __VPHAL_DBG_SURF_DUMPER_RESOURCE_LOCK,
1133 1,
1134 MediaUserSetting::Group::Device);
1135
1136 VP_DEBUG_ASSERT(eStatus == MOS_STATUS_SUCCESS);
1137 }
1138
1139 MOS_SecureStringPrint(
1140 sPath,
1141 MAX_PATH,
1142 sizeof(sPath),
1143 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].%s",
1144 psPathPrefix,
1145 iCounter,
1146 pSurface->dwWidth,
1147 planes[0].dwHeight,
1148 pSurface->dwPitch,
1149 VpDumperTool::GetFormatStr(pSurface->Format));
1150
1151 VpDumperTool::GetOsFilePath(sPath, sOsPath);
1152
1153 pDst = (uint8_t*)MOS_AllocAndZeroMemory(dwSize);
1154 VP_DEBUG_CHK_NULL(pDst);
1155 VP_DEBUG_CHK_NULL(pData);
1156 pTmpSrc = pData;
1157 pTmpDst = pDst;
1158
1159 for (j = 0; j < dwNumPlanes; j++)
1160 {
1161 pTmpSrc = pData + planes[j].dwOffset;
1162 for (i = 0; i < planes[j].dwHeight; i++)
1163 {
1164 if (hasAuxSurf && enableAuxDump)
1165 {
1166 MOS_SecureMemcpy(
1167 pTmpDst,
1168 planes[j].dwPitch,
1169 pTmpSrc,
1170 planes[j].dwPitch);
1171
1172 pTmpSrc += planes[j].dwPitch;
1173 pTmpDst += planes[j].dwPitch;
1174
1175 dstPlaneOffset[j+1] += planes[j].dwPitch;
1176 }
1177 else
1178 {
1179 // For RGB24 format, need to remove one invalid zero every 64 byte
1180 // which is designed to avoid splitting two cache lines
1181 if (pSurface->Format == Format_R8G8B8)
1182 {
1183 int dummyBytesPerLine = planes[j].dwWidth / 63;
1184 int resPixel = planes[j].dwWidth - 63 * dummyBytesPerLine;
1185 for (int p = 0; p < dummyBytesPerLine; p++)
1186 {
1187 MOS_SecureMemcpy(
1188 &pTmpDst[p * 63],
1189 63,
1190 &pTmpSrc[p * 64],
1191 63);
1192 }
1193 if (resPixel > 0)
1194 {
1195 MOS_SecureMemcpy(
1196 &pTmpDst[dummyBytesPerLine * 63],
1197 resPixel,
1198 &pTmpSrc[dummyBytesPerLine * 64],
1199 resPixel);
1200 }
1201 }
1202 else
1203 {
1204 MOS_SecureMemcpy(
1205 pTmpDst,
1206 planes[j].dwWidth,
1207 pTmpSrc,
1208 planes[j].dwWidth);
1209
1210 }
1211 pTmpSrc += planes[j].dwPitch;
1212 pTmpDst += planes[j].dwWidth;
1213
1214 dstPlaneOffset[j + 1] += planes[j].dwWidth;
1215 }
1216 }
1217
1218 //if more than 1 plane, dump each plane's surface for offline analysis
1219 if (enablePlaneDump)
1220 {
1221 if ((dwNumPlanes > 1) && (dwNumPlanes <= 3))
1222 {
1223 char sPlanePath[MAX_PATH], sPlaneOsPath[MAX_PATH];
1224 MOS_ZeroMemory(sPlanePath, MAX_PATH);
1225 MOS_ZeroMemory(sPlaneOsPath, MAX_PATH);
1226
1227 MOS_SecureStringPrint(
1228 sPlanePath,
1229 MAX_PATH,
1230 sizeof(sPlanePath),
1231 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].%s",
1232 psPathPrefix,
1233 iCounter,
1234 planes[j].dwWidth,
1235 planes[j].dwHeight,
1236 planes[j].dwPitch,
1237 (j == 0 ? "Y" : ((dwNumPlanes == 2) ? "UV" : ((j == 1) ? "U" : "V"))));
1238
1239 VpDumperTool::GetOsFilePath(sPlanePath, sPlaneOsPath);
1240
1241 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sPlaneOsPath, pDst + dstPlaneOffset[j], dstPlaneOffset[j + 1]));
1242 }
1243 else
1244 {
1245 VP_DEBUG_ASSERTMESSAGE("More than 3 planes not supported during plane dump.");
1246 }
1247 }
1248 }
1249
1250 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pDst, dwSize));
1251 VP_PUBLIC_NORMALMESSAGE("VP surface dump to %s", sOsPath);
1252 #if !EMUL
1253 // Dump Aux surface data
1254 if (hasAuxSurf && enableAuxDump)
1255 {
1256 uint32_t resourceIndex;
1257 bool isPlanar;
1258 uint8_t *auxDataY;
1259 uint8_t *auxDataUV;
1260 uint32_t auxSizeY;
1261 uint32_t auxSizeUV;
1262 uint8_t *pSurfaceBase;
1263
1264 resourceIndex = 0;
1265 pSurfaceBase = pData;
1266 isPlanar = (pOsInterface->pfnGetGmmClientContext(pOsInterface)->IsPlanar(pSurface->OsResource.pGmmResInfo->GetResourceFormat()) != 0);
1267 auxDataY = (uint8_t*)pSurfaceBase + pSurface->OsResource.pGmmResInfo->GetPlanarAuxOffset(resourceIndex, GMM_AUX_Y_CCS);
1268 auxDataUV = (uint8_t*)pSurfaceBase + pSurface->OsResource.pGmmResInfo->GetPlanarAuxOffset(resourceIndex, GMM_AUX_UV_CCS);
1269 if (isPlanar)
1270 {
1271 auxSizeY = (uint32_t)(pSurface->OsResource.pGmmResInfo->GetPlanarAuxOffset(resourceIndex, GMM_AUX_UV_CCS) -
1272 pSurface->OsResource.pGmmResInfo->GetPlanarAuxOffset(resourceIndex, GMM_AUX_Y_CCS));
1273 }else
1274 {
1275 auxSizeY = (uint32_t)(pSurface->OsResource.pGmmResInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1276 }
1277
1278 auxSizeUV = (uint32_t)(pSurface->OsResource.pGmmResInfo->GetPlanarAuxOffset(resourceIndex, GMM_AUX_COMP_STATE) -
1279 pSurface->OsResource.pGmmResInfo->GetPlanarAuxOffset(resourceIndex, GMM_AUX_UV_CCS));
1280
1281 if (auxSizeUV == 0)
1282 {
1283 auxSizeUV = (uint32_t)(pSurface->OsResource.pGmmResInfo->GetSizeAuxSurface(GMM_AUX_SURF)) /
1284 (pSurface->OsResource.pGmmResInfo)->GetArraySize() - auxSizeY;
1285 }
1286
1287 // Dump Y Aux data
1288 MOS_SecureStringPrint(
1289 sPath,
1290 MAX_PATH,
1291 sizeof(sPath),
1292 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].Yaux",
1293 psPathPrefix,
1294 iCounter,
1295 pSurface->dwWidth,
1296 pSurface->dwHeight,
1297 pSurface->dwPitch);
1298
1299 VpDumperTool::GetOsFilePath(sPath, sOsPath);
1300
1301 uint8_t *pDstAux = (uint8_t*)MOS_AllocAndZeroMemory(auxSizeY);
1302 VP_DEBUG_CHK_NULL(pDstAux);
1303
1304 MOS_SecureMemcpy(
1305 pDstAux,
1306 auxSizeY,
1307 auxDataY,
1308 auxSizeY);
1309
1310 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pDstAux, auxSizeY));
1311 MOS_SafeFreeMemory(pDstAux);
1312
1313 if (auxSizeUV && isPlanar)
1314 {
1315 // Dump UV Aux data
1316 MOS_SecureStringPrint(
1317 sPath,
1318 MAX_PATH,
1319 sizeof(sPath),
1320 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].UVaux",
1321 psPathPrefix,
1322 iCounter,
1323 pSurface->dwWidth,
1324 pSurface->dwHeight,
1325 pSurface->dwPitch);
1326
1327 VpDumperTool::GetOsFilePath(sPath, sOsPath);
1328
1329 uint8_t *pDstUVAux = (uint8_t*)MOS_AllocAndZeroMemory(auxSizeUV);
1330 VP_DEBUG_CHK_NULL(pDstUVAux);
1331
1332 MOS_SecureMemcpy(
1333 pDstUVAux,
1334 auxSizeUV,
1335 auxDataUV,
1336 auxSizeUV);
1337
1338 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pDstUVAux, auxSizeUV));
1339 MOS_SafeFreeMemory(pDstUVAux);
1340 }
1341 }
1342 #endif
1343
1344 finish:
1345 MOS_SafeFreeMemory(pDst);
1346
1347 UnlockAndDestroyResource(pOsInterface, temp2DSurfForCopy, pLockedResource, bLockSurface);
1348
1349 return eStatus;
1350 }
1351
1352
DumpSurfaceToFile(PMOS_INTERFACE pOsInterface,PVP_SURFACE pSurface,const char * psPathPrefix,uint64_t iCounter,bool bLockSurface,bool bNoDecompWhenLock,uint8_t * pData)1353 MOS_STATUS VpSurfaceDumper::DumpSurfaceToFile(
1354 PMOS_INTERFACE pOsInterface,
1355 PVP_SURFACE pSurface,
1356 const char *psPathPrefix,
1357 uint64_t iCounter,
1358 bool bLockSurface,
1359 bool bNoDecompWhenLock,
1360 uint8_t* pData)
1361 {
1362 VP_FUNC_CALL();
1363
1364 MOS_STATUS eStatus;
1365 bool isSurfaceLocked;
1366 char sPath[MAX_PATH], sOsPath[MAX_PATH];
1367 uint8_t *pDst, *pTmpSrc, *pTmpDst;
1368 uint32_t dwNumPlanes, dwSize, j, i;
1369 VPHAL_SURF_DUMP_SURFACE_DEF planes[3];
1370 uint32_t dstPlaneOffset[3] = {0};
1371 MOS_LOCK_PARAMS LockFlags;
1372 bool hasAuxSurf;
1373 bool enableAuxDump;
1374 bool enablePlaneDump = false;
1375 PMOS_RESOURCE pLockedResource = nullptr;
1376
1377 VP_DEBUG_ASSERT(pSurface);
1378 VP_DEBUG_ASSERT(pOsInterface);
1379 VP_DEBUG_ASSERT(psPathPrefix);
1380
1381 eStatus = MOS_STATUS_SUCCESS;
1382 isSurfaceLocked = false;
1383 hasAuxSurf = false;
1384 pDst = nullptr;
1385 enableAuxDump = m_dumpSpec.enableAuxDump;
1386 MOS_ZeroMemory(sPath, MAX_PATH);
1387 MOS_ZeroMemory(sOsPath, MAX_PATH);
1388 dwNumPlanes = 0;
1389 enablePlaneDump = m_dumpSpec.enablePlaneDump;
1390
1391 if (pSurface->osSurface->dwDepth == 0)
1392 {
1393 pSurface->osSurface->dwDepth = 1;
1394 }
1395
1396 hasAuxSurf = HasAuxSurf(&pSurface->osSurface->OsResource);
1397
1398 // get plane definitions
1399 VP_DEBUG_CHK_STATUS(GetPlaneDefs(
1400 pSurface,
1401 planes,
1402 &dwNumPlanes,
1403 &dwSize,
1404 hasAuxSurf, //(hasAuxSurf && enableAuxDump),
1405 !enableAuxDump));// !(hasAuxSurf && enableAuxDump)));
1406
1407 if (bLockSurface)
1408 {
1409 // Caller should not give pData when it expect the function to lock surf
1410 VP_DEBUG_ASSERT(pData = nullptr);
1411
1412 LockFlags.Value = 0;
1413 LockFlags.ReadOnly = 1;
1414
1415 // If aux data exist and enable aux dump, no swizzle and no decompress
1416 if (hasAuxSurf && enableAuxDump)
1417 {
1418 LockFlags.TiledAsTiled = 1;
1419 LockFlags.NoDecompress = 1;
1420 }
1421
1422 if (bNoDecompWhenLock)
1423 {
1424 LockFlags.NoDecompress = 1;
1425 }
1426
1427 bool isPlanar = false;
1428 isPlanar = (pSurface->osSurface->OsResource.Format == Format_NV12) || (pSurface->osSurface->OsResource.Format == Format_P010) || (pSurface->osSurface->OsResource.Format == Format_P016);
1429
1430 {
1431 pData = (uint8_t *)pOsInterface->pfnLockResource(
1432 pOsInterface,
1433 &pSurface->osSurface->OsResource,
1434 &LockFlags);
1435 pLockedResource = &pSurface->osSurface->OsResource;
1436 }
1437 VP_DEBUG_CHK_NULL(pData);
1438
1439 // Write error to user feauture key
1440 eStatus = ReportUserSettingForDebug(
1441 m_userSettingPtr,
1442 __VPHAL_DBG_SURF_DUMPER_RESOURCE_LOCK,
1443 1,
1444 MediaUserSetting::Group::Device);
1445
1446 VP_DEBUG_ASSERT(eStatus == MOS_STATUS_SUCCESS);
1447 isSurfaceLocked = true;
1448 }
1449
1450 MOS_SecureStringPrint(
1451 sPath,
1452 MAX_PATH,
1453 sizeof(sPath),
1454 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].%s",
1455 psPathPrefix,
1456 iCounter,
1457 pSurface->osSurface->dwWidth,
1458 pSurface->osSurface->dwHeight,
1459 pSurface->osSurface->dwPitch,
1460 VpDumperTool::GetFormatStr(pSurface->osSurface->Format));
1461
1462 VpDumperTool::GetOsFilePath(sPath, sOsPath);
1463
1464 pDst = (uint8_t*)MOS_AllocAndZeroMemory(dwSize);
1465 VP_DEBUG_CHK_NULL(pDst);
1466 VP_DEBUG_CHK_NULL(pData);
1467 pTmpSrc = pData;
1468 pTmpDst = pDst;
1469
1470 for (j = 0; j < dwNumPlanes; j++)
1471 {
1472 for (i = 0; i < planes[j].dwHeight; i++)
1473 {
1474 if (hasAuxSurf && enableAuxDump)
1475 {
1476 MOS_SecureMemcpy(
1477 pTmpDst,
1478 planes[j].dwPitch,
1479 pTmpSrc,
1480 planes[j].dwPitch);
1481
1482 pTmpSrc += planes[j].dwPitch;
1483 pTmpDst += planes[j].dwPitch;
1484
1485 dstPlaneOffset[j+1] += planes[j].dwPitch;
1486 }
1487 else
1488 {
1489 MOS_SecureMemcpy(
1490 pTmpDst,
1491 planes[j].dwWidth,
1492 pTmpSrc,
1493 planes[j].dwWidth);
1494
1495 pTmpSrc += planes[j].dwPitch;
1496 pTmpDst += planes[j].dwWidth;
1497
1498 dstPlaneOffset[j+1] += planes[j].dwWidth;
1499 }
1500 }
1501
1502 //if more than 1 plane, dump each plane's surface for offline analysis
1503 if (enablePlaneDump)
1504 {
1505 if ((dwNumPlanes > 1) && (dwNumPlanes <= 3))
1506 {
1507 char sPlanePath[MAX_PATH], sPlaneOsPath[MAX_PATH];
1508 MOS_ZeroMemory(sPlanePath, MAX_PATH);
1509 MOS_ZeroMemory(sPlaneOsPath, MAX_PATH);
1510
1511 MOS_SecureStringPrint(
1512 sPlanePath,
1513 MAX_PATH,
1514 sizeof(sPlanePath),
1515 "%s_f[%04lld]_w[%d]_h[%d]_p[%d].%s",
1516 psPathPrefix,
1517 iCounter,
1518 planes[j].dwWidth,
1519 planes[j].dwHeight,
1520 planes[j].dwPitch,
1521 (j == 0 ? "Y" : ((dwNumPlanes == 2) ? "UV" : ((j == 1) ? "U" : "V"))));
1522
1523 VpDumperTool::GetOsFilePath(sPlanePath, sPlaneOsPath);
1524
1525 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sPlaneOsPath, pDst + dstPlaneOffset[j], dstPlaneOffset[j + 1]));
1526 }
1527 else
1528 {
1529 VP_DEBUG_ASSERTMESSAGE("More than 3 planes not supported during plane dump.");
1530 }
1531 }
1532 }
1533
1534 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pDst, dwSize));
1535 VP_PUBLIC_NORMALMESSAGE("VP surface dump to %s", sOsPath);
1536 finish:
1537 MOS_SafeFreeMemory(pDst);
1538
1539 if (isSurfaceLocked && pLockedResource != nullptr)
1540 {
1541 eStatus = (MOS_STATUS)pOsInterface->pfnUnlockResource(pOsInterface, pLockedResource);
1542 VP_DEBUG_ASSERT(eStatus == MOS_STATUS_SUCCESS);
1543 }
1544
1545 return eStatus;
1546 }
1547
WhitespaceTrim(char * ptr)1548 char* VpSurfaceDumper::WhitespaceTrim(
1549 char* ptr)
1550 {
1551 VP_FUNC_CALL();
1552
1553 char* pcTemp; // pointer to temp string to remove spces
1554
1555 VP_DEBUG_ASSERT(ptr);
1556
1557 if(strlen(ptr) == 0)
1558 {
1559 goto finish;
1560 }
1561
1562 //remove left spaces
1563 while (*ptr == ' ' || *ptr == '\t')
1564 {
1565 ptr++;
1566 }
1567
1568 //remove right spaces
1569 pcTemp = ptr + strlen(ptr)-1;
1570 while(*pcTemp == ' '|| *pcTemp == '\t')
1571 {
1572 pcTemp--;
1573 }
1574 *(++pcTemp) = '\0';
1575
1576 finish:
1577 return ptr;
1578 }
1579
StringToLower(char * pcString)1580 void VpDumperTool::StringToLower(
1581 char* pcString)
1582 {
1583 VP_FUNC_CALL();
1584
1585 size_t stStrLen; // length of string
1586 size_t i; // loop iterator
1587
1588 stStrLen = strlen(pcString);
1589 for (i = 0; i < stStrLen; i++)
1590 {
1591 if (isupper(pcString[i]))
1592 {
1593 pcString[i] = (char)tolower(pcString[i]);
1594 }
1595 }
1596 }
1597
LocStringToEnum(char * pcLocString,uint32_t * pLocation)1598 MOS_STATUS VpSurfaceDumper::LocStringToEnum(
1599 char* pcLocString,
1600 uint32_t *pLocation)
1601 {
1602 VP_FUNC_CALL();
1603
1604 MOS_STATUS eStatus;
1605
1606 eStatus = MOS_STATUS_SUCCESS;
1607
1608 VpDumperTool::StringToLower(pcLocString);
1609 if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_PREALL) == 0)
1610 {
1611 *pLocation = VPHAL_DUMP_TYPE_PRE_ALL;
1612 }
1613 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_PREDNDI) == 0)
1614 {
1615 *pLocation = VPHAL_DUMP_TYPE_PRE_DNDI;
1616 }
1617 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_POSTDNDI) == 0)
1618 {
1619 *pLocation = VPHAL_DUMP_TYPE_POST_DNDI;
1620 }
1621 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_PRECOMP) == 0)
1622 {
1623 *pLocation = VPHAL_DUMP_TYPE_PRE_COMP;
1624 }
1625 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_POSTCOMP) == 0)
1626 {
1627 *pLocation = VPHAL_DUMP_TYPE_POST_COMP;
1628 }
1629 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_PREMEMDECOMP) == 0)
1630 {
1631 *pLocation = VPHAL_DUMP_TYPE_PRE_MEMDECOMP;
1632 }
1633 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_POSTMEMDECOMP) == 0)
1634 {
1635 *pLocation = VPHAL_DUMP_TYPE_POST_MEMDECOMP;
1636 }
1637 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_POSTALL) == 0)
1638 {
1639 *pLocation = VPHAL_DUMP_TYPE_POST_ALL;
1640 }
1641 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_VEBOX_DRIVERHEAP) == 0)
1642 {
1643 *pLocation = VPHAL_DUMP_TYPE_VEBOX_DRIVERHEAP;
1644 }
1645 else if (strcmp(pcLocString, VPHAL_SURF_DUMP_LOC_VEBOX_KERNELHEAP) == 0)
1646 {
1647 *pLocation = VPHAL_DUMP_TYPE_VEBOX_KERNELHEAP;
1648 }
1649 else
1650 {
1651 VP_DEBUG_NORMALMESSAGE("Unknown dump location \"%s\".", pcLocString);
1652 eStatus = MOS_STATUS_UNKNOWN;
1653 goto finish;
1654 }
1655
1656 finish:
1657 return eStatus;
1658 }
1659
EnumToLocString(uint32_t Location,char * pcLocString)1660 MOS_STATUS VpSurfaceDumper::EnumToLocString(
1661 uint32_t Location,
1662 char* pcLocString)
1663 {
1664 VP_FUNC_CALL();
1665
1666 MOS_STATUS eStatus;
1667 uint32_t i;
1668 size_t stStrLen;
1669
1670 eStatus = MOS_STATUS_SUCCESS;
1671
1672 if (pcLocString == nullptr)
1673 {
1674 eStatus = MOS_STATUS_INVALID_PARAMETER;
1675 goto finish;
1676 }
1677
1678 switch (Location)
1679 {
1680 case VPHAL_DUMP_TYPE_PRE_ALL:
1681 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_PREALL);
1682 break;
1683 case VPHAL_DUMP_TYPE_PRE_DNDI:
1684 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_PREDNDI);
1685 break;
1686 case VPHAL_DUMP_TYPE_POST_DNDI:
1687 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_POSTDNDI);
1688 break;
1689 case VPHAL_DUMP_TYPE_PRE_COMP:
1690 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_PRECOMP);
1691 break;
1692 case VPHAL_DUMP_TYPE_POST_COMP:
1693 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_POSTCOMP);
1694 break;
1695 case VPHAL_DUMP_TYPE_PRE_MEMDECOMP:
1696 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_PREMEMDECOMP);
1697 break;
1698 case VPHAL_DUMP_TYPE_POST_MEMDECOMP:
1699 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_POSTMEMDECOMP);
1700 break;
1701 case VPHAL_DUMP_TYPE_POST_ALL:
1702 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_POSTALL);
1703 break;
1704 case VPHAL_DUMP_TYPE_VEBOX_DRIVERHEAP:
1705 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_VEBOX_DRIVERHEAP);
1706 break;
1707 case VPHAL_DUMP_TYPE_VEBOX_KERNELHEAP:
1708 MOS_SecureStringPrint(pcLocString, MAX_PATH, MAX_PATH, VPHAL_SURF_DUMP_LOC_VEBOX_KERNELHEAP);
1709 break;
1710 default:
1711 VP_DEBUG_ASSERTMESSAGE("Unknown dump location \"%d\".", Location);
1712 eStatus = MOS_STATUS_UNKNOWN;
1713 goto finish;
1714 } // end switch
1715
1716 stStrLen = strlen(pcLocString);
1717 VP_DEBUG_ASSERT(stStrLen > 1); // assert b/c invalid access if <= 1
1718 i = pcLocString[1] == 'r' ? 3 : 4; // If pre, start i at 3, else 4
1719 // Maybe should add error case in case macros get changed later?
1720 for (; i < stStrLen; i++)
1721 {
1722 pcLocString[i] = (char)toupper(pcLocString[i]);
1723 }
1724
1725 finish:
1726 return eStatus;
1727 }
1728
EnumToDdiString(uint32_t uiDDI,char * pcDdiString)1729 MOS_STATUS VpSurfaceDumper::EnumToDdiString(
1730 uint32_t uiDDI,
1731 char* pcDdiString)
1732 {
1733 VP_DEBUG_CHK_NULL_RETURN(pcDdiString)
1734
1735 switch (uiDDI)
1736 {
1737 case VPHAL_SURF_DUMP_DDI_UNKNOWN:
1738 MOS_SecureStringPrint(pcDdiString, MAX_PATH, MAX_PATH, VPHAL_PARAMS_DUMP_DDI_UNKNOWN);
1739 break;
1740 case VPHAL_SURF_DUMP_DDI_VP_BLT:
1741 MOS_SecureStringPrint(pcDdiString, MAX_PATH, MAX_PATH, VPHAL_PARAMS_DUMP_DDI_VP_BLT);
1742 break;
1743 case VPHAL_SURF_DUMP_DDI_CLEAR_VIEW:
1744 MOS_SecureStringPrint(pcDdiString, MAX_PATH, MAX_PATH, VPHAL_PARAMS_DUMP_DDI_CLEAR_VIEW);
1745 break;
1746 default:
1747 VP_DEBUG_ASSERTMESSAGE("Unknown dump DDI \"%d\".", uiDDI);
1748 return MOS_STATUS_UNKNOWN;
1749 }
1750
1751 return MOS_STATUS_SUCCESS;
1752 }
1753
SurfTypeStringToEnum(char * pcSurfType,VPHAL_SURFACE_TYPE * pSurfType)1754 MOS_STATUS VpSurfaceDumper::SurfTypeStringToEnum(
1755 char* pcSurfType,
1756 VPHAL_SURFACE_TYPE *pSurfType)
1757 {
1758 VP_FUNC_CALL();
1759
1760 MOS_STATUS eStatus;
1761
1762 eStatus = MOS_STATUS_SUCCESS;
1763 VpDumperTool::StringToLower(pcSurfType);
1764 if (strcmp(pcSurfType, VPHAL_SURF_DUMP_TYPE_BACKGROUND) == 0)
1765 {
1766 *pSurfType = SURF_IN_BACKGROUND;
1767 }
1768 else if (strcmp(pcSurfType, VPHAL_SURF_DUMP_TYPE_PRIMARY) == 0)
1769 {
1770 *pSurfType = SURF_IN_PRIMARY;
1771 }
1772 else if (strcmp(pcSurfType, VPHAL_SURF_DUMP_TYPE_SUBSTREAM) == 0)
1773 {
1774 *pSurfType = SURF_IN_SUBSTREAM;
1775 }
1776 else if (strcmp(pcSurfType, VPHAL_SURF_DUMP_TYPE_REFERENCE) == 0)
1777 {
1778 *pSurfType = SURF_IN_REFERENCE;
1779 }
1780 else if (strcmp(pcSurfType, VPHAL_SURF_DUMP_TYPE_RENDERTARGET) == 0)
1781 {
1782 *pSurfType = SURF_OUT_RENDERTARGET;
1783 }
1784 else
1785 {
1786 VP_DEBUG_ASSERTMESSAGE("Unknown surface type \"%s\".", pcSurfType);
1787 eStatus = MOS_STATUS_UNKNOWN;
1788 goto finish;
1789 }
1790
1791 finish:
1792 return eStatus;
1793 }
1794
1795
ProcessDumpLocations(char * pcDumpLocData)1796 MOS_STATUS VpSurfaceDumper::ProcessDumpLocations(
1797 char* pcDumpLocData)
1798 {
1799 VP_FUNC_CALL();
1800
1801 MOS_STATUS eStatus;
1802 char* pcCommaLoc; // pointer to next comma in dump location string
1803 char* pcCurrToken; // pointer to current token in a string
1804 char* pcColonLoc; // pointer to next colon in location string
1805 int32_t iNumStrings; // number of dump locations
1806 int32_t i; // loop iteration counter
1807 VPHAL_SURF_DUMP_SPEC *pDumpSpec = &m_dumpSpec;
1808
1809 eStatus = MOS_STATUS_SUCCESS;
1810 iNumStrings = 0;
1811
1812 if (strlen(pcDumpLocData) > 0)
1813 {
1814 // Count number of strings in key data
1815 // If non empty string, there is at least one value
1816 iNumStrings++;
1817 // Count the rest
1818 pcCommaLoc = pcDumpLocData;
1819 while ((pcCommaLoc = strchr(pcCommaLoc + 1, ',')) != nullptr)
1820 {
1821 iNumStrings++;
1822 }
1823
1824 // Set number of strings and allocate space for them
1825 pDumpSpec->iNumDumpLocs = iNumStrings;
1826 pDumpSpec->pDumpLocations = (VPHAL_SURF_DUMP_LOC*)MOS_AllocAndZeroMemory(
1827 sizeof(VPHAL_SURF_DUMP_LOC) * pDumpSpec->iNumDumpLocs);
1828 pcCurrToken = pcDumpLocData;
1829
1830 // Determine each part of the string
1831 for (i = 0; i < pDumpSpec->iNumDumpLocs; i++)
1832 {
1833 pcCommaLoc = strchr(pcCurrToken, ',');
1834 if (pcCommaLoc != nullptr)
1835 {
1836 *pcCommaLoc = '\0';
1837 }
1838
1839 // Handle surface type
1840 pcColonLoc = strchr(pcCurrToken, ':');
1841 if (pcColonLoc == nullptr)
1842 {
1843 // Dump all
1844 pDumpSpec->pDumpLocations[i].SurfType = SURF_NONE;
1845 }
1846 else
1847 {
1848 // Remove surface type from dump location
1849 *pcColonLoc = '\0';
1850 // Set surface type
1851 pcColonLoc++;
1852
1853 pcColonLoc = WhitespaceTrim(pcColonLoc);
1854 VP_DEBUG_CHK_STATUS(SurfTypeStringToEnum(pcColonLoc,
1855 &(pDumpSpec->pDumpLocations[i].SurfType)));
1856 }
1857
1858 //trim the whitespaces from dump location
1859 pcCurrToken = WhitespaceTrim(pcCurrToken);
1860
1861 VP_DEBUG_CHK_STATUS(LocStringToEnum(pcCurrToken,
1862 &(pDumpSpec->pDumpLocations[i].DumpLocation)));
1863 if (pcCommaLoc != nullptr)
1864 {
1865 pcCurrToken = pcCommaLoc + 1;
1866 }
1867 } // end for each part of the string
1868 } // if data length > 0
1869 finish:
1870 return eStatus;
1871 }
1872
GetSurfaceDumpSpecForVPSolo(VPHAL_SURF_DUMP_SPEC * pDumpSpec,MediaUserSetting::Value outValue)1873 void VpSurfaceDumper::GetSurfaceDumpSpecForVPSolo(VPHAL_SURF_DUMP_SPEC *pDumpSpec, MediaUserSetting::Value outValue)
1874 {
1875 VP_FUNC_CALL();
1876
1877 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1878 pDumpSpec->uiStartFrame = 0;
1879 pDumpSpec->uiEndFrame = 0xFFFFFFFF;
1880 outValue = "C:\\dumps";
1881 if (outValue.ConstString().size() > 0 && outValue.ConstString().size() < MOS_USER_CONTROL_MAX_DATA_SIZE)
1882 {
1883 // Copy the Output path
1884 MOS_SecureMemcpy(
1885 pDumpSpec->pcOutputPath,
1886 MAX_PATH,
1887 outValue.ConstString().c_str(),
1888 outValue.ConstString().size());
1889 }
1890 outValue = "postall";
1891 if (outValue.ConstString().size() > 0 && outValue.ConstString().size() < MOS_USER_CONTROL_MAX_DATA_SIZE && pDumpSpec->pcOutputPath[0] != '\0')
1892 {
1893 VP_DEBUG_CHK_STATUS(ProcessDumpLocations(const_cast<char *>(outValue.ConstString().c_str())));
1894 }
1895
1896 finish:
1897 if ((eStatus != MOS_STATUS_SUCCESS) || (pDumpSpec->pcOutputPath[0] == '\0'))
1898 {
1899 pDumpSpec->uiStartFrame = 1;
1900 pDumpSpec->uiEndFrame = 0;
1901 }
1902 }
1903
GetSurfaceDumpSpec()1904 void VpSurfaceDumper::GetSurfaceDumpSpec()
1905 {
1906 VP_FUNC_CALL();
1907
1908 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
1909 char pcDumpLocData[VPHAL_SURF_DUMP_MAX_DATA_LEN];
1910 VPHAL_SURF_DUMP_SPEC *pDumpSpec = &m_dumpSpec;
1911 MediaUserSetting::Value outValue;
1912
1913 pDumpSpec->uiStartFrame = 0xFFFFFFFF;
1914 pDumpSpec->uiEndFrame = 0;
1915 pDumpSpec->pcOutputPath[0] = '\0';
1916 pcDumpLocData[0] = '\0';
1917
1918 #if EMUL
1919 GetSurfaceDumpSpecForVPSolo(pDumpSpec, outValue);
1920 return;
1921 #endif
1922
1923 // Get start frame
1924 // if start frame is not got assign a default value of 0
1925 ReadUserSettingForDebug(
1926 m_userSettingPtr,
1927 pDumpSpec->uiStartFrame,
1928 __VPHAL_DBG_SURF_DUMP_START_FRAME_KEY_NAME,
1929 MediaUserSetting::Group::Device);
1930
1931 // Get end frame
1932 // if end frame is not got assign a default value of max
1933 ReadUserSettingForDebug(
1934 m_userSettingPtr,
1935 pDumpSpec->uiEndFrame,
1936 __VPHAL_DBG_SURF_DUMP_END_FRAME_KEY_NAME,
1937 MediaUserSetting::Group::Device);
1938
1939 // Get out file path
1940 ReadUserSettingForDebug(
1941 m_userSettingPtr,
1942 outValue,
1943 __VPHAL_DBG_SURF_DUMP_OUTFILE_KEY_NAME,
1944 MediaUserSetting::Group::Device);
1945
1946 if (outValue.ConstString().size() > 0 && outValue.ConstString().size() < MOS_USER_CONTROL_MAX_DATA_SIZE)
1947 {
1948 // Copy the Output path
1949 MOS_SecureMemcpy(
1950 pDumpSpec->pcOutputPath,
1951 MAX_PATH,
1952 outValue.ConstString().c_str(),
1953 outValue.ConstString().size());
1954 }
1955 #if !defined(LINUX) && !defined(ANDROID)
1956 else
1957 {
1958 std::string vphalDumpFilePath;
1959
1960 // Use state separation APIs to obtain appropriate storage location
1961 if (SUCCEEDED(GetDriverPersistentStorageLocation(vphalDumpFilePath)))
1962 {
1963 std::string m_outputFilePath;
1964
1965 m_outputFilePath = vphalDumpFilePath.c_str();
1966 m_outputFilePath.append(VPHAL_DUMP_OUTPUT_FOLDER);
1967
1968 // Copy the Output path
1969 MOS_SecureMemcpy(
1970 pDumpSpec->pcOutputPath,
1971 MAX_PATH,
1972 m_outputFilePath.c_str(),
1973 m_outputFilePath.size());
1974
1975 ReportUserSettingForDebug(m_userSettingPtr, __VPHAL_DBG_DUMP_OUTPUT_DIRECTORY, m_outputFilePath, MediaUserSetting::Group::Sequence);
1976 }
1977 }
1978 #endif
1979
1980 // Get dump locations
1981 outValue = "";
1982 ReadUserSettingForDebug(
1983 m_userSettingPtr,
1984 outValue,
1985 __VPHAL_DBG_SURF_DUMP_LOCATION_KEY_NAME,
1986 MediaUserSetting::Group::Device);
1987 if (outValue.ConstString().size() > 0 && outValue.ConstString().size() < MOS_USER_CONTROL_MAX_DATA_SIZE
1988 && pDumpSpec->pcOutputPath[0] != '\0')
1989 {
1990 VP_DEBUG_CHK_STATUS(ProcessDumpLocations(const_cast<char *>(outValue.ConstString().c_str())));
1991 }
1992
1993 // Get enableAuxDump
1994 ReadUserSettingForDebug(
1995 m_userSettingPtr,
1996 pDumpSpec->enableAuxDump,
1997 __VPHAL_DBG_SURF_DUMP_ENABLE_AUX_DUMP,
1998 MediaUserSetting::Group::Device);
1999
2000 // Get plane dump enabled flag
2001 ReadUserSettingForDebug(
2002 m_userSettingPtr,
2003 pDumpSpec->enablePlaneDump,
2004 __VPHAL_DBG_SURF_DUMPER_ENABLE_PLANE_DUMP,
2005 MediaUserSetting::Group::Device);
2006
2007 finish:
2008 if ((eStatus != MOS_STATUS_SUCCESS) || (pDumpSpec->pcOutputPath[0] == '\0'))
2009 {
2010 pDumpSpec->uiStartFrame = 1;
2011 pDumpSpec->uiEndFrame = 0;
2012 }
2013 }
2014
VpSurfaceDumper(PMOS_INTERFACE pOsInterface)2015 VpSurfaceDumper::VpSurfaceDumper(PMOS_INTERFACE pOsInterface) :
2016 m_dumpSpec(),
2017 m_osInterface(pOsInterface)
2018 {
2019 if (m_osInterface)
2020 {
2021 m_userSettingPtr = m_osInterface->pfnGetUserSettingInstance(m_osInterface);
2022 }
2023 }
2024
~VpSurfaceDumper()2025 VpSurfaceDumper::~VpSurfaceDumper()
2026 {
2027 MOS_SafeFreeMemory(m_dumpSpec.pDumpLocations);
2028 }
2029
2030
DumpSurface(PVPHAL_SURFACE pSurf,uint32_t uiFrameNumber,uint32_t uiCounter,uint32_t Location,uint32_t uiDDI)2031 MOS_STATUS VpSurfaceDumper::DumpSurface(
2032 PVPHAL_SURFACE pSurf,
2033 uint32_t uiFrameNumber,
2034 uint32_t uiCounter,
2035 uint32_t Location,
2036 uint32_t uiDDI)
2037 {
2038 VP_FUNC_CALL();
2039
2040 int32_t VphalSurfDumpManualTrigger = VPHAL_SURF_DUMP_MANUAL_TRIGGER_DEFAULT_NOT_SET;
2041
2042 MOS_STATUS eStatus;
2043 int32_t i;
2044 VPHAL_SURF_DUMP_SPEC* pDumpSpec = &m_dumpSpec;
2045 bool isDumpFromDecomp;
2046 bool orgDumpAuxEnable;
2047 int32_t pid = MosUtilities::MosGetPid();
2048 uint64_t timeStamp = 0;
2049
2050 MosUtilities::MosQueryPerformanceCounter(&timeStamp);
2051 eStatus = MOS_STATUS_SUCCESS;
2052 i = 0;
2053 isDumpFromDecomp = (Location == VPHAL_DUMP_TYPE_PRE_MEMDECOMP || Location == VPHAL_DUMP_TYPE_POST_MEMDECOMP);
2054
2055 orgDumpAuxEnable = m_dumpSpec.enableAuxDump;
2056 if (Location == VPHAL_DUMP_TYPE_PRE_MEMDECOMP)
2057 {
2058 // For PreMemDecomp, dump without aux is meaningless
2059 // and, if we don't turn on aux dump, the surface will be deswizzled,
2060 // while Mos_Specific_LockResource() will perform deswilling to temp buffer and then copy to locked buffer
2061 // This will break the compressed surface.
2062 // So, we cannot dump compressed surf with deswizzling under current implementation.
2063 m_dumpSpec.enableAuxDump = true;
2064 }
2065
2066 OsContextNext *osCtx = nullptr;
2067
2068 if (m_osInterface && m_osInterface->osStreamState && m_osInterface->osStreamState->osDeviceContext)
2069 {
2070 osCtx = m_osInterface->osStreamState->osDeviceContext;
2071 if (osCtx && osCtx->GetDumpFrameNum() != 0xffffffff && isDumpFromDecomp)
2072 {
2073 // override the uiFrameNumer as it is during Vphal dumping its surface and already in lock and decomp phase
2074 uiFrameNumber = osCtx->GetDumpFrameNum();
2075 }
2076
2077 if (osCtx && !isDumpFromDecomp)
2078 {
2079 osCtx->SetDumpFrameNum(uiFrameNumber);
2080 }
2081
2082 }
2083
2084
2085 // Get if manual triggered build
2086 ReadUserSettingForDebug(
2087 m_userSettingPtr,
2088 VphalSurfDumpManualTrigger,
2089 __VPHAL_DBG_SURF_DUMP_MANUAL_TRIGGER_KEY_NAME,
2090 MediaUserSetting::Group::Device);
2091
2092 if (VphalSurfDumpManualTrigger != VPHAL_SURF_DUMP_MANUAL_TRIGGER_DEFAULT_NOT_SET)
2093 {
2094 if (VphalSurfDumpManualTrigger == VPHAL_SURF_DUMP_MANUAL_TRIGGER_STARTED)
2095 {
2096 VP_DEBUG_NORMALMESSAGE("Dump manaul trigger enabled, dump started: %d \n", VphalSurfDumpManualTrigger);
2097
2098 for (i = 0; i < pDumpSpec->iNumDumpLocs; i++)
2099 {
2100 if (pDumpSpec->pDumpLocations[i].DumpLocation == Location && // should dump at this pipeline location AND
2101 (pDumpSpec->pDumpLocations[i].SurfType == pSurf->SurfType || // should dump for this surface type OR
2102 pDumpSpec->pDumpLocations[i].SurfType == SURF_NONE)) // should dump for any surface type
2103 {
2104 char *loc = nullptr;
2105 if (osCtx)
2106 {
2107 loc = osCtx->GetdumpLoc();
2108 }
2109 VP_DEBUG_CHK_STATUS(EnumToLocString(Location, m_dumpLoc));
2110 VP_DEBUG_CHK_STATUS(EnumToDdiString(uiDDI, m_dumpDDI));
2111 if (!isDumpFromDecomp && pSurf->bIsCompressed && loc)
2112 {
2113 EnumToLocString(Location, loc);
2114 }
2115
2116 if (!isDumpFromDecomp || (loc && loc[0] == 0))
2117 {
2118 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc[%s]_lyr[%d]_ddi[%s(%d)]", pDumpSpec->pcOutputPath, pid, timeStamp, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2119 }
2120 else
2121 {
2122 if (loc)
2123 {
2124 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc[%s_%s]_lyr[%d]_ddi[%s(%d)]", pDumpSpec->pcOutputPath, pid, timeStamp, loc, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2125 }
2126 }
2127 DumpSurfaceToFile(
2128 m_osInterface,
2129 pSurf,
2130 m_dumpPrefix,
2131 uiFrameNumber,
2132 true,
2133 isDumpFromDecomp,
2134 nullptr);
2135 break;
2136 }
2137 }
2138 }
2139 else if (VphalSurfDumpManualTrigger == VPHAL_SURF_DUMP_MANUAL_TRIGGER_STOPPED)
2140 {
2141 VP_DEBUG_NORMALMESSAGE("Dump manaul trigger enabled, dump stopped: %d \n", VphalSurfDumpManualTrigger);
2142 }
2143 else
2144 {
2145 VP_DEBUG_NORMALMESSAGE("Dump manaul trigger flag: %d \n", VphalSurfDumpManualTrigger);
2146 }
2147 }
2148 else if (pDumpSpec->uiStartFrame <= uiFrameNumber &&
2149 uiFrameNumber <= pDumpSpec->uiEndFrame)
2150 {
2151 for (i = 0; i < pDumpSpec->iNumDumpLocs; i++)
2152 {
2153 if (pDumpSpec->pDumpLocations[i].DumpLocation == Location && // should dump at this pipeline location AND
2154 (pDumpSpec->pDumpLocations[i].SurfType == pSurf->SurfType || // should dump for this surface type OR
2155 pDumpSpec->pDumpLocations[i].SurfType == SURF_NONE)) // should dump for any surface type
2156 {
2157 char *loc = nullptr;
2158 if (osCtx)
2159 {
2160 loc = osCtx->GetdumpLoc();
2161 }
2162 VP_DEBUG_CHK_STATUS(EnumToLocString(Location, m_dumpLoc));
2163 VP_DEBUG_CHK_STATUS(EnumToDdiString(uiDDI, m_dumpDDI));
2164 if (!isDumpFromDecomp && pSurf->bIsCompressed && loc)
2165 {
2166 EnumToLocString(Location, loc);
2167 }
2168
2169 if (!isDumpFromDecomp || (loc && loc[0] == 0))
2170 {
2171 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc_loc[%s]_lyr[%d]_ddi[%s(%d)]",
2172 pDumpSpec->pcOutputPath, pid, timeStamp, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2173 }
2174 else
2175 {
2176 if (loc)
2177 {
2178 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc_loc[%s_%s]_lyr[%d]_ddi[%s(%d)]",
2179 pDumpSpec->pcOutputPath, pid, timeStamp, loc, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2180 }
2181 }
2182
2183 DumpSurfaceToFile(
2184 m_osInterface,
2185 pSurf,
2186 m_dumpPrefix,
2187 uiFrameNumber,
2188 true,
2189 isDumpFromDecomp,
2190 nullptr);
2191 break;
2192 }
2193 }
2194 }
2195 else
2196 {
2197 VP_DEBUG_VERBOSEMESSAGE("No surface dumpped, VphalSurfDumpManualTrigger: %d, uiStartFrame: %d, uiEndFrame: %d\n", VphalSurfDumpManualTrigger, pDumpSpec->uiStartFrame, pDumpSpec->uiEndFrame);
2198 }
2199
2200 finish:
2201 if (!isDumpFromDecomp && osCtx)
2202 {
2203 osCtx->ResetDumpFrameNum();
2204 osCtx->ResetdumpLoc();
2205 }
2206 m_dumpSpec.enableAuxDump = orgDumpAuxEnable;
2207
2208 return eStatus;
2209 }
2210
DumpSurface(PVP_SURFACE pSurf,uint32_t uiFrameNumber,uint32_t uiCounter,uint32_t Location,uint32_t uiDDI)2211 MOS_STATUS VpSurfaceDumper::DumpSurface(
2212 PVP_SURFACE pSurf,
2213 uint32_t uiFrameNumber,
2214 uint32_t uiCounter,
2215 uint32_t Location,
2216 uint32_t uiDDI)
2217 {
2218 VP_FUNC_CALL();
2219
2220 MOS_USER_FEATURE_VALUE_DATA UserFeatureData;
2221 int32_t VphalSurfDumpManualTrigger = VPHAL_SURF_DUMP_MANUAL_TRIGGER_DEFAULT_NOT_SET;
2222
2223 MOS_STATUS eStatus;
2224 int32_t i;
2225 VPHAL_SURF_DUMP_SPEC* pDumpSpec = &m_dumpSpec;
2226 bool isDumpFromDecomp;
2227 bool orgDumpAuxEnable;
2228 int32_t pid = MosUtilities::MosGetPid();
2229 uint64_t timeStamp = 0;
2230
2231 MosUtilities::MosQueryPerformanceCounter(&timeStamp);
2232 eStatus = MOS_STATUS_SUCCESS;
2233 i = 0;
2234 isDumpFromDecomp = (Location == VPHAL_DUMP_TYPE_PRE_MEMDECOMP || Location == VPHAL_DUMP_TYPE_POST_MEMDECOMP);
2235
2236 orgDumpAuxEnable = m_dumpSpec.enableAuxDump;
2237 if (Location == VPHAL_DUMP_TYPE_PRE_MEMDECOMP)
2238 {
2239 // For PreMemDecomp, dump without aux is meaningless
2240 // and, if we don't turn on aux dump, the surface will be deswizzled,
2241 // while Mos_Specific_LockResource() will perform deswilling to temp buffer and then copy to locked buffer
2242 // This will break the compressed surface.
2243 // So, we cannot dump compressed surf with deswizzling under current implementation.
2244 m_dumpSpec.enableAuxDump = true;
2245 }
2246
2247 OsContextNext *osCtx = nullptr;
2248
2249 if (m_osInterface && m_osInterface->osStreamState && m_osInterface->osStreamState->osDeviceContext)
2250 {
2251 osCtx = m_osInterface->osStreamState->osDeviceContext;
2252 if (osCtx && osCtx->GetDumpFrameNum() != 0xffffffff && isDumpFromDecomp)
2253 {
2254 // override the uiFrameNumer as it is during Vphal dumping its surface and already in lock and decomp phase
2255 uiFrameNumber = osCtx->GetDumpFrameNum();
2256 }
2257
2258 if (osCtx && !isDumpFromDecomp)
2259 {
2260 osCtx->SetDumpFrameNum(uiFrameNumber);
2261 }
2262
2263 }
2264
2265 // Get if manual triggered build
2266 ReadUserSettingForDebug(
2267 m_userSettingPtr,
2268 VphalSurfDumpManualTrigger,
2269 __VPHAL_DBG_SURF_DUMP_MANUAL_TRIGGER_KEY_NAME,
2270 MediaUserSetting::Group::Device);
2271
2272 if (VphalSurfDumpManualTrigger != VPHAL_SURF_DUMP_MANUAL_TRIGGER_DEFAULT_NOT_SET)
2273 {
2274 if (VphalSurfDumpManualTrigger == VPHAL_SURF_DUMP_MANUAL_TRIGGER_STARTED)
2275 {
2276 VP_DEBUG_NORMALMESSAGE("Dump manaul trigger enabled, dump started: %d \n", VphalSurfDumpManualTrigger);
2277
2278 for (i = 0; i < pDumpSpec->iNumDumpLocs; i++)
2279 {
2280 if (pDumpSpec->pDumpLocations[i].DumpLocation == Location && // should dump at this pipeline location AND
2281 (pDumpSpec->pDumpLocations[i].SurfType == pSurf->SurfType || // should dump for this surface type OR
2282 pDumpSpec->pDumpLocations[i].SurfType == SURF_NONE)) // should dump for any surface type
2283 {
2284 char *loc = nullptr;
2285 if (osCtx)
2286 {
2287 loc = osCtx->GetdumpLoc();
2288 }
2289 VP_DEBUG_CHK_STATUS(EnumToLocString(Location, m_dumpLoc));
2290 VP_DEBUG_CHK_STATUS(EnumToDdiString(uiDDI, m_dumpDDI));
2291 if (!isDumpFromDecomp && pSurf->osSurface->bIsCompressed && loc)
2292 {
2293 EnumToLocString(Location, loc);
2294 }
2295
2296 if (!isDumpFromDecomp || (loc && loc[0] == 0))
2297 {
2298 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc[%s]_lyr[%d]_ddi[%s(%d)]", pDumpSpec->pcOutputPath, pid, timeStamp, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2299 }
2300 else
2301 {
2302 if (loc)
2303 {
2304 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc[%s_%s]_lyr[%d]_ddi[%s(%d)]", pDumpSpec->pcOutputPath, pid, timeStamp, loc, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2305 }
2306 }
2307 DumpSurfaceToFile(
2308 m_osInterface,
2309 pSurf,
2310 m_dumpPrefix,
2311 uiFrameNumber,
2312 true,
2313 isDumpFromDecomp,
2314 nullptr);
2315 break;
2316 }
2317 }
2318 }
2319 else if (VphalSurfDumpManualTrigger == VPHAL_SURF_DUMP_MANUAL_TRIGGER_STOPPED)
2320 {
2321 VP_DEBUG_NORMALMESSAGE("Dump manaul trigger enabled, dump stopped: %d \n", VphalSurfDumpManualTrigger);
2322 }
2323 else
2324 {
2325 VP_DEBUG_NORMALMESSAGE("Dump manaul trigger flag: %d \n", VphalSurfDumpManualTrigger);
2326 }
2327 }
2328 else if (pDumpSpec->uiStartFrame <= uiFrameNumber &&
2329 uiFrameNumber <= pDumpSpec->uiEndFrame)
2330 {
2331 for (i = 0; i < pDumpSpec->iNumDumpLocs; i++)
2332 {
2333 if (pDumpSpec->pDumpLocations[i].DumpLocation == Location && // should dump at this pipeline location AND
2334 (pDumpSpec->pDumpLocations[i].SurfType == pSurf->SurfType || // should dump for this surface type OR
2335 pDumpSpec->pDumpLocations[i].SurfType == SURF_NONE)) // should dump for any surface type
2336 {
2337 char *loc = nullptr;
2338 if (osCtx)
2339 {
2340 loc = osCtx->GetdumpLoc();
2341 }
2342 VP_DEBUG_CHK_STATUS(EnumToLocString(Location, m_dumpLoc));
2343 VP_DEBUG_CHK_STATUS(EnumToDdiString(uiDDI, m_dumpDDI));
2344 if (!isDumpFromDecomp && pSurf->osSurface->bIsCompressed && loc)
2345 {
2346 EnumToLocString(Location, loc);
2347 }
2348
2349 if (!isDumpFromDecomp || (loc && loc[0] == 0))
2350 {
2351 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc[%s]_lyr[%d]_ddi[%s(%d)]",
2352 pDumpSpec->pcOutputPath, pid, timeStamp, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2353 }
2354 else
2355 {
2356 if (loc)
2357 {
2358 MOS_SecureStringPrint(m_dumpPrefix, MAX_PATH, MAX_PATH, "%s/surfdump_pid%x_ts%llx_loc[%s_%s]_lyr[%d]_ddi[%s(%d)]",
2359 pDumpSpec->pcOutputPath, pid, timeStamp, loc, m_dumpLoc, uiCounter, m_dumpDDI, uiDDI);
2360 }
2361 }
2362
2363 DumpSurfaceToFile(
2364 m_osInterface,
2365 pSurf,
2366 m_dumpPrefix,
2367 uiFrameNumber,
2368 true,
2369 isDumpFromDecomp,
2370 nullptr);
2371 break;
2372 }
2373 }
2374 }
2375 else
2376 {
2377 VP_DEBUG_VERBOSEMESSAGE("No surface dumpped, VphalSurfDumpManualTrigger: %d, uiStartFrame: %d, uiEndFrame: %d\n", VphalSurfDumpManualTrigger, pDumpSpec->uiStartFrame, pDumpSpec->uiEndFrame);
2378 }
2379
2380 finish:
2381 if (!isDumpFromDecomp && osCtx)
2382 {
2383 osCtx->ResetDumpFrameNum();
2384 osCtx->ResetdumpLoc();
2385 }
2386 m_dumpSpec.enableAuxDump = orgDumpAuxEnable;
2387
2388 return eStatus;
2389 }
2390
DumpSurfaceArray(PVPHAL_SURFACE * ppSurfaces,uint32_t uiMaxSurfaces,uint32_t uiNumSurfaces,uint32_t uiFrameNumber,uint32_t Location,uint32_t uiDDI)2391 MOS_STATUS VpSurfaceDumper::DumpSurfaceArray(
2392 PVPHAL_SURFACE *ppSurfaces,
2393 uint32_t uiMaxSurfaces,
2394 uint32_t uiNumSurfaces,
2395 uint32_t uiFrameNumber,
2396 uint32_t Location,
2397 uint32_t uiDDI)
2398 {
2399 VP_FUNC_CALL();
2400
2401 MOS_STATUS eStatus;
2402 uint32_t uiIndex;
2403 uint32_t uiLayer;
2404
2405 //---------------------------------------------------
2406 VP_DEBUG_ASSERT(ppSurfaces);
2407 //---------------------------------------------------
2408
2409 eStatus = MOS_STATUS_SUCCESS;
2410
2411 for (uiIndex = 0, uiLayer = 0;
2412 uiLayer < uiNumSurfaces && uiIndex < uiMaxSurfaces; uiIndex++)
2413 {
2414 if (ppSurfaces[uiIndex])
2415 {
2416 VP_DEBUG_ASSERT(!Mos_ResourceIsNull(&ppSurfaces[uiIndex]->OsResource));
2417
2418 VP_DEBUG_CHK_STATUS(DumpSurface(
2419 ppSurfaces[uiIndex],
2420 uiFrameNumber,
2421 uiLayer,
2422 Location,
2423 uiDDI));
2424
2425 uiLayer++;
2426 }
2427 }
2428
2429 finish:
2430 return eStatus;
2431 }
2432
2433
GetParametersDumpSpec()2434 void VpParameterDumper::GetParametersDumpSpec()
2435 {
2436 VP_FUNC_CALL();
2437
2438 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
2439 bool bDumpEnabled;
2440 VPHAL_PARAMS_DUMP_SPEC *pDumpSpec = &m_dumpSpec;
2441 MediaUserSetting::Value outValue;
2442
2443 pDumpSpec->uiStartFrame = 0xFFFFFFFF;
2444 pDumpSpec->uiEndFrame = 0;
2445 pDumpSpec->outFileLocation[0] = '\0';
2446 bDumpEnabled = false;
2447
2448 // Get start frame
2449 // if start frame is not got assign a default value of 0
2450 ReadUserSettingForDebug(
2451 m_userSettingPtr,
2452 pDumpSpec->uiStartFrame,
2453 __VPHAL_DBG_PARAM_DUMP_START_FRAME_KEY_NAME,
2454 MediaUserSetting::Group::Sequence);
2455
2456 // Get end frame
2457 // if end frame is not got assign a default value of max
2458 ReadUserSettingForDebug(
2459 m_userSettingPtr,
2460 pDumpSpec->uiEndFrame,
2461 __VPHAL_DBG_PARAM_DUMP_END_FRAME_KEY_NAME,
2462 MediaUserSetting::Group::Sequence);
2463
2464 // Get out file path
2465 ReadUserSettingForDebug(
2466 m_userSettingPtr,
2467 outValue,
2468 __VPHAL_DBG_PARAM_DUMP_OUTFILE_KEY_NAME,
2469 MediaUserSetting::Group::Sequence);
2470 if (outValue.ConstString().size() > 0 && outValue.ConstString().size() < MOS_USER_CONTROL_MAX_DATA_SIZE)
2471 {
2472 // Copy the Output path
2473 MOS_SecureMemcpy(
2474 pDumpSpec->outFileLocation,
2475 MAX_PATH,
2476 outValue.ConstString().c_str(),
2477 outValue.ConstString().size());
2478 bDumpEnabled = true;
2479 }
2480 #if !defined(LINUX) && !defined(ANDROID)
2481 else
2482 {
2483 std::string vphalDumpFilePath;
2484
2485 // Use state separation APIs to obtain appropriate storage location
2486 if (SUCCEEDED(GetDriverPersistentStorageLocation(vphalDumpFilePath)))
2487 {
2488 std::string m_outputFilePath;
2489
2490 m_outputFilePath = vphalDumpFilePath.c_str();
2491 m_outputFilePath.append(VPHAL_DUMP_OUTPUT_FOLDER);
2492
2493 // Copy the Output path
2494 MOS_SecureMemcpy(
2495 pDumpSpec->outFileLocation,
2496 MAX_PATH,
2497 m_outputFilePath.c_str(),
2498 m_outputFilePath.size());
2499
2500 ReportUserSettingForDebug(m_userSettingPtr, __VPHAL_DBG_DUMP_OUTPUT_DIRECTORY, m_outputFilePath, MediaUserSetting::Group::Sequence);
2501
2502 bDumpEnabled = true;
2503 }
2504 }
2505 #endif
2506
2507 // Get enableSkuWaDump
2508 ReadUserSettingForDebug(
2509 m_userSettingPtr,
2510 pDumpSpec->enableSkuWaDump,
2511 __VPHAL_DBG_PARA_DUMP_ENABLE_SKUWA_DUMP,
2512 MediaUserSetting::Group::Sequence);
2513
2514 if ((eStatus != MOS_STATUS_SUCCESS) || (!bDumpEnabled))
2515 {
2516 pDumpSpec->uiStartFrame = 1;
2517 pDumpSpec->uiEndFrame = 0;
2518 }
2519 }
2520
DumpSourceSurface(uint32_t uiFrameCounter,char * pcOutputPath,PVPHAL_SURFACE pSrc,uint32_t index,char * & pcOutContents)2521 MOS_STATUS VpParameterDumper::DumpSourceSurface(
2522 uint32_t uiFrameCounter,
2523 char *pcOutputPath,
2524 PVPHAL_SURFACE pSrc,
2525 uint32_t index,
2526 char* &pcOutContents)
2527 {
2528 VP_FUNC_CALL();
2529
2530 MOS_STATUS eStatus;
2531 char sSurfaceFilePath[MAX_PATH] = { 0 }, sOsSurfaceFilePath[MAX_PATH] = { 0 };
2532 int32_t pid = MosUtilities::MosGetPid();
2533 uint64_t timeStamp = 0;
2534
2535 MosUtilities::MosQueryPerformanceCounter(&timeStamp);
2536 eStatus = MOS_STATUS_SUCCESS;
2537
2538 //Color Information
2539 {
2540 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<!-- Color Information -->\n"));
2541 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_CSPACE>%s</VPHAL_CSPACE>\n", GetColorSpaceStr(pSrc->ColorSpace)));
2542 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<EXTENDED_GAMUT></EXTENDED_GAMUT>\n"));
2543 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<PALETTE_ALLOCATION>%d</PALETTE_ALLOCATION>\n", (pSrc->iPalette)));
2544 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<PALETTE_DATA>\n"));
2545 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<PALETTE_DATA_TYPE>%s</PALETTE_DATA_TYPE>\n", GetPaletteTypeStr(pSrc->Palette.PaletteType)));
2546 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_CSPACE>%s</VPHAL_CSPACE>\n", GetColorSpaceStr(pSrc->Palette.ColorSpace)));
2547 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HAS_ALPHA>%d</HAS_ALPHA>\n", pSrc->Palette.bHasAlpha ? 1 : 0));
2548 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<TOTAL_ENTRIES>%d</TOTAL_ENTRIES>\n", pSrc->Palette.iTotalEntries));
2549 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<NUM_ENTRIES>%d</NUM_ENTRIES>\n", pSrc->Palette.iNumEntries));
2550 for (int nIndex = 0; nIndex < pSrc->Palette.iTotalEntries; nIndex++)
2551 {
2552 if (pSrc->Palette.pPalette8)
2553 {
2554 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<PVPHAL_COLOR_SAMPLE>%08x</PVPHAL_COLOR_SAMPLE>\n", pSrc->Palette.pPalette8[nIndex].dwValue));
2555 }
2556 }
2557 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</PALETTE_DATA>\n"));
2558
2559 //Rendering parameters
2560 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<!-- Rendering parameters -->\n"));
2561 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_BLENDING_PARAMS>\n"));
2562 if (pSrc->pBlendingParams)
2563 {
2564 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_BLEND_TYPE>%s</VPHAL_BLEND_TYPE>\n", GetBlendTypeStr(pSrc->pBlendingParams->BlendType)));
2565 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ALPHA type=\"real\">%.3f</ALPHA>\n", pSrc->pBlendingParams->fAlpha));
2566 }
2567 else
2568 {
2569 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ALPHA type=\"real\"></ALPHA>\n"));
2570 }
2571 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_BLENDING_PARAMS>\n"));
2572
2573 //Luma key params
2574 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_LUMAKEY_PARAMS>\n"));
2575 if (pSrc->pLumaKeyParams)
2576 {
2577 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<LUMA_LOW>%d</LUMA_LOW>\n", pSrc->pLumaKeyParams->LumaLow));
2578 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<LUMA_HIGH>%d</LUMA_HIGH>\n", pSrc->pLumaKeyParams->LumaHigh));
2579 }
2580 else
2581 {
2582 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<LUMA_LOW></LUMA_LOW>\n"));
2583 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<LUMA_HIGH></LUMA_HIGH>\n"));
2584 }
2585 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_LUMAKEY_PARAMS>\n"));
2586
2587 //ChromaSitting params
2588 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_CHROMASITTING_PARAMS>\n"));
2589 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CHROMA_SITING_HORZ_LEFT>%d</CHROMA_SITING_HORZ_LEFT>\n", (pSrc->ChromaSiting & CHROMA_SITING_HORZ_LEFT) == CHROMA_SITING_HORZ_LEFT ? 1 : 0));
2590 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CHROMA_SITING_HORZ_CENTER>%d</CHROMA_SITING_HORZ_CENTER>\n", (pSrc->ChromaSiting & CHROMA_SITING_HORZ_CENTER) == CHROMA_SITING_HORZ_CENTER ? 1 : 0));
2591 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CHROMA_SITING_HORZ_RIGHT>%d</CHROMA_SITING_HORZ_RIGHT>\n", (pSrc->ChromaSiting & CHROMA_SITING_HORZ_RIGHT) == CHROMA_SITING_HORZ_RIGHT ? 1 : 0));
2592 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CHROMA_SITING_VERT_TOP>%d</CHROMA_SITING_VERT_TOP>\n", (pSrc->ChromaSiting & CHROMA_SITING_VERT_TOP) == CHROMA_SITING_VERT_TOP ? 1 : 0));
2593 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CHROMA_SITING_VERT_CENTER>%d</CHROMA_SITING_VERT_CENTER>\n", (pSrc->ChromaSiting & CHROMA_SITING_VERT_CENTER) == CHROMA_SITING_VERT_CENTER ? 1 : 0));
2594 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CHROMA_SITING_VERT_BOTTOM>%d</CHROMA_SITING_VERT_BOTTOM>\n", (pSrc->ChromaSiting & CHROMA_SITING_VERT_BOTTOM) == CHROMA_SITING_VERT_BOTTOM ? 1 : 0));
2595 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_CHROMASITTING_PARAMS>\n"));
2596
2597 //Propcamp params
2598 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_PROCAMP_PARAMS>\n"));
2599 if (pSrc->pProcampParams)
2600 {
2601 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLED>%d</ENABLED>\n", (pSrc->pProcampParams->bEnabled ? 1 : 0)));
2602 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<BRIGHTNESS type=\"real\">%.3f</BRIGHTNESS>\n", pSrc->pProcampParams->fBrightness));
2603 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CONTRAST type=\"real\">%.3f</CONTRAST>\n", pSrc->pProcampParams->fContrast));
2604 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HUE type=\"real\">%.3f</HUE>\n", pSrc->pProcampParams->fHue));
2605 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<SATURATION type=\"real\">%.3f</SATURATION>\n", pSrc->pProcampParams->fSaturation));
2606 }
2607 else
2608 {
2609 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLED></ENABLED>\n"));
2610 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<BRIGHTNESS type=\"real\"></BRIGHTNESS>\n"));
2611 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CONTRAST type=\"real\"></CONTRAST>\n"));
2612 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HUE type=\"real\"></HUE>\n"));
2613 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<SATURATION type=\"real\"></SATURATION>\n"));
2614 }
2615 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_PROCAMP_PARAMS>\n"));
2616
2617 //IEF parameter
2618 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_IEF_PARAMS>\n"));
2619 if (pSrc->pIEFParams)
2620 {
2621 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<IEFFACTOR type = \"real\">%.3f</IEFFACTOR>\n", pSrc->pIEFParams->fIEFFactor));
2622 }
2623 else
2624 {
2625 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<IEFFACTOR type = \"real\"></IEFFACTOR>\n"));
2626 }
2627 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_IEF_PARAMS>\n"));
2628
2629 //Advanced processing
2630 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<!-- Advanced processing -->\n"));
2631 //DI
2632 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_DI_PARAMS>\n"));
2633 if (pSrc->pDeinterlaceParams)
2634 {
2635 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<DIMODE>%s</DIMODE>\n", GetDIModeStr(pSrc->pDeinterlaceParams->DIMode)));
2636 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<ENABLE_FMD>%d</ENABLE_FMD>\n", (pSrc->pDeinterlaceParams->bEnableFMD ? 1 : 0)));
2637 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<SINGLE_FIELD>%d</SINGLE_FIELD>\n", (pSrc->pDeinterlaceParams->bSingleField ? 1 : 0)));
2638 }
2639 else
2640 {
2641 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<DIMODE></DIMODE>\n"));
2642 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<ENABLE_FMD></ENABLE_FMD>\n"));
2643 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<SINGLE_FIELD></SINGLE_FIELD>\n"));
2644 }
2645 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_DI_PARAMS>\n"));
2646 //Denoise
2647 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_DENOISE_PARAMS>\n"));
2648 if (pSrc->pDenoiseParams)
2649 {
2650 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_LUMA>%d</ENABLE_LUMA>\n", (pSrc->pDenoiseParams->bEnableLuma ? 1 : 0)));
2651 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_CHROMA>%d</ENABLE_CHROMA>\n", (pSrc->pDenoiseParams->bEnableChroma ? 1 : 0)));
2652 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<AUTO_DETECT>%d</AUTO_DETECT>\n", (pSrc->pDenoiseParams->bAutoDetect ? 1 : 0)));
2653 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<DENOISE_FACTOR>%.3f</DENOISE_FACTOR>\n", (pSrc->pDenoiseParams->fDenoiseFactor)));
2654 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<NOISE_LEVEL>%s</NOISE_LEVEL>\n", GetDenoiseModeStr(pSrc->pDenoiseParams->NoiseLevel)));
2655 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_HVS_DENOISE>%d</ENABLE_HVS_DENOISE>\n", (pSrc->pDenoiseParams->bEnableHVSDenoise ? 1 : 0)));
2656 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HVS_DENOISE_QP>%d</HVS_DENOISE_QP>\n", (pSrc->pDenoiseParams->HVSDenoise.QP)));
2657 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HVS_DENOISE_STRENGTH>%d</HVS_DENOISE_STRENGTH>\n", (pSrc->pDenoiseParams->HVSDenoise.Strength)));
2658 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HVS_DENOISE_MODE>%s</HVS_DENOISE_MODE>\n", GetHVSDenoiseModeStr(pSrc->pDenoiseParams->HVSDenoise.Mode)));
2659 }
2660 else
2661 {
2662 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_LUMA></ENABLE_LUMA>\n"));
2663 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_CHROMA></ENABLE_CHROMA>\n"));
2664 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<AUTO_DETECT></AUTO_DETECT>\n"));
2665 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<DENOISE_FACTOR></DENOISE_FACTOR>\n"));
2666 }
2667 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_DENOISE_PARAMS>\n"));
2668 //ColorPipe
2669 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_COLORPIPE_PARAMS>\n"));
2670 if (pSrc->pColorPipeParams)
2671 {
2672 VPHAL_TCC_PARAMS TccParams = pSrc->pColorPipeParams->TccParams;
2673 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_ACE>%d</ENABLE_ACE>\n", (pSrc->pColorPipeParams->bEnableACE ? 1 : 0)));
2674 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_STE>%d</ENABLE_STE>\n", (pSrc->pColorPipeParams->bEnableSTE ? 1 : 0)));
2675 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_TCC>%d</ENABLE_TCC>\n", (pSrc->pColorPipeParams->bEnableTCC ? 1 : 0)));
2676 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ACE_LEVEL>%d</ACE_LEVEL>\n", (pSrc->pColorPipeParams->dwAceLevel)));
2677 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ACE_STRENGHTH>%d</ACE_STRENGHTH>\n", (pSrc->pColorPipeParams->dwAceStrength)));
2678 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<STE_PARAMS>\n"));
2679 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t\t<STE_FACTOR>%d</STE_FACTOR>\n", (pSrc->pColorPipeParams->SteParams.dwSTEFactor)));
2680 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t</STE_PARAMS>\n"));
2681 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<TCC_PARAMS>%d,%d,%d,%d,%d,%d</TCC_PARAMS>\n", TccParams.Blue, TccParams.Cyan, TccParams.Green, TccParams.Magenta, TccParams.Red, TccParams.Yellow));
2682 }
2683 else
2684 {
2685 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_ACE></ENABLE_ACE>\n"));
2686 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_STE></ENABLE_STE>\n"));
2687 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ENABLE_TCC></ENABLE_TCC>\n"));
2688 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<ACE_LEVEL></ACE_LEVEL>\n"));
2689 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<STE_PARAMS></STE_PARAMS>\n"));
2690 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<TCC_PARAMS></TCC_PARAMS>\n"));
2691 }
2692 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_COLORPIPE_PARAMS>\n"));
2693 //Gamut
2694 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_GAMUT_PARAMS>\n"));
2695 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<GCOMP_MODE></GCOMP_MODE>\n"));
2696 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_GAMUT_PARAMS>\n"));
2697
2698 //Sample information
2699 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<!-- Sample information -->\n"));
2700 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_FORMAT>%s</VPHAL_FORMAT>\n", GetWholeFormatStr(pSrc->Format)));
2701 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_SURFACE_TYPE>%s</VPHAL_SURFACE_TYPE>\n", GetSurfaceTypeStr(pSrc->SurfType)));
2702 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_SAMPLE_TYPE>%s</VPHAL_SAMPLE_TYPE>\n", GetSampleTypeStr(pSrc->SampleType)));
2703 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_SCALING_MODE>%s</VPHAL_SCALING_MODE>\n", GetScalingModeStr(pSrc->ScalingMode)));
2704 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_ROTATION_MODE>%s</VPHAL_ROTATION_MODE>\n", GetRotationModeStr(pSrc->Rotation)));
2705 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<RCSRC>%d,%d,%d,%d</RCSRC>\n", pSrc->rcSrc.left, pSrc->rcSrc.top, pSrc->rcSrc.right, pSrc->rcSrc.bottom));
2706 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<RCDST>%d,%d,%d,%d</RCDST>\n", pSrc->rcDst.left, pSrc->rcDst.top, pSrc->rcDst.right, pSrc->rcDst.bottom));
2707
2708 //Basic information
2709 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<!-- Basic information -->\n"));
2710 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_TILE_TYPE>%s</VPHAL_TILE_TYPE>\n", GetTileTypeStr(pSrc->TileType)));
2711 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_TILE_MODE>%s</VPHAL_TILE_MODE>\n", GetTileModeGMMStr(pSrc->TileModeGMM)));
2712 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<WIDTH>%d</WIDTH>\n", pSrc->dwWidth));
2713 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<HEIGHT>%d</HEIGHT>\n", pSrc->dwHeight));
2714 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<PITCH>%d</PITCH>\n", pSrc->dwPitch));
2715 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<SIZE>%d</SIZE>\n", pSrc->dwPitch * pSrc->dwHeight));
2716
2717 //Surface content initialization
2718 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<!-- Surface content initialization -->\n"));
2719 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<DATA>\n"));
2720 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<DEFAULT_COLOR type=\"integer\">0x000000FF</DEFAULT_COLOR>\n"));
2721 if (pcOutputPath)
2722 {
2723 memset(sSurfaceFilePath, 0, MAX_PATH);
2724 memset(sOsSurfaceFilePath, 0, MAX_PATH);
2725
2726 MOS_SecureStringPrint(sSurfaceFilePath, MAX_PATH, MAX_PATH, "%s%csurfdump_pid%x_ts%llx_loc[preALL]_lyr[%d]_f[%04d]_w[%d]_h[%d]_p[%d].%s",
2727 pcOutputPath, MOS_DIR_SEPERATOR, pid, timeStamp, index, uiFrameCounter, pSrc->dwWidth, pSrc->dwHeight, pSrc->dwPitch, VpDumperTool::GetFormatStr(pSrc->Format));
2728 VpDumperTool::GetOsFilePath(sSurfaceFilePath, sOsSurfaceFilePath);
2729 }
2730 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<FILE>%s</FILE>\n", sOsSurfaceFilePath));
2731 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</DATA>\n"));
2732 // get backward reference
2733 if (pSrc->pBwdRef)
2734 {
2735 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<BACKREFDATA>\n"));
2736 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<DEFAULT_COLOR type=\"integer\">0x000000FF</DEFAULT_COLOR>\n"));
2737 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<Num>%d</Num>\n", pSrc->uBwdRefCount));
2738 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<FILE></FILE>\n"));
2739 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</BACKREFDATA>\n"));
2740 }
2741 // get forward reference
2742 if (pSrc->pFwdRef)
2743 {
2744 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<FWDREFDATA>\n"));
2745 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<Num>%d</Num>\n", pSrc->uFwdRefCount));
2746 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</FWDREFDATA>\n"));
2747 }
2748 }
2749
2750 finish:
2751 return eStatus;
2752 }
2753
DumpTargetSurface(uint32_t uiFrameCounter,char * pcOutputPath,PVPHAL_SURFACE pTarget,uint32_t index,char * & pcOutContents)2754 MOS_STATUS VpParameterDumper::DumpTargetSurface(
2755 uint32_t uiFrameCounter,
2756 char *pcOutputPath,
2757 PVPHAL_SURFACE pTarget,
2758 uint32_t index,
2759 char* &pcOutContents)
2760 {
2761 VP_FUNC_CALL();
2762
2763 MOS_STATUS eStatus;
2764
2765 eStatus = MOS_STATUS_SUCCESS;
2766
2767 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_FORMAT>%s</VPHAL_FORMAT>\n", VpParameterDumper::GetWholeFormatStr(pTarget->Format)));
2768 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_SURFACE_TYPE>%s</VPHAL_SURFACE_TYPE>\n", VpParameterDumper::GetSurfaceTypeStr(pTarget->SurfType)));
2769 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_SAMPLE_TYPE>%s</VPHAL_SAMPLE_TYPE>\n", GetSampleTypeStr(pTarget->SampleType)));
2770 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_CSPACE>%s</VPHAL_CSPACE>\n", GetColorSpaceStr(pTarget->ColorSpace)));
2771 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_SCALING_MODE>%s</VPHAL_SCALING_MODE>\n", GetScalingModeStr(pTarget->ScalingMode)));
2772 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_TILE_TYPE>%s</VPHAL_TILE_TYPE>\n", GetTileTypeStr(pTarget->TileType)));
2773 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<VPHAL_TILE_MODE>%s</VPHAL_TILE_MODE>\n", GetTileModeGMMStr(pTarget->TileModeGMM)));
2774 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<WIDTH>%d</WIDTH>\n", pTarget->dwWidth));
2775 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<HEIGHT>%d</HEIGHT>\n", pTarget->dwHeight));
2776 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<PITCH>%d</PITCH>\n", pTarget->dwPitch));
2777 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<SIZE>%d</SIZE>\n", pTarget->dwPitch*pTarget->dwHeight));
2778 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<RCSRC>%d,%d,%d,%d</RCSRC>\n", pTarget->rcSrc.left, pTarget->rcSrc.top, pTarget->rcSrc.right, pTarget->rcSrc.bottom));
2779 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<RCDST>%d,%d,%d,%d</RCDST>\n", pTarget->rcDst.left, pTarget->rcDst.top, pTarget->rcDst.right, pTarget->rcDst.bottom));
2780 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<DATA>\n"));
2781 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t\t<DEFAULT_COLOR type=\"integer\">0x000000FF</DEFAULT_COLOR>\n"));
2782 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t\t<FILE></FILE>\n"));
2783 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t</DATA>\n"));
2784 //Gamut
2785 if (pTarget->pGamutParams)
2786 {
2787 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_GAMUT_PARAMS>\n"));
2788 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<GAMMA_VALUE>%s</GAMMA_VALUE>\n", VpParameterDumper::GetGammaValueTypeStr(pTarget->pGamutParams->GammaValue)));
2789 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_GAMUT_PARAMS>\n"));
2790 }
2791
2792 finish:
2793 return eStatus;
2794 }
2795
DumpRenderParameter(uint32_t uiFrameCounter,char * pcOutputPath,PVPHAL_RENDER_PARAMS pRenderParams,char * & pcOutContents)2796 MOS_STATUS VpParameterDumper::DumpRenderParameter(
2797 uint32_t uiFrameCounter,
2798 char *pcOutputPath,
2799 PVPHAL_RENDER_PARAMS pRenderParams,
2800 char* &pcOutContents)
2801 {
2802 VP_FUNC_CALL();
2803
2804 MOS_STATUS eStatus;
2805
2806 eStatus = MOS_STATUS_SUCCESS;
2807
2808 if (pRenderParams->pTarget[0])
2809 {
2810 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_SURFACE_TARGET>\n"));
2811 VP_DEBUG_CHK_STATUS(DumpTargetSurface(
2812 uiFrameCounter,
2813 pcOutputPath,
2814 pRenderParams->pTarget[0],
2815 0,
2816 pcOutContents));
2817 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_SURFACE_TARGET>\n"));
2818 }
2819 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<SRC_COUNT>%d</SRC_COUNT>\n", pRenderParams->uSrcCount));
2820
2821 //Color fill
2822 if (pRenderParams->pColorFillParams)
2823 {
2824 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_COLORFILL_PARAMS>\n"));
2825 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<bYCbCr>%d</bYCbCr>\n", pRenderParams->pColorFillParams->bYCbCr));
2826 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<COLOR type=\"integer\">%08x</COLOR>\n", pRenderParams->pColorFillParams->Color));
2827 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t\t<CSPACE>%s</CSPACE>\n", GetColorSpaceStr(pRenderParams->pColorFillParams->CSpace)));
2828 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t</VPHAL_COLORFILL_PARAMS>\n"));
2829 }
2830
2831 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<VPHAL_COMPONENT>%s</VPHAL_COMPONENT>\n", GetComponentStr(pRenderParams->Component)));
2832
2833 finish:
2834 return eStatus;
2835 }
2836
DumpToXML(uint32_t uiFrameCounter,char * pcOutputPath,PVPHAL_RENDER_PARAMS pRenderParams)2837 MOS_STATUS VpParameterDumper::DumpToXML(
2838 uint32_t uiFrameCounter,
2839 char *pcOutputPath,
2840 PVPHAL_RENDER_PARAMS pRenderParams)
2841 {
2842 VP_FUNC_CALL();
2843
2844 char sPath[MAX_PATH] = { 0 }, sOsPath[MAX_PATH] = { 0 };
2845 MOS_STATUS eStatus;
2846 char* pcOutContents;
2847 uint32_t dwStrLen = 0;
2848 FILE *fpOutXML;
2849 char* pCurFrameFileName;
2850 char* pBwdFrameFileName;
2851 VPHAL_PARAMS_DUMP_SPEC *pParamsDumpSpec = &m_dumpSpec;
2852 int32_t pid = MosUtilities::MosGetPid();
2853 uint64_t timeStamp = 0;
2854
2855 MosUtilities::MosQueryPerformanceCounter(&timeStamp);
2856 eStatus = MOS_STATUS_SUCCESS;
2857 dwStrLen = 0;
2858 pcOutContents = nullptr;
2859 fpOutXML = nullptr;
2860 pCurFrameFileName = nullptr;
2861 pBwdFrameFileName = nullptr;
2862
2863 VP_DEBUG_CHK_NULL(pRenderParams);
2864 VP_DEBUG_CHK_NULL(pParamsDumpSpec);
2865
2866 if ((pParamsDumpSpec->uiEndFrame < pParamsDumpSpec->uiStartFrame) || pParamsDumpSpec->uiEndFrame ==0 || strlen(pParamsDumpSpec->outFileLocation) == 0)
2867 goto finish;
2868
2869 // Create a processing instruction element.
2870 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(true, &pcOutContents, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
2871 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\n"));
2872 // Create the root element.
2873 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "<VPHAL_SCENARIO>\n"));
2874 // General infomation
2875 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<ID>%d</ID>\n", MosUtilities::MosGetPid()));
2876
2877 VP_DEBUG_CHK_NULL(pRenderParams->pSrc[0]);
2878 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<DESCRIPTION>%d</DESCRIPTION>\n", pRenderParams->pSrc[0]->FrameID));
2879 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<!-- Number of frames to render -->\n"));
2880 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<FRAME_COUNT type = \"integer\">1</FRAME_COUNT>\n"));
2881 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<!-- 60i or 30p BLT -->\n"));
2882 if ((pRenderParams->uSrcCount > 0) &&
2883 (pRenderParams->pSrc[0]->SampleType != SAMPLE_PROGRESSIVE))
2884 {
2885 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<BLT_TYPE>60i</BLT_TYPE>\n"));
2886 }
2887 else
2888 {
2889 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<BLT_TYPE>30p</BLT_TYPE>\n"));
2890 }
2891
2892 // Surface
2893 for (uint32_t i = 0; i < pRenderParams->uSrcCount; i++)
2894 {
2895 if (pRenderParams->pSrc[i] == nullptr)
2896 continue;
2897
2898 //surface infomation
2899 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<!-- Input surface definitions -->\n"));
2900 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<VPHAL_SURFACE>\n"));
2901
2902 VP_DEBUG_CHK_STATUS(DumpSourceSurface(
2903 uiFrameCounter,
2904 pcOutputPath,
2905 pRenderParams->pSrc[i],
2906 i,
2907 pcOutContents));
2908 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t</VPHAL_SURFACE>\n"));
2909 }
2910
2911 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<!-- Rendering parameters -->\n"));
2912 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<VPHAL_RENDER_PARAMS>\n"));
2913
2914 VP_DEBUG_CHK_STATUS(DumpRenderParameter(
2915 uiFrameCounter,
2916 pcOutputPath,
2917 pRenderParams,
2918 pcOutContents));
2919
2920 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t</VPHAL_RENDER_PARAMS>\n"));
2921 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "</VPHAL_SCENARIO>\n"));
2922
2923 MOS_SecureStringPrint(sPath, MAX_PATH, MAX_PATH, "%s%cparam_dump_pid%x_ts%llx[%04d].xml", pParamsDumpSpec->outFileLocation, MOS_DIR_SEPERATOR, pid, timeStamp, uiFrameCounter);
2924
2925 VpDumperTool::GetOsFilePath(sPath, sOsPath);
2926
2927 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pcOutContents, strlen(pcOutContents)));
2928 finish:
2929 if (pcOutContents)
2930 {
2931 MOS_FreeMemory(pcOutContents);
2932 pcOutContents = nullptr;
2933 }
2934 return eStatus;
2935 }
2936
VpParameterDumper(PMOS_INTERFACE pOsInterface)2937 VpParameterDumper::VpParameterDumper(PMOS_INTERFACE pOsInterface):
2938 m_dumpSpec(),
2939 m_osInterface(pOsInterface)
2940 {
2941 if (m_osInterface)
2942 {
2943 m_userSettingPtr = m_osInterface->pfnGetUserSettingInstance(m_osInterface);
2944 }
2945 }
2946
~VpParameterDumper()2947 VpParameterDumper::~VpParameterDumper()
2948 {
2949 }
2950
GetFormatStr(MOS_FORMAT format)2951 const char * VpDumperTool::GetFormatStr(MOS_FORMAT format)
2952 {
2953 VP_FUNC_CALL();
2954
2955 switch (format)
2956 {
2957 case Format_A8R8G8B8 : return _T("argb");
2958 case Format_X8R8G8B8 : return _T("xrgb");
2959 case Format_A8B8G8R8 : return _T("abgr");
2960 case Format_X8B8G8R8 : return _T("xbgr");
2961 case Format_A16R16G16B16: return _T("argb16");
2962 case Format_A16B16G16R16: return _T("abgr16");
2963 case Format_R5G6B5 : return _T("rgb16");
2964 case Format_R8G8B8 : return _T("rgb");
2965 case Format_R32U : return _T("r32u");
2966 case Format_RGBP : return _T("rgbp");
2967 case Format_BGRP : return _T("bgrp");
2968 case Format_R32F : return _T("r32f");
2969 case Format_YUY2 : return _T("yuy2");
2970 case Format_YUYV : return _T("yuyv");
2971 case Format_YVYU : return _T("yvyu");
2972 case Format_UYVY : return _T("uyvy");
2973 case Format_VYUY : return _T("vyuy");
2974 case Format_Y416 : return _T("y416");
2975 case Format_AYUV : return _T("ayuv");
2976 case Format_AUYV : return _T("auyv");
2977 case Format_NV12 : return _T("nv12");
2978 case Format_NV11 : return _T("nv11");
2979 case Format_P208 : return _T("p208");
2980 case Format_IMC1 : return _T("imc1");
2981 case Format_IMC2 : return _T("imc2");
2982 case Format_IMC3 : return _T("imc3");
2983 case Format_IMC4 : return _T("imc4");
2984 case Format_422H : return _T("422h");
2985 case Format_422V : return _T("422v");
2986 case Format_444P : return _T("444p");
2987 case Format_411P : return _T("411p");
2988 case Format_411R : return _T("411r");
2989 case Format_400P : return _T("400p");
2990 case Format_I420 : return _T("i420");
2991 case Format_IYUV : return _T("iyuv");
2992 case Format_YV12 : return _T("yv12");
2993 case Format_YVU9 : return _T("yvu9");
2994 case Format_AI44 : return _T("ai44");
2995 case Format_IA44 : return _T("ia44");
2996 case Format_P8 : return _T("P8");
2997 case Format_STMM : return _T("stmm");
2998 case Format_Buffer : return _T("buff");
2999 case Format_RAW : return _T("buff");
3000 case Format_PAL : return _T("pal");
3001 case Format_A8P8 : return _T("a8p8");
3002 case Format_A8 : return _T("a8");
3003 case Format_L8 : return _T("l8");
3004 case Format_A4L4 : return _T("a4l4");
3005 case Format_A8L8 : return _T("a8l8");
3006 case Format_V8U8 : return _T("v8u8");
3007 case Format_IRW0 : return _T("irw0");
3008 case Format_IRW1 : return _T("irw1");
3009 case Format_IRW2 : return _T("irw2");
3010 case Format_IRW3 : return _T("irw3");
3011 case Format_R10G10B10A2 : return _T("r10g10b10a2");
3012 case Format_B10G10R10A2 : return _T("b10g10r10a2");
3013 case Format_P010 : return _T("p010");
3014 case Format_P016 : return _T("p016");
3015 case Format_R16F : return _T("r16f");
3016 case Format_Y210 : return _T("y210");
3017 case Format_Y216 : return _T("y216");
3018 case Format_Y410 : return _T("y410");
3019 case Format_P210 : return _T("p210");
3020 case Format_P216 : return _T("p216");
3021 case Format_A16B16G16R16F : return _T("abgr16_float");
3022 case Format_A16R16G16B16F : return _T("argb16_float");
3023 default : return _T("Err");
3024 }
3025
3026 return nullptr;
3027 }
3028
GetSurfaceSize(PVPHAL_SURFACE pSurface,uint32_t iBpp,uint32_t * piWidthInBytes,uint32_t * piHeightInRows)3029 MOS_STATUS VpDumperTool::GetSurfaceSize(
3030 PVPHAL_SURFACE pSurface,
3031 uint32_t iBpp,
3032 uint32_t* piWidthInBytes,
3033 uint32_t* piHeightInRows)
3034 {
3035 VP_FUNC_CALL();
3036
3037 MOS_STATUS eStatus;
3038 uint32_t iWidthInBytes;
3039 uint32_t iHeightInRows;
3040
3041 //-------------------------------------------
3042 VP_DEBUG_ASSERT(pSurface->dwWidth >= 1);
3043 VP_DEBUG_ASSERT(pSurface->dwHeight >= 1);
3044 VP_DEBUG_ASSERT(pSurface->dwPitch >= 1);
3045 //-------------------------------------------
3046
3047 eStatus = MOS_STATUS_SUCCESS;
3048
3049 switch (pSurface->Format)
3050 {
3051 // Packed Formats
3052 case Format_A8R8G8B8:
3053 case Format_X8R8G8B8:
3054 case Format_A8B8G8R8:
3055 case Format_X8B8G8R8:
3056 case Format_R5G6B5:
3057 case Format_R8G8B8:
3058 case Format_R32U:
3059 case Format_R32F:
3060 case Format_AYUV:
3061 case Format_YUY2:
3062 case Format_YUYV:
3063 case Format_YVYU:
3064 case Format_UYVY:
3065 case Format_VYUY:
3066 case Format_AI44:
3067 case Format_IA44:
3068 case Format_P8:
3069 case Format_A8P8:
3070 case Format_A8:
3071 case Format_L8:
3072 case Format_A4L4:
3073 case Format_A8L8:
3074 case Format_V8U8:
3075 case Format_R10G10B10A2:
3076 case Format_B10G10R10A2:
3077 case Format_Y410:
3078 case Format_Y416:
3079 case Format_Y210:
3080 case Format_Y216:
3081 iWidthInBytes = pSurface->dwWidth * iBpp / 8;
3082 iHeightInRows = pSurface->dwHeight;
3083 break;
3084
3085 // 4:2:0 (12-bits per pixel)
3086 // IMC1 // IMC3
3087 // -----------------> // ----------------->
3088 // ________________________ // ________________________
3089 //|Y0|Y1| | //|Y0|Y1| |
3090 //|__|__| | //|__|__| |
3091 //| | //| |
3092 //| | //| |
3093 //| | //| |
3094 //| | //| |
3095 //| | //| |
3096 //|________________________| //|________________________|
3097 //|V0|V1| | | //|U0|U1| | |
3098 //|__|__| | | //|__|__| | |
3099 //| | | //| | |
3100 //|____________| PAD | //|____________| PAD |
3101 //|U0|U1| | | //|V0|V1| | |
3102 //|__|__| | | //|__|__| | |
3103 //| | | //| | |
3104 //|____________|___________| //|____________|___________|
3105 case Format_IMC1:
3106 case Format_IMC3:
3107 iWidthInBytes = pSurface->dwWidth;
3108 iHeightInRows = pSurface->dwHeight * 2;
3109 break;
3110
3111 // 4:0:0 (8-bits per pixel)
3112 // 400P
3113 // ----------------->
3114 // ________________________
3115 //|Y0|Y1| |
3116 //|__|__| |
3117 //| |
3118 //| |
3119 //| |
3120 //| |
3121 //| |
3122 //|________________________|
3123 case Format_400P:
3124 case Format_Buffer:
3125 case Format_RAW:
3126 iWidthInBytes = pSurface->dwWidth;
3127 iHeightInRows = pSurface->dwHeight;
3128 break;
3129
3130 // 4:1:1 (12-bits per pixel) // 4:2:2 (16-bits per pixel)
3131 // 411P // 422H
3132 // -----------------> // ----------------->
3133 // ________________________ // ________________________
3134 //|Y0|Y1| | //|Y0|Y1| |
3135 //|__|__| | //|__|__| |
3136 //| | //| |
3137 //| | //| |
3138 //| | //| |
3139 //| | //| |
3140 //| | //| |
3141 //|________________________| //|________________________|
3142 //|U0|U1|| | //|U0|U1| | |
3143 //|__|__|| | //|__|__| | |
3144 //| | | //| | |
3145 //| | PAD | //| | PAD |
3146 //| | | //| | |
3147 //| | | //| | |
3148 //| | | //| | |
3149 //|______|_________________| //|____________|___________|
3150 //|V0|V1|| | //|V0|V1| | |
3151 //|__|__|| | //|__|__| | |
3152 //| | | //| | |
3153 //| | PAD | //| | PAD |
3154 //| | | //| | |
3155 //| | | //| | |
3156 //| | | //| | |
3157 //|______|_________________| //|____________|___________|
3158
3159 // 4:4:4 (24-bits per pixel)
3160 // 444P
3161 // ----------------->
3162 // ________________________
3163 //|Y0|Y1| |
3164 //|__|__| |
3165 //| |
3166 //| |
3167 //| |
3168 //| |
3169 //| |
3170 //|________________________|
3171 //|U0|U1| |
3172 //|__|__| |
3173 //| |
3174 //| |
3175 //| |
3176 //| |
3177 //| |
3178 //|________________________|
3179 //|V0|V1| |
3180 //|__|__| |
3181 //| |
3182 //| |
3183 //| |
3184 //| |
3185 //| |
3186 //|________________________|
3187
3188 // 4:4:4 (24-bits per pixel)
3189 // RGBP
3190 // ----------------->
3191 // ________________________
3192 //|R0|R1| |
3193 //|__|__| |
3194 //| |
3195 //| |
3196 //| |
3197 //| |
3198 //| |
3199 //|________________________|
3200 //|G0|G1| |
3201 //|__|__| |
3202 //| |
3203 //| |
3204 //| |
3205 //| |
3206 //| |
3207 //|________________________|
3208 //|B0|B1| |
3209 //|__|__| |
3210 //| |
3211 //| |
3212 //| |
3213 //| |
3214 //| |
3215 //|________________________|
3216 case Format_RGBP:
3217
3218 // 4:4:4 (24-bits per pixel)
3219 // BGRP
3220 // ----------------->
3221 // ________________________
3222 //|B0|B1| |
3223 //|__|__| |
3224 //| |
3225 //| |
3226 //| |
3227 //| |
3228 //| |
3229 //|________________________|
3230 //|G0|G1| |
3231 //|__|__| |
3232 //| |
3233 //| |
3234 //| |
3235 //| |
3236 //| |
3237 //|________________________|
3238 //|R0|R1| |
3239 //|__|__| |
3240 //| |
3241 //| |
3242 //| |
3243 //| |
3244 //| |
3245 //|________________________|
3246 case Format_BGRP:
3247 case Format_411P:
3248 case Format_422H:
3249 case Format_444P:
3250 iWidthInBytes = pSurface->dwWidth;
3251 iHeightInRows = pSurface->dwHeight * 3;
3252 break;
3253
3254 // 4:1:1 (12-bits per pixel)
3255 // 411R
3256 // ----------------->
3257 // ________________________
3258 //|Y0|Y1| |
3259 //|__|__| |
3260 //| |
3261 //| |
3262 //| |
3263 //| |
3264 //| |
3265 //|________________________|
3266 //|U0|U1| |
3267 //|__|__| |
3268 //|________________________|
3269 //|V0|V1| |
3270 //|__|__| |
3271 //|________________________|
3272 case Format_411R:
3273 iWidthInBytes = pSurface->dwWidth;
3274 iHeightInRows = (pSurface->dwHeight * 3) / 2;
3275 break;
3276
3277 // 4:2:2V (16-bits per pixel)
3278 // 422V
3279 // ----------------->
3280 // ________________________
3281 //|Y0|Y1| |
3282 //|__|__| |
3283 //| |
3284 //| |
3285 //| |
3286 //| |
3287 //| |
3288 //|________________________|
3289 //|U0|U1| |
3290 //|__|__| |
3291 //| |
3292 //|________________________|
3293 //|V0|V1| |
3294 //|__|__| |
3295 //| |
3296 //|________________________|
3297 case Format_422V:
3298 iWidthInBytes = pSurface->dwWidth;
3299 iHeightInRows = pSurface->dwHeight * 2;
3300 break;
3301
3302 // 4:2:0 (12-bits per pixel)
3303 // IMC2 // IMC4
3304 // -----------------> // ----------------->
3305 // ________________________ // ________________________
3306 //|Y0|Y1| | //|Y0|Y1| |
3307 //|__|__| | //|__|__| |
3308 //| | //| |
3309 //| | //| |
3310 //| | //| |
3311 //| | //| |
3312 //| | //| |
3313 //|________________________| //|________________________|
3314 //|V0|V1| |U0|U1| | //|U0|U1| |V0|V1| |
3315 //|__|__| |__|__| | //|__|__| |__|__| |
3316 //| | | //| | |
3317 //|____________|___________| //|____________|___________|
3318
3319 // NV12 // YV12
3320 // -----------------> // ----------------->
3321 // ________________________ // ________________________
3322 //|Y0|Y1| | //|Y0|Y1| |
3323 //|__|__| | //|__|__| |
3324 //| | //| |
3325 //| | //| |
3326 //| | //| |
3327 //| | //| |
3328 //| | //| |
3329 //|________________________| //|________________________|
3330 //|U0|V0|U1|V1| | //|V0|V1| |
3331 //|__|__|__|__| | //|__|__|__________________|
3332 //| | //|U0|U1| |
3333 //|________________________| //|__|__|__________________|
3334
3335 case Format_IMC2:
3336 case Format_IMC4:
3337 case Format_NV12:
3338 case Format_YV12:
3339 case Format_I420:
3340 case Format_IYUV:
3341 case Format_YVU9:
3342 iWidthInBytes = pSurface->dwWidth;
3343 iHeightInRows = pSurface->dwHeight * iBpp / 8;
3344 break;
3345
3346 case Format_P010:
3347 case Format_P016:
3348 iWidthInBytes = pSurface->dwWidth * 2;
3349 iHeightInRows = pSurface->dwHeight * 3 / 2;
3350 break;
3351
3352 case Format_A16R16G16B16:
3353 case Format_A16B16G16R16:
3354 iWidthInBytes = pSurface->dwWidth * 8;
3355 iHeightInRows = pSurface->dwHeight;
3356 break;
3357
3358 case Format_P210:
3359 case Format_P216:
3360 iWidthInBytes = pSurface->dwWidth * 2;
3361 iHeightInRows = pSurface->dwHeight * 2;
3362
3363 default:
3364 VP_DEBUG_ASSERTMESSAGE("Format %d not supported.", pSurface->Format);
3365 eStatus = MOS_STATUS_UNKNOWN;
3366 goto finish;
3367 }
3368
3369 *piWidthInBytes = iWidthInBytes;
3370 *piHeightInRows = iHeightInRows;
3371
3372 finish:
3373 return eStatus;
3374 }
3375
AppendString(bool bFirst,char ** ppcBigString,PCCHAR pcToAppendFmt,...)3376 MOS_STATUS VpDumperTool::AppendString(
3377 bool bFirst,
3378 char* *ppcBigString,
3379 PCCHAR pcToAppendFmt,
3380 ...)
3381 {
3382 VP_FUNC_CALL();
3383
3384 static size_t stTotalStrLen = 0;
3385 static size_t stTotalAlloc = 0;
3386
3387 MOS_STATUS eStatus;
3388 size_t stStrLenOld;
3389 size_t stStrLenToAppend;
3390 char* pcToAppend;
3391 char* pcTmpPtr;
3392 va_list argList;
3393
3394 eStatus = MOS_STATUS_SUCCESS;
3395 stStrLenToAppend = 0;
3396 stStrLenOld = 0;
3397 pcTmpPtr = nullptr;
3398 pcToAppend = (char*)MOS_AllocAndZeroMemory(sizeof(char) * ALLOC_GRANULARITY);
3399
3400 if (bFirst)
3401 {
3402 stTotalStrLen = 0;
3403 stTotalAlloc = 0;
3404 }
3405
3406 stStrLenOld = stTotalStrLen;
3407
3408 if (ppcBigString == nullptr || pcToAppendFmt == nullptr || (int)strlen(pcToAppendFmt) < 0)
3409 {
3410 eStatus = MOS_STATUS_INVALID_PARAMETER;
3411 goto finish;
3412 }
3413
3414 va_start(argList, pcToAppendFmt);
3415 MosUtilities::MosSecureVStringPrint(pcToAppend, ALLOC_GRANULARITY, ALLOC_GRANULARITY, pcToAppendFmt, argList);
3416 va_end(argList);
3417
3418 stStrLenToAppend = strlen(pcToAppend);
3419
3420 if (*ppcBigString == nullptr)
3421 {
3422 stTotalStrLen = stStrLenToAppend + 1;
3423 stTotalAlloc = MOS_ALIGN_CEIL(stStrLenToAppend, ALLOC_GRANULARITY);
3424 *ppcBigString = (char*)MOS_AllocAndZeroMemory(stTotalAlloc);
3425 VP_DEBUG_CHK_NULL(*ppcBigString);
3426 *ppcBigString[0] = '\0';
3427 stStrLenOld++;
3428 }
3429 else
3430 {
3431 stTotalStrLen += stStrLenToAppend;
3432 if (stTotalStrLen >= stTotalAlloc)
3433 {
3434 stTotalAlloc = MOS_ALIGN_CEIL(stTotalStrLen, ALLOC_GRANULARITY);
3435 // Below should be equivalent to *ppcBigString = (char*)realloc(*ppcBigString, stTotalAlloc);
3436 pcTmpPtr = *ppcBigString;
3437 *ppcBigString = (char*)MOS_AllocAndZeroMemory(stTotalAlloc);
3438 VP_DEBUG_CHK_NULL(*ppcBigString);
3439 MOS_SecureStringPrint(*ppcBigString, stTotalAlloc, stTotalAlloc, "%s", pcTmpPtr);
3440 MOS_FreeMemory(pcTmpPtr);
3441 }
3442 }
3443 MOS_SecureMemcpy(
3444 (char*)(((uintptr_t)(*ppcBigString)) + stStrLenOld - 1),
3445 stStrLenToAppend + 1,
3446 pcToAppend,
3447 stStrLenToAppend + 1);
3448
3449 finish:
3450 MOS_FreeMemory(pcToAppend);
3451 return eStatus;
3452 }
3453
WriteFrame(PMOS_INTERFACE pOsInterface,PVPHAL_SURFACE pSurface,PCCHAR fileName,uint64_t iCounter)3454 void VpDumperTool::WriteFrame(
3455 PMOS_INTERFACE pOsInterface,
3456 PVPHAL_SURFACE pSurface,
3457 PCCHAR fileName,
3458 uint64_t iCounter)
3459 {
3460 VP_FUNC_CALL();
3461
3462 uint8_t* pData;
3463 char sPath[MAX_PATH];
3464 char sOsPath[MAX_PATH];
3465 uint8_t* pDst;
3466 uint8_t* pTmpDst;
3467 uint8_t* pTmpSrc;
3468 uint32_t iWidthInBytes;
3469 uint32_t iHeightInRows;
3470 uint32_t iBpp;
3471 uint32_t iSize;
3472 uint32_t iY;
3473 MOS_LOCK_PARAMS LockFlags;
3474
3475 pDst = nullptr;
3476 MOS_ZeroMemory(sPath, MAX_PATH);
3477 MOS_ZeroMemory(sOsPath, MAX_PATH);
3478
3479 // get bits per pixel for the format
3480 pOsInterface->pfnGetBitsPerPixel(pOsInterface, pSurface->Format, &iBpp);
3481
3482 VpDumperTool::GetSurfaceSize(
3483 pSurface,
3484 iBpp,
3485 &iWidthInBytes,
3486 &iHeightInRows);
3487
3488 iSize = iWidthInBytes * iHeightInRows;
3489
3490 // Write original image to file
3491 MOS_ZeroMemory(&LockFlags, sizeof(MOS_LOCK_PARAMS));
3492
3493 LockFlags.ReadOnly = 1;
3494
3495 pData = (uint8_t*)pOsInterface->pfnLockResource(
3496 pOsInterface,
3497 &pSurface->OsResource,
3498 &LockFlags);
3499
3500 if(pData == nullptr)
3501 {
3502 VP_DEBUG_ASSERTMESSAGE("pData == nullptr.");
3503
3504 return;
3505 }
3506 MOS_SecureStringPrint(
3507 sPath,
3508 MAX_PATH,
3509 sizeof(sPath),
3510 "c:\\dump\\f[%08I64x]_%s_w[%d]_h[%d]_p[%d].%s",
3511 iCounter,
3512 fileName,
3513 pSurface->dwWidth,
3514 pSurface->dwHeight,
3515 pSurface->dwPitch,
3516 VpDumperTool::GetFormatStr(pSurface->Format));
3517
3518 MOS_SecureMemcpy(sOsPath, MAX_PATH, sPath, strlen(sPath));
3519
3520 // Write the data to file
3521 if (pSurface->dwPitch == iWidthInBytes)
3522 {
3523 MosUtilities::MosWriteFileFromPtr((const char *)sOsPath, pData, iSize);
3524 }
3525 else
3526 {
3527 pDst = (uint8_t*)MOS_AllocAndZeroMemory(iSize);
3528 pTmpSrc = pData;
3529 pTmpDst = pDst;
3530
3531 for (iY = 0; iY < iHeightInRows; iY++)
3532 {
3533 MOS_SecureMemcpy(pTmpDst, iSize, pTmpSrc, iWidthInBytes);
3534 pTmpSrc += pSurface->dwPitch;
3535 pTmpDst += iWidthInBytes;
3536 }
3537
3538 MosUtilities::MosWriteFileFromPtr((const char *)sOsPath, pDst, iSize);
3539 }
3540
3541 if (pDst)
3542 {
3543 MOS_FreeMemory(pDst);
3544 }
3545
3546 pOsInterface->pfnUnlockResource(
3547 pOsInterface,
3548 &pSurface->OsResource);
3549 }
3550
GetComponentStr(MOS_COMPONENT component)3551 const char * VpParameterDumper::GetComponentStr(MOS_COMPONENT component)
3552 {
3553 VP_FUNC_CALL();
3554
3555 switch (component)
3556 {
3557 case COMPONENT_UNKNOWN: return _T("COMPONENT_UNKNOWN");
3558 case COMPONENT_LibVA: return _T("COMPONENT_LibVA");
3559 case COMPONENT_VPreP: return _T("COMPONENT_VPreP");
3560 case COMPONENT_EMULATION: return _T("COMPONENT_EMULATION");
3561 case COMPONENT_CM: return _T("COMPONENT_CM");
3562 case COMPONENT_Encode: return _T("COMPONENT_Encode");
3563 case COMPONENT_Decode: return _T("COMPONENT_Decode");
3564 default: return _T("Err");
3565 }
3566
3567 return nullptr;
3568 }
3569
GetWholeFormatStr(MOS_FORMAT format)3570 const char * VpParameterDumper::GetWholeFormatStr(MOS_FORMAT format)
3571 {
3572 VP_FUNC_CALL();
3573
3574 switch (format)
3575 {
3576 case Format_Invalid: return _T("Format_Invalid");
3577 case Format_Source: return _T("Format_Source");
3578 case Format_420O: return _T("Format_420O");
3579 case Format_RGB_Swap: return _T("Format_RGB_Swap");
3580 case Format_RGB_No_Swap: return _T("Format_RGB_No_Swap");
3581 case Format_RGB: return _T("Format_RGB");
3582 case Format_RGB32: return _T("Format_RGB32");
3583 case Format_PA: return _T("Format_PA");
3584 case Format_PL2: return _T("Format_PL2");
3585 case Format_PL2_UnAligned: return _T("Format_PL2_UnAligned");
3586 case Format_PL3: return _T("Format_PL3");
3587 case Format_PL3_RGB: return _T("Format_PL3_RGB");
3588 case Format_PAL: return _T("Format_PA_T(");
3589
3590 case Format_None: return _T("Format_None");
3591 case Format_Any: return _T("Format_Any");
3592 case Format_A8R8G8B8: return _T("Format_A8R8G8B8");
3593 case Format_X8R8G8B8: return _T("Format_X8R8G8B8");
3594 case Format_A8B8G8R8: return _T("Format_A8B8G8R8");
3595 case Format_X8B8G8R8: return _T("Format_X8B8G8R8");
3596 case Format_A16B16G16R16: return _T("Format_A16B16G16R16");
3597 case Format_A16R16G16B16: return _T("Format_A16R16G16B16");
3598 case Format_R5G6B5: return _T("Format_R5G6B5");
3599 case Format_R8G8B8: return _T("Format_R8G8B8");
3600 case Format_R32U: return _T("Format_R32U");
3601 case Format_R32F: return _T("Format_R32F");
3602 case Format_RGBP: return _T("Format_RGBP");
3603 case Format_BGRP: return _T("Format_BGRP");
3604
3605 case Format_YUY2: return _T("Format_YUY2");
3606 case Format_YUYV: return _T("Format_YUYV");
3607 case Format_YVYU: return _T("Format_YVYU");
3608 case Format_UYVY: return _T("Format_UYVY");
3609 case Format_VYUY: return _T("Format_VYUY");
3610
3611 case Format_Y416: return _T("Format_Y416");
3612 case Format_AYUV: return _T("Format_AYUV");
3613 case Format_AUYV: return _T("Format_AUYV");
3614 case Format_400P: return _T("Format_400P");
3615 case Format_NV12: return _T("Format_NV12");
3616 case Format_NV12_UnAligned: return _T("Format_NV12_UnAligned");
3617 case Format_NV21: return _T("Format_NV21");
3618 case Format_NV11: return _T("Format_NV11");
3619 case Format_NV11_UnAligned: return _T("Format_NV11_UnAligned");
3620 case Format_P208: return _T("Format_P208");
3621 case Format_P208_UnAligned: return _T("Format_P208_UnAligned");
3622 case Format_IMC1: return _T("Format_IMC1");
3623 case Format_IMC2: return _T("Format_IMC2");
3624 case Format_IMC3: return _T("Format_IMC3");
3625 case Format_IMC4: return _T("Format_IMC4");
3626 case Format_422H: return _T("Format_422H");
3627 case Format_422V: return _T("Format_422V");
3628 case Format_444P: return _T("Format_444P");
3629 case Format_411P: return _T("Format_411P");
3630 case Format_411R: return _T("Format_411R");
3631 case Format_I420: return _T("Format_I420");
3632 case Format_IYUV: return _T("Format_IYUV");
3633 case Format_YV12: return _T("Format_YV12");
3634 case Format_YVU9: return _T("Format_YVU9");
3635 case Format_AI44: return _T("Format_AI44");
3636 case Format_IA44: return _T("Format_IA44");
3637 case Format_P8: return _T("Format_P8");
3638 case Format_A8P8: return _T("Format_A8P8");
3639 case Format_A8: return _T("Format_A8");
3640 case Format_L8: return _T("Format_L8");
3641 case Format_A4L4: return _T("Format_A4L4");
3642 case Format_A8L8: return _T("Format_A8L8");
3643 case Format_IRW0: return _T("Format_IRW0");
3644 case Format_IRW1: return _T("Format_IRW1");
3645 case Format_IRW2: return _T("Format_IRW2");
3646 case Format_IRW3: return _T("Format_IRW3");
3647 case Format_IRW4: return _T("Format_IRW4");
3648 case Format_IRW5: return _T("Format_IRW5");
3649 case Format_IRW6: return _T("Format_IRW6");
3650 case Format_IRW7: return _T("Format_IRW7");
3651 case Format_STMM: return _T("Format_STMM");
3652 case Format_Buffer: return _T("Format_Buffer");
3653 case Format_Buffer_2D: return _T("Format_Buffer_2D");
3654 case Format_V8U8: return _T("Format_V8U8");
3655 case Format_R32S: return _T("Format_R32S");
3656 case Format_R8U: return _T("Format_R8U");
3657 case Format_R8G8UN: return _T("Format_R8G8UN");
3658 case Format_R8G8SN: return _T("Format_R8G8SN");
3659 case Format_G8R8_G8B8: return _T("Format_G8R8_G8B8");
3660 case Format_R16U: return _T("Format_R16U");
3661 case Format_R16S: return _T("Format_R16S");
3662 case Format_R16UN: return _T("Format_R16UN");
3663 case Format_RAW: return _T("Format_RAW");
3664 case Format_Y8: return _T("Format_Y8");
3665 case Format_Y1: return _T("Format_Y1");
3666 case Format_Y16U: return _T("Format_Y16U");
3667 case Format_Y16S: return _T("Format_Y16S");
3668 case Format_L16: return _T("Format_L16");
3669 case Format_D16: return _T("Format_D16");
3670 case Format_R10G10B10A2: return _T("Format_R10G10B10A2");
3671 case Format_B10G10R10A2: return _T("Format_B10G10R10A2");
3672 case Format_P016: return _T("Format_P016");
3673 case Format_P010: return _T("Format_P010");
3674 case Format_Y210: return _T("Format_Y210");
3675 case Format_Y216: return _T("Format_Y216");
3676 case Format_Y410: return _T("Format_Y410");
3677 case Format_P210: return _T("Format_P210");
3678 case Format_P216: return _T("Format_P216");
3679 case Format_YV12_Planar: return _T("Format_YV12_Planar");
3680 case Format_Count: return _T("Format_Count");
3681 case Format_A16B16G16R16F: return _T("Format_A16B16G16R16F");
3682 case Format_A16R16G16B16F: return _T("Format_A16R16G16B16F");
3683 default: return _T("Err");
3684 }
3685
3686 return nullptr;
3687 }
3688
GetTileTypeStr(MOS_TILE_TYPE tile_type)3689 const char * VpParameterDumper::GetTileTypeStr(MOS_TILE_TYPE tile_type)
3690 {
3691 VP_FUNC_CALL();
3692
3693 switch (tile_type)
3694 {
3695 case MOS_TILE_X: return _T("MOS_TILE_X");
3696 case MOS_TILE_Y: return _T("MOS_TILE_Y");
3697 case MOS_TILE_LINEAR: return _T("MOS_TILE_LINEAR");
3698 case MOS_TILE_INVALID: return _T("MOS_TILE_INVALID");
3699 default: return _T("Err");
3700 }
3701
3702 return nullptr;
3703 }
3704
GetTileModeGMMStr(MOS_TILE_MODE_GMM tile_mode)3705 const char *VpParameterDumper::GetTileModeGMMStr(MOS_TILE_MODE_GMM tile_mode)
3706 {
3707 VP_FUNC_CALL();
3708
3709 switch (tile_mode)
3710 {
3711 case MOS_TILE_64_GMM:
3712 return _T("MOS_TILE_64_GMM");
3713 case MOS_TILE_4_GMM:
3714 return _T("MOS_TILE_4_GMM");
3715 case MOS_TILE_LINEAR_GMM:
3716 return _T("MOS_TILE_LINEAR_GMM");
3717 case MOS_TILE_UNSET_GMM:
3718 return _T("MOS_TILE_UNSET_GMM");
3719 default:
3720 return _T("Err");
3721 }
3722 }
3723
GetSurfaceTypeStr(VPHAL_SURFACE_TYPE surface_type)3724 const char * VpParameterDumper::GetSurfaceTypeStr(VPHAL_SURFACE_TYPE surface_type)
3725 {
3726 VP_FUNC_CALL();
3727
3728 switch (surface_type)
3729 {
3730 case SURF_NONE: return _T("SURF_NONE");
3731 case SURF_IN_BACKGROUND: return _T("SURF_IN_BACKGROUND");
3732 case SURF_IN_PRIMARY: return _T("SURF_IN_PRIMARY");
3733 case SURF_IN_SUBSTREAM: return _T("SURF_IN_SUBSTREAM");
3734 case SURF_IN_REFERENCE: return _T("SURF_IN_REFERENCE");
3735 case SURF_OUT_RENDERTARGET: return _T("SURF_OUT_RENDERTARGET");
3736 case SURF_TYPE_COUNT: return _T("SURF_TYPE_COUNT");
3737 default: return _T("Err");
3738 }
3739
3740 return nullptr;
3741 }
3742
GetGammaValueTypeStr(VPHAL_GAMMA_VALUE gamma_value)3743 const char *VpParameterDumper::GetGammaValueTypeStr(VPHAL_GAMMA_VALUE gamma_value)
3744 {
3745 VP_FUNC_CALL();
3746
3747 switch (gamma_value)
3748 {
3749 case GAMMA_1P0:
3750 return _T("GAMMA_1P0");
3751 case GAMMA_2P2:
3752 return _T("GAMMA_2P2");
3753 case GAMMA_2P6:
3754 return _T("GAMMA_2P6");
3755 default:
3756 return _T("Err");
3757 }
3758
3759 return nullptr;
3760 }
3761
GetSampleTypeStr(VPHAL_SAMPLE_TYPE sample_type)3762 const char * VpParameterDumper::GetSampleTypeStr(VPHAL_SAMPLE_TYPE sample_type)
3763 {
3764 VP_FUNC_CALL();
3765
3766 switch (sample_type)
3767 {
3768 case SAMPLE_PROGRESSIVE: return _T("SAMPLE_PROGRESSIVE");
3769 case SAMPLE_SINGLE_TOP_FIELD: return _T("SAMPLE_SINGLE_TOP_FIELD");
3770 case SAMPLE_SINGLE_BOTTOM_FIELD: return _T("SAMPLE_SINGLE_BOTTOM_FIELD");
3771 case SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD: return _T("SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD");
3772 case SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD: return _T("SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD");
3773 case SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD: return _T("SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD");
3774 case SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD: return _T("SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD");
3775 case SAMPLE_INVALID: return _T("SAMPLE_INVALID");
3776 default: return _T("Err");
3777 }
3778
3779 return nullptr;
3780 }
3781
GetColorSpaceStr(VPHAL_CSPACE color_space)3782 const char * VpParameterDumper::GetColorSpaceStr(VPHAL_CSPACE color_space)
3783 {
3784 VP_FUNC_CALL();
3785
3786 switch (color_space)
3787 {
3788 case CSpace_None: return _T("CSpace_None");
3789 case CSpace_Source: return _T("CSpace_Source");
3790 case CSpace_RGB: return _T("CSpace_RGB");
3791 case CSpace_YUV: return _T("CSpace_YUV");
3792 case CSpace_Gray: return _T("CSpace_Gray");
3793 case CSpace_Any: return _T("CSpace_Any");
3794 case CSpace_sRGB: return _T("CSpace_sRGB");
3795 case CSpace_stRGB: return _T("CSpace_stRGB");
3796 case CSpace_BT601: return _T("CSpace_BT601");
3797 case CSpace_BT601_FullRange: return _T("CSpace_BT601_FullRange");
3798 case CSpace_BT709: return _T("CSpace_BT709");
3799 case CSpace_BT709_FullRange: return _T("CSpace_BT709_FullRange");
3800 case CSpace_xvYCC601: return _T("CSpace_xvYCC601");
3801 case CSpace_xvYCC709: return _T("CSpace_xvYCC709");
3802 case CSpace_BT601Gray: return _T("CSpace_BT601Gray");
3803 case CSpace_BT601Gray_FullRange: return _T("CSpace_BT601Gray_FullRange");
3804 case CSpace_BT2020: return _T("CSpace_BT2020");
3805 case CSpace_BT2020_FullRange: return _T("CSpace_BT2020_FullRange");
3806 case CSpace_BT2020_RGB: return _T("CSpace_BT2020_RGB");
3807 case CSpace_BT2020_stRGB: return _T("CSpace_BT2020_stRGB");
3808 case CSpace_Count: return _T("CSpace_Count");
3809 default: return _T("Err");
3810 }
3811
3812 return nullptr;
3813 }
3814
GetBlendTypeStr(VPHAL_BLEND_TYPE blend_type)3815 const char * VpParameterDumper::GetBlendTypeStr(VPHAL_BLEND_TYPE blend_type)
3816 {
3817 VP_FUNC_CALL();
3818
3819 switch (blend_type)
3820 {
3821 case BLEND_NONE: return _T("BLEND_NONE");
3822 case BLEND_SOURCE: return _T("BLEND_SOURCE");
3823 case BLEND_PARTIAL: return _T("BLEND_PARTIAL");
3824 case BLEND_CONSTANT: return _T("BLEND_CONSTANT");
3825 case BLEND_CONSTANT_SOURCE: return _T("BLEND_CONSTANT_SOURCE");
3826 case BLEND_CONSTANT_PARTIAL: return _T("BLEND_CONSTANT_PARTIAL");
3827 default: return _T("Err");
3828 }
3829
3830 return nullptr;
3831 }
3832
GetPaletteTypeStr(VPHAL_PALETTE_TYPE palette_type)3833 const char * VpParameterDumper::GetPaletteTypeStr(VPHAL_PALETTE_TYPE palette_type)
3834 {
3835 VP_FUNC_CALL();
3836
3837 switch (palette_type)
3838 {
3839 case VPHAL_PALETTE_NONE: return _T("VPHAL_PALETTE_NONE");
3840 case VPHAL_PALETTE_YCbCr_8: return _T("VPHAL_PALETTE_YCbCr_8");
3841 case VPHAL_PALETTE_ARGB_8: return _T("VPHAL_PALETTE_ARGB_8");
3842 case VPHAL_PALETTE_AVYU_8: return _T("VPHAL_PALETTE_AVYU_8");
3843 default: return _T("Err");
3844 }
3845
3846 return nullptr;
3847 }
3848
GetScalingModeStr(VPHAL_SCALING_MODE scaling_mode)3849 const char * VpParameterDumper::GetScalingModeStr(VPHAL_SCALING_MODE scaling_mode)
3850 {
3851 VP_FUNC_CALL();
3852
3853 switch (scaling_mode)
3854 {
3855 case VPHAL_SCALING_NEAREST: return _T("VPHAL_SCALING_NEAREST");
3856 case VPHAL_SCALING_BILINEAR: return _T("VPHAL_SCALING_BILINEAR");
3857 case VPHAL_SCALING_AVS: return _T("VPHAL_SCALING_AVS");
3858 default: return _T("Err");
3859 }
3860
3861 return nullptr;
3862 }
3863
GetRotationModeStr(VPHAL_ROTATION rotation_mode)3864 const char * VpParameterDumper::GetRotationModeStr(VPHAL_ROTATION rotation_mode)
3865 {
3866 VP_FUNC_CALL();
3867
3868 switch (rotation_mode)
3869 {
3870 case VPHAL_ROTATION_IDENTITY: return _T("VPHAL_ROTATION_IDENTITY");
3871 case VPHAL_ROTATION_90: return _T("VPHAL_ROTATION_90");
3872 case VPHAL_ROTATION_180: return _T("VPHAL_ROTATION_180");
3873 case VPHAL_ROTATION_270: return _T("VPHAL_ROTATION_270");
3874 case VPHAL_MIRROR_HORIZONTAL: return _T("VPHAL_MIRROR_HORIZONTAL");
3875 case VPHAL_MIRROR_VERTICAL: return _T("VPHAL_MIRROR_VERTICAL");
3876 case VPHAL_ROTATE_90_MIRROR_VERTICAL: return _T("VPHAL_ROTATE_90_MIRROR_VERTICAL");
3877 case VPHAL_ROTATE_90_MIRROR_HORIZONTAL: return _T("VPHAL_ROTATE_90_MIRROR_HORIZONTAL");
3878
3879 default: return _T("Err");
3880 }
3881
3882 return nullptr;
3883 }
3884
GetDIModeStr(VPHAL_DI_MODE di_mode)3885 const char * VpParameterDumper::GetDIModeStr(VPHAL_DI_MODE di_mode)
3886 {
3887 VP_FUNC_CALL();
3888
3889 switch (di_mode)
3890 {
3891 case DI_MODE_BOB: return _T("DI_MODE_BOB");
3892 case DI_MODE_ADI: return _T("DI_MODE_ADI");
3893 default: return _T("Err");
3894 }
3895
3896 return nullptr;
3897 }
3898
GetDenoiseModeStr(VPHAL_NOISELEVEL noise_level)3899 const char * VpParameterDumper::GetDenoiseModeStr(VPHAL_NOISELEVEL noise_level)
3900 {
3901 VP_FUNC_CALL();
3902
3903 switch (noise_level)
3904 {
3905 case NOISELEVEL_DEFAULT: return _T("NOISELEVEL_DEFAULT");
3906 case NOISELEVEL_VC1_HD: return _T("NOISELEVEL_VC1_HD");
3907 default: return _T("Err");
3908 }
3909
3910 return nullptr;
3911 }
3912
GetHVSDenoiseModeStr(VPHAL_HVSDN_MODE hvs_dn_mode)3913 const char *VpParameterDumper::GetHVSDenoiseModeStr(VPHAL_HVSDN_MODE hvs_dn_mode)
3914 {
3915 switch (hvs_dn_mode)
3916 {
3917 case HVSDENOISE_AUTO_BDRATE:
3918 return _T("HVSDENOISE_AUTO_BDRATE");
3919 case HVSDENOISE_AUTO_SUBJECTIVE:
3920 return _T("HVSDENOISE_AUTO_SUBJECTIVE");
3921 case HVSDENOISE_MANUAL:
3922 return _T("HVSDENOISE_MANUAL");
3923 default:
3924 return _T("Err");
3925 }
3926
3927 return nullptr;
3928 }
3929 #endif // (_DEBUG || _RELEASE_INTERNAL)
3930