blob: 08f7431a153e56a94f4bc147ec5362ef277c8205 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
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 Daniel54bfb182018-11-20 17:12:36 -050011#include "GrVkResource.h"
Greg Daniel487132b2018-12-20 14:09:36 -050012#include "vk/GrVkTypes.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050013
14class GrVkGpu;
15
egdanielc2dc1b22016-03-18 13:18:23 -070016/**
halcanary9d524f22016-03-29 09:03:52 -070017 * We require that all descriptor sets are of a single descriptor type. We also use a pool to only
egdanielc2dc1b22016-03-18 13:18:23 -070018 * make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for
19 * for one type of descriptor.
20 */
Greg Daniel164a9f02016-02-22 09:56:40 -050021class GrVkDescriptorPool : public GrVkResource {
22public:
egdaniel778555c2016-05-02 06:50:36 -070023 GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count);
Greg Daniel164a9f02016-02-22 09:56:40 -050024
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
egdanielc2dc1b22016-03-18 13:18:23 -070030 // not in use by another draw, to support the requested type and count.
31 bool isCompatible(VkDescriptorType type, uint32_t count) const;
Greg Daniel164a9f02016-02-22 09:56:40 -050032
jvanverth7ec92412016-07-06 09:24:57 -070033#ifdef SK_TRACE_VK_RESOURCES
34 void dumpInfo() const override {
Ben Wagner63fd7602017-10-09 15:45:33 -040035 SkDebugf("GrVkDescriptorPool: %d, type %d (%d refs)\n", fDescPool, fType,
jvanverth7ec92412016-07-06 09:24:57 -070036 this->getRefCnt());
37 }
38#endif
39
Greg Daniel164a9f02016-02-22 09:56:40 -050040private:
Ethan Nicholas8e265a72018-12-12 16:22:40 -050041 void freeGPUData(GrVkGpu* gpu) const override;
Greg Daniel164a9f02016-02-22 09:56:40 -050042
egdanielc2dc1b22016-03-18 13:18:23 -070043 VkDescriptorType fType;
44 uint32_t fCount;
Greg Daniel164a9f02016-02-22 09:56:40 -050045 VkDescriptorPool fDescPool;
46
47 typedef GrVkResource INHERITED;
48};
49
bsalomonbc2f4df2016-02-22 13:09:26 -080050#endif