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