• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 VkPhysicalDevicePrivateDataFeatures *features) const;
50 	bool hasExtendedFeatures(const VkPhysicalDeviceTextureCompressionASTCHDRFeatures *features) const;
51 	bool hasExtendedFeatures(const VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures *features) const;
52 	bool hasExtendedFeatures(const VkPhysicalDeviceShaderTerminateInvocationFeatures *features) const;
53 	bool hasExtendedFeatures(const VkPhysicalDeviceSubgroupSizeControlFeatures *requested) const;
54 	bool hasExtendedFeatures(const VkPhysicalDeviceInlineUniformBlockFeatures *features) const;
55 	bool hasExtendedFeatures(const VkPhysicalDeviceShaderIntegerDotProductFeatures *features) const;
56 	bool hasExtendedFeatures(const VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures *requested) const;
57 
58 	const VkPhysicalDeviceProperties &getProperties() const;
59 	void getProperties(VkPhysicalDeviceIDProperties *properties) const;
60 	void getProperties(VkPhysicalDeviceMaintenance3Properties *properties) const;
61 	void getProperties(VkPhysicalDeviceMaintenance4Properties *properties) const;
62 	void getProperties(VkPhysicalDeviceMultiviewProperties *properties) const;
63 	void getProperties(VkPhysicalDevicePointClippingProperties *properties) const;
64 	void getProperties(VkPhysicalDeviceProtectedMemoryProperties *properties) const;
65 	void getProperties(VkPhysicalDeviceSubgroupProperties *properties) const;
66 	void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const;
67 	void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalBufferProperties *properties) const;
68 	void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const;
69 #ifdef __ANDROID__
70 	void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const;
71 	void getProperties(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkAndroidHardwareBufferUsageANDROID *properties) const;
72 #endif
73 	void getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const;
74 	void getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const;
75 	void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) const;
76 	void getProperties(VkPhysicalDeviceExternalMemoryHostPropertiesEXT *properties) const;
77 	void getProperties(VkPhysicalDeviceDriverProperties *properties) const;
78 	void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
79 	void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
80 	void getProperties(VkPhysicalDeviceFloatControlsProperties *) const;
81 	void getProperties(VkPhysicalDeviceSamplerFilterMinmaxProperties *properties) const;
82 	void getProperties(VkPhysicalDeviceTimelineSemaphoreProperties *properties) const;
83 	void getProperties(VkPhysicalDeviceVulkan12Properties *properties) const;
84 	void getProperties(VkPhysicalDeviceVulkan13Properties *properties) const;
85 	void getProperties(VkPhysicalDeviceDescriptorIndexingProperties *properties) const;
86 	void getProperties(VkPhysicalDeviceDepthStencilResolveProperties *properties) const;
87 	void getProperties(VkPhysicalDeviceCustomBorderColorPropertiesEXT *properties) const;
88 	void getProperties(VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *properties) const;
89 	void getProperties(VkPhysicalDeviceSubgroupSizeControlProperties *properties) const;
90 	void getProperties(VkPhysicalDeviceInlineUniformBlockProperties *properties) const;
91 	void getProperties(VkPhysicalDeviceTexelBufferAlignmentProperties *properties) const;
92 	void getProperties(VkPhysicalDeviceShaderIntegerDotProductProperties *properties) const;
93 	void getProperties(VkPhysicalDeviceVulkan11Properties *properties) const;
94 
95 	static void GetFormatProperties(Format format, VkFormatProperties *pFormatProperties);
96 	static void GetFormatProperties(Format format, VkFormatProperties3 *pFormatProperties);
97 	void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
98 	                              VkImageUsageFlags usage, VkImageCreateFlags flags,
99 	                              VkImageFormatProperties *pImageFormatProperties) const;
100 	uint32_t getQueueFamilyPropertyCount() const;
101 
102 	void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
103 	                              VkQueueFamilyProperties *pQueueFamilyProperties) const;
104 	void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
105 	                              VkQueueFamilyProperties2 *pQueueFamilyProperties) const;
106 	static const VkPhysicalDeviceMemoryProperties &GetMemoryProperties();
107 
108 	static const VkPhysicalDeviceLimits &getLimits();
109 
110 private:
111 	static VkSampleCountFlags getSampleCounts();
112 	VkQueueFamilyProperties getQueueFamilyProperties() const;
113 
114 	template<typename T>
115 	T getSupportedFeatures(const T *requested) const;
116 };
117 
118 using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
119 
Cast(VkPhysicalDevice object)120 static inline PhysicalDevice *Cast(VkPhysicalDevice object)
121 {
122 	return DispatchablePhysicalDevice::Cast(object);
123 }
124 
125 }  // namespace vk
126 
127 #endif  // VK_PHYSICAL_DEVICE_HPP_
128