xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/CLContextImpl.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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                                       void *hostPtr,
39                                       CLMemoryImpl::Ptr *imageOut) = 0;
40 
41     virtual angle::Result getSupportedImageFormats(cl::MemFlags flags,
42                                                    cl::MemObjectType imageType,
43                                                    cl_uint numEntries,
44                                                    cl_image_format *imageFormats,
45                                                    cl_uint *numImageFormats) = 0;
46 
47     virtual angle::Result createSampler(const cl::Sampler &sampler,
48                                         CLSamplerImpl::Ptr *samplerOut) = 0;
49 
50     virtual angle::Result createProgramWithSource(const cl::Program &program,
51                                                   const std::string &source,
52                                                   CLProgramImpl::Ptr *programOut) = 0;
53 
54     virtual angle::Result createProgramWithIL(const cl::Program &program,
55                                               const void *il,
56                                               size_t length,
57                                               CLProgramImpl::Ptr *programOut) = 0;
58 
59     virtual angle::Result createProgramWithBinary(const cl::Program &program,
60                                                   const size_t *lengths,
61                                                   const unsigned char **binaries,
62                                                   cl_int *binaryStatus,
63                                                   CLProgramImpl::Ptr *programOut) = 0;
64 
65     virtual angle::Result createProgramWithBuiltInKernels(const cl::Program &program,
66                                                           const char *kernel_names,
67                                                           CLProgramImpl::Ptr *programOut) = 0;
68 
69     virtual angle::Result linkProgram(const cl::Program &program,
70                                       const cl::DevicePtrs &devices,
71                                       const char *options,
72                                       const cl::ProgramPtrs &inputPrograms,
73                                       cl::Program *notify,
74                                       CLProgramImpl::Ptr *programOut) = 0;
75 
76     virtual angle::Result createUserEvent(const cl::Event &event, CLEventImpl::Ptr *eventOut) = 0;
77 
78     virtual angle::Result waitForEvents(const cl::EventPtrs &events) = 0;
79 
80   protected:
81     const cl::Context &mContext;
82 };
83 
84 }  // namespace rx
85 
86 #endif  // LIBANGLE_RENDERER_CLCONTEXTIMPL_H_
87