blob: c0b9bba971dca3c4ae6a416cb1814cdca260b015 [file] [log] [blame]
Alexis Hetu767b41b2018-09-26 11:25:46 -04001// 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"
Alexis Hetue70c3512018-10-17 13:18:04 -040016#include "VkDestroy.h"
Alexis Hetu767b41b2018-09-26 11:25:46 -040017
18namespace vk
19{
20
21Instance::Instance(const CreateInfo* pCreateInfo, void* mem)
22{
23 if(pCreateInfo->pPhysicalDevice)
24 {
25 physicalDevice = pCreateInfo->pPhysicalDevice;
26 physicalDeviceCount = 1;
27 }
28}
29
30void Instance::destroy(const VkAllocationCallbacks* pAllocator)
31{
32 vk::destroy(physicalDevice, pAllocator);
33}
34
35uint32_t Instance::getPhysicalDeviceCount() const
36{
37 return physicalDeviceCount;
38}
39
40void Instance::getPhysicalDevices(uint32_t pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) const
41{
42 ASSERT(pPhysicalDeviceCount == 1);
43
44 *pPhysicalDevices = physicalDevice;
45}
46
47uint32_t Instance::getPhysicalDeviceGroupCount() const
48{
49 return physicalDeviceGroupCount;
50}
51
52void 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