mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 23:56:36 +00:00
Backends: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous validation layer. (#7189, #4238)
This commit is contained in:
parent
e8dd47effa
commit
4778560e66
@ -33,6 +33,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (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-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.
|
||||
@ -79,6 +80,9 @@
|
||||
#ifndef IMGUI_DISABLE
|
||||
#include "imgui_impl_vulkan.h"
|
||||
#include <stdio.h>
|
||||
#ifndef IM_MAX
|
||||
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
// Visual Studio warnings
|
||||
#ifdef _MSC_VER
|
||||
@ -400,16 +404,17 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
||||
VkMemoryRequirements req;
|
||||
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
||||
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
||||
VkDeviceSize size = IM_MAX(v->MinAllocationSize, req.size);
|
||||
VkMemoryAllocateInfo alloc_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);
|
||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
||||
check_vk_result(err);
|
||||
|
||||
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
||||
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)
|
||||
@ -669,7 +674,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
||||
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
||||
VkMemoryAllocateInfo alloc_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);
|
||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
||||
check_vk_result(err);
|
||||
@ -710,7 +715,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
||||
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
||||
VkMemoryAllocateInfo alloc_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);
|
||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
||||
check_vk_result(err);
|
||||
|
@ -71,6 +71,7 @@ struct ImGui_ImplVulkan_InitInfo
|
||||
// Allocation, Debugging
|
||||
const VkAllocationCallbacks* Allocator;
|
||||
void (*CheckVkResultFn)(VkResult err);
|
||||
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||
};
|
||||
|
||||
// Called by user code
|
||||
|
@ -96,6 +96,8 @@ Other changes:
|
||||
compiling in MBCS mode. (#7174) [@kimidaisuki22]
|
||||
- Backends: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs
|
||||
vkDestroyCommandPool(). (#7075) [@FoonTheRaccoon]
|
||||
- Backends: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous
|
||||
"best practice" validation layer. (#7189, #4238) [@philae-ael]
|
||||
- Backends: WebGPU: Fixed wgpuRenderPassEncoderSetScissorRect() crash when rendering modal
|
||||
window's dimming layer, which has an unclipped value in ImDrawCmd::ClipRect. (#7191) [@aparis69]
|
||||
- Examples: GLFW+Emscripten: Fixed examples not consistently resizing according to host canvas.
|
||||
|
Loading…
Reference in New Issue
Block a user