VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
DescriptorVk Struct Reference

#include <set> More...

#include <ScriptorVk.h>

Classes

struct  ioSP
 

Public Types

typedef std::tuple< LayoutType, ioSPioType
 

Public Member Functions

 DescriptorVk ()
 
 ~DescriptorVk ()
 
bool $createLayout$ (LayoutType type)
 
size_t $createLayout$ (LayoutType type, std::vector< VkDescriptorSetLayoutBinding > &dslb)
 
template<class De >
bool $createPuddle$ (De &desc)
 template<Interface_desc Ma> More...
 
template<class De >
bool $createPuddle$ (De &desc, std::vector< VkDescriptorSetLayoutBinding > &dslb)
 
template<class Ma >
void destroyPuddle (Ma &mat)
 template<Interface_desc Ma> More...
 
VkDescriptorSet & getSet (long id)
 
void createDraft (std::vector< VkPushConstantRange > pushConstantRange={})
 
void destroy ()
 

Public Attributes

VkPipelineLayout draft
 
std::vector< ioSPio
 
std::vector< VkDescriptorSetLayout > layoutSet
 std::unordered_set<layoutType> layoutSet; More...
 
struct {
   long   Layout
 
   long   Set
 
Nums = { 0,0 }
 
_PoolSize PoolSize = { 0,0 }
 

Detailed Description

#include <set>

Definition at line 60 of file ScriptorVk.h.

Member Typedef Documentation

◆ ioType

typedef std::tuple<LayoutType, ioSP> DescriptorVk::ioType

Definition at line 70 of file ScriptorVk.h.

Constructor & Destructor Documentation

◆ DescriptorVk()

DescriptorVk::DescriptorVk ( )

memset(io,NULL, DESC_MAX * sizeof(ioSP));

Definition at line 159 of file ScriptorVk.cpp.

159 : draft(VK_NULL_HANDLE), Nums({ 0,0 }) {
161 io.resize(0);
162 layoutSet.resize(0);
163 log_scr("Constructor Descriptor io %zu layoutSet %x \n", io.size(),layoutSet.size());
164
165};
#define log_scr(...)
Definition: ScriptorVk.h:11
std::vector< VkDescriptorSetLayout > layoutSet
std::unordered_set<layoutType> layoutSet;
Definition: ScriptorVk.h:74
std::vector< ioSP > io
Definition: ScriptorVk.h:72
VkPipelineLayout draft
Definition: ScriptorVk.h:71
struct DescriptorVk::@14 Nums

◆ ~DescriptorVk()

DescriptorVk::~DescriptorVk ( )

Definition at line 167 of file ScriptorVk.cpp.

167{destroy();};
void destroy()
Definition: ScriptorVk.cpp:187

Member Function Documentation

◆ $createLayout$() [1/2]

bool DescriptorVk::$createLayout$ ( LayoutType  type)
inline

Definition at line 102 of file ScriptorVk.h.

102 {
103 std::vector<VkDescriptorSetLayoutBinding> _ = {};
104 if ($DSL.$set$(type, _)) {
105 VkDescriptorSetLayout layout;
106 $DSL.get(layout, type);
107 layoutSet.push_back(layout);
108 }
109 else {
110 log_bad("Failed to create DSL. \n");
111 }
112 return true;
113 };
#define log_bad(...)
Definition: log.hpp:37

◆ $createLayout$() [2/2]

size_t DescriptorVk::$createLayout$ ( LayoutType  type,
std::vector< VkDescriptorSetLayoutBinding > &  dslb 
)
inline

for (auto& v : layoutSet) if (v == layout)return;

Definition at line 115 of file ScriptorVk.h.

115 {
116
117 VkDescriptorSetLayout layout;
118
119
120 if ($DSL.$set$(type, dslb)) {
121 $DSL.get(layout, type);
122 layoutSet.push_back(layout);
123 return layoutSet.size() - 1;
124 };
126 return -1;
127 };

◆ $createPuddle$() [1/2]

template<class De >
bool DescriptorVk::$createPuddle$ ( De &  desc)
inline

template<Interface_desc Ma>

log_scr("LOCK_OPERATOR CreatePuddle %s \n ", type.data());

appendLayoutSet(layout);

Definition at line 132 of file ScriptorVk.h.

132 {
133
134 long orig = InterlockedCompareExchange(&(desc.hach.id), INT32_MAX, -1);
135 if (orig != -1) return false;
136 LayoutType type =desc.type;
137
139 VkDescriptorSetLayout layout;
140
141 std::vector<VkDescriptorSetLayoutBinding> _ = {};
142 if ($DSL.$set$(type, _)) {
143 desc.hach.id = io.size();
144 if (desc.hach.id >= DESC_MAX) {
145 log_bad("Create Layout OVER Limit. \n");
146 };
147 $DSL.get(layout, type);
149 }
150 else {
151 log_bad("Failed to create DSL. \n");
152 }
153
154
155 VkDescriptorSetAllocateInfo allocInfo{};
156 allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
157 allocInfo.descriptorSetCount = 1;
158 allocInfo.pSetLayouts = &layout;
159
160 std::vector<VkDescriptorPoolSize> poolSizes;
161 poolSizes.clear();
162 size_t size = type.size();
163 for (int i = 0; i < size; i++) {
164 if (type[i] == 's') {
165 poolSizes.push_back(vka::plysm::descriptorPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1));
166 }
167 else if (type[i] == 'u') {
168 poolSizes.push_back(vka::plysm::descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1));
169 }
170 else if (type[i] == 't') {
171 poolSizes.push_back(vka::plysm::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1));
172 }
173 else {
174 log_bad("Descriptor_CreateIO::ParseError \n");
175 };
176 };
177
178 VkDescriptorPoolCreateInfo descriptorPoolInfo{};
179 descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
180 descriptorPoolInfo.poolSizeCount = static_cast<uint32_t>(poolSizes.size());
181 descriptorPoolInfo.pPoolSizes = poolSizes.data();
182 descriptorPoolInfo.maxSets = 1;
183
184
185 ioSP puddle = {};
186 VK_CHECK_RESULT(vkCreateDescriptorPool($device, &descriptorPoolInfo, nullptr, &puddle.Pool));
187 allocInfo.descriptorPool = puddle.Pool;
188 VK_CHECK_RESULT(vkAllocateDescriptorSets($device, &allocInfo, &puddle.Set));
189 io.push_back(puddle);
190
191 return true;
192
193 };
#define DESC_MAX
Definition: ScriptorVk.h:14
std::string_view LayoutType

