Skip to content

Commit db6f92c

Browse files
committed
DescriptorBuildInfo
1 parent 36e05ab commit db6f92c

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

HelloVulkan/Header/DescriptorBuildInfo.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ struct DescriptorSetWrite
1717
VkDescriptorBufferInfo* bufferInfoPtr_ = nullptr;
1818
// If you have an array of buffers/images, descriptorCount_ must be bigger than one
1919
uint32_t descriptorCount_ = 1u;
20-
VkDescriptorType type_;
21-
VkShaderStageFlags shaderFlags_; // TODO rename to stageFlags_
20+
VkDescriptorType descriptorType_;
21+
VkShaderStageFlags shaderStage_;
2222
};
2323

2424
class DescriptorBuildInfo
@@ -46,15 +46,17 @@ class DescriptorBuildInfo
4646
void UpdateImage(const VulkanImage* image, size_t bindingIndex);
4747

4848
// Descriptor indexing
49+
// TODO imageArrays is not stored so you need to supply it again if you update the descriptors
4950
void AddImageArray(
50-
const std::vector<VkDescriptorImageInfo>& imageArrays,
51+
const std::vector<VkDescriptorImageInfo>& imageArray,
5152
VkDescriptorType dsType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
5253
VkShaderStageFlags stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT);
5354

5455
// Raytracing
5556
void AddAccelerationStructure();
5657
void AddAccelerationStructure(VkWriteDescriptorSetAccelerationStructureKHR* asInfo);
5758
void UpdateStorageImage(const VulkanImage* image, size_t bindingIndex);
59+
// TODO asInfo is not stored so you need to supply it again if you update the descriptors
5860
void UpdateAccelerationStructure(VkWriteDescriptorSetAccelerationStructureKHR* asInfo, size_t bindingIndex);
5961

6062
private:

HelloVulkan/Source/DescriptorBuildInfo.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void DescriptorBuildInfo::AddBuffer(
2222
({
2323
.bufferInfoPtr_ = bufferInfo,
2424
.descriptorCount_ = 1u,
25-
.type_ = dsType,
26-
.shaderFlags_ = stageFlags
25+
.descriptorType_ = dsType,
26+
.shaderStage_ = stageFlags
2727
});
2828
}
2929

@@ -45,25 +45,25 @@ void DescriptorBuildInfo::AddImage(
4545
({
4646
.imageInfoPtr_ = imageInfo,
4747
.descriptorCount_ = 1u,
48-
.type_ = dsType,
49-
.shaderFlags_ = stageFlags
48+
.descriptorType_ = dsType,
49+
.shaderStage_ = stageFlags
5050
});
5151
}
5252

5353
// Special case for descriptor indexing
5454
void DescriptorBuildInfo::AddImageArray(
55-
const std::vector<VkDescriptorImageInfo>& imageArrays,
55+
const std::vector<VkDescriptorImageInfo>& imageArray,
5656
VkDescriptorType dsType,
5757
VkShaderStageFlags stageFlags)
5858
{
59-
imageArrays_ = imageArrays;
59+
imageArrays_ = imageArray;
6060

6161
writes_.push_back
6262
({
6363
.imageInfoPtr_ = imageArrays_.data(),
6464
.descriptorCount_ = static_cast<uint32_t>(imageArrays_.size()),
65-
.type_ = dsType,
66-
.shaderFlags_ = stageFlags
65+
.descriptorType_ = dsType,
66+
.shaderStage_ = stageFlags
6767
});
6868
}
6969

@@ -73,8 +73,8 @@ void DescriptorBuildInfo::AddAccelerationStructure()
7373
writes_.push_back
7474
({
7575
.descriptorCount_ = 1u,
76-
.type_ = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
77-
.shaderFlags_ = VK_SHADER_STAGE_RAYGEN_BIT_KHR
76+
.descriptorType_ = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
77+
.shaderStage_ = VK_SHADER_STAGE_RAYGEN_BIT_KHR
7878
});
7979
}
8080

@@ -85,8 +85,8 @@ void DescriptorBuildInfo::AddAccelerationStructure(VkWriteDescriptorSetAccelerat
8585
({
8686
.pNext_ = asInfo,
8787
.descriptorCount_ = 1u,
88-
.type_ = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
89-
.shaderFlags_ = VK_SHADER_STAGE_RAYGEN_BIT_KHR
88+
.descriptorType_ = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
89+
.shaderStage_ = VK_SHADER_STAGE_RAYGEN_BIT_KHR
9090
});
9191
}
9292

HelloVulkan/Source/VulkanDescriptor.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ void VulkanDescriptor::CreatePoolAndLayout(
1919
// Create pool
2020
for (auto& write : buildInfo.writes_)
2121
{
22-
if (write.type_ == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)
22+
if (write.descriptorType_ == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)
2323
{
2424
uboCount++;
2525
}
26-
else if(write.type_ == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
26+
else if(write.descriptorType_ == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
2727
{
2828
ssboCount++;
2929
}
30-
else if (write.type_ == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
30+
else if (write.descriptorType_ == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
3131
{
3232
samplerCount++;
3333
}
34-
else if (write.type_ == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR)
34+
else if (write.descriptorType_ == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR)
3535
{
3636
accelerationStructureCount++;
3737
}
38-
else if (write.type_ == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE)
38+
else if (write.descriptorType_ == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE)
3939
{
4040
storageImageCount++;
4141
}
@@ -112,8 +112,8 @@ void VulkanDescriptor::CreatePoolAndLayout(
112112
CreateDescriptorSetLayoutBinding
113113
(
114114
bindingIndex++,
115-
write.type_,
116-
write.shaderFlags_,
115+
write.descriptorType_,
116+
write.shaderStage_,
117117
write.descriptorCount_
118118
)
119119
);
@@ -171,7 +171,7 @@ void VulkanDescriptor::UpdateSet(
171171
.dstBinding = bindIndex++,
172172
.dstArrayElement = 0,
173173
.descriptorCount = buildInfo.writes_[i].descriptorCount_,
174-
.descriptorType = buildInfo.writes_[i].type_,
174+
.descriptorType = buildInfo.writes_[i].descriptorType_,
175175
.pImageInfo = buildInfo.writes_[i].imageInfoPtr_,
176176
.pBufferInfo = buildInfo.writes_[i].bufferInfoPtr_,
177177
.pTexelBufferView = nullptr

0 commit comments

Comments
 (0)