1 // Copyright 2019 The Amber Authors. 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 #include "src/vulkan/command_pool.h" 16 17 #include "src/vulkan/device.h" 18 19 namespace amber { 20 namespace vulkan { 21 CommandPool(Device * device)22CommandPool::CommandPool(Device* device) : device_(device) {} 23 ~CommandPool()24CommandPool::~CommandPool() { 25 if (pool_ == VK_NULL_HANDLE) 26 return; 27 28 device_->GetPtrs()->vkDestroyCommandPool(device_->GetVkDevice(), pool_, 29 nullptr); 30 } 31 Initialize()32Result CommandPool::Initialize() { 33 VkCommandPoolCreateInfo pool_info = VkCommandPoolCreateInfo(); 34 pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; 35 pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; 36 pool_info.queueFamilyIndex = device_->GetQueueFamilyIndex(); 37 38 if (device_->GetPtrs()->vkCreateCommandPool( 39 device_->GetVkDevice(), &pool_info, nullptr, &pool_) != VK_SUCCESS) { 40 return Result("Vulkan::Calling vkCreateCommandPool Fail"); 41 } 42 43 return {}; 44 } 45 46 } // namespace vulkan 47 } // namespace amber 48