A RAII wrapper around opencl context
| 27 | |
| 28 | // A RAII wrapper around opencl context |
| 29 | class CLContext { |
| 30 | public: |
| 31 | CLContext() {} |
| 32 | explicit CLContext(cl_context context); |
| 33 | |
| 34 | // Move only |
| 35 | CLContext(CLContext&& context); |
| 36 | CLContext& operator=(CLContext&& context); |
| 37 | CLContext(const CLContext&) = delete; |
| 38 | CLContext& operator=(const CLContext&) = delete; |
| 39 | |
| 40 | ~CLContext(); |
| 41 | |
| 42 | cl_context context() const { return context_; } |
| 43 | |
| 44 | bool IsFloatTexture2DSupported(int num_channels, DataType data_type, |
| 45 | cl_mem_flags flags = CL_MEM_READ_WRITE) const; |
| 46 | |
| 47 | private: |
| 48 | void Release(); |
| 49 | |
| 50 | cl_context context_ = nullptr; |
| 51 | }; |
| 52 | |
| 53 | Status CreateCLContext(const CLDevice& device, CLContext* result); |
| 54 | Status CreateCLGLContext(const CLDevice& device, |