1 /*
2 // Copyright (C) 2020-2021 Intel Corporation
3 //
4 // Licensed under the Apache License,Version 2.0(the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing,software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 //!
17 //! \file     codechal_debug_xe_xpm_ext.cpp
18 //! \brief    Defines the ext debug interface .
19 //! \details  The ext debug interface dumps that are used only for internal branches
20 //!
21 
22 #include "codechal_debug.h"
23 
24 #if USE_CODECHAL_DEBUG_TOOL
25 
26 #include "codechal_debug_xe_xpm_ext.h"
27 #include "codechal_utilities.h"
28 #include "codechal_hw_xe_xpm.h"
29 
CodechalDebugInterfaceXe_Xpm()30 CodechalDebugInterfaceXe_Xpm::CodechalDebugInterfaceXe_Xpm()
31 {
32 
33 }
34 
~CodechalDebugInterfaceXe_Xpm()35 CodechalDebugInterfaceXe_Xpm::~CodechalDebugInterfaceXe_Xpm()
36 {
37 
38 }
39 
DumpBltOutput(PMOS_SURFACE surface,const char * attrName)40 MOS_STATUS CodechalDebugInterfaceXe_Xpm::DumpBltOutput(
41     PMOS_SURFACE              surface,
42     const char *              attrName)
43 {
44     if (!DumpIsEnabled(attrName))
45     {
46         return MOS_STATUS_SUCCESS;
47     }
48 
49     bool copyMain = true;
50     bool copyCcs = true;
51     BltStateXe_Xpm *bltState = nullptr;
52     CodechalHwInterfaceXe_Xpm* hwInterface = dynamic_cast<CodechalHwInterfaceXe_Xpm*>(m_hwInterface);
53     CODECHAL_DEBUG_CHK_NULL(hwInterface);
54     bltState = hwInterface->GetBltState();
55     CODECHAL_DEBUG_CHK_NULL(bltState);
56     const PMOS_SURFACE inputSurface = surface;
57     MOS_ALLOC_GFXRES_PARAMS AllocParams = {};
58 
59     if (copyMain)
60     {
61         CODECHAL_DEBUG_CHK_STATUS_MESSAGE(
62             DumpYUVSurface(
63                 inputSurface,
64                 attrName,
65                 "BltOutMainSurf"),
66             "DumpYUVSurface BltOutMainSurf error");
67     }
68 
69     if (copyCcs)
70     {
71         // dump ccs surface
72         MOS_ZeroMemory(&AllocParams, sizeof(MOS_ALLOC_GFXRES_PARAMS));
73         AllocParams.TileType        = MOS_TILE_LINEAR;
74         AllocParams.Type            = MOS_GFXRES_BUFFER;
75         AllocParams.dwWidth         = (uint32_t)inputSurface->OsResource.pGmmResInfo->GetSizeMainSurface() / 256;
76         AllocParams.dwHeight        = 1;
77         AllocParams.Format          = Format_Buffer;
78         AllocParams.bIsCompressible = false;
79         AllocParams.CompressionMode = MOS_MMC_DISABLED;
80         AllocParams.pBufName        = "TempCCS";
81         AllocParams.dwArraySize     = 1;
82 
83         PMOS_SURFACE ccsSurface = (PMOS_SURFACE)MOS_AllocAndZeroMemory(sizeof(MOS_SURFACE));
84         m_osInterface->pfnAllocateResource(
85             m_osInterface,
86             &AllocParams,
87             &ccsSurface->OsResource);
88         CODECHAL_DEBUG_CHK_STATUS(CodecHalGetResourceInfo(
89             m_osInterface,
90             ccsSurface));
91         CODECHAL_DEBUG_VERBOSEMESSAGE("BLT CCS surface width %d, height %d, pitch %d, TileType %d, bIsCompressed %d, CompressionMode %d",
92             ccsSurface->dwWidth, ccsSurface->dwHeight, ccsSurface->dwPitch, ccsSurface->TileType, ccsSurface->bIsCompressed, ccsSurface->CompressionMode);
93 
94         CODECHAL_DEBUG_CHK_STATUS_MESSAGE(
95             bltState->GetCCS(inputSurface, ccsSurface),
96             "BLT CopyMainSurface error");
97 
98         CODECHAL_DEBUG_CHK_STATUS_MESSAGE(
99             DumpSurface(
100                 ccsSurface,
101                 attrName,
102                 "BltOutCcsSurf"),
103             "DumpYUVSurface BltOutMainSurf error");
104 
105         m_osInterface->pfnFreeResource(m_osInterface, &ccsSurface->OsResource);
106         MOS_FreeMemAndSetNull(ccsSurface);
107     }
108 
109     return MOS_STATUS_SUCCESS;
110 }
111 
112 #endif
113