blob: ea74d164894199a2950c15c23546babf1959a741 [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_PHYSICAL_DEVICE_HPP_
16#define VK_PHYSICAL_DEVICE_HPP_
17
Antonio Maiorano42fd1592020-04-27 11:30:40 -040018#include "VkFormat.hpp"
Ben Clayton2ed93ab2019-12-17 20:38:03 +000019#include "VkObject.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040020
Hernan Liatis83a3eb42019-04-29 17:16:10 -070021#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +000022# include <vulkan/vk_android_native_buffer.h>
Hernan Liatis83a3eb42019-04-29 17:16:10 -070023#endif
24
Nicolas Capens157ba262019-12-10 17:49:14 -050025namespace vk {
Alexis Hetu767b41b2018-09-26 11:25:46 -040026
27class PhysicalDevice
28{
29public:
Hernan Liatis94e3e4a2019-05-17 11:50:06 -070030 static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE; }
Alexis Hetu767b41b2018-09-26 11:25:46 -040031
Ben Clayton2ed93ab2019-12-17 20:38:03 +000032 PhysicalDevice(const void *, void *mem);
33 void destroy(const VkAllocationCallbacks *pAllocator) {}
Alexis Hetu767b41b2018-09-26 11:25:46 -040034
Ben Clayton2ed93ab2019-12-17 20:38:03 +000035 static size_t ComputeRequiredAllocationSize(const void *) { return 0; }
Alexis Hetu767b41b2018-09-26 11:25:46 -040036
Ben Clayton2ed93ab2019-12-17 20:38:03 +000037 const VkPhysicalDeviceFeatures &getFeatures() const;
38 void getFeatures(VkPhysicalDeviceSamplerYcbcrConversionFeatures *features) const;
39 void getFeatures(VkPhysicalDevice16BitStorageFeatures *features) const;
40 void getFeatures(VkPhysicalDeviceVariablePointerFeatures *features) const;
41 void getFeatures(VkPhysicalDevice8BitStorageFeaturesKHR *features) const;
42 void getFeatures(VkPhysicalDeviceMultiviewFeatures *features) const;
43 void getFeatures(VkPhysicalDeviceProtectedMemoryFeatures *features) const;
44 void getFeatures(VkPhysicalDeviceShaderDrawParameterFeatures *features) const;
45 void getFeatures(VkPhysicalDeviceLineRasterizationFeaturesEXT *features) const;
Ben Claytona0453d52020-02-11 18:05:41 +000046 void getFeatures(VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *features) const;
Ben Clayton2ed93ab2019-12-17 20:38:03 +000047 void getFeatures(VkPhysicalDeviceProvokingVertexFeaturesEXT *features) const;
48 bool hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatures) const;
Alexis Hetu9e4d0402018-10-16 15:44:12 -040049
Ben Clayton2ed93ab2019-12-17 20:38:03 +000050 const VkPhysicalDeviceProperties &getProperties() const;
51 void getProperties(VkPhysicalDeviceIDProperties *properties) const;
52 void getProperties(VkPhysicalDeviceMaintenance3Properties *properties) const;
53 void getProperties(VkPhysicalDeviceMultiviewProperties *properties) const;
54 void getProperties(VkPhysicalDevicePointClippingProperties *properties) const;
55 void getProperties(VkPhysicalDeviceProtectedMemoryProperties *properties) const;
56 void getProperties(VkPhysicalDeviceSubgroupProperties *properties) const;
57 void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const;
58 void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const;
Hernan Liatis83a3eb42019-04-29 17:16:10 -070059#ifdef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +000060 void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const;
Hernan Liatis83a3eb42019-04-29 17:16:10 -070061#endif
Ben Clayton2ed93ab2019-12-17 20:38:03 +000062 void getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const;
63 void getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const;
64 void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) const;
Jonah Ryan-Davisf9f999f2020-01-08 14:41:28 -050065 void getProperties(VkPhysicalDeviceExternalMemoryHostPropertiesEXT *properties) const;
Ben Clayton2ed93ab2019-12-17 20:38:03 +000066 void getProperties(VkPhysicalDeviceDriverPropertiesKHR *properties) const;
67 void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
68 void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
Alexis Hetu9e4d0402018-10-16 15:44:12 -040069
Ben Clayton2ed93ab2019-12-17 20:38:03 +000070 void getFormatProperties(Format format, VkFormatProperties *pFormatProperties) const;
Nicolas Capens7e01e4e2019-05-18 08:19:07 -040071 void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
Alexis Hetu767b41b2018-09-26 11:25:46 -040072 VkImageUsageFlags usage, VkImageCreateFlags flags,
Ben Clayton2ed93ab2019-12-17 20:38:03 +000073 VkImageFormatProperties *pImageFormatProperties) const;
Alexis Hetu767b41b2018-09-26 11:25:46 -040074 uint32_t getQueueFamilyPropertyCount() const;
75 void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
Ben Clayton2ed93ab2019-12-17 20:38:03 +000076 VkQueueFamilyProperties *pQueueFamilyProperties) const;
Alexis Hetu4100b732019-10-11 17:01:48 -040077 void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
Ben Clayton2ed93ab2019-12-17 20:38:03 +000078 VkQueueFamilyProperties2 *pQueueFamilyProperties) const;
79 const VkPhysicalDeviceMemoryProperties &getMemoryProperties() const;
Alexis Hetu767b41b2018-09-26 11:25:46 -040080
81private:
Ben Clayton2ed93ab2019-12-17 20:38:03 +000082 const VkPhysicalDeviceLimits &getLimits() const;
Alexis Hetu767b41b2018-09-26 11:25:46 -040083 VkSampleCountFlags getSampleCounts() const;
Alexis Hetu767b41b2018-09-26 11:25:46 -040084};
85
86using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
87
Ben Clayton2ed93ab2019-12-17 20:38:03 +000088static inline PhysicalDevice *Cast(VkPhysicalDevice object)
Alexis Hetu767b41b2018-09-26 11:25:46 -040089{
90 return DispatchablePhysicalDevice::Cast(object);
91}
92
Nicolas Capens157ba262019-12-10 17:49:14 -050093} // namespace vk
Alexis Hetu767b41b2018-09-26 11:25:46 -040094
Ben Clayton2ed93ab2019-12-17 20:38:03 +000095#endif // VK_PHYSICAL_DEVICE_HPP_