Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
| 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 "VkInstance.hpp" |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 16 | #include "VkDestroy.hpp" |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 17 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 18 | namespace vk { |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 19 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 20 | Instance::Instance(const VkInstanceCreateInfo *pCreateInfo, void *mem, VkPhysicalDevice physicalDevice) |
| 21 | : physicalDevice(physicalDevice) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 22 | { |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 23 | } |
| 24 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 25 | void Instance::destroy(const VkAllocationCallbacks *pAllocator) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 26 | { |
| 27 | vk::destroy(physicalDevice, pAllocator); |
| 28 | } |
| 29 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 30 | VkResult Instance::getPhysicalDevices(uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices) const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 31 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 32 | if(!pPhysicalDevices) |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 33 | { |
| 34 | *pPhysicalDeviceCount = 1; |
| 35 | return VK_SUCCESS; |
| 36 | } |
| 37 | |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 38 | if(*pPhysicalDeviceCount < 1) |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 39 | { |
| 40 | return VK_INCOMPLETE; |
| 41 | } |
| 42 | |
| 43 | pPhysicalDevices[0] = physicalDevice; |
| 44 | *pPhysicalDeviceCount = 1; |
| 45 | |
| 46 | return VK_SUCCESS; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 47 | } |
| 48 | |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 49 | VkResult Instance::getPhysicalDeviceGroups(uint32_t *pPhysicalDeviceGroupCount, |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 50 | VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties) const |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 51 | { |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 52 | if(!pPhysicalDeviceGroupProperties) |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 53 | { |
| 54 | *pPhysicalDeviceGroupCount = 1; |
| 55 | return VK_SUCCESS; |
| 56 | } |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 57 | |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 58 | if(*pPhysicalDeviceGroupCount < 1) |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 59 | { |
| 60 | return VK_INCOMPLETE; |
| 61 | } |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 62 | |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 63 | pPhysicalDeviceGroupProperties[0].physicalDeviceCount = 1; |
| 64 | pPhysicalDeviceGroupProperties[0].physicalDevices[0] = physicalDevice; |
| 65 | pPhysicalDeviceGroupProperties[0].subsetAllocation = VK_FALSE; |
| 66 | *pPhysicalDeviceGroupCount = 1; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 67 | |
Chris Forbes | df84b94 | 2019-06-12 11:28:09 -0700 | [diff] [blame] | 68 | return VK_SUCCESS; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 69 | } |
| 70 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 71 | } // namespace vk |