1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/dxvk/dxvk_queue.h
Philip Rebohle 1fe5b74762 Optimized command submission
Command submission now does not synchronize with the device every single
time. Instead, the command list and the fence that was created for it are
added to a queue. A separate thread will then wait for the execution to
complete and return the command list to the device.
2017-12-16 18:10:55 +01:00

52 lines
931 B
C++

#pragma once
#include <condition_variable>
#include <mutex>
#include <queue>
#include <thread>
#include "dxvk_cmdlist.h"
#include "dxvk_sync.h"
namespace dxvk {
class DxvkDevice;
/**
* \brief Submission queue
*
*
*/
class DxvkSubmissionQueue {
public:
DxvkSubmissionQueue(DxvkDevice* device);
~DxvkSubmissionQueue();
void submit(
const Rc<DxvkFence>& fence,
const Rc<DxvkCommandList>& cmdList);
private:
struct Entry {
Rc<DxvkFence> fence;
Rc<DxvkCommandList> cmdList;
};
DxvkDevice* m_device;
std::atomic<bool> m_stopped = { false };
std::mutex m_mutex;
std::condition_variable m_condOnAdd;
std::condition_variable m_condOnTake;
std::queue<Entry> m_entries;
std::thread m_thread;
void threadFunc();
};
}