Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrVkDescriptorSetManager Class Reference

#include <GrVkDescriptorSetManager.h>

Public Member Functions

 ~GrVkDescriptorSetManager ()
 
void release (GrVkGpu *gpu)
 
VkDescriptorSetLayout layout () const
 
const GrVkDescriptorSetgetDescriptorSet (GrVkGpu *gpu, const Handle &handle)
 
void recycleDescriptorSet (const GrVkDescriptorSet *)
 
bool isCompatible (VkDescriptorType type, const GrVkUniformHandler *) const
 
bool isZeroSampler () const
 

Static Public Member Functions

static GrVkDescriptorSetManagerCreateUniformManager (GrVkGpu *gpu)
 
static GrVkDescriptorSetManagerCreateSamplerManager (GrVkGpu *gpu, VkDescriptorType type, const GrVkUniformHandler &)
 
static GrVkDescriptorSetManagerCreateZeroSamplerManager (GrVkGpu *gpu)
 
static GrVkDescriptorSetManagerCreateInputManager (GrVkGpu *gpu)
 

Detailed Description

This class handles the allocation of descriptor sets for a given VkDescriptorSetLayout. It will try to reuse previously allocated descriptor sets if they are no longer in use by other objects.

Definition at line 26 of file GrVkDescriptorSetManager.h.

Constructor & Destructor Documentation

◆ ~GrVkDescriptorSetManager()

GrVkDescriptorSetManager::~GrVkDescriptorSetManager ( )
inline

Definition at line 38 of file GrVkDescriptorSetManager.h.

38{}

Member Function Documentation

◆ CreateInputManager()

GrVkDescriptorSetManager * GrVkDescriptorSetManager::CreateInputManager ( GrVkGpu gpu)
static

Definition at line 47 of file GrVkDescriptorSetManager.cpp.

47 {
48 STArray<1, uint32_t> visibilities;
51 return Create(gpu, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, visibilities, samplers);
52}
@ kFragment_GrShaderFlag
Definition: GrTypesPriv.h:287
@ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
Definition: vulkan_core.h:2135

◆ CreateSamplerManager()

GrVkDescriptorSetManager * GrVkDescriptorSetManager::CreateSamplerManager ( GrVkGpu gpu,
VkDescriptorType  type,
const GrVkUniformHandler uniformHandler 
)
static

Definition at line 29 of file GrVkDescriptorSetManager.cpp.

30 {
31 STArray<4, uint32_t> visibilities;
32 STArray<4, const GrVkSampler*> immutableSamplers;
34 for (int i = 0 ; i < uniformHandler.numSamplers(); ++i) {
35 visibilities.push_back(uniformHandler.samplerVisibility(i));
36 immutableSamplers.push_back(uniformHandler.immutableSampler(i));
37 }
38 return Create(gpu, type, visibilities, immutableSamplers);
39}
#define SkASSERT(cond)
Definition: SkAssert.h:116
GLenum type
@ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
Definition: vulkan_core.h:2126

◆ CreateUniformManager()

GrVkDescriptorSetManager * GrVkDescriptorSetManager::CreateUniformManager ( GrVkGpu gpu)
static

Definition at line 21 of file GrVkDescriptorSetManager.cpp.

21 {
22 STArray<1, uint32_t> visibilities;
24 visibilities.push_back(stages);
26 return Create(gpu, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, visibilities, samplers);
27}
@ kVertex_GrShaderFlag
Definition: GrTypesPriv.h:286
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan_core.h:2131

◆ CreateZeroSamplerManager()

GrVkDescriptorSetManager * GrVkDescriptorSetManager::CreateZeroSamplerManager ( GrVkGpu gpu)
static

Definition at line 41 of file GrVkDescriptorSetManager.cpp.

41 {
42 TArray<uint32_t> visibilities;
43 TArray<const GrVkSampler*> immutableSamplers;
44 return Create(gpu, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, visibilities, immutableSamplers);
45}

◆ getDescriptorSet()

const GrVkDescriptorSet * GrVkDescriptorSetManager::getDescriptorSet ( GrVkGpu gpu,
const Handle &  handle 
)

Definition at line 228 of file GrVkDescriptorSetManager.cpp.

229 {
230 const GrVkDescriptorSet* ds = nullptr;
231 int count = fFreeSets.size();
232 if (count > 0) {
233 ds = fFreeSets[count - 1];
234 fFreeSets.removeShuffle(count - 1);
235 } else {
236 VkDescriptorSet vkDS;
237 if (!fPoolManager.getNewDescriptorSet(gpu, &vkDS)) {
238 return nullptr;
239 }
240
241 ds = new GrVkDescriptorSet(gpu, vkDS, fPoolManager.fPool, handle);
242 }
243 SkASSERT(ds);
244 return ds;
245}
int count
Definition: FontMgrTest.cpp:50
void removeShuffle(int n)
Definition: SkTArray.h:188
int size() const
Definition: SkTArray.h:421

◆ isCompatible()

bool GrVkDescriptorSetManager::isCompatible ( VkDescriptorType  type,
const GrVkUniformHandler uniHandler 
) const

Definition at line 268 of file GrVkDescriptorSetManager.cpp.

269 {
270 SkASSERT(uniHandler);
271 if (type != fPoolManager.fDescType) {
272 return false;
273 }
274
276 if (fBindingVisibilities.size() != uniHandler->numSamplers()) {
277 return false;
278 }
279 for (int i = 0; i < uniHandler->numSamplers(); ++i) {
280 if (uniHandler->samplerVisibility(i) != fBindingVisibilities[i] ||
281 uniHandler->immutableSampler(i) != fImmutableSamplers[i]) {
282 return false;
283 }
284 }
285 return true;
286}

◆ isZeroSampler()

bool GrVkDescriptorSetManager::isZeroSampler ( ) const

Definition at line 288 of file GrVkDescriptorSetManager.cpp.

288 {
289 if (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER != fPoolManager.fDescType) {
290 return false;
291 }
292 if (!fBindingVisibilities.empty()) {
293 return false;
294 }
295 return true;
296}
bool empty() const
Definition: SkTArray.h:199

◆ layout()

VkDescriptorSetLayout GrVkDescriptorSetManager::layout ( ) const
inline

Definition at line 42 of file GrVkDescriptorSetManager.h.

42{ return fPoolManager.fDescLayout; }

◆ recycleDescriptorSet()

void GrVkDescriptorSetManager::recycleDescriptorSet ( const GrVkDescriptorSet descSet)

Definition at line 247 of file GrVkDescriptorSetManager.cpp.

247 {
248 SkASSERT(descSet);
249 fFreeSets.push_back(descSet);
250}

◆ release()

void GrVkDescriptorSetManager::release ( GrVkGpu gpu)

Definition at line 252 of file GrVkDescriptorSetManager.cpp.

252 {
253 fPoolManager.freeGPUResources(gpu);
254
255 for (int i = 0; i < fFreeSets.size(); ++i) {
256 fFreeSets[i]->unref();
257 }
258 fFreeSets.clear();
259
260 for (int i = 0; i < fImmutableSamplers.size(); ++i) {
261 if (fImmutableSamplers[i]) {
262 fImmutableSamplers[i]->unref();
263 }
264 }
265 fImmutableSamplers.clear();
266}

The documentation for this class was generated from the following files: