-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDescriptorSetFactory.cpp
More file actions
54 lines (39 loc) · 1.33 KB
/
DescriptorSetFactory.cpp
File metadata and controls
54 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include"DescriptorSetFactory.h"
DescriptorSetFactory::DescriptorSetFactory(VkDevice& d,std::shared_ptr<DescriptorSetBuilder> b
, std::shared_ptr<DescriptorSetLayoutFactory> lf)
{
builder = b;
layoutFactory = lf;
device = d;
frameIndex = 0;
}
std::shared_ptr<DescriptorSet> DescriptorSetFactory::Create(const DescriptorSetProperty& property)
{
std::shared_ptr<DescriptorSet> descriptorSet = std::make_shared<DescriptorSet>(shared_from_this());
builder->Create(property, descriptorSet->descriptorSet);
descriptorSet->layout = property.layout;
descriptorSet->buffer.resize(property.buffer.size());
descriptorSet->texture.resize(property.texture.size());
for (int i = 0; i < property.buffer.size(); i++)
{
descriptorSet->buffer[i] = property.buffer[i].buffer;
}
for(int i = 0; i < property.texture.size(); i++)
{
descriptorSet->texture[i] = property.texture[i].texture;
}
return descriptorSet;
}
void DescriptorSetFactory::addDefferedDestruct(VkDescriptorSet& descriptorSet)
{
destructList[frameIndex].push_back(descriptorSet);
}
void DescriptorSetFactory::resourceDestruct()
{
frameIndex = (frameIndex == 0) ? 1 : 0; //フレームインデックスを切り替える
for (VkDescriptorSet& descriptorSet : destructList[frameIndex])
{
vkFreeDescriptorSets(device, builder->getPool(), 1, &descriptorSet);
}
destructList[frameIndex].clear();
}