blob: 4f65a8a34532c87eedaeb3a1840b5e4a82e96960 [file] [log] [blame]
dan sinclair70d430c2018-09-28 16:12:38 -04001// Copyright 2018 The Amber 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#include "src/engine.h"
16
17#include "src/make_unique.h"
18
19#if AMBER_ENGINE_VULKAN
20#pragma clang diagnostic push
21#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
22#include "src/vulkan/engine_vulkan.h"
23#pragma clang diagnostic pop
24#endif // AMBER_ENGINE_VULKAN
25
David Netoef2bc0a2018-11-12 13:52:31 +000026#if AMBER_ENGINE_DAWN
27#include "src/dawn/engine_dawn.h"
28#endif // AMBER_ENGINE_DAWN
29
dan sinclair70d430c2018-09-28 16:12:38 -040030namespace amber {
31
32// static
33std::unique_ptr<Engine> Engine::Create(EngineType type) {
34 std::unique_ptr<Engine> engine;
35 switch (type) {
dan sinclair39af1032019-01-15 10:42:30 -050036 case kEngineTypeVulkan:
dan sinclair70d430c2018-09-28 16:12:38 -040037#if AMBER_ENGINE_VULKAN
38 engine = MakeUnique<vulkan::EngineVulkan>();
39#endif // AMBER_ENGINE_VULKAN
40 break;
dan sinclair39af1032019-01-15 10:42:30 -050041 case kEngineTypeDawn:
David Netoef2bc0a2018-11-12 13:52:31 +000042#if AMBER_ENGINE_DAWN
43 engine = MakeUnique<dawn::EngineDawn>();
44#endif // AMBER_ENGINE_DAWN
45 break;
dan sinclair70d430c2018-09-28 16:12:38 -040046 }
47 return engine;
48}
49
50Engine::Engine() = default;
51
52Engine::~Engine() = default;
53
54} // namespace amber