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 "VkFormat.hpp"
19 #include "VkObject.hpp"
20 
21 #ifdef VK_USE_PLATFORM_ANDROID_KHR
22 #	include <vulkan/vk_android_native_buffer.h>
23 #endif
24 
25 namespace vk {
26 
27 class PhysicalDevice
28 {
29 public:
GetAllocationScope()30 	static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE; }
31 
32 	PhysicalDevice(const void *, void *mem);
destroy(const VkAllocationCallbacks * pAllocator)33 	void destroy(const VkAllocationCallbacks *pAllocator) {}
34 
ComputeRequiredAllocationSize(const void *)35 	static size_t ComputeRequiredAllocationSize(const void *) { return 0; }
36 
37 	const VkPhysicalDeviceFeatures &getFeatures() const;
38 	void getFeatures2(VkPhysicalDeviceFeatures2 *features) const;
39 	bool hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatures) const;
40 
41 	const VkPhysicalDeviceProperties &getProperties() const;
42 	void getProperties(VkPhysicalDeviceIDProperties *properties) const;
43 	void getProperties(VkPhysicalDeviceMaintenance3Properties *properties) const;
44 	void getProperties(VkPhysicalDeviceMultiviewProperties *properties) const;
45 	void getProperties(VkPhysicalDevicePointClippingProperties *properties) const;
46 	void getProperties(VkPhysicalDeviceProtectedMemoryProperties *properties) const;
47 	void getProperties(VkPhysicalDeviceSubgroupProperties *properties) const;
48 	void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const;
49 	void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalBufferProperties *properties) const;
50 	void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const;
51 #ifdef __ANDROID__
52 	void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const;
53 	void getProperties(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkAndroidHardwareBufferUsageANDROID *properties) const;
54 #endif
55 	void getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const;
56 	void getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const;
57 	void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) const;
58 	void getProperties(VkPhysicalDeviceExternalMemoryHostPropertiesEXT *properties) const;
59 	void getProperties(VkPhysicalDeviceDriverPropertiesKHR *properties) const;
60 	void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
61 	void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
62 	void getProperties(VkPhysicalDeviceFloatControlsProperties *) const;
63 	void getProperties(VkPhysicalDeviceSamplerFilterMinmaxProperties *properties) const;
64 	void getProperties(VkPhysicalDeviceTimelineSemaphoreProperties *properties) const;
65 	void getProperties(VkPhysicalDeviceVulkan12Properties *properties) const;
66 	void getProperties(VkPhysicalDeviceDescriptorIndexingProperties *properties) const;
67 	void getProperties(VkPhysicalDeviceDepthStencilResolveProperties *properties) const;
68 	void getProperties(VkPhysicalDeviceVulkan11Properties *properties) const;
69 
70 	static void GetFormatProperties(Format format, VkFormatProperties *pFormatProperties);
71 	void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
72 	                              VkImageUsageFlags usage, VkImageCreateFlags flags,
73 	                              VkImageFormatProperties *pImageFormatProperties) const;
74 	uint32_t getQueueFamilyPropertyCount() const;
75 
76 	void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
77 	                              VkQueueFamilyProperties *pQueueFamilyProperties) const;
78 	void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
79 	                              VkQueueFamilyProperties2 *pQueueFamilyProperties) const;
80 	static const VkPhysicalDeviceMemoryProperties &GetMemoryProperties();
81 
82 private:
83 	const VkPhysicalDeviceLimits &getLimits() const;
84 	VkSampleCountFlags getSampleCounts() const;
85 	VkQueueFamilyProperties getQueueFamilyProperties() const;
86 };
87 
88 using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
89 
Cast(VkPhysicalDevice object)90 static inline PhysicalDevice *Cast(VkPhysicalDevice object)
91 {
92 	return DispatchablePhysicalDevice::Cast(object);
93 }
94 
95 }  // namespace vk
96 
97 #endif  // VK_PHYSICAL_DEVICE_HPP_
98