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 cl::DevicePtrs getDevices(cl_int &errorCode) const = 0; 29 30 virtual CLCommandQueueImpl::Ptr createCommandQueue(const cl::CommandQueue &commandQueue, 31 cl_int &errorCode) = 0; 32 33 virtual CLMemoryImpl::Ptr createBuffer(const cl::Buffer &buffer, 34 size_t size, 35 void *hostPtr, 36 cl_int &errorCode) = 0; 37 38 virtual CLMemoryImpl::Ptr createImage(const cl::Image &image, 39 cl::MemFlags flags, 40 const cl_image_format &format, 41 const cl::ImageDescriptor &desc, 42 void *hostPtr, 43 cl_int &errorCode) = 0; 44 45 virtual cl_int getSupportedImageFormats(cl::MemFlags flags, 46 cl::MemObjectType imageType, 47 cl_uint numEntries, 48 cl_image_format *imageFormats, 49 cl_uint *numImageFormats) = 0; 50 51 virtual CLSamplerImpl::Ptr createSampler(const cl::Sampler &sampler, cl_int &errorCode) = 0; 52 53 virtual CLProgramImpl::Ptr createProgramWithSource(const cl::Program &program, 54 const std::string &source, 55 cl_int &errorCode) = 0; 56 57 virtual CLProgramImpl::Ptr createProgramWithIL(const cl::Program &program, 58 const void *il, 59 size_t length, 60 cl_int &errorCode) = 0; 61 62 virtual CLProgramImpl::Ptr createProgramWithBinary(const cl::Program &program, 63 const size_t *lengths, 64 const unsigned char **binaries, 65 cl_int *binaryStatus, 66 cl_int &errorCode) = 0; 67 68 virtual CLProgramImpl::Ptr createProgramWithBuiltInKernels(const cl::Program &program, 69 const char *kernel_names, 70 cl_int &errorCode) = 0; 71 72 virtual CLProgramImpl::Ptr linkProgram(const cl::Program &program, 73 const cl::DevicePtrs &devices, 74 const char *options, 75 const cl::ProgramPtrs &inputPrograms, 76 cl::Program *notify, 77 cl_int &errorCode) = 0; 78 79 virtual CLEventImpl::Ptr createUserEvent(const cl::Event &event, cl_int &errorCode) = 0; 80 81 virtual cl_int 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