| 1 |
/* |
| 2 |
* Copyright (c) 2018-2021, 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 |
#ifndef __VP_PACKET_PIPE_H__ |
| 23 |
#define __VP_PACKET_PIPE_H__ |
| 24 |
|
| 25 |
#include "media_cmd_packet.h" |
| 26 |
#include "mhw_sfc.h" |
| 27 |
#include "vp_pipeline_common.h" |
| 28 |
#include "vp_allocator.h" |
| 29 |
#include "vp_debug_interface.h" |
| 30 |
#include "vp_graphset.h" |
| 31 |
|
| 32 |
#include <vector> |
| 33 |
#include "hw_filter.h" |
| 34 |
|
| 35 |
#include "vp_packet_shared_context.h" |
| 36 |
|
| 37 |
class MediaScalability; |
| 38 |
class MediaContext; |
| 39 |
class VpDebugInterface; |
| 40 |
|
| 41 |
namespace vp { |
| 42 |
|
| 43 |
class VpPlatformInterface; |
| 44 |
class VpKernelSet; |
| 45 |
|
| 46 |
class PacketFactory |
| 47 |
{ |
| 48 |
public: |
| 49 |
PacketFactory(VpPlatformInterface *vpPlatformInterface); |
| 50 |
virtual ~PacketFactory(); |
| 51 |
MOS_STATUS Initialize(MediaTask *pTask, PVP_MHWINTERFACE pHwInterface, PVpAllocator pAllocator, VPMediaMemComp *pMmc, VP_PACKET_SHARED_CONTEXT *packetSharedContext, VpKernelSet *vpKernels, void *debugInterface, VpGraphSet *vpGraphSets); |
| 52 |
VpCmdPacket *CreatePacket(EngineType type); |
| 53 |
void ReturnPacket(VpCmdPacket *&pPacket); |
| 54 |
|
| 55 |
VpDebugInterface *m_debugInterface = nullptr; |
| 56 |
|
| 57 |
protected: |
| 58 |
VpCmdPacket *CreateVeboxPacket(); |
| 59 |
VpCmdPacket *CreateRenderPacket(); |
| 60 |
VpCmdPacket *CreateNpuPacket(); |
| 61 |
|
| 62 |
void ClearPacketPool(std::vector<VpCmdPacket *> &pool); |
| 63 |
|
| 64 |
std::vector<VpCmdPacket *> m_VeboxPacketPool; |
| 65 |
std::vector<VpCmdPacket *> m_RenderPacketPool; |
| 66 |
VpCmdPacket *m_NpuPacket = nullptr; //Only one npu packet needed in current case |
| 67 |
|
| 68 |
MediaTask *m_pTask = nullptr; |
| 69 |
PVP_MHWINTERFACE m_pHwInterface = nullptr; |
| 70 |
PVpAllocator m_pAllocator = nullptr; |
| 71 |
VPMediaMemComp *m_pMmc = nullptr; |
| 72 |
VpPlatformInterface *m_vpPlatformInterface = nullptr; |
| 73 |
VpKernelSet *m_kernelSet = nullptr; |
| 74 |
VpGraphSet *m_graphSet = nullptr; |
| 75 |
VP_PACKET_SHARED_CONTEXT *m_packetSharedContext = nullptr; |
| 76 |
|
| 77 |
MEDIA_CLASS_DEFINE_END(vp__PacketFactory) |
| 78 |
}; |
| 79 |
|
| 80 |
class PacketPipe |
| 81 |
{ |
| 82 |
public: |
| 83 |
PacketPipe(PacketFactory &packetFactory); |
| 84 |
virtual ~PacketPipe(); |
| 85 |
MOS_STATUS Clean(); |
| 86 |
MOS_STATUS AddPacket(HwFilter &hwFilter); |
| 87 |
MOS_STATUS Execute(MediaStatusReport *statusReport, MediaScalability *&scalability, MediaContext *mediaContext, bool bEnableVirtualEngine, uint8_t numVebox, uint64_t gpuCtxOnHybridCmd, uint32_t frameCnt); |
| 88 |
VPHAL_OUTPUT_PIPE_MODE GetOutputPipeMode() |
| 89 |
{ |
| 90 |
return m_outputPipeMode; |
| 91 |
} |
| 92 |
|
| 93 |
bool IsVeboxFeatureInuse() |
| 94 |
{ |
| 95 |
return m_veboxFeatureInuse; |
| 96 |
} |
| 97 |
|
| 98 |
uint32_t PacketNum() |
| 99 |
{ |
| 100 |
return m_Pipe.size(); |
| 101 |
} |
| 102 |
|
| 103 |
VpCmdPacket *GetPacket(uint32_t idx) |
| 104 |
{ |
| 105 |
return idx < m_Pipe.size() ? m_Pipe[idx] : nullptr; |
| 106 |
} |
| 107 |
|
| 108 |
static MOS_STATUS SwitchContext(PacketType type, MediaScalability *&scalability, MediaContext *mediaContext, bool bEnableVirtualEngine, uint8_t numVebox, uint64_t gpuCtxOnHybridCmd = 0); |
| 109 |
|
| 110 |
private: |
| 111 |
VpCmdPacket *CreatePacket(EngineType type); |
| 112 |
MOS_STATUS SetOutputPipeMode(EngineType engineType); |
| 113 |
|
| 114 |
PacketFactory &m_PacketFactory; |
| 115 |
std::vector<VpCmdPacket *> m_Pipe; |
| 116 |
VPHAL_OUTPUT_PIPE_MODE m_outputPipeMode = VPHAL_OUTPUT_PIPE_MODE_INVALID; |
| 117 |
bool m_veboxFeatureInuse = false; |
| 118 |
|
| 119 |
MEDIA_CLASS_DEFINE_END(vp__PacketPipe) |
| 120 |
}; |
| 121 |
|
| 122 |
class PacketPipeFactory |
| 123 |
{ |
| 124 |
public: |
| 125 |
PacketPipeFactory(PacketFactory &pPacketFactory); |
| 126 |
virtual ~PacketPipeFactory(); |
| 127 |
PacketPipe *CreatePacketPipe(); |
| 128 |
void ReturnPacketPipe(PacketPipe *&pPipe); |
| 129 |
|
| 130 |
private: |
| 131 |
PacketFactory &m_pPacketFactory; |
| 132 |
std::vector<PacketPipe *> m_Pool; |
| 133 |
|
| 134 |
MEDIA_CLASS_DEFINE_END(vp__PacketPipeFactory) |
| 135 |
}; |
| 136 |
|
| 137 |
} |
| 138 |
#endif // !__VP_PACKET_PIPE_H__ |