Let's try a mutex. Doesn't completely solve the problem though..

This commit is contained in:
Henrik Rydgård 2017-08-25 16:21:45 +02:00
parent d3672d9e57
commit 72a41cd524
2 changed files with 5 additions and 0 deletions

View file

@ -215,9 +215,11 @@ void VulkanRenderManager::ThreadFunc() {
condVar_.wait(lock);
if (frameAvailable_) {
int frame = threadFrame_;
frameData_[frame].mutex.lock();
frameAvailable_ = false;
Run(frame);
EndFrame(frame);
frameData_[frame].mutex.unlock();
}
}
}
@ -236,6 +238,7 @@ void VulkanRenderManager::BeginFrame() {
;
}
frameData.readyForFence = false;
frameData.mutex.lock();
}
ILOG("Fencing %d", curFrame);
@ -656,6 +659,7 @@ void VulkanRenderManager::Flush() {
Run(curFrame);
EndFrame(curFrame);
} else {
frameData.mutex.unlock();
{
std::unique_lock<std::mutex> lock(mutex_);
frameAvailable_ = true;

View file

@ -335,6 +335,7 @@ private:
// Per-frame data, round-robin so we can overlap submission with execution of the previous frame.
struct FrameData {
std::mutex mutex;
bool readyForFence = true;
VkFence fence;
// These are on different threads so need separate pools.