Skip to content

Commit

Permalink
Move the get*MemoryPropertyFlags functions to the Memory class
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Quill <robert.quill@imgtec.com>
  • Loading branch information
robquill committed Aug 27, 2024
1 parent d8fc662 commit 4fa4dfd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 68 deletions.
32 changes: 0 additions & 32 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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<vk::Image>
Image::getPrimaryImage()
{
Expand Down
32 changes: 32 additions & 0 deletions src/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
32 changes: 0 additions & 32 deletions src/Tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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<vk::Buffer>
Tensor::getPrimaryBuffer()
{
Expand Down
2 changes: 0 additions & 2 deletions src/include/kompute/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions src/include/kompute/Memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ class Memory
void mapRawData();
void unmapRawData();
void updateRawData(void* data);
vk::MemoryPropertyFlags getPrimaryMemoryPropertyFlags();
vk::MemoryPropertyFlags getStagingMemoryPropertyFlags();
};

} // End namespace kp
2 changes: 0 additions & 2 deletions src/include/kompute/Tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 4fa4dfd

Please sign in to comment.