blob: 97c27e1eafb956d8e7e46b7008e1ad813bf15378 [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
11#include "GrVkResource.h"
12
jvanverthe50f3e72016-03-28 07:03:06 -070013#include "vk/GrVkDefines.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050014
15class GrVkGpu;
16
egdanielc2dc1b22016-03-18 13:18:23 -070017/**
halcanary9d524f22016-03-29 09:03:52 -070018 * 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 -070019 * make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for
20 * for one type of descriptor.
21 */
Greg Daniel164a9f02016-02-22 09:56:40 -050022class GrVkDescriptorPool : public GrVkResource {
23public:
egdaniel778555c2016-05-02 06:50:36 -070024 GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count);
Greg Daniel164a9f02016-02-22 09:56:40 -050025
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
egdanielc2dc1b22016-03-18 13:18:23 -070031 // not in use by another draw, to support the requested type and count.
32 bool isCompatible(VkDescriptorType type, uint32_t count) const;
Greg Daniel164a9f02016-02-22 09:56:40 -050033
jvanverth7ec92412016-07-06 09:24:57 -070034#ifdef SK_TRACE_VK_RESOURCES
35 void dumpInfo() const override {
Ben Wagner63fd7602017-10-09 15:45:33 -040036 SkDebugf("GrVkDescriptorPool: %d, type %d (%d refs)\n", fDescPool, fType,
jvanverth7ec92412016-07-06 09:24:57 -070037 this->getRefCnt());
38 }
39#endif
40
Greg Daniel164a9f02016-02-22 09:56:40 -050041private:
42 void freeGPUData(const GrVkGpu* gpu) const override;
43
egdanielc2dc1b22016-03-18 13:18:23 -070044 VkDescriptorType fType;
45 uint32_t fCount;
Greg Daniel164a9f02016-02-22 09:56:40 -050046 VkDescriptorPool fDescPool;
47
48 typedef GrVkResource INHERITED;
49};
50
bsalomonbc2f4df2016-02-22 13:09:26 -080051#endif