• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // CLKernelImpl.h: Defines the abstract rx::CLKernelImpl class.
7 
8 #ifndef LIBANGLE_RENDERER_CLKERNELIMPL_H_
9 #define LIBANGLE_RENDERER_CLKERNELIMPL_H_
10 
11 #include "libANGLE/renderer/CLtypes.h"
12 
13 namespace rx
14 {
15 
16 class CLKernelImpl : angle::NonCopyable
17 {
18   public:
19     using Ptr         = std::unique_ptr<CLKernelImpl>;
20     using CreateFunc  = std::function<Ptr(const cl::Kernel &)>;
21     using CreateFuncs = std::list<CreateFunc>;
22 
23     struct WorkGroupInfo
24     {
25         WorkGroupInfo();
26         ~WorkGroupInfo();
27 
28         WorkGroupInfo(const WorkGroupInfo &) = delete;
29         WorkGroupInfo &operator=(const WorkGroupInfo &) = delete;
30 
31         WorkGroupInfo(WorkGroupInfo &&);
32         WorkGroupInfo &operator=(WorkGroupInfo &&);
33 
34         std::array<size_t, 3u> globalWorkSize       = {};
35         size_t workGroupSize                        = 0u;
36         std::array<size_t, 3u> compileWorkGroupSize = {};
37         cl_ulong localMemSize                       = 0u;
38         size_t prefWorkGroupSizeMultiple            = 0u;
39         cl_ulong privateMemSize                     = 0u;
40     };
41 
42     struct ArgInfo
43     {
44         ArgInfo();
45         ~ArgInfo();
46 
47         ArgInfo(const ArgInfo &) = delete;
48         ArgInfo &operator=(const ArgInfo &) = delete;
49 
50         ArgInfo(ArgInfo &&);
51         ArgInfo &operator=(ArgInfo &&);
52 
isAvailableArgInfo53         bool isAvailable() const { return !name.empty(); }
54 
55         cl_kernel_arg_address_qualifier addressQualifier = 0u;
56         cl_kernel_arg_access_qualifier accessQualifier   = 0u;
57         std::string typeName;
58         cl_kernel_arg_type_qualifier typeQualifier = 0u;
59         std::string name;
60     };
61 
62     struct Info
63     {
64         Info();
65         ~Info();
66 
67         Info(const Info &) = delete;
68         Info &operator=(const Info &) = delete;
69 
70         Info(Info &&);
71         Info &operator=(Info &&);
72 
isValidInfo73         bool isValid() const { return !functionName.empty(); }
74 
75         std::string functionName;
76         cl_uint numArgs = 0u;
77         std::string attributes;
78 
79         std::vector<WorkGroupInfo> workGroups;
80         std::vector<ArgInfo> args;
81     };
82 
83     CLKernelImpl(const cl::Kernel &kernel);
84     virtual ~CLKernelImpl();
85 
86     virtual cl_int setArg(cl_uint argIndex, size_t argSize, const void *argValue) = 0;
87 
88     virtual Info createInfo(cl_int &errorCode) const = 0;
89 
90   protected:
91     const cl::Kernel &mKernel;
92 };
93 
94 }  // namespace rx
95 
96 #endif  // LIBANGLE_RENDERER_CLKERNELIMPL_H_
97