Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
skgpu::graphite::VulkanDescriptorPool Class Reference

#include <VulkanDescriptorPool.h>

Inheritance diagram for skgpu::graphite::VulkanDescriptorPool:
SkRefCnt SkRefCntBase

Public Member Functions

VkDescriptorPool descPool ()
 
const VkDescriptorSetLayout * descSetLayout ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< VulkanDescriptorPoolMake (const VulkanSharedContext *, SkSpan< DescriptorData >, VkDescriptorSetLayout)
 

Static Public Attributes

static constexpr int kMaxNumSets = 512
 

Private Member Functions

 ~VulkanDescriptorPool () override
 

Detailed Description

Definition at line 21 of file VulkanDescriptorPool.h.

Member Function Documentation

◆ descPool()

VkDescriptorPool skgpu::graphite::VulkanDescriptorPool::descPool ( )
inline

Definition at line 34 of file VulkanDescriptorPool.h.

34{ return fDescPool; }

◆ descSetLayout()

const VkDescriptorSetLayout * skgpu::graphite::VulkanDescriptorPool::descSetLayout ( )
inline

Definition at line 36 of file VulkanDescriptorPool.h.

36 {
37 SkASSERT(fDescSetLayout != VK_NULL_HANDLE);
38 return &fDescSetLayout;
39 }
#define SkASSERT(cond)
Definition SkAssert.h:116
#define VK_NULL_HANDLE
Definition vulkan_core.h:46

◆ Make()

sk_sp< VulkanDescriptorPool > skgpu::graphite::VulkanDescriptorPool::Make ( const VulkanSharedContext context,
SkSpan< DescriptorData requestedDescCounts,
VkDescriptorSetLayout  layout 
)
static

Given a span of descriptor types and counts, a descriptor pool will be created which houses enough of the descriptor types and quantities requested to allocate the maximum number of sets possible (kMaxNumSets). Counts must be > 0.

Definition at line 15 of file VulkanDescriptorPool.cpp.

17 {
18
19 if (requestedDescCounts.empty()) {
20 return nullptr;
21 }
22
23 // For each requested descriptor type and count, create a VkDescriptorPoolSize struct which
24 // specifies the descriptor type and quantity for pool creation. Multiple pool size structures
25 // may contain the same descriptor type - the pool will be created with enough storage for the
26 // total number of descriptors of each type. Source:
27 // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VkDescriptorPoolSize
28 // Note: The kMaxNumDescriptors limit could be evaded since we do not currently track and check
29 // the cumulative quantities of each type of descriptor, but this is an internal call and it is
30 // highly unexpected for us to exceed this limit in practice.
32 for (size_t i = 0; i < requestedDescCounts.size(); i++) {
33 SkASSERT(requestedDescCounts[i].count > 0);
34 if (requestedDescCounts[i].count > kMaxNumDescriptors) {
35 SkDebugf("The number of descriptors requested, %u, exceeds the maximum allowed (%d).\n",
36 requestedDescCounts[i].count,
37 kMaxNumDescriptors);
38 return nullptr;
39 }
40 VkDescriptorPoolSize& poolSize = poolSizes.push_back();
41 memset(&poolSize, 0, sizeof(VkDescriptorPoolSize));
42 // Map each DescriptorSetType to the appropriate backend VkDescriptorType
43 poolSize.type = DsTypeEnumToVkDs(requestedDescCounts[i].type);
44 // Create a pool large enough to accommodate the maximum possible number of descriptor sets
45 poolSize.descriptorCount = requestedDescCounts[i].count * kMaxNumSets;
46 }
47
49 memset(&createInfo, 0, sizeof(VkDescriptorPoolCreateInfo));
51 createInfo.pNext = nullptr;
52 createInfo.flags = 0;
53 createInfo.maxSets = kMaxNumSets;
54 createInfo.poolSizeCount = requestedDescCounts.size();
55 createInfo.pPoolSizes = &poolSizes.front();
56
57 VkDescriptorPool pool;
59 VULKAN_CALL_RESULT(context,
60 result,
61 CreateDescriptorPool(context->device(),
62 &createInfo,
63 /*const VkAllocationCallbacks*=*/nullptr,
64 &pool));
65 if (result != VK_SUCCESS) {
66 VULKAN_CALL(context->interface(),
67 DestroyDescriptorSetLayout(context->device(), layout, nullptr));
68 return nullptr;
69 }
70 return sk_sp<VulkanDescriptorPool>(new VulkanDescriptorPool(context, pool, layout));
71}
AutoreleasePool pool
int count
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define VULKAN_CALL(IFACE, X)
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
constexpr bool empty() const
Definition SkSpan_impl.h:96
constexpr size_t size() const
Definition SkSpan_impl.h:95
GAsyncResult * result
VkDescriptorType DsTypeEnumToVkDs(DescriptorType type)
const VkDescriptorPoolSize * pPoolSizes
VkDescriptorPoolCreateFlags flags
VkDescriptorType type
VkResult
@ VK_SUCCESS
@ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO

◆ ~VulkanDescriptorPool()

skgpu::graphite::VulkanDescriptorPool::~VulkanDescriptorPool ( )
overrideprivate

Definition at line 80 of file VulkanDescriptorPool.cpp.

80 {
81 // Destroying the VkDescriptorPool will automatically free and delete any VkDescriptorSets
82 // allocated from the pool.
83 VULKAN_CALL(fSharedContext->interface(),
84 DestroyDescriptorPool(fSharedContext->device(), fDescPool, nullptr));
85 if (fDescSetLayout != VK_NULL_HANDLE) {
86 VULKAN_CALL(fSharedContext->interface(),
87 DestroyDescriptorSetLayout(fSharedContext->device(), fDescSetLayout, nullptr));
88 fDescSetLayout = VK_NULL_HANDLE;
89 }
90}
const skgpu::VulkanInterface * interface() const

Member Data Documentation

◆ kMaxNumSets

constexpr int skgpu::graphite::VulkanDescriptorPool::kMaxNumSets = 512
staticconstexpr

Definition at line 24 of file VulkanDescriptorPool.h.


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