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#ifndef VK_PHYSICAL_DEVICE_HPP_
16#define VK_PHYSICAL_DEVICE_HPP_
17
18#include "VkObject.hpp"
19#include "VkFormat.h"
20
21#ifdef VK_USE_PLATFORM_ANDROID_KHR
22#include <vulkan/vk_android_native_buffer.h>
23#endif
24
25namespace vk
26{
27
28class PhysicalDevice
29{
30public:
31 static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE; }
32
33 PhysicalDevice(const void*, void* mem);
34 void destroy(const VkAllocationCallbacks* pAllocator) {}
35
36 static size_t ComputeRequiredAllocationSize(const void*) { return 0; }
37
38 const VkPhysicalDeviceFeatures& getFeatures() const;
39 void getFeatures(VkPhysicalDeviceSamplerYcbcrConversionFeatures* features) const;
40 void getFeatures(VkPhysicalDevice16BitStorageFeatures* features) const;
41 void getFeatures(VkPhysicalDeviceVariablePointerFeatures* features) const;
42 void getFeatures(VkPhysicalDevice8BitStorageFeaturesKHR* features) const;
43 void getFeatures(VkPhysicalDeviceMultiviewFeatures* features) const;
44 void getFeatures(VkPhysicalDeviceProtectedMemoryFeatures* features) const;
45 void getFeatures(VkPhysicalDeviceShaderDrawParameterFeatures* features) const;
46 void getFeatures(VkPhysicalDeviceLineRasterizationFeaturesEXT* features) const;
47 void getFeatures(VkPhysicalDeviceProvokingVertexFeaturesEXT* features) const;
48 bool hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const;
49
50 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;
59#ifdef __ANDROID__
60 void getProperties(VkPhysicalDevicePresentationPropertiesANDROID* properties) const;
61#endif
62 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;
65 void getProperties(VkPhysicalDeviceDriverPropertiesKHR* properties) const;
66 void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT* properties) const;
67 void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT* properties) const;
68
69 void getFormatProperties(Format format, VkFormatProperties* pFormatProperties) const;
70 void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
71 VkImageUsageFlags usage, VkImageCreateFlags flags,
72 VkImageFormatProperties* pImageFormatProperties) const;
73 uint32_t getQueueFamilyPropertyCount() const;
74 void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
75 VkQueueFamilyProperties* pQueueFamilyProperties) const;
76 void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
77 VkQueueFamilyProperties2* pQueueFamilyProperties) const;
78 const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const;
79
80private:
81 const VkPhysicalDeviceLimits& getLimits() const;
82 VkSampleCountFlags getSampleCounts() const;
83};
84
85using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
86
87static inline PhysicalDevice* Cast(VkPhysicalDevice object)
88{
89 return DispatchablePhysicalDevice::Cast(object);
90}
91
92} // namespace vk
93
94#endif // VK_PHYSICAL_DEVICE_HPP_
95