Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan backend: on synchronization primitives #1043

Closed
wants to merge 8 commits into from
Closed

Vulkan backend: on synchronization primitives #1043

wants to merge 8 commits into from

Conversation

ParticlePeter
Copy link
Contributor

See details in the commits

Added a macro to switch between unlimited frame rate (VK_PRESENT_MODE_IMMEDIATE_KHR) and limited to 60 fps (VK_PRESENT_MODE_FIFO_KHR). Only the latter mode is guaranteed to be available, but the former one most likely is.
…g report callback

Additional layer, extension and the callback itself are used/created when IMGUI_VULKAN_DEBUG_REPORT is defined. The callback reports seven (potential!) errors which will be fixed with another pull request.
The transition of the swapchain image(s) can happen implicitly in the renderpass. This approach has been stated to be more efficient than using an explicit barrier.
See "Vulkan Programming Guide", Chapter 7: "Graphics Pipelines", section "Renderpasses".
…ribute. This is only meaningful when we present directly to multiple swapchains. In that case we can an VkResult per swapchain.
…submission through semaphores.

To maintain maximum frame rate we render to the last acquired swapchain image but present the last but one drawn image. This behavior is optional through conditional compilation macros.
@ParticlePeter
Copy link
Contributor Author

ParticlePeter commented Feb 27, 2017

Added mandatory semaphores between vkQueueSubmit and vkQueuePresentKHR. To maintain a high frame rate in this single threaded scenario and efficiently overlap CPU and GPU work (still single threaded) we draw into the last acquired swapchain image but display the last but one. All changes made so far are editable, so that we can draw and immediately present the latest acquired image for the cost of less work overlap and hence much lower frame rate. However, the semaphores are required to ensure correctness.

@ocornut
Copy link
Owner

ocornut commented May 1, 2017

@ParticlePeter I am trying to catch up with the various Vulkan related PR but your PR here and most others have multiple commits that seems unrelated to that specific PR. Is that intended?

@ocornut
Copy link
Owner

ocornut commented May 1, 2017

Pasting comment from #1039, same author (now closed)

So I managed to get a similar high performance with the mentioned semaphores (pr #1043). I guess the setup is now working as initially intend by the author. The cost for the high frame rate is a lag of one frame, we render into the last acquired image but display the last but one instead. The former setup had probably a lag as well but at least two frames and at most swapchain image count frames (depends how the driver delivers next swapchain index).
Reasoning: without a semaphore between vkQueueSubmit and vkQueuePresentKHR (using the same swapchain index as frambuffer index and present image index) the swapchain image would have been presented as soon as the command buffers SUBMITTED but not FINISHED. Assuming that an image presentation is (much) faster than a graphics pipeline render task, we would see the image drawn one complete acquiring cycle ago.

ocornut added a commit that referenced this pull request May 1, 2017
@ocornut
Copy link
Owner

ocornut commented May 1, 2017

This is now merged (had to cherry-pick individual commits). Please in the future try to make the PR saner to work with :) Thanks!

I also fixed an extra validation warning I got.

Message: vkCreateSampler(): The samplerAnisotropy feature is not enabled, so the maxAnisotropy member of the VkSamplerCreateInfo structure must be 1.0 but is 0.000000.

@ocornut ocornut closed this May 1, 2017
@ParticlePeter
Copy link
Contributor Author

Hello and sorry for the generated work. I created in total three pull request. All the commits per pull request were meant to be accepted, I didn't mean you to cherry pick, what was the issue?

@ocornut
Copy link
Owner

ocornut commented May 2, 2017

With Git a PR is associated to a whole branch, so further commits in the branch gets added to the PR. So some of the commits here were duplicated 3 times. It's a classic confusing things with GIT, everyone makes the mistake once.

I could probably have done without cherry-picking but it's also an easy way for me to "process" the changes one by one as I review them in situations where I am utterly confused by the sum of the whole.

All good now (I think!).

@ParticlePeter
Copy link
Contributor Author

I am aware of the fact with the commits, but I have not found a good working procedure so far. Lets say PR2 branched from PR1, after that PR1 got some more commits which should be available in PR2 as well. So how to do that without hassle for you the origin maintainer?

@MrSapps
Copy link

MrSapps commented May 2, 2017

Make a branch for both (and to create the PRs from), and then have a "staging" branch that you merge both into for testing. Thats my usual flow.

@ParticlePeter
Copy link
Contributor Author

Sounds reasonable, thanks, I'll try that.

@ocornut ocornut added the vulkan label Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants