aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkDescriptorPool.h
blob: 97c27e1eafb956d8e7e46b7008e1ad813bf15378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef GrVkDescriptorPool_DEFINED
#define GrVkDescriptorPool_DEFINED

#include "GrVkResource.h"

#include "vk/GrVkDefines.h"

class GrVkGpu;

/**
 * We require that all descriptor sets are of a single descriptor type. We also use a pool to only
 * make one type of descriptor set. Thus a single VkDescriptorPool will only allocated space for
 * for one type of descriptor.
 */
class GrVkDescriptorPool : public GrVkResource {
public:
    GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count);

    VkDescriptorPool descPool() const { return fDescPool; }

    void reset(const GrVkGpu* gpu);

    // Returns whether or not this descriptor pool could be used, assuming it gets fully reset and
    // not in use by another draw, to support the requested type and count.
    bool isCompatible(VkDescriptorType type, uint32_t count) const;

#ifdef SK_TRACE_VK_RESOURCES
    void dumpInfo() const override {
        SkDebugf("GrVkDescriptorPool: %d, type %d (%d refs)\n", fDescPool, fType,
                 this->getRefCnt());
    }
#endif

private:
    void freeGPUData(const GrVkGpu* gpu) const override;

    VkDescriptorType     fType;
    uint32_t             fCount;
    VkDescriptorPool     fDescPool;

    typedef GrVkResource INHERITED;
};

#endif