• 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 // CLContextImpl.h: Defines the abstract rx::CLContextImpl class.
7 
8 #ifndef LIBANGLE_RENDERER_CLCONTEXTIMPL_H_
9 #define LIBANGLE_RENDERER_CLCONTEXTIMPL_H_
10 
11 #include "libANGLE/renderer/CLCommandQueueImpl.h"
12 #include "libANGLE/renderer/CLEventImpl.h"
13 #include "libANGLE/renderer/CLMemoryImpl.h"
14 #include "libANGLE/renderer/CLProgramImpl.h"
15 #include "libANGLE/renderer/CLSamplerImpl.h"
16 
17 namespace rx
18 {
19 
20 class CLContextImpl : angle::NonCopyable
21 {
22   public:
23     using Ptr = std::unique_ptr<CLContextImpl>;
24 
25     CLContextImpl(const cl::Context &context);
26     virtual ~CLContextImpl();
27 
28     virtual angle::Result getDevices(cl::DevicePtrs *devicePtrsOut) const = 0;
29 
30     virtual angle::Result createCommandQueue(const cl::CommandQueue &commandQueue,
31                                              CLCommandQueueImpl::Ptr *commandQueueOut) = 0;
32 
33     virtual angle::Result createBuffer(const cl::Buffer &buffer,
34                                        void *hostPtr,
35                                        CLMemoryImpl::Ptr *bufferOut) = 0;
36 
37     virtual angle::Result createImage(const cl::Image &image,
38                                       cl::MemFlags flags,
39                                       const cl_image_format &format,
40                                       const cl::ImageDescriptor &desc,
41                                       void *hostPtr,
42                                       CLMemoryImpl::Ptr *imageOut) = 0;
43 
44     virtual angle::Result getSupportedImageFormats(cl::MemFlags flags,
45                                                    cl::MemObjectType imageType,
46                                                    cl_uint numEntries,
47                                                    cl_image_format *imageFormats,
48                                                    cl_uint *numImageFormats) = 0;
49 
50     virtual angle::Result createSampler(const cl::Sampler &sampler,
51                                         CLSamplerImpl::Ptr *samplerOut) = 0;
52 
53     virtual angle::Result createProgramWithSource(const cl::Program &program,
54                                                   const std::string &source,
55                                                   CLProgramImpl::Ptr *programOut) = 0;
56 
57     virtual angle::Result createProgramWithIL(const cl::Program &program,
58                                               const void *il,
59                                               size_t length,
60                                               CLProgramImpl::Ptr *programOut) = 0;
61 
62     virtual angle::Result createProgramWithBinary(const cl::Program &program,
63                                                   const size_t *lengths,
64                                                   const unsigned char **binaries,
65                                                   cl_int *binaryStatus,
66                                                   CLProgramImpl::Ptr *programOut) = 0;
67 
68     virtual angle::Result createProgramWithBuiltInKernels(const cl::Program &program,
69                                                           const char *kernel_names,
70                                                           CLProgramImpl::Ptr *programOut) = 0;
71 
72     virtual angle::Result linkProgram(const cl::Program &program,
73                                       const cl::DevicePtrs &devices,
74                                       const char *options,
75                                       const cl::ProgramPtrs &inputPrograms,
76                                       cl::Program *notify,
77                                       CLProgramImpl::Ptr *programOut) = 0;
78 
79     virtual angle::Result createUserEvent(const cl::Event &event, CLEventImpl::Ptr *eventOut) = 0;
80 
81     virtual angle::Result waitForEvents(const cl::EventPtrs &events) = 0;
82 
83   protected:
84     const cl::Context &mContext;
85 };
86 
87 }  // namespace rx
88 
89 #endif  // LIBANGLE_RENDERER_CLCONTEXTIMPL_H_
90