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" |
16 | #include "VkDestroy.h" |
17 | |
18 | namespace vk |
19 | { |
20 | |
21 | Instance::Instance(const VkInstanceCreateInfo* pCreateInfo, void* mem, VkPhysicalDevice physicalDevice) |
22 | : physicalDevice(physicalDevice) |
23 | { |
24 | } |
25 | |
26 | void Instance::destroy(const VkAllocationCallbacks* pAllocator) |
27 | { |
28 | vk::destroy(physicalDevice, pAllocator); |
29 | } |
30 | |
31 | VkResult Instance::getPhysicalDevices(uint32_t *pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) const |
32 | { |
33 | if (!pPhysicalDevices) |
34 | { |
35 | *pPhysicalDeviceCount = 1; |
36 | return VK_SUCCESS; |
37 | } |
38 | |
39 | if (*pPhysicalDeviceCount < 1) |
40 | { |
41 | return VK_INCOMPLETE; |
42 | } |
43 | |
44 | pPhysicalDevices[0] = physicalDevice; |
45 | *pPhysicalDeviceCount = 1; |
46 | |
47 | return VK_SUCCESS; |
48 | } |
49 | |
50 | VkResult Instance::getPhysicalDeviceGroups(uint32_t *pPhysicalDeviceGroupCount, |
51 | VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) const |
52 | { |
53 | if (!pPhysicalDeviceGroupProperties) |
54 | { |
55 | *pPhysicalDeviceGroupCount = 1; |
56 | return VK_SUCCESS; |
57 | } |
58 | |
59 | if (*pPhysicalDeviceGroupCount < 1) |
60 | { |
61 | return VK_INCOMPLETE; |
62 | } |
63 | |
64 | pPhysicalDeviceGroupProperties[0].physicalDeviceCount = 1; |
65 | pPhysicalDeviceGroupProperties[0].physicalDevices[0] = physicalDevice; |
66 | pPhysicalDeviceGroupProperties[0].subsetAllocation = VK_FALSE; |
67 | *pPhysicalDeviceGroupCount = 1; |
68 | |
69 | return VK_SUCCESS; |
70 | } |
71 | |
72 | } // namespace vk |
73 |