◆ $createPuddle$() [2/2]

template<class De >
bool DescriptorVk::$createPuddle$ ( De &  desc,
std::vector< VkDescriptorSetLayoutBinding > &  dslb 
)
inline

Definition at line 196 of file ScriptorVk.h.

196 {
197
198 long orig = InterlockedCompareExchange(&(desc.hach.id), INT32_MAX, -1);
199 if (orig != -1) return false;
200 LayoutType type = desc.type;
201
202
203 std::vector<VkDescriptorPoolSize> poolSizes;
204 for (auto& v : dslb) poolSizes.push_back(vka::plysm::descriptorPoolSize(v.descriptorType, 1));
205
206 VkDescriptorSetLayout layout = VK_NULL_HANDLE;
207
208 if ($DSL.$set$(type, dslb)) {
209 $DSL.get(layout, type);
210 desc.hach.id = io.size();
211 //appendLayoutSet(layout);
212 if (desc.hach.id >= DESC_MAX) {
213 log_bad("Create Layout OVER Limit. \n");
214 };
215 }
216 else {
217 log_bad("Failed to create DSL. \n");
218 }
219
220 VkDescriptorSetAllocateInfo allocInfo{};
221 allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
222 allocInfo.descriptorSetCount = 1;
223 allocInfo.pSetLayouts = &layout;
224
225 VkDescriptorPoolCreateInfo descriptorPoolInfo{};
226 descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
227 descriptorPoolInfo.poolSizeCount = static_cast<uint32_t>(poolSizes.size());
228 descriptorPoolInfo.pPoolSizes = poolSizes.data();
229 descriptorPoolInfo.maxSets = 1;
230
231
232 ioSP puddle = {};
233 VK_CHECK_RESULT(vkCreateDescriptorPool($device, &descriptorPoolInfo, nullptr, &puddle.Pool));
234 allocInfo.descriptorPool = puddle.Pool;
235 VK_CHECK_RESULT(vkAllocateDescriptorSets($device, &allocInfo, &puddle.Set));
236 io.push_back(puddle);
237
238 return true;
239
240 };

