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 | |
| 11 | #include "GrVkResource.h" |
| 12 | |
jvanverth | e50f3e7 | 2016-03-28 07:03:06 -0700 | [diff] [blame] | 13 | #include "vk/GrVkDefines.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | |
| 15 | class GrVkGpu; |
| 16 | |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 17 | /** |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 18 | * 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] | 19 | * make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for |
| 20 | * for one type of descriptor. |
| 21 | */ |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 22 | class GrVkDescriptorPool : public GrVkResource { |
| 23 | public: |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame^] | 24 | GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 25 | |
| 26 | VkDescriptorPool descPool() const { return fDescPool; } |
| 27 | |
| 28 | void reset(const GrVkGpu* gpu); |
| 29 | |
| 30 | // 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] | 31 | // not in use by another draw, to support the requested type and count. |
| 32 | bool isCompatible(VkDescriptorType type, uint32_t count) const; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | void freeGPUData(const GrVkGpu* gpu) const override; |
| 36 | |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 37 | VkDescriptorType fType; |
| 38 | uint32_t fCount; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 39 | VkDescriptorPool fDescPool; |
| 40 | |
| 41 | typedef GrVkResource INHERITED; |
| 42 | }; |
| 43 | |
bsalomon | bc2f4df | 2016-02-22 13:09:26 -0800 | [diff] [blame] | 44 | #endif |