• 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     cl_int setArg(cl_uint argIndex, size_t argSize, const void *argValue);
23 
24     cl_int getInfo(KernelInfo name, size_t valueSize, void *value, size_t *valueSizeRet) const;
25 
26     cl_int getWorkGroupInfo(cl_device_id device,
27                             KernelWorkGroupInfo name,
28                             size_t valueSize,
29                             void *value,
30                             size_t *valueSizeRet) const;
31 
32     cl_int getArgInfo(cl_uint argIndex,
33                       KernelArgInfo name,
34                       size_t valueSize,
35                       void *value,
36                       size_t *valueSizeRet) const;
37 
38   public:
39     ~Kernel() override;
40 
41     const Program &getProgram() const;
42     const rx::CLKernelImpl::Info &getInfo() const;
43 
44     template <typename T = rx::CLKernelImpl>
45     T &getImpl() const;
46 
47   private:
48     Kernel(Program &program, const char *name, cl_int &errorCode);
49     Kernel(Program &program, const rx::CLKernelImpl::CreateFunc &createFunc, cl_int &errorCode);
50 
51     const ProgramPtr mProgram;
52     const rx::CLKernelImpl::Ptr mImpl;
53     const rx::CLKernelImpl::Info mInfo;
54 
55     friend class Object;
56     friend class Program;
57 };
58 
getProgram()59 inline const Program &Kernel::getProgram() const
60 {
61     return *mProgram;
62 }
63 
getInfo()64 inline const rx::CLKernelImpl::Info &Kernel::getInfo() const
65 {
66     return mInfo;
67 }
68 
69 template <typename T>
getImpl()70 inline T &Kernel::getImpl() const
71 {
72     return static_cast<T &>(*mImpl);
73 }
74 
75 }  // namespace cl
76 
77 #endif  // LIBANGLE_CLKERNEL_H_
78