◆ createDraft()

void DescriptorVk::createDraft ( std::vector< VkPushConstantRange >  pushConstantRange = {})

Definition at line 170 of file ScriptorVk.cpp.

170 {
171
172 VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo{};
173
174 uint32_t pcSize = (uint32_t)(pushConstantRange.size());
175 if (pcSize != 0) {
176 pipelineLayoutCreateInfo.pushConstantRangeCount = pcSize;
177 pipelineLayoutCreateInfo.pPushConstantRanges = pushConstantRange.data();
178 }
179
180 pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
181 pipelineLayoutCreateInfo.pSetLayouts = layoutSet.data();
182 pipelineLayoutCreateInfo.setLayoutCount = (uint32_t)layoutSet.size();
183 VK_CHECK_RESULT(vkCreatePipelineLayout($device, &pipelineLayoutCreateInfo, nullptr, &draft));
184};

◆ destroy()

void DescriptorVk::destroy ( )

if(Nums > 0)vkFreeDescriptorSets($device, Pool, Nums, ioSet.data());

Definition at line 187 of file ScriptorVk.cpp.

187 {
188
189 if (draft != VK_NULL_HANDLE) {
190 vkDestroyPipelineLayout($device, draft, nullptr);
191 draft = VK_NULL_HANDLE;
192 }
193
194
195 for (auto& [pool, set] : io) {
196 if (pool != VK_NULL_HANDLE) {
197 vkDestroyDescriptorPool($device, pool, nullptr);
198 pool = VK_NULL_HANDLE;
199 };
200 };
201
203
204
205
206 Nums = { 0,0 };
207
208}

◆ destroyPuddle()

template<class Ma >
void DescriptorVk::destroyPuddle ( Ma &  mat)
inline

template<Interface_desc Ma>

Definition at line 244 of file ScriptorVk.h.

244 {
245 ioSP& sp = io[&mat].Pool;
246 if (sp.Pool != VK_NULL_HANDLE) {
247 vkDestroyDescriptorPool($device, sp.Pool, nullptr);
248 sp.Pool == VK_NULL_HANDLE;
249 mat.active.desc = -1;
250 };
251 };

◆ getSet()

VkDescriptorSet & DescriptorVk::getSet ( long  id)
inline

Definition at line 254 of file ScriptorVk.h.

254 {
255 return io[id].Set;
256 };

Member Data Documentation

◆ draft

VkPipelineLayout DescriptorVk::draft

Definition at line 71 of file ScriptorVk.h.

◆ io

std::vector<ioSP> DescriptorVk::io

Definition at line 72 of file ScriptorVk.h.

◆ Layout

long DescriptorVk::Layout

Definition at line 78 of file ScriptorVk.h.

◆ layoutSet

std::vector<VkDescriptorSetLayout> DescriptorVk::layoutSet

std::unordered_set<layoutType> layoutSet;

Definition at line 74 of file ScriptorVk.h.

◆ 

struct { ... } DescriptorVk::Nums

◆ PoolSize

_PoolSize DescriptorVk::PoolSize = { 0,0 }

Definition at line 82 of file ScriptorVk.h.

◆ Set

long DescriptorVk::Set

Definition at line 79 of file ScriptorVk.h.


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