mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Add present wait support to Vulkan.
This commit is contained in:
parent
2e9e748f62
commit
37227b8a83
2 changed files with 16 additions and 0 deletions
|
|
@ -2124,6 +2124,12 @@ namespace plume {
|
|||
}
|
||||
|
||||
bool VulkanSwapChain::present(uint32_t textureIndex, RenderCommandSemaphore **waitSemaphores, uint32_t waitSemaphoreCount) {
|
||||
constexpr uint64_t MaxFrameDelay = 1;
|
||||
if (commandQueue->device->capabilities.presentWait && (currentPresentId > MaxFrameDelay)) {
|
||||
constexpr uint64_t waitTimeout = 100000000;
|
||||
vkWaitForPresentKHR(commandQueue->device->vk, vk, currentPresentId - MaxFrameDelay, waitTimeout);
|
||||
}
|
||||
|
||||
thread_local std::vector<VkSemaphore> waitSemaphoresVector;
|
||||
waitSemaphoresVector.clear();
|
||||
for (uint32_t i = 0; i < waitSemaphoreCount; i++) {
|
||||
|
|
@ -2138,6 +2144,15 @@ namespace plume {
|
|||
presentInfo.pImageIndices = &textureIndex;
|
||||
presentInfo.pWaitSemaphores = !waitSemaphoresVector.empty() ? waitSemaphoresVector.data() : nullptr;
|
||||
presentInfo.waitSemaphoreCount = uint32_t(waitSemaphoresVector.size());
|
||||
|
||||
VkPresentIdKHR presentId = {};
|
||||
if (commandQueue->device->capabilities.presentWait) {
|
||||
currentPresentId++;
|
||||
presentId.sType = VK_STRUCTURE_TYPE_PRESENT_ID_KHR;
|
||||
presentId.pPresentIds = ¤tPresentId;
|
||||
presentId.swapchainCount = 1;
|
||||
presentInfo.pNext = &presentId;
|
||||
}
|
||||
|
||||
VkResult res;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ namespace plume {
|
|||
VkPresentModeKHR requiredPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
VkCompositeAlphaFlagBitsKHR pickedAlphaFlag = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
std::vector<VulkanTexture> textures;
|
||||
uint64_t currentPresentId = 0;
|
||||
bool immediatePresentModeSupported = false;
|
||||
|
||||
VulkanSwapChain(VulkanCommandQueue *commandQueue, RenderWindow renderWindow, uint32_t textureCount, RenderFormat format);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue