1 /*
2 * Copyright 2016 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 GrVkDescriptorPool_DEFINED
9 #define GrVkDescriptorPool_DEFINED
10 
11 #include "include/gpu/vk/GrVkTypes.h"
12 #include "src/gpu/vk/GrVkManagedResource.h"
13 
14 class GrVkGpu;
15 
16 /**
17  * We require that all descriptor sets are of a single descriptor type. We also use a pool to only
18  * make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for
19  * for one type of descriptor.
20  */
21 class GrVkDescriptorPool : public GrVkManagedResource {
22 public:
23     static GrVkDescriptorPool* Create(GrVkGpu* gpu, VkDescriptorType type, uint32_t count);
24 
descPool()25     VkDescriptorPool descPool() const { return fDescPool; }
26 
27     // Returns whether or not this descriptor pool could be used, assuming it gets fully reset and
28     // not in use by another draw, to support the requested type and count.
29     bool isCompatible(VkDescriptorType type, uint32_t count) const;
30 
31 #ifdef SK_TRACE_MANAGED_RESOURCES
dumpInfo()32     void dumpInfo() const override {
33         SkDebugf("GrVkDescriptorPool: %d, type %d (%d refs)\n", fDescPool, fType,
34                  this->getRefCnt());
35     }
36 #endif
37 
38 private:
39     GrVkDescriptorPool(const GrVkGpu*, VkDescriptorPool pool, VkDescriptorType type,
40                        uint32_t count);
41 
42     void freeGPUData() const override;
43 
44     VkDescriptorType     fType;
45     uint32_t             fCount;
46     VkDescriptorPool     fDescPool;
47 
48     using INHERITED = GrVkManagedResource;
49 };
50 
51 #endif
52