blob: 0aec4230c73f96be7c2197ee7326771983c7dc75 [file] [log] [blame]
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001// 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 Claytona4e06ca2019-12-03 12:38:14 +000019
Alexis Hetubffee5e2018-11-19 11:30:43 -050020#include <set>
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050021
Nicolas Capens157ba262019-12-10 17:49:14 -050022namespace vk {
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050023
Ben Claytona4e06ca2019-12-03 12:38:14 +000024class Device;
25
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050026class CommandPool : public Object<CommandPool, VkCommandPool>
27{
28public:
Ben Clayton2ed93ab2019-12-17 20:38:03 +000029 CommandPool(const VkCommandPoolCreateInfo *pCreateInfo, void *mem);
30 void destroy(const VkAllocationCallbacks *pAllocator);
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050031
Ben Clayton2ed93ab2019-12-17 20:38:03 +000032 static size_t ComputeRequiredAllocationSize(const VkCommandPoolCreateInfo *pCreateInfo);
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050033
Ben Claytona4e06ca2019-12-03 12:38:14 +000034 VkResult allocateCommandBuffers(Device *device, VkCommandBufferLevel level, uint32_t commandBufferCount, VkCommandBuffer *pCommandBuffers);
Ben Clayton2ed93ab2019-12-17 20:38:03 +000035 void freeCommandBuffers(uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers);
Alexis Hetucd610c92019-02-01 16:47:51 -050036 VkResult reset(VkCommandPoolResetFlags flags);
37 void trim(VkCommandPoolTrimFlags flags);
Alexis Hetubffee5e2018-11-19 11:30:43 -050038
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050039private:
Ben Clayton2ed93ab2019-12-17 20:38:03 +000040 std::set<VkCommandBuffer> *commandBuffers;
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050041};
42
Ben Clayton2ed93ab2019-12-17 20:38:03 +000043static inline CommandPool *Cast(VkCommandPool object)
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050044{
Alexis Hetubd4cf812019-06-14 15:14:07 -040045 return CommandPool::Cast(object);
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050046}
47
Nicolas Capens157ba262019-12-10 17:49:14 -050048} // namespace vk
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050049
Ben Clayton2ed93ab2019-12-17 20:38:03 +000050#endif // VK_COMMAND_POOL_HPP_