VPP  0.8
A high-level modern C++ API for Vulkan
vppCommandPool.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 
37 {
38 public:
43  CommandPool ( const Device& hDevice, EQueueType queueType, std::uint32_t flags = 0 );
44 
50  VkResult reset();
51 
57  VkResult release();
58 
62  bool valid() const;
63 
67  const Device& device() const;
68 
72  VkCommandPool handle() const;
73 
74  enum EBufferLevel
75  {
76  PRIMARY = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
77  SECONDARY = VK_COMMAND_BUFFER_LEVEL_SECONDARY
78  };
79 
83  CommandBuffer createBuffer ( EBufferLevel level = PRIMARY );
84 
88  void freeBuffer ( const CommandBuffer& buffer );
89 
93  VkResult createBuffers (
94  std::uint32_t count,
95  std::vector< CommandBuffer >* pBuffers,
96  EBufferLevel level = PRIMARY );
97 
101  void freeBuffers (
102  const std::vector< CommandBuffer >& buffers );
103 };
104 
105 // -----------------------------------------------------------------------------
106 } // namespace vpp
107 // -----------------------------------------------------------------------------
Represents logical rendering device.
Definition: vppDevice.hpp:49
void freeBuffers(const std::vector< CommandBuffer > &buffers)
Frees multiple command buffers.
CommandPool(const Device &hDevice, EQueueType queueType, std::uint32_t flags=0)
Creates a command pool for specified device and queue type.
const Device & device() const
Retrieves the device.
The VPP namespace.
Definition: main.hpp:1
CommandBuffer createBuffer(EBufferLevel level=PRIMARY)
Creates single command buffer.
Represents a sequence of Vulkan commands.
Definition: vppCommandBuffer.hpp:68
void freeBuffer(const CommandBuffer &buffer)
Frees single command buffer.
Allocates and manages the lifetime of command buffers.
Definition: vppCommandPool.hpp:36
VkCommandPool handle() const
Retrieves the Vulkan handle.
VkResult reset()
Resets all child buffers for reusing.
VkResult createBuffers(std::uint32_t count, std::vector< CommandBuffer > *pBuffers, EBufferLevel level=PRIMARY)
Creates multiple command buffers.
bool valid() const
Checks whether this is valid command pool.
VkResult release()
Freees all child buffers.