Flutter Engine
The Flutter Engine
GrVkDescriptorSetManager.h
Go to the documentation of this file.
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 GrVkDescriptorSetManager_DEFINED
9#define GrVkDescriptorSetManager_DEFINED
10
17
19class GrVkGpu;
21
22/**
23 * This class handles the allocation of descriptor sets for a given VkDescriptorSetLayout. It will
24 * try to reuse previously allocated descriptor sets if they are no longer in use by other objects.
25 */
27public:
29
32 const GrVkUniformHandler&);
33 // See GrVkResourceProvider::getZeroSamplerDescriptorSetHandle() for more info on what the zero
34 // sampler is for.
37
39
40 void release(GrVkGpu* gpu);
41
42 VkDescriptorSetLayout layout() const { return fPoolManager.fDescLayout; }
43
44 const GrVkDescriptorSet* getDescriptorSet(GrVkGpu* gpu, const Handle& handle);
45
47
49
50 bool isZeroSampler() const;
51
52private:
53 struct DescriptorPoolManager {
54 DescriptorPoolManager(VkDescriptorSetLayout, VkDescriptorType type,
55 uint32_t descCountPerSet);
56
57 ~DescriptorPoolManager() {
58 SkASSERT(!fDescLayout);
59 SkASSERT(!fPool);
60 }
61
62 bool getNewDescriptorSet(GrVkGpu* gpu, VkDescriptorSet* ds);
63
64 void freeGPUResources(GrVkGpu* gpu);
65
66 VkDescriptorSetLayout fDescLayout;
67 VkDescriptorType fDescType;
68 uint32_t fDescCountPerSet;
69 uint32_t fMaxDescriptors;
70 uint32_t fCurrentDescriptorCount;
71 GrVkDescriptorPool* fPool;
72
73 private:
74 enum {
75 kMaxDescriptors = 1024,
76 kStartNumDescriptors = 16, // must be less than kMaxUniformDescriptors
77 };
78
79 bool getNewPool(GrVkGpu* gpu);
80 };
81
82 static GrVkDescriptorSetManager* Create(GrVkGpu* gpu,
84 const skia_private::TArray<uint32_t>& visibilities,
85 const skia_private::TArray<const GrVkSampler*>& immutableSamplers);
86
88 VkDescriptorType, VkDescriptorSetLayout, uint32_t descCountPerSet,
89 const skia_private::TArray<uint32_t>& visibilities,
90 const skia_private::TArray<const GrVkSampler*>& immutableSamplers);
91
92
93 DescriptorPoolManager fPoolManager;
95 skia_private::STArray<4, uint32_t> fBindingVisibilities;
97};
98
99#endif
#define GR_DEFINE_RESOURCE_HANDLE_CLASS(name)
#define SkASSERT(cond)
Definition: SkAssert.h:116
GLenum type
void recycleDescriptorSet(const GrVkDescriptorSet *)
static GrVkDescriptorSetManager * CreateZeroSamplerManager(GrVkGpu *gpu)
const GrVkDescriptorSet * getDescriptorSet(GrVkGpu *gpu, const Handle &handle)
static GrVkDescriptorSetManager * CreateSamplerManager(GrVkGpu *gpu, VkDescriptorType type, const GrVkUniformHandler &)
VkDescriptorSetLayout layout() const
bool isCompatible(VkDescriptorType type, const GrVkUniformHandler *) const
static GrVkDescriptorSetManager * CreateInputManager(GrVkGpu *gpu)
static GrVkDescriptorSetManager * CreateUniformManager(GrVkGpu *gpu)
VkDescriptorType
Definition: vulkan_core.h:2124