Skip to content

Commit 3be3b92

Browse files
[ET-VK] Removing unnecessary and redundant members from VulkanBuffer and ParamsBuffer. (#7226)
Pull Request resolved: #7144 This diff removes unnecessary and redundant members from VulkanBuffer and ParamsBuffer. ghstack-source-id: 256911526 @exported-using-ghexport Differential Revision: [D66557456](https://our.internmc.facebook.com/intern/diff/D66557456/) Co-authored-by: Vivek Trivedi <[email protected]>
1 parent fcc103d commit 3be3b92

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

backends/vulkan/runtime/api/containers/ParamsBuffer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace api {
2020
class ParamsBuffer final {
2121
private:
2222
Context* context_p_;
23-
size_t nbytes_;
2423
vkapi::VulkanBuffer vulkan_buffer_;
2524

2625
public:
@@ -29,14 +28,12 @@ class ParamsBuffer final {
2928
template <typename Block>
3029
ParamsBuffer(Context* context_p, const Block& block)
3130
: context_p_(context_p),
32-
nbytes_(sizeof(block)),
3331
vulkan_buffer_(
3432
context_p_->adapter_ptr()->vma().create_params_buffer(block)) {}
3533

3634
template <typename Block>
3735
ParamsBuffer(Context* context_p, const VkDeviceSize nbytes)
3836
: context_p_(context_p),
39-
nbytes_(nbytes),
4037
vulkan_buffer_(
4138
context_p_->adapter_ptr()->vma().create_uniform_buffer(nbytes)) {}
4239

@@ -70,7 +67,7 @@ class ParamsBuffer final {
7067
template <typename T>
7168
T read() const {
7269
T val;
73-
if (sizeof(val) != nbytes_) {
70+
if (sizeof(val) != vulkan_buffer_.mem_size()) {
7471
VK_THROW(
7572
"Attempted to store value from ParamsBuffer to type of different size");
7673
}

backends/vulkan/runtime/vk_api/memory/Buffer.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ VulkanBuffer::VulkanBuffer(
2929
const VmaAllocationCreateInfo& allocation_create_info,
3030
const VkBufferUsageFlags usage,
3131
const bool allocate_memory)
32-
: buffer_properties_({
33-
size,
34-
0u,
35-
size,
36-
usage,
37-
}),
32+
: buffer_properties_({size, 0u, size}),
3833
allocator_(vma_allocator),
3934
memory_{},
4035
owns_memory_(allocate_memory),
@@ -52,7 +47,7 @@ VulkanBuffer::VulkanBuffer(
5247
nullptr, // pNext
5348
0u, // flags
5449
buffer_properties_.size, // size
55-
buffer_properties_.buffer_usage, // usage
50+
usage, // usage
5651
VK_SHARING_MODE_EXCLUSIVE, // sharingMode
5752
0u, // queueFamilyIndexCount
5853
nullptr, // pQueueFamilyIndices

backends/vulkan/runtime/vk_api/memory/Buffer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class VulkanBuffer final {
4848
VkDeviceSize size;
4949
VkDeviceSize mem_offset;
5050
VkDeviceSize mem_range;
51-
VkBufferUsageFlags buffer_usage;
5251
};
5352

5453
explicit VulkanBuffer();

0 commit comments

Comments
 (0)