• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 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_D3D12_BACKENDD3D12_H_
16 #define DAWNNATIVE_D3D12_BACKENDD3D12_H_
17 
18 #include "dawn_native/BackendConnection.h"
19 
20 #include "dawn_native/d3d12/d3d12_platform.h"
21 
22 namespace dawn_native { namespace d3d12 {
23 
24     class PlatformFunctions;
25 
26     class Backend : public BackendConnection {
27       public:
28         Backend(InstanceBase* instance);
29 
30         MaybeError Initialize();
31 
32         ComPtr<IDXGIFactory4> GetFactory() const;
33 
34         MaybeError EnsureDxcLibrary();
35         MaybeError EnsureDxcCompiler();
36         MaybeError EnsureDxcValidator();
37         ComPtr<IDxcLibrary> GetDxcLibrary() const;
38         ComPtr<IDxcCompiler> GetDxcCompiler() const;
39         ComPtr<IDxcValidator> GetDxcValidator() const;
40 
41         const PlatformFunctions* GetFunctions() const;
42 
43         std::vector<std::unique_ptr<AdapterBase>> DiscoverDefaultAdapters() override;
44         ResultOrError<std::vector<std::unique_ptr<AdapterBase>>> DiscoverAdapters(
45             const AdapterDiscoveryOptionsBase* optionsBase) override;
46 
47       private:
48         // Keep mFunctions as the first member so that in the destructor it is freed last. Otherwise
49         // the D3D12 DLLs are unloaded before we are done using them.
50         std::unique_ptr<PlatformFunctions> mFunctions;
51         ComPtr<IDXGIFactory4> mFactory;
52         ComPtr<IDxcLibrary> mDxcLibrary;
53         ComPtr<IDxcCompiler> mDxcCompiler;
54         ComPtr<IDxcValidator> mDxcValidator;
55     };
56 
57 }}  // namespace dawn_native::d3d12
58 
59 #endif  // DAWNNATIVE_D3D12_BACKENDD3D12_H_
60