| 1 |
/* |
| 2 |
* Copyright (c) 2020-2022, 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 media_debug_interface_misc.cpp |
| 24 |
//! \brief Defines the debug interface shared by all of Media. |
| 25 |
//! \details The debug interface dumps output from Media based on input config file. |
| 26 |
//! |
| 27 |
#include "media_debug_interface.h" |
| 28 |
#if USE_MEDIA_DEBUG_TOOL |
| 29 |
MOS_STATUS MediaDebugInterface::SubmitDummyWorkload(MOS_COMMAND_BUFFER *pCmdBuffer, int32_t bNullRendering) |
| 30 |
{ |
| 31 |
MHW_MI_FLUSH_DW_PARAMS flushDwParams{}; |
| 32 |
MEDIA_DEBUG_CHK_STATUS(((MhwMiInterface*)m_miInterface)->AddMiFlushDwCmd( |
| 33 |
pCmdBuffer, |
| 34 |
&flushDwParams)); |
| 35 |
MEDIA_DEBUG_CHK_STATUS(((MhwMiInterface*)m_miInterface)->AddMiBatchBufferEnd( |
| 36 |
pCmdBuffer, |
| 37 |
nullptr)); |
| 38 |
m_osInterface->pfnReturnCommandBuffer(m_osInterface, pCmdBuffer, 0); |
| 39 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSubmitCommandBuffer(m_osInterface, pCmdBuffer, bNullRendering)); |
| 40 |
return MOS_STATUS_SUCCESS; |
| 41 |
} |
| 42 |
|
| 43 |
MOS_STATUS MediaDebugInterface::CopySurfaceData_Vdbox( |
| 44 |
uint32_t dwDataSize, |
| 45 |
PMOS_RESOURCE presSourceSurface, |
| 46 |
PMOS_RESOURCE presCopiedSurface) |
| 47 |
{ |
| 48 |
MOS_COMMAND_BUFFER CmdBuffer{}; |
| 49 |
MHW_MI_FLUSH_DW_PARAMS FlushDwParams{}; |
| 50 |
MHW_GENERIC_PROLOG_PARAMS genericPrologParams{}; |
| 51 |
MHW_CP_COPY_PARAMS cpCopyParams{}; |
| 52 |
MOS_NULL_RENDERING_FLAGS NullRenderingFlags{}; |
| 53 |
MOS_GPU_CONTEXT orgGpuContext{}; |
| 54 |
|
| 55 |
if (!m_vdboxContextCreated) |
| 56 |
{ |
| 57 |
MOS_GPUCTX_CREATOPTIONS_ENHANCED createOption = {}; |
| 58 |
|
| 59 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnCreateGpuContext( |
| 60 |
m_osInterface, |
| 61 |
MOS_GPU_CONTEXT_VIDEO, |
| 62 |
MOS_GPU_NODE_VIDEO, |
| 63 |
&createOption)); |
| 64 |
|
| 65 |
// Register VDbox GPU context with the Batch Buffer completion event |
| 66 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterBBCompleteNotifyEvent( |
| 67 |
m_osInterface, |
| 68 |
MOS_GPU_CONTEXT_VIDEO)); |
| 69 |
|
| 70 |
m_vdboxContextCreated = true; |
| 71 |
} |
| 72 |
|
| 73 |
MEDIA_DEBUG_CHK_NULL(m_cpInterface); |
| 74 |
MEDIA_DEBUG_CHK_NULL(m_osInterface); |
| 75 |
MEDIA_DEBUG_CHK_NULL(m_miInterface); |
| 76 |
MEDIA_DEBUG_CHK_NULL(m_osInterface->pfnGetWaTable(m_osInterface)); |
| 77 |
|
| 78 |
orgGpuContext = m_osInterface->CurrentGpuContextOrdinal; |
| 79 |
|
| 80 |
// Due to VDBOX cryto copy limitation, the size must be Cache line aligned |
| 81 |
if (!MOS_IS_ALIGNED(dwDataSize, MHW_CACHELINE_SIZE)) |
| 82 |
{ |
| 83 |
MEDIA_DEBUG_ASSERTMESSAGE("Size is not CACHE line aligned, cannot use VDBOX to copy."); |
| 84 |
return MOS_STATUS_INVALID_PARAMETER; |
| 85 |
} |
| 86 |
|
| 87 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSetGpuContext(m_osInterface, MOS_GPU_CONTEXT_VIDEO)); |
| 88 |
m_osInterface->pfnResetOsStates(m_osInterface); |
| 89 |
|
| 90 |
// Register the target resource |
| 91 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterResource( |
| 92 |
m_osInterface, |
| 93 |
presCopiedSurface, |
| 94 |
true, |
| 95 |
true)); |
| 96 |
|
| 97 |
// Register the source resource |
| 98 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterResource( |
| 99 |
m_osInterface, |
| 100 |
presSourceSurface, |
| 101 |
false, |
| 102 |
true)); |
| 103 |
|
| 104 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnGetCommandBuffer(m_osInterface, &CmdBuffer, 0)); |
| 105 |
|
| 106 |
genericPrologParams.pOsInterface = m_osInterface; |
| 107 |
genericPrologParams.pvMiInterface = (MhwMiInterface*)m_miInterface; |
| 108 |
genericPrologParams.bMmcEnabled = false; |
| 109 |
MEDIA_DEBUG_CHK_STATUS(Mhw_SendGenericPrologCmd(&CmdBuffer, &genericPrologParams)); |
| 110 |
|
| 111 |
cpCopyParams.size = dwDataSize; |
| 112 |
cpCopyParams.presSrc = presSourceSurface; |
| 113 |
cpCopyParams.presDst = presCopiedSurface; |
| 114 |
cpCopyParams.isEncodeInUse = false; |
| 115 |
|
| 116 |
MEDIA_DEBUG_CHK_STATUS(m_cpInterface->SetCpCopy(m_osInterface, &CmdBuffer, &cpCopyParams)); |
| 117 |
|
| 118 |
// MI_FLUSH |
| 119 |
MEDIA_DEBUG_CHK_STATUS(((MhwMiInterface*)m_miInterface)->AddMiFlushDwCmd( |
| 120 |
&CmdBuffer, |
| 121 |
&FlushDwParams)); |
| 122 |
|
| 123 |
MEDIA_DEBUG_CHK_STATUS(((MhwMiInterface*)m_miInterface)->AddMiBatchBufferEnd( |
| 124 |
&CmdBuffer, |
| 125 |
nullptr)); |
| 126 |
|
| 127 |
m_osInterface->pfnReturnCommandBuffer(m_osInterface, &CmdBuffer, 0); |
| 128 |
|
| 129 |
NullRenderingFlags = m_osInterface->pfnGetNullHWRenderFlags(m_osInterface); |
| 130 |
|
| 131 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSubmitCommandBuffer( |
| 132 |
m_osInterface, |
| 133 |
&CmdBuffer, |
| 134 |
NullRenderingFlags.CtxVideo || NullRenderingFlags.CodecGlobal || NullRenderingFlags.CtxVideo || NullRenderingFlags.VPGobal)); |
| 135 |
|
| 136 |
MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSetGpuContext(m_osInterface, orgGpuContext)); |
| 137 |
return MOS_STATUS_SUCCESS; |
| 138 |
} |
| 139 |
|
| 140 |
#endif // USE_MEDIA_DEBUG_TOOL |