forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hrydgard#16035 from hrydgard/vk-acquire-late
Vulkan: "Acquire" the image from the swapchain as late as possible in the frame
- Loading branch information
Showing
20 changed files
with
393 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "VulkanFrameData.h" | ||
|
||
void FrameData::AcquireNextImage(VulkanContext *vulkan) { | ||
// Get the index of the next available swapchain image, and a semaphore to block command buffer execution on. | ||
VkResult res = vkAcquireNextImageKHR(vulkan->GetDevice(), vulkan->GetSwapchain(), UINT64_MAX, acquireSemaphore, (VkFence)VK_NULL_HANDLE, &curSwapchainImage); | ||
if (res == VK_SUBOPTIMAL_KHR) { | ||
// Hopefully the resize will happen shortly. Ignore - one frame might look bad or something. | ||
WARN_LOG(G3D, "VK_SUBOPTIMAL_KHR returned - ignoring"); | ||
} else if (res == VK_ERROR_OUT_OF_DATE_KHR) { | ||
WARN_LOG(G3D, "VK_ERROR_OUT_OF_DATE_KHR returned - processing the frame, but not presenting"); | ||
skipSwap = true; | ||
} else { | ||
_assert_msg_(res == VK_SUCCESS, "vkAcquireNextImageKHR failed! result=%s", VulkanResultToString(res)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include <mutex> | ||
#include <condition_variable> | ||
|
||
#include "Common/GPU/Vulkan/VulkanContext.h" | ||
|
||
struct VKRStep; | ||
|
||
enum class VKRRunType { | ||
END, | ||
SYNC, | ||
}; | ||
|
||
struct QueueProfileContext { | ||
VkQueryPool queryPool; | ||
std::vector<std::string> timestampDescriptions; | ||
std::string profileSummary; | ||
double cpuStartTime; | ||
double cpuEndTime; | ||
}; | ||
|
||
// Per-frame data, round-robin so we can overlap submission with execution of the previous frame. | ||
struct FrameData { | ||
std::mutex push_mutex; | ||
std::condition_variable push_condVar; | ||
|
||
std::mutex pull_mutex; | ||
std::condition_variable pull_condVar; | ||
|
||
bool readyForFence = true; | ||
bool readyForRun = false; | ||
bool skipSwap = false; | ||
VKRRunType type = VKRRunType::END; | ||
|
||
VkFence fence; | ||
VkFence readbackFence; // Strictly speaking we might only need one of these. | ||
bool readbackFenceUsed = false; | ||
|
||
// These are on different threads so need separate pools. | ||
VkCommandPool cmdPoolInit; // Written to from main thread | ||
VkCommandPool cmdPoolMain; // Written to from render thread, which also submits | ||
|
||
VkCommandBuffer initCmd; | ||
VkCommandBuffer mainCmd; | ||
VkCommandBuffer presentCmd; | ||
|
||
bool hasInitCommands = false; | ||
bool hasPresentCommands = false; | ||
|
||
std::vector<VKRStep *> steps; | ||
|
||
// Swapchain. | ||
bool hasBegun = false; | ||
uint32_t curSwapchainImage = -1; | ||
VkSemaphore acquireSemaphore; // Not owned, shared between all FrameData. | ||
|
||
// Profiling. | ||
QueueProfileContext profile; | ||
bool profilingEnabled_; | ||
|
||
void AcquireNextImage(VulkanContext *vulkan); | ||
}; |
Oops, something went wrong.