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
Instance(const CreateInfo * pCreateInfo,void * mem)21 Instance::Instance(const CreateInfo* pCreateInfo, void* mem)
22 {
23 if(pCreateInfo->pPhysicalDevice)
24 {
25 physicalDevice = pCreateInfo->pPhysicalDevice;
26 physicalDeviceCount = 1;
27 }
28 }
29
destroy(const VkAllocationCallbacks * pAllocator)30 void Instance::destroy(const VkAllocationCallbacks* pAllocator)
31 {
32 vk::destroy(physicalDevice, pAllocator);
33 }
34
getPhysicalDeviceCount() const35 uint32_t Instance::getPhysicalDeviceCount() const
36 {
37 return physicalDeviceCount;
38 }
39
getPhysicalDevices(uint32_t pPhysicalDeviceCount,VkPhysicalDevice * pPhysicalDevices) const40 void Instance::getPhysicalDevices(uint32_t pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) const
41 {
42 ASSERT(pPhysicalDeviceCount == 1);
43
44 *pPhysicalDevices = physicalDevice;
45 }
46
getPhysicalDeviceGroupCount() const47 uint32_t Instance::getPhysicalDeviceGroupCount() const
48 {
49 return physicalDeviceGroupCount;
50 }
51
getPhysicalDeviceGroups(uint32_t pPhysicalDeviceGroupCount,VkPhysicalDeviceGroupProperties * pPhysicalDeviceGroupProperties) const52 void Instance::getPhysicalDeviceGroups(uint32_t pPhysicalDeviceGroupCount,
53 VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) const
54 {
55 ASSERT(pPhysicalDeviceGroupCount == 1);
56
57 pPhysicalDeviceGroupProperties->physicalDeviceCount = physicalDeviceCount;
58 pPhysicalDeviceGroupProperties->physicalDevices[0] = physicalDevice;
59 pPhysicalDeviceGroupProperties->subsetAllocation = VK_FALSE;
60 }
61
62 } // namespace vk
63