aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasuonpaa <34128694+asuonpaa@users.noreply.github.com>2020-09-10 12:24:45 +0300
committerGitHub <noreply@github.com>2020-09-10 10:24:45 +0100
commitabadcf3289085a79efb907dd09e31ae8eeee2633 (patch)
tree6ce969d27c656840a36efdafca3f0d421dfc5560
parenta1788ec26a1dd763a38890db64691a4b4a99a945 (diff)
downloadamber-abadcf3289085a79efb907dd09e31ae8eeee2633.tar.gz
Fix dynamic offset order when calling vkCmdBindDescriptorSets (#910)
-rw-r--r--src/vulkan/pipeline.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/vulkan/pipeline.cc b/src/vulkan/pipeline.cc
index 315866e..0bd3e36 100644
--- a/src/vulkan/pipeline.cc
+++ b/src/vulkan/pipeline.cc
@@ -438,11 +438,26 @@ void Pipeline::BindVkDescriptorSets(const VkPipelineLayout& pipeline_layout) {
if (descriptor_set_info_[i].empty)
continue;
- std::vector<uint32_t> dynamic_offsets;
-
+ // Sort descriptors by binding number to get correct order of dynamic
+ // offsets.
+ typedef std::pair<uint32_t, std::vector<uint32_t>> binding_offsets_pair;
+ std::vector<binding_offsets_pair> binding_offsets;
for (const auto& desc : descriptor_set_info_[i].descriptors) {
- for (auto offset : desc->GetDynamicOffsets())
+ binding_offsets.push_back(
+ {desc->GetBinding(), desc->GetDynamicOffsets()});
+ }
+
+ std::sort(std::begin(binding_offsets), std::end(binding_offsets),
+ [](const binding_offsets_pair& a, const binding_offsets_pair& b) {
+ return a.first < b.first;
+ });
+
+ // Add the sorted dynamic offsets.
+ std::vector<uint32_t> dynamic_offsets;
+ for (const auto& binding_offset : binding_offsets) {
+ for (auto offset : binding_offset.second) {
dynamic_offsets.push_back(offset);
+ }
}
device_->GetPtrs()->vkCmdBindDescriptorSets(