vsg: include/vsg/vk/CommandPool.h Source File

vsg 1.1.9 VulkanSceneGraph library |

Loading...
Searching...
No Matches
CommandPool.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/vk/Device.h>
16
17namespace vsg
18{
19 // forward declare
20 class CommandBuffer;
21
24 class VSG_DECLSPEC CommandPool : public Inherit<Object, CommandPool>
25 {
26 public:
27 CommandPool(Device* device, uint32_t queueFamilyIndex, VkCommandPoolCreateFlags flags = 0);
28
29 operator VkCommandPool() const { return _commandPool; }
30 VkCommandPool vk() const { return _commandPool; }
31
32 const uint32_t queueFamilyIndex;
33 const VkCommandPoolCreateFlags flags;
34
35 void reset(VkCommandPoolResetFlags reset_flags = VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT) const { vkResetCommandPool(*_device, _commandPool, reset_flags); }
36
38 ref_ptr<CommandBuffer> allocate(VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY);
39
40 Device* getDevice() { return _device; }
41 const Device* getDevice() const { return _device; }
42
43 protected:
44 virtual ~CommandPool();
45
46 friend CommandBuffer;
47
49 void free(CommandBuffer* commandBuffer);
50
51 std::mutex _mutex;
52 VkCommandPool _commandPool;
53 ref_ptr<Device> _device;
54 };
55 VSG_type_name(vsg::CommandPool);
56
57} // namespace vsg
vsg::CommandBuffer
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
vsg::CommandPool
Definition CommandPool.h:25
vsg::CommandPool::free
void free(CommandBuffer *commandBuffer)
free CommandBuffer
vsg::CommandPool::allocate
ref_ptr< CommandBuffer > allocate(VkCommandBufferLevel level=VK_COMMAND_BUFFER_LEVEL_PRIMARY)
allocate CommandBuffer from CommandPool
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:39
vsg::ref_ptr
Definition ref_ptr.h:22