[Legacy VMA] remove memory alignment, it's pointless and wastes RAM (#391)
All checks were successful
eden-license / license-header (pull_request) Successful in 20s
All checks were successful
eden-license / license-header (pull_request) Successful in 20s
Final cleanups after new VMA. It already takes care of properly aligning, so we no longer need these. Reviewed-on: #391 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev> Co-authored-by: Calchan <denis.dupeyron@gmail.com> Co-committed-by: Calchan <denis.dupeyron@gmail.com>
This commit is contained in:
parent
a823d9bbee
commit
15b4d6fca9
1 changed files with 5 additions and 15 deletions
|
@ -242,11 +242,7 @@ namespace Vulkan {
|
||||||
VmaAllocation allocation{};
|
VmaAllocation allocation{};
|
||||||
VkMemoryPropertyFlags property_flags{};
|
VkMemoryPropertyFlags property_flags{};
|
||||||
|
|
||||||
VkResult result = vmaCreateBuffer(allocator, &ci, &alloc_ci, &handle, &allocation, &alloc_info);
|
vk::Check(vmaCreateBuffer(allocator, &ci, &alloc_ci, &handle, &allocation, &alloc_info));
|
||||||
if (result == VK_ERROR_OUT_OF_DEVICE_MEMORY) {
|
|
||||||
LOG_ERROR(Render_Vulkan, "Out of memory creating buffer (size: {})", ci.size);
|
|
||||||
}
|
|
||||||
vk::Check(result);
|
|
||||||
vmaGetAllocationMemoryProperties(allocator, allocation, &property_flags);
|
vmaGetAllocationMemoryProperties(allocator, allocation, &property_flags);
|
||||||
|
|
||||||
u8 *data = reinterpret_cast<u8 *>(alloc_info.pMappedData);
|
u8 *data = reinterpret_cast<u8 *>(alloc_info.pMappedData);
|
||||||
|
@ -260,36 +256,30 @@ namespace Vulkan {
|
||||||
|
|
||||||
MemoryCommit MemoryAllocator::Commit(const VkMemoryRequirements &reqs, MemoryUsage usage)
|
MemoryCommit MemoryAllocator::Commit(const VkMemoryRequirements &reqs, MemoryUsage usage)
|
||||||
{
|
{
|
||||||
// Adreno stands firm - ensure 4KB alignment for Qualcomm GPUs
|
|
||||||
VkMemoryRequirements adjusted_reqs = reqs;
|
|
||||||
if (device.GetDriverID() == VK_DRIVER_ID_QUALCOMM_PROPRIETARY) {
|
|
||||||
adjusted_reqs.size = Common::AlignUp(reqs.size, 4096);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto vma_usage = MemoryUsageVma(usage);
|
const auto vma_usage = MemoryUsageVma(usage);
|
||||||
VmaAllocationCreateInfo ci{};
|
VmaAllocationCreateInfo ci{};
|
||||||
ci.flags = VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT | MemoryUsageVmaFlags(usage);
|
ci.flags = VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT | MemoryUsageVmaFlags(usage);
|
||||||
ci.usage = vma_usage;
|
ci.usage = vma_usage;
|
||||||
ci.memoryTypeBits = adjusted_reqs.memoryTypeBits & valid_memory_types;
|
ci.memoryTypeBits = reqs.memoryTypeBits & valid_memory_types;
|
||||||
ci.requiredFlags = 0;
|
ci.requiredFlags = 0;
|
||||||
ci.preferredFlags = MemoryUsagePreferredVmaFlags(usage);
|
ci.preferredFlags = MemoryUsagePreferredVmaFlags(usage);
|
||||||
|
|
||||||
VmaAllocation a{};
|
VmaAllocation a{};
|
||||||
VmaAllocationInfo info{};
|
VmaAllocationInfo info{};
|
||||||
|
|
||||||
VkResult res = vmaAllocateMemory(allocator, &adjusted_reqs, &ci, &a, &info);
|
VkResult res = vmaAllocateMemory(allocator, &reqs, &ci, &a, &info);
|
||||||
|
|
||||||
if (res != VK_SUCCESS) {
|
if (res != VK_SUCCESS) {
|
||||||
// Relax 1: drop budget constraint
|
// Relax 1: drop budget constraint
|
||||||
auto ci2 = ci;
|
auto ci2 = ci;
|
||||||
ci2.flags &= ~VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT;
|
ci2.flags &= ~VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT;
|
||||||
res = vmaAllocateMemory(allocator, &adjusted_reqs, &ci2, &a, &info);
|
res = vmaAllocateMemory(allocator, &reqs, &ci2, &a, &info);
|
||||||
|
|
||||||
// Relax 2: if we preferred DEVICE_LOCAL, drop that preference
|
// Relax 2: if we preferred DEVICE_LOCAL, drop that preference
|
||||||
if (res != VK_SUCCESS && (ci.preferredFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
|
if (res != VK_SUCCESS && (ci.preferredFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
|
||||||
auto ci3 = ci2;
|
auto ci3 = ci2;
|
||||||
ci3.preferredFlags &= ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
ci3.preferredFlags &= ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||||
res = vmaAllocateMemory(allocator, &adjusted_reqs, &ci3, &a, &info);
|
res = vmaAllocateMemory(allocator, &reqs, &ci3, &a, &info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue