|
@@ -33,6 +33,7 @@
|
|
|
|
|
|
// CHANGELOG
|
|
// CHANGELOG
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
+// 2024-01-03: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous "best practice" validation layer. (#7189, #4238)
|
|
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
|
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
|
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
|
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
|
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
|
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
|
@@ -79,6 +80,9 @@
|
|
#ifndef IMGUI_DISABLE
|
|
#ifndef IMGUI_DISABLE
|
|
#include "imgui_impl_vulkan.h"
|
|
#include "imgui_impl_vulkan.h"
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
|
+#ifndef IM_MAX
|
|
|
|
+#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
|
|
|
|
+#endif
|
|
|
|
|
|
// Visual Studio warnings
|
|
// Visual Studio warnings
|
|
#ifdef _MSC_VER
|
|
#ifdef _MSC_VER
|
|
@@ -400,16 +404,17 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|
VkMemoryRequirements req;
|
|
VkMemoryRequirements req;
|
|
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
|
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
|
|
|
+ VkDeviceSize size = IM_MAX(v->MinAllocationSize, req.size);
|
|
VkMemoryAllocateInfo alloc_info = {};
|
|
VkMemoryAllocateInfo alloc_info = {};
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
- alloc_info.allocationSize = req.size;
|
|
|
|
|
|
+ alloc_info.allocationSize = size;
|
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
|
check_vk_result(err);
|
|
check_vk_result(err);
|
|
|
|
|
|
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
|
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
|
check_vk_result(err);
|
|
check_vk_result(err);
|
|
- p_buffer_size = req.size;
|
|
|
|
|
|
+ p_buffer_size = size;
|
|
}
|
|
}
|
|
|
|
|
|
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
|
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
|
@@ -669,7 +674,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
|
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
|
VkMemoryAllocateInfo alloc_info = {};
|
|
VkMemoryAllocateInfo alloc_info = {};
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
- alloc_info.allocationSize = req.size;
|
|
|
|
|
|
+ alloc_info.allocationSize = IM_MAX(v->MinAllocationSize, req.size);
|
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
|
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
|
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
|
check_vk_result(err);
|
|
check_vk_result(err);
|
|
@@ -710,7 +715,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
|
VkMemoryAllocateInfo alloc_info = {};
|
|
VkMemoryAllocateInfo alloc_info = {};
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
- alloc_info.allocationSize = req.size;
|
|
|
|
|
|
+ alloc_info.allocationSize = IM_MAX(v->MinAllocationSize, req.size);
|
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
|
check_vk_result(err);
|
|
check_vk_result(err);
|