dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 1 | // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "gpu/vulkan/vulkan_implementation.h" |
| 6 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 7 | #include "base/bind.h" |
| 8 | #include "gpu/vulkan/vulkan_device_queue.h" |
Vikas Soni | cd499af | 2019-01-29 19:00:11 | [diff] [blame] | 9 | #include "gpu/vulkan/vulkan_function_pointers.h" |
Sergey Ulanov | af257db | 2019-01-28 20:13:52 | [diff] [blame] | 10 | #include "gpu/vulkan/vulkan_instance.h" |
dyen | 5bd6d4f | 2016-03-31 15:25:45 | [diff] [blame] | 11 | |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 12 | namespace gpu { |
| 13 | |
Emircan Uysaler | d41c9bf | 2019-08-08 20:38:33 | [diff] [blame^] | 14 | VulkanImplementation::VulkanImplementation(bool use_swiftshader, |
| 15 | bool allow_protected_memory, |
| 16 | bool enforce_protected_memory) |
| 17 | : use_swiftshader_(use_swiftshader), |
| 18 | allow_protected_memory_(allow_protected_memory), |
| 19 | enforce_protected_memory_(enforce_protected_memory) {} |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 20 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 21 | VulkanImplementation::~VulkanImplementation() {} |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 22 | |
Sergey Ulanov | 520fe0e | 2019-04-02 06:02:55 | [diff] [blame] | 23 | std::unique_ptr<VulkanDeviceQueue> CreateVulkanDeviceQueue( |
| 24 | VulkanImplementation* vulkan_implementation, |
| 25 | uint32_t option) { |
| 26 | auto device_queue = std::make_unique<VulkanDeviceQueue>( |
Emircan Uysaler | d41c9bf | 2019-08-08 20:38:33 | [diff] [blame^] | 27 | vulkan_implementation->GetVulkanInstance()->vk_instance(), |
| 28 | vulkan_implementation->enforce_protected_memory()); |
Sergey Ulanov | 520fe0e | 2019-04-02 06:02:55 | [diff] [blame] | 29 | auto callback = base::BindRepeating( |
| 30 | &VulkanImplementation::GetPhysicalDevicePresentationSupport, |
| 31 | base::Unretained(vulkan_implementation)); |
| 32 | std::vector<const char*> required_extensions = |
| 33 | vulkan_implementation->GetRequiredDeviceExtensions(); |
Sergey Ulanov | e82b100 | 2019-07-22 22:23:39 | [diff] [blame] | 34 | if (!device_queue->Initialize( |
| 35 | option, vulkan_implementation->GetVulkanInstance()->api_version(), |
Emircan Uysaler | d41c9bf | 2019-08-08 20:38:33 | [diff] [blame^] | 36 | std::move(required_extensions), |
| 37 | vulkan_implementation->allow_protected_memory(), callback)) { |
Sergey Ulanov | 520fe0e | 2019-04-02 06:02:55 | [diff] [blame] | 38 | device_queue->Destroy(); |
| 39 | return nullptr; |
| 40 | } |
| 41 | |
| 42 | return device_queue; |
| 43 | } |
| 44 | |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 45 | } // namespace gpu |