Debian Codegraph @

media_softlet/agnostic/common/vp/hal/feature_manager/vp_graphset.h

raw
1 /* Copyright (c) 2025, Intel Corporation
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included
11 * in all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19 * OTHER DEALINGS IN THE SOFTWARE.
20 */
21 //!
22 //! \file vp_graphset.h
23 //! \brief The header file of the base class of graph set
24 //! \details The graph set will include graph generation from binary.
25 //! It's responsible for setting up HW states and generating the SFC
26 //! commands.
27 //!
28 #ifndef __VP_GRAPH_SET_H__
29 #define __VP_GRAPH_SET_H__
30
31 #include "vp_pipeline_common.h"
32 #include "vp_allocator.h"
33 #include "mos_hybrid_cmd_manager.h"
34 #include "levelzero_npu_interface.h"
35
36 namespace vp
37 {
38 using VpGraphIDList = std::vector<VP_GRAPH_ID>;
39 struct GRAPH_BIN
40 {
41 uint8_t *blob = nullptr;
42 uint32_t size = 0;
43 };
44 using GRAPH_POOL = std::map<VP_GRAPH_ID, GRAPH_BIN>;
45
46 class VpGraphSet
47 {
48 public:
49 VpGraphSet(PVP_MHWINTERFACE hwInterface, PVpAllocator allocator);
50 virtual ~VpGraphSet()
51 {
52 Clean();
53 };
54
55 virtual MOS_STATUS Clean();
56
57 virtual MOS_STATUS Destroy()
58 {
59 return MOS_STATUS_SUCCESS;
60 }
61
62 virtual MOS_STATUS GetGraphObject(
63 VP_GRAPH_ID graphId,
64 GraphHandle *&graphHandle);
65
66 protected:
67 #if (_DEBUG || _RELEASE_INTERNAL)
68 virtual MOS_STATUS LoadGraphForDebug() { return MOS_STATUS_SUCCESS; };
69 #endif
70
71 protected:
72 GRAPH_POOL *m_graphPool = nullptr;
73 PVP_MHWINTERFACE m_hwInterface = nullptr;
74 PMOS_INTERFACE m_osInterface = nullptr;
75 PVpAllocator m_allocator = nullptr;
76 std::map<VP_GRAPH_ID, GraphHandle> m_cachedGraphs = {};
77
78 MEDIA_CLASS_DEFINE_END(vp__VpGraphSet)
79 };
80
81 class InitGraphCmdPackage : public CmdPackage
82 {
83 public:
84 InitGraphCmdPackage(GRAPH_BIN &graphBin, L0NpuInterface *npuInterface, GraphHandle *graphHandle) : m_graphHandle(graphHandle), m_npuInterface(npuInterface), m_graphBin(graphBin) {};
85 virtual MOS_STATUS Submit();
86 virtual MOS_STATUS Wait() { return MOS_STATUS_SUCCESS; };
87 virtual std::unique_ptr<CmdPackage> Clone() const;
88 virtual bool Releaseable() override { return m_releaseable; };
89
90 private:
91 GraphHandle *m_graphHandle = nullptr;
92 L0NpuInterface *m_npuInterface = nullptr;
93 GRAPH_BIN m_graphBin = {};
94 bool m_releaseable = false;
95 };
96
97 } // namespace vp
98
99 #endif //__VP_GRAPH_SET_H__