mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 00:26:36 +00:00
Fixed resize window validation errors with removing frame prerender once and present last but one frame functionality. Frame rate is still similar.
This commit is contained in:
parent
887712a6f1
commit
b2453d7e8f
@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
#define IMGUI_MAX_POSSIBLE_BACK_BUFFERS 16
|
#define IMGUI_MAX_POSSIBLE_BACK_BUFFERS 16
|
||||||
#define IMGUI_UNLIMITED_FRAME_RATE
|
#define IMGUI_UNLIMITED_FRAME_RATE
|
||||||
//#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
//#define IMGUI_VULKAN_DEBUG_REPORT
|
#define IMGUI_VULKAN_DEBUG_REPORT
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
static VkAllocationCallbacks* g_Allocator = NULL;
|
static VkAllocationCallbacks* g_Allocator = NULL;
|
||||||
static VkInstance g_Instance = VK_NULL_HANDLE;
|
static VkInstance g_Instance = VK_NULL_HANDLE;
|
||||||
@ -568,19 +568,12 @@ static void frame_end()
|
|||||||
static void frame_present()
|
static void frame_present()
|
||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
// If IMGUI_UNLIMITED_FRAME_RATE is defined we present the latest but one frame. Otherwise we present the latest rendered frame
|
|
||||||
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
|
||||||
uint32_t PresentIndex = (g_FrameIndex + IMGUI_VK_QUEUED_FRAMES - 1) % IMGUI_VK_QUEUED_FRAMES;
|
|
||||||
#else
|
|
||||||
uint32_t PresentIndex = g_FrameIndex;
|
|
||||||
#endif // IMGUI_UNLIMITED_FRAME_RATE
|
|
||||||
|
|
||||||
VkSwapchainKHR swapchains[1] = {g_Swapchain};
|
VkSwapchainKHR swapchains[1] = {g_Swapchain};
|
||||||
uint32_t indices[1] = {g_BackbufferIndices[PresentIndex]};
|
uint32_t indices[1] = {g_BackbufferIndices[g_FrameIndex]};
|
||||||
VkPresentInfoKHR info = {};
|
VkPresentInfoKHR info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
info.waitSemaphoreCount = 1;
|
info.waitSemaphoreCount = 1;
|
||||||
info.pWaitSemaphores = &g_RenderCompleteSemaphore[PresentIndex];
|
info.pWaitSemaphores = &g_RenderCompleteSemaphore[g_FrameIndex];
|
||||||
info.swapchainCount = 1;
|
info.swapchainCount = 1;
|
||||||
info.pSwapchains = swapchains;
|
info.pSwapchains = swapchains;
|
||||||
info.pImageIndices = indices;
|
info.pImageIndices = indices;
|
||||||
@ -678,16 +671,6 @@ int main(int, char**)
|
|||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// When IMGUI_UNLIMITED_FRAME_RATE is defined we render into latest image acquired from the swapchain but we display the image which was rendered before.
|
|
||||||
// Hence we must render once and increase the g_FrameIndex without presenting, which we do before entering the render loop.
|
|
||||||
// This is also the reason why frame_end() is split into frame_end() and frame_present(), the later one not being called here.
|
|
||||||
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
|
||||||
ImGui_ImplGlfwVulkan_NewFrame();
|
|
||||||
frame_begin();
|
|
||||||
ImGui_ImplGlfwVulkan_Render(g_CommandBuffer[g_FrameIndex]);
|
|
||||||
frame_end();
|
|
||||||
g_FrameIndex = (g_FrameIndex + 1) % IMGUI_VK_QUEUED_FRAMES;
|
|
||||||
#endif // IMGUI_UNLIMITED_FRAME_RATE
|
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
|
Loading…
Reference in New Issue
Block a user