From e9be8d91ef6367cb6c2d5bfbbfb541e86ee5a7f0 Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 9 Oct 2022 09:37:18 +0800 Subject: [PATCH] Avoid using VMA_MEMORY_USAGE_AUTO if possible --- lib/graphics_engine/src/ge_spm_buffer.cpp | 4 ++-- lib/graphics_engine/src/ge_vulkan_array_texture.cpp | 2 +- lib/graphics_engine/src/ge_vulkan_mesh_cache.cpp | 4 ++-- lib/graphics_engine/src/ge_vulkan_texture.cpp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/graphics_engine/src/ge_spm_buffer.cpp b/lib/graphics_engine/src/ge_spm_buffer.cpp index ca80a7424..0dfa2829f 100644 --- a/lib/graphics_engine/src/ge_spm_buffer.cpp +++ b/lib/graphics_engine/src/ge_spm_buffer.cpp @@ -32,7 +32,7 @@ void GESPMBuffer::createVertexIndexBuffer() VkBuffer staging_buffer = VK_NULL_HANDLE; VmaAllocation staging_memory = VK_NULL_HANDLE; VmaAllocationCreateInfo staging_buffer_create_info = {}; - staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO; + staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST; staging_buffer_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT; staging_buffer_create_info.preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; @@ -77,7 +77,7 @@ void GESPMBuffer::createVertexIndexBuffer() vmaFlushAllocation(vk->getVmaAllocator(), staging_memory, 0, total_size); VmaAllocationCreateInfo local_create_info = {}; - local_create_info.usage = VMA_MEMORY_USAGE_AUTO; + local_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE; if (!vk->createBuffer(total_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, local_create_info, m_buffer, diff --git a/lib/graphics_engine/src/ge_vulkan_array_texture.cpp b/lib/graphics_engine/src/ge_vulkan_array_texture.cpp index 094bcfcec..f3361478c 100644 --- a/lib/graphics_engine/src/ge_vulkan_array_texture.cpp +++ b/lib/graphics_engine/src/ge_vulkan_array_texture.cpp @@ -81,7 +81,7 @@ void GEVulkanArrayTexture::reloadInternal(const std::vector& list, VkBuffer staging_buffer = VK_NULL_HANDLE; VmaAllocation staging_buffer_allocation = NULL; VmaAllocationCreateInfo staging_buffer_create_info = {}; - staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO; + staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST; staging_buffer_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT; staging_buffer_create_info.preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; diff --git a/lib/graphics_engine/src/ge_vulkan_mesh_cache.cpp b/lib/graphics_engine/src/ge_vulkan_mesh_cache.cpp index 4e3175bb7..380f348df 100644 --- a/lib/graphics_engine/src/ge_vulkan_mesh_cache.cpp +++ b/lib/graphics_engine/src/ge_vulkan_mesh_cache.cpp @@ -77,7 +77,7 @@ void GEVulkanMeshCache::updateCache() VkBuffer staging_buffer = VK_NULL_HANDLE; VmaAllocation staging_memory = VK_NULL_HANDLE; VmaAllocationCreateInfo staging_buffer_create_info = {}; - staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO; + staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST; staging_buffer_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; @@ -150,7 +150,7 @@ void GEVulkanMeshCache::updateCache() vmaFlushAllocation(m_vk->getVmaAllocator(), staging_memory, 0, offset); VmaAllocationCreateInfo local_create_info = {}; - local_create_info.usage = VMA_MEMORY_USAGE_AUTO; + local_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE; local_create_info.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; if (!m_vk->createBuffer(vbo_size + ibo_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | diff --git a/lib/graphics_engine/src/ge_vulkan_texture.cpp b/lib/graphics_engine/src/ge_vulkan_texture.cpp index 98ac63a15..500eb65fc 100644 --- a/lib/graphics_engine/src/ge_vulkan_texture.cpp +++ b/lib/graphics_engine/src/ge_vulkan_texture.cpp @@ -193,7 +193,7 @@ bool GEVulkanTexture::createTextureImage(uint8_t* texture_data, VkBuffer staging_buffer; VmaAllocation staging_buffer_allocation; VmaAllocationCreateInfo staging_buffer_create_info = {}; - staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO; + staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST; staging_buffer_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT; staging_buffer_create_info.preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; @@ -291,7 +291,7 @@ bool GEVulkanTexture::createImage(VkImageUsageFlags usage) m_vma_info = {}; VmaAllocationCreateInfo alloc_info = {}; - alloc_info.usage = VMA_MEMORY_USAGE_AUTO; + alloc_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE; VkResult result = vmaCreateImage(m_vk->getVmaAllocator(), &image_info, &alloc_info, &m_image, &m_vma_allocation, &m_vma_info); @@ -655,7 +655,7 @@ void GEVulkanTexture::updateTexture(void* data, video::ECOLOR_FORMAT format, VkBuffer staging_buffer; VmaAllocation staging_buffer_allocation; VmaAllocationCreateInfo staging_buffer_create_info = {}; - staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO; + staging_buffer_create_info.usage = VMA_MEMORY_USAGE_AUTO_PREFER_HOST; staging_buffer_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT; staging_buffer_create_info.preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; if (isSingleChannel())