• 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 // CLKernel.h: Defines the cl::Kernel class, which is a function declared in an OpenCL program.
7 
8 #ifndef LIBANGLE_CLKERNEL_H_
9 #define LIBANGLE_CLKERNEL_H_
10 
11 #include "libANGLE/CLObject.h"
12 #include "libANGLE/renderer/CLKernelImpl.h"
13 
14 namespace cl
15 {
16 
17 class Kernel final : public _cl_kernel, public Object
18 {
19   public:
20     // Front end entry functions, only called from OpenCL entry points
21 
22     angle::Result setArg(cl_uint argIndex, size_t argSize, const void *argValue);
23 
24     angle::Result getInfo(KernelInfo name,
25                           size_t valueSize,
26                           void *value,
27                           size_t *valueSizeRet) const;
28 
29     angle::Result getWorkGroupInfo(cl_device_id device,
30                                    KernelWorkGroupInfo name,
31                                    size_t valueSize,
32                                    void *value,
33                                    size_t *valueSizeRet) const;
34 
35     angle::Result getArgInfo(cl_uint argIndex,
36                              KernelArgInfo name,
37                              size_t valueSize,
38                              void *value,
39                              size_t *valueSizeRet) const;
40 
41   public:
42     ~Kernel() override;
43 
44     const Program &getProgram() const;
45     const rx::CLKernelImpl::Info &getInfo() const;
46 
47     template <typename T = rx::CLKernelImpl>
48     T &getImpl() const;
49 
50   private:
51     Kernel(Program &program, const char *name);
52     Kernel(Program &program, const rx::CLKernelImpl::CreateFunc &createFunc);
53 
54     const ProgramPtr mProgram;
55     rx::CLKernelImpl::Ptr mImpl;
56     rx::CLKernelImpl::Info mInfo;
57 
58     friend class Object;
59     friend class Program;
60 };
61 
getProgram()62 inline const Program &Kernel::getProgram() const
63 {
64     return *mProgram;
65 }
66 
getInfo()67 inline const rx::CLKernelImpl::Info &Kernel::getInfo() const
68 {
69     return mInfo;
70 }
71 
72 template <typename T>
getImpl()73 inline T &Kernel::getImpl() const
74 {
75     return static_cast<T &>(*mImpl);
76 }
77 
78 }  // namespace cl
79 
80 #endif  // LIBANGLE_CLKERNEL_H_
81