xref: /aosp_15_r20/external/swiftshader/src/Vulkan/VkPhysicalDevice.hpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
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 	bool hasExtendedFeatures(const VkPhysicalDeviceLineRasterizationFeaturesEXT *features) const;
42 	bool hasExtendedFeatures(const VkPhysicalDeviceProvokingVertexFeaturesEXT *features) const;
43 	bool hasExtendedFeatures(const VkPhysicalDeviceVulkan11Features *features) const;
44 	bool hasExtendedFeatures(const VkPhysicalDeviceVulkan12Features *features) const;
45 	bool hasExtendedFeatures(const VkPhysicalDeviceVulkan13Features *features) const;
46 	bool hasExtendedFeatures(const VkPhysicalDeviceDepthClipEnableFeaturesEXT *features) const;
47 	bool hasExtendedFeatures(const VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT *features) const;
48 	bool hasExtendedFeatures(const VkPhysicalDeviceExtendedDynamicStateFeaturesEXT *features) const;
49 	bool hasExtendedFeatures(const VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT *features) const;
50 	bool hasExtendedFeatures(const VkPhysicalDevicePrivateDataFeatures *features) const;
51 	bool hasExtendedFeatures(const VkPhysicalDeviceTextureCompressionASTCHDRFeatures *features) const;
52 	bool hasExtendedFeatures(const VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures *features) const;
53 	bool hasExtendedFeatures(const VkPhysicalDeviceShaderTerminateInvocationFeatures *features) const;
54 	bool hasExtendedFeatures(const VkPhysicalDeviceSubgroupSizeControlFeatures *requested) const;
55 	bool hasExtendedFeatures(const VkPhysicalDeviceInlineUniformBlockFeatures *features) const;
56 	bool hasExtendedFeatures(const VkPhysicalDeviceShaderIntegerDotProductFeatures *features) const;
57 	bool hasExtendedFeatures(const VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures *requested) const;
58 	bool hasExtendedFeatures(const VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT *requested) const;
59 	bool hasExtendedFeatures(const VkPhysicalDeviceDescriptorIndexingFeatures *requested) const;
60 	bool hasExtendedFeatures(const VkPhysicalDevicePipelineRobustnessFeaturesEXT *requested) const;
61 	bool hasExtendedFeatures(const VkPhysicalDeviceProtectedMemoryFeatures *requested) const;
62 	bool hasExtendedFeatures(const VkPhysicalDeviceBufferDeviceAddressFeatures *requested) const;
63 	bool hasExtendedFeatures(const VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT *requested) const;
64 	bool hasExtendedFeatures(const VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR *requested) const;
65 	bool hasExtendedFeatures(const VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT *requested) const;
66 	bool hasExtendedFeatures(const VkPhysicalDeviceHostImageCopyFeaturesEXT *requested) const;
67 
68 	const VkPhysicalDeviceProperties &getProperties() const;
69 	void getProperties(VkPhysicalDeviceIDProperties *properties) const;
70 	void getProperties(VkPhysicalDeviceMaintenance3Properties *properties) const;
71 	void getProperties(VkPhysicalDeviceMaintenance4Properties *properties) const;
72 	void getProperties(VkPhysicalDeviceMultiviewProperties *properties) const;
73 	void getProperties(VkPhysicalDevicePointClippingProperties *properties) const;
74 	void getProperties(VkPhysicalDeviceProtectedMemoryProperties *properties) const;
75 	void getProperties(VkPhysicalDeviceSubgroupProperties *properties) const;
76 	void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const;
77 	void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalBufferProperties *properties) const;
78 	void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const;
79 #ifdef __ANDROID__
80 	void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const;
81 	void getProperties(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkAndroidHardwareBufferUsageANDROID *properties) const;
82 #endif
83 	void getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const;
84 	void getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const;
85 	void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) const;
86 	void getProperties(VkPhysicalDeviceExternalMemoryHostPropertiesEXT *properties) const;
87 	void getProperties(VkPhysicalDeviceDriverProperties *properties) const;
88 	void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
89 	void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
90 	void getProperties(VkPhysicalDeviceFloatControlsProperties *) const;
91 	void getProperties(VkPhysicalDeviceSamplerFilterMinmaxProperties *properties) const;
92 	void getProperties(VkPhysicalDeviceTimelineSemaphoreProperties *properties) const;
93 	void getProperties(VkPhysicalDeviceDescriptorIndexingProperties *properties) const;
94 	void getProperties(VkPhysicalDeviceDepthStencilResolveProperties *properties) const;
95 	void getProperties(VkPhysicalDeviceCustomBorderColorPropertiesEXT *properties) const;
96 	void getProperties(VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *properties) const;
97 	void getProperties(VkPhysicalDeviceSubgroupSizeControlProperties *properties) const;
98 	void getProperties(VkPhysicalDeviceInlineUniformBlockProperties *properties) const;
99 	void getProperties(VkPhysicalDeviceTexelBufferAlignmentProperties *properties) const;
100 	void getProperties(VkPhysicalDeviceShaderIntegerDotProductProperties *properties) const;
101 	void getProperties(VkPhysicalDevicePipelineRobustnessPropertiesEXT *properties) const;
102 	void getProperties(VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT *properties) const;
103 	void getProperties(VkPhysicalDeviceHostImageCopyPropertiesEXT *properties) const;
104 	void getProperties(VkPhysicalDeviceVulkan11Properties *properties) const;
105 	void getProperties(VkPhysicalDeviceVulkan12Properties *properties) const;
106 	void getProperties(VkPhysicalDeviceVulkan13Properties *properties) const;
107 
108 	static bool isFormatSupported(vk::Format format, VkImageType type, VkImageTiling tiling,
109 	                              VkImageUsageFlags usage, VkImageUsageFlags stencilUsage, VkImageCreateFlags flags);
110 	static void GetFormatProperties(Format format, VkFormatProperties *pFormatProperties);
111 	static void GetFormatProperties(Format format, VkFormatProperties3 *pFormatProperties);
112 	void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
113 	                              VkImageUsageFlags usage, VkImageCreateFlags flags,
114 	                              VkImageFormatProperties *pImageFormatProperties) const;
115 
116 	uint32_t getQueueFamilyPropertyCount() const;
117 	void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
118 	                              VkQueueFamilyProperties *pQueueFamilyProperties) const;
119 	void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
120 	                              VkQueueFamilyProperties2 *pQueueFamilyProperties) const;
121 	void getQueueFamilyGlobalPriorityProperties(VkQueueFamilyGlobalPriorityPropertiesKHR *pQueueFamilyGlobalPriorityProperties) const;
122 	bool validateQueueGlobalPriority(VkQueueGlobalPriorityKHR queueGlobalPriority) const;
123 	VkQueueGlobalPriorityKHR getDefaultQueueGlobalPriority() const;
124 	static const VkPhysicalDeviceMemoryProperties &GetMemoryProperties();
125 
126 	static const VkPhysicalDeviceLimits &getLimits();
127 
128 private:
129 	static VkSampleCountFlags getSampleCounts();
130 	VkQueueFamilyProperties getQueueFamilyProperties() const;
131 
132 	template<typename T>
133 	T getSupportedFeatures(const T *requested) const;
134 };
135 
136 using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
137 
Cast(VkPhysicalDevice object)138 static inline PhysicalDevice *Cast(VkPhysicalDevice object)
139 {
140 	return DispatchablePhysicalDevice::Cast(object);
141 }
142 
143 }  // namespace vk
144 
145 #endif  // VK_PHYSICAL_DEVICE_HPP_
146