mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-12 00:59:41 +01:00
Merge pull request #10068 from unknownbrackets/vulkan-minor
Vulkan: Fix deadlock on resize
This commit is contained in:
1 file changed
+11
-7
@@ -217,13 +217,15 @@ void VulkanRenderManager::StopThread(bool shutdown) {
|
||||
thread_.join();
|
||||
VLOG("thread joined.");
|
||||
|
||||
// Resignal fences for next time around - must be done after join.
|
||||
// Wait for any fences to finish and be resignaled, so we don't have sync issues.
|
||||
for (int i = 0; i < vulkan_->GetInflightFrames(); i++) {
|
||||
auto &frameData = frameData_[i];
|
||||
frameData.readyForRun = false;
|
||||
if (!shutdown && !frameData.readyForFence) {
|
||||
vkDestroyFence(vulkan_->GetDevice(), frameData.fence, nullptr);
|
||||
frameData.fence = vulkan_->CreateFence(true);
|
||||
|
||||
std::unique_lock<std::mutex> lock(frameData.push_mutex);
|
||||
while (!frameData.readyForFence) {
|
||||
VLOG("PUSH: Waiting for frame[%d].readyForFence = 1 (stop)", i);
|
||||
frameData.push_condVar.wait(lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,12 +270,11 @@ VulkanRenderManager::~VulkanRenderManager() {
|
||||
queueRunner_.DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
// TODO: Activate this code.
|
||||
void VulkanRenderManager::ThreadFunc() {
|
||||
setCurrentThreadName("RenderMan");
|
||||
int threadFrame = threadInitFrame_;
|
||||
bool nextFrame = false;
|
||||
while (run_) {
|
||||
while (true) {
|
||||
{
|
||||
if (nextFrame) {
|
||||
threadFrame++;
|
||||
@@ -286,6 +287,10 @@ void VulkanRenderManager::ThreadFunc() {
|
||||
VLOG("PULL: Waiting for frame[%d].readyForRun", threadFrame);
|
||||
frameData.pull_condVar.wait(lock);
|
||||
}
|
||||
if (!frameData.readyForRun && !run_) {
|
||||
// This means we're out of frames to render and run_ is false, so bail.
|
||||
break;
|
||||
}
|
||||
VLOG("PULL: frame[%d].readyForRun = false", threadFrame);
|
||||
frameData.readyForRun = false;
|
||||
// Previously we had a quick exit here that avoided calling Run() if run_ was suddenly false,
|
||||
@@ -656,7 +661,6 @@ void VulkanRenderManager::Finish() {
|
||||
}
|
||||
|
||||
void VulkanRenderManager::Wipe() {
|
||||
int curFrame = vulkan_->GetCurFrame();
|
||||
for (auto step : steps_) {
|
||||
// Need to release held framebuffers.
|
||||
switch (step->stepType) {
|
||||
|
||||
Reference in new issue
Block a user