From 4fa4dfd71165bfc73c4f397b12f1dd3a2623b711 Mon Sep 17 00:00:00 2001 From: Robert Quill Date: Tue, 27 Aug 2024 15:54:00 +0100 Subject: [PATCH] Move the get*MemoryPropertyFlags functions to the Memory class Signed-off-by: Robert Quill --- src/Image.cpp | 32 -------------------------------- src/Memory.cpp | 32 ++++++++++++++++++++++++++++++++ src/Tensor.cpp | 32 -------------------------------- src/include/kompute/Image.hpp | 2 -- src/include/kompute/Memory.hpp | 2 ++ src/include/kompute/Tensor.hpp | 2 -- 6 files changed, 34 insertions(+), 68 deletions(-) diff --git a/src/Image.cpp b/src/Image.cpp index b8f3f8fe..7d4cf56e 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -396,25 +396,6 @@ Image::getPrimaryImageUsageFlags() } } -vk::MemoryPropertyFlags -Image::getPrimaryMemoryPropertyFlags() -{ - switch (this->mMemoryType) { - case MemoryTypes::eDevice: - return vk::MemoryPropertyFlagBits::eDeviceLocal; - break; - case MemoryTypes::eHost: - return vk::MemoryPropertyFlagBits::eHostVisible | - vk::MemoryPropertyFlagBits::eHostCoherent; - break; - case MemoryTypes::eStorage: - return vk::MemoryPropertyFlagBits::eDeviceLocal; - break; - default: - throw std::runtime_error("Kompute Image invalid image type"); - } -} - vk::ImageUsageFlags Image::getStagingImageUsageFlags() { @@ -428,19 +409,6 @@ Image::getStagingImageUsageFlags() } } -vk::MemoryPropertyFlags -Image::getStagingMemoryPropertyFlags() -{ - switch (this->mMemoryType) { - case MemoryTypes::eDevice: - return vk::MemoryPropertyFlagBits::eHostVisible | - vk::MemoryPropertyFlagBits::eHostCoherent; - break; - default: - throw std::runtime_error("Kompute Image invalid image type"); - } -} - std::shared_ptr Image::getPrimaryImage() { diff --git a/src/Memory.cpp b/src/Memory.cpp index 566d059a..40afbcf6 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -207,6 +207,38 @@ Memory::updateRawData(void* data) } } +vk::MemoryPropertyFlags +Memory::getPrimaryMemoryPropertyFlags() +{ + switch (this->mMemoryType) { + case MemoryTypes::eDevice: + return vk::MemoryPropertyFlagBits::eDeviceLocal; + break; + case MemoryTypes::eHost: + return vk::MemoryPropertyFlagBits::eHostVisible | + vk::MemoryPropertyFlagBits::eHostCoherent; + break; + case MemoryTypes::eStorage: + return vk::MemoryPropertyFlagBits::eDeviceLocal; + break; + default: + throw std::runtime_error("Kompute Memory invalid memory type"); + } +} + +vk::MemoryPropertyFlags +Memory::getStagingMemoryPropertyFlags() +{ + switch (this->mMemoryType) { + case MemoryTypes::eDevice: + return vk::MemoryPropertyFlagBits::eHostVisible | + vk::MemoryPropertyFlagBits::eHostCoherent; + break; + default: + throw std::runtime_error("Kompute Memory invalid memory type"); + } +} + void Memory::destroy(void) { diff --git a/src/Tensor.cpp b/src/Tensor.cpp index 99941084..d4374d60 100644 --- a/src/Tensor.cpp +++ b/src/Tensor.cpp @@ -294,25 +294,6 @@ Tensor::getPrimaryBufferUsageFlags() } } -vk::MemoryPropertyFlags -Tensor::getPrimaryMemoryPropertyFlags() -{ - switch (this->mMemoryType) { - case MemoryTypes::eDevice: - return vk::MemoryPropertyFlagBits::eDeviceLocal; - break; - case MemoryTypes::eHost: - return vk::MemoryPropertyFlagBits::eHostVisible | - vk::MemoryPropertyFlagBits::eHostCoherent; - break; - case MemoryTypes::eStorage: - return vk::MemoryPropertyFlagBits::eDeviceLocal; - break; - default: - throw std::runtime_error("Kompute Tensor invalid tensor type"); - } -} - vk::BufferUsageFlags Tensor::getStagingBufferUsageFlags() { @@ -326,19 +307,6 @@ Tensor::getStagingBufferUsageFlags() } } -vk::MemoryPropertyFlags -Tensor::getStagingMemoryPropertyFlags() -{ - switch (this->mMemoryType) { - case MemoryTypes::eDevice: - return vk::MemoryPropertyFlagBits::eHostVisible | - vk::MemoryPropertyFlagBits::eHostCoherent; - break; - default: - throw std::runtime_error("Kompute Tensor invalid tensor type"); - } -} - std::shared_ptr Tensor::getPrimaryBuffer() { diff --git a/src/include/kompute/Image.hpp b/src/include/kompute/Image.hpp index edba9a16..03c6e3eb 100644 --- a/src/include/kompute/Image.hpp +++ b/src/include/kompute/Image.hpp @@ -322,9 +322,7 @@ class Image : public Memory // Private util functions vk::ImageUsageFlags getPrimaryImageUsageFlags(); - vk::MemoryPropertyFlags getPrimaryMemoryPropertyFlags(); vk::ImageUsageFlags getStagingImageUsageFlags(); - vk::MemoryPropertyFlags getStagingMemoryPropertyFlags(); vk::Format getFormat(); diff --git a/src/include/kompute/Memory.hpp b/src/include/kompute/Memory.hpp index cd64881a..4811e41c 100644 --- a/src/include/kompute/Memory.hpp +++ b/src/include/kompute/Memory.hpp @@ -278,6 +278,8 @@ class Memory void mapRawData(); void unmapRawData(); void updateRawData(void* data); + vk::MemoryPropertyFlags getPrimaryMemoryPropertyFlags(); + vk::MemoryPropertyFlags getStagingMemoryPropertyFlags(); }; } // End namespace kp diff --git a/src/include/kompute/Tensor.hpp b/src/include/kompute/Tensor.hpp index 54da649d..c045c20a 100644 --- a/src/include/kompute/Tensor.hpp +++ b/src/include/kompute/Tensor.hpp @@ -197,9 +197,7 @@ class Tensor : public Memory // Private util functions vk::BufferUsageFlags getPrimaryBufferUsageFlags(); - vk::MemoryPropertyFlags getPrimaryMemoryPropertyFlags(); vk::BufferUsageFlags getStagingBufferUsageFlags(); - vk::MemoryPropertyFlags getStagingMemoryPropertyFlags(); vk::DescriptorBufferInfo constructDescriptorBufferInfo();