mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- add GroupMemoryBarrierCommand
This commit is contained in:
parent
efa434d47b
commit
c9fd52340e
2 changed files with 24 additions and 0 deletions
|
@ -203,6 +203,8 @@ void DrawerThreads::StopThreads()
|
|||
shutdown_flag = false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DrawerCommandQueue::DrawerCommandQueue(RenderMemory *frameMemory) : FrameMemory(frameMemory)
|
||||
{
|
||||
}
|
||||
|
@ -211,3 +213,13 @@ void *DrawerCommandQueue::AllocMemory(size_t size)
|
|||
{
|
||||
return FrameMemory->AllocMemory<uint8_t>((int)size);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GroupMemoryBarrierCommand::Execute(DrawerThread *thread)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
count++;
|
||||
condition.notify_all();
|
||||
condition.wait(lock, [&]() { return count >= thread->num_cores; });
|
||||
}
|
||||
|
|
|
@ -97,6 +97,18 @@ public:
|
|||
virtual void Execute(DrawerThread *thread) = 0;
|
||||
};
|
||||
|
||||
// Wait for all worker threads before executing next command
|
||||
class GroupMemoryBarrierCommand : public DrawerCommand
|
||||
{
|
||||
public:
|
||||
void Execute(DrawerThread *thread);
|
||||
|
||||
private:
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
size_t count = 0;
|
||||
};
|
||||
|
||||
class DrawerCommandQueue;
|
||||
typedef std::shared_ptr<DrawerCommandQueue> DrawerCommandQueuePtr;
|
||||
|
||||
|
|
Loading…
Reference in a new issue