Flutter Engine
The Flutter Engine
Functions
GrVkDescriptorSetManager.cpp File Reference
#include "src/gpu/ganesh/vk/GrVkDescriptorSetManager.h"
#include "src/gpu/ganesh/vk/GrVkDescriptorPool.h"
#include "src/gpu/ganesh/vk/GrVkDescriptorSet.h"
#include "src/gpu/ganesh/vk/GrVkGpu.h"
#include "src/gpu/ganesh/vk/GrVkUniformHandler.h"

Go to the source code of this file.

Functions

VkShaderStageFlags visibility_to_vk_stage_flags (uint32_t visibility)
 
static bool get_layout_and_desc_count (GrVkGpu *gpu, VkDescriptorType type, const TArray< uint32_t > &visibilities, const TArray< const GrVkSampler * > &immutableSamplers, VkDescriptorSetLayout *descSetLayout, uint32_t *descCountPerSet)
 

Function Documentation

◆ get_layout_and_desc_count()

static bool get_layout_and_desc_count ( GrVkGpu gpu,
VkDescriptorType  type,
const TArray< uint32_t > &  visibilities,
const TArray< const GrVkSampler * > &  immutableSamplers,
VkDescriptorSetLayout *  descSetLayout,
uint32_t *  descCountPerSet 
)
static

Definition at line 66 of file GrVkDescriptorSetManager.cpp.

71 {
74 uint32_t numBindings = visibilities.size();
75 std::unique_ptr<VkDescriptorSetLayoutBinding[]> dsSamplerBindings(
76 new VkDescriptorSetLayoutBinding[numBindings]);
77 *descCountPerSet = 0;
78 for (uint32_t i = 0; i < numBindings; ++i) {
79 uint32_t visibility = visibilities[i];
80 dsSamplerBindings[i].binding = i;
81 dsSamplerBindings[i].descriptorType = type;
82 dsSamplerBindings[i].descriptorCount = 1;
83 dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(visibility);
85 if (immutableSamplers[i]) {
86 (*descCountPerSet) += gpu->vkCaps().ycbcrCombinedImageSamplerDescriptorCount();
87 dsSamplerBindings[i].pImmutableSamplers = immutableSamplers[i]->samplerPtr();
88 } else {
89 (*descCountPerSet)++;
90 dsSamplerBindings[i].pImmutableSamplers = nullptr;
91 }
92 }
93 }
94
95 VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo;
96 memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo));
98 dsSamplerLayoutCreateInfo.pNext = nullptr;
99 dsSamplerLayoutCreateInfo.flags = 0;
100 dsSamplerLayoutCreateInfo.bindingCount = numBindings;
101 // Setting to nullptr fixes an error in the param checker validation layer. Even though
102 // bindingCount is 0 (which is valid), it still tries to validate pBindings unless it is
103 // null.
104 dsSamplerLayoutCreateInfo.pBindings = numBindings ? dsSamplerBindings.get() : nullptr;
105
106#if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS)
107 // skia:8713
108 __lsan::ScopedDisabler lsanDisabler;
109#endif
112 CreateDescriptorSetLayout(gpu->device(),
113 &dsSamplerLayoutCreateInfo,
114 nullptr,
115 descSetLayout));
116 if (result != VK_SUCCESS) {
117 return false;
118 }
120 static constexpr int kUniformDescPerSet = 1;
121 SkASSERT(kUniformDescPerSet == visibilities.size());
122 // Create Uniform Buffer Descriptor
123 VkDescriptorSetLayoutBinding dsUniBinding;
126 dsUniBinding.descriptorCount = 1;
127 dsUniBinding.stageFlags = visibility_to_vk_stage_flags(visibilities[0]);
128 dsUniBinding.pImmutableSamplers = nullptr;
129
130 VkDescriptorSetLayoutCreateInfo uniformLayoutCreateInfo;
132 uniformLayoutCreateInfo.pNext = nullptr;
133 uniformLayoutCreateInfo.flags = 0;
134 uniformLayoutCreateInfo.bindingCount = 1;
135 uniformLayoutCreateInfo.pBindings = &dsUniBinding;
136
137#if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS)
138 // skia:8713
139 __lsan::ScopedDisabler lsanDisabler;
140#endif
142 GR_VK_CALL_RESULT(gpu, result, CreateDescriptorSetLayout(gpu->device(),
143 &uniformLayoutCreateInfo,
144 nullptr,
145 descSetLayout));
146 if (result != VK_SUCCESS) {
147 return false;
148 }
149
150 *descCountPerSet = kUniformDescPerSet;
151 } else {
153 static constexpr int kInputDescPerSet = 1;
154 SkASSERT(kInputDescPerSet == visibilities.size());
155
156 // Create Input Buffer Descriptor
157 VkDescriptorSetLayoutBinding dsInpuBinding;
158 dsInpuBinding.binding = 0;
160 dsInpuBinding.descriptorCount = 1;
161 SkASSERT(visibilities[0] == kFragment_GrShaderFlag);
162 dsInpuBinding.stageFlags = visibility_to_vk_stage_flags(visibilities[0]);
163 dsInpuBinding.pImmutableSamplers = nullptr;
164
165 VkDescriptorSetLayoutCreateInfo inputLayoutCreateInfo;
167 inputLayoutCreateInfo.pNext = nullptr;
168 inputLayoutCreateInfo.flags = 0;
169 inputLayoutCreateInfo.bindingCount = 1;
170 inputLayoutCreateInfo.pBindings = &dsInpuBinding;
171
172#if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS)
173 // skia:8713
174 __lsan::ScopedDisabler lsanDisabler;
175#endif
177 GR_VK_CALL_RESULT(gpu, result, CreateDescriptorSetLayout(gpu->device(),
178 &inputLayoutCreateInfo,
179 nullptr, descSetLayout));
180 if (result != VK_SUCCESS) {
181 return false;
182 }
183
184 *descCountPerSet = kInputDescPerSet;
185 }
186 return true;
187}
@ kFragment_GrShaderFlag
Definition: GrTypesPriv.h:287
VkShaderStageFlags visibility_to_vk_stage_flags(uint32_t visibility)
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
#define SkASSERT(cond)
Definition: SkAssert.h:116
GLenum type
uint32_t ycbcrCombinedImageSamplerDescriptorCount() const
Definition: GrVkCaps.h:163
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61
VkDevice device() const
Definition: GrVkGpu.h:71
int size() const
Definition: SkTArray.h:421
GAsyncResult * result
VkDescriptorType descriptorType
Definition: vulkan_core.h:3773
const VkSampler * pImmutableSamplers
Definition: vulkan_core.h:3776
VkShaderStageFlags stageFlags
Definition: vulkan_core.h:3775
const VkDescriptorSetLayoutBinding * pBindings
Definition: vulkan_core.h:3784
VkDescriptorSetLayoutCreateFlags flags
Definition: vulkan_core.h:3782
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan_core.h:2131
@ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
Definition: vulkan_core.h:2129
@ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
Definition: vulkan_core.h:2135
@ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
Definition: vulkan_core.h:2126
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
Definition: vulkan_core.h:234

◆ visibility_to_vk_stage_flags()

VkShaderStageFlags visibility_to_vk_stage_flags ( uint32_t  visibility)

Definition at line 54 of file GrVkDescriptorSetManager.cpp.

54 {
56
57 if (visibility & kVertex_GrShaderFlag) {
59 }
60 if (visibility & kFragment_GrShaderFlag) {
62 }
63 return flags;
64}
@ kVertex_GrShaderFlag
Definition: GrTypesPriv.h:286
FlutterSemanticsFlag flags
@ VK_SHADER_STAGE_VERTEX_BIT
Definition: vulkan_core.h:2665
@ VK_SHADER_STAGE_FRAGMENT_BIT
Definition: vulkan_core.h:2669
VkFlags VkShaderStageFlags
Definition: vulkan_core.h:2731