Debian Codegraph @

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

raw
1 /* Copyright (c) 2020-2022, 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_render_kernelset.h
23 //! \brief The header file of the base class of kernel set
24 //! \details The kernel set will include kernel generation from binary.
25 //! It's responsible for setting up HW states and generating the SFC
26 //! commands.
27 //!
28 #ifndef __VP_KERNEL_SET_H__
29 #define __VP_KERNEL_SET_H__
30
31 #include "vp_platform_interface.h"
32 #include "vp_pipeline_common.h"
33 #include "vp_render_kernel_obj.h"
34 #include "vpkrnheader.h"
35 #include <map>
36
37 namespace vp {
38
39 // KernelIndex is the index in KERNEL_PARAMS_LIST
40 using KERNEL_OBJECTS = std::map<KernelIndex, VpRenderKernelObj*>;
41 using KERNEL_PARAMS_LIST = std::vector<KERNEL_PARAMS>;
42
43 class VpKernelSet
44 {
45 public:
46 VpKernelSet(PVP_MHWINTERFACE hwInterface, PVpAllocator allocator);
47 virtual ~VpKernelSet()
48 {
49 for (auto &it : m_cachedKernels)
50 {
51 MOS_Delete(it.second);
52 }
53 };
54
55 virtual MOS_STATUS Clean()
56 {
57 return MOS_STATUS_SUCCESS;
58 }
59
60 virtual MOS_STATUS Destroy()
61 {
62 return MOS_STATUS_SUCCESS;
63 }
64
65 virtual MOS_STATUS CreateSingleKernelObject(
66 VpRenderKernelObj *&kernel,
67 VpKernelID kernelId,
68 KernelIndex kernelIndex,
69 std::string kernelName);
70
71 virtual MOS_STATUS CreateKernelObjects(
72 KERNEL_PARAMS_LIST& kernelParams,
73 VP_SURFACE_GROUP& surfacesGroup,
74 KERNEL_SAMPLER_STATE_GROUP& samplerStateGroup,
75 KERNEL_CONFIGS& kernelConfigs,
76 KERNEL_OBJECTS& kernelObjs,
77 VP_RENDER_CACHE_CNTL& surfMemCacheCtl,
78 VP_PACKET_SHARED_CONTEXT* sharedContext);
79
80 virtual MOS_STATUS DestroyKernelObjects(KERNEL_OBJECTS& kernelObjs)
81 {
82 while (!kernelObjs.empty())
83 {
84 auto it = kernelObjs.begin();
85 if (m_cachedKernels.size() == 0 || m_cachedKernels.end() == m_cachedKernels.find(it->second->GetKernelId()))
86 {
87 // Only destroy the kernels not exists in m_cachedKernels.
88 MOS_Delete(it->second);
89 }
90 kernelObjs.erase(it);
91 }
92
93 return MOS_STATUS_SUCCESS;
94 }
95
96 virtual MOS_STATUS GetKernelInfo(std::string kernalName, uint32_t kuid, uint32_t &size, void *&kernel);
97
98 virtual MOS_STATUS GetVpRenderKernel(std::string kernalName, VpRenderKernel &vpKernel);
99 protected:
100
101 MOS_STATUS FindAndInitKernelObj(VpRenderKernelObj* kernelObj);
102
103 protected:
104 KERNEL_POOL* m_pKernelPool = nullptr;
105 PVP_MHWINTERFACE m_hwInterface = nullptr;
106 PVpAllocator m_allocator = nullptr;
107 std::map<VpKernelID, VpRenderKernelObj *> m_cachedKernels;
108
109 MEDIA_CLASS_DEFINE_END(vp__VpKernelSet)
110 };
111 }
112
113 #endif //__VP_KERNEL_SET_H__