• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DAWNNATIVE_ADAPTER_H_
16 #define DAWNNATIVE_ADAPTER_H_
17 
18 #include "dawn_native/DawnNative.h"
19 
20 #include "dawn_native/Error.h"
21 
22 namespace dawn_native {
23 
24     class DeviceBase;
25 
26     class AdapterBase {
27       public:
28         AdapterBase(InstanceBase* instance, BackendType backend);
29         virtual ~AdapterBase() = default;
30 
31         BackendType GetBackendType() const;
32         DeviceType GetDeviceType() const;
33         const PCIInfo& GetPCIInfo() const;
34         InstanceBase* GetInstance() const;
35 
36         DeviceBase* CreateDevice(const DeviceDescriptor* descriptor = nullptr);
37 
38       protected:
39         PCIInfo mPCIInfo = {};
40         DeviceType mDeviceType = DeviceType::Unknown;
41 
42       private:
43         virtual ResultOrError<DeviceBase*> CreateDeviceImpl(const DeviceDescriptor* descriptor) = 0;
44 
45         MaybeError CreateDeviceInternal(DeviceBase** result, const DeviceDescriptor* descriptor);
46 
47         InstanceBase* mInstance = nullptr;
48         BackendType mBackend;
49     };
50 
51 }  // namespace dawn_native
52 
53 #endif  // DAWNNATIVE_ADAPTER_H_
54