Skip to content

Commit 13d55aa

Browse files
committed
[ET-VK] Removing unnecessary and redundant members from VulkanBuffer and ParamsBuffer.
This diff removes unnecessary and redundant members from VulkanBuffer and ParamsBuffer. Differential Revision: [D66557456](https://our.internmc.facebook.com/intern/diff/D66557456/) ghstack-source-id: 255708869 Pull Request resolved: #7144
1 parent 3e53705 commit 13d55aa

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ VulkanBuffer::VulkanBuffer(
3232
: buffer_properties_({
3333
size,
3434
0u,
35-
size,
36-
usage,
35+
size
3736
}),
3837
allocator_(vma_allocator),
3938
memory_{},
@@ -52,7 +51,7 @@ VulkanBuffer::VulkanBuffer(
5251
nullptr, // pNext
5352
0u, // flags
5453
buffer_properties_.size, // size
55-
buffer_properties_.buffer_usage, // usage
54+
usage, // usage
5655
VK_SHARING_MODE_EXCLUSIVE, // sharingMode
5756
0u, // queueFamilyIndexCount
5857
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)