VPP  0.8
A high-level modern C++ API for Vulkan
vppPhysicalDevice.hpp
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 // -----------------------------------------------------------------------------
28 namespace vpp {
29 // -----------------------------------------------------------------------------
30 
65 {
66  fRobustBufferAccess,
67  fFullDrawIndexUint32,
68  fImageCubeArray,
69  fIndependentBlend,
70  fGeometryShader,
71  fTessellationShader,
72  fSampleRateShading,
73  fDualSrcBlend,
74  fLogicOp,
75  fMultiDrawIndirect,
76  fDrawIndirectFirstInstance,
77  fDepthClamp,
78  fDepthBiasClamp,
79  fFillModeNonSolid,
80  fDepthBounds,
81  fWideLines,
82  fLargePoints,
83  fAlphaToOne,
84  fMultiViewport,
85  fSamplerAnisotropy,
86  fTextureCompressionETC2,
87  fTextureCompressionASTC_LDR,
88  fTextureCompressionBC,
89  fOcclusionQueryPrecise,
90  fPipelineStatisticsQuery,
91  fVertexPipelineStoresAndAtomics,
92  fFragmentStoresAndAtomics,
93  fShaderTessellationAndGeometryPointSize,
94  fShaderImageGatherExtended,
95  fShaderStorageImageExtendedFormats,
96  fShaderStorageImageMultisample,
97  fShaderStorageImageReadWithoutFormat,
98  fShaderStorageImageWriteWithoutFormat,
99  fShaderUniformBufferArrayDynamicIndexing,
100  fShaderSampledImageArrayDynamicIndexing,
101  fShaderStorageBufferArrayDynamicIndexing,
102  fShaderStorageImageArrayDynamicIndexing,
103  fShaderClipDistance,
104  fShaderCullDistance,
105  fShaderFloat64,
106  fShaderInt64,
107  fShaderInt16,
108  fShaderResourceResidency,
109  fShaderResourceMinLod,
110  fSparseBinding,
111  fSparseResidencyBuffer,
112  fSparseResidencyImage2D,
113  fSparseResidencyImage3D,
114  fSparseResidency2Samples,
115  fSparseResidency4Samples,
116  fSparseResidency8Samples,
117  fSparseResidency16Samples,
118  fSparseResidencyAliased,
119  fVariableMultisampleRate,
120  fInheritedQueries,
121  fMultiview,
122  fMultiviewGeometryShader,
123  fMultiviewTessellationShader,
124  fVariablePointersStorageBuffer,
125  fVariablePointers,
126  fStorageBuffer8BitAccess,
127  fUniformAndStorageBuffer8BitAccess,
128  fStoragePushConstant8,
129  fShaderBufferInt64Atomics,
130  fShaderSharedInt64Atomics,
131  fStorageBuffer16BitAccess,
132  fUniformAndStorageBuffer16BitAccess,
133  fStoragePushConstant16,
134  fStorageInputOutput16,
135  fShaderFloat16,
136  fShaderInt8,
137  fSamplerYcbcrConversion,
138  fProtectedMemory,
139  fAdvancedBlendCoherentOperations,
140  fConditionalRendering,
141  fInheritedConditionalRendering,
142  fShaderDrawParameters,
143  fShaderInputAttachmentArrayDynamicIndexing,
144  fShaderUniformTexelBufferArrayDynamicIndexing,
145  fShaderStorageTexelBufferArrayDynamicIndexing,
146  fShaderUniformBufferArrayNonUniformIndexing,
147  fShaderSampledImageArrayNonUniformIndexing,
148  fShaderStorageBufferArrayNonUniformIndexing,
149  fShaderStorageImageArrayNonUniformIndexing,
150  fShaderInputAttachmentArrayNonUniformIndexing,
151  fShaderUniformTexelBufferArrayNonUniformIndexing,
152  fShaderStorageTexelBufferArrayNonUniformIndexing,
153  fDescriptorBindingUniformBufferUpdateAfterBind,
154  fDescriptorBindingSampledImageUpdateAfterBind,
155  fDescriptorBindingStorageImageUpdateAfterBind,
156  fDescriptorBindingStorageBufferUpdateAfterBind,
157  fDescriptorBindingUniformTexelBufferUpdateAfterBind,
158  fDescriptorBindingStorageTexelBufferUpdateAfterBind,
159  fDescriptorBindingUpdateUnusedWhilePending,
160  fDescriptorBindingPartiallyBound,
161  fDescriptorBindingVariableDescriptorCount,
162  fRuntimeDescriptorArray,
163  fDecodeModeSharedExponent,
164  fVertexAttributeInstanceRateDivisor,
165  fVertexAttributeInstanceRateZeroDivisor,
166  fTransformFeedback,
167  fGeometryStreams,
168  fVulkanMemoryModel,
169  fVulkanMemoryModelDeviceScope,
170  fVulkanMemoryModelAvailabilityVisibilityChains,
171  fInlineUniformBlock,
172  fDescriptorBindingInlineUniformBlockUpdateAfterBind,
173  fFragmentDensityMap,
174  fFragmentDensityMapDynamic,
175  fFragmentDensityMapNonSubsampledImages,
176  fScalarBlockLayout,
177  fDepthClipEnable,
178  fMemoryPriority,
179  fBufferDeviceAddress,
180  fBufferDeviceAddressCaptureReplay,
181  fBufferDeviceAddressMultiDevice,
182  fExtBlendOperationAdvanced,
183  fExtConditionalRendering,
184  fExtConservativeRasterization,
185  fExtDepthRangeUnrestricted,
186  fExtDescriptorIndexing,
187  fExtDiscardRectangles,
188  fExtExternalMemoryHost,
189  fExtHdrMetadata,
190  fExtInlineUniformBlock,
191  fExtPostDepthCoverage,
192  fExtSampleLocations,
193  fExtSamplerFilterMinmax,
194  fExtScalarBlockLayout,
195  fExtShaderSubgroupBallot,
196  fExtShaderSubgroupVote,
197  fExtShaderViewportIndexLayer,
198  fExtTransformFeedback,
199  fExtVertexAttributeDivisor,
200  fExtStorage16bit,
201  fExtStorage8bit,
202  fExtBindMemory2,
203  fExtCreateRenderpass2,
204  fExtDedicatedAllocation,
205  fExtDepthStencilResolve,
206  fExtDescriptorUpdateTemplate,
207  fExtDeviceGroup,
208  fExtDrawIndirectCount,
209  fExtDriverProperties,
210  fExtExternalFence,
211  fExtExternalFenceWin32,
212  fExtExternalMemory,
213  fExtExternalMemoryWin32,
214  fExtExternalSemaphore,
215  fExtExternalSemaphoreWin32,
216  fExtGetMemoryRequirements2,
217  fExtImageFormatList,
218  fExtMultiview,
219  fExtPushDescriptor,
220  fExtRelaxedBlockLayout,
221  fExtSamplerMirrorClampToEdge,
222  fExtSamplerYcbcrConversion,
223  fExtShaderAtomicInt64,
224  fExtShaderDrawParameters,
225  fExtShaderFloat16Int8,
226  fExtShaderFloatControls,
227  fExtStorageBufferStorageClass,
228  fExtSwapchain,
229  fExtSwapchainMutableFormat,
230  fExtVariablePointers,
231  fExtVulkanMemoryModel,
232  fExtWin32KeyedMutex,
233  fExtFragmentDensityMap,
234  fExtAstcDecodeMode,
235  fExtDepthClipEnable,
236  fExtMemoryPriority,
237  fExtBufferDeviceAddress
238 
239 };
240 
241 // -----------------------------------------------------------------------------
242 
259 {
260 public:
262  PhysicalDevice();
263 
265  PhysicalDevice ( VkPhysicalDevice hDevice );
266 
268  operator bool() const;
269 
271  VkPhysicalDevice handle() const;
272 
274  const VkPhysicalDeviceProperties& properties() const;
275 
277  const DeviceFeatures& features() const;
278 
280  VkPhysicalDeviceMemoryProperties getMemoryProperties() const;
281 
283  size_t queueFamilyCount() const;
284 
286  const VkQueueFamilyProperties& getQueueFamilyProperties ( size_t iFamily ) const;
287 
289  bool supportsSurface ( const Surface& surface, size_t iFamily ) const;
290 
292  void getLimitValuesAsText ( std::ostream& sst ) const;
293 
299  {
303  };
304 
328  VkFormatFeatureFlags supportsFormat ( VkFormat fmt, EFormatUsage u = OPTIMAL_TILING ) const;
329 
331  bool supportsDepthStencilFormat ( VkFormat fmt ) const;
332 
334  VkResult enumerateExtensions ( ExtensionProperties* pResult );
335 };
336 
337 // -----------------------------------------------------------------------------
338 
343 typedef std::vector< PhysicalDevice > PhysicalDevices;
344 
345 // -----------------------------------------------------------------------------
346 // -----------------------------------------------------------------------------
347 
363 {
364 public:
370  DeviceFeatures();
371 
373  DeviceFeatures ( const DeviceFeatures& rhs );
374 
376  const DeviceFeatures& operator= ( const DeviceFeatures& rhs );
377 
384  void readSupported ( const PhysicalDevice& hDevice );
385 
387  void readSupported ( VkPhysicalDevice hDevice );
388 
394  bool operator[] ( EFeature feature ) const;
395 
400  bool enableIfSupported ( EFeature feature, const PhysicalDevice& hDevice );
401 
407  const char* getFeatureName ( EFeature feature );
408 };
409 
410 // -----------------------------------------------------------------------------
411 } // namespace vpp
412 // -----------------------------------------------------------------------------
413 
414 
bool supportsSurface(const Surface &surface, size_t iFamily) const
Checks whether a queue family of this device supports presentation to a given surface.
VkResult enumerateExtensions(ExtensionProperties *pResult)
Gets a list of available Vulkan extensions for this device.
VkPhysicalDeviceMemoryProperties getMemoryProperties() const
Retrieves memory properties for this device.
VkFormatFeatureFlags supportsFormat(VkFormat fmt, EFormatUsage u=OPTIMAL_TILING) const
Checks whether this device supports specified usage of given format.
bool operator[](EFeature feature) const
Reads the status of specified feature or known extension.
The VPP namespace.
Definition: main.hpp:1
const VkQueueFamilyProperties & getQueueFamilyProperties(size_t iFamily) const
Retrieves properties for specified queue family.
Represents a surface visible on the screen.
Definition: vppSurface.hpp:59
const DeviceFeatures & operator=(const DeviceFeatures &rhs)
Makes a copy of specified feature list.
const DeviceFeatures & features() const
Retrieves features and extensions supported by the device.
const VkPhysicalDeviceProperties & properties() const
Retrieves device properties.
DeviceFeatures()
Constructs the empty feature list.
bool supportsDepthStencilFormat(VkFormat fmt) const
Checks whether this device supports specified depth/stencil format.
void getLimitValuesAsText(std::ostream &sst) const
Gets textual representation of limits section in device properties. Useful for diagnostic logs...
Utility class for dealing with device features and known extensions.
Definition: vppPhysicalDevice.hpp:362
Represents physical rendering device.
Definition: vppPhysicalDevice.hpp:258
Use the format in texel buffers.
Definition: vppPhysicalDevice.hpp:302
size_t queueFamilyCount() const
Retrieves number of queue families supported by this device.
Use the format in optimal tiling images.
Definition: vppPhysicalDevice.hpp:300
EFormatUsage
Enumeration of possible usages for data format.
Definition: vppPhysicalDevice.hpp:298
bool enableIfSupported(EFeature feature, const PhysicalDevice &hDevice)
Enables specified feature or known extension if supported by the device.
const char * getFeatureName(EFeature feature)
Retrieves the name of specified feature or known extension.
PhysicalDevice()
Constructs null reference.
std::vector< PhysicalDevice > PhysicalDevices
Array of physical devices.
Definition: vppPhysicalDevice.hpp:343
EFeature
Optional device feature enumeration.
Definition: vppPhysicalDevice.hpp:64
void readSupported(const PhysicalDevice &hDevice)
Reads supported features and known extensions from specified device.
VkPhysicalDevice handle() const
Retrieves Vulkan handle for this device.
Use the format in linear tiling images.
Definition: vppPhysicalDevice.hpp:301