From cf7d58cec01eda546bf22d60341a5ab2141f35ef Mon Sep 17 00:00:00 2001 From: Vivek Trivedi <5340687+trivedivivek@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:48:24 -0800 Subject: [PATCH 1/2] [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-poisoned] --- backends/vulkan/runtime/api/containers/ParamsBuffer.h | 5 +---- backends/vulkan/runtime/vk_api/memory/Buffer.cpp | 5 ++--- backends/vulkan/runtime/vk_api/memory/Buffer.h | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/backends/vulkan/runtime/api/containers/ParamsBuffer.h b/backends/vulkan/runtime/api/containers/ParamsBuffer.h index c3f19028ed..fe157c5e01 100644 --- a/backends/vulkan/runtime/api/containers/ParamsBuffer.h +++ b/backends/vulkan/runtime/api/containers/ParamsBuffer.h @@ -20,7 +20,6 @@ namespace api { class ParamsBuffer final { private: Context* context_p_; - size_t nbytes_; vkapi::VulkanBuffer vulkan_buffer_; public: @@ -29,14 +28,12 @@ class ParamsBuffer final { template 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 ParamsBuffer(Context* context_p, const VkDeviceSize nbytes) : context_p_(context_p), - nbytes_(nbytes), vulkan_buffer_( context_p_->adapter_ptr()->vma().create_uniform_buffer(nbytes)) {} @@ -70,7 +67,7 @@ class ParamsBuffer final { template 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"); } diff --git a/backends/vulkan/runtime/vk_api/memory/Buffer.cpp b/backends/vulkan/runtime/vk_api/memory/Buffer.cpp index 9fa3c2ac77..a02467624d 100644 --- a/backends/vulkan/runtime/vk_api/memory/Buffer.cpp +++ b/backends/vulkan/runtime/vk_api/memory/Buffer.cpp @@ -32,8 +32,7 @@ VulkanBuffer::VulkanBuffer( : buffer_properties_({ size, 0u, - size, - usage, + size }), allocator_(vma_allocator), memory_{}, @@ -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 diff --git a/backends/vulkan/runtime/vk_api/memory/Buffer.h b/backends/vulkan/runtime/vk_api/memory/Buffer.h index 347c5dd917..0ef9f7e95e 100644 --- a/backends/vulkan/runtime/vk_api/memory/Buffer.h +++ b/backends/vulkan/runtime/vk_api/memory/Buffer.h @@ -48,7 +48,6 @@ class VulkanBuffer final { VkDeviceSize size; VkDeviceSize mem_offset; VkDeviceSize mem_range; - VkBufferUsageFlags buffer_usage; }; explicit VulkanBuffer(); From 278bd83a8d706a1a9bd86fbebb978b95f247b92f Mon Sep 17 00:00:00 2001 From: Vivek Trivedi <5340687+trivedivivek@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:16:16 -0800 Subject: [PATCH 2/2] Update on "[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-poisoned]