Skip to content

Commit

Permalink
[ET-VK] Removing unnecessary and redundant members from VulkanBuffer …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
trivedivivek committed Dec 2, 2024
1 parent 3e53705 commit 13d55aa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
5 changes: 1 addition & 4 deletions backends/vulkan/runtime/api/containers/ParamsBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace api {
class ParamsBuffer final {
private:
Context* context_p_;
size_t nbytes_;
vkapi::VulkanBuffer vulkan_buffer_;

public:
Expand All @@ -29,14 +28,12 @@ class ParamsBuffer final {
template <typename Block>
ParamsBuffer(Context* context_p, const Block& block)
: context_p_(context_p),
nbytes_(sizeof(block)),
vulkan_buffer_(
context_p_->adapter_ptr()->vma().create_params_buffer(block)) {}

template <typename Block>
ParamsBuffer(Context* context_p, const VkDeviceSize nbytes)
: context_p_(context_p),
nbytes_(nbytes),
vulkan_buffer_(
context_p_->adapter_ptr()->vma().create_uniform_buffer(nbytes)) {}

Expand Down Expand Up @@ -70,7 +67,7 @@ class ParamsBuffer final {
template <typename T>
T read() const {
T val;
if (sizeof(val) != nbytes_) {
if (sizeof(val) != vulkan_buffer_.mem_size()) {
VK_THROW(
"Attempted to store value from ParamsBuffer to type of different size");
}
Expand Down
5 changes: 2 additions & 3 deletions backends/vulkan/runtime/vk_api/memory/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ VulkanBuffer::VulkanBuffer(
: buffer_properties_({
size,
0u,
size,
usage,
size
}),
allocator_(vma_allocator),
memory_{},
Expand All @@ -52,7 +51,7 @@ VulkanBuffer::VulkanBuffer(
nullptr, // pNext
0u, // flags
buffer_properties_.size, // size
buffer_properties_.buffer_usage, // usage
usage, // usage
VK_SHARING_MODE_EXCLUSIVE, // sharingMode
0u, // queueFamilyIndexCount
nullptr, // pQueueFamilyIndices
Expand Down
1 change: 0 additions & 1 deletion backends/vulkan/runtime/vk_api/memory/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class VulkanBuffer final {
VkDeviceSize size;
VkDeviceSize mem_offset;
VkDeviceSize mem_range;
VkBufferUsageFlags buffer_usage;
};

explicit VulkanBuffer();
Expand Down

0 comments on commit 13d55aa

Please sign in to comment.