VPP  0.8
A high-level modern C++ API for Vulkan
vppDevice.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 
49 class Device
50 {
51 public:
53  Device();
54 
56  Device (
57  const PhysicalDevice& hPhysicalDevice );
58 
76  Device (
77  const PhysicalDevice& hPhysicalDevice,
78  const VkPhysicalDeviceFeatures& features );
79 
81  Device (
82  const PhysicalDevice& hPhysicalDevice,
83  const std::vector< float >& queuePriorities );
84 
88  Device (
89  const PhysicalDevice& hPhysicalDevice,
90  const std::vector< float >& queuePriorities,
91  const VkPhysicalDeviceFeatures& features );
92 
94  ~Device();
95 
97  operator bool() const;
98 
100  VkDevice handle() const;
101 
103  const PhysicalDevice& physical() const;
104 
106  unsigned int queueFamily ( EQueueType queueType ) const;
107 
109  unsigned int queueCount ( EQueueType queueType ) const;
110 
112  float queuePriority ( unsigned int iQueue ) const;
113 
129  CommandPool& defaultCmdPool ( EQueueType queueType = Q_GRAPHICS ) const;
130 
143 
145  bool hasFeature ( EFeature feature ) const;
146 
148  const std::set< std::string >& enabledExtensions() const;
149 
151  bool supportsVersion ( const SVulkanVersion& ver ) const;
152 
154  VkResult waitForIdle();
155 };
156 
157 // -----------------------------------------------------------------------------
158 } // namespace vpp
159 // -----------------------------------------------------------------------------
PipelineCache & defaultPipelineCache() const
Retrieves default pipeline cache for this device.
CommandPool & defaultCmdPool(EQueueType queueType=Q_GRAPHICS) const
Retrieves default command allocation pool for this device and specified queue type.
Represents logical rendering device.
Definition: vppDevice.hpp:49
bool hasFeature(EFeature feature) const
Checks whether the device supports specified feature and has enabled it.
VkResult waitForIdle()
Waits until all operations performed by this device are finished.
Definition: vppPipelineCache.hpp:31
bool supportsVersion(const SVulkanVersion &ver) const
Checks whether the device (and instance) supports specified Vulkan version.
The VPP namespace.
Definition: main.hpp:1
const std::set< std::string > & enabledExtensions() const
Retrieves the names of enabled device extensions.
Device()
Constructs null reference.
Allocates and manages the lifetime of command buffers.
Definition: vppCommandPool.hpp:36
VkDevice handle() const
Retrieves Vulkan handle for this device.
const PhysicalDevice & physical() const
Retrieves parent physical device for this logical device.
Represents physical rendering device.
Definition: vppPhysicalDevice.hpp:258
unsigned int queueCount(EQueueType queueType) const
Retrieves queue count within default queue family of specified type.
float queuePriority(unsigned int iQueue) const
Retrieves queue priority for specified queue index within default graphics queue family.
EFeature
Optional device feature enumeration.
Definition: vppPhysicalDevice.hpp:64
Structure holding information about Vulkan version.
Definition: vppInstance.hpp:35
~Device()
Decreases reference count. Deletes the device object when count reaches zero.
unsigned int queueFamily(EQueueType queueType) const
Retrieves default queue family index for queues of specified type.