• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(ErrorContext *context,
32                        ProtectionType protectionType,
33                        uint32_t queueFamilyIndex);
34 
35     angle::Result allocate(ErrorContext *context, PrimaryCommandBuffer *commandBufferOut);
36     angle::Result collect(ErrorContext *context, PrimaryCommandBuffer &&buffer);
37 
valid()38     bool valid() const { return mCommandPool.valid(); }
39 
40   private:
41     angle::Result allocateCommandBuffer(ErrorContext *context);
42 
43     std::deque<PrimaryCommandBuffer> mFreeBuffers;
44 
45     CommandPool mCommandPool;
46 
47     static const int kInitBufferNum = 2;
48 };
49 
50 }  // namespace vk
51 
52 }  // namespace rx
53 
54 #endif
55