Skip rendering first vulkan frame when elements off screen #3177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Apologies as I'm rather new to imgui. I ran into this trying my first integration. There is probably a better solution than this work around but I don't know the depths of imgui yet. I'm hoping this PR gets the conversation started and towards the correct fix.
There's a bug with
imgui_impl_vulkan
where if the GUI elements are initially off screen on the first frame, theTotalIdxCount
andTotalVtxCount
are0
. When this happens later on we try and allocate a vulkan buffer with size 0, which Vulkan gives us an error code -2,VK_ERROR_OUT_OF_DEVICE_MEMORY
. (terrible error since size 0 isn't out of memory, it's invalid).Interestingly if we just skip rendering frames where the vertex count is 0
GetDrawData
has vertices again. It looks like imgui repositions off screen elements back into the viewable area? This leads me to the belief that there may be a bug withinGetDrawData
and this hack is covering it up.We can easily reproduce the behavior by placing this ini alongside a built Vulkan example. The
check_vk_result
on line 355/356 fails because of the 0 size passed intovkMapMemory