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_CMD_PACKET_H__ 23 #define __VP_CMD_PACKET_H__ 24 25 #include "media_cmd_packet.h" 26 #include "mhw_sfc.h" 27 #include "mhw_vebox_itf.h" 28 #include "vp_pipeline_common.h" 29 #include "vp_allocator.h" 30 #include "vp_packet_shared_context.h" 31 #include "media_scalability.h" 32 33 namespace vp { 34 35 enum _PacketType 36 { 37 VP_PIPELINE_PACKET_UNINITIALIZED = 0, 38 VP_PIPELINE_PACKET_VEBOX, 39 VP_PIPELINE_PACKET_RENDER, 40 VP_PIPELINE_PACKET_COMPUTE 41 }; 42 using PacketType = _PacketType; 43 44 class VpCmdPacket : virtual public CmdPacket 45 { 46 public: 47 VpCmdPacket(MediaTask *task, PVP_MHWINTERFACE hwInterface, PVpAllocator &allocator, VPMediaMemComp *mmc, PacketType packetId); ~VpCmdPacket()48 virtual ~VpCmdPacket() {}; 49 SetPacketSharedContext(VP_PACKET_SHARED_CONTEXT * context)50 void SetPacketSharedContext(VP_PACKET_SHARED_CONTEXT *context) 51 { 52 m_packetSharedContext = context; 53 } 54 55 // Need to remove vphal surface dependence from VpCmdPacket later. 56 virtual MOS_STATUS PacketInit( 57 VP_SURFACE *inputSurface, 58 VP_SURFACE *outputSurface, 59 VP_SURFACE *previousSurface, 60 VP_SURFACE_SETTING &surfSetting, 61 VP_EXECUTE_CAPS packetCaps) = 0; 62 PacketInitForReuse(VP_SURFACE * inputSurface,VP_SURFACE * outputSurface,VP_SURFACE * previousSurface,VP_SURFACE_SETTING & surfSetting,VP_EXECUTE_CAPS packetCaps)63 virtual MOS_STATUS PacketInitForReuse( 64 VP_SURFACE *inputSurface, 65 VP_SURFACE *outputSurface, 66 VP_SURFACE *previousSurface, 67 VP_SURFACE_SETTING &surfSetting, 68 VP_EXECUTE_CAPS packetCaps) 69 { 70 VP_FUNC_CALL(); 71 m_packetResourcesPrepared = false; 72 m_PacketCaps = packetCaps; 73 VP_RENDER_CHK_STATUS_RETURN(SetUpdatedExecuteResource(inputSurface, outputSurface, previousSurface, surfSetting)); 74 75 // need to update for DNDI case. 76 m_DNDIFirstFrame = (!m_PacketCaps.bRefValid && (m_PacketCaps.bDN || m_PacketCaps.bDI)); 77 return MOS_STATUS_SUCCESS; 78 } 79 Prepare()80 virtual MOS_STATUS Prepare() 81 { 82 return MOS_STATUS_SUCCESS; 83 }; 84 PrepareState()85 virtual MOS_STATUS PrepareState() 86 { 87 return MOS_STATUS_SUCCESS; 88 }; 89 DumpOutput()90 virtual MOS_STATUS DumpOutput() 91 { 92 return MOS_STATUS_SUCCESS; 93 }; 94 SetUpdatedExecuteResource(VP_SURFACE * inputSurface,VP_SURFACE * outputSurface,VP_SURFACE * previousSurface,VP_SURFACE_SETTING & surfSetting)95 virtual MOS_STATUS SetUpdatedExecuteResource( 96 VP_SURFACE *inputSurface, 97 VP_SURFACE *outputSurface, 98 VP_SURFACE *previousSurface, 99 VP_SURFACE_SETTING &surfSetting) 100 { 101 VP_RENDER_ASSERTMESSAGE("Should not come here!"); 102 return MOS_STATUS_SUCCESS; 103 } 104 GetPacketId()105 PacketType GetPacketId() 106 { 107 return m_PacketId; 108 } 109 SetMediaScalability(MediaScalability * scalability)110 void SetMediaScalability(MediaScalability *scalability) 111 { 112 m_scalability = scalability; 113 } 114 GetMediaScalability()115 MediaScalability *&GetMediaScalability() 116 { 117 return m_scalability; 118 } 119 GetSurfSetting()120 VP_SURFACE_SETTING &GetSurfSetting() 121 { 122 return m_surfSetting; 123 } 124 ExtraProcessing()125 virtual bool ExtraProcessing() 126 { 127 return false; 128 } 129 UpdateFeature(SwFilterPipe * swFilter)130 MOS_STATUS UpdateFeature(SwFilterPipe *swFilter) 131 { 132 return MOS_STATUS_SUCCESS; 133 } 134 GetExecuteCaps()135 VP_EXECUTE_CAPS GetExecuteCaps() 136 { 137 return m_PacketCaps; 138 } 139 140 protected: 141 virtual MOS_STATUS VpCmdPacketInit(); IsOutputPipeVebox()142 bool IsOutputPipeVebox() 143 { 144 return m_PacketCaps.bVebox && !m_PacketCaps.bSFC && !m_PacketCaps.bRender; 145 } 146 147 virtual MOS_STATUS SetMediaFrameTracking(RENDERHAL_GENERIC_PROLOG_PARAMS &genericPrologParams); 148 149 public: 150 // HW intface to access MHW 151 PVP_MHWINTERFACE m_hwInterface = nullptr; 152 VP_EXECUTE_CAPS m_PacketCaps = {}; 153 PVpAllocator &m_allocator; 154 VPMediaMemComp *m_mmc = nullptr; 155 uint32_t m_DNDIFirstFrame = 0; 156 uint32_t m_veboxHeapCurState = 0; 157 158 protected: 159 PacketType m_PacketId = VP_PIPELINE_PACKET_UNINITIALIZED; 160 VP_PACKET_SHARED_CONTEXT *m_packetSharedContext = nullptr; 161 VP_SURFACE_SETTING m_surfSetting; 162 bool m_packetResourcesPrepared = false; 163 VpFeatureReport *m_report = nullptr; 164 165 private: 166 MediaScalability * m_scalability = nullptr; 167 168 MEDIA_CLASS_DEFINE_END(vp__VpCmdPacket) 169 }; 170 } 171 #endif // !__VP_CMD_PACKET_H__ 172