upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_bindless.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/vulkan_bindless.h')
-rw-r--r--runtime/src/vulkan_bindless.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h
index 3bf07fa5d..c599eb7c2 100644
--- a/runtime/src/vulkan_bindless.h
+++ b/runtime/src/vulkan_bindless.h
@@ -724,7 +724,7 @@ private:
724 full = true; 724 full = true;
725 grew = true; 725 grew = true;
726 } 726 }
727 const DescriptorTable::Changes changes = table_.take_changes(); 727 DescriptorTable::Changes changes = table_.take_changes();
728 full = full || changes.all; 728 full = full || changes.all;
729 bool recorded = false; 729 bool recorded = false;
730 // The staging buffer is written only for buffers that were just created (first upload or growth): a later 730 // The staging buffer is written only for buffers that were just created (first upload or growth): a later
@@ -732,11 +732,11 @@ private:
732 // flight can be reading bytes the CPU rewrites. 732 // flight can be reading bytes the CPU rewrites.
733 const bool fresh = grew || !table_uploaded_; 733 const bool fresh = grew || !table_uploaded_;
734 const auto upload_all = [&]() { 734 const auto upload_all = [&]() {
735 const std::vector<std::uint32_t> words = table_.build_gpu_buffer();
736 if (fresh) { 735 if (fresh) {
737 std::memcpy(table_buffers_.staging.mapped, words.data(), bytes); 736 table_.write_to_buffer(table_buffers_.staging.mapped);
738 copy_table_range(command_buffer, 0, bytes); 737 copy_table_range(command_buffer, 0, bytes);
739 } else { 738 } else {
739 const std::vector<std::uint32_t> words = table_.build_gpu_buffer();
740 update_table_range(command_buffer, 0, words.data(), bytes); 740 update_table_range(command_buffer, 0, words.data(), bytes);
741 } 741 }
742 recorded = true; 742 recorded = true;
@@ -744,15 +744,16 @@ private:
744 if (full) { 744 if (full) {
745 upload_all(); 745 upload_all();
746 } else if (!changes.slots.empty()) { 746 } else if (!changes.slots.empty()) {
747 std::vector<std::uint32_t> slots = changes.slots; 747 std::vector<std::uint32_t> slots = std::move(changes.slots);
748 std::sort(slots.begin(), slots.end()); 748 std::sort(slots.begin(), slots.end());
749 slots.erase(std::unique(slots.begin(), slots.end()), slots.end()); 749 slots.erase(std::unique(slots.begin(), slots.end()), slots.end());
750 std::vector<std::uint32_t> words;
750 bool staged = true; 751 bool staged = true;
751 for (std::size_t first = 0; staged && first < slots.size();) { 752 for (std::size_t first = 0; staged && first < slots.size();) {
752 std::size_t last = first; 753 std::size_t last = first;
753 while (last + 1 < slots.size() && slots[last + 1] == slots[last] + 1) ++last; 754 while (last + 1 < slots.size() && slots[last + 1] == slots[last] + 1) ++last;
754 const std::uint32_t count = std::uint32_t(last - first + 1); 755 const std::uint32_t count = std::uint32_t(last - first + 1);
755 std::vector<std::uint32_t> words(std::size_t(count) * 10); 756 words.resize(std::size_t(count) * 10);
756 staged = table_.read_slots(slots[first], count, words.data()); 757 staged = table_.read_slots(slots[first], count, words.data());
757 if (staged) { 758 if (staged) {
758 update_table_range(command_buffer, entry_offset(slots[first]), words.data(), 759 update_table_range(command_buffer, entry_offset(slots[first]), words.data(),