VPP  0.8
A high-level modern C++ API for Vulkan
vppInstance.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 
36 {
38  unsigned int major;
39 
41  unsigned int minor;
42 
44  unsigned int patch;
45 
47  std::string toString() const;
48 
50  unsigned int id() const;
51 
53  static SVulkanVersion fromId ( unsigned int id );
54 };
55 
56 // -----------------------------------------------------------------------------
57 // -----------------------------------------------------------------------------
58 
115 class Instance
116 {
117 public:
119  ~Instance();
120 
122  VkInstance handle() const;
123 
125  bool valid() const;
126 
128  const std::set< std::string >& enabledExtensions() const;
129 
131  VkResult enumeratePhysicalDevices ( PhysicalDevices* pResult ) const;
132 
140 
144 
146  static VkResult enumerateExtensions ( ExtensionProperties* pResult );
147 
150 };
151 
152 // -----------------------------------------------------------------------------
153 // -----------------------------------------------------------------------------
154 
189 {
190 public:
192  createInstance();
193 
214  createInstance& vulkan ( const SVulkanVersion& v );
215 
217  createInstance& validation ( bool v );
218 
224  createInstance& raw ( bool v );
225 
233  createInstance& appName ( const char* v );
234 
242  createInstance& engineName ( const char* v );
243 
251  createInstance& appVersion ( unsigned int v );
252 
260  createInstance& engineVersion ( unsigned int v );
261 
268  createInstance& ext ( const std::string& v );
269 
275  createInstance& layer ( const std::string& v );
276 
278  operator Instance() const;
279 };
280 
281 // -----------------------------------------------------------------------------
282 } // namespace vpp
283 // -----------------------------------------------------------------------------
createInstance & engineName(const char *v)
Sets the engine name (default: null).
createInstance & raw(bool v)
If set, VPP will not add any extensions automatically (default: false).
static VkResult enumerateExtensions(ExtensionProperties *pResult)
Gets a list of available Vulkan extensions for the instance.
createInstance & appName(const char *v)
Sets the application name (default: null).
unsigned int minor
Minor version number.
Definition: vppInstance.hpp:41
~Instance()
Destructor.
The VPP namespace.
Definition: main.hpp:1
static SVulkanVersion fromId(unsigned int id)
Creates from opaque identifier.
Base class for debug report generators.
Definition: vppDebugReporter.hpp:55
Instance factory class.
Definition: vppInstance.hpp:188
VkResult enumeratePhysicalDevices(PhysicalDevices *pResult) const
Gets a list of physical devices in the system.
static DebugReporter * getDebugReporter()
Gets currently registered debug reporter, or zero if there is no one.
unsigned int patch
Patch number.
Definition: vppInstance.hpp:44
const std::set< std::string > & enabledExtensions() const
Retrieves the names of enabled extensions.
createInstance()
Constructs instance factory object with default options.
static SVulkanVersion supportedVersion()
Gets the minimum of two versions: latest available and requested by user.
VkInstance handle() const
Retrieves Vulkan handle for the instance.
unsigned int major
Major version number.
Definition: vppInstance.hpp:38
createInstance & layer(const std::string &v)
Adds a layer to enable.
createInstance & appVersion(unsigned int v)
Sets the application version (default: 0).
createInstance & validation(bool v)
Sets the validation status (default: disabled).
Represents the instance of Vulkan system.
Definition: vppInstance.hpp:115
createInstance & ext(const std::string &v)
Adds an instance extension to enable.
bool valid() const
Checks whether instance creation has succeeded.
std::vector< PhysicalDevice > PhysicalDevices
Array of physical devices.
Definition: vppPhysicalDevice.hpp:343
unsigned int id() const
Returns opaque identifier.
std::string toString() const
Returns string representation.
Structure holding information about Vulkan version.
Definition: vppInstance.hpp:35
static SVulkanVersion getLatestAvailableVulkanVersion()
Gets newest Vulkan version available on the system.
createInstance & engineVersion(unsigned int v)
Sets the engine version (default: 0).
createInstance & vulkan(const SVulkanVersion &v)
Sets the target Vulkan version (default: 1.0.0).