mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
vulkan_memory_allocator: Respect bufferImageGranularity
This commit is contained in:
parent
456adb95ff
commit
bb29dcb7f2
2 changed files with 8 additions and 2 deletions
|
@ -228,7 +228,9 @@ void MemoryCommit::Release() {
|
||||||
|
|
||||||
MemoryAllocator::MemoryAllocator(const Device& device_, bool export_allocations_)
|
MemoryAllocator::MemoryAllocator(const Device& device_, bool export_allocations_)
|
||||||
: device{device_}, properties{device_.GetPhysical().GetMemoryProperties()},
|
: device{device_}, properties{device_.GetPhysical().GetMemoryProperties()},
|
||||||
export_allocations{export_allocations_} {}
|
export_allocations{export_allocations_},
|
||||||
|
buffer_image_granularity{
|
||||||
|
device_.GetPhysical().GetProperties().limits.bufferImageGranularity} {}
|
||||||
|
|
||||||
MemoryAllocator::~MemoryAllocator() = default;
|
MemoryAllocator::~MemoryAllocator() = default;
|
||||||
|
|
||||||
|
@ -258,7 +260,9 @@ MemoryCommit MemoryAllocator::Commit(const vk::Buffer& buffer, MemoryUsage usage
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryCommit MemoryAllocator::Commit(const vk::Image& image, MemoryUsage usage) {
|
MemoryCommit MemoryAllocator::Commit(const vk::Image& image, MemoryUsage usage) {
|
||||||
auto commit = Commit(device.GetLogical().GetImageMemoryRequirements(*image), usage);
|
VkMemoryRequirements requirements = device.GetLogical().GetImageMemoryRequirements(*image);
|
||||||
|
requirements.size = Common::AlignUp(requirements.size, buffer_image_granularity);
|
||||||
|
auto commit = Commit(requirements, usage);
|
||||||
image.BindMemory(commit.Memory(), commit.Offset());
|
image.BindMemory(commit.Memory(), commit.Offset());
|
||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ private:
|
||||||
const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties.
|
const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties.
|
||||||
const bool export_allocations; ///< True when memory allocations have to be exported.
|
const bool export_allocations; ///< True when memory allocations have to be exported.
|
||||||
std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations.
|
std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations.
|
||||||
|
VkDeviceSize buffer_image_granularity; // The granularity for adjacent offsets between buffers
|
||||||
|
// and optimal images
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns true when a memory usage is guaranteed to be host visible.
|
/// Returns true when a memory usage is guaranteed to be host visible.
|
||||||
|
|
Loading…
Reference in a new issue