Skip to content

Commit 5a4d7a7

Browse files
committed
[EK-VT] Adding reserve and append functions to SpecVarList
This diff adds two new functions to the SpecVarList class in the Vulkan runtime library. The first function, reserve, allows the user to reserve a certain amount of space in the SpecVarList before adding any elements. The second function, append, allows the user to add a single SpecVar to the SpecVarList. These functions are useful for optimizing memory usage and improving performance in the Vulkan runtime. Differential Revision: [D70021782](https://our.internmc.facebook.com/intern/diff/D70021782/) ghstack-source-id: 267791088 Pull Request resolved: #8633
1 parent fd6f06c commit 5a4d7a7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

backends/vulkan/runtime/vk_api/Pipeline.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ void SpecVarList::append(const SpecVarList& other) {
174174
vars.insert(vars.end(), other.vars.begin(), other.vars.end());
175175
}
176176

177+
void SpecVarList::reserve(const size_t size) {
178+
vars.reserve(size);
179+
}
180+
181+
void SpecVarList::append(const SpecVar& other) {
182+
vars.push_back(other);
183+
}
184+
177185
std::vector<VkSpecializationMapEntry> SpecVarList::generate_map_entries()
178186
const {
179187
std::vector<VkSpecializationMapEntry> map_entries;

backends/vulkan/runtime/vk_api/Pipeline.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ class SpecVarList final {
8282

8383
void append(const SpecVarList& other);
8484

85+
void reserve(const size_t size);
86+
87+
void append(const SpecVar& other);
88+
8589
std::vector<VkSpecializationMapEntry> generate_map_entries() const;
8690

8791
friend bool operator==(const SpecVarList& lhs, const SpecVarList& rhs);

0 commit comments

Comments
 (0)