Debian Codegraph @

src/gpu/ganesh/vk/GrVkCommandPool.h

raw
1 /*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrVkCommandPool_DEFINED
9 #define GrVkCommandPool_DEFINED
10
11 #include "include/private/base/SkDebug.h"
12 #include "include/private/base/SkTArray.h"
13 #include "include/private/gpu/vk/SkiaVulkan.h"
14 #include "src/gpu/ganesh/GrManagedResource.h"
15 #include "src/gpu/ganesh/vk/GrVkCommandBuffer.h"
16 #include "src/gpu/ganesh/vk/GrVkManagedResource.h"
17
18 #include <stdint.h>
19 #include <cinttypes>
20 #include <memory>
21
22 class GrVkGpu;
23
24 class GrVkCommandPool : public GrVkManagedResource {
25 public:
26 static GrVkCommandPool* Create(GrVkGpu* gpu);
27
28 VkCommandPool vkCommandPool() const {
29 return fCommandPool;
30 }
31
32 void reset(GrVkGpu* gpu);
33
34
35 GrVkPrimaryCommandBuffer* getPrimaryCommandBuffer() { return fPrimaryCommandBuffer.get(); }
36
37 std::unique_ptr<GrVkSecondaryCommandBuffer> findOrCreateSecondaryCommandBuffer(GrVkGpu* gpu);
38
39 void recycleSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer);
40
41 // marks that we are finished with this command pool; it is not legal to continue creating or
42 // writing to command buffers in a closed pool
43 void close();
44
45 // returns true if close() has not been called
46 bool isOpen() const { return fOpen; }
47
48 #ifdef SK_TRACE_MANAGED_RESOURCES
49 void dumpInfo() const override {
50 SkDebugf("GrVkCommandPool: %" PRIdPTR " (%d refs)\n",
51 (intptr_t)fCommandPool, this->getRefCnt());
52 }
53 #endif
54
55 private:
56 GrVkCommandPool() = delete;
57
58 GrVkCommandPool(GrVkGpu* gpu, VkCommandPool commandPool, GrVkPrimaryCommandBuffer*);
59
60 void releaseResources();
61
62 void freeGPUData() const override;
63
64 bool fOpen = true;
65
66 VkCommandPool fCommandPool;
67
68 std::unique_ptr<GrVkPrimaryCommandBuffer> fPrimaryCommandBuffer;
69
70 // Array of available secondary command buffers that are not in flight
71 skia_private::STArray<4,
72 std::unique_ptr<GrVkSecondaryCommandBuffer>, true> fAvailableSecondaryBuffers;
73 int fMaxCachedSecondaryCommandBuffers;
74 };
75
76 #endif