blob: 53d676448a4c86a2aa36a68f1311bdb8da4dc903 [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#ifndef VK_INSTANCE_HPP_
16#define VK_INSTANCE_HPP_
17
Alexis Hetue70c3512018-10-17 13:18:04 -040018#include "VkObject.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040019
Nicolas Capens157ba262019-12-10 17:49:14 -050020namespace vk {
Alexis Hetu767b41b2018-09-26 11:25:46 -040021
22class Instance
23{
24public:
Alexis Hetu767b41b2018-09-26 11:25:46 -040025 static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE; }
26
Ben Clayton2ed93ab2019-12-17 20:38:03 +000027 Instance(const VkInstanceCreateInfo *pCreateInfo, void *mem, VkPhysicalDevice physicalDevice);
28 void destroy(const VkAllocationCallbacks *pAllocator);
Alexis Hetu767b41b2018-09-26 11:25:46 -040029
Ben Clayton2ed93ab2019-12-17 20:38:03 +000030 static size_t ComputeRequiredAllocationSize(const VkInstanceCreateInfo *) { return 0; }
Alexis Hetu767b41b2018-09-26 11:25:46 -040031
Ben Clayton2ed93ab2019-12-17 20:38:03 +000032 VkResult getPhysicalDevices(uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices) const;
Chris Forbesdf84b942019-06-12 11:28:09 -070033 VkResult getPhysicalDeviceGroups(uint32_t *pPhysicalDeviceGroupCount,
Ben Clayton2ed93ab2019-12-17 20:38:03 +000034 VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties) const;
Nicolas Capens0c736802019-05-27 12:53:31 -040035
Alexis Hetu767b41b2018-09-26 11:25:46 -040036private:
Alexis Hetu767b41b2018-09-26 11:25:46 -040037 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
Alexis Hetu767b41b2018-09-26 11:25:46 -040038};
39
40using DispatchableInstance = DispatchableObject<Instance, VkInstance>;
41
Ben Clayton2ed93ab2019-12-17 20:38:03 +000042static inline Instance *Cast(VkInstance object)
Alexis Hetu767b41b2018-09-26 11:25:46 -040043{
44 return DispatchableInstance::Cast(object);
45}
46
Nicolas Capens157ba262019-12-10 17:49:14 -050047} // namespace vk
Alexis Hetu767b41b2018-09-26 11:25:46 -040048
Ben Clayton2ed93ab2019-12-17 20:38:03 +000049#endif // VK_INSTANCE_HPP_