1 // 2 // Copyright 2019 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // PersistentCommandPool.h: 7 // Defines the class interface for PersistentCommandBuffer 8 // 9 10 #ifndef LIBANGLE_RENDERER_VULKAN_PERSISTENTCOMMANDPOOL_H_ 11 #define LIBANGLE_RENDERER_VULKAN_PERSISTENTCOMMANDPOOL_H_ 12 13 #include <vector> 14 15 #include "libANGLE/renderer/vulkan/vk_utils.h" 16 #include "libANGLE/renderer/vulkan/vk_wrapper.h" 17 18 namespace rx 19 { 20 21 namespace vk 22 { 23 24 class PersistentCommandPool final 25 { 26 public: 27 PersistentCommandPool(); 28 ~PersistentCommandPool(); 29 30 void destroy(VkDevice device); 31 angle::Result init(vk::Context *context, bool hasProtectedContent, uint32_t queueFamilyIndex); 32 33 angle::Result allocate(vk::Context *context, vk::PrimaryCommandBuffer *commandBufferOut); 34 angle::Result collect(vk::Context *context, vk::PrimaryCommandBuffer &&buffer); 35 valid()36 bool valid() const { return mCommandPool.valid(); } 37 38 private: 39 angle::Result allocateCommandBuffer(vk::Context *context); 40 41 std::vector<vk::PrimaryCommandBuffer> mFreeBuffers; 42 43 vk::CommandPool mCommandPool; 44 45 static const int kInitBufferNum = 2; 46 }; 47 48 } // namespace vk 49 50 } // namespace rx 51 52 #endif 53