xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/CLPlatformImpl.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 // CLPlatformImpl.h: Defines the abstract rx::CLPlatformImpl class.
7 
8 #ifndef LIBANGLE_RENDERER_CLPLATFORMIMPL_H_
9 #define LIBANGLE_RENDERER_CLPLATFORMIMPL_H_
10 
11 #include "libANGLE/renderer/CLContextImpl.h"
12 #include "libANGLE/renderer/CLDeviceImpl.h"
13 #include "libANGLE/renderer/CLExtensions.h"
14 
15 namespace rx
16 {
17 
18 class CLPlatformImpl : angle::NonCopyable
19 {
20   public:
21     using Ptr         = std::unique_ptr<CLPlatformImpl>;
22     using CreateFunc  = std::function<Ptr(const cl::Platform &)>;
23     using CreateFuncs = std::list<CreateFunc>;
24 
25     struct Info : public CLExtensions
26     {
27         Info();
28         ~Info();
29 
30         Info(const Info &)            = delete;
31         Info &operator=(const Info &) = delete;
32 
33         Info(Info &&);
34         Info &operator=(Info &&);
35 
isValidInfo36         bool isValid() const { return version != 0u; }
37 
38         std::string profile;
39         std::string name;
40         cl_ulong hostTimerRes = 0u;
41     };
42 
43     explicit CLPlatformImpl(const cl::Platform &platform);
44     virtual ~CLPlatformImpl();
45 
46     // For initialization only
47     virtual Info createInfo() const                         = 0;
48     virtual CLDeviceImpl::CreateDatas createDevices() const = 0;
49 
50     virtual angle::Result createContext(cl::Context &context,
51                                         const cl::DevicePtrs &devices,
52                                         bool userSync,
53                                         CLContextImpl::Ptr *contextOut) = 0;
54 
55     virtual angle::Result createContextFromType(cl::Context &context,
56                                                 cl::DeviceType deviceType,
57                                                 bool userSync,
58                                                 CLContextImpl::Ptr *contextOut) = 0;
59 
60     virtual angle::Result unloadCompiler() = 0;
61 
62   protected:
63     const cl::Platform &mPlatform;
64 };
65 
66 }  // namespace rx
67 
68 #endif  // LIBANGLE_RENDERER_CLPLATFORMIMPL_H_
69