Flutter Engine
The Flutter Engine
GrVkDescriptorPool.cpp
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
9
12
13
15 uint32_t count) {
16 VkDescriptorPoolSize poolSize;
17 memset(&poolSize, 0, sizeof(VkDescriptorPoolSize));
18 poolSize.descriptorCount = count;
19 poolSize.type = type;
20
22 memset(&createInfo, 0, sizeof(VkDescriptorPoolCreateInfo));
24 createInfo.pNext = nullptr;
25 createInfo.flags = 0;
26 // This is an over/conservative estimate since each set may contain more than count descriptors.
27 createInfo.maxSets = count;
28 createInfo.poolSizeCount = 1;
29 createInfo.pPoolSizes = &poolSize;
30
31 VkDescriptorPool pool;
33 GR_VK_CALL_RESULT(gpu, result, CreateDescriptorPool(gpu->device(), &createInfo, nullptr,
34 &pool));
35 if (result != VK_SUCCESS) {
36 return nullptr;
37 }
38 return new GrVkDescriptorPool(gpu, pool, type, count);
39}
40
41GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorPool pool,
42 VkDescriptorType type, uint32_t count)
43 : INHERITED(gpu), fType(type), fCount(count), fDescPool(pool) {}
44
46 return fType == type && count <= fCount;
47}
48
49void GrVkDescriptorPool::freeGPUData() const {
50 // Destroying the VkDescriptorPool will automatically free and delete any VkDescriptorSets
51 // allocated from the pool.
52 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorPool(fGpu->device(), fDescPool, nullptr));
53}
AutoreleasePool pool
int count
Definition: FontMgrTest.cpp:50
#define GR_VK_CALL(IFACE, X)
Definition: GrVkUtil.h:24
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
#define INHERITED(method,...)
Definition: SkRecorder.cpp:128
GLenum type
static GrVkDescriptorPool * Create(GrVkGpu *gpu, VkDescriptorType type, uint32_t count)
bool isCompatible(VkDescriptorType type, uint32_t count) const
const skgpu::VulkanInterface * vkInterface() const
Definition: GrVkGpu.h:60
VkDevice device() const
Definition: GrVkGpu.h:71
GAsyncResult * result
const VkDescriptorPoolSize * pPoolSizes
Definition: vulkan_core.h:3760
VkDescriptorPoolCreateFlags flags
Definition: vulkan_core.h:3757
VkDescriptorType type
Definition: vulkan_core.h:3750
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
VkDescriptorType
Definition: vulkan_core.h:2124
@ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
Definition: vulkan_core.h:235