Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef VK_COMMAND_POOL_HPP_ |
| 16 | #define VK_COMMAND_POOL_HPP_ |
| 17 | |
| 18 | #include "VkObject.hpp" |
Ben Clayton | a4e06ca | 2019-12-03 12:38:14 +0000 | [diff] [blame] | 19 | |
Alexis Hetu | bffee5e | 2018-11-19 11:30:43 -0500 | [diff] [blame] | 20 | #include <set> |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 21 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 22 | namespace vk { |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 23 | |
Ben Clayton | a4e06ca | 2019-12-03 12:38:14 +0000 | [diff] [blame] | 24 | class Device; |
| 25 | |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 26 | class CommandPool : public Object<CommandPool, VkCommandPool> |
| 27 | { |
| 28 | public: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 29 | CommandPool(const VkCommandPoolCreateInfo *pCreateInfo, void *mem); |
| 30 | void destroy(const VkAllocationCallbacks *pAllocator); |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 31 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 32 | static size_t ComputeRequiredAllocationSize(const VkCommandPoolCreateInfo *pCreateInfo); |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 33 | |
Ben Clayton | a4e06ca | 2019-12-03 12:38:14 +0000 | [diff] [blame] | 34 | VkResult allocateCommandBuffers(Device *device, VkCommandBufferLevel level, uint32_t commandBufferCount, VkCommandBuffer *pCommandBuffers); |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 35 | void freeCommandBuffers(uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers); |
Alexis Hetu | cd610c9 | 2019-02-01 16:47:51 -0500 | [diff] [blame] | 36 | VkResult reset(VkCommandPoolResetFlags flags); |
| 37 | void trim(VkCommandPoolTrimFlags flags); |
Alexis Hetu | bffee5e | 2018-11-19 11:30:43 -0500 | [diff] [blame] | 38 | |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 39 | private: |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 40 | std::set<VkCommandBuffer> *commandBuffers; |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 41 | }; |
| 42 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 43 | static inline CommandPool *Cast(VkCommandPool object) |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 44 | { |
Alexis Hetu | bd4cf81 | 2019-06-14 15:14:07 -0400 | [diff] [blame] | 45 | return CommandPool::Cast(object); |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 46 | } |
| 47 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 48 | } // namespace vk |
Alexis Hetu | 9c4ecae | 2018-11-20 16:26:10 -0500 | [diff] [blame] | 49 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 50 | #endif // VK_COMMAND_POOL_HPP_ |