Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 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 | |
Greg Daniel | 54bfb18 | 2018-11-20 17:12:36 -0500 | [diff] [blame] | 11 | #include "GrVkResource.h" |
Greg Daniel | 487132b | 2018-12-20 14:09:36 -0500 | [diff] [blame] | 12 | #include "vk/GrVkTypes.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 13 | |
| 14 | class GrVkGpu; |
| 15 | |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 16 | /** |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 17 | * We require that all descriptor sets are of a single descriptor type. We also use a pool to only |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 18 | * make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for |
| 19 | * for one type of descriptor. |
| 20 | */ |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 21 | class GrVkDescriptorPool : public GrVkResource { |
| 22 | public: |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame] | 23 | GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 24 | |
| 25 | VkDescriptorPool descPool() const { return fDescPool; } |
| 26 | |
| 27 | void reset(const GrVkGpu* gpu); |
| 28 | |
| 29 | // Returns whether or not this descriptor pool could be used, assuming it gets fully reset and |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 30 | // not in use by another draw, to support the requested type and count. |
| 31 | bool isCompatible(VkDescriptorType type, uint32_t count) const; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 32 | |
jvanverth | 7ec9241 | 2016-07-06 09:24:57 -0700 | [diff] [blame] | 33 | #ifdef SK_TRACE_VK_RESOURCES |
| 34 | void dumpInfo() const override { |
Ben Wagner | 63fd760 | 2017-10-09 15:45:33 -0400 | [diff] [blame] | 35 | SkDebugf("GrVkDescriptorPool: %d, type %d (%d refs)\n", fDescPool, fType, |
jvanverth | 7ec9241 | 2016-07-06 09:24:57 -0700 | [diff] [blame] | 36 | this->getRefCnt()); |
| 37 | } |
| 38 | #endif |
| 39 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 40 | private: |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 41 | void freeGPUData(GrVkGpu* gpu) const override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 42 | |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 43 | VkDescriptorType fType; |
| 44 | uint32_t fCount; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 45 | VkDescriptorPool fDescPool; |
| 46 | |
| 47 | typedef GrVkResource INHERITED; |
| 48 | }; |
| 49 | |
bsalomon | bc2f4df | 2016-02-22 13:09:26 -0800 | [diff] [blame] | 50 | #endif |