mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Vulkan: Wait for orderly thread stop on resize.
To be safer, let's just let it finish. We don't actually sync the thread in join(), so it could still be running a frame.
This commit is contained in:
parent
1ab9f102ab
commit
6c1f6618b6
1 changed files with 11 additions and 7 deletions
|
@ -217,14 +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);
|
||||
frameData.readyForFence = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +274,7 @@ 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